@supabase/auth-js 2.81.2-canary.0 → 2.81.2-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main/GoTrueAdminApi.d.ts +13 -0
- package/dist/main/GoTrueAdminApi.d.ts.map +1 -1
- package/dist/main/GoTrueAdminApi.js +13 -0
- package/dist/main/GoTrueAdminApi.js.map +1 -1
- package/dist/main/GoTrueClient.d.ts +21 -0
- package/dist/main/GoTrueClient.d.ts.map +1 -1
- package/dist/main/GoTrueClient.js +70 -0
- package/dist/main/GoTrueClient.js.map +1 -1
- package/dist/main/lib/errors.d.ts +127 -0
- package/dist/main/lib/errors.d.ts.map +1 -1
- package/dist/main/lib/errors.js +127 -0
- package/dist/main/lib/errors.js.map +1 -1
- package/dist/main/lib/locks.d.ts +43 -0
- package/dist/main/lib/locks.d.ts.map +1 -1
- package/dist/main/lib/locks.js +43 -0
- package/dist/main/lib/locks.js.map +1 -1
- package/dist/main/lib/types.d.ts +46 -3
- package/dist/main/lib/types.d.ts.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/module/GoTrueAdminApi.d.ts +13 -0
- package/dist/module/GoTrueAdminApi.d.ts.map +1 -1
- package/dist/module/GoTrueAdminApi.js +13 -0
- package/dist/module/GoTrueAdminApi.js.map +1 -1
- package/dist/module/GoTrueClient.d.ts +21 -0
- package/dist/module/GoTrueClient.d.ts.map +1 -1
- package/dist/module/GoTrueClient.js +70 -0
- package/dist/module/GoTrueClient.js.map +1 -1
- package/dist/module/lib/errors.d.ts +127 -0
- package/dist/module/lib/errors.d.ts.map +1 -1
- package/dist/module/lib/errors.js +127 -0
- package/dist/module/lib/errors.js.map +1 -1
- package/dist/module/lib/locks.d.ts +43 -0
- package/dist/module/lib/locks.d.ts.map +1 -1
- package/dist/module/lib/locks.js +43 -0
- package/dist/module/lib/locks.js.map +1 -1
- package/dist/module/lib/types.d.ts +46 -3
- package/dist/module/lib/types.d.ts.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/tsconfig.module.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/GoTrueAdminApi.ts +13 -0
- package/src/GoTrueClient.ts +88 -0
- package/src/lib/errors.ts +127 -0
- package/src/lib/locks.ts +43 -0
- package/src/lib/types.ts +49 -3
- package/src/lib/version.ts +1 -1
package/src/lib/errors.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { WeakPasswordReasons } from './types'
|
|
2
2
|
import { ErrorCode } from './error-codes'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Base error thrown by Supabase Auth helpers.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { AuthError } from '@supabase/auth-js'
|
|
10
|
+
*
|
|
11
|
+
* throw new AuthError('Unexpected auth error', 500, 'unexpected')
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
4
14
|
export class AuthError extends Error {
|
|
5
15
|
/**
|
|
6
16
|
* Error code associated with the error. Most errors coming from
|
|
@@ -27,6 +37,16 @@ export function isAuthError(error: unknown): error is AuthError {
|
|
|
27
37
|
return typeof error === 'object' && error !== null && '__isAuthError' in error
|
|
28
38
|
}
|
|
29
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Error returned directly from the GoTrue REST API.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { AuthApiError } from '@supabase/auth-js'
|
|
46
|
+
*
|
|
47
|
+
* throw new AuthApiError('Invalid credentials', 400, 'invalid_credentials')
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
30
50
|
export class AuthApiError extends AuthError {
|
|
31
51
|
status: number
|
|
32
52
|
|
|
@@ -42,6 +62,20 @@ export function isAuthApiError(error: unknown): error is AuthApiError {
|
|
|
42
62
|
return isAuthError(error) && error.name === 'AuthApiError'
|
|
43
63
|
}
|
|
44
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Wraps non-standard errors so callers can inspect the root cause.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { AuthUnknownError } from '@supabase/auth-js'
|
|
71
|
+
*
|
|
72
|
+
* try {
|
|
73
|
+
* await someAuthCall()
|
|
74
|
+
* } catch (err) {
|
|
75
|
+
* throw new AuthUnknownError('Auth failed', err)
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
45
79
|
export class AuthUnknownError extends AuthError {
|
|
46
80
|
originalError: unknown
|
|
47
81
|
|
|
@@ -52,6 +86,16 @@ export class AuthUnknownError extends AuthError {
|
|
|
52
86
|
}
|
|
53
87
|
}
|
|
54
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Flexible error class used to create named auth errors at runtime.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* import { CustomAuthError } from '@supabase/auth-js'
|
|
95
|
+
*
|
|
96
|
+
* throw new CustomAuthError('My custom auth error', 'MyAuthError', 400, 'custom_code')
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
55
99
|
export class CustomAuthError extends AuthError {
|
|
56
100
|
name: string
|
|
57
101
|
status: number
|
|
@@ -63,6 +107,16 @@ export class CustomAuthError extends AuthError {
|
|
|
63
107
|
}
|
|
64
108
|
}
|
|
65
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Error thrown when an operation requires a session but none is present.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* import { AuthSessionMissingError } from '@supabase/auth-js'
|
|
116
|
+
*
|
|
117
|
+
* throw new AuthSessionMissingError()
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
66
120
|
export class AuthSessionMissingError extends CustomAuthError {
|
|
67
121
|
constructor() {
|
|
68
122
|
super('Auth session missing!', 'AuthSessionMissingError', 400, undefined)
|
|
@@ -73,18 +127,51 @@ export function isAuthSessionMissingError(error: any): error is AuthSessionMissi
|
|
|
73
127
|
return isAuthError(error) && error.name === 'AuthSessionMissingError'
|
|
74
128
|
}
|
|
75
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Error thrown when the token response is malformed.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* import { AuthInvalidTokenResponseError } from '@supabase/auth-js'
|
|
136
|
+
*
|
|
137
|
+
* throw new AuthInvalidTokenResponseError()
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
76
140
|
export class AuthInvalidTokenResponseError extends CustomAuthError {
|
|
77
141
|
constructor() {
|
|
78
142
|
super('Auth session or user missing', 'AuthInvalidTokenResponseError', 500, undefined)
|
|
79
143
|
}
|
|
80
144
|
}
|
|
81
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Error thrown when email/password credentials are invalid.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* import { AuthInvalidCredentialsError } from '@supabase/auth-js'
|
|
152
|
+
*
|
|
153
|
+
* throw new AuthInvalidCredentialsError('Email or password is incorrect')
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
82
156
|
export class AuthInvalidCredentialsError extends CustomAuthError {
|
|
83
157
|
constructor(message: string) {
|
|
84
158
|
super(message, 'AuthInvalidCredentialsError', 400, undefined)
|
|
85
159
|
}
|
|
86
160
|
}
|
|
87
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Error thrown when implicit grant redirects contain an error.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { AuthImplicitGrantRedirectError } from '@supabase/auth-js'
|
|
168
|
+
*
|
|
169
|
+
* throw new AuthImplicitGrantRedirectError('OAuth redirect failed', {
|
|
170
|
+
* error: 'access_denied',
|
|
171
|
+
* code: 'oauth_error',
|
|
172
|
+
* })
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
88
175
|
export class AuthImplicitGrantRedirectError extends CustomAuthError {
|
|
89
176
|
details: { error: string; code: string } | null = null
|
|
90
177
|
constructor(message: string, details: { error: string; code: string } | null = null) {
|
|
@@ -108,6 +195,16 @@ export function isAuthImplicitGrantRedirectError(
|
|
|
108
195
|
return isAuthError(error) && error.name === 'AuthImplicitGrantRedirectError'
|
|
109
196
|
}
|
|
110
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Error thrown during PKCE code exchanges.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* import { AuthPKCEGrantCodeExchangeError } from '@supabase/auth-js'
|
|
204
|
+
*
|
|
205
|
+
* throw new AuthPKCEGrantCodeExchangeError('PKCE exchange failed')
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
111
208
|
export class AuthPKCEGrantCodeExchangeError extends CustomAuthError {
|
|
112
209
|
details: { error: string; code: string } | null = null
|
|
113
210
|
|
|
@@ -126,6 +223,16 @@ export class AuthPKCEGrantCodeExchangeError extends CustomAuthError {
|
|
|
126
223
|
}
|
|
127
224
|
}
|
|
128
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Error thrown when a transient fetch issue occurs.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* import { AuthRetryableFetchError } from '@supabase/auth-js'
|
|
232
|
+
*
|
|
233
|
+
* throw new AuthRetryableFetchError('Service temporarily unavailable', 503)
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
129
236
|
export class AuthRetryableFetchError extends CustomAuthError {
|
|
130
237
|
constructor(message: string, status: number) {
|
|
131
238
|
super(message, 'AuthRetryableFetchError', status, undefined)
|
|
@@ -141,6 +248,16 @@ export function isAuthRetryableFetchError(error: unknown): error is AuthRetryabl
|
|
|
141
248
|
* weak. Inspect the reasons to identify what password strength rules are
|
|
142
249
|
* inadequate.
|
|
143
250
|
*/
|
|
251
|
+
/**
|
|
252
|
+
* Error thrown when a supplied password is considered weak.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* import { AuthWeakPasswordError } from '@supabase/auth-js'
|
|
257
|
+
*
|
|
258
|
+
* throw new AuthWeakPasswordError('Password too short', 400, ['min_length'])
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
144
261
|
export class AuthWeakPasswordError extends CustomAuthError {
|
|
145
262
|
/**
|
|
146
263
|
* Reasons why the password is deemed weak.
|
|
@@ -158,6 +275,16 @@ export function isAuthWeakPasswordError(error: unknown): error is AuthWeakPasswo
|
|
|
158
275
|
return isAuthError(error) && error.name === 'AuthWeakPasswordError'
|
|
159
276
|
}
|
|
160
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Error thrown when a JWT cannot be verified or parsed.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* import { AuthInvalidJwtError } from '@supabase/auth-js'
|
|
284
|
+
*
|
|
285
|
+
* throw new AuthInvalidJwtError('Token signature is invalid')
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
161
288
|
export class AuthInvalidJwtError extends CustomAuthError {
|
|
162
289
|
constructor(message: string) {
|
|
163
290
|
super(message, 'AuthInvalidJwtError', 400, 'invalid_jwt')
|
package/src/lib/locks.ts
CHANGED
|
@@ -19,6 +19,17 @@ export const internals = {
|
|
|
19
19
|
* An error thrown when a lock cannot be acquired after some amount of time.
|
|
20
20
|
*
|
|
21
21
|
* Use the {@link #isAcquireTimeout} property instead of checking with `instanceof`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { LockAcquireTimeoutError } from '@supabase/auth-js'
|
|
26
|
+
*
|
|
27
|
+
* class CustomLockError extends LockAcquireTimeoutError {
|
|
28
|
+
* constructor() {
|
|
29
|
+
* super('Lock timed out')
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
22
33
|
*/
|
|
23
34
|
export abstract class LockAcquireTimeoutError extends Error {
|
|
24
35
|
public readonly isAcquireTimeout = true
|
|
@@ -28,7 +39,27 @@ export abstract class LockAcquireTimeoutError extends Error {
|
|
|
28
39
|
}
|
|
29
40
|
}
|
|
30
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Error thrown when the browser Navigator Lock API fails to acquire a lock.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { NavigatorLockAcquireTimeoutError } from '@supabase/auth-js'
|
|
48
|
+
*
|
|
49
|
+
* throw new NavigatorLockAcquireTimeoutError('Lock timed out')
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
31
52
|
export class NavigatorLockAcquireTimeoutError extends LockAcquireTimeoutError {}
|
|
53
|
+
/**
|
|
54
|
+
* Error thrown when the process-level lock helper cannot acquire a lock.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { ProcessLockAcquireTimeoutError } from '@supabase/auth-js'
|
|
59
|
+
*
|
|
60
|
+
* throw new ProcessLockAcquireTimeoutError('Lock timed out')
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
32
63
|
export class ProcessLockAcquireTimeoutError extends LockAcquireTimeoutError {}
|
|
33
64
|
|
|
34
65
|
/**
|
|
@@ -55,6 +86,12 @@ export class ProcessLockAcquireTimeoutError extends LockAcquireTimeoutError {}
|
|
|
55
86
|
* will time out after so many milliseconds. An error is
|
|
56
87
|
* a timeout if it has `isAcquireTimeout` set to true.
|
|
57
88
|
* @param fn The operation to run once the lock is acquired.
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* await navigatorLock('sync-user', 1000, async () => {
|
|
92
|
+
* await refreshSession()
|
|
93
|
+
* })
|
|
94
|
+
* ```
|
|
58
95
|
*/
|
|
59
96
|
export async function navigatorLock<R>(
|
|
60
97
|
name: string,
|
|
@@ -167,6 +204,12 @@ const PROCESS_LOCKS: { [name: string]: Promise<any> } = {}
|
|
|
167
204
|
* will time out after so many milliseconds. An error is
|
|
168
205
|
* a timeout if it has `isAcquireTimeout` set to true.
|
|
169
206
|
* @param fn The operation to run once the lock is acquired.
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* await processLock('migrate', 5000, async () => {
|
|
210
|
+
* await runMigration()
|
|
211
|
+
* })
|
|
212
|
+
* ```
|
|
170
213
|
*/
|
|
171
214
|
export async function processLock<R>(
|
|
172
215
|
name: string,
|
package/src/lib/types.ts
CHANGED
|
@@ -1675,11 +1675,11 @@ export interface GoTrueAdminOAuthApi {
|
|
|
1675
1675
|
*/
|
|
1676
1676
|
export type OAuthAuthorizationClient = {
|
|
1677
1677
|
/** Unique identifier for the OAuth client (UUID) */
|
|
1678
|
-
|
|
1678
|
+
id: string
|
|
1679
1679
|
/** Human-readable name of the OAuth client */
|
|
1680
|
-
|
|
1680
|
+
name: string
|
|
1681
1681
|
/** URI of the OAuth client's website */
|
|
1682
|
-
|
|
1682
|
+
uri: string
|
|
1683
1683
|
/** URI of the OAuth client's logo */
|
|
1684
1684
|
logo_uri: string
|
|
1685
1685
|
}
|
|
@@ -1721,6 +1721,31 @@ export type AuthOAuthConsentResponse = RequestResult<{
|
|
|
1721
1721
|
redirect_url: string
|
|
1722
1722
|
}>
|
|
1723
1723
|
|
|
1724
|
+
/**
|
|
1725
|
+
* An OAuth grant representing a user's authorization of an OAuth client.
|
|
1726
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1727
|
+
*/
|
|
1728
|
+
export type OAuthGrant = {
|
|
1729
|
+
/** OAuth client information */
|
|
1730
|
+
client: OAuthAuthorizationClient
|
|
1731
|
+
/** Array of scopes granted to this client */
|
|
1732
|
+
scopes: string[]
|
|
1733
|
+
/** Timestamp when the grant was created (ISO 8601 date-time) */
|
|
1734
|
+
granted_at: string
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* Response type for listing user's OAuth grants.
|
|
1739
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1740
|
+
*/
|
|
1741
|
+
export type AuthOAuthGrantsResponse = RequestResult<OAuthGrant[]>
|
|
1742
|
+
|
|
1743
|
+
/**
|
|
1744
|
+
* Response type for revoking an OAuth grant.
|
|
1745
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1746
|
+
*/
|
|
1747
|
+
export type AuthOAuthRevokeGrantResponse = RequestResult<{}>
|
|
1748
|
+
|
|
1724
1749
|
/**
|
|
1725
1750
|
* Contains all OAuth 2.1 authorization server user-facing methods.
|
|
1726
1751
|
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
@@ -1767,4 +1792,25 @@ export interface AuthOAuthServerApi {
|
|
|
1767
1792
|
authorizationId: string,
|
|
1768
1793
|
options?: { skipBrowserRedirect?: boolean }
|
|
1769
1794
|
): Promise<AuthOAuthConsentResponse>
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* Lists all OAuth grants that the authenticated user has authorized.
|
|
1798
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1799
|
+
*
|
|
1800
|
+
* @returns Response with array of OAuth grants with client information and granted scopes
|
|
1801
|
+
*/
|
|
1802
|
+
listGrants(): Promise<AuthOAuthGrantsResponse>
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* Revokes a user's OAuth grant for a specific client.
|
|
1806
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1807
|
+
*
|
|
1808
|
+
* Revocation marks consent as revoked, deletes active sessions for that OAuth client,
|
|
1809
|
+
* and invalidates associated refresh tokens.
|
|
1810
|
+
*
|
|
1811
|
+
* @param options - Revocation options
|
|
1812
|
+
* @param options.clientId - The OAuth client identifier (UUID) to revoke access for
|
|
1813
|
+
* @returns Empty response on successful revocation
|
|
1814
|
+
*/
|
|
1815
|
+
revokeGrant(options: { clientId: string }): Promise<AuthOAuthRevokeGrantResponse>
|
|
1770
1816
|
}
|
package/src/lib/version.ts
CHANGED
|
@@ -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 = '2.81.2-canary.
|
|
7
|
+
export const version = '2.81.2-canary.2'
|