You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Callback function for managing the closing of the MongoDB client.
55
-
* This could be useful when `client` is provided as a function returning MongoClient | Promise<MongoClient>.
55
+
* This could be useful when `client` is provided as a function returning MongoClient.
56
56
* It allows for more customized management of database connections,
57
57
* addressing persistence, container reuse, and connection closure issues.
58
58
*/
@@ -115,7 +115,7 @@ export function MongoDBAdapter(
115
115
* - A promise that resolves to a connected `MongoClient` (not recommended).
116
116
* - A function, to handle more complex and custom connection strategies.
117
117
*
118
-
* Using a function that returns `MongoClient | Promise<MongoClient>`, combined with `options.onClose`, can be useful when you want a more advanced and customized connection strategy to address challenges related to persistence, container reuse, and connection closure.
118
+
* Using a function combined with `options.onClose`, can be useful when you want a more advanced and customized connection strategy to address challenges related to persistence, container reuse, and connection closure.
Copy file name to clipboardExpand all lines: packages/core/src/errors.ts
+80-3Lines changed: 80 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -38,17 +38,24 @@ type ErrorType =
38
38
* Base error class for all Auth.js errors.
39
39
* It's optimized to be printed in the server logs in a nicely formatted way
40
40
* via the [`logger.error`](https://authjs.dev/reference/core#logger) option.
41
+
* @noInheritDoc
41
42
*/
42
43
exportclassAuthErrorextendsError{
43
-
/** The error type. Used to identify the error in the logs. */
44
+
/** The error type. Used to identify the error in the logs.
45
+
* @internal
46
+
*/
44
47
type: ErrorType
45
48
/**
46
49
* Determines on which page an error should be handled. Typically `signIn` errors can be handled in-page.
47
50
* Default is `"error"`.
48
51
* @internal
49
52
*/
50
53
kind?: "signIn"|"error"
54
+
55
+
/** @internal */
51
56
cause?: Record<string,unknown>&{err?: Error}
57
+
58
+
/** @internal */
52
59
constructor(
53
60
message?: string|Error|ErrorOptions,
54
61
errorOptions?: ErrorOptions
@@ -77,7 +84,12 @@ export class AuthError extends Error {
77
84
}
78
85
}
79
86
87
+
/**
88
+
* Thrown when the user's sign-in attempt failed.
89
+
* @noInheritDoc
90
+
*/
80
91
exportclassSignInErrorextendsAuthError{
92
+
/** @internal */
81
93
statickind="signIn"
82
94
}
83
95
@@ -93,16 +105,20 @@ export class SignInError extends AuthError {
93
105
* { "args": [undefined] }
94
106
* ```
95
107
* :::
108
+
* @noInheritDoc
96
109
*/
97
110
exportclassAdapterErrorextendsAuthError{
111
+
/** @internal */
98
112
statictype="AdapterError"
99
113
}
100
114
101
115
/**
102
116
* Thrown when the execution of the [`signIn` callback](https://authjs.dev/reference/core/types#signin) fails
103
117
* or if it returns `false`.
118
+
* @noInheritDoc
104
119
*/
105
120
exportclassAccessDeniedextendsAuthError{
121
+
/** @internal */
106
122
statictype="AccessDenied"
107
123
}
108
124
@@ -144,8 +160,10 @@ export class AccessDenied extends AuthError {
144
160
* Check out `[auth][cause]` in the error message for more details.
145
161
* It will show the original stack trace.
146
162
* :::
163
+
* @noInheritDoc
147
164
*/
148
165
exportclassCallbackRouteErrorextendsAuthError{
166
+
/** @internal */
149
167
statictype="CallbackRouteError"
150
168
}
151
169
@@ -156,8 +174,10 @@ export class CallbackRouteError extends AuthError {
156
174
* To fix this, make sure that the `error` page does not require authentication.
157
175
*
158
176
* Learn more at [Guide: Error pages](https://authjs.dev/guides/pages/error)
177
+
* @noInheritDoc
159
178
*/
160
179
exportclassErrorPageLoopextendsAuthError{
180
+
/** @internal */
161
181
statictype="ErrorPageLoop"
162
182
}
163
183
@@ -168,8 +188,10 @@ export class ErrorPageLoop extends AuthError {
168
188
* Make sure that the `events` methods are implemented correctly and uncaught errors are handled.
169
189
*
170
190
* Learn more at [`events`](https://authjs.dev/reference/core/types#eventcallbacks)
191
+
* @noInheritDoc
171
192
*/
172
193
exportclassEventErrorextendsAuthError{
194
+
/** @internal */
173
195
statictype="EventError"
174
196
}
175
197
@@ -182,8 +204,10 @@ export class EventError extends AuthError {
182
204
* To prevent this, Auth.js checks if the callback URL is valid and throws this error if it is not.
183
205
*
184
206
* There is no action required, but it might be an indicator that somebody is trying to attack your application.
207
+
* @noInheritDoc
185
208
*/
186
209
exportclassInvalidCallbackUrlextendsAuthError{
210
+
/** @internal */
187
211
statictype="InvalidCallbackUrl"
188
212
}
189
213
@@ -192,8 +216,10 @@ export class InvalidCallbackUrl extends AuthError {
192
216
* When an error occurs during the `authorize` callback, two things can happen:
193
217
* 1. The user is redirected to the signin page, with `error=CredentialsSignin&code=credentials` in the URL. `code` is configurable.
194
218
* 2. If you throw this error in a framework that handles form actions server-side, this error is thrown, instead of redirecting the user, so you'll need to handle.
219
+
* @noInheritDoc
195
220
*/
196
221
exportclassCredentialsSigninextendsSignInError{
222
+
/** @internal */
197
223
statictype="CredentialsSignin"
198
224
/**
199
225
* The error code that is set in the `code` query parameter of the redirect URL.
@@ -214,8 +240,10 @@ export class CredentialsSignin extends SignInError {
214
240
* To perform OAuth or OIDC sign in, at least one of these endpoints is required.
215
241
*
216
242
* Learn more at [`OAuth2Config`](https://authjs.dev/reference/core/providers#oauth2configprofile) or [Guide: OAuth Provider](https://authjs.dev/guides/configuring-oauth-providers)
243
+
* @noInheritDoc
217
244
*/
218
245
exportclassInvalidEndpointsextendsAuthError{
246
+
/** @internal */
219
247
statictype="InvalidEndpoints"
220
248
}
221
249
@@ -224,8 +252,10 @@ export class InvalidEndpoints extends AuthError {
224
252
* This could happen if the OAuth provider is configured incorrectly or if the browser is blocking cookies.
225
253
*
226
254
* Learn more at [`checks`](https://authjs.dev/reference/core/providers#checks)
255
+
* @noInheritDoc
227
256
*/
228
257
exportclassInvalidCheckextendsAuthError{
258
+
/** @internal */
229
259
statictype="InvalidCheck"
230
260
}
231
261
@@ -239,8 +269,10 @@ export class InvalidCheck extends AuthError {
239
269
* :::
240
270
*
241
271
* Learn more at [`secret`](https://authjs.dev/reference/core#secret), [`jwt.encode`](https://authjs.dev/reference/core/jwt#encode-1) or [`jwt.decode`](https://authjs.dev/reference/core/jwt#decode-2) for more information.
272
+
* @noInheritDoc
242
273
*/
243
274
exportclassJWTSessionErrorextendsAuthError{
275
+
/** @internal */
244
276
statictype="JWTSessionError"
245
277
}
246
278
@@ -250,8 +282,10 @@ export class JWTSessionError extends AuthError {
250
282
* In both cases, make sure you either remove the configuration or add the missing adapter.
251
283
*
252
284
* Learn more at [Database Adapters](https://authjs.dev/getting-started/database), [Email provider](https://authjs.dev/getting-started/authentication/email) or [Concept: Database session strategy](https://authjs.dev/concepts/session-strategies#database-session)
285
+
* @noInheritDoc
253
286
*/
254
287
exportclassMissingAdapterextendsAuthError{
288
+
/** @internal */
255
289
statictype="MissingAdapter"
256
290
}
257
291
@@ -261,8 +295,10 @@ export class MissingAdapter extends AuthError {
261
295
* Make sure you either remove the configuration or add the missing methods to the adapter.
262
296
*
263
297
* Learn more at [Database Adapters](https://authjs.dev/getting-started/database)
298
+
* @noInheritDoc
264
299
*/
265
300
exportclassMissingAdapterMethodsextendsAuthError{
301
+
/** @internal */
266
302
statictype="MissingAdapterMethods"
267
303
}
268
304
@@ -271,8 +307,10 @@ export class MissingAdapterMethods extends AuthError {
271
307
* To perform credentials sign in, the `authorize` method is required.
272
308
*
273
309
* Learn more at [Credentials provider](https://authjs.dev/getting-started/authentication/credentials)
310
+
* @noInheritDoc
274
311
*/
275
312
exportclassMissingAuthorizeextendsAuthError{
313
+
/** @internal */
276
314
statictype="MissingAuthorize"
277
315
}
278
316
@@ -288,8 +326,10 @@ export class MissingAuthorize extends AuthError {
288
326
* :::tip
289
327
* To generate a random string, you can use the Auth.js CLI: `npx auth secret`
290
328
* :::
329
+
* @noInheritDoc
291
330
*/
292
331
exportclassMissingSecretextendsAuthError{
332
+
/** @internal */
293
333
statictype="MissingSecret"
294
334
}
295
335
@@ -304,8 +344,10 @@ export class MissingSecret extends AuthError {
304
344
* you can enable automatic account linking by setting [`allowDangerousEmailAccountLinking: true`](https://authjs.dev/reference/core/providers#allowdangerousemailaccountlinking)
@@ -314,17 +356,21 @@ export class OAuthAccountNotLinked extends SignInError {
314
356
* This could happen for example if the user denied access to the application or there was a configuration error.
315
357
*
316
358
* For a full list of possible reasons, check out the specification [Authorization Code Grant: Error Response](https://www.rfc-editor.org/rfc/rfc6749#section-4.1.2.1)
359
+
* @noInheritDoc
317
360
*/
318
361
exportclassOAuthCallbackErrorextendsSignInError{
362
+
/** @internal */
319
363
statictype="OAuthCallbackError"
320
364
}
321
365
322
366
/**
323
367
* This error occurs during an OAuth sign in attempt when the provider's
324
368
* response could not be parsed. This could for example happen if the provider's API
325
369
* changed, or the [`OAuth2Config.profile`](https://authjs.dev/reference/core/providers#oauth2configprofile) method is not implemented correctly.
@@ -334,8 +380,10 @@ export class OAuthProfileParseError extends AuthError {
334
380
* The database adapter might be misconfigured or the database is not reachable.
335
381
*
336
382
* Learn more at [Concept: Database session strategy](https://authjs.dev/concepts/session-strategies#database)
383
+
* @noInheritDoc
337
384
*/
338
385
exportclassSessionTokenErrorextendsAuthError{
386
+
/** @internal */
339
387
statictype="SessionTokenError"
340
388
}
341
389
@@ -353,8 +401,10 @@ export class SessionTokenError extends AuthError {
353
401
* [auth][details]: { "provider": "github" }
354
402
* ```
355
403
* :::
404
+
* @noInheritDoc
356
405
*/
357
406
exportclassOAuthSignInErrorextendsSignInError{
407
+
/** @internal */
358
408
statictype="OAuthSignInError"
359
409
}
360
410
@@ -367,8 +417,10 @@ export class OAuthSignInError extends SignInError {
367
417
* Ask the user to log in again.
368
418
* - There was an error with the database:
369
419
* Check the database logs.
420
+
* @noInheritDoc
370
421
*/
371
422
exportclassEmailSignInErrorextendsSignInError{
423
+
/** @internal */
372
424
statictype="EmailSignInError"
373
425
}
374
426
@@ -380,32 +432,41 @@ export class EmailSignInError extends SignInError {
380
432
* process, such as emitting sign-out events or clearing session cookies.
381
433
*
382
434
* The session cookie(s) are emptied even if this error is logged.
383
-
*
435
+
*@noInheritDoc
384
436
*/
385
437
exportclassSignOutErrorextendsAuthError{
438
+
/** @internal */
386
439
statictype="SignOutError"
387
440
}
388
441
389
442
/**
390
443
* Auth.js was requested to handle an operation that it does not support.
391
444
*
392
445
* See [`AuthAction`](https://authjs.dev/reference/core/types#authaction) for the supported actions.
446
+
* @noInheritDoc
393
447
*/
394
448
exportclassUnknownActionextendsAuthError{
449
+
/** @internal */
395
450
statictype="UnknownAction"
396
451
}
397
452
398
453
/**
399
454
* Thrown when a Credentials provider is present but the JWT strategy (`strategy: "jwt"`) is not enabled.
400
455
*
401
456
* Learn more at [`strategy`](https://authjs.dev/reference/core#strategy) or [Credentials provider](https://authjs.dev/getting-started/authentication/credentials)
457
+
* @noInheritDoc
402
458
*/
403
459
exportclassUnsupportedStrategyextendsAuthError{
460
+
/** @internal */
404
461
statictype="UnsupportedStrategy"
405
462
}
406
463
407
-
/** Thrown when an endpoint was incorrectly called without a provider, or with an unsupported provider. */
464
+
/**
465
+
* Thrown when an endpoint was incorrectly called without a provider, or with an unsupported provider.
466
+
* @noInheritDoc
467
+
*/
408
468
exportclassInvalidProviderextendsAuthError{
469
+
/** @internal */
409
470
statictype="InvalidProvider"
410
471
}
411
472
@@ -419,17 +480,21 @@ export class InvalidProvider extends AuthError {
419
480
* :::
420
481
*
421
482
* Learn more at [`trustHost`](https://authjs.dev/reference/core#trusthost) or [Guide: Deployment](https://authjs.dev/getting-started/deployment)
483
+
* @noInheritDoc
422
484
*/
423
485
exportclassUntrustedHostextendsAuthError{
486
+
/** @internal */
424
487
statictype="UntrustedHost"
425
488
}
426
489
427
490
/**
428
491
* The user's email/token combination was invalid.
429
492
* This could be because the email/token combination was not found in the database,
430
493
* or because the token has expired. Ask the user to log in again.
494
+
* @noInheritDoc
431
495
*/
432
496
exportclassVerificationextendsAuthError{
497
+
/** @internal */
433
498
statictype="Verification"
434
499
}
435
500
@@ -442,8 +507,10 @@ export class Verification extends AuthError {
442
507
*
443
508
* Double submit cookie pattern, a CSRF defense, requires matching values in a cookie
444
509
* and request parameter. More on this at [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Glossary/CSRF).
510
+
* @noInheritDoc
445
511
*/
446
512
exportclassMissingCSRFextendsSignInError{
513
+
/** @internal */
447
514
statictype="MissingCSRF"
448
515
}
449
516
@@ -471,24 +538,30 @@ export function isClientError(error: Error): error is AuthError {
471
538
/**
472
539
* Thrown when multiple providers have `enableConditionalUI` set to `true`.
473
540
* Only one provider can have this option enabled at a time.
* - `debug-enabled`: The `debug` option was evaluated to `true`. It adds extra logs in the terminal which is useful in development,
3
+
* but since it can print sensitive information about users, make sure to set this to `false` in production.
4
+
* In Node.js environments, you can for example set `debug: process.env.NODE_ENV !== "production"`.
5
+
* Consult with your runtime/framework on how to set this value correctly.
6
+
* - `csrf-disabled`: You were trying to get a CSRF response from Auth.js (eg.: by calling a `/csrf` endpoint),
7
+
* but in this setup, CSRF protection via Auth.js was turned off. This is likely if you are not directly using `@auth/core`
8
+
* but a framework library (like `@auth/sveltekit`) that already has CSRF protection built-in. You likely won't need the CSRF response.
9
+
* - `env-url-basepath-redundant`: `AUTH_URL` (or `NEXTAUTH_URL`) and `authConfig.basePath` are both declared. This is a configuration mistake - you should either remove the `authConfig.basePath` configuration,
10
+
* or remove the `pathname` of `AUTH_URL` (or `NEXTAUTH_URL`). Only one of them is needed.
11
+
* - `env-url-basepath-mismatch`: `AUTH_URL` (or `NEXTAUTH_URL`) and `authConfig.basePath` are both declared, but they don't match. This is a configuration mistake.
12
+
* `@auth/core` will use `basePath` to construct the full URL to the corresponding action (/signin, /signout, etc.) in this case.
13
+
* - `experimental-webauthn`: Experimental WebAuthn feature is enabled.
0 commit comments