@supabase/auth-js 3.0.0-next.2 → 3.0.0-next.20

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 (85) hide show
  1. package/dist/main/GoTrueAdminApi.d.ts +28 -4
  2. package/dist/main/GoTrueAdminApi.d.ts.map +1 -1
  3. package/dist/main/GoTrueAdminApi.js +50 -3
  4. package/dist/main/GoTrueAdminApi.js.map +1 -1
  5. package/dist/main/GoTrueClient.d.ts +80 -7
  6. package/dist/main/GoTrueClient.d.ts.map +1 -1
  7. package/dist/main/GoTrueClient.js +387 -35
  8. package/dist/main/GoTrueClient.js.map +1 -1
  9. package/dist/main/lib/fetch.d.ts +28 -8
  10. package/dist/main/lib/fetch.d.ts.map +1 -1
  11. package/dist/main/lib/fetch.js +15 -2
  12. package/dist/main/lib/fetch.js.map +1 -1
  13. package/dist/main/lib/helpers.d.ts +4 -1
  14. package/dist/main/lib/helpers.d.ts.map +1 -1
  15. package/dist/main/lib/helpers.js +9 -3
  16. package/dist/main/lib/helpers.js.map +1 -1
  17. package/dist/main/lib/locks.d.ts.map +1 -1
  18. package/dist/main/lib/locks.js +8 -3
  19. package/dist/main/lib/locks.js.map +1 -1
  20. package/dist/main/lib/types.d.ts +138 -11
  21. package/dist/main/lib/types.d.ts.map +1 -1
  22. package/dist/main/lib/types.js.map +1 -1
  23. package/dist/main/lib/version.d.ts +1 -1
  24. package/dist/main/lib/version.d.ts.map +1 -1
  25. package/dist/main/lib/version.js +1 -1
  26. package/dist/main/lib/version.js.map +1 -1
  27. package/dist/main/lib/webauthn.d.ts +8 -0
  28. package/dist/main/lib/webauthn.d.ts.map +1 -1
  29. package/dist/main/lib/webauthn.dom.d.ts +3 -3
  30. package/dist/main/lib/webauthn.dom.d.ts.map +1 -1
  31. package/dist/main/lib/webauthn.errors.d.ts +5 -0
  32. package/dist/main/lib/webauthn.errors.d.ts.map +1 -1
  33. package/dist/main/lib/webauthn.errors.js +7 -0
  34. package/dist/main/lib/webauthn.errors.js.map +1 -1
  35. package/dist/main/lib/webauthn.js +1 -0
  36. package/dist/main/lib/webauthn.js.map +1 -1
  37. package/dist/module/GoTrueAdminApi.d.ts +28 -4
  38. package/dist/module/GoTrueAdminApi.d.ts.map +1 -1
  39. package/dist/module/GoTrueAdminApi.js +51 -4
  40. package/dist/module/GoTrueAdminApi.js.map +1 -1
  41. package/dist/module/GoTrueClient.d.ts +80 -7
  42. package/dist/module/GoTrueClient.d.ts.map +1 -1
  43. package/dist/module/GoTrueClient.js +389 -37
  44. package/dist/module/GoTrueClient.js.map +1 -1
  45. package/dist/module/lib/fetch.d.ts +28 -8
  46. package/dist/module/lib/fetch.d.ts.map +1 -1
  47. package/dist/module/lib/fetch.js +15 -2
  48. package/dist/module/lib/fetch.js.map +1 -1
  49. package/dist/module/lib/helpers.d.ts +4 -1
  50. package/dist/module/lib/helpers.d.ts.map +1 -1
  51. package/dist/module/lib/helpers.js +8 -3
  52. package/dist/module/lib/helpers.js.map +1 -1
  53. package/dist/module/lib/locks.d.ts.map +1 -1
  54. package/dist/module/lib/locks.js +8 -3
  55. package/dist/module/lib/locks.js.map +1 -1
  56. package/dist/module/lib/types.d.ts +138 -11
  57. package/dist/module/lib/types.d.ts.map +1 -1
  58. package/dist/module/lib/types.js.map +1 -1
  59. package/dist/module/lib/version.d.ts +1 -1
  60. package/dist/module/lib/version.d.ts.map +1 -1
  61. package/dist/module/lib/version.js +1 -1
  62. package/dist/module/lib/version.js.map +1 -1
  63. package/dist/module/lib/webauthn.d.ts +8 -0
  64. package/dist/module/lib/webauthn.d.ts.map +1 -1
  65. package/dist/module/lib/webauthn.dom.d.ts +3 -3
  66. package/dist/module/lib/webauthn.dom.d.ts.map +1 -1
  67. package/dist/module/lib/webauthn.errors.d.ts +5 -0
  68. package/dist/module/lib/webauthn.errors.d.ts.map +1 -1
  69. package/dist/module/lib/webauthn.errors.js +7 -0
  70. package/dist/module/lib/webauthn.errors.js.map +1 -1
  71. package/dist/module/lib/webauthn.js +1 -1
  72. package/dist/module/lib/webauthn.js.map +1 -1
  73. package/dist/tsconfig.module.tsbuildinfo +1 -1
  74. package/dist/tsconfig.tsbuildinfo +1 -1
  75. package/package.json +1 -1
  76. package/src/GoTrueAdminApi.ts +82 -3
  77. package/src/GoTrueClient.ts +462 -15
  78. package/src/lib/fetch.ts +53 -19
  79. package/src/lib/helpers.ts +13 -5
  80. package/src/lib/locks.ts +14 -7
  81. package/src/lib/types.ts +195 -10
  82. package/src/lib/version.ts +1 -1
  83. package/src/lib/webauthn.dom.ts +3 -3
  84. package/src/lib/webauthn.errors.ts +12 -0
  85. package/src/lib/webauthn.ts +1 -1
package/src/lib/fetch.ts CHANGED
@@ -3,11 +3,13 @@ import { expiresAt, looksLikeFetchResponse, parseResponseAPIVersion } from './he
3
3
  import {
4
4
  AuthResponse,
5
5
  AuthResponsePassword,
6
+ Session,
6
7
  SSOResponse,
7
8
  GenerateLinkProperties,
8
9
  GenerateLinkResponse,
9
10
  User,
10
11
  UserResponse,
12
+ WeakPassword,
11
13
  } from './types'
12
14
  import {
13
15
  AuthApiError,
@@ -19,6 +21,30 @@ import {
19
21
 
20
22
  export type Fetch = typeof fetch
21
23
 
24
+ /** Raw session data from GoTrue server response. */
25
+ interface GoTrueSessionData {
26
+ access_token?: string
27
+ refresh_token?: string
28
+ expires_in?: number
29
+ expires_at?: number
30
+ user?: User
31
+ [key: string]: any // server returns additional fields (token_type, provider_token, etc.) copied into Session
32
+ }
33
+
34
+ /** Raw session data that includes weak password info (password sign-in endpoints). */
35
+ interface GoTrueSessionPasswordData extends GoTrueSessionData {
36
+ weak_password?: WeakPassword
37
+ }
38
+
39
+ /** Raw user data — either `{ user: User }` or the User object itself. */
40
+ interface GoTrueUserData {
41
+ user?: User
42
+ [key: string]: any // data may BE the User directly (fallback path)
43
+ }
44
+
45
+ /** Raw generate-link data — link properties + User fields flattened into one object. */
46
+ type GoTrueGenerateLinkData = GenerateLinkProperties & Record<string, any>
47
+
22
48
  export interface FetchOptions {
23
49
  headers?: {
24
50
  [key: string]: string
@@ -30,10 +56,18 @@ export interface FetchParameters {
30
56
  signal?: AbortSignal
31
57
  }
32
58
 
33
- export type RequestMethodType = 'GET' | 'POST' | 'PUT' | 'DELETE'
59
+ export type RequestMethodType = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
34
60
 
35
- const _getErrorMessage = (err: any): string =>
36
- err.msg || err.message || err.error_description || err.error || JSON.stringify(err)
61
+ const _getErrorMessage = (err: unknown): string => {
62
+ if (typeof err === 'object' && err !== null) {
63
+ const e = err as Record<string, unknown>
64
+ if (typeof e.msg === 'string') return e.msg
65
+ if (typeof e.message === 'string') return e.message
66
+ if (typeof e.error_description === 'string') return e.error_description
67
+ if (typeof e.error === 'string') return e.error
68
+ }
69
+ return JSON.stringify(err)
70
+ }
37
71
 
38
72
  // 502, 503, 504: Standard server/gateway errors
39
73
  // 520-524, 530: Cloudflare-specific error codes (web server down, connection timed out, etc.)
@@ -53,7 +87,7 @@ export async function handleError(error: unknown) {
53
87
  let data: any
54
88
  try {
55
89
  data = await error.json()
56
- } catch (e: any) {
90
+ } catch (e) {
57
91
  throw new AuthUnknownError(_getErrorMessage(e), e)
58
92
  }
59
93
 
@@ -181,7 +215,7 @@ async function _handleRequest(
181
215
  ): Promise<any> {
182
216
  const requestParams = _getRequestParams(method, options, parameters, body)
183
217
 
184
- let result: any
218
+ let result: Response
185
219
 
186
220
  try {
187
221
  result = await fetcher(url, {
@@ -204,18 +238,18 @@ async function _handleRequest(
204
238
 
205
239
  try {
206
240
  return await result.json()
207
- } catch (e: any) {
241
+ } catch (e) {
208
242
  await handleError(e)
209
243
  }
210
244
  }
211
245
 
212
- export function _sessionResponse(data: any): AuthResponse {
246
+ export function _sessionResponse(data: GoTrueSessionData): AuthResponse {
213
247
  let session = null
214
248
  if (hasSession(data)) {
215
- session = { ...data }
249
+ session = { ...data } as Session
216
250
 
217
251
  if (!data.expires_at) {
218
- session.expires_at = expiresAt(data.expires_in)
252
+ session.expires_at = expiresAt(data.expires_in!)
219
253
  }
220
254
  }
221
255
 
@@ -223,7 +257,7 @@ export function _sessionResponse(data: any): AuthResponse {
223
257
  return { data: { session, user }, error: null }
224
258
  }
225
259
 
226
- export function _sessionResponsePassword(data: any): AuthResponsePassword {
260
+ export function _sessionResponsePassword(data: GoTrueSessionPasswordData): AuthResponsePassword {
227
261
  const response = _sessionResponse(data) as AuthResponsePassword
228
262
 
229
263
  if (
@@ -234,7 +268,7 @@ export function _sessionResponsePassword(data: any): AuthResponsePassword {
234
268
  data.weak_password.reasons.length &&
235
269
  data.weak_password.message &&
236
270
  typeof data.weak_password.message === 'string' &&
237
- data.weak_password.reasons.reduce((a: boolean, i: any) => a && typeof i === 'string', true)
271
+ data.weak_password.reasons.reduce((a: boolean, i: unknown) => a && typeof i === 'string', true)
238
272
  ) {
239
273
  response.data.weak_password = data.weak_password
240
274
  }
@@ -242,16 +276,16 @@ export function _sessionResponsePassword(data: any): AuthResponsePassword {
242
276
  return response
243
277
  }
244
278
 
245
- export function _userResponse(data: any): UserResponse {
279
+ export function _userResponse(data: GoTrueUserData): UserResponse {
246
280
  const user: User = data.user ?? (data as User)
247
281
  return { data: { user }, error: null }
248
282
  }
249
283
 
250
- export function _ssoResponse(data: any): SSOResponse {
251
- return { data, error: null }
284
+ export function _ssoResponse(data: Record<string, any>): SSOResponse {
285
+ return { data, error: null } as SSOResponse
252
286
  }
253
287
 
254
- export function _generateLinkResponse(data: any): GenerateLinkResponse {
288
+ export function _generateLinkResponse(data: GoTrueGenerateLinkData): GenerateLinkResponse {
255
289
  const { action_link, email_otp, hashed_token, redirect_to, verification_type, ...rest } = data
256
290
 
257
291
  const properties: GenerateLinkProperties = {
@@ -262,7 +296,7 @@ export function _generateLinkResponse(data: any): GenerateLinkResponse {
262
296
  verification_type,
263
297
  }
264
298
 
265
- const user: User = { ...rest }
299
+ const user = { ...rest } as User
266
300
  return {
267
301
  data: {
268
302
  properties,
@@ -272,7 +306,7 @@ export function _generateLinkResponse(data: any): GenerateLinkResponse {
272
306
  }
273
307
  }
274
308
 
275
- export function _noResolveJsonResponse(data: any): Response {
309
+ export function _noResolveJsonResponse(data: Response): Response {
276
310
  return data
277
311
  }
278
312
 
@@ -281,6 +315,6 @@ export function _noResolveJsonResponse(data: any): Response {
281
315
  * @param data A response object
282
316
  * @returns true if a session is in the response
283
317
  */
284
- function hasSession(data: any): boolean {
285
- return data.access_token && data.refresh_token && data.expires_in
318
+ function hasSession(data: GoTrueSessionData): boolean {
319
+ return !!data.access_token && !!data.refresh_token && !!data.expires_in
286
320
  }
@@ -87,7 +87,7 @@ export function parseParametersFromURL(href: string) {
87
87
  hashSearchParams.forEach((value, key) => {
88
88
  result[key] = value
89
89
  })
90
- } catch (e: any) {
90
+ } catch (_e) {
91
91
  // hash is not a query string
92
92
  }
93
93
  }
@@ -235,7 +235,7 @@ export function retryable<T>(
235
235
  accept(result)
236
236
  return
237
237
  }
238
- } catch (e: any) {
238
+ } catch (e) {
239
239
  if (!isRetryable(attempt, e)) {
240
240
  reject(e)
241
241
  return
@@ -304,7 +304,7 @@ export async function getCodeChallengeAndMethod(
304
304
  const codeVerifier = generatePKCEVerifier()
305
305
  let storedCodeVerifier = codeVerifier
306
306
  if (isPasswordRecovery) {
307
- storedCodeVerifier += '/PASSWORD_RECOVERY'
307
+ storedCodeVerifier += '/recovery'
308
308
  }
309
309
  await setItemAsync(storage, `${storageKey}-code-verifier`, storedCodeVerifier)
310
310
  const codeChallenge = await generatePKCEChallenge(codeVerifier)
@@ -329,7 +329,7 @@ export function parseResponseAPIVersion(response: Response) {
329
329
  try {
330
330
  const date = new Date(`${apiVersion}T00:00:00.0Z`)
331
331
  return date
332
- } catch (e: any) {
332
+ } catch (_e) {
333
333
  return null
334
334
  }
335
335
  }
@@ -345,7 +345,7 @@ export function validateExp(exp: number) {
345
345
  }
346
346
 
347
347
  export function getAlgorithm(
348
- alg: 'HS256' | 'RS256' | 'ES256'
348
+ alg: 'HS256' | 'RS256' | 'ES256' | (string & {})
349
349
  ): RsaHashedImportParams | EcKeyImportParams {
350
350
  switch (alg) {
351
351
  case 'RS256':
@@ -372,6 +372,14 @@ export function validateUUID(str: string) {
372
372
  }
373
373
  }
374
374
 
375
+ export function assertPasskeyExperimentalEnabled(experimental: { passkey?: boolean }): void {
376
+ if (!experimental.passkey) {
377
+ throw new Error(
378
+ '@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).'
379
+ )
380
+ }
381
+ }
382
+
375
383
  export function userNotAvailableProxy(): User {
376
384
  const proxyTarget = {} as User
377
385
 
package/src/lib/locks.ts CHANGED
@@ -176,7 +176,7 @@ export async function navigatorLock<R>(
176
176
  '@supabase/gotrue-js: Navigator LockManager state',
177
177
  JSON.stringify(result, null, ' ')
178
178
  )
179
- } catch (e: any) {
179
+ } catch (e) {
180
180
  console.warn(
181
181
  '@supabase/gotrue-js: Error when querying Navigator LockManager state',
182
182
  e
@@ -198,14 +198,21 @@ export async function navigatorLock<R>(
198
198
  }
199
199
  }
200
200
  )
201
- } catch (e: any) {
201
+ } catch (e) {
202
202
  // Always clear the acquire timeout once the request settles, so it cannot
203
203
  // fire later and incorrectly abort/log after a rejection.
204
204
  if (acquireTimeout > 0) {
205
205
  clearTimeout(acquireTimeoutTimer)
206
206
  }
207
207
 
208
- if (e?.name === 'AbortError' && acquireTimeout > 0) {
208
+ // DOMException does not extend Error in Node.js, so use structural check
209
+ if (
210
+ e !== null &&
211
+ typeof e === 'object' &&
212
+ 'name' in e &&
213
+ e.name === 'AbortError' &&
214
+ acquireTimeout > 0
215
+ ) {
209
216
  if (abortController.signal.aborted) {
210
217
  // OUR timeout fired — the lock is genuinely orphaned. Steal it.
211
218
  //
@@ -370,14 +377,14 @@ export async function processLock<R>(
370
377
  if (timeoutId !== null) {
371
378
  clearTimeout(timeoutId)
372
379
  }
373
- } catch (e: any) {
380
+ } catch (e) {
374
381
  // Clear the timeout on error path as well
375
382
  if (timeoutId !== null) {
376
383
  clearTimeout(timeoutId)
377
384
  }
378
385
 
379
386
  // Re-throw timeout errors, ignore others
380
- if (e && e.isAcquireTimeout) {
387
+ if (e instanceof LockAcquireTimeoutError) {
381
388
  throw e
382
389
  }
383
390
  // Fall through to run fn() - previous operation finished with error
@@ -391,8 +398,8 @@ export async function processLock<R>(
391
398
  PROCESS_LOCKS[name] = (async () => {
392
399
  try {
393
400
  return await currentOperation
394
- } catch (e: any) {
395
- if (e && e.isAcquireTimeout) {
401
+ } catch (e) {
402
+ if (e instanceof LockAcquireTimeoutError) {
396
403
  // if the current operation timed out, it doesn't mean that the previous
397
404
  // operation finished, so we need continue waiting for it to finish
398
405
  try {
package/src/lib/types.ts CHANGED
@@ -6,6 +6,12 @@ import {
6
6
  ServerCredentialCreationOptions,
7
7
  ServerCredentialRequestOptions,
8
8
  WebAuthnApi,
9
+ WebAuthnError,
10
+ } from './webauthn'
11
+ import type {
12
+ RegistrationResponseJSON,
13
+ AuthenticationResponseJSON,
14
+ ServerCredentialResponse,
9
15
  } from './webauthn'
10
16
  import {
11
17
  AuthenticationCredential,
@@ -174,6 +180,27 @@ export type GoTrueClientOptions = {
174
180
  * @default false
175
181
  */
176
182
  skipAutoInitialize?: boolean
183
+
184
+ /**
185
+ * Opt-in flags for experimental features. These APIs may change without
186
+ * notice and are disabled by default.
187
+ *
188
+ * @experimental
189
+ */
190
+ experimental?: ExperimentalFeatureFlags
191
+ }
192
+
193
+ export type ExperimentalFeatureFlags = {
194
+ /**
195
+ * Enables passkey support:
196
+ * - `auth.signInWithPasskey()`, `auth.registerPasskey()`
197
+ * - `auth.passkey.*`
198
+ * - `auth.admin.passkey.*`
199
+ *
200
+ * Defaults to `false`. Calling any passkey method while this flag is
201
+ * disabled throws a descriptive error at call time.
202
+ */
203
+ passkey?: boolean
177
204
  }
178
205
 
179
206
  const WeakPasswordReasons = ['length', 'characters', 'pwned'] as const
@@ -666,7 +693,7 @@ export type SignInWithPasswordlessCredentials =
666
693
  }
667
694
  }
668
695
 
669
- export type AuthFlowType = 'implicit' | 'pkce'
696
+ export type AuthFlowType = 'implicit' | 'pkce' | (string & {})
670
697
  export type SignInWithOAuthCredentials = {
671
698
  /** One of the providers supported by GoTrue. */
672
699
  provider: Provider
@@ -831,8 +858,15 @@ export interface VerifyTokenHashParams {
831
858
  type: EmailOtpType
832
859
  }
833
860
 
834
- export type MobileOtpType = 'sms' | 'phone_change'
835
- export type EmailOtpType = 'signup' | 'invite' | 'magiclink' | 'recovery' | 'email_change' | 'email'
861
+ export type MobileOtpType = 'sms' | 'phone_change' | (string & {})
862
+ export type EmailOtpType =
863
+ | 'signup'
864
+ | 'invite'
865
+ | 'magiclink'
866
+ | 'recovery'
867
+ | 'email_change'
868
+ | 'email'
869
+ | (string & {})
836
870
 
837
871
  export type ResendParams =
838
872
  | {
@@ -1211,7 +1245,7 @@ export type AuthMFAListFactorsResponse<T extends typeof FactorTypes = typeof Fac
1211
1245
  }
1212
1246
  >
1213
1247
 
1214
- export type AuthenticatorAssuranceLevels = 'aal1' | 'aal2'
1248
+ export type AuthenticatorAssuranceLevels = 'aal1' | 'aal2' | (string & {})
1215
1249
 
1216
1250
  export type AuthMFAGetAuthenticatorAssuranceLevelResponse = RequestResult<{
1217
1251
  /** Current AAL level of the session. */
@@ -1905,7 +1939,7 @@ export type AuthMFAEnrollWebauthnResponse = RequestResult<
1905
1939
  >
1906
1940
 
1907
1941
  export type JwtHeader = {
1908
- alg: 'RS256' | 'ES256' | 'HS256'
1942
+ alg: 'RS256' | 'ES256' | 'HS256' | (string & {})
1909
1943
  kid: string
1910
1944
  typ: string
1911
1945
  }
@@ -1956,7 +1990,7 @@ export interface JwtPayload extends RequiredClaims {
1956
1990
  }
1957
1991
 
1958
1992
  export interface JWK {
1959
- kty: 'RSA' | 'EC' | 'oct'
1993
+ kty: 'RSA' | 'EC' | 'oct' | (string & {})
1960
1994
  key_ops: string[]
1961
1995
  alg?: string
1962
1996
  kid?: string
@@ -1970,7 +2004,7 @@ export type SignOutScope = (typeof SIGN_OUT_SCOPES)[number]
1970
2004
  * OAuth client grant types supported by the OAuth 2.1 server.
1971
2005
  * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
1972
2006
  */
1973
- export type OAuthClientGrantType = 'authorization_code' | 'refresh_token'
2007
+ export type OAuthClientGrantType = 'authorization_code' | 'refresh_token' | (string & {})
1974
2008
 
1975
2009
  /**
1976
2010
  * OAuth client response types supported by the OAuth 2.1 server.
@@ -1982,13 +2016,13 @@ export type OAuthClientResponseType = 'code'
1982
2016
  * OAuth client type indicating whether the client can keep credentials confidential.
1983
2017
  * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
1984
2018
  */
1985
- export type OAuthClientType = 'public' | 'confidential'
2019
+ export type OAuthClientType = 'public' | 'confidential' | (string & {})
1986
2020
 
1987
2021
  /**
1988
2022
  * OAuth client registration type.
1989
2023
  * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
1990
2024
  */
1991
- export type OAuthClientRegistrationType = 'dynamic' | 'manual'
2025
+ export type OAuthClientRegistrationType = 'dynamic' | 'manual' | (string & {})
1992
2026
 
1993
2027
  /**
1994
2028
  * OAuth client token endpoint authentication method.
@@ -2164,7 +2198,7 @@ export interface GoTrueAdminOAuthApi {
2164
2198
  /**
2165
2199
  * Type of custom identity provider.
2166
2200
  */
2167
- export type CustomProviderType = 'oauth2' | 'oidc'
2201
+ export type CustomProviderType = 'oauth2' | 'oidc' | (string & {})
2168
2202
 
2169
2203
  /**
2170
2204
  * OIDC discovery document fields.
@@ -2624,3 +2658,154 @@ export interface AuthOAuthServerApi {
2624
2658
  */
2625
2659
  revokeGrant(options: { clientId: string }): Promise<AuthOAuthRevokeGrantResponse>
2626
2660
  }
2661
+
2662
+ // --- Passkey Types ---
2663
+
2664
+ /** Response from POST /passkeys/registration/options */
2665
+ export type PasskeyRegistrationOptionsResponse = {
2666
+ challenge_id: string
2667
+ options: ServerCredentialCreationOptions
2668
+ expires_at: number
2669
+ }
2670
+
2671
+ /** Request body for POST /passkeys/registration/verify */
2672
+ export type PasskeyRegistrationVerifyParams = {
2673
+ challenge_id: string
2674
+ credential: RegistrationResponseJSON
2675
+ }
2676
+
2677
+ /** Response from POST /passkeys/registration/verify */
2678
+ export type PasskeyMetadata = {
2679
+ id: string
2680
+ friendly_name?: string
2681
+ created_at: string
2682
+ }
2683
+
2684
+ /** Response from POST /passkeys/authentication/options */
2685
+ export type PasskeyAuthenticationOptionsResponse = {
2686
+ challenge_id: string
2687
+ options: ServerCredentialRequestOptions
2688
+ expires_at: number
2689
+ }
2690
+
2691
+ /** Request body for POST /passkeys/authentication/verify */
2692
+ export type PasskeyAuthenticationVerifyParams = {
2693
+ challenge_id: string
2694
+ credential: AuthenticationResponseJSON
2695
+ }
2696
+
2697
+ /** Item in the passkeys list (GET /passkeys/ and admin list) */
2698
+ export type PasskeyListItem = {
2699
+ id: string
2700
+ friendly_name?: string
2701
+ created_at: string
2702
+ last_used_at?: string
2703
+ }
2704
+
2705
+ // --- Passkey SDK Method Parameter/Response Types ---
2706
+
2707
+ export type SignInWithPasskeyCredentials = {
2708
+ options?: {
2709
+ captchaToken?: string
2710
+ signal?: AbortSignal
2711
+ }
2712
+ }
2713
+
2714
+ export type RegisterPasskeyCredentials = {
2715
+ options?: {
2716
+ signal?: AbortSignal
2717
+ }
2718
+ }
2719
+
2720
+ export type VerifyPasskeyRegistrationParams = {
2721
+ /** Challenge ID from startRegistration */
2722
+ challengeId: string
2723
+ /** Serialized credential from navigator.credentials.create() */
2724
+ credential: ServerCredentialResponse
2725
+ }
2726
+
2727
+ export type StartPasskeyAuthenticationParams = {
2728
+ options?: {
2729
+ captchaToken?: string
2730
+ }
2731
+ }
2732
+
2733
+ export type VerifyPasskeyAuthenticationParams = {
2734
+ /** Challenge ID from startAuthentication */
2735
+ challengeId: string
2736
+ /** Serialized credential from navigator.credentials.get() */
2737
+ credential: ServerCredentialResponse
2738
+ }
2739
+
2740
+ export type PasskeyUpdateParams = {
2741
+ /** UUID of the passkey to update */
2742
+ passkeyId: string
2743
+ /** New friendly name (max 120 chars) */
2744
+ friendlyName: string
2745
+ }
2746
+
2747
+ export type PasskeyDeleteParams = {
2748
+ /** UUID of the passkey to delete */
2749
+ passkeyId: string
2750
+ }
2751
+
2752
+ // --- Passkey Response Types ---
2753
+
2754
+ export type AuthPasskeyRegistrationOptionsResponse =
2755
+ RequestResult<PasskeyRegistrationOptionsResponse>
2756
+ export type AuthPasskeyRegistrationVerifyResponse = RequestResult<
2757
+ PasskeyMetadata,
2758
+ WebAuthnError | AuthError
2759
+ >
2760
+ export type AuthPasskeyAuthenticationOptionsResponse =
2761
+ RequestResult<PasskeyAuthenticationOptionsResponse>
2762
+ export type AuthPasskeyAuthenticationVerifyResponse = RequestResult<
2763
+ { session: Session | null; user: User | null },
2764
+ WebAuthnError | AuthError
2765
+ >
2766
+ export type AuthPasskeyListResponse = RequestResult<PasskeyListItem[]>
2767
+ export type AuthPasskeyUpdateResponse = RequestResult<PasskeyListItem>
2768
+ export type AuthPasskeyDeleteResponse = RequestResult<null>
2769
+
2770
+ // --- Passkey Admin Types ---
2771
+
2772
+ export type AuthPasskeyAdminListParams = {
2773
+ userId: string
2774
+ }
2775
+
2776
+ export type AuthPasskeyAdminDeleteParams = {
2777
+ userId: string
2778
+ passkeyId: string
2779
+ }
2780
+
2781
+ // --- Passkey Namespace Interfaces ---
2782
+
2783
+ /**
2784
+ * Lower-level two-step API and management methods for passkeys.
2785
+ * Access via `supabase.auth.passkey`.
2786
+ */
2787
+ export interface AuthPasskeyApi {
2788
+ // Two-step registration
2789
+ startRegistration(): Promise<AuthPasskeyRegistrationOptionsResponse>
2790
+ verifyRegistration(
2791
+ params: VerifyPasskeyRegistrationParams
2792
+ ): Promise<AuthPasskeyRegistrationVerifyResponse>
2793
+
2794
+ // Two-step authentication
2795
+ startAuthentication(
2796
+ params?: StartPasskeyAuthenticationParams
2797
+ ): Promise<AuthPasskeyAuthenticationOptionsResponse>
2798
+ verifyAuthentication(
2799
+ params: VerifyPasskeyAuthenticationParams
2800
+ ): Promise<AuthPasskeyAuthenticationVerifyResponse>
2801
+
2802
+ // Management
2803
+ list(): Promise<AuthPasskeyListResponse>
2804
+ update(params: PasskeyUpdateParams): Promise<AuthPasskeyUpdateResponse>
2805
+ delete(params: PasskeyDeleteParams): Promise<AuthPasskeyDeleteResponse>
2806
+ }
2807
+
2808
+ export interface GoTrueAdminPasskeyApi {
2809
+ listPasskeys(params: AuthPasskeyAdminListParams): Promise<AuthPasskeyListResponse>
2810
+ deletePasskey(params: AuthPasskeyAdminDeleteParams): Promise<AuthPasskeyDeleteResponse>
2811
+ }
@@ -4,4 +4,4 @@
4
4
  // - Debugging and support (identifying which version is running)
5
5
  // - Telemetry and logging (version reporting in errors/analytics)
6
6
  // - Ensuring build artifacts match the published package version
7
- export const version = '3.0.0-next.2'
7
+ export const version = '3.0.0-next.20'
@@ -575,7 +575,7 @@ export interface PublicKeyCredentialFuture<
575
575
  *
576
576
  * @see {@link https://w3c.github.io/webauthn/#sctn-authenticator-data W3C WebAuthn Spec - Authenticator Data}
577
577
  */
578
- export type CredentialDeviceType = 'singleDevice' | 'multiDevice'
578
+ export type CredentialDeviceType = 'singleDevice' | 'multiDevice' | (string & {})
579
579
 
580
580
  /**
581
581
  * Categories of authenticators that Relying Parties can pass along to browsers during
@@ -591,7 +591,7 @@ export type CredentialDeviceType = 'singleDevice' | 'multiDevice'
591
591
  * @see {@link https://w3c.github.io/webauthn/#enumdef-publickeycredentialhint W3C WebAuthn Spec - PublicKeyCredentialHint}
592
592
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#hints MDN - hints}
593
593
  */
594
- export type PublicKeyCredentialHint = 'hybrid' | 'security-key' | 'client-device'
594
+ export type PublicKeyCredentialHint = 'hybrid' | 'security-key' | 'client-device' | (string & {})
595
595
 
596
596
  /**
597
597
  * Values for an attestation object's `fmt`.
@@ -633,4 +633,4 @@ export type Uint8Array_ = ReturnType<Uint8Array['slice']>
633
633
  * @see {@link https://w3c.github.io/webauthn/#enum-attachment W3C WebAuthn Spec - AuthenticatorAttachment}
634
634
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions/authenticatorSelection#authenticatorattachment MDN - authenticatorAttachment}
635
635
  */
636
- export type AuthenticatorAttachment = 'cross-platform' | 'platform'
636
+ export type AuthenticatorAttachment = 'cross-platform' | 'platform' | (string & {})
@@ -45,6 +45,18 @@ export class WebAuthnError extends Error {
45
45
  this.name = name ?? (cause instanceof Error ? cause.name : undefined) ?? 'Unknown Error'
46
46
  this.code = code
47
47
  }
48
+
49
+ toJSON(): {
50
+ name: string
51
+ message: string
52
+ code: WebAuthnErrorCode
53
+ } {
54
+ return {
55
+ name: this.name,
56
+ message: this.message,
57
+ code: this.code,
58
+ }
59
+ }
48
60
  }
49
61
 
50
62
  /**
@@ -356,7 +356,7 @@ export function isValidDomain(hostname: string): boolean {
356
356
  * @returns {boolean} True if browser supports WebAuthn
357
357
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential#browser_compatibility MDN - PublicKeyCredential Browser Compatibility}
358
358
  */
359
- function browserSupportsWebAuthn(): boolean {
359
+ export function browserSupportsWebAuthn(): boolean {
360
360
  return !!(
361
361
  isBrowser() &&
362
362
  'PublicKeyCredential' in window &&