@supabase/auth-js 2.72.1-rc.1 → 2.73.0-rc.3

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.
@@ -56,86 +56,70 @@ export declare type GoTrueClientOptions = {
56
56
  */
57
57
  hasCustomAuthorizationHeader?: boolean;
58
58
  };
59
- export declare type WeakPasswordReasons = 'length' | 'characters' | 'pwned' | (string & {});
59
+ declare const WeakPasswordReasons: readonly ["length", "characters", "pwned"];
60
+ export declare type WeakPasswordReasons = typeof WeakPasswordReasons[number];
60
61
  export declare type WeakPassword = {
61
62
  reasons: WeakPasswordReasons[];
62
63
  message: string;
63
64
  };
64
- export declare type AuthResponse = {
65
- data: {
66
- user: User | null;
67
- session: Session | null;
68
- };
65
+ /**
66
+ * Resolve mapped types and show the derived keys and their types when hovering in
67
+ * VS Code, instead of just showing the names those mapped types are defined with.
68
+ */
69
+ export declare type Prettify<T> = T extends Function ? T : {
70
+ [K in keyof T]: T[K];
71
+ };
72
+ /**
73
+ * a shared result type that encapsulates errors instead of throwing them, allows you to optionally specify the ErrorType
74
+ */
75
+ export declare type RequestResult<T, ErrorType extends Error = AuthError> = {
76
+ data: T;
69
77
  error: null;
70
78
  } | {
71
- data: {
72
- user: null;
73
- session: null;
74
- };
75
- error: AuthError;
79
+ data: null;
80
+ error: Error extends AuthError ? AuthError : ErrorType;
76
81
  };
77
- export declare type AuthResponsePassword = {
78
- data: {
79
- user: User | null;
80
- session: Session | null;
81
- weak_password?: WeakPassword | null;
82
- };
82
+ /**
83
+ * similar to RequestResult except it allows you to destructure the possible shape of the success response
84
+ * {@see RequestResult}
85
+ */
86
+ export declare type RequestResultSafeDestructure<T> = {
87
+ data: T;
83
88
  error: null;
84
89
  } | {
85
- data: {
86
- user: null;
87
- session: null;
88
- };
90
+ data: T extends object ? {
91
+ [K in keyof T]: null;
92
+ } : null;
89
93
  error: AuthError;
90
94
  };
95
+ export declare type AuthResponse = RequestResultSafeDestructure<{
96
+ user: User | null;
97
+ session: Session | null;
98
+ }>;
99
+ export declare type AuthResponsePassword = RequestResultSafeDestructure<{
100
+ user: User | null;
101
+ session: Session | null;
102
+ weak_password?: WeakPassword | null;
103
+ }>;
91
104
  /**
92
105
  * AuthOtpResponse is returned when OTP is used.
93
106
  *
94
107
  * {@see AuthResponse}
95
108
  */
96
- export declare type AuthOtpResponse = {
97
- data: {
98
- user: null;
99
- session: null;
100
- messageId?: string | null;
101
- };
102
- error: null;
103
- } | {
104
- data: {
105
- user: null;
106
- session: null;
107
- messageId?: string | null;
108
- };
109
- error: AuthError;
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
- };
109
+ export declare type AuthOtpResponse = RequestResultSafeDestructure<{
110
+ user: null;
111
+ session: null;
112
+ messageId?: string | null;
113
+ }>;
114
+ export declare type AuthTokenResponse = RequestResultSafeDestructure<{
115
+ user: User;
116
+ session: Session;
117
+ }>;
118
+ export declare type AuthTokenResponsePassword = RequestResultSafeDestructure<{
119
+ user: User;
120
+ session: Session;
121
+ weakPassword?: WeakPassword;
122
+ }>;
139
123
  export declare type OAuthResponse = {
140
124
  data: {
141
125
  provider: Provider;
@@ -149,33 +133,19 @@ export declare type OAuthResponse = {
149
133
  };
150
134
  error: AuthError;
151
135
  };
152
- export declare type SSOResponse = {
153
- data: {
154
- /**
155
- * URL to open in a browser which will complete the sign-in flow by
156
- * taking the user to the identity provider's authentication flow.
157
- *
158
- * On browsers you can set the URL to `window.location.href` to take
159
- * the user to the authentication flow.
160
- */
161
- url: string;
162
- };
163
- error: null;
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
- };
136
+ export declare type SSOResponse = RequestResult<{
137
+ /**
138
+ * URL to open in a browser which will complete the sign-in flow by
139
+ * taking the user to the identity provider's authentication flow.
140
+ *
141
+ * On browsers you can set the URL to `window.location.href` to take
142
+ * the user to the authentication flow.
143
+ */
144
+ url: string;
145
+ }>;
146
+ export declare type UserResponse = RequestResultSafeDestructure<{
147
+ user: User;
148
+ }>;
179
149
  export interface Session {
180
150
  /**
181
151
  * The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.
@@ -202,12 +172,14 @@ export interface Session {
202
172
  * A timestamp of when the token will expire. Returned when a login is confirmed.
203
173
  */
204
174
  expires_at?: number;
205
- token_type: string;
175
+ token_type: 'bearer';
206
176
  /**
207
177
  * When using a separate user storage, accessing properties of this object will throw an error.
208
178
  */
209
179
  user: User;
210
180
  }
181
+ declare const AMRMethods: readonly ["password", "otp", "oauth", "totp", "mfa/totp", "mfa/phone", "anonymous", "sso/saml", "magiclink", "web3"];
182
+ export declare type AMRMethod = typeof AMRMethods[number] | (string & {});
211
183
  /**
212
184
  * An authentication methord reference (AMR) entry.
213
185
  *
@@ -218,7 +190,7 @@ export interface Session {
218
190
  */
219
191
  export interface AMREntry {
220
192
  /** Authentication method name. */
221
- method: 'password' | 'otp' | 'oauth' | 'mfa/totp' | (string & {});
193
+ method: AMRMethod;
222
194
  /**
223
195
  * Timestamp when the method was successfully used. Represents number of
224
196
  * seconds since 1st January 1970 (UNIX epoch) in UTC.
@@ -237,6 +209,16 @@ export interface UserIdentity {
237
209
  last_sign_in_at?: string;
238
210
  updated_at?: string;
239
211
  }
212
+ export declare const FactorTypes: readonly ["totp", "phone"];
213
+ /**
214
+ * Type of factor. `totp` and `phone` supported with this version
215
+ */
216
+ export declare type FactorType = typeof FactorTypes[number];
217
+ declare const FactorVerificationStatuses: readonly ["verified", "unverified"];
218
+ /**
219
+ * The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`
220
+ */
221
+ declare type FactorVerificationStatus = typeof FactorVerificationStatuses[number];
240
222
  /**
241
223
  * A MFA factor.
242
224
  *
@@ -244,7 +226,7 @@ export interface UserIdentity {
244
226
  * @see {@link GoTrueMFAApi#listFactors}
245
227
  * @see {@link GoTrueMFAAdminApi#listFactors}
246
228
  */
247
- export interface Factor {
229
+ export declare type Factor<Type extends FactorType = FactorType, Status extends FactorVerificationStatus = typeof FactorVerificationStatuses[number]> = {
248
230
  /** ID of the factor. */
249
231
  id: string;
250
232
  /** Friendly name of the factor, useful to disambiguate between multiple factors. */
@@ -252,12 +234,14 @@ export interface Factor {
252
234
  /**
253
235
  * Type of factor. `totp` and `phone` supported with this version
254
236
  */
255
- factor_type: 'totp' | 'phone' | (string & {});
256
- /** Factor's status. */
257
- status: 'verified' | 'unverified';
237
+ factor_type: Type;
238
+ /**
239
+ * The verification status of the factor, default is `unverified` after `.enroll()`, then `verified` after the user verifies it with `.verify()`
240
+ */
241
+ status: Status;
258
242
  created_at: string;
259
243
  updated_at: string;
260
- }
244
+ };
261
245
  export interface UserAppMetadata {
262
246
  provider?: string;
263
247
  [key: string]: any;
@@ -289,7 +273,7 @@ export interface User {
289
273
  identities?: UserIdentity[];
290
274
  is_anonymous?: boolean;
291
275
  is_sso_user?: boolean;
292
- factors?: Factor[];
276
+ factors?: Factor<FactorType>[];
293
277
  deleted_at?: string;
294
278
  }
295
279
  export interface UserAttributes {
@@ -412,57 +396,23 @@ export declare type SignInAnonymouslyCredentials = {
412
396
  captchaToken?: string;
413
397
  };
414
398
  };
415
- export declare type SignUpWithPasswordCredentials = {
416
- /** The user's email address. */
417
- email: string;
418
- /** The user's password. */
419
- password: string;
399
+ export declare type SignUpWithPasswordCredentials = Prettify<PasswordCredentialsBase & {
420
400
  options?: {
421
- /** The redirect url embedded in the email link */
422
401
  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
402
  data?: object;
444
- /** Verification token received when the user completes the captcha on the site. Requires a configured WhatsApp sender on Twilio */
445
403
  captchaToken?: string;
446
- /** Messaging channel to use (e.g. whatsapp or sms) */
447
404
  channel?: 'sms' | 'whatsapp';
448
405
  };
449
- };
450
- export declare type SignInWithPasswordCredentials = {
451
- /** The user's email address. */
406
+ }>;
407
+ declare type PasswordCredentialsBase = {
452
408
  email: string;
453
- /** The user's password. */
454
409
  password: string;
455
- options?: {
456
- /** Verification token received when the user completes the captcha on the site. */
457
- captchaToken?: string;
458
- };
459
410
  } | {
460
- /** The user's phone number. */
461
411
  phone: string;
462
- /** The user's password. */
463
412
  password: string;
413
+ };
414
+ export declare type SignInWithPasswordCredentials = PasswordCredentialsBase & {
464
415
  options?: {
465
- /** Verification token received when the user completes the captcha on the site. */
466
416
  captchaToken?: string;
467
417
  };
468
418
  };
@@ -708,19 +658,10 @@ export interface GenerateLinkOptions {
708
658
  redirectTo?: string;
709
659
  }
710
660
  export declare type GenerateLinkParams = GenerateSignupLinkParams | GenerateInviteOrMagiclinkParams | GenerateRecoveryLinkParams | GenerateEmailChangeLinkParams;
711
- export declare type GenerateLinkResponse = {
712
- data: {
713
- properties: GenerateLinkProperties;
714
- user: User;
715
- };
716
- error: null;
717
- } | {
718
- data: {
719
- properties: null;
720
- user: null;
721
- };
722
- error: AuthError;
723
- };
661
+ export declare type GenerateLinkResponse = RequestResultSafeDestructure<{
662
+ properties: GenerateLinkProperties;
663
+ user: User;
664
+ }>;
724
665
  /** The properties related to the email link generated */
725
666
  export declare type GenerateLinkProperties = {
726
667
  /**
@@ -748,107 +689,89 @@ export declare type MFAUnenrollParams = {
748
689
  /** ID of the factor being unenrolled. */
749
690
  factorId: string;
750
691
  };
751
- export declare type MFAVerifyParams = {
692
+ declare type MFAVerifyParamsBase = {
752
693
  /** ID of the factor being verified. Returned in enroll(). */
753
694
  factorId: string;
754
695
  /** ID of the challenge being verified. Returned in challenge(). */
755
696
  challengeId: string;
697
+ };
698
+ declare type MFAVerifyTOTPParamFields = {
756
699
  /** Verification code provided by the user. */
757
700
  code: string;
758
701
  };
759
- export declare type MFAChallengeParams = {
702
+ export declare type MFAVerifyTOTPParams = Prettify<MFAVerifyParamsBase & MFAVerifyTOTPParamFields>;
703
+ declare type MFAVerifyPhoneParamFields = MFAVerifyTOTPParamFields;
704
+ export declare type MFAVerifyPhoneParams = Prettify<MFAVerifyParamsBase & MFAVerifyPhoneParamFields>;
705
+ export declare type MFAVerifyParams = MFAVerifyTOTPParams | MFAVerifyPhoneParams;
706
+ declare type MFAChallengeParamsBase = {
760
707
  /** ID of the factor to be challenged. Returned in enroll(). */
761
708
  factorId: string;
762
- /** Messaging channel to use (e.g. whatsapp or sms). Only relevant for phone factors */
763
- channel?: 'sms' | 'whatsapp';
764
- };
765
- export declare type MFAChallengeAndVerifyParams = {
766
- /** ID of the factor being verified. Returned in enroll(). */
767
- factorId: string;
768
- /** Verification code provided by the user. */
769
- code: string;
770
- };
771
- export declare type AuthMFAVerifyResponse = {
772
- data: {
773
- /** New access token (JWT) after successful verification. */
774
- access_token: string;
775
- /** Type of token, typically `Bearer`. */
776
- token_type: string;
777
- /** Number of seconds in which the access token will expire. */
778
- expires_in: number;
779
- /** Refresh token you can use to obtain new access tokens when expired. */
780
- refresh_token: string;
781
- /** Updated user profile. */
782
- user: User;
783
- };
784
- error: null;
785
- } | {
786
- data: null;
787
- error: AuthError;
788
709
  };
710
+ declare const MFATOTPChannels: readonly ["sms", "whatsapp"];
711
+ export declare type MFATOTPChannel = typeof MFATOTPChannels[number];
712
+ export declare type MFAChallengeTOTPParams = Prettify<MFAChallengeParamsBase>;
713
+ declare type MFAChallengePhoneParamFields<Channel extends MFATOTPChannel = MFATOTPChannel> = {
714
+ /** Messaging channel to use (e.g. whatsapp or sms). Only relevant for phone factors */
715
+ channel: Channel;
716
+ };
717
+ export declare type MFAChallengePhoneParams = Prettify<MFAChallengeParamsBase & MFAChallengePhoneParamFields>;
718
+ export declare type MFAChallengeParams = MFAChallengeTOTPParams | MFAChallengePhoneParams;
719
+ declare type MFAChallengeAndVerifyParamsBase = Omit<MFAVerifyParamsBase, 'challengeId'>;
720
+ declare type MFAChallengeAndVerifyTOTPParamFields = MFAVerifyTOTPParamFields;
721
+ declare type MFAChallengeAndVerifyTOTPParams = Prettify<MFAChallengeAndVerifyParamsBase & MFAChallengeAndVerifyTOTPParamFields>;
722
+ declare type MFAChallengeAndVerifyPhoneParamFields = MFAVerifyPhoneParamFields;
723
+ declare type MFAChallengeAndVerifyPhoneParams = Prettify<MFAChallengeAndVerifyParamsBase & MFAChallengeAndVerifyPhoneParamFields>;
724
+ export declare type MFAChallengeAndVerifyParams = MFAChallengeAndVerifyTOTPParams | MFAChallengeAndVerifyPhoneParams;
725
+ export declare type AuthMFAVerifyResponse = RequestResult<{
726
+ /** New access token (JWT) after successful verification. */
727
+ access_token: string;
728
+ /** Type of token, always `bearer`. */
729
+ token_type: 'bearer';
730
+ /** Number of seconds in which the access token will expire. */
731
+ expires_in: number;
732
+ /** Refresh token you can use to obtain new access tokens when expired. */
733
+ refresh_token: string;
734
+ /** Updated user profile. */
735
+ user: User;
736
+ }>;
789
737
  export declare type AuthMFAEnrollResponse = AuthMFAEnrollTOTPResponse | AuthMFAEnrollPhoneResponse;
790
- export declare type AuthMFAUnenrollResponse = {
791
- data: {
792
- /** ID of the factor that was successfully unenrolled. */
793
- id: string;
794
- };
795
- error: null;
796
- } | {
797
- data: null;
798
- error: AuthError;
799
- };
800
- export declare type AuthMFAChallengeResponse = {
801
- data: {
802
- /** ID of the newly created challenge. */
803
- id: string;
804
- /** Factor Type which generated the challenge */
805
- type: 'totp' | 'phone';
806
- /** Timestamp in UNIX seconds when this challenge will no longer be usable. */
807
- expires_at: number;
808
- };
809
- error: null;
810
- } | {
811
- data: null;
812
- error: AuthError;
813
- };
814
- export declare type AuthMFAListFactorsResponse = {
815
- data: {
816
- /** All available factors (verified and unverified). */
817
- all: Factor[];
818
- /** Only verified TOTP factors. (A subset of `all`.) */
819
- totp: Factor[];
820
- /** Only verified Phone factors. (A subset of `all`.) */
821
- phone: Factor[];
822
- };
823
- error: null;
824
- } | {
825
- data: null;
826
- error: AuthError;
827
- };
738
+ export declare type AuthMFAUnenrollResponse = RequestResult<{
739
+ /** ID of the factor that was successfully unenrolled. */
740
+ id: string;
741
+ }>;
742
+ export declare type AuthMFAChallengeResponse<T extends FactorType> = RequestResult<{
743
+ /** ID of the newly created challenge. */
744
+ id: string;
745
+ /** Factor Type which generated the challenge */
746
+ type: T;
747
+ /** Timestamp in UNIX seconds when this challenge will no longer be usable. */
748
+ expires_at: number;
749
+ }>;
750
+ /** response of ListFactors, which should contain all the types of factors that are available, this ensures we always include all */
751
+ export declare type AuthMFAListFactorsResponse<T extends typeof FactorTypes = typeof FactorTypes> = RequestResult<{
752
+ /** All available factors (verified and unverified). */
753
+ all: Prettify<Factor>[];
754
+ } & {
755
+ [K in T[number]]: Prettify<Factor<K, 'verified'>>[];
756
+ }>;
828
757
  export declare type AuthenticatorAssuranceLevels = 'aal1' | 'aal2';
829
- export declare type AuthMFAGetAuthenticatorAssuranceLevelResponse = {
830
- data: {
831
- /** Current AAL level of the session. */
832
- currentLevel: AuthenticatorAssuranceLevels | null;
833
- /**
834
- * Next possible AAL level for the session. If the next level is higher
835
- * than the current one, the user should go through MFA.
836
- *
837
- * @see {@link GoTrueMFAApi#challenge}
838
- */
839
- nextLevel: AuthenticatorAssuranceLevels | null;
840
- /**
841
- * A list of all authentication methods attached to this session. Use
842
- * the information here to detect the last time a user verified a
843
- * factor, for example if implementing a step-up scenario.
844
- */
845
- currentAuthenticationMethods: AMREntry[];
846
- };
847
- error: null;
848
- } | {
849
- data: null;
850
- error: AuthError;
851
- };
758
+ export declare type AuthMFAGetAuthenticatorAssuranceLevelResponse = RequestResult<{
759
+ /** Current AAL level of the session. */
760
+ currentLevel: AuthenticatorAssuranceLevels | null;
761
+ /**
762
+ * Next possible AAL level for the session. If the next level is higher
763
+ * than the current one, the user should go through MFA.
764
+ *
765
+ * @see {@link GoTrueMFAApi#challenge}
766
+ */
767
+ nextLevel: AuthenticatorAssuranceLevels | null;
768
+ /**
769
+ * A list of all authentication methods attached to this session. Use
770
+ * the information here to detect the last time a user verified a
771
+ * factor, for example if implementing a step-up scenario.
772
+ */
773
+ currentAuthenticationMethods: AMREntry[];
774
+ }>;
852
775
  /**
853
776
  * Contains the full multi-factor authentication API.
854
777
  *
@@ -862,7 +785,6 @@ export interface GoTrueMFAApi {
862
785
  * The user has to enter the code from their authenticator app to verify it.
863
786
  *
864
787
  * Upon verifying a factor, all other sessions are logged out and the current session's authenticator level is promoted to `aal2`.
865
- *
866
788
  */
867
789
  enroll(params: MFAEnrollTOTPParams): Promise<AuthMFAEnrollTOTPResponse>;
868
790
  enroll(params: MFAEnrollPhoneParams): Promise<AuthMFAEnrollPhoneResponse>;
@@ -871,11 +793,15 @@ export interface GoTrueMFAApi {
871
793
  * Prepares a challenge used to verify that a user has access to a MFA
872
794
  * factor.
873
795
  */
874
- challenge(params: MFAChallengeParams): Promise<AuthMFAChallengeResponse>;
796
+ challenge(params: MFAChallengeTOTPParams): Promise<Prettify<AuthMFAChallengeResponse<'totp'>>>;
797
+ challenge(params: MFAChallengePhoneParams): Promise<Prettify<AuthMFAChallengeResponse<'phone'>>>;
798
+ challenge(params: MFAChallengeParams): Promise<Prettify<AuthMFAChallengeResponse<'totp' | 'phone'>>>;
875
799
  /**
876
800
  * Verifies a code against a challenge. The verification code is
877
801
  * provided by the user by entering a code seen in their authenticator app.
878
802
  */
803
+ verify(params: MFAVerifyTOTPParams): Promise<AuthMFAVerifyResponse>;
804
+ verify(params: MFAVerifyPhoneParams): Promise<AuthMFAVerifyResponse>;
879
805
  verify(params: MFAVerifyParams): Promise<AuthMFAVerifyResponse>;
880
806
  /**
881
807
  * Unenroll removes a MFA factor.
@@ -914,16 +840,10 @@ export interface GoTrueMFAApi {
914
840
  /**
915
841
  * @expermental
916
842
  */
917
- export declare type AuthMFAAdminDeleteFactorResponse = {
918
- data: {
919
- /** ID of the factor that was successfully deleted. */
920
- id: string;
921
- };
922
- error: null;
923
- } | {
924
- data: null;
925
- error: AuthError;
926
- };
843
+ export declare type AuthMFAAdminDeleteFactorResponse = RequestResult<{
844
+ /** ID of the factor that was successfully deleted. */
845
+ id: string;
846
+ }>;
927
847
  /**
928
848
  * @expermental
929
849
  */
@@ -936,16 +856,10 @@ export declare type AuthMFAAdminDeleteFactorParams = {
936
856
  /**
937
857
  * @expermental
938
858
  */
939
- export declare type AuthMFAAdminListFactorsResponse = {
940
- data: {
941
- /** All factors attached to the user. */
942
- factors: Factor[];
943
- };
944
- error: null;
945
- } | {
946
- data: null;
947
- error: AuthError;
948
- };
859
+ export declare type AuthMFAAdminListFactorsResponse = RequestResult<{
860
+ /** All factors attached to the user. */
861
+ factors: Factor[];
862
+ }>;
949
863
  /**
950
864
  * @expermental
951
865
  */
@@ -992,13 +906,7 @@ export declare type SupportedStorage = PromisifyMethods<Pick<Storage, 'getItem'
992
906
  export declare type InitializeResult = {
993
907
  error: AuthError | null;
994
908
  };
995
- export declare type CallRefreshTokenResult = {
996
- session: Session;
997
- error: null;
998
- } | {
999
- session: null;
1000
- error: AuthError;
1001
- };
909
+ export declare type CallRefreshTokenResult = RequestResult<Session>;
1002
910
  export declare type Pagination = {
1003
911
  [key: string]: any;
1004
912
  nextPage: number | null;
@@ -1024,66 +932,52 @@ export declare type SignOut = {
1024
932
  */
1025
933
  scope?: 'global' | 'local' | 'others';
1026
934
  };
1027
- export declare type MFAEnrollTOTPParams = {
935
+ declare type MFAEnrollParamsBase<T extends FactorType> = {
1028
936
  /** The type of factor being enrolled. */
1029
- factorType: 'totp';
1030
- /** Domain which the user is enrolled with. */
1031
- issuer?: string;
937
+ factorType: T;
1032
938
  /** Human readable name assigned to the factor. */
1033
939
  friendlyName?: string;
1034
940
  };
1035
- export declare type MFAEnrollPhoneParams = {
1036
- /** The type of factor being enrolled. */
1037
- factorType: 'phone';
1038
- /** Human readable name assigned to the factor. */
1039
- friendlyName?: string;
941
+ declare type MFAEnrollTOTPParamFields = {
942
+ /** Domain which the user is enrolled with. */
943
+ issuer?: string;
944
+ };
945
+ export declare type MFAEnrollTOTPParams = Prettify<MFAEnrollParamsBase<'totp'> & MFAEnrollTOTPParamFields>;
946
+ declare type MFAEnrollPhoneParamFields = {
1040
947
  /** Phone number associated with a factor. Number should conform to E.164 format */
1041
948
  phone: string;
1042
949
  };
1043
- export declare type AuthMFAEnrollTOTPResponse = {
1044
- data: {
1045
- /** ID of the factor that was just enrolled (in an unverified state). */
1046
- id: string;
1047
- /** Type of MFA factor.*/
1048
- type: 'totp';
1049
- /** TOTP enrollment information. */
1050
- totp: {
1051
- /** Contains a QR code encoding the authenticator URI. You can
1052
- * convert it to a URL by prepending `data:image/svg+xml;utf-8,` to
1053
- * the value. Avoid logging this value to the console. */
1054
- qr_code: string;
1055
- /** The TOTP secret (also encoded in the QR code). Show this secret
1056
- * in a password-style field to the user, in case they are unable to
1057
- * scan the QR code. Avoid logging this value to the console. */
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;
950
+ export declare type MFAEnrollPhoneParams = Prettify<MFAEnrollParamsBase<'phone'> & MFAEnrollPhoneParamFields>;
951
+ declare type AuthMFAEnrollResponseBase<T extends FactorType> = {
952
+ /** ID of the factor that was just enrolled (in an unverified state). */
953
+ id: string;
954
+ /** Type of MFA factor.*/
955
+ type: T;
956
+ /** Friendly name of the factor, useful for distinguishing between factors **/
957
+ friendly_name?: string;
1070
958
  };
1071
- export declare type AuthMFAEnrollPhoneResponse = {
1072
- data: {
1073
- /** ID of the factor that was just enrolled (in an unverified state). */
1074
- id: string;
1075
- /** Type of MFA factor. */
1076
- type: 'phone';
1077
- /** Friendly name of the factor, useful for distinguishing between factors **/
1078
- friendly_name?: string;
1079
- /** Phone number of the MFA factor in E.164 format. Used to send messages */
1080
- phone: string;
1081
- };
1082
- error: null;
1083
- } | {
1084
- data: null;
1085
- error: AuthError;
959
+ declare type AuthMFAEnrollTOTPResponseFields = {
960
+ /** TOTP enrollment information. */
961
+ totp: {
962
+ /** Contains a QR code encoding the authenticator URI. You can
963
+ * convert it to a URL by prepending `data:image/svg+xml;utf-8,` to
964
+ * the value. Avoid logging this value to the console. */
965
+ qr_code: string;
966
+ /** The TOTP secret (also encoded in the QR code). Show this secret
967
+ * in a password-style field to the user, in case they are unable to
968
+ * scan the QR code. Avoid logging this value to the console. */
969
+ secret: string;
970
+ /** The authenticator URI encoded within the QR code, should you need
971
+ * to use it. Avoid loggin this value to the console. */
972
+ uri: string;
973
+ };
974
+ };
975
+ export declare type AuthMFAEnrollTOTPResponse = RequestResult<Prettify<AuthMFAEnrollResponseBase<'totp'> & AuthMFAEnrollTOTPResponseFields>>;
976
+ declare type AuthMFAEnrollPhoneResponseFields = {
977
+ /** Phone number of the MFA factor in E.164 format. Used to send messages */
978
+ phone: string;
1086
979
  };
980
+ export declare type AuthMFAEnrollPhoneResponse = RequestResult<Prettify<AuthMFAEnrollResponseBase<'phone'> & AuthMFAEnrollPhoneResponseFields>>;
1087
981
  export declare type JwtHeader = {
1088
982
  alg: 'RS256' | 'ES256' | 'HS256';
1089
983
  kid: string;