Skip to content

Commit 7207529

Browse files
committed
split warning to a separate file
1 parent b31d829 commit 7207529

File tree

9 files changed

+30
-27
lines changed

9 files changed

+30
-27
lines changed

docs/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default withNextra({
7272
{
7373
source: "/:path(.*)",
7474
has: [{ type: "host", value: "warnings.authjs.dev" }],
75-
destination: "https://authjs.dev/reference/core/errors#warningcode",
75+
destination: "https://authjs.dev/reference/core/types#warningcode",
7676
permanent: true,
7777
},
7878
{

docs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint": "eslint ./{components,pages,utils}",
1313
"lint:fix": "eslint ./{components,pages,utils} --fix",
1414
"build:sitemap": "next-sitemap --config next-sitemap.config.cjs",
15-
"clean": "rm -rf .next build pages/reference/**/*.mdx pages/reference/*.mdx"
15+
"clean": "rm -rf .next build pages/reference/*.mdx pages/reference/**/*"
1616
},
1717
"repository": {
1818
"type": "git",

docs/typedoc-nextauth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function parseOutput(app) {
5757
const replaceCodeBlockTitle = (match, p1, p2, p3) => `${p1}filename="${p3}"`
5858

5959
page.contents = page.contents
60-
.replace(calloutRegex, replaceCallout)
60+
?.replace(calloutRegex, replaceCallout)
6161
.replace(codeBlockRegex, replaceCodeBlockTitle)
6262
})
6363
}

packages/core/src/errors.ts

-21
Original file line numberDiff line numberDiff line change
@@ -585,24 +585,3 @@ export class ExperimentalFeatureNotEnabled extends AuthError {
585585
/** @internal */
586586
static type = "ExperimentalFeatureNotEnabled"
587587
}
588-
589-
/**
590-
* - `debug-enabled`: The `debug` option was evaluated to `true`. It adds extra logs in the terminal which is useful in development,
591-
* but since it can print sensitive information about users, make sure to set this to `false` in production.
592-
* In Node.js environments, you can for example set `debug: process.env.NODE_ENV !== "production"`.
593-
* Consult with your runtime/framework on how to set this value correctly.
594-
* - `csrf-disabled`: You were trying to get a CSRF response from Auth.js (eg.: by calling a `/csrf` endpoint),
595-
* but in this setup, CSRF protection via Auth.js was turned off. This is likely if you are not directly using `@auth/core`
596-
* but a framework library (like `@auth/sveltekit`) that already has CSRF protection built-in. You likely won't need the CSRF response.
597-
* - `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,
598-
* or remove the `pathname` of `AUTH_URL` (or `NEXTAUTH_URL`). Only one of them is needed.
599-
* - `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.
600-
* `@auth/core` will use `basePath` to construct the full URL to the corresponding action (/signin, /signout, etc.) in this case.
601-
* - `experimental-webauthn`: Experimental WebAuthn feature is enabled.
602-
*/
603-
export type WarningCode =
604-
| "debug-enabled"
605-
| "csrf-disabled"
606-
| "env-url-basepath-redundant"
607-
| "env-url-basepath-mismatch"
608-
| "experimental-webauthn"

packages/core/src/lib/utils/assert.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from "../../errors.js"
1616

1717
import type { RequestInternal, SemverString } from "../../types.js"
18-
import type { WarningCode } from "../../errors.js"
18+
import type { WarningCode } from "../../warnings.js"
1919
import { Adapter } from "../../adapters.js"
2020
import type { AuthConfig } from "../../index.js"
2121

packages/core/src/lib/utils/logger.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { AuthError, WarningCode } from "../../errors.js"
1+
import { AuthError } from "../../errors.js"
2+
import type { WarningCode } from "../../warnings.js"
23
import type { AuthConfig } from "../../index.js"
34

45
/**

packages/core/src/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import { AuthConfig } from "./index.js"
5858
import type { JWTOptions } from "./jwt.js"
5959
import type { Cookie } from "./lib/utils/cookie.js"
6060
import type { LoggerInstance } from "./lib/utils/logger.js"
61+
import type { WarningCode } from "./warnings.js"
6162
import type {
6263
CredentialsConfig,
6364
EmailConfig,
@@ -72,7 +73,7 @@ import type {
7273

7374
export type { WebAuthnOptionsResponseBody } from "./lib/utils/webauthn-utils.js"
7475
export type { AuthConfig } from "./index.js"
75-
export type { LoggerInstance }
76+
export type { LoggerInstance, WarningCode }
7677
export type Awaitable<T> = T | PromiseLike<T>
7778
export type Awaited<T> = T extends Promise<infer U> ? U : T
7879

packages/core/src/warnings.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* - `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.
14+
*
15+
*/
16+
export type WarningCode =
17+
| "debug-enabled"
18+
| "csrf-disabled"
19+
| "env-url-basepath-redundant"
20+
| "env-url-basepath-mismatch"
21+
| "experimental-webauthn"

turbo.json

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"build/**/*",
128128
"!.next/cache/**",
129129
"docs/reference/**/*.mdx",
130+
"docs/reference/**/*.js",
130131
"docs/reference/*.mdx"
131132
]
132133
}

0 commit comments

Comments
 (0)