-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.d.ts
52 lines (45 loc) · 1.61 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
export interface TokenProviderResponse {
token: string;
}
export interface ITokenProvider {
fetchToken(userId: string): Promise<TokenProviderResponse>;
}
interface TokenProviderOptions {
url: string;
queryParams?: { [key: string]: any };
headers?: { [key: string]: string };
credentials?: string;
}
export class TokenProvider implements ITokenProvider {
constructor(options: TokenProviderOptions);
fetchToken(userId: string): Promise<TokenProviderResponse>;
}
export enum RegistrationState {
PERMISSION_GRANTED_REGISTERED_WITH_BEAMS = 'PERMISSION_GRANTED_REGISTERED_WITH_BEAMS',
PERMISSION_GRANTED_NOT_REGISTERED_WITH_BEAMS = 'PERMISSION_GRANTED_NOT_REGISTERED_WITH_BEAMS',
PERMISSION_PROMPT_REQUIRED = 'PERMISSION_PROMPT_REQUIRED',
PERMISSION_DENIED = 'PERMISSION_DENIED',
}
export class Client {
instanceId: string;
deviceId: string;
userId: string;
constructor(options: ClientOptions);
start(): Promise<undefined>;
getDeviceId(): Promise<string>;
addDeviceInterest(interest: string): Promise<undefined>;
removeDeviceInterest(interest: string): Promise<undefined>;
getDeviceInterests(): Promise<Array<string>>;
setDeviceInterests(interests: Array<string>): Promise<undefined>;
clearDeviceInterests(): Promise<undefined>;
getUserId(): Promise<string>;
setUserId(userId: string, tokenProvider: ITokenProvider): Promise<undefined>;
stop(): Promise<undefined>;
clearAllState(): Promise<undefined>;
getRegistrationState(): Promise<RegistrationState>;
}
interface ClientOptions {
instanceId: string;
serviceWorkerRegistration?: ServiceWorkerRegistration;
endpointOverride?: string;
}