@supabase/gotrue-js 2.72.1-rc.1 → 2.73.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main/GoTrueClient.d.ts +7 -1
- package/dist/main/GoTrueClient.d.ts.map +1 -1
- package/dist/main/GoTrueClient.js +114 -33
- package/dist/main/GoTrueClient.js.map +1 -1
- package/dist/main/lib/base64url.d.ts +3 -2
- package/dist/main/lib/base64url.d.ts.map +1 -1
- package/dist/main/lib/base64url.js.map +1 -1
- package/dist/main/lib/errors.d.ts +1 -1
- package/dist/main/lib/errors.d.ts.map +1 -1
- package/dist/main/lib/errors.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +2 -1
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/types.d.ts +329 -314
- package/dist/main/lib/types.d.ts.map +1 -1
- package/dist/main/lib/types.js +17 -0
- package/dist/main/lib/types.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/lib/webauthn.d.ts +274 -0
- package/dist/main/lib/webauthn.d.ts.map +1 -0
- package/dist/main/lib/webauthn.dom.d.ts +583 -0
- package/dist/main/lib/webauthn.dom.d.ts.map +1 -0
- package/dist/main/lib/webauthn.dom.js +4 -0
- package/dist/main/lib/webauthn.dom.js.map +1 -0
- package/dist/main/lib/webauthn.errors.d.ts +80 -0
- package/dist/main/lib/webauthn.errors.d.ts.map +1 -0
- package/dist/main/lib/webauthn.errors.js +265 -0
- package/dist/main/lib/webauthn.errors.js.map +1 -0
- package/dist/main/lib/webauthn.js +702 -0
- package/dist/main/lib/webauthn.js.map +1 -0
- package/dist/module/GoTrueClient.d.ts +7 -1
- package/dist/module/GoTrueClient.d.ts.map +1 -1
- package/dist/module/GoTrueClient.js +120 -39
- package/dist/module/GoTrueClient.js.map +1 -1
- package/dist/module/lib/base64url.d.ts +3 -2
- package/dist/module/lib/base64url.d.ts.map +1 -1
- package/dist/module/lib/base64url.js.map +1 -1
- package/dist/module/lib/errors.d.ts +1 -1
- package/dist/module/lib/errors.d.ts.map +1 -1
- package/dist/module/lib/errors.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +2 -1
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/types.d.ts +329 -314
- package/dist/module/lib/types.d.ts.map +1 -1
- package/dist/module/lib/types.js +17 -0
- package/dist/module/lib/types.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/lib/webauthn.d.ts +274 -0
- package/dist/module/lib/webauthn.d.ts.map +1 -0
- package/dist/module/lib/webauthn.dom.d.ts +583 -0
- package/dist/module/lib/webauthn.dom.d.ts.map +1 -0
- package/dist/module/lib/webauthn.dom.js +3 -0
- package/dist/module/lib/webauthn.dom.js.map +1 -0
- package/dist/module/lib/webauthn.errors.d.ts +80 -0
- package/dist/module/lib/webauthn.errors.d.ts.map +1 -0
- package/dist/module/lib/webauthn.errors.js +257 -0
- package/dist/module/lib/webauthn.errors.js.map +1 -0
- package/dist/module/lib/webauthn.js +685 -0
- package/dist/module/lib/webauthn.js.map +1 -0
- package/package.json +1 -1
- package/src/GoTrueClient.ts +282 -81
- package/src/lib/base64url.ts +4 -2
- package/src/lib/errors.ts +1 -1
- package/src/lib/helpers.ts +2 -1
- package/src/lib/types.ts +465 -353
- package/src/lib/version.ts +1 -1
- package/src/lib/webauthn.dom.ts +636 -0
- package/src/lib/webauthn.errors.ts +317 -0
- package/src/lib/webauthn.ts +929 -0
package/src/lib/types.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import { EIP1193Provider } from './web3/ethereum'
|
|
2
1
|
import { AuthError } from './errors'
|
|
3
2
|
import { Fetch } from './fetch'
|
|
3
|
+
import { EIP1193Provider, EthereumSignInInput, Hex } from './web3/ethereum'
|
|
4
4
|
import type { SolanaSignInInput, SolanaSignInOutput } from './web3/solana'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ServerCredentialCreationOptions,
|
|
7
|
+
ServerCredentialRequestOptions,
|
|
8
|
+
WebAuthnApi,
|
|
9
|
+
} from './webauthn'
|
|
10
|
+
import {
|
|
11
|
+
AuthenticationCredential,
|
|
12
|
+
PublicKeyCredentialCreationOptionsFuture,
|
|
13
|
+
PublicKeyCredentialRequestOptionsFuture,
|
|
14
|
+
RegistrationCredential,
|
|
15
|
+
} from './webauthn.dom'
|
|
6
16
|
|
|
7
17
|
/** One of the providers supported by GoTrue. */
|
|
8
18
|
export type Provider =
|
|
@@ -99,93 +109,83 @@ export type GoTrueClientOptions = {
|
|
|
99
109
|
hasCustomAuthorizationHeader?: boolean
|
|
100
110
|
}
|
|
101
111
|
|
|
102
|
-
|
|
112
|
+
const WeakPasswordReasons = ['length', 'characters', 'pwned'] as const
|
|
113
|
+
|
|
114
|
+
export type WeakPasswordReasons = typeof WeakPasswordReasons[number]
|
|
103
115
|
export type WeakPassword = {
|
|
104
116
|
reasons: WeakPasswordReasons[]
|
|
105
117
|
message: string
|
|
106
118
|
}
|
|
107
119
|
|
|
108
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Resolve mapped types and show the derived keys and their types when hovering in
|
|
122
|
+
* VS Code, instead of just showing the names those mapped types are defined with.
|
|
123
|
+
*/
|
|
124
|
+
export type Prettify<T> = T extends Function ? T : { [K in keyof T]: T[K] }
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* A stricter version of TypeScript's Omit that only allows omitting keys that actually exist.
|
|
128
|
+
* This prevents typos and ensures type safety at compile time.
|
|
129
|
+
* Unlike regular Omit, this will error if you try to omit a non-existent key.
|
|
130
|
+
*/
|
|
131
|
+
export type StrictOmit<T, K extends keyof T> = Omit<T, K>
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* a shared result type that encapsulates errors instead of throwing them, allows you to optionally specify the ErrorType
|
|
135
|
+
*/
|
|
136
|
+
export type RequestResult<T, ErrorType extends Error = AuthError> =
|
|
109
137
|
| {
|
|
110
|
-
data:
|
|
111
|
-
user: User | null
|
|
112
|
-
session: Session | null
|
|
113
|
-
}
|
|
138
|
+
data: T
|
|
114
139
|
error: null
|
|
115
140
|
}
|
|
116
141
|
| {
|
|
117
|
-
data:
|
|
118
|
-
|
|
119
|
-
session: null
|
|
120
|
-
}
|
|
121
|
-
error: AuthError
|
|
142
|
+
data: null
|
|
143
|
+
error: Error extends AuthError ? AuthError : ErrorType
|
|
122
144
|
}
|
|
123
145
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
error: null
|
|
132
|
-
}
|
|
146
|
+
/**
|
|
147
|
+
* similar to RequestResult except it allows you to destructure the possible shape of the success response
|
|
148
|
+
* {@see RequestResult}
|
|
149
|
+
*/
|
|
150
|
+
export type RequestResultSafeDestructure<T> =
|
|
151
|
+
| { data: T; error: null }
|
|
133
152
|
| {
|
|
134
|
-
data: {
|
|
135
|
-
user: null
|
|
136
|
-
session: null
|
|
137
|
-
}
|
|
153
|
+
data: T extends object ? { [K in keyof T]: null } : null
|
|
138
154
|
error: AuthError
|
|
139
155
|
}
|
|
140
156
|
|
|
157
|
+
export type AuthResponse = RequestResultSafeDestructure<{
|
|
158
|
+
user: User | null
|
|
159
|
+
session: Session | null
|
|
160
|
+
}>
|
|
161
|
+
|
|
162
|
+
export type AuthResponsePassword = RequestResultSafeDestructure<{
|
|
163
|
+
user: User | null
|
|
164
|
+
session: Session | null
|
|
165
|
+
weak_password?: WeakPassword | null
|
|
166
|
+
}>
|
|
167
|
+
|
|
141
168
|
/**
|
|
142
169
|
* AuthOtpResponse is returned when OTP is used.
|
|
143
170
|
*
|
|
144
171
|
* {@see AuthResponse}
|
|
145
172
|
*/
|
|
146
|
-
export type AuthOtpResponse =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
| {
|
|
152
|
-
data: { user: null; session: null; messageId?: string | null }
|
|
153
|
-
error: AuthError
|
|
154
|
-
}
|
|
173
|
+
export type AuthOtpResponse = RequestResultSafeDestructure<{
|
|
174
|
+
user: null
|
|
175
|
+
session: null
|
|
176
|
+
messageId?: string | null
|
|
177
|
+
}>
|
|
155
178
|
|
|
156
|
-
export type AuthTokenResponse =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
session: Session
|
|
161
|
-
}
|
|
162
|
-
error: null
|
|
163
|
-
}
|
|
164
|
-
| {
|
|
165
|
-
data: {
|
|
166
|
-
user: null
|
|
167
|
-
session: null
|
|
168
|
-
}
|
|
169
|
-
error: AuthError
|
|
170
|
-
}
|
|
179
|
+
export type AuthTokenResponse = RequestResultSafeDestructure<{
|
|
180
|
+
user: User
|
|
181
|
+
session: Session
|
|
182
|
+
}>
|
|
171
183
|
|
|
172
|
-
export type AuthTokenResponsePassword =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
weakPassword?: WeakPassword
|
|
178
|
-
}
|
|
179
|
-
error: null
|
|
180
|
-
}
|
|
181
|
-
| {
|
|
182
|
-
data: {
|
|
183
|
-
user: null
|
|
184
|
-
session: null
|
|
185
|
-
weakPassword?: null
|
|
186
|
-
}
|
|
187
|
-
error: AuthError
|
|
188
|
-
}
|
|
184
|
+
export type AuthTokenResponsePassword = RequestResultSafeDestructure<{
|
|
185
|
+
user: User
|
|
186
|
+
session: Session
|
|
187
|
+
weakPassword?: WeakPassword
|
|
188
|
+
}>
|
|
189
189
|
|
|
190
190
|
export type OAuthResponse =
|
|
191
191
|
| {
|
|
@@ -203,38 +203,20 @@ export type OAuthResponse =
|
|
|
203
203
|
error: AuthError
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
export type SSOResponse =
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
url: string
|
|
217
|
-
}
|
|
218
|
-
error: null
|
|
219
|
-
}
|
|
220
|
-
| {
|
|
221
|
-
data: null
|
|
222
|
-
error: AuthError
|
|
223
|
-
}
|
|
206
|
+
export type SSOResponse = RequestResult<{
|
|
207
|
+
/**
|
|
208
|
+
* URL to open in a browser which will complete the sign-in flow by
|
|
209
|
+
* taking the user to the identity provider's authentication flow.
|
|
210
|
+
*
|
|
211
|
+
* On browsers you can set the URL to `window.location.href` to take
|
|
212
|
+
* the user to the authentication flow.
|
|
213
|
+
*/
|
|
214
|
+
url: string
|
|
215
|
+
}>
|
|
224
216
|
|
|
225
|
-
export type UserResponse =
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
user: User
|
|
229
|
-
}
|
|
230
|
-
error: null
|
|
231
|
-
}
|
|
232
|
-
| {
|
|
233
|
-
data: {
|
|
234
|
-
user: null
|
|
235
|
-
}
|
|
236
|
-
error: AuthError
|
|
237
|
-
}
|
|
217
|
+
export type UserResponse = RequestResultSafeDestructure<{
|
|
218
|
+
user: User
|
|
219
|
+
}>
|
|
238
220
|
|
|
239
221
|
export interface Session {
|
|
240
222
|
/**
|
|
@@ -262,7 +244,7 @@ export interface Session {
|
|
|
262
244
|
* A timestamp of when the token will expire. Returned when a login is confirmed.
|
|
263
245
|
*/
|
|
264
246
|
expires_at?: number
|
|
265
|
-
token_type:
|
|
247
|
+
token_type: 'bearer'
|
|
266
248
|
|
|
267
249
|
/**
|
|
268
250
|
* When using a separate user storage, accessing properties of this object will throw an error.
|
|
@@ -270,6 +252,22 @@ export interface Session {
|
|
|
270
252
|
user: User
|
|
271
253
|
}
|
|
272
254
|
|
|
255
|
+
const AMRMethods = [
|
|
256
|
+
'password',
|
|
257
|
+
'otp',
|
|
258
|
+
'oauth',
|
|
259
|
+
'totp',
|
|
260
|
+
'mfa/totp',
|
|
261
|
+
'mfa/phone',
|
|
262
|
+
'mfa/webauthn',
|
|
263
|
+
'anonymous',
|
|
264
|
+
'sso/saml',
|
|
265
|
+
'magiclink',
|
|
266
|
+
'web3',
|
|
267
|
+
] as const
|
|
268
|
+
|
|
269
|
+
export type AMRMethod = typeof AMRMethods[number] | (string & {})
|
|
270
|
+
|
|
273
271
|
/**
|
|
274
272
|
* An authentication methord reference (AMR) entry.
|
|
275
273
|
*
|
|
@@ -280,7 +278,7 @@ export interface Session {
|
|
|
280
278
|
*/
|
|
281
279
|
export interface AMREntry {
|
|
282
280
|
/** Authentication method name. */
|
|
283
|
-
method:
|
|
281
|
+
method: AMRMethod
|
|
284
282
|
|
|
285
283
|
/**
|
|
286
284
|
* Timestamp when the method was successfully used. Represents number of
|
|
@@ -302,6 +300,20 @@ export interface UserIdentity {
|
|
|
302
300
|
updated_at?: string
|
|
303
301
|
}
|
|
304
302
|
|
|
303
|
+
const FactorTypes = ['totp', 'phone', 'webauthn'] as const
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Type of factor. `totp` and `phone` supported with this version
|
|
307
|
+
*/
|
|
308
|
+
export type FactorType = typeof FactorTypes[number]
|
|
309
|
+
|
|
310
|
+
const FactorVerificationStatuses = ['verified', 'unverified'] as const
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`
|
|
314
|
+
*/
|
|
315
|
+
type FactorVerificationStatus = typeof FactorVerificationStatuses[number]
|
|
316
|
+
|
|
305
317
|
/**
|
|
306
318
|
* A MFA factor.
|
|
307
319
|
*
|
|
@@ -309,7 +321,10 @@ export interface UserIdentity {
|
|
|
309
321
|
* @see {@link GoTrueMFAApi#listFactors}
|
|
310
322
|
* @see {@link GoTrueMFAAdminApi#listFactors}
|
|
311
323
|
*/
|
|
312
|
-
export
|
|
324
|
+
export type Factor<
|
|
325
|
+
Type extends FactorType = FactorType,
|
|
326
|
+
Status extends FactorVerificationStatus = typeof FactorVerificationStatuses[number]
|
|
327
|
+
> = {
|
|
313
328
|
/** ID of the factor. */
|
|
314
329
|
id: string
|
|
315
330
|
|
|
@@ -319,10 +334,12 @@ export interface Factor {
|
|
|
319
334
|
/**
|
|
320
335
|
* Type of factor. `totp` and `phone` supported with this version
|
|
321
336
|
*/
|
|
322
|
-
factor_type:
|
|
337
|
+
factor_type: Type
|
|
323
338
|
|
|
324
|
-
/**
|
|
325
|
-
|
|
339
|
+
/**
|
|
340
|
+
* The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`
|
|
341
|
+
*/
|
|
342
|
+
status: Status
|
|
326
343
|
|
|
327
344
|
created_at: string
|
|
328
345
|
updated_at: string
|
|
@@ -361,7 +378,7 @@ export interface User {
|
|
|
361
378
|
identities?: UserIdentity[]
|
|
362
379
|
is_anonymous?: boolean
|
|
363
380
|
is_sso_user?: boolean
|
|
364
|
-
factors?: Factor[]
|
|
381
|
+
factors?: (Factor<FactorType, 'verified'> | Factor<FactorType, 'unverified'>)[]
|
|
365
382
|
deleted_at?: string
|
|
366
383
|
}
|
|
367
384
|
|
|
@@ -500,65 +517,26 @@ export type SignInAnonymouslyCredentials = {
|
|
|
500
517
|
}
|
|
501
518
|
}
|
|
502
519
|
|
|
503
|
-
export type SignUpWithPasswordCredentials =
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
/** The redirect url embedded in the email link */
|
|
511
|
-
emailRedirectTo?: string
|
|
512
|
-
/**
|
|
513
|
-
* A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.
|
|
514
|
-
*
|
|
515
|
-
* The `data` should be a JSON object that includes user-specific info, such as their first and last name.
|
|
516
|
-
*/
|
|
517
|
-
data?: object
|
|
518
|
-
/** Verification token received when the user completes the captcha on the site. */
|
|
519
|
-
captchaToken?: string
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
| {
|
|
523
|
-
/** The user's phone number. */
|
|
524
|
-
phone: string
|
|
525
|
-
/** The user's password. */
|
|
526
|
-
password: string
|
|
527
|
-
options?: {
|
|
528
|
-
/**
|
|
529
|
-
* A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.
|
|
530
|
-
*
|
|
531
|
-
* The `data` should be a JSON object that includes user-specific info, such as their first and last name.
|
|
532
|
-
*/
|
|
533
|
-
data?: object
|
|
534
|
-
/** Verification token received when the user completes the captcha on the site. Requires a configured WhatsApp sender on Twilio */
|
|
535
|
-
captchaToken?: string
|
|
536
|
-
/** Messaging channel to use (e.g. whatsapp or sms) */
|
|
537
|
-
channel?: 'sms' | 'whatsapp'
|
|
538
|
-
}
|
|
520
|
+
export type SignUpWithPasswordCredentials = Prettify<
|
|
521
|
+
PasswordCredentialsBase & {
|
|
522
|
+
options?: {
|
|
523
|
+
emailRedirectTo?: string // only for email
|
|
524
|
+
data?: object
|
|
525
|
+
captchaToken?: string
|
|
526
|
+
channel?: 'sms' | 'whatsapp' // only for phone
|
|
539
527
|
}
|
|
528
|
+
}
|
|
529
|
+
>
|
|
540
530
|
|
|
541
|
-
|
|
542
|
-
| {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
| {
|
|
553
|
-
/** The user's phone number. */
|
|
554
|
-
phone: string
|
|
555
|
-
/** The user's password. */
|
|
556
|
-
password: string
|
|
557
|
-
options?: {
|
|
558
|
-
/** Verification token received when the user completes the captcha on the site. */
|
|
559
|
-
captchaToken?: string
|
|
560
|
-
}
|
|
561
|
-
}
|
|
531
|
+
type PasswordCredentialsBase =
|
|
532
|
+
| { email: string; password: string }
|
|
533
|
+
| { phone: string; password: string }
|
|
534
|
+
|
|
535
|
+
export type SignInWithPasswordCredentials = PasswordCredentialsBase & {
|
|
536
|
+
options?: {
|
|
537
|
+
captchaToken?: string
|
|
538
|
+
}
|
|
539
|
+
}
|
|
562
540
|
|
|
563
541
|
export type SignInWithPasswordlessCredentials =
|
|
564
542
|
| {
|
|
@@ -859,21 +837,10 @@ export type GenerateLinkParams =
|
|
|
859
837
|
| GenerateRecoveryLinkParams
|
|
860
838
|
| GenerateEmailChangeLinkParams
|
|
861
839
|
|
|
862
|
-
export type GenerateLinkResponse =
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
user: User
|
|
867
|
-
}
|
|
868
|
-
error: null
|
|
869
|
-
}
|
|
870
|
-
| {
|
|
871
|
-
data: {
|
|
872
|
-
properties: null
|
|
873
|
-
user: null
|
|
874
|
-
}
|
|
875
|
-
error: AuthError
|
|
876
|
-
}
|
|
840
|
+
export type GenerateLinkResponse = RequestResultSafeDestructure<{
|
|
841
|
+
properties: GenerateLinkProperties
|
|
842
|
+
user: User
|
|
843
|
+
}>
|
|
877
844
|
|
|
878
845
|
/** The properties related to the email link generated */
|
|
879
846
|
export type GenerateLinkProperties = {
|
|
@@ -905,132 +872,270 @@ export type GenerateLinkType =
|
|
|
905
872
|
| 'email_change_current'
|
|
906
873
|
| 'email_change_new'
|
|
907
874
|
|
|
908
|
-
export type MFAEnrollParams = MFAEnrollTOTPParams | MFAEnrollPhoneParams
|
|
875
|
+
export type MFAEnrollParams = MFAEnrollTOTPParams | MFAEnrollPhoneParams | MFAEnrollWebauthnParams
|
|
909
876
|
|
|
910
877
|
export type MFAUnenrollParams = {
|
|
911
878
|
/** ID of the factor being unenrolled. */
|
|
912
879
|
factorId: string
|
|
913
880
|
}
|
|
914
881
|
|
|
915
|
-
|
|
882
|
+
type MFAVerifyParamsBase = {
|
|
916
883
|
/** ID of the factor being verified. Returned in enroll(). */
|
|
917
884
|
factorId: string
|
|
918
|
-
|
|
919
885
|
/** ID of the challenge being verified. Returned in challenge(). */
|
|
920
886
|
challengeId: string
|
|
887
|
+
}
|
|
921
888
|
|
|
889
|
+
type MFAVerifyTOTPParamFields = {
|
|
922
890
|
/** Verification code provided by the user. */
|
|
923
891
|
code: string
|
|
924
892
|
}
|
|
925
893
|
|
|
926
|
-
export type
|
|
894
|
+
export type MFAVerifyTOTPParams = Prettify<MFAVerifyParamsBase & MFAVerifyTOTPParamFields>
|
|
895
|
+
|
|
896
|
+
type MFAVerifyPhoneParamFields = MFAVerifyTOTPParamFields
|
|
897
|
+
|
|
898
|
+
export type MFAVerifyPhoneParams = Prettify<MFAVerifyParamsBase & MFAVerifyPhoneParamFields>
|
|
899
|
+
|
|
900
|
+
type MFAVerifyWebauthnParamFieldsBase = {
|
|
901
|
+
/** Relying party ID */
|
|
902
|
+
rpId: string
|
|
903
|
+
/** Relying party origins */
|
|
904
|
+
rpOrigins?: string[]
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
type MFAVerifyWebauthnCredentialParamFields<T extends 'create' | 'request' = 'create' | 'request'> =
|
|
908
|
+
{
|
|
909
|
+
/** Operation type */
|
|
910
|
+
type: T
|
|
911
|
+
/** Creation response from the authenticator (for enrollment/unverified factors) */
|
|
912
|
+
credential_response: T extends 'create' ? RegistrationCredential : AuthenticationCredential
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* WebAuthn-specific fields for MFA verification.
|
|
917
|
+
* Supports both credential creation (registration) and request (authentication) flows.
|
|
918
|
+
* @template T - Type of WebAuthn operation: 'create' for registration, 'request' for authentication
|
|
919
|
+
*/
|
|
920
|
+
export type MFAVerifyWebauthnParamFields<T extends 'create' | 'request' = 'create' | 'request'> = {
|
|
921
|
+
webauthn: MFAVerifyWebauthnParamFieldsBase & MFAVerifyWebauthnCredentialParamFields<T>
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Parameters for WebAuthn MFA verification.
|
|
926
|
+
* Used to verify WebAuthn credentials after challenge.
|
|
927
|
+
* @template T - Type of WebAuthn operation: 'create' for registration, 'request' for authentication
|
|
928
|
+
* @see {@link https://w3c.github.io/webauthn/#sctn-verifying-assertion W3C WebAuthn Spec - Verifying an Authentication Assertion}
|
|
929
|
+
*/
|
|
930
|
+
export type MFAVerifyWebauthnParams<T extends 'create' | 'request' = 'create' | 'request'> =
|
|
931
|
+
Prettify<MFAVerifyParamsBase & MFAVerifyWebauthnParamFields<T>>
|
|
932
|
+
|
|
933
|
+
export type MFAVerifyParams = MFAVerifyTOTPParams | MFAVerifyPhoneParams | MFAVerifyWebauthnParams
|
|
934
|
+
|
|
935
|
+
type MFAChallengeParamsBase = {
|
|
927
936
|
/** ID of the factor to be challenged. Returned in enroll(). */
|
|
928
937
|
factorId: string
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
const MFATOTPChannels = ['sms', 'whatsapp'] as const
|
|
941
|
+
export type MFATOTPChannel = typeof MFATOTPChannels[number]
|
|
942
|
+
|
|
943
|
+
export type MFAChallengeTOTPParams = Prettify<MFAChallengeParamsBase>
|
|
944
|
+
|
|
945
|
+
type MFAChallengePhoneParamFields<Channel extends MFATOTPChannel = MFATOTPChannel> = {
|
|
929
946
|
/** Messaging channel to use (e.g. whatsapp or sms). Only relevant for phone factors */
|
|
930
|
-
channel
|
|
947
|
+
channel: Channel
|
|
931
948
|
}
|
|
932
949
|
|
|
933
|
-
export type
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
950
|
+
export type MFAChallengePhoneParams = Prettify<
|
|
951
|
+
MFAChallengeParamsBase & MFAChallengePhoneParamFields
|
|
952
|
+
>
|
|
953
|
+
|
|
954
|
+
/** WebAuthn parameters for WebAuthn factor challenge */
|
|
955
|
+
type MFAChallengeWebauthnParamFields = {
|
|
956
|
+
webauthn: {
|
|
957
|
+
/** Relying party ID */
|
|
958
|
+
rpId: string
|
|
959
|
+
/** Relying party origins*/
|
|
960
|
+
rpOrigins?: string[]
|
|
961
|
+
}
|
|
938
962
|
}
|
|
939
963
|
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
964
|
+
/**
|
|
965
|
+
* Parameters for initiating a WebAuthn MFA challenge.
|
|
966
|
+
* Includes Relying Party information needed for WebAuthn ceremonies.
|
|
967
|
+
* @see {@link https://w3c.github.io/webauthn/#sctn-rp-operations W3C WebAuthn Spec - Relying Party Operations}
|
|
968
|
+
*/
|
|
969
|
+
export type MFAChallengeWebauthnParams = Prettify<
|
|
970
|
+
MFAChallengeParamsBase & MFAChallengeWebauthnParamFields
|
|
971
|
+
>
|
|
945
972
|
|
|
946
|
-
|
|
947
|
-
|
|
973
|
+
export type MFAChallengeParams =
|
|
974
|
+
| MFAChallengeTOTPParams
|
|
975
|
+
| MFAChallengePhoneParams
|
|
976
|
+
| MFAChallengeWebauthnParams
|
|
948
977
|
|
|
949
|
-
|
|
950
|
-
expires_in: number
|
|
978
|
+
type MFAChallengeAndVerifyParamsBase = Omit<MFAVerifyParamsBase, 'challengeId'>
|
|
951
979
|
|
|
952
|
-
|
|
953
|
-
refresh_token: string
|
|
980
|
+
type MFAChallengeAndVerifyTOTPParamFields = MFAVerifyTOTPParamFields
|
|
954
981
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
error: null
|
|
959
|
-
}
|
|
960
|
-
| {
|
|
961
|
-
data: null
|
|
962
|
-
error: AuthError
|
|
963
|
-
}
|
|
982
|
+
type MFAChallengeAndVerifyTOTPParams = Prettify<
|
|
983
|
+
MFAChallengeAndVerifyParamsBase & MFAChallengeAndVerifyTOTPParamFields
|
|
984
|
+
>
|
|
964
985
|
|
|
965
|
-
export type
|
|
986
|
+
export type MFAChallengeAndVerifyParams = MFAChallengeAndVerifyTOTPParams
|
|
966
987
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
}
|
|
975
|
-
| { data: null; error: AuthError }
|
|
988
|
+
/**
|
|
989
|
+
* Data returned after successful MFA verification.
|
|
990
|
+
* Contains new session tokens and updated user information.
|
|
991
|
+
*/
|
|
992
|
+
export type AuthMFAVerifyResponseData = {
|
|
993
|
+
/** New access token (JWT) after successful verification. */
|
|
994
|
+
access_token: string
|
|
976
995
|
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
data: {
|
|
980
|
-
/** ID of the newly created challenge. */
|
|
981
|
-
id: string
|
|
996
|
+
/** Type of token, always `bearer`. */
|
|
997
|
+
token_type: 'bearer'
|
|
982
998
|
|
|
983
|
-
|
|
984
|
-
|
|
999
|
+
/** Number of seconds in which the access token will expire. */
|
|
1000
|
+
expires_in: number
|
|
985
1001
|
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
}
|
|
989
|
-
error: null
|
|
990
|
-
}
|
|
991
|
-
| { data: null; error: AuthError }
|
|
1002
|
+
/** Refresh token you can use to obtain new access tokens when expired. */
|
|
1003
|
+
refresh_token: string
|
|
992
1004
|
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
/** All available factors (verified and unverified). */
|
|
997
|
-
all: Factor[]
|
|
1005
|
+
/** Updated user profile. */
|
|
1006
|
+
user: User
|
|
1007
|
+
}
|
|
998
1008
|
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1009
|
+
/**
|
|
1010
|
+
* Response type for MFA verification operations.
|
|
1011
|
+
* Returns session tokens on successful verification.
|
|
1012
|
+
*/
|
|
1013
|
+
export type AuthMFAVerifyResponse = RequestResult<AuthMFAVerifyResponseData>
|
|
1014
|
+
|
|
1015
|
+
export type AuthMFAEnrollResponse =
|
|
1016
|
+
| AuthMFAEnrollTOTPResponse
|
|
1017
|
+
| AuthMFAEnrollPhoneResponse
|
|
1018
|
+
| AuthMFAEnrollWebauthnResponse
|
|
1019
|
+
|
|
1020
|
+
export type AuthMFAUnenrollResponse = RequestResult<{
|
|
1021
|
+
/** ID of the factor that was successfully unenrolled. */
|
|
1022
|
+
id: string
|
|
1023
|
+
}>
|
|
1024
|
+
|
|
1025
|
+
type AuthMFAChallengeResponseBase<T extends FactorType> = {
|
|
1026
|
+
/** ID of the newly created challenge. */
|
|
1027
|
+
id: string
|
|
1028
|
+
|
|
1029
|
+
/** Factor Type which generated the challenge */
|
|
1030
|
+
type: T
|
|
1031
|
+
|
|
1032
|
+
/** Timestamp in UNIX seconds when this challenge will no longer be usable. */
|
|
1033
|
+
expires_at: number
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
type AuthMFAChallengeTOTPResponseFields = {
|
|
1037
|
+
/** no extra fields for now, kept for consistency and for possible future changes */
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
export type AuthMFAChallengeTOTPResponse = RequestResult<
|
|
1041
|
+
Prettify<AuthMFAChallengeResponseBase<'totp'> & AuthMFAChallengeTOTPResponseFields>
|
|
1042
|
+
>
|
|
1043
|
+
|
|
1044
|
+
type AuthMFAChallengePhoneResponseFields = {
|
|
1045
|
+
/** no extra fields for now, kept for consistency and for possible future changes */
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
export type AuthMFAChallengePhoneResponse = RequestResult<
|
|
1049
|
+
Prettify<AuthMFAChallengeResponseBase<'phone'> & AuthMFAChallengePhoneResponseFields>
|
|
1050
|
+
>
|
|
1051
|
+
|
|
1052
|
+
type AuthMFAChallengeWebauthnResponseFields = {
|
|
1053
|
+
webauthn:
|
|
1054
|
+
| {
|
|
1055
|
+
type: 'create'
|
|
1056
|
+
credential_options: { publicKey: PublicKeyCredentialCreationOptionsFuture }
|
|
1003
1057
|
}
|
|
1004
|
-
|
|
1058
|
+
| {
|
|
1059
|
+
type: 'request'
|
|
1060
|
+
credential_options: { publicKey: PublicKeyCredentialRequestOptionsFuture }
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* Response type for WebAuthn MFA challenge.
|
|
1066
|
+
* Contains credential creation or request options from the server.
|
|
1067
|
+
* @see {@link https://w3c.github.io/webauthn/#sctn-credential-creation W3C WebAuthn Spec - Credential Creation}
|
|
1068
|
+
*/
|
|
1069
|
+
export type AuthMFAChallengeWebauthnResponse = RequestResult<
|
|
1070
|
+
Prettify<AuthMFAChallengeResponseBase<'webauthn'> & AuthMFAChallengeWebauthnResponseFields>
|
|
1071
|
+
>
|
|
1072
|
+
|
|
1073
|
+
type AuthMFAChallengeWebauthnResponseFieldsJSON = {
|
|
1074
|
+
webauthn:
|
|
1075
|
+
| {
|
|
1076
|
+
type: 'create'
|
|
1077
|
+
credential_options: { publicKey: ServerCredentialCreationOptions }
|
|
1078
|
+
}
|
|
1079
|
+
| {
|
|
1080
|
+
type: 'request'
|
|
1081
|
+
credential_options: { publicKey: ServerCredentialRequestOptions }
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* JSON-serializable version of WebAuthn challenge response.
|
|
1087
|
+
* Used for server communication with base64url-encoded binary fields.
|
|
1088
|
+
*/
|
|
1089
|
+
export type AuthMFAChallengeWebauthnResponseDataJSON = Prettify<
|
|
1090
|
+
AuthMFAChallengeResponseBase<'webauthn'> & AuthMFAChallengeWebauthnResponseFieldsJSON
|
|
1091
|
+
>
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* Server response type for WebAuthn MFA challenge.
|
|
1095
|
+
* Contains JSON-formatted WebAuthn options ready for browser API.
|
|
1096
|
+
*/
|
|
1097
|
+
export type AuthMFAChallengeWebauthnServerResponse =
|
|
1098
|
+
RequestResult<AuthMFAChallengeWebauthnResponseDataJSON>
|
|
1099
|
+
|
|
1100
|
+
export type AuthMFAChallengeResponse =
|
|
1101
|
+
| AuthMFAChallengeTOTPResponse
|
|
1102
|
+
| AuthMFAChallengePhoneResponse
|
|
1103
|
+
| AuthMFAChallengeWebauthnResponse
|
|
1104
|
+
|
|
1105
|
+
/** response of ListFactors, which should contain all the types of factors that are available, this ensures we always include all */
|
|
1106
|
+
export type AuthMFAListFactorsResponse<T extends typeof FactorTypes = typeof FactorTypes> =
|
|
1107
|
+
RequestResult<
|
|
1108
|
+
{
|
|
1109
|
+
/** All available factors (verified and unverified). */
|
|
1110
|
+
all: Prettify<Factor>[]
|
|
1111
|
+
|
|
1112
|
+
// Dynamically create a property for each factor type with only verified factors
|
|
1113
|
+
} & {
|
|
1114
|
+
[K in T[number]]: Prettify<Factor<K, 'verified'>>[]
|
|
1005
1115
|
}
|
|
1006
|
-
|
|
1116
|
+
>
|
|
1007
1117
|
|
|
1008
1118
|
export type AuthenticatorAssuranceLevels = 'aal1' | 'aal2'
|
|
1009
1119
|
|
|
1010
|
-
export type AuthMFAGetAuthenticatorAssuranceLevelResponse =
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
/** Current AAL level of the session. */
|
|
1014
|
-
currentLevel: AuthenticatorAssuranceLevels | null
|
|
1120
|
+
export type AuthMFAGetAuthenticatorAssuranceLevelResponse = RequestResult<{
|
|
1121
|
+
/** Current AAL level of the session. */
|
|
1122
|
+
currentLevel: AuthenticatorAssuranceLevels | null
|
|
1015
1123
|
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1124
|
+
/**
|
|
1125
|
+
* Next possible AAL level for the session. If the next level is higher
|
|
1126
|
+
* than the current one, the user should go through MFA.
|
|
1127
|
+
*
|
|
1128
|
+
* @see {@link GoTrueMFAApi#challenge}
|
|
1129
|
+
*/
|
|
1130
|
+
nextLevel: AuthenticatorAssuranceLevels | null
|
|
1023
1131
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
error: null
|
|
1032
|
-
}
|
|
1033
|
-
| { data: null; error: AuthError }
|
|
1132
|
+
/**
|
|
1133
|
+
* A list of all authentication methods attached to this session. Use
|
|
1134
|
+
* the information here to detect the last time a user verified a
|
|
1135
|
+
* factor, for example if implementing a step-up scenario.
|
|
1136
|
+
*/
|
|
1137
|
+
currentAuthenticationMethods: AMREntry[]
|
|
1138
|
+
}>
|
|
1034
1139
|
|
|
1035
1140
|
/**
|
|
1036
1141
|
* Contains the full multi-factor authentication API.
|
|
@@ -1045,22 +1150,28 @@ export interface GoTrueMFAApi {
|
|
|
1045
1150
|
* The user has to enter the code from their authenticator app to verify it.
|
|
1046
1151
|
*
|
|
1047
1152
|
* Upon verifying a factor, all other sessions are logged out and the current session's authenticator level is promoted to `aal2`.
|
|
1048
|
-
*
|
|
1049
1153
|
*/
|
|
1050
1154
|
enroll(params: MFAEnrollTOTPParams): Promise<AuthMFAEnrollTOTPResponse>
|
|
1051
1155
|
enroll(params: MFAEnrollPhoneParams): Promise<AuthMFAEnrollPhoneResponse>
|
|
1156
|
+
enroll(params: MFAEnrollWebauthnParams): Promise<AuthMFAEnrollWebauthnResponse>
|
|
1052
1157
|
enroll(params: MFAEnrollParams): Promise<AuthMFAEnrollResponse>
|
|
1053
1158
|
|
|
1054
1159
|
/**
|
|
1055
1160
|
* Prepares a challenge used to verify that a user has access to a MFA
|
|
1056
1161
|
* factor.
|
|
1057
1162
|
*/
|
|
1163
|
+
challenge(params: MFAChallengeTOTPParams): Promise<Prettify<AuthMFAChallengeTOTPResponse>>
|
|
1164
|
+
challenge(params: MFAChallengePhoneParams): Promise<Prettify<AuthMFAChallengePhoneResponse>>
|
|
1165
|
+
challenge(params: MFAChallengeWebauthnParams): Promise<Prettify<AuthMFAChallengeWebauthnResponse>>
|
|
1058
1166
|
challenge(params: MFAChallengeParams): Promise<AuthMFAChallengeResponse>
|
|
1059
1167
|
|
|
1060
1168
|
/**
|
|
1061
1169
|
* Verifies a code against a challenge. The verification code is
|
|
1062
1170
|
* provided by the user by entering a code seen in their authenticator app.
|
|
1063
1171
|
*/
|
|
1172
|
+
verify(params: MFAVerifyTOTPParams): Promise<AuthMFAVerifyResponse>
|
|
1173
|
+
verify(params: MFAVerifyPhoneParams): Promise<AuthMFAVerifyResponse>
|
|
1174
|
+
verify(params: MFAVerifyWebauthnParams): Promise<AuthMFAVerifyResponse>
|
|
1064
1175
|
verify(params: MFAVerifyParams): Promise<AuthMFAVerifyResponse>
|
|
1065
1176
|
|
|
1066
1177
|
/**
|
|
@@ -1099,21 +1210,18 @@ export interface GoTrueMFAApi {
|
|
|
1099
1210
|
*
|
|
1100
1211
|
*/
|
|
1101
1212
|
getAuthenticatorAssuranceLevel(): Promise<AuthMFAGetAuthenticatorAssuranceLevelResponse>
|
|
1213
|
+
|
|
1214
|
+
// namespace for the webauthn methods
|
|
1215
|
+
webauthn: WebAuthnApi
|
|
1102
1216
|
}
|
|
1103
1217
|
|
|
1104
1218
|
/**
|
|
1105
1219
|
* @expermental
|
|
1106
1220
|
*/
|
|
1107
|
-
export type AuthMFAAdminDeleteFactorResponse =
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
id: string
|
|
1112
|
-
}
|
|
1113
|
-
error: null
|
|
1114
|
-
}
|
|
1115
|
-
| { data: null; error: AuthError }
|
|
1116
|
-
|
|
1221
|
+
export type AuthMFAAdminDeleteFactorResponse = RequestResult<{
|
|
1222
|
+
/** ID of the factor that was successfully deleted. */
|
|
1223
|
+
id: string
|
|
1224
|
+
}>
|
|
1117
1225
|
/**
|
|
1118
1226
|
* @expermental
|
|
1119
1227
|
*/
|
|
@@ -1128,15 +1236,10 @@ export type AuthMFAAdminDeleteFactorParams = {
|
|
|
1128
1236
|
/**
|
|
1129
1237
|
* @expermental
|
|
1130
1238
|
*/
|
|
1131
|
-
export type AuthMFAAdminListFactorsResponse =
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
factors: Factor[]
|
|
1136
|
-
}
|
|
1137
|
-
error: null
|
|
1138
|
-
}
|
|
1139
|
-
| { data: null; error: AuthError }
|
|
1239
|
+
export type AuthMFAAdminListFactorsResponse = RequestResult<{
|
|
1240
|
+
/** All factors attached to the user. */
|
|
1241
|
+
factors: Factor[]
|
|
1242
|
+
}>
|
|
1140
1243
|
|
|
1141
1244
|
/**
|
|
1142
1245
|
* @expermental
|
|
@@ -1193,15 +1296,7 @@ export type SupportedStorage = PromisifyMethods<
|
|
|
1193
1296
|
|
|
1194
1297
|
export type InitializeResult = { error: AuthError | null }
|
|
1195
1298
|
|
|
1196
|
-
export type CallRefreshTokenResult =
|
|
1197
|
-
| {
|
|
1198
|
-
session: Session
|
|
1199
|
-
error: null
|
|
1200
|
-
}
|
|
1201
|
-
| {
|
|
1202
|
-
session: null
|
|
1203
|
-
error: AuthError
|
|
1204
|
-
}
|
|
1299
|
+
export type CallRefreshTokenResult = RequestResult<Session>
|
|
1205
1300
|
|
|
1206
1301
|
export type Pagination = {
|
|
1207
1302
|
[key: string]: any
|
|
@@ -1231,79 +1326,96 @@ export type SignOut = {
|
|
|
1231
1326
|
scope?: 'global' | 'local' | 'others'
|
|
1232
1327
|
}
|
|
1233
1328
|
|
|
1234
|
-
|
|
1329
|
+
type MFAEnrollParamsBase<T extends FactorType> = {
|
|
1235
1330
|
/** The type of factor being enrolled. */
|
|
1236
|
-
factorType:
|
|
1237
|
-
/** Domain which the user is enrolled with. */
|
|
1238
|
-
issuer?: string
|
|
1331
|
+
factorType: T
|
|
1239
1332
|
/** Human readable name assigned to the factor. */
|
|
1240
1333
|
friendlyName?: string
|
|
1241
1334
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1335
|
+
|
|
1336
|
+
type MFAEnrollTOTPParamFields = {
|
|
1337
|
+
/** Domain which the user is enrolled with. */
|
|
1338
|
+
issuer?: string
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
export type MFAEnrollTOTPParams = Prettify<MFAEnrollParamsBase<'totp'> & MFAEnrollTOTPParamFields>
|
|
1342
|
+
|
|
1343
|
+
type MFAEnrollPhoneParamFields = {
|
|
1247
1344
|
/** Phone number associated with a factor. Number should conform to E.164 format */
|
|
1248
1345
|
phone: string
|
|
1249
1346
|
}
|
|
1347
|
+
export type MFAEnrollPhoneParams = Prettify<
|
|
1348
|
+
MFAEnrollParamsBase<'phone'> & MFAEnrollPhoneParamFields
|
|
1349
|
+
>
|
|
1250
1350
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
/** ID of the factor that was just enrolled (in an unverified state). */
|
|
1255
|
-
id: string
|
|
1256
|
-
|
|
1257
|
-
/** Type of MFA factor.*/
|
|
1258
|
-
type: 'totp'
|
|
1259
|
-
|
|
1260
|
-
/** TOTP enrollment information. */
|
|
1261
|
-
totp: {
|
|
1262
|
-
/** Contains a QR code encoding the authenticator URI. You can
|
|
1263
|
-
* convert it to a URL by prepending `data:image/svg+xml;utf-8,` to
|
|
1264
|
-
* the value. Avoid logging this value to the console. */
|
|
1265
|
-
qr_code: string
|
|
1266
|
-
|
|
1267
|
-
/** The TOTP secret (also encoded in the QR code). Show this secret
|
|
1268
|
-
* in a password-style field to the user, in case they are unable to
|
|
1269
|
-
* scan the QR code. Avoid logging this value to the console. */
|
|
1270
|
-
secret: string
|
|
1271
|
-
|
|
1272
|
-
/** The authenticator URI encoded within the QR code, should you need
|
|
1273
|
-
* to use it. Avoid loggin this value to the console. */
|
|
1274
|
-
uri: string
|
|
1275
|
-
}
|
|
1276
|
-
/** Friendly name of the factor, useful for distinguishing between factors **/
|
|
1277
|
-
friendly_name?: string
|
|
1278
|
-
}
|
|
1279
|
-
error: null
|
|
1280
|
-
}
|
|
1281
|
-
| {
|
|
1282
|
-
data: null
|
|
1283
|
-
error: AuthError
|
|
1284
|
-
}
|
|
1351
|
+
type MFAEnrollWebauthnFields = {
|
|
1352
|
+
/** no extra fields for now, kept for consistency and for possible future changes */
|
|
1353
|
+
}
|
|
1285
1354
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1355
|
+
/**
|
|
1356
|
+
* Parameters for enrolling a WebAuthn factor.
|
|
1357
|
+
* Creates an unverified WebAuthn factor that must be verified with a credential.
|
|
1358
|
+
* @see {@link https://w3c.github.io/webauthn/#sctn-registering-a-new-credential W3C WebAuthn Spec - Registering a New Credential}
|
|
1359
|
+
*/
|
|
1360
|
+
export type MFAEnrollWebauthnParams = Prettify<
|
|
1361
|
+
MFAEnrollParamsBase<'webauthn'> & MFAEnrollWebauthnFields
|
|
1362
|
+
>
|
|
1291
1363
|
|
|
1292
|
-
|
|
1293
|
-
|
|
1364
|
+
type AuthMFAEnrollResponseBase<T extends FactorType> = {
|
|
1365
|
+
/** ID of the factor that was just enrolled (in an unverified state). */
|
|
1366
|
+
id: string
|
|
1294
1367
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1368
|
+
/** Type of MFA factor.*/
|
|
1369
|
+
type: T
|
|
1297
1370
|
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1371
|
+
/** Friendly name of the factor, useful for distinguishing between factors **/
|
|
1372
|
+
friendly_name?: string
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
type AuthMFAEnrollTOTPResponseFields = {
|
|
1376
|
+
/** TOTP enrollment information. */
|
|
1377
|
+
totp: {
|
|
1378
|
+
/** Contains a QR code encoding the authenticator URI. You can
|
|
1379
|
+
* convert it to a URL by prepending `data:image/svg+xml;utf-8,` to
|
|
1380
|
+
* the value. Avoid logging this value to the console. */
|
|
1381
|
+
qr_code: string
|
|
1382
|
+
|
|
1383
|
+
/** The TOTP secret (also encoded in the QR code). Show this secret
|
|
1384
|
+
* in a password-style field to the user, in case they are unable to
|
|
1385
|
+
* scan the QR code. Avoid logging this value to the console. */
|
|
1386
|
+
secret: string
|
|
1387
|
+
|
|
1388
|
+
/** The authenticator URI encoded within the QR code, should you need
|
|
1389
|
+
* to use it. Avoid loggin this value to the console. */
|
|
1390
|
+
uri: string
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
export type AuthMFAEnrollTOTPResponse = RequestResult<
|
|
1395
|
+
Prettify<AuthMFAEnrollResponseBase<'totp'> & AuthMFAEnrollTOTPResponseFields>
|
|
1396
|
+
>
|
|
1397
|
+
|
|
1398
|
+
type AuthMFAEnrollPhoneResponseFields = {
|
|
1399
|
+
/** Phone number of the MFA factor in E.164 format. Used to send messages */
|
|
1400
|
+
phone: string
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
export type AuthMFAEnrollPhoneResponse = RequestResult<
|
|
1404
|
+
Prettify<AuthMFAEnrollResponseBase<'phone'> & AuthMFAEnrollPhoneResponseFields>
|
|
1405
|
+
>
|
|
1406
|
+
|
|
1407
|
+
type AuthMFAEnrollWebauthnFields = {
|
|
1408
|
+
/** no extra fields for now, kept for consistency and for possible future changes */
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
/**
|
|
1412
|
+
* Response type for WebAuthn factor enrollment.
|
|
1413
|
+
* Returns the enrolled factor ID and metadata.
|
|
1414
|
+
* @see {@link https://w3c.github.io/webauthn/#sctn-registering-a-new-credential W3C WebAuthn Spec - Registering a New Credential}
|
|
1415
|
+
*/
|
|
1416
|
+
export type AuthMFAEnrollWebauthnResponse = RequestResult<
|
|
1417
|
+
Prettify<AuthMFAEnrollResponseBase<'webauthn'> & AuthMFAEnrollWebauthnFields>
|
|
1418
|
+
>
|
|
1307
1419
|
|
|
1308
1420
|
export type JwtHeader = {
|
|
1309
1421
|
alg: 'RS256' | 'ES256' | 'HS256'
|