@supabase/auth-js 2.72.0-rc.8 → 2.72.1-canary.0
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/README.md +95 -3
- package/dist/main/GoTrueAdminApi.js.map +1 -1
- package/dist/main/GoTrueClient.d.ts +7 -1
- package/dist/main/GoTrueClient.d.ts.map +1 -1
- package/dist/main/GoTrueClient.js +132 -51
- 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 +10 -11
- package/dist/main/lib/base64url.js.map +1 -1
- package/dist/main/lib/error-codes.d.ts +1 -1
- package/dist/main/lib/error-codes.d.ts.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 +7 -7
- package/dist/main/lib/errors.js.map +1 -1
- package/dist/main/lib/fetch.d.ts +2 -2
- package/dist/main/lib/fetch.d.ts.map +1 -1
- package/dist/main/lib/fetch.js +8 -9
- package/dist/main/lib/fetch.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +3 -2
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +34 -24
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/local-storage.js +1 -2
- package/dist/main/lib/local-storage.js.map +1 -1
- package/dist/main/lib/locks.js +3 -3
- package/dist/main/lib/locks.js.map +1 -1
- package/dist/main/lib/polyfills.js +1 -2
- package/dist/main/lib/polyfills.js.map +1 -1
- package/dist/main/lib/types.d.ts +376 -361
- 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.d.ts.map +1 -1
- package/dist/main/lib/version.js +7 -1
- package/dist/main/lib/version.js.map +1 -1
- package/dist/main/lib/web3/ethereum.d.ts +9 -9
- package/dist/main/lib/web3/ethereum.d.ts.map +1 -1
- package/dist/main/lib/web3/ethereum.js +4 -5
- package/dist/main/lib/web3/ethereum.js.map +1 -1
- package/dist/main/lib/web3/solana.d.ts +4 -4
- package/dist/main/lib/web3/solana.d.ts.map +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/GoTrueAdminApi.js.map +1 -1
- package/dist/module/GoTrueClient.d.ts +7 -1
- package/dist/module/GoTrueClient.d.ts.map +1 -1
- package/dist/module/GoTrueClient.js +139 -57
- 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/error-codes.d.ts +1 -1
- package/dist/module/lib/error-codes.d.ts.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/fetch.d.ts +2 -2
- package/dist/module/lib/fetch.d.ts.map +1 -1
- package/dist/module/lib/fetch.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +3 -2
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/locks.js.map +1 -1
- package/dist/module/lib/polyfills.js.map +1 -1
- package/dist/module/lib/types.d.ts +376 -361
- 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.d.ts.map +1 -1
- package/dist/module/lib/version.js +7 -1
- package/dist/module/lib/version.js.map +1 -1
- package/dist/module/lib/web3/ethereum.d.ts +9 -9
- package/dist/module/lib/web3/ethereum.d.ts.map +1 -1
- package/dist/module/lib/web3/ethereum.js.map +1 -1
- package/dist/module/lib/web3/solana.d.ts +4 -4
- package/dist/module/lib/web3/solana.d.ts.map +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 +13 -33
- package/src/GoTrueClient.ts +279 -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 +469 -357
- package/src/lib/version.ts +7 -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/dist/main/lib/types.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
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 { ServerCredentialCreationOptions, ServerCredentialRequestOptions, WebAuthnApi } from './webauthn';
|
|
6
|
+
import { AuthenticationCredential, PublicKeyCredentialCreationOptionsFuture, PublicKeyCredentialRequestOptionsFuture, RegistrationCredential } from './webauthn.dom';
|
|
6
7
|
/** One of the providers supported by GoTrue. */
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export type Provider = 'apple' | 'azure' | 'bitbucket' | 'discord' | 'facebook' | 'figma' | 'github' | 'gitlab' | 'google' | 'kakao' | 'keycloak' | 'linkedin' | 'linkedin_oidc' | 'notion' | 'slack' | 'slack_oidc' | 'spotify' | 'twitch' | 'twitter' | 'workos' | 'zoom' | 'fly';
|
|
9
|
+
export type AuthChangeEventMFA = 'MFA_CHALLENGE_VERIFIED';
|
|
10
|
+
export type AuthChangeEvent = 'INITIAL_SESSION' | 'PASSWORD_RECOVERY' | 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED' | AuthChangeEventMFA;
|
|
10
11
|
/**
|
|
11
12
|
* Provide your own global lock implementation instead of the default
|
|
12
13
|
* implementation. The function should acquire a lock for the duration of the
|
|
@@ -22,8 +23,8 @@ export declare type AuthChangeEvent = 'INITIAL_SESSION' | 'PASSWORD_RECOVERY' |
|
|
|
22
23
|
* acquired after this much time (ms).
|
|
23
24
|
* @param fn The operation to execute when the lock is acquired.
|
|
24
25
|
*/
|
|
25
|
-
export
|
|
26
|
-
export
|
|
26
|
+
export type LockFunc = <R>(name: string, acquireTimeout: number, fn: () => Promise<R>) => Promise<R>;
|
|
27
|
+
export type GoTrueClientOptions = {
|
|
27
28
|
url?: string;
|
|
28
29
|
headers?: {
|
|
29
30
|
[key: string]: string;
|
|
@@ -56,87 +57,77 @@ export declare type GoTrueClientOptions = {
|
|
|
56
57
|
*/
|
|
57
58
|
hasCustomAuthorizationHeader?: boolean;
|
|
58
59
|
};
|
|
59
|
-
|
|
60
|
-
export
|
|
60
|
+
declare const WeakPasswordReasons: readonly ["length", "characters", "pwned"];
|
|
61
|
+
export type WeakPasswordReasons = (typeof WeakPasswordReasons)[number];
|
|
62
|
+
export type WeakPassword = {
|
|
61
63
|
reasons: WeakPasswordReasons[];
|
|
62
64
|
message: string;
|
|
63
65
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Resolve mapped types and show the derived keys and their types when hovering in
|
|
68
|
+
* VS Code, instead of just showing the names those mapped types are defined with.
|
|
69
|
+
*/
|
|
70
|
+
export type Prettify<T> = T extends Function ? T : {
|
|
71
|
+
[K in keyof T]: T[K];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* A stricter version of TypeScript's Omit that only allows omitting keys that actually exist.
|
|
75
|
+
* This prevents typos and ensures type safety at compile time.
|
|
76
|
+
* Unlike regular Omit, this will error if you try to omit a non-existent key.
|
|
77
|
+
*/
|
|
78
|
+
export type StrictOmit<T, K extends keyof T> = Omit<T, K>;
|
|
79
|
+
/**
|
|
80
|
+
* a shared result type that encapsulates errors instead of throwing them, allows you to optionally specify the ErrorType
|
|
81
|
+
*/
|
|
82
|
+
export type RequestResult<T, ErrorType extends Error = AuthError> = {
|
|
83
|
+
data: T;
|
|
69
84
|
error: null;
|
|
70
85
|
} | {
|
|
71
|
-
data:
|
|
72
|
-
|
|
73
|
-
session: null;
|
|
74
|
-
};
|
|
75
|
-
error: AuthError;
|
|
86
|
+
data: null;
|
|
87
|
+
error: Error extends AuthError ? AuthError : ErrorType;
|
|
76
88
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
/**
|
|
90
|
+
* similar to RequestResult except it allows you to destructure the possible shape of the success response
|
|
91
|
+
* {@see RequestResult}
|
|
92
|
+
*/
|
|
93
|
+
export type RequestResultSafeDestructure<T> = {
|
|
94
|
+
data: T;
|
|
83
95
|
error: null;
|
|
84
96
|
} | {
|
|
85
|
-
data: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
97
|
+
data: T extends object ? {
|
|
98
|
+
[K in keyof T]: null;
|
|
99
|
+
} : null;
|
|
89
100
|
error: AuthError;
|
|
90
101
|
};
|
|
102
|
+
export type AuthResponse = RequestResultSafeDestructure<{
|
|
103
|
+
user: User | null;
|
|
104
|
+
session: Session | null;
|
|
105
|
+
}>;
|
|
106
|
+
export type AuthResponsePassword = RequestResultSafeDestructure<{
|
|
107
|
+
user: User | null;
|
|
108
|
+
session: Session | null;
|
|
109
|
+
weak_password?: WeakPassword | null;
|
|
110
|
+
}>;
|
|
91
111
|
/**
|
|
92
112
|
* AuthOtpResponse is returned when OTP is used.
|
|
93
113
|
*
|
|
94
114
|
* {@see AuthResponse}
|
|
95
115
|
*/
|
|
96
|
-
export
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
export declare type AuthTokenResponse = {
|
|
112
|
-
data: {
|
|
113
|
-
user: User;
|
|
114
|
-
session: Session;
|
|
115
|
-
};
|
|
116
|
-
error: null;
|
|
117
|
-
} | {
|
|
118
|
-
data: {
|
|
119
|
-
user: null;
|
|
120
|
-
session: null;
|
|
121
|
-
};
|
|
122
|
-
error: AuthError;
|
|
123
|
-
};
|
|
124
|
-
export declare type AuthTokenResponsePassword = {
|
|
125
|
-
data: {
|
|
126
|
-
user: User;
|
|
127
|
-
session: Session;
|
|
128
|
-
weakPassword?: WeakPassword;
|
|
129
|
-
};
|
|
130
|
-
error: null;
|
|
131
|
-
} | {
|
|
132
|
-
data: {
|
|
133
|
-
user: null;
|
|
134
|
-
session: null;
|
|
135
|
-
weakPassword?: null;
|
|
136
|
-
};
|
|
137
|
-
error: AuthError;
|
|
138
|
-
};
|
|
139
|
-
export declare type OAuthResponse = {
|
|
116
|
+
export type AuthOtpResponse = RequestResultSafeDestructure<{
|
|
117
|
+
user: null;
|
|
118
|
+
session: null;
|
|
119
|
+
messageId?: string | null;
|
|
120
|
+
}>;
|
|
121
|
+
export type AuthTokenResponse = RequestResultSafeDestructure<{
|
|
122
|
+
user: User;
|
|
123
|
+
session: Session;
|
|
124
|
+
}>;
|
|
125
|
+
export type AuthTokenResponsePassword = RequestResultSafeDestructure<{
|
|
126
|
+
user: User;
|
|
127
|
+
session: Session;
|
|
128
|
+
weakPassword?: WeakPassword;
|
|
129
|
+
}>;
|
|
130
|
+
export type OAuthResponse = {
|
|
140
131
|
data: {
|
|
141
132
|
provider: Provider;
|
|
142
133
|
url: string;
|
|
@@ -149,33 +140,19 @@ export declare type OAuthResponse = {
|
|
|
149
140
|
};
|
|
150
141
|
error: AuthError;
|
|
151
142
|
};
|
|
152
|
-
export
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
data: null;
|
|
166
|
-
error: AuthError;
|
|
167
|
-
};
|
|
168
|
-
export declare type UserResponse = {
|
|
169
|
-
data: {
|
|
170
|
-
user: User;
|
|
171
|
-
};
|
|
172
|
-
error: null;
|
|
173
|
-
} | {
|
|
174
|
-
data: {
|
|
175
|
-
user: null;
|
|
176
|
-
};
|
|
177
|
-
error: AuthError;
|
|
178
|
-
};
|
|
143
|
+
export type SSOResponse = RequestResult<{
|
|
144
|
+
/**
|
|
145
|
+
* URL to open in a browser which will complete the sign-in flow by
|
|
146
|
+
* taking the user to the identity provider's authentication flow.
|
|
147
|
+
*
|
|
148
|
+
* On browsers you can set the URL to `window.location.href` to take
|
|
149
|
+
* the user to the authentication flow.
|
|
150
|
+
*/
|
|
151
|
+
url: string;
|
|
152
|
+
}>;
|
|
153
|
+
export type UserResponse = RequestResultSafeDestructure<{
|
|
154
|
+
user: User;
|
|
155
|
+
}>;
|
|
179
156
|
export interface Session {
|
|
180
157
|
/**
|
|
181
158
|
* The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.
|
|
@@ -202,12 +179,14 @@ export interface Session {
|
|
|
202
179
|
* A timestamp of when the token will expire. Returned when a login is confirmed.
|
|
203
180
|
*/
|
|
204
181
|
expires_at?: number;
|
|
205
|
-
token_type:
|
|
182
|
+
token_type: 'bearer';
|
|
206
183
|
/**
|
|
207
184
|
* When using a separate user storage, accessing properties of this object will throw an error.
|
|
208
185
|
*/
|
|
209
186
|
user: User;
|
|
210
187
|
}
|
|
188
|
+
declare const AMRMethods: readonly ["password", "otp", "oauth", "totp", "mfa/totp", "mfa/phone", "mfa/webauthn", "anonymous", "sso/saml", "magiclink", "web3"];
|
|
189
|
+
export type AMRMethod = (typeof AMRMethods)[number] | (string & {});
|
|
211
190
|
/**
|
|
212
191
|
* An authentication methord reference (AMR) entry.
|
|
213
192
|
*
|
|
@@ -218,7 +197,7 @@ export interface Session {
|
|
|
218
197
|
*/
|
|
219
198
|
export interface AMREntry {
|
|
220
199
|
/** Authentication method name. */
|
|
221
|
-
method:
|
|
200
|
+
method: AMRMethod;
|
|
222
201
|
/**
|
|
223
202
|
* Timestamp when the method was successfully used. Represents number of
|
|
224
203
|
* seconds since 1st January 1970 (UNIX epoch) in UTC.
|
|
@@ -237,6 +216,16 @@ export interface UserIdentity {
|
|
|
237
216
|
last_sign_in_at?: string;
|
|
238
217
|
updated_at?: string;
|
|
239
218
|
}
|
|
219
|
+
declare const FactorTypes: readonly ["totp", "phone", "webauthn"];
|
|
220
|
+
/**
|
|
221
|
+
* Type of factor. `totp` and `phone` supported with this version
|
|
222
|
+
*/
|
|
223
|
+
export type FactorType = (typeof FactorTypes)[number];
|
|
224
|
+
declare const FactorVerificationStatuses: readonly ["verified", "unverified"];
|
|
225
|
+
/**
|
|
226
|
+
* The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`
|
|
227
|
+
*/
|
|
228
|
+
type FactorVerificationStatus = (typeof FactorVerificationStatuses)[number];
|
|
240
229
|
/**
|
|
241
230
|
* A MFA factor.
|
|
242
231
|
*
|
|
@@ -244,7 +233,7 @@ export interface UserIdentity {
|
|
|
244
233
|
* @see {@link GoTrueMFAApi#listFactors}
|
|
245
234
|
* @see {@link GoTrueMFAAdminApi#listFactors}
|
|
246
235
|
*/
|
|
247
|
-
export
|
|
236
|
+
export type Factor<Type extends FactorType = FactorType, Status extends FactorVerificationStatus = (typeof FactorVerificationStatuses)[number]> = {
|
|
248
237
|
/** ID of the factor. */
|
|
249
238
|
id: string;
|
|
250
239
|
/** Friendly name of the factor, useful to disambiguate between multiple factors. */
|
|
@@ -252,12 +241,14 @@ export interface Factor {
|
|
|
252
241
|
/**
|
|
253
242
|
* Type of factor. `totp` and `phone` supported with this version
|
|
254
243
|
*/
|
|
255
|
-
factor_type:
|
|
256
|
-
/**
|
|
257
|
-
|
|
244
|
+
factor_type: Type;
|
|
245
|
+
/**
|
|
246
|
+
* The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`
|
|
247
|
+
*/
|
|
248
|
+
status: Status;
|
|
258
249
|
created_at: string;
|
|
259
250
|
updated_at: string;
|
|
260
|
-
}
|
|
251
|
+
};
|
|
261
252
|
export interface UserAppMetadata {
|
|
262
253
|
provider?: string;
|
|
263
254
|
[key: string]: any;
|
|
@@ -289,7 +280,7 @@ export interface User {
|
|
|
289
280
|
identities?: UserIdentity[];
|
|
290
281
|
is_anonymous?: boolean;
|
|
291
282
|
is_sso_user?: boolean;
|
|
292
|
-
factors?: Factor[];
|
|
283
|
+
factors?: (Factor<FactorType, 'verified'> | Factor<FactorType, 'unverified'>)[];
|
|
293
284
|
deleted_at?: string;
|
|
294
285
|
}
|
|
295
286
|
export interface UserAttributes {
|
|
@@ -400,7 +391,7 @@ export interface Subscription {
|
|
|
400
391
|
*/
|
|
401
392
|
unsubscribe: () => void;
|
|
402
393
|
}
|
|
403
|
-
export
|
|
394
|
+
export type SignInAnonymouslyCredentials = {
|
|
404
395
|
options?: {
|
|
405
396
|
/**
|
|
406
397
|
* A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.
|
|
@@ -412,61 +403,27 @@ export declare type SignInAnonymouslyCredentials = {
|
|
|
412
403
|
captchaToken?: string;
|
|
413
404
|
};
|
|
414
405
|
};
|
|
415
|
-
export
|
|
416
|
-
/** The user's email address. */
|
|
417
|
-
email: string;
|
|
418
|
-
/** The user's password. */
|
|
419
|
-
password: string;
|
|
406
|
+
export type SignUpWithPasswordCredentials = Prettify<PasswordCredentialsBase & {
|
|
420
407
|
options?: {
|
|
421
|
-
/** The redirect url embedded in the email link */
|
|
422
408
|
emailRedirectTo?: string;
|
|
423
|
-
/**
|
|
424
|
-
* A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.
|
|
425
|
-
*
|
|
426
|
-
* The `data` should be a JSON object that includes user-specific info, such as their first and last name.
|
|
427
|
-
*/
|
|
428
|
-
data?: object;
|
|
429
|
-
/** Verification token received when the user completes the captcha on the site. */
|
|
430
|
-
captchaToken?: string;
|
|
431
|
-
};
|
|
432
|
-
} | {
|
|
433
|
-
/** The user's phone number. */
|
|
434
|
-
phone: string;
|
|
435
|
-
/** The user's password. */
|
|
436
|
-
password: string;
|
|
437
|
-
options?: {
|
|
438
|
-
/**
|
|
439
|
-
* A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.
|
|
440
|
-
*
|
|
441
|
-
* The `data` should be a JSON object that includes user-specific info, such as their first and last name.
|
|
442
|
-
*/
|
|
443
409
|
data?: object;
|
|
444
|
-
/** Verification token received when the user completes the captcha on the site. Requires a configured WhatsApp sender on Twilio */
|
|
445
410
|
captchaToken?: string;
|
|
446
|
-
/** Messaging channel to use (e.g. whatsapp or sms) */
|
|
447
411
|
channel?: 'sms' | 'whatsapp';
|
|
448
412
|
};
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/** The user's email address. */
|
|
413
|
+
}>;
|
|
414
|
+
type PasswordCredentialsBase = {
|
|
452
415
|
email: string;
|
|
453
|
-
/** The user's password. */
|
|
454
416
|
password: string;
|
|
455
|
-
options?: {
|
|
456
|
-
/** Verification token received when the user completes the captcha on the site. */
|
|
457
|
-
captchaToken?: string;
|
|
458
|
-
};
|
|
459
417
|
} | {
|
|
460
|
-
/** The user's phone number. */
|
|
461
418
|
phone: string;
|
|
462
|
-
/** The user's password. */
|
|
463
419
|
password: string;
|
|
420
|
+
};
|
|
421
|
+
export type SignInWithPasswordCredentials = PasswordCredentialsBase & {
|
|
464
422
|
options?: {
|
|
465
|
-
/** Verification token received when the user completes the captcha on the site. */
|
|
466
423
|
captchaToken?: string;
|
|
467
424
|
};
|
|
468
425
|
};
|
|
469
|
-
export
|
|
426
|
+
export type SignInWithPasswordlessCredentials = {
|
|
470
427
|
/** The user's email address. */
|
|
471
428
|
email: string;
|
|
472
429
|
options?: {
|
|
@@ -501,8 +458,8 @@ export declare type SignInWithPasswordlessCredentials = {
|
|
|
501
458
|
channel?: 'sms' | 'whatsapp';
|
|
502
459
|
};
|
|
503
460
|
};
|
|
504
|
-
export
|
|
505
|
-
export
|
|
461
|
+
export type AuthFlowType = 'implicit' | 'pkce';
|
|
462
|
+
export type SignInWithOAuthCredentials = {
|
|
506
463
|
/** One of the providers supported by GoTrue. */
|
|
507
464
|
provider: Provider;
|
|
508
465
|
options?: {
|
|
@@ -518,7 +475,7 @@ export declare type SignInWithOAuthCredentials = {
|
|
|
518
475
|
skipBrowserRedirect?: boolean;
|
|
519
476
|
};
|
|
520
477
|
};
|
|
521
|
-
export
|
|
478
|
+
export type SignInWithIdTokenCredentials = {
|
|
522
479
|
/** Provider name or OIDC `iss` value identifying which provider should be used to verify the provided token. Supported names: `google`, `apple`, `azure`, `facebook`, `kakao`, `keycloak` (deprecated). */
|
|
523
480
|
provider: 'google' | 'apple' | 'azure' | 'facebook' | 'kakao' | (string & {});
|
|
524
481
|
/** OIDC ID token issued by the specified provider. The `iss` claim in the ID token must match the supplied provider. Some ID tokens contain an `at_hash` which require that you provide an `access_token` value to be accepted properly. If the token contains a `nonce` claim you must supply the nonce used to obtain the ID token. */
|
|
@@ -532,14 +489,14 @@ export declare type SignInWithIdTokenCredentials = {
|
|
|
532
489
|
captchaToken?: string;
|
|
533
490
|
};
|
|
534
491
|
};
|
|
535
|
-
export
|
|
492
|
+
export type SolanaWallet = {
|
|
536
493
|
signIn?: (...inputs: SolanaSignInInput[]) => Promise<SolanaSignInOutput | SolanaSignInOutput[]>;
|
|
537
494
|
publicKey?: {
|
|
538
495
|
toBase58: () => string;
|
|
539
496
|
} | null;
|
|
540
497
|
signMessage?: (message: Uint8Array, encoding?: 'utf8' | string) => Promise<Uint8Array> | undefined;
|
|
541
498
|
};
|
|
542
|
-
export
|
|
499
|
+
export type SolanaWeb3Credentials = {
|
|
543
500
|
chain: 'solana';
|
|
544
501
|
/** Wallet interface to use. If not specified will default to `window.solana`. */
|
|
545
502
|
wallet?: SolanaWallet;
|
|
@@ -563,12 +520,12 @@ export declare type SolanaWeb3Credentials = {
|
|
|
563
520
|
captchaToken?: string;
|
|
564
521
|
};
|
|
565
522
|
};
|
|
566
|
-
export
|
|
567
|
-
export
|
|
523
|
+
export type EthereumWallet = EIP1193Provider;
|
|
524
|
+
export type EthereumWeb3Credentials = {
|
|
568
525
|
chain: 'ethereum';
|
|
569
|
-
/** Wallet interface to use. If not specified will default to `window.
|
|
526
|
+
/** Wallet interface to use. If not specified will default to `window.ethereum`. */
|
|
570
527
|
wallet?: EthereumWallet;
|
|
571
|
-
/** Optional statement to include in the Sign in with
|
|
528
|
+
/** Optional statement to include in the Sign in with Ethereum message. Must not include new line characters. Most wallets like Phantom **require specifying a statement!** */
|
|
572
529
|
statement?: string;
|
|
573
530
|
options?: {
|
|
574
531
|
/** URL to use with the wallet interface. Some wallets do not allow signing a message for URLs different from the current page. */
|
|
@@ -581,15 +538,15 @@ export declare type EthereumWeb3Credentials = {
|
|
|
581
538
|
chain: 'ethereum';
|
|
582
539
|
/** Sign in with Ethereum compatible message. Must include `Issued At`, `URI` and `Version`. */
|
|
583
540
|
message: string;
|
|
584
|
-
/**
|
|
541
|
+
/** Ethereum curve (secp256k1) signature of the message. */
|
|
585
542
|
signature: Hex;
|
|
586
543
|
options?: {
|
|
587
544
|
/** Verification token received when the user completes the captcha on the site. */
|
|
588
545
|
captchaToken?: string;
|
|
589
546
|
};
|
|
590
547
|
};
|
|
591
|
-
export
|
|
592
|
-
export
|
|
548
|
+
export type Web3Credentials = SolanaWeb3Credentials | EthereumWeb3Credentials;
|
|
549
|
+
export type VerifyOtpParams = VerifyMobileOtpParams | VerifyEmailOtpParams | VerifyTokenHashParams;
|
|
593
550
|
export interface VerifyMobileOtpParams {
|
|
594
551
|
/** The user's phone number. */
|
|
595
552
|
phone: string;
|
|
@@ -631,9 +588,9 @@ export interface VerifyTokenHashParams {
|
|
|
631
588
|
/** The user's verification type. */
|
|
632
589
|
type: EmailOtpType;
|
|
633
590
|
}
|
|
634
|
-
export
|
|
635
|
-
export
|
|
636
|
-
export
|
|
591
|
+
export type MobileOtpType = 'sms' | 'phone_change';
|
|
592
|
+
export type EmailOtpType = 'signup' | 'invite' | 'magiclink' | 'recovery' | 'email_change' | 'email';
|
|
593
|
+
export type ResendParams = {
|
|
637
594
|
type: Extract<EmailOtpType, 'signup' | 'email_change'>;
|
|
638
595
|
email: string;
|
|
639
596
|
options?: {
|
|
@@ -650,7 +607,7 @@ export declare type ResendParams = {
|
|
|
650
607
|
captchaToken?: string;
|
|
651
608
|
};
|
|
652
609
|
};
|
|
653
|
-
export
|
|
610
|
+
export type SignInWithSSO = {
|
|
654
611
|
/** UUID of the SSO provider to invoke single-sign on to. */
|
|
655
612
|
providerId: string;
|
|
656
613
|
options?: {
|
|
@@ -669,25 +626,25 @@ export declare type SignInWithSSO = {
|
|
|
669
626
|
captchaToken?: string;
|
|
670
627
|
};
|
|
671
628
|
};
|
|
672
|
-
export
|
|
629
|
+
export type GenerateSignupLinkParams = {
|
|
673
630
|
type: 'signup';
|
|
674
631
|
email: string;
|
|
675
632
|
password: string;
|
|
676
633
|
options?: Pick<GenerateLinkOptions, 'data' | 'redirectTo'>;
|
|
677
634
|
};
|
|
678
|
-
export
|
|
635
|
+
export type GenerateInviteOrMagiclinkParams = {
|
|
679
636
|
type: 'invite' | 'magiclink';
|
|
680
637
|
/** The user's email */
|
|
681
638
|
email: string;
|
|
682
639
|
options?: Pick<GenerateLinkOptions, 'data' | 'redirectTo'>;
|
|
683
640
|
};
|
|
684
|
-
export
|
|
641
|
+
export type GenerateRecoveryLinkParams = {
|
|
685
642
|
type: 'recovery';
|
|
686
643
|
/** The user's email */
|
|
687
644
|
email: string;
|
|
688
645
|
options?: Pick<GenerateLinkOptions, 'redirectTo'>;
|
|
689
646
|
};
|
|
690
|
-
export
|
|
647
|
+
export type GenerateEmailChangeLinkParams = {
|
|
691
648
|
type: 'email_change_current' | 'email_change_new';
|
|
692
649
|
/** The user's email */
|
|
693
650
|
email: string;
|
|
@@ -707,22 +664,13 @@ export interface GenerateLinkOptions {
|
|
|
707
664
|
/** The URL which will be appended to the email link generated. */
|
|
708
665
|
redirectTo?: string;
|
|
709
666
|
}
|
|
710
|
-
export
|
|
711
|
-
export
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
};
|
|
716
|
-
error: null;
|
|
717
|
-
} | {
|
|
718
|
-
data: {
|
|
719
|
-
properties: null;
|
|
720
|
-
user: null;
|
|
721
|
-
};
|
|
722
|
-
error: AuthError;
|
|
723
|
-
};
|
|
667
|
+
export type GenerateLinkParams = GenerateSignupLinkParams | GenerateInviteOrMagiclinkParams | GenerateRecoveryLinkParams | GenerateEmailChangeLinkParams;
|
|
668
|
+
export type GenerateLinkResponse = RequestResultSafeDestructure<{
|
|
669
|
+
properties: GenerateLinkProperties;
|
|
670
|
+
user: User;
|
|
671
|
+
}>;
|
|
724
672
|
/** The properties related to the email link generated */
|
|
725
|
-
export
|
|
673
|
+
export type GenerateLinkProperties = {
|
|
726
674
|
/**
|
|
727
675
|
* The email link to send to the user.
|
|
728
676
|
* The action_link follows the following format: auth/v1/verify?type={verification_type}&token={hashed_token}&redirect_to={redirect_to}
|
|
@@ -742,113 +690,191 @@ export declare type GenerateLinkProperties = {
|
|
|
742
690
|
/** The verification type that the email link is associated to. */
|
|
743
691
|
verification_type: GenerateLinkType;
|
|
744
692
|
};
|
|
745
|
-
export
|
|
746
|
-
export
|
|
747
|
-
export
|
|
693
|
+
export type GenerateLinkType = 'signup' | 'invite' | 'magiclink' | 'recovery' | 'email_change_current' | 'email_change_new';
|
|
694
|
+
export type MFAEnrollParams = MFAEnrollTOTPParams | MFAEnrollPhoneParams | MFAEnrollWebauthnParams;
|
|
695
|
+
export type MFAUnenrollParams = {
|
|
748
696
|
/** ID of the factor being unenrolled. */
|
|
749
697
|
factorId: string;
|
|
750
698
|
};
|
|
751
|
-
|
|
699
|
+
type MFAVerifyParamsBase = {
|
|
752
700
|
/** ID of the factor being verified. Returned in enroll(). */
|
|
753
701
|
factorId: string;
|
|
754
702
|
/** ID of the challenge being verified. Returned in challenge(). */
|
|
755
703
|
challengeId: string;
|
|
704
|
+
};
|
|
705
|
+
type MFAVerifyTOTPParamFields = {
|
|
756
706
|
/** Verification code provided by the user. */
|
|
757
707
|
code: string;
|
|
758
708
|
};
|
|
759
|
-
export
|
|
709
|
+
export type MFAVerifyTOTPParams = Prettify<MFAVerifyParamsBase & MFAVerifyTOTPParamFields>;
|
|
710
|
+
type MFAVerifyPhoneParamFields = MFAVerifyTOTPParamFields;
|
|
711
|
+
export type MFAVerifyPhoneParams = Prettify<MFAVerifyParamsBase & MFAVerifyPhoneParamFields>;
|
|
712
|
+
type MFAVerifyWebauthnParamFieldsBase = {
|
|
713
|
+
/** Relying party ID */
|
|
714
|
+
rpId: string;
|
|
715
|
+
/** Relying party origins */
|
|
716
|
+
rpOrigins?: string[];
|
|
717
|
+
};
|
|
718
|
+
type MFAVerifyWebauthnCredentialParamFields<T extends 'create' | 'request' = 'create' | 'request'> = {
|
|
719
|
+
/** Operation type */
|
|
720
|
+
type: T;
|
|
721
|
+
/** Creation response from the authenticator (for enrollment/unverified factors) */
|
|
722
|
+
credential_response: T extends 'create' ? RegistrationCredential : AuthenticationCredential;
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* WebAuthn-specific fields for MFA verification.
|
|
726
|
+
* Supports both credential creation (registration) and request (authentication) flows.
|
|
727
|
+
* @template T - Type of WebAuthn operation: 'create' for registration, 'request' for authentication
|
|
728
|
+
*/
|
|
729
|
+
export type MFAVerifyWebauthnParamFields<T extends 'create' | 'request' = 'create' | 'request'> = {
|
|
730
|
+
webauthn: MFAVerifyWebauthnParamFieldsBase & MFAVerifyWebauthnCredentialParamFields<T>;
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* Parameters for WebAuthn MFA verification.
|
|
734
|
+
* Used to verify WebAuthn credentials after challenge.
|
|
735
|
+
* @template T - Type of WebAuthn operation: 'create' for registration, 'request' for authentication
|
|
736
|
+
* @see {@link https://w3c.github.io/webauthn/#sctn-verifying-assertion W3C WebAuthn Spec - Verifying an Authentication Assertion}
|
|
737
|
+
*/
|
|
738
|
+
export type MFAVerifyWebauthnParams<T extends 'create' | 'request' = 'create' | 'request'> = Prettify<MFAVerifyParamsBase & MFAVerifyWebauthnParamFields<T>>;
|
|
739
|
+
export type MFAVerifyParams = MFAVerifyTOTPParams | MFAVerifyPhoneParams | MFAVerifyWebauthnParams;
|
|
740
|
+
type MFAChallengeParamsBase = {
|
|
760
741
|
/** ID of the factor to be challenged. Returned in enroll(). */
|
|
761
742
|
factorId: string;
|
|
762
|
-
/** Messaging channel to use (e.g. whatsapp or sms). Only relevant for phone factors */
|
|
763
|
-
channel?: 'sms' | 'whatsapp';
|
|
764
743
|
};
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
744
|
+
declare const MFATOTPChannels: readonly ["sms", "whatsapp"];
|
|
745
|
+
export type MFATOTPChannel = (typeof MFATOTPChannels)[number];
|
|
746
|
+
export type MFAChallengeTOTPParams = Prettify<MFAChallengeParamsBase>;
|
|
747
|
+
type MFAChallengePhoneParamFields<Channel extends MFATOTPChannel = MFATOTPChannel> = {
|
|
748
|
+
/** Messaging channel to use (e.g. whatsapp or sms). Only relevant for phone factors */
|
|
749
|
+
channel: Channel;
|
|
770
750
|
};
|
|
771
|
-
export
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
|
|
779
|
-
/** Refresh token you can use to obtain new access tokens when expired. */
|
|
780
|
-
refresh_token: string;
|
|
781
|
-
/** Updated user profile. */
|
|
782
|
-
user: User;
|
|
751
|
+
export type MFAChallengePhoneParams = Prettify<MFAChallengeParamsBase & MFAChallengePhoneParamFields>;
|
|
752
|
+
/** WebAuthn parameters for WebAuthn factor challenge */
|
|
753
|
+
type MFAChallengeWebauthnParamFields = {
|
|
754
|
+
webauthn: {
|
|
755
|
+
/** Relying party ID */
|
|
756
|
+
rpId: string;
|
|
757
|
+
/** Relying party origins*/
|
|
758
|
+
rpOrigins?: string[];
|
|
783
759
|
};
|
|
784
|
-
error: null;
|
|
785
|
-
} | {
|
|
786
|
-
data: null;
|
|
787
|
-
error: AuthError;
|
|
788
760
|
};
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
761
|
+
/**
|
|
762
|
+
* Parameters for initiating a WebAuthn MFA challenge.
|
|
763
|
+
* Includes Relying Party information needed for WebAuthn ceremonies.
|
|
764
|
+
* @see {@link https://w3c.github.io/webauthn/#sctn-rp-operations W3C WebAuthn Spec - Relying Party Operations}
|
|
765
|
+
*/
|
|
766
|
+
export type MFAChallengeWebauthnParams = Prettify<MFAChallengeParamsBase & MFAChallengeWebauthnParamFields>;
|
|
767
|
+
export type MFAChallengeParams = MFAChallengeTOTPParams | MFAChallengePhoneParams | MFAChallengeWebauthnParams;
|
|
768
|
+
type MFAChallengeAndVerifyParamsBase = Omit<MFAVerifyParamsBase, 'challengeId'>;
|
|
769
|
+
type MFAChallengeAndVerifyTOTPParamFields = MFAVerifyTOTPParamFields;
|
|
770
|
+
type MFAChallengeAndVerifyTOTPParams = Prettify<MFAChallengeAndVerifyParamsBase & MFAChallengeAndVerifyTOTPParamFields>;
|
|
771
|
+
export type MFAChallengeAndVerifyParams = MFAChallengeAndVerifyTOTPParams;
|
|
772
|
+
/**
|
|
773
|
+
* Data returned after successful MFA verification.
|
|
774
|
+
* Contains new session tokens and updated user information.
|
|
775
|
+
*/
|
|
776
|
+
export type AuthMFAVerifyResponseData = {
|
|
777
|
+
/** New access token (JWT) after successful verification. */
|
|
778
|
+
access_token: string;
|
|
779
|
+
/** Type of token, always `bearer`. */
|
|
780
|
+
token_type: 'bearer';
|
|
781
|
+
/** Number of seconds in which the access token will expire. */
|
|
782
|
+
expires_in: number;
|
|
783
|
+
/** Refresh token you can use to obtain new access tokens when expired. */
|
|
784
|
+
refresh_token: string;
|
|
785
|
+
/** Updated user profile. */
|
|
786
|
+
user: User;
|
|
799
787
|
};
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
788
|
+
/**
|
|
789
|
+
* Response type for MFA verification operations.
|
|
790
|
+
* Returns session tokens on successful verification.
|
|
791
|
+
*/
|
|
792
|
+
export type AuthMFAVerifyResponse = RequestResult<AuthMFAVerifyResponseData>;
|
|
793
|
+
export type AuthMFAEnrollResponse = AuthMFAEnrollTOTPResponse | AuthMFAEnrollPhoneResponse | AuthMFAEnrollWebauthnResponse;
|
|
794
|
+
export type AuthMFAUnenrollResponse = RequestResult<{
|
|
795
|
+
/** ID of the factor that was successfully unenrolled. */
|
|
796
|
+
id: string;
|
|
797
|
+
}>;
|
|
798
|
+
type AuthMFAChallengeResponseBase<T extends FactorType> = {
|
|
799
|
+
/** ID of the newly created challenge. */
|
|
800
|
+
id: string;
|
|
801
|
+
/** Factor Type which generated the challenge */
|
|
802
|
+
type: T;
|
|
803
|
+
/** Timestamp in UNIX seconds when this challenge will no longer be usable. */
|
|
804
|
+
expires_at: number;
|
|
813
805
|
};
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
806
|
+
type AuthMFAChallengeTOTPResponseFields = {};
|
|
807
|
+
export type AuthMFAChallengeTOTPResponse = RequestResult<Prettify<AuthMFAChallengeResponseBase<'totp'> & AuthMFAChallengeTOTPResponseFields>>;
|
|
808
|
+
type AuthMFAChallengePhoneResponseFields = {};
|
|
809
|
+
export type AuthMFAChallengePhoneResponse = RequestResult<Prettify<AuthMFAChallengeResponseBase<'phone'> & AuthMFAChallengePhoneResponseFields>>;
|
|
810
|
+
type AuthMFAChallengeWebauthnResponseFields = {
|
|
811
|
+
webauthn: {
|
|
812
|
+
type: 'create';
|
|
813
|
+
credential_options: {
|
|
814
|
+
publicKey: PublicKeyCredentialCreationOptionsFuture;
|
|
815
|
+
};
|
|
816
|
+
} | {
|
|
817
|
+
type: 'request';
|
|
818
|
+
credential_options: {
|
|
819
|
+
publicKey: PublicKeyCredentialRequestOptionsFuture;
|
|
820
|
+
};
|
|
822
821
|
};
|
|
823
|
-
error: null;
|
|
824
|
-
} | {
|
|
825
|
-
data: null;
|
|
826
|
-
error: AuthError;
|
|
827
822
|
};
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
currentAuthenticationMethods: AMREntry[];
|
|
823
|
+
/**
|
|
824
|
+
* Response type for WebAuthn MFA challenge.
|
|
825
|
+
* Contains credential creation or request options from the server.
|
|
826
|
+
* @see {@link https://w3c.github.io/webauthn/#sctn-credential-creation W3C WebAuthn Spec - Credential Creation}
|
|
827
|
+
*/
|
|
828
|
+
export type AuthMFAChallengeWebauthnResponse = RequestResult<Prettify<AuthMFAChallengeResponseBase<'webauthn'> & AuthMFAChallengeWebauthnResponseFields>>;
|
|
829
|
+
type AuthMFAChallengeWebauthnResponseFieldsJSON = {
|
|
830
|
+
webauthn: {
|
|
831
|
+
type: 'create';
|
|
832
|
+
credential_options: {
|
|
833
|
+
publicKey: ServerCredentialCreationOptions;
|
|
834
|
+
};
|
|
835
|
+
} | {
|
|
836
|
+
type: 'request';
|
|
837
|
+
credential_options: {
|
|
838
|
+
publicKey: ServerCredentialRequestOptions;
|
|
839
|
+
};
|
|
846
840
|
};
|
|
847
|
-
error: null;
|
|
848
|
-
} | {
|
|
849
|
-
data: null;
|
|
850
|
-
error: AuthError;
|
|
851
841
|
};
|
|
842
|
+
/**
|
|
843
|
+
* JSON-serializable version of WebAuthn challenge response.
|
|
844
|
+
* Used for server communication with base64url-encoded binary fields.
|
|
845
|
+
*/
|
|
846
|
+
export type AuthMFAChallengeWebauthnResponseDataJSON = Prettify<AuthMFAChallengeResponseBase<'webauthn'> & AuthMFAChallengeWebauthnResponseFieldsJSON>;
|
|
847
|
+
/**
|
|
848
|
+
* Server response type for WebAuthn MFA challenge.
|
|
849
|
+
* Contains JSON-formatted WebAuthn options ready for browser API.
|
|
850
|
+
*/
|
|
851
|
+
export type AuthMFAChallengeWebauthnServerResponse = RequestResult<AuthMFAChallengeWebauthnResponseDataJSON>;
|
|
852
|
+
export type AuthMFAChallengeResponse = AuthMFAChallengeTOTPResponse | AuthMFAChallengePhoneResponse | AuthMFAChallengeWebauthnResponse;
|
|
853
|
+
/** response of ListFactors, which should contain all the types of factors that are available, this ensures we always include all */
|
|
854
|
+
export type AuthMFAListFactorsResponse<T extends typeof FactorTypes = typeof FactorTypes> = RequestResult<{
|
|
855
|
+
/** All available factors (verified and unverified). */
|
|
856
|
+
all: Prettify<Factor>[];
|
|
857
|
+
} & {
|
|
858
|
+
[K in T[number]]: Prettify<Factor<K, 'verified'>>[];
|
|
859
|
+
}>;
|
|
860
|
+
export type AuthenticatorAssuranceLevels = 'aal1' | 'aal2';
|
|
861
|
+
export type AuthMFAGetAuthenticatorAssuranceLevelResponse = RequestResult<{
|
|
862
|
+
/** Current AAL level of the session. */
|
|
863
|
+
currentLevel: AuthenticatorAssuranceLevels | null;
|
|
864
|
+
/**
|
|
865
|
+
* Next possible AAL level for the session. If the next level is higher
|
|
866
|
+
* than the current one, the user should go through MFA.
|
|
867
|
+
*
|
|
868
|
+
* @see {@link GoTrueMFAApi#challenge}
|
|
869
|
+
*/
|
|
870
|
+
nextLevel: AuthenticatorAssuranceLevels | null;
|
|
871
|
+
/**
|
|
872
|
+
* A list of all authentication methods attached to this session. Use
|
|
873
|
+
* the information here to detect the last time a user verified a
|
|
874
|
+
* factor, for example if implementing a step-up scenario.
|
|
875
|
+
*/
|
|
876
|
+
currentAuthenticationMethods: AMREntry[];
|
|
877
|
+
}>;
|
|
852
878
|
/**
|
|
853
879
|
* Contains the full multi-factor authentication API.
|
|
854
880
|
*
|
|
@@ -862,20 +888,26 @@ export interface GoTrueMFAApi {
|
|
|
862
888
|
* The user has to enter the code from their authenticator app to verify it.
|
|
863
889
|
*
|
|
864
890
|
* Upon verifying a factor, all other sessions are logged out and the current session's authenticator level is promoted to `aal2`.
|
|
865
|
-
*
|
|
866
891
|
*/
|
|
867
892
|
enroll(params: MFAEnrollTOTPParams): Promise<AuthMFAEnrollTOTPResponse>;
|
|
868
893
|
enroll(params: MFAEnrollPhoneParams): Promise<AuthMFAEnrollPhoneResponse>;
|
|
894
|
+
enroll(params: MFAEnrollWebauthnParams): Promise<AuthMFAEnrollWebauthnResponse>;
|
|
869
895
|
enroll(params: MFAEnrollParams): Promise<AuthMFAEnrollResponse>;
|
|
870
896
|
/**
|
|
871
897
|
* Prepares a challenge used to verify that a user has access to a MFA
|
|
872
898
|
* factor.
|
|
873
899
|
*/
|
|
900
|
+
challenge(params: MFAChallengeTOTPParams): Promise<Prettify<AuthMFAChallengeTOTPResponse>>;
|
|
901
|
+
challenge(params: MFAChallengePhoneParams): Promise<Prettify<AuthMFAChallengePhoneResponse>>;
|
|
902
|
+
challenge(params: MFAChallengeWebauthnParams): Promise<Prettify<AuthMFAChallengeWebauthnResponse>>;
|
|
874
903
|
challenge(params: MFAChallengeParams): Promise<AuthMFAChallengeResponse>;
|
|
875
904
|
/**
|
|
876
905
|
* Verifies a code against a challenge. The verification code is
|
|
877
906
|
* provided by the user by entering a code seen in their authenticator app.
|
|
878
907
|
*/
|
|
908
|
+
verify(params: MFAVerifyTOTPParams): Promise<AuthMFAVerifyResponse>;
|
|
909
|
+
verify(params: MFAVerifyPhoneParams): Promise<AuthMFAVerifyResponse>;
|
|
910
|
+
verify(params: MFAVerifyWebauthnParams): Promise<AuthMFAVerifyResponse>;
|
|
879
911
|
verify(params: MFAVerifyParams): Promise<AuthMFAVerifyResponse>;
|
|
880
912
|
/**
|
|
881
913
|
* Unenroll removes a MFA factor.
|
|
@@ -910,24 +942,19 @@ export interface GoTrueMFAApi {
|
|
|
910
942
|
*
|
|
911
943
|
*/
|
|
912
944
|
getAuthenticatorAssuranceLevel(): Promise<AuthMFAGetAuthenticatorAssuranceLevelResponse>;
|
|
945
|
+
webauthn: WebAuthnApi;
|
|
913
946
|
}
|
|
914
947
|
/**
|
|
915
948
|
* @expermental
|
|
916
949
|
*/
|
|
917
|
-
export
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
};
|
|
922
|
-
error: null;
|
|
923
|
-
} | {
|
|
924
|
-
data: null;
|
|
925
|
-
error: AuthError;
|
|
926
|
-
};
|
|
950
|
+
export type AuthMFAAdminDeleteFactorResponse = RequestResult<{
|
|
951
|
+
/** ID of the factor that was successfully deleted. */
|
|
952
|
+
id: string;
|
|
953
|
+
}>;
|
|
927
954
|
/**
|
|
928
955
|
* @expermental
|
|
929
956
|
*/
|
|
930
|
-
export
|
|
957
|
+
export type AuthMFAAdminDeleteFactorParams = {
|
|
931
958
|
/** ID of the MFA factor to delete. */
|
|
932
959
|
id: string;
|
|
933
960
|
/** ID of the user whose factor is being deleted. */
|
|
@@ -936,20 +963,14 @@ export declare type AuthMFAAdminDeleteFactorParams = {
|
|
|
936
963
|
/**
|
|
937
964
|
* @expermental
|
|
938
965
|
*/
|
|
939
|
-
export
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
};
|
|
944
|
-
error: null;
|
|
945
|
-
} | {
|
|
946
|
-
data: null;
|
|
947
|
-
error: AuthError;
|
|
948
|
-
};
|
|
966
|
+
export type AuthMFAAdminListFactorsResponse = RequestResult<{
|
|
967
|
+
/** All factors attached to the user. */
|
|
968
|
+
factors: Factor[];
|
|
969
|
+
}>;
|
|
949
970
|
/**
|
|
950
971
|
* @expermental
|
|
951
972
|
*/
|
|
952
|
-
export
|
|
973
|
+
export type AuthMFAAdminListFactorsParams = {
|
|
953
974
|
/** ID of the user. */
|
|
954
975
|
userId: string;
|
|
955
976
|
};
|
|
@@ -974,12 +995,12 @@ export interface GoTrueAdminMFAApi {
|
|
|
974
995
|
*/
|
|
975
996
|
deleteFactor(params: AuthMFAAdminDeleteFactorParams): Promise<AuthMFAAdminDeleteFactorResponse>;
|
|
976
997
|
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
998
|
+
type AnyFunction = (...args: any[]) => any;
|
|
999
|
+
type MaybePromisify<T> = T | Promise<T>;
|
|
1000
|
+
type PromisifyMethods<T> = {
|
|
980
1001
|
[K in keyof T]: T[K] extends AnyFunction ? (...args: Parameters<T[K]>) => MaybePromisify<ReturnType<T[K]>> : T[K];
|
|
981
1002
|
};
|
|
982
|
-
export
|
|
1003
|
+
export type SupportedStorage = PromisifyMethods<Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>> & {
|
|
983
1004
|
/**
|
|
984
1005
|
* If set to `true` signals to the library that the storage medium is used
|
|
985
1006
|
* on a server and the values may not be authentic, such as reading from
|
|
@@ -989,29 +1010,23 @@ export declare type SupportedStorage = PromisifyMethods<Pick<Storage, 'getItem'
|
|
|
989
1010
|
*/
|
|
990
1011
|
isServer?: boolean;
|
|
991
1012
|
};
|
|
992
|
-
export
|
|
1013
|
+
export type InitializeResult = {
|
|
993
1014
|
error: AuthError | null;
|
|
994
1015
|
};
|
|
995
|
-
export
|
|
996
|
-
|
|
997
|
-
error: null;
|
|
998
|
-
} | {
|
|
999
|
-
session: null;
|
|
1000
|
-
error: AuthError;
|
|
1001
|
-
};
|
|
1002
|
-
export declare type Pagination = {
|
|
1016
|
+
export type CallRefreshTokenResult = RequestResult<Session>;
|
|
1017
|
+
export type Pagination = {
|
|
1003
1018
|
[key: string]: any;
|
|
1004
1019
|
nextPage: number | null;
|
|
1005
1020
|
lastPage: number;
|
|
1006
1021
|
total: number;
|
|
1007
1022
|
};
|
|
1008
|
-
export
|
|
1023
|
+
export type PageParams = {
|
|
1009
1024
|
/** The page number */
|
|
1010
1025
|
page?: number;
|
|
1011
1026
|
/** Number of items returned per page */
|
|
1012
1027
|
perPage?: number;
|
|
1013
1028
|
};
|
|
1014
|
-
export
|
|
1029
|
+
export type SignOut = {
|
|
1015
1030
|
/**
|
|
1016
1031
|
* Determines which sessions should be
|
|
1017
1032
|
* logged out. Global means all
|
|
@@ -1024,72 +1039,72 @@ export declare type SignOut = {
|
|
|
1024
1039
|
*/
|
|
1025
1040
|
scope?: 'global' | 'local' | 'others';
|
|
1026
1041
|
};
|
|
1027
|
-
|
|
1042
|
+
type MFAEnrollParamsBase<T extends FactorType> = {
|
|
1028
1043
|
/** The type of factor being enrolled. */
|
|
1029
|
-
factorType:
|
|
1030
|
-
/** Domain which the user is enrolled with. */
|
|
1031
|
-
issuer?: string;
|
|
1044
|
+
factorType: T;
|
|
1032
1045
|
/** Human readable name assigned to the factor. */
|
|
1033
1046
|
friendlyName?: string;
|
|
1034
1047
|
};
|
|
1035
|
-
|
|
1036
|
-
/**
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1048
|
+
type MFAEnrollTOTPParamFields = {
|
|
1049
|
+
/** Domain which the user is enrolled with. */
|
|
1050
|
+
issuer?: string;
|
|
1051
|
+
};
|
|
1052
|
+
export type MFAEnrollTOTPParams = Prettify<MFAEnrollParamsBase<'totp'> & MFAEnrollTOTPParamFields>;
|
|
1053
|
+
type MFAEnrollPhoneParamFields = {
|
|
1040
1054
|
/** Phone number associated with a factor. Number should conform to E.164 format */
|
|
1041
1055
|
phone: string;
|
|
1042
1056
|
};
|
|
1043
|
-
export
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
secret: string;
|
|
1059
|
-
/** The authenticator URI encoded within the QR code, should you need
|
|
1060
|
-
* to use it. Avoid loggin this value to the console. */
|
|
1061
|
-
uri: string;
|
|
1062
|
-
};
|
|
1063
|
-
/** Friendly name of the factor, useful for distinguishing between factors **/
|
|
1064
|
-
friendly_name?: string;
|
|
1065
|
-
};
|
|
1066
|
-
error: null;
|
|
1067
|
-
} | {
|
|
1068
|
-
data: null;
|
|
1069
|
-
error: AuthError;
|
|
1057
|
+
export type MFAEnrollPhoneParams = Prettify<MFAEnrollParamsBase<'phone'> & MFAEnrollPhoneParamFields>;
|
|
1058
|
+
type MFAEnrollWebauthnFields = {};
|
|
1059
|
+
/**
|
|
1060
|
+
* Parameters for enrolling a WebAuthn factor.
|
|
1061
|
+
* Creates an unverified WebAuthn factor that must be verified with a credential.
|
|
1062
|
+
* @see {@link https://w3c.github.io/webauthn/#sctn-registering-a-new-credential W3C WebAuthn Spec - Registering a New Credential}
|
|
1063
|
+
*/
|
|
1064
|
+
export type MFAEnrollWebauthnParams = Prettify<MFAEnrollParamsBase<'webauthn'> & MFAEnrollWebauthnFields>;
|
|
1065
|
+
type AuthMFAEnrollResponseBase<T extends FactorType> = {
|
|
1066
|
+
/** ID of the factor that was just enrolled (in an unverified state). */
|
|
1067
|
+
id: string;
|
|
1068
|
+
/** Type of MFA factor.*/
|
|
1069
|
+
type: T;
|
|
1070
|
+
/** Friendly name of the factor, useful for distinguishing between factors **/
|
|
1071
|
+
friendly_name?: string;
|
|
1070
1072
|
};
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1073
|
+
type AuthMFAEnrollTOTPResponseFields = {
|
|
1074
|
+
/** TOTP enrollment information. */
|
|
1075
|
+
totp: {
|
|
1076
|
+
/** Contains a QR code encoding the authenticator URI. You can
|
|
1077
|
+
* convert it to a URL by prepending `data:image/svg+xml;utf-8,` to
|
|
1078
|
+
* the value. Avoid logging this value to the console. */
|
|
1079
|
+
qr_code: string;
|
|
1080
|
+
/** The TOTP secret (also encoded in the QR code). Show this secret
|
|
1081
|
+
* in a password-style field to the user, in case they are unable to
|
|
1082
|
+
* scan the QR code. Avoid logging this value to the console. */
|
|
1083
|
+
secret: string;
|
|
1084
|
+
/** The authenticator URI encoded within the QR code, should you need
|
|
1085
|
+
* to use it. Avoid loggin this value to the console. */
|
|
1086
|
+
uri: string;
|
|
1081
1087
|
};
|
|
1082
|
-
error: null;
|
|
1083
|
-
} | {
|
|
1084
|
-
data: null;
|
|
1085
|
-
error: AuthError;
|
|
1086
1088
|
};
|
|
1087
|
-
export
|
|
1089
|
+
export type AuthMFAEnrollTOTPResponse = RequestResult<Prettify<AuthMFAEnrollResponseBase<'totp'> & AuthMFAEnrollTOTPResponseFields>>;
|
|
1090
|
+
type AuthMFAEnrollPhoneResponseFields = {
|
|
1091
|
+
/** Phone number of the MFA factor in E.164 format. Used to send messages */
|
|
1092
|
+
phone: string;
|
|
1093
|
+
};
|
|
1094
|
+
export type AuthMFAEnrollPhoneResponse = RequestResult<Prettify<AuthMFAEnrollResponseBase<'phone'> & AuthMFAEnrollPhoneResponseFields>>;
|
|
1095
|
+
type AuthMFAEnrollWebauthnFields = {};
|
|
1096
|
+
/**
|
|
1097
|
+
* Response type for WebAuthn factor enrollment.
|
|
1098
|
+
* Returns the enrolled factor ID and metadata.
|
|
1099
|
+
* @see {@link https://w3c.github.io/webauthn/#sctn-registering-a-new-credential W3C WebAuthn Spec - Registering a New Credential}
|
|
1100
|
+
*/
|
|
1101
|
+
export type AuthMFAEnrollWebauthnResponse = RequestResult<Prettify<AuthMFAEnrollResponseBase<'webauthn'> & AuthMFAEnrollWebauthnFields>>;
|
|
1102
|
+
export type JwtHeader = {
|
|
1088
1103
|
alg: 'RS256' | 'ES256' | 'HS256';
|
|
1089
1104
|
kid: string;
|
|
1090
1105
|
typ: string;
|
|
1091
1106
|
};
|
|
1092
|
-
export
|
|
1107
|
+
export type RequiredClaims = {
|
|
1093
1108
|
iss: string;
|
|
1094
1109
|
sub: string;
|
|
1095
1110
|
aud: string | string[];
|
|
@@ -1099,7 +1114,7 @@ export declare type RequiredClaims = {
|
|
|
1099
1114
|
aal: AuthenticatorAssuranceLevels;
|
|
1100
1115
|
session_id: string;
|
|
1101
1116
|
};
|
|
1102
|
-
export
|
|
1117
|
+
export type JwtPayload = RequiredClaims & {
|
|
1103
1118
|
[key: string]: any;
|
|
1104
1119
|
};
|
|
1105
1120
|
export interface JWK {
|
|
@@ -1110,6 +1125,6 @@ export interface JWK {
|
|
|
1110
1125
|
[key: string]: any;
|
|
1111
1126
|
}
|
|
1112
1127
|
export declare const SIGN_OUT_SCOPES: readonly ["global", "local", "others"];
|
|
1113
|
-
export
|
|
1128
|
+
export type SignOutScope = (typeof SIGN_OUT_SCOPES)[number];
|
|
1114
1129
|
export {};
|
|
1115
1130
|
//# sourceMappingURL=types.d.ts.map
|