-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathtypes.ts
612 lines (583 loc) · 14.6 KB
/
types.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
export type Credentials = {
/**
* A token in JWT format that has user claims
*/
idToken: string;
/**
* The token used to make API calls
*/
accessToken: string;
/**
* The type of the token, e.g.: Bearer
*/
tokenType: string;
/**
* Used to denote when the token will expire, as a UNIX timestamp
*/
expiresAt: number;
/**
* The token used to refresh the access token
*/
refreshToken?: string;
/**
* Represents the scope of the current token
*/
scope?: string;
[key: string]: any;
};
export type User = {
name?: string;
givenName?: string;
familyName?: string;
middleName?: string;
nickname?: string;
preferredUsername?: string;
profile?: string;
picture?: string;
website?: string;
email?: string;
emailVerified?: boolean;
gender?: string;
birthdate?: string;
zoneinfo?: string;
locale?: string;
phoneNumber?: string;
phoneNumberVerified?: boolean;
address?: string;
updatedAt?: string;
sub?: string;
[key: string]: any;
};
/**
* Parameters that are sent to a call to the `/authorize` endpoint.
*/
export interface WebAuthorizeParameters {
/**
* Random string to prevent CSRF attacks.
*/
state?: string;
/**
* One-time random value that is used to prevent replay attacks.
*/
nonce?: string;
/**
* The intended API identifier that will be the consumer for the issued access token.
*/
audience?: string;
/**
* The scopes requested for the issued tokens. e.g. `openid profile`
*/
scope?: string;
/**
* The database connection in which to look for users.
*/
connection?: string;
/**
* The maximum age in seconds that the resulting ID token should be issued for.
*/
maxAge?: number;
/**
* The organization in which user's should be authenticated into.
*/
organization?: string;
/**
* The invitation URL for those users who have been invited to join a specific organization.
*/
invitationUrl?: string;
/**
* Specify a custom redirect URL to be used. Normally, you wouldn't need to call this method manually as the default value is autogenerated for you.
*
* If you are using this, ensure a proper redirect URL is constructed in the following format
* Android: {YOUR_APP_PACKAGE_NAME}.auth0://{AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
* iOS: {PRODUCT_BUNDLE_IDENTIFIER}.auth0://{AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
*
* If you have `useLegacyCallbackUrl` set to true then the redirect URL should in the format
* Android: {YOUR_APP_PACKAGE_NAME}://{AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
* iOS: {PRODUCT_BUNDLE_IDENTIFIER}://{AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
*/
redirectUrl?: string;
/**
* Any additional arbitrary parameters to send along in the URL.
*/
additionalParameters?: { [key: string]: string };
}
/**
* Options for controlling the SDK's behaviour when calling the `/authorize` endpoint.
*/
export interface WebAuthorizeOptions {
/**
* The amount of leeway, in seconds, to accommodate potential clock skew when validating an ID token's claims.
* @default 60 seconds.
*/
leeway?: number;
/**
* **iOS only**: Disable Single-Sign-On (SSO). It only affects iOS with versions 13 and above.
* @default `false`
*/
ephemeralSession?: boolean;
/**
* **Android only:** Custom scheme to build the callback URL with.
*/
customScheme?: string;
/**
* This will use older callback URL. See {@link https://github.com/auth0/react-native-auth0/blob/master/MIGRATION_GUIDE.md#callback-url-migration} for more details.
*/
useLegacyCallbackUrl?: boolean;
/**
* **iOS only:** Uses `SFSafariViewController` instead of `ASWebAuthenticationSession`. If empty object is set, the presentationStyle defaults to {@link SafariViewControllerPresentationStyle.fullScreen}
*
* This can be used as a boolean value or as an object which sets the `presentationStyle`. See the examples below for reference
*
* @example
* ```typescript
* await authorize({}, {useSFSafariViewController: true});
* ```
*
* or
*
* @example
* ```typescript
* await authorize({}, {useSFSafariViewController: {presentationStyle: SafariViewControllerPresentationStyle.fullScreen}});
* ```
*/
useSFSafariViewController?:
| {
presentationStyle?: SafariViewControllerPresentationStyle;
}
| boolean;
}
/**
* Parameters for sending to the Auth0 logout endpoint.
*/
export interface ClearSessionParameters {
/**
* If `true`, the user will be signed out of any connected identity providers in addition to their Auth0 session.
* @default `false`
* @see https://auth0.com/docs/authenticate/login/logout/log-users-out-of-idps
*/
federated?: boolean;
/**
* Specify a custom redirect URL to be used. Normally, you wouldn't need to call this method manually as the default value is autogenerated for you.
*
* If you are using this, ensure a proper redirect URL is constructed in the following format
* Android: {YOUR_APP_PACKAGE_NAME}.auth0://{AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
* iOS: {PRODUCT_BUNDLE_IDENTIFIER}.auth0://{AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
*
* If you have `useLegacyCallbackUrl` set to true then the redirect URL should in the format
* Android: {YOUR_APP_PACKAGE_NAME}://{AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
* iOS: {PRODUCT_BUNDLE_IDENTIFIER}://{AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
*/
returnToUrl?: string;
}
/**
* Options for configuring the SDK's clear session behaviour.
*/
export interface ClearSessionOptions {
/**
* **Android only:** Custom scheme to build the callback URL with.
*/
customScheme?: string;
/**
* This will use older callback URL. See {@link https://github.com/auth0/react-native-auth0/blob/master/MIGRATION_GUIDE.md#callback-url-migration} for more details.
*/
useLegacyCallbackUrl?: boolean;
}
export interface GetUserOptions {
id: string;
[key: string]: any;
}
export interface PatchUserOptions {
id: string;
metadata: object;
[key: string]: any;
}
/**
* Options for building a URL for `/authorize`
*/
export interface AuthorizeUrlOptions {
/**
* The response_type value
*/
responseType: string;
/**
* Where the authorization server will redirect back after success or failure.
*/
redirectUri: object;
/**
* Random string to prevent CSRF attacks.
*/
state: object;
/**
* Custom parameters to send to `/authorize`
*/
[key: string]: any;
}
/**
* Options for the logout endpoint
*/
export interface LogoutUrlOptions {
/**
* Whether the logout should include removing session for federated IdP.
*/
federated?: boolean;
/**
* The client identifier of the one requesting the logout
*/
clientId?: string;
/**
* URL where the user is redirected to after logout. It must be declared in you Auth0 Dashboard
*/
returnTo?: string;
/**
* Custom parameters to send to the logout endpoint
*/
[key: string]: any;
}
/**
* Options for the `/oauth/token` endpoint to exchange a code for an access token
*/
export interface ExchangeOptions {
/**
* The code returned by `/authorize`.
*/
code: string;
/**
* The value used to generate the code challenge sent to `/authorize`.
*/
verifier: string;
/**
* The original redirectUri used when calling `/authorize`.
*/
redirectUri: string;
/**
* Custom parameters to send to the /oauth/token endpoint
*/
[key: string]: any;
}
/**
* Options for obtaining user tokens from an external provider's token
*/
export interface ExchangeNativeSocialOptions {
/**
* The token returned by the native social authentication solution
*/
subjectToken: string;
/**
* The identifier that indicates the native social authentication solution
*/
subjectTokenType: string;
/**
* Additional profile attributes to set or override, only on select native social authentication solutions
*/
userProfile?: string;
/**
* The API audience to request
*/
audience?: string;
/**
* The scopes requested for the issued tokens. e.g. `openid profile`
*/
scope?: string;
[key: string]: any;
}
/**
* Options for authenticating using the username & password grant.
*/
export interface PasswordRealmOptions {
/**
* The user's username or email
*/
username: string;
/**
* The user's password
*/
password: string;
/**
* The name of the Realm where to Auth (or connection name)
*/
realm: string;
/**
* The identifier of Resource Server (RS) to be included as audience (aud claim) of the issued access token
*/
audience?: string;
/**
* The scopes requested for the issued tokens. e.g. `openid profile`
*/
scope?: string;
[key: string]: any;
}
/**
* Refresh token parameters
*/
export interface RefreshTokenOptions {
/**
* The issued refresh token
*/
refreshToken: string;
/**
* The scopes requested for the issued tokens. e.g. `openid profile`
*/
scope?: string;
[key: string]: any;
}
/**
* Options for requesting passwordless login using email
*/
export interface PasswordlessWithEmailOptions {
/**
* The email to send the link/code to
*/
email: string;
/**
* The passwordless strategy, either 'link' or 'code'
*/
send?: string;
/**
* Optional parameters, used when strategy is 'linḱ'
*/
authParams?: object;
[key: string]: any;
}
/**
* Options for requesting passwordless login using SMS
*/
export interface PasswordlessWithSMSOptions {
/**
* The phone number to send the link/code to
*/
phoneNumber: string;
/**
* The passwordless strategy, either 'link' or 'code'
*/
send?: string;
/**
* Optional passwordless parameters
*/
authParams?: object;
[key: string]: any;
}
/**
* The options for completing the passwordless login with email request
*/
export interface LoginWithEmailOptions {
/**
* The email where the link/code was received
*/
email: string;
/**
* The code numeric value (OTP)
*/
code: string;
/**
* The API audience to request
*/
audience?: string;
/**
* The scopes to request
*/
scope?: string;
[key: string]: any;
}
/**
* The options for completing the passwordless login with SMS request
*/
export interface LoginWithSMSOptions {
/**
* The phone number where the code was received
*/
phoneNumber: string;
/**
* The code numeric value (OTP)
*/
code: string;
/**
* Optional API audience to request
*/
audience?: string;
/**
* Optional scopes to request
*/
scope?: string;
[key: string]: any;
}
/**
* Options for logging in using an OTP code
*/
export interface LoginWithOTPOptions {
/**
* The token received in the previous login response
*/
mfaToken: string;
/**
* The one time password code provided by the resource owner, typically obtained
* from an MFA application such as Google Authenticator or Guardian.
*/
otp: string;
/**
* The API audience
*/
audience?: string;
[key: string]: any;
}
/**
* Options for logging in using an OOB code
*/
export interface LoginWithOOBOptions {
/**
* The token received in the previous login response
*/
mfaToken: string;
/**
* The out of band code received in the challenge response.
*/
oobCode: string;
/**
* The code used to bind the side channel (used to deliver the challenge) with the
* main channel you are using to authenticate. This is usually an OTP-like code
* delivered as part of the challenge message.
*/
bindingCode?: string;
[key: string]: any;
}
/**
* Options for logging in using a recovery code
*/
export interface LoginWithRecoveryCodeOptions {
/**
* The token received in the previous login response
*/
mfaToken: string;
/**
* The recovery code provided by the end-user.
*/
recoveryCode: string;
[key: string]: any;
}
/**
* Options for multifactor challenge.
*/
export interface MultifactorChallengeOptions {
/**
* The token received in the previous login response
*/
mfaToken: string;
/**
* A whitespace-separated list of the challenges types accepted by your application.
* Accepted challenge types are oob or otp. Excluding this parameter means that your client application
* accepts all supported challenge types.
*/
challengeType?: string;
/**
* The ID of the authenticator to challenge.
*/
authenticatorId?: string;
[key: string]: any;
}
/**
* Options for the revoke refresh token endpoint.
*/
export interface RevokeOptions {
/**
* The user's issued refresh token
*/
refreshToken: string;
[key: string]: any;
}
/**
* Options for accessing the `/userinfo` endpoint.
*/
export interface UserInfoOptions {
/**
* The user's access token
*/
token: string;
}
/**
* Options for resetting a user's password.
*/
export interface ResetPasswordOptions {
/**
* The user's email
*/
email: string;
/**
* The name of the database connection of the user
*/
connection: string;
[key: string]: any;
}
/**
* Options for creating a new user.
*/
export interface CreateUserOptions {
/**
* The user's email
*/
email: string;
/**
* The user's password
*/
password: string;
/**
* The name of the database connection where to create the user
*/
connection: string;
/**
* The user's username
*/
username?: string;
/**
* The user's given name(s)
*/
given_name?: string;
/**
* The user's family name(s)
*/
family_name?: string;
/**
* The user's full name
*/
name?: string;
/**
* The user's nickname
*/
nickname?: string;
/**
* A URL pointing to the user's picture
*/
picture?: string;
/**
* Additional information that will be stored in `user_metadata`
*/
metadata?: object;
[key: string]: any;
}
export type MultifactorChallengeOTPResponse = { challengeType: string };
export type MultifactorChallengeOOBResponse =
MultifactorChallengeOTPResponse & {
oobCode: string;
};
export type MultifactorChallengeOOBWithBindingResponse =
MultifactorChallengeOOBResponse & {
bindingMethod: string;
};
export type MultifactorChallengeResponse =
| MultifactorChallengeOTPResponse
| MultifactorChallengeOOBResponse
| MultifactorChallengeOOBWithBindingResponse;
/**
* Presentation styles for when using SFSafariViewController on iOS.
* For the full description of what each option does, please see {@link https://developer.apple.com/documentation/uikit/uimodalpresentationstyle} for more details
*/
export enum SafariViewControllerPresentationStyle {
automatic = -2,
none,
fullScreen,
pageSheet,
formSheet,
currentContext,
custom,
overFullScreen,
overCurrentContext,
popover,
}