-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.d.ts
More file actions
80 lines (67 loc) · 1.7 KB
/
types.d.ts
File metadata and controls
80 lines (67 loc) · 1.7 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
declare module 'roll-node' {
type Options = {
apiUrl?: string;
baseUrl?: string;
rollDomain?: string;
userToken?: string;
};
type CurrentSite = {
domain: string;
name: string;
};
type CurrentUser = {
username?: string;
fullName?: string;
dateJoined?: string;
authenticated: boolean;
};
enum LoginMethods {
VERIFICATION_CODE = "VERIFICATION_CODE",
OTP_CODE = "OTP_CODE",
}
type InitLogin = {
availableMethods: LoginMethods[];
};
type Authenticated = {
token: string;
user: CurrentUser;
};
type AuthorizeParams = {
[key: string]: string;
};
enum ApprovalPrompt {
FORCE = "force",
AUTO = "auto",
}
type OAuth2Application = {
clientId: string;
name: string;
skipAuthorization: boolean;
};
type Authorize = {
approvalPrompt: ApprovalPrompt;
redirectUri: string;
responseType: string;
state: string;
codeChallenge: string;
codeChallengeMethod: string;
nonce: string;
scopes: { [scope: string]: string };
application: OAuth2Application;
};
type Authorized = {
uri: string;
};
export class APIURLNotResolvedError extends Error {}
export class FormValidationError extends Error { fields: { [key: string]: string[] } }
export default class Roll {
constructor (options?: Options)
getCurrentSite(): CurrentSite
getCurrentUser(): CurrentUser
initLogin(phoneNumber: string): InitLogin
requestVerificationCode(phoneNumber: string): boolean
verifyVerificationCode(phoneNumber: string, code: string): Authenticated
authorize(params: AuthorizeParams, allow?: false): Authorize
authorize(params: AuthorizeParams, allow: true): Authorized
}
}