@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.
Files changed (72) hide show
  1. package/dist/main/GoTrueClient.d.ts +7 -1
  2. package/dist/main/GoTrueClient.d.ts.map +1 -1
  3. package/dist/main/GoTrueClient.js +114 -33
  4. package/dist/main/GoTrueClient.js.map +1 -1
  5. package/dist/main/lib/base64url.d.ts +3 -2
  6. package/dist/main/lib/base64url.d.ts.map +1 -1
  7. package/dist/main/lib/base64url.js.map +1 -1
  8. package/dist/main/lib/errors.d.ts +1 -1
  9. package/dist/main/lib/errors.d.ts.map +1 -1
  10. package/dist/main/lib/errors.js.map +1 -1
  11. package/dist/main/lib/helpers.d.ts +2 -1
  12. package/dist/main/lib/helpers.d.ts.map +1 -1
  13. package/dist/main/lib/helpers.js.map +1 -1
  14. package/dist/main/lib/types.d.ts +329 -314
  15. package/dist/main/lib/types.d.ts.map +1 -1
  16. package/dist/main/lib/types.js +17 -0
  17. package/dist/main/lib/types.js.map +1 -1
  18. package/dist/main/lib/version.d.ts +1 -1
  19. package/dist/main/lib/version.js +1 -1
  20. package/dist/main/lib/webauthn.d.ts +274 -0
  21. package/dist/main/lib/webauthn.d.ts.map +1 -0
  22. package/dist/main/lib/webauthn.dom.d.ts +583 -0
  23. package/dist/main/lib/webauthn.dom.d.ts.map +1 -0
  24. package/dist/main/lib/webauthn.dom.js +4 -0
  25. package/dist/main/lib/webauthn.dom.js.map +1 -0
  26. package/dist/main/lib/webauthn.errors.d.ts +80 -0
  27. package/dist/main/lib/webauthn.errors.d.ts.map +1 -0
  28. package/dist/main/lib/webauthn.errors.js +265 -0
  29. package/dist/main/lib/webauthn.errors.js.map +1 -0
  30. package/dist/main/lib/webauthn.js +702 -0
  31. package/dist/main/lib/webauthn.js.map +1 -0
  32. package/dist/module/GoTrueClient.d.ts +7 -1
  33. package/dist/module/GoTrueClient.d.ts.map +1 -1
  34. package/dist/module/GoTrueClient.js +120 -39
  35. package/dist/module/GoTrueClient.js.map +1 -1
  36. package/dist/module/lib/base64url.d.ts +3 -2
  37. package/dist/module/lib/base64url.d.ts.map +1 -1
  38. package/dist/module/lib/base64url.js.map +1 -1
  39. package/dist/module/lib/errors.d.ts +1 -1
  40. package/dist/module/lib/errors.d.ts.map +1 -1
  41. package/dist/module/lib/errors.js.map +1 -1
  42. package/dist/module/lib/helpers.d.ts +2 -1
  43. package/dist/module/lib/helpers.d.ts.map +1 -1
  44. package/dist/module/lib/helpers.js.map +1 -1
  45. package/dist/module/lib/types.d.ts +329 -314
  46. package/dist/module/lib/types.d.ts.map +1 -1
  47. package/dist/module/lib/types.js +17 -0
  48. package/dist/module/lib/types.js.map +1 -1
  49. package/dist/module/lib/version.d.ts +1 -1
  50. package/dist/module/lib/version.js +1 -1
  51. package/dist/module/lib/webauthn.d.ts +274 -0
  52. package/dist/module/lib/webauthn.d.ts.map +1 -0
  53. package/dist/module/lib/webauthn.dom.d.ts +583 -0
  54. package/dist/module/lib/webauthn.dom.d.ts.map +1 -0
  55. package/dist/module/lib/webauthn.dom.js +3 -0
  56. package/dist/module/lib/webauthn.dom.js.map +1 -0
  57. package/dist/module/lib/webauthn.errors.d.ts +80 -0
  58. package/dist/module/lib/webauthn.errors.d.ts.map +1 -0
  59. package/dist/module/lib/webauthn.errors.js +257 -0
  60. package/dist/module/lib/webauthn.errors.js.map +1 -0
  61. package/dist/module/lib/webauthn.js +685 -0
  62. package/dist/module/lib/webauthn.js.map +1 -0
  63. package/package.json +1 -1
  64. package/src/GoTrueClient.ts +282 -81
  65. package/src/lib/base64url.ts +4 -2
  66. package/src/lib/errors.ts +1 -1
  67. package/src/lib/helpers.ts +2 -1
  68. package/src/lib/types.ts +465 -353
  69. package/src/lib/version.ts +1 -1
  70. package/src/lib/webauthn.dom.ts +636 -0
  71. package/src/lib/webauthn.errors.ts +317 -0
  72. package/src/lib/webauthn.ts +929 -0
@@ -0,0 +1 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AAC,KAAK,CAAC,EAAE;gBACtB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;aAC7B;YACD,OAAO;gBACL,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,IAAI,gBAAgB,CAAC,8BAA8B,EAAE,KAAK,CAAC;aACnE,CAAA;SACF;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/gotrue-js",
3
- "version": "2.72.1-rc.1",
3
+ "version": "2.73.0-rc.5",
4
4
  "private": false,
5
5
  "description": "Official client library for Supabase Auth",
6
6
  "keywords": [
@@ -1,128 +1,155 @@
1
1
  import GoTrueAdminApi from './GoTrueAdminApi'
2
2
  import {
3
- DEFAULT_HEADERS,
4
- EXPIRY_MARGIN_MS,
5
3
  AUTO_REFRESH_TICK_DURATION_MS,
6
4
  AUTO_REFRESH_TICK_THRESHOLD,
5
+ DEFAULT_HEADERS,
6
+ EXPIRY_MARGIN_MS,
7
7
  GOTRUE_URL,
8
- STORAGE_KEY,
9
8
  JWKS_TTL,
9
+ STORAGE_KEY,
10
10
  } from './lib/constants'
11
11
  import {
12
12
  AuthError,
13
13
  AuthImplicitGrantRedirectError,
14
- AuthPKCEGrantCodeExchangeError,
15
14
  AuthInvalidCredentialsError,
16
- AuthSessionMissingError,
15
+ AuthInvalidJwtError,
17
16
  AuthInvalidTokenResponseError,
17
+ AuthPKCEGrantCodeExchangeError,
18
+ AuthSessionMissingError,
18
19
  AuthUnknownError,
19
20
  isAuthApiError,
20
21
  isAuthError,
22
+ isAuthImplicitGrantRedirectError,
21
23
  isAuthRetryableFetchError,
22
24
  isAuthSessionMissingError,
23
- isAuthImplicitGrantRedirectError,
24
- AuthInvalidJwtError,
25
25
  } from './lib/errors'
26
26
  import {
27
27
  Fetch,
28
28
  _request,
29
29
  _sessionResponse,
30
30
  _sessionResponsePassword,
31
- _userResponse,
32
31
  _ssoResponse,
32
+ _userResponse,
33
33
  } from './lib/fetch'
34
34
  import {
35
+ decodeJWT,
35
36
  deepClone,
36
37
  Deferred,
38
+ getAlgorithm,
39
+ getCodeChallengeAndMethod,
37
40
  getItemAsync,
38
41
  isBrowser,
42
+ parseParametersFromURL,
39
43
  removeItemAsync,
40
44
  resolveFetch,
41
- setItemAsync,
42
- uuid,
43
45
  retryable,
46
+ setItemAsync,
44
47
  sleep,
45
- parseParametersFromURL,
46
- getCodeChallengeAndMethod,
47
- getAlgorithm,
48
- validateExp,
49
- decodeJWT,
50
- userNotAvailableProxy,
51
48
  supportsLocalStorage,
49
+ userNotAvailableProxy,
50
+ uuid,
51
+ validateExp,
52
52
  } from './lib/helpers'
53
53
  import { memoryLocalStorageAdapter } from './lib/local-storage'
54
+ import { LockAcquireTimeoutError, navigatorLock } from './lib/locks'
54
55
  import { polyfillGlobalThis } from './lib/polyfills'
55
56
  import { version } from './lib/version'
56
- import { LockAcquireTimeoutError, navigatorLock } from './lib/locks'
57
57
 
58
+ import { bytesToBase64URL, stringToUint8Array } from './lib/base64url'
58
59
  import type {
59
60
  AuthChangeEvent,
61
+ AuthenticatorAssuranceLevels,
62
+ AuthFlowType,
63
+ AuthMFAChallengePhoneResponse,
64
+ AuthMFAChallengeResponse,
65
+ AuthMFAChallengeTOTPResponse,
66
+ AuthMFAChallengeWebauthnResponse,
67
+ AuthMFAChallengeWebauthnServerResponse,
68
+ AuthMFAEnrollPhoneResponse,
69
+ AuthMFAEnrollResponse,
70
+ AuthMFAEnrollTOTPResponse,
71
+ AuthMFAEnrollWebauthnResponse,
72
+ AuthMFAGetAuthenticatorAssuranceLevelResponse,
73
+ AuthMFAListFactorsResponse,
74
+ AuthMFAUnenrollResponse,
75
+ AuthMFAVerifyResponse,
76
+ AuthOtpResponse,
60
77
  AuthResponse,
61
78
  AuthResponsePassword,
62
79
  AuthTokenResponse,
63
80
  AuthTokenResponsePassword,
64
- AuthOtpResponse,
65
81
  CallRefreshTokenResult,
82
+ EthereumWallet,
83
+ EthereumWeb3Credentials,
84
+ Factor,
66
85
  GoTrueClientOptions,
86
+ GoTrueMFAApi,
67
87
  InitializeResult,
88
+ JWK,
89
+ JwtHeader,
90
+ JwtPayload,
91
+ LockFunc,
92
+ MFAChallengeAndVerifyParams,
93
+ MFAChallengeParams,
94
+ MFAChallengePhoneParams,
95
+ MFAChallengeTOTPParams,
96
+ MFAChallengeWebauthnParams,
97
+ MFAEnrollParams,
98
+ MFAEnrollPhoneParams,
99
+ MFAEnrollTOTPParams,
100
+ MFAEnrollWebauthnParams,
101
+ MFAUnenrollParams,
102
+ MFAVerifyParams,
103
+ MFAVerifyPhoneParams,
104
+ MFAVerifyTOTPParams,
105
+ MFAVerifyWebauthnParamFields,
106
+ MFAVerifyWebauthnParams,
68
107
  OAuthResponse,
69
- SSOResponse,
108
+ Prettify,
70
109
  Provider,
110
+ ResendParams,
71
111
  Session,
112
+ SignInAnonymouslyCredentials,
72
113
  SignInWithIdTokenCredentials,
73
114
  SignInWithOAuthCredentials,
74
115
  SignInWithPasswordCredentials,
75
116
  SignInWithPasswordlessCredentials,
76
- SignUpWithPasswordCredentials,
77
117
  SignInWithSSO,
78
118
  SignOut,
119
+ SignUpWithPasswordCredentials,
120
+ SolanaWallet,
121
+ SolanaWeb3Credentials,
122
+ SSOResponse,
123
+ StrictOmit,
79
124
  Subscription,
80
125
  SupportedStorage,
81
126
  User,
82
127
  UserAttributes,
128
+ UserIdentity,
83
129
  UserResponse,
84
130
  VerifyOtpParams,
85
- GoTrueMFAApi,
86
- MFAEnrollParams,
87
- AuthMFAEnrollResponse,
88
- MFAChallengeParams,
89
- AuthMFAChallengeResponse,
90
- MFAUnenrollParams,
91
- AuthMFAUnenrollResponse,
92
- MFAVerifyParams,
93
- AuthMFAVerifyResponse,
94
- AuthMFAListFactorsResponse,
95
- AuthMFAGetAuthenticatorAssuranceLevelResponse,
96
- AuthenticatorAssuranceLevels,
97
- Factor,
98
- MFAChallengeAndVerifyParams,
99
- ResendParams,
100
- AuthFlowType,
101
- LockFunc,
102
- UserIdentity,
103
- SignInAnonymouslyCredentials,
104
- MFAEnrollTOTPParams,
105
- MFAEnrollPhoneParams,
106
- AuthMFAEnrollTOTPResponse,
107
- AuthMFAEnrollPhoneResponse,
108
- JWK,
109
- JwtPayload,
110
- JwtHeader,
111
- SolanaWeb3Credentials,
112
- SolanaWallet,
113
131
  Web3Credentials,
114
- EthereumWeb3Credentials,
115
- EthereumWallet,
116
132
  } from './lib/types'
117
- import { stringToUint8Array, bytesToBase64URL } from './lib/base64url'
118
133
  import {
134
+ createSiweMessage,
119
135
  fromHex,
120
136
  getAddress,
121
137
  Hex,
122
- toHex,
123
- createSiweMessage,
124
138
  SiweMessage,
139
+ toHex,
125
140
  } from './lib/web3/ethereum'
141
+ import {
142
+ deserializeCredentialCreationOptions,
143
+ deserializeCredentialRequestOptions,
144
+ serializeCredentialCreationResponse,
145
+ serializeCredentialRequestResponse,
146
+ WebAuthnApi,
147
+ } from './lib/webauthn'
148
+ import {
149
+ AuthenticationCredential,
150
+ PublicKeyCredentialJSON,
151
+ RegistrationCredential,
152
+ } from './lib/webauthn.dom'
126
153
 
127
154
  polyfillGlobalThis() // Make "globalThis" available
128
155
 
@@ -292,6 +319,7 @@ export default class GoTrueClient {
292
319
  listFactors: this._listFactors.bind(this),
293
320
  challengeAndVerify: this._challengeAndVerify.bind(this),
294
321
  getAuthenticatorAssuranceLevel: this._getAuthenticatorAssuranceLevel.bind(this),
322
+ webauthn: new WebAuthnApi(this),
295
323
  }
296
324
 
297
325
  if (this.persistSession) {
@@ -1578,7 +1606,7 @@ export default class GoTrueClient {
1578
1606
  return { data: { session: currentSession }, error: null }
1579
1607
  }
1580
1608
 
1581
- const { session, error } = await this._callRefreshToken(currentSession.refresh_token)
1609
+ const { data: session, error } = await this._callRefreshToken(currentSession.refresh_token)
1582
1610
  if (error) {
1583
1611
  return { data: { session: null }, error }
1584
1612
  }
@@ -1757,7 +1785,7 @@ export default class GoTrueClient {
1757
1785
  }
1758
1786
 
1759
1787
  if (hasExpired) {
1760
- const { session: refreshedSession, error } = await this._callRefreshToken(
1788
+ const { data: refreshedSession, error } = await this._callRefreshToken(
1761
1789
  currentSession.refresh_token
1762
1790
  )
1763
1791
  if (error) {
@@ -1827,7 +1855,7 @@ export default class GoTrueClient {
1827
1855
  throw new AuthSessionMissingError()
1828
1856
  }
1829
1857
 
1830
- const { session, error } = await this._callRefreshToken(currentSession.refresh_token)
1858
+ const { data: session, error } = await this._callRefreshToken(currentSession.refresh_token)
1831
1859
  if (error) {
1832
1860
  return { data: { user: null, session: null }, error: error }
1833
1861
  }
@@ -1963,7 +1991,7 @@ export default class GoTrueClient {
1963
1991
  expires_in: expiresIn,
1964
1992
  expires_at: expiresAt,
1965
1993
  refresh_token,
1966
- token_type,
1994
+ token_type: token_type as 'bearer',
1967
1995
  user: data.user,
1968
1996
  }
1969
1997
 
@@ -2174,11 +2202,27 @@ export default class GoTrueClient {
2174
2202
  throw error
2175
2203
  }
2176
2204
  }
2205
+
2177
2206
  /**
2178
2207
  * Links an oauth identity to an existing user.
2179
2208
  * This method supports the PKCE flow.
2180
2209
  */
2181
- async linkIdentity(credentials: SignInWithOAuthCredentials): Promise<OAuthResponse> {
2210
+ async linkIdentity(credentials: SignInWithOAuthCredentials): Promise<OAuthResponse>
2211
+
2212
+ /**
2213
+ * Links an OIDC identity to an existing user.
2214
+ */
2215
+ async linkIdentity(credentials: SignInWithIdTokenCredentials): Promise<AuthTokenResponse>
2216
+
2217
+ async linkIdentity(credentials: any): Promise<any> {
2218
+ if ('token' in credentials) {
2219
+ return this.linkIdentityIdToken(credentials)
2220
+ }
2221
+
2222
+ return this.linkIdentityOAuth(credentials)
2223
+ }
2224
+
2225
+ private async linkIdentityOAuth(credentials: SignInWithOAuthCredentials): Promise<OAuthResponse> {
2182
2226
  try {
2183
2227
  const { data, error } = await this._useSession(async (result) => {
2184
2228
  const { data, error } = result
@@ -2211,6 +2255,56 @@ export default class GoTrueClient {
2211
2255
  }
2212
2256
  }
2213
2257
 
2258
+ private async linkIdentityIdToken(
2259
+ credentials: SignInWithIdTokenCredentials
2260
+ ): Promise<AuthTokenResponse> {
2261
+ return await this._useSession(async (result) => {
2262
+ try {
2263
+ const {
2264
+ error: sessionError,
2265
+ data: { session },
2266
+ } = result
2267
+ if (sessionError) throw sessionError
2268
+
2269
+ const { options, provider, token, access_token, nonce } = credentials
2270
+
2271
+ const res = await _request(this.fetch, 'POST', `${this.url}/token?grant_type=id_token`, {
2272
+ headers: this.headers,
2273
+ jwt: session?.access_token ?? undefined,
2274
+ body: {
2275
+ provider,
2276
+ id_token: token,
2277
+ access_token,
2278
+ nonce,
2279
+ link_identity: true,
2280
+ gotrue_meta_security: { captcha_token: options?.captchaToken },
2281
+ },
2282
+ xform: _sessionResponse,
2283
+ })
2284
+
2285
+ const { data, error } = res
2286
+ if (error) {
2287
+ return { data: { user: null, session: null }, error }
2288
+ } else if (!data || !data.session || !data.user) {
2289
+ return {
2290
+ data: { user: null, session: null },
2291
+ error: new AuthInvalidTokenResponseError(),
2292
+ }
2293
+ }
2294
+ if (data.session) {
2295
+ await this._saveSession(data.session)
2296
+ await this._notifyAllSubscribers('USER_UPDATED', data.session)
2297
+ }
2298
+ return { data, error }
2299
+ } catch (error) {
2300
+ if (isAuthError(error)) {
2301
+ return { data: { user: null, session: null }, error }
2302
+ }
2303
+ throw error
2304
+ }
2305
+ })
2306
+ }
2307
+
2214
2308
  /**
2215
2309
  * Unlinks an identity from a user by deleting it. The user will no longer be able to sign in with that identity once it's unlinked.
2216
2310
  */
@@ -2478,7 +2572,7 @@ export default class GoTrueClient {
2478
2572
  await this._saveSession(data.session)
2479
2573
  await this._notifyAllSubscribers('TOKEN_REFRESHED', data.session)
2480
2574
 
2481
- const result = { session: data.session, error: null }
2575
+ const result = { data: data.session, error: null }
2482
2576
 
2483
2577
  this.refreshingDeferred.resolve(result)
2484
2578
 
@@ -2487,7 +2581,7 @@ export default class GoTrueClient {
2487
2581
  this._debug(debugName, 'error', error)
2488
2582
 
2489
2583
  if (isAuthError(error)) {
2490
- const result = { session: null, error }
2584
+ const result = { data: null, error }
2491
2585
 
2492
2586
  if (!isAuthRetryableFetchError(error)) {
2493
2587
  await this._removeSession()
@@ -2913,6 +3007,7 @@ export default class GoTrueClient {
2913
3007
  */
2914
3008
  private async _enroll(params: MFAEnrollTOTPParams): Promise<AuthMFAEnrollTOTPResponse>
2915
3009
  private async _enroll(params: MFAEnrollPhoneParams): Promise<AuthMFAEnrollPhoneResponse>
3010
+ private async _enroll(params: MFAEnrollWebauthnParams): Promise<AuthMFAEnrollWebauthnResponse>
2916
3011
  private async _enroll(params: MFAEnrollParams): Promise<AuthMFAEnrollResponse> {
2917
3012
  try {
2918
3013
  return await this._useSession(async (result) => {
@@ -2924,20 +3019,23 @@ export default class GoTrueClient {
2924
3019
  const body = {
2925
3020
  friendly_name: params.friendlyName,
2926
3021
  factor_type: params.factorType,
2927
- ...(params.factorType === 'phone' ? { phone: params.phone } : { issuer: params.issuer }),
3022
+ ...(params.factorType === 'phone'
3023
+ ? { phone: params.phone }
3024
+ : params.factorType === 'totp'
3025
+ ? { issuer: params.issuer }
3026
+ : {}),
2928
3027
  }
2929
3028
 
2930
- const { data, error } = await _request(this.fetch, 'POST', `${this.url}/factors`, {
3029
+ const { data, error } = (await _request(this.fetch, 'POST', `${this.url}/factors`, {
2931
3030
  body,
2932
3031
  headers: this.headers,
2933
3032
  jwt: sessionData?.session?.access_token,
2934
- })
2935
-
3033
+ })) as AuthMFAEnrollResponse
2936
3034
  if (error) {
2937
3035
  return { data: null, error }
2938
3036
  }
2939
3037
 
2940
- if (params.factorType === 'totp' && data?.totp?.qr_code) {
3038
+ if (params.factorType === 'totp' && data.type === 'totp' && data?.totp?.qr_code) {
2941
3039
  data.totp.qr_code = `data:image/svg+xml;utf-8,${data.totp.qr_code}`
2942
3040
  }
2943
3041
 
@@ -2954,6 +3052,11 @@ export default class GoTrueClient {
2954
3052
  /**
2955
3053
  * {@see GoTrueMFAApi#verify}
2956
3054
  */
3055
+ private async _verify(params: MFAVerifyTOTPParams): Promise<AuthMFAVerifyResponse>
3056
+ private async _verify(params: MFAVerifyPhoneParams): Promise<AuthMFAVerifyResponse>
3057
+ private async _verify<T extends 'create' | 'request'>(
3058
+ params: MFAVerifyWebauthnParams<T>
3059
+ ): Promise<AuthMFAVerifyResponse>
2957
3060
  private async _verify(params: MFAVerifyParams): Promise<AuthMFAVerifyResponse> {
2958
3061
  return this._acquireLock(-1, async () => {
2959
3062
  try {
@@ -2963,12 +3066,50 @@ export default class GoTrueClient {
2963
3066
  return { data: null, error: sessionError }
2964
3067
  }
2965
3068
 
3069
+ const body: StrictOmit<
3070
+ | Exclude<MFAVerifyParams, MFAVerifyWebauthnParams>
3071
+ /** Exclude out the webauthn params from here because we're going to need to serialize them in the response */
3072
+ | Prettify<
3073
+ StrictOmit<MFAVerifyWebauthnParams, 'webauthn'> & {
3074
+ webauthn: Prettify<
3075
+ | StrictOmit<
3076
+ MFAVerifyWebauthnParamFields['webauthn'],
3077
+ 'credential_response'
3078
+ > & {
3079
+ credential_response: PublicKeyCredentialJSON
3080
+ }
3081
+ >
3082
+ }
3083
+ >,
3084
+ /* Exclude challengeId because the backend expects snake_case, and exclude factorId since it's passed in the path params */
3085
+ 'challengeId' | 'factorId'
3086
+ > & {
3087
+ challenge_id: string
3088
+ } = {
3089
+ challenge_id: params.challengeId,
3090
+ ...('webauthn' in params
3091
+ ? {
3092
+ webauthn: {
3093
+ ...params.webauthn,
3094
+ credential_response:
3095
+ params.webauthn.type === 'create'
3096
+ ? serializeCredentialCreationResponse(
3097
+ params.webauthn.credential_response as RegistrationCredential
3098
+ )
3099
+ : serializeCredentialRequestResponse(
3100
+ params.webauthn.credential_response as AuthenticationCredential
3101
+ ),
3102
+ },
3103
+ }
3104
+ : { code: params.code }),
3105
+ }
3106
+
2966
3107
  const { data, error } = await _request(
2967
3108
  this.fetch,
2968
3109
  'POST',
2969
3110
  `${this.url}/factors/${params.factorId}/verify`,
2970
3111
  {
2971
- body: { code: params.code, challenge_id: params.challengeId },
3112
+ body,
2972
3113
  headers: this.headers,
2973
3114
  jwt: sessionData?.session?.access_token,
2974
3115
  }
@@ -2997,6 +3138,15 @@ export default class GoTrueClient {
2997
3138
  /**
2998
3139
  * {@see GoTrueMFAApi#challenge}
2999
3140
  */
3141
+ private async _challenge(
3142
+ params: MFAChallengeTOTPParams
3143
+ ): Promise<Prettify<AuthMFAChallengeTOTPResponse>>
3144
+ private async _challenge(
3145
+ params: MFAChallengePhoneParams
3146
+ ): Promise<Prettify<AuthMFAChallengePhoneResponse>>
3147
+ private async _challenge(
3148
+ params: MFAChallengeWebauthnParams
3149
+ ): Promise<Prettify<AuthMFAChallengeWebauthnResponse>>
3000
3150
  private async _challenge(params: MFAChallengeParams): Promise<AuthMFAChallengeResponse> {
3001
3151
  return this._acquireLock(-1, async () => {
3002
3152
  try {
@@ -3006,16 +3156,64 @@ export default class GoTrueClient {
3006
3156
  return { data: null, error: sessionError }
3007
3157
  }
3008
3158
 
3009
- return await _request(
3159
+ const response = (await _request(
3010
3160
  this.fetch,
3011
3161
  'POST',
3012
3162
  `${this.url}/factors/${params.factorId}/challenge`,
3013
3163
  {
3014
- body: { channel: params.channel },
3164
+ body: params,
3015
3165
  headers: this.headers,
3016
3166
  jwt: sessionData?.session?.access_token,
3017
3167
  }
3018
- )
3168
+ )) as
3169
+ | Exclude<AuthMFAChallengeResponse, AuthMFAChallengeWebauthnResponse>
3170
+ /** The server will send `serialized` data, so we assert the serialized response */
3171
+ | AuthMFAChallengeWebauthnServerResponse
3172
+
3173
+ if (response.error) {
3174
+ return response
3175
+ }
3176
+
3177
+ const { data } = response
3178
+
3179
+ if (data.type !== 'webauthn') {
3180
+ return { data, error: null }
3181
+ }
3182
+
3183
+ switch (data.webauthn.type) {
3184
+ case 'create':
3185
+ return {
3186
+ data: {
3187
+ ...data,
3188
+ webauthn: {
3189
+ ...data.webauthn,
3190
+ credential_options: {
3191
+ ...data.webauthn.credential_options,
3192
+ publicKey: deserializeCredentialCreationOptions(
3193
+ data.webauthn.credential_options.publicKey
3194
+ ),
3195
+ },
3196
+ },
3197
+ },
3198
+ error: null,
3199
+ }
3200
+ case 'request':
3201
+ return {
3202
+ data: {
3203
+ ...data,
3204
+ webauthn: {
3205
+ ...data.webauthn,
3206
+ credential_options: {
3207
+ ...data.webauthn.credential_options,
3208
+ publicKey: deserializeCredentialRequestOptions(
3209
+ data.webauthn.credential_options.publicKey
3210
+ ),
3211
+ },
3212
+ },
3213
+ },
3214
+ error: null,
3215
+ }
3216
+ }
3019
3217
  })
3020
3218
  } catch (error) {
3021
3219
  if (isAuthError(error)) {
@@ -3062,20 +3260,23 @@ export default class GoTrueClient {
3062
3260
  return { data: null, error: userError }
3063
3261
  }
3064
3262
 
3065
- const factors = user?.factors || []
3066
- const totp = factors.filter(
3067
- (factor) => factor.factor_type === 'totp' && factor.status === 'verified'
3068
- )
3069
- const phone = factors.filter(
3070
- (factor) => factor.factor_type === 'phone' && factor.status === 'verified'
3071
- )
3263
+ const data: AuthMFAListFactorsResponse['data'] = {
3264
+ all: [],
3265
+ phone: [],
3266
+ totp: [],
3267
+ webauthn: [],
3268
+ }
3269
+
3270
+ // loop over the factors ONCE
3271
+ for (const factor of user?.factors ?? []) {
3272
+ data.all.push(factor)
3273
+ if (factor.status === 'verified') {
3274
+ ;(data[factor.factor_type] as typeof factor[]).push(factor)
3275
+ }
3276
+ }
3072
3277
 
3073
3278
  return {
3074
- data: {
3075
- all: factors,
3076
- totp,
3077
- phone,
3078
- },
3279
+ data,
3079
3280
  error: null,
3080
3281
  }
3081
3282
  }
@@ -4,6 +4,8 @@
4
4
  * that repo!
5
5
  */
6
6
 
7
+ import { Uint8Array_ } from './webauthn.dom'
8
+
7
9
  /**
8
10
  * An array of characters that encode 6 bits into a Base64-URL alphabet
9
11
  * character.
@@ -268,7 +270,7 @@ export function stringFromUTF8(
268
270
  * Helper functions to convert different types of strings to Uint8Array
269
271
  */
270
272
 
271
- export function base64UrlToUint8Array(str: string): Uint8Array {
273
+ export function base64UrlToUint8Array(str: string): Uint8Array_ {
272
274
  const result: number[] = []
273
275
  const state = { queue: 0, queuedBits: 0 }
274
276
 
@@ -283,7 +285,7 @@ export function base64UrlToUint8Array(str: string): Uint8Array {
283
285
  return new Uint8Array(result)
284
286
  }
285
287
 
286
- export function stringToUint8Array(str: string): Uint8Array {
288
+ export function stringToUint8Array(str: string): Uint8Array_ {
287
289
  const result: number[] = []
288
290
  stringToUTF8(str, (byte: number) => result.push(byte))
289
291
  return new Uint8Array(result)
package/src/lib/errors.ts CHANGED
@@ -147,7 +147,7 @@ export class AuthWeakPasswordError extends CustomAuthError {
147
147
  */
148
148
  reasons: WeakPasswordReasons[]
149
149
 
150
- constructor(message: string, status: number, reasons: string[]) {
150
+ constructor(message: string, status: number, reasons: WeakPasswordReasons[]) {
151
151
  super(message, 'AuthWeakPasswordError', status, 'weak_password')
152
152
 
153
153
  this.reasons = reasons
@@ -2,6 +2,7 @@ import { API_VERSION_HEADER_NAME, BASE64URL_REGEX } from './constants'
2
2
  import { AuthInvalidJwtError } from './errors'
3
3
  import { base64UrlToUint8Array, stringFromBase64URL } from './base64url'
4
4
  import { JwtHeader, JwtPayload, SupportedStorage, User } from './types'
5
+ import { Uint8Array_ } from './webauthn.dom'
5
6
 
6
7
  export function expiresAt(expiresIn: number) {
7
8
  const timeNow = Math.round(Date.now() / 1000)
@@ -171,7 +172,7 @@ export class Deferred<T = any> {
171
172
  export function decodeJWT(token: string): {
172
173
  header: JwtHeader
173
174
  payload: JwtPayload
174
- signature: Uint8Array
175
+ signature: Uint8Array_
175
176
  raw: {
176
177
  header: string
177
178
  payload: string