diff --git a/packages/core/src/lib/actions/callback/oauth/checks.ts b/packages/core/src/lib/actions/callback/oauth/checks.ts index 9269ab1224..e10a1542c4 100644 --- a/packages/core/src/lib/actions/callback/oauth/checks.ts +++ b/packages/core/src/lib/actions/callback/oauth/checks.ts @@ -74,7 +74,7 @@ export const pkce = { const codeVerifier = cookies?.[options.cookies.pkceCodeVerifier.name] if (!codeVerifier) - throw new InvalidCheck("PKCE code_verifier cookie was missing.") + throw new InvalidCheck("PKCE code_verifier cookie was missing") const value = await decode({ ...options.jwt, @@ -83,7 +83,7 @@ export const pkce = { }) if (!value?.value) - throw new InvalidCheck("PKCE code_verifier value could not be parsed.") + throw new InvalidCheck("PKCE code_verifier value could not be parsed") // Clear the pkce code verifier cookie after use resCookies.push({ @@ -117,7 +117,7 @@ export const state = { if (!provider.checks.includes("state")) { if (data) { throw new InvalidCheck( - "State data was provided but the provider is not configured to use state." + "State data was provided but the provider is not configured to use state" ) } return @@ -155,7 +155,7 @@ export const state = { const state = cookies?.[options.cookies.state.name] - if (!state) throw new InvalidCheck("State cookie was missing.") + if (!state) throw new InvalidCheck("State cookie was missing") // IDEA: Let the user do something with the returned state const encodedState = await decode({ @@ -165,12 +165,12 @@ export const state = { }) if (!encodedState?.value) - throw new InvalidCheck("State (cookie) value could not be parsed.") + throw new InvalidCheck("State (cookie) value could not be parsed") const decodedState = decodeState(encodedState.value) if (!decodedState) - throw new InvalidCheck("State (encoded) value could not be parsed.") + throw new InvalidCheck("State (encoded) value could not be parsed") if (decodedState.random !== paramRandom) throw new InvalidCheck( @@ -214,7 +214,7 @@ export const nonce = { if (!provider?.checks?.includes("nonce")) return const nonce = cookies?.[options.cookies.nonce.name] - if (!nonce) throw new InvalidCheck("Nonce cookie was missing.") + if (!nonce) throw new InvalidCheck("Nonce cookie was missing") const value = await decode({ ...options.jwt, @@ -222,8 +222,7 @@ export const nonce = { salt: options.cookies.nonce.name, }) - if (!value?.value) - throw new InvalidCheck("Nonce value could not be parsed.") + if (!value?.value) throw new InvalidCheck("Nonce value could not be parsed") // Clear the nonce cookie after use resCookies.push({ @@ -294,7 +293,7 @@ export const webauthnChallenge = { ): Promise { const challenge = cookies?.[options.cookies.webauthnChallenge.name] - if (!challenge) throw new InvalidCheck("Challenge cookie missing.") + if (!challenge) throw new InvalidCheck("Challenge cookie missing") const value = await decode({ ...options.jwt, @@ -303,7 +302,7 @@ export const webauthnChallenge = { }) if (!value?.value) - throw new InvalidCheck("Challenge value could not be parsed.") + throw new InvalidCheck("Challenge value could not be parsed") // Clear the pkce code verifier cookie after use const cookie = { diff --git a/packages/core/src/lib/utils/assert.ts b/packages/core/src/lib/utils/assert.ts index d4ae83be35..919741a144 100644 --- a/packages/core/src/lib/utils/assert.ts +++ b/packages/core/src/lib/utils/assert.ts @@ -98,7 +98,7 @@ export function assertConfig( } if (!options.secret?.length) { - return new MissingSecret("Please define a `secret`.") + return new MissingSecret("Please define a `secret`") } const callbackUrlParam = request.query?.callbackUrl as string | undefined @@ -141,7 +141,7 @@ export function assertConfig( if (key) { return new InvalidEndpoints( - `Provider "${provider.id}" is missing both \`issuer\` and \`${key}\` endpoint config. At least one of them is required.` + `Provider "${provider.id}" is missing both \`issuer\` and \`${key}\` endpoint config. At least one of them is required` ) } } @@ -165,7 +165,7 @@ export function assertConfig( // Make sure only one webauthn provider has "enableConditionalUI" set to true if (hasConditionalUIProvider) { return new DuplicateConditionalUI( - `Multiple webauthn providers have 'enableConditionalUI' set to True. Only one provider can have this option enabled at a time.` + `Multiple webauthn providers have 'enableConditionalUI' set to True. Only one provider can have this option enabled at a time` ) } hasConditionalUIProvider = true @@ -177,7 +177,7 @@ export function assertConfig( ) if (!hasWebauthnFormField) { return new MissingWebAuthnAutocomplete( - `Provider "${provider.id}" has 'enableConditionalUI' set to True, but none of its formFields have 'webauthn' in their autocomplete param.` + `Provider "${provider.id}" has 'enableConditionalUI' set to True, but none of its formFields have 'webauthn' in their autocomplete param` ) } } @@ -216,12 +216,11 @@ export function assertConfig( (!session?.strategy && adapter) ) { if (hasEmail) { - if (!adapter) - return new MissingAdapter("Email login requires an adapter.") + if (!adapter) return new MissingAdapter("Email login requires an adapter") requiredMethods.push(...emailMethods) } else { if (!adapter) - return new MissingAdapter("Database session requires an adapter.") + return new MissingAdapter("Database session requires an adapter") requiredMethods.push(...sessionMethods) } } @@ -232,11 +231,11 @@ export function assertConfig( warnings.push("experimental-webauthn") } else { return new ExperimentalFeatureNotEnabled( - "WebAuthn is an experimental feature. To enable it, set `experimental.enableWebAuthn` to `true` in your config." + "WebAuthn is an experimental feature. To enable it, set `experimental.enableWebAuthn` to `true` in your config" ) } - if (!adapter) return new MissingAdapter("WebAuthn requires an adapter.") + if (!adapter) return new MissingAdapter("WebAuthn requires an adapter") requiredMethods.push(...webauthnMethods) } diff --git a/packages/core/src/lib/utils/web.ts b/packages/core/src/lib/utils/web.ts index 42fd2b7168..41e341d7de 100644 --- a/packages/core/src/lib/utils/web.ts +++ b/packages/core/src/lib/utils/web.ts @@ -28,7 +28,7 @@ export async function toInternalRequest( ): Promise { try { if (req.method !== "GET" && req.method !== "POST") - throw new UnknownAction("Only GET and POST requests are supported.") + throw new UnknownAction("Only GET and POST requests are supported") // Defaults are usually set in the `init` function, but this is needed below config.basePath ??= "/auth" diff --git a/packages/core/src/lib/utils/webauthn-utils.ts b/packages/core/src/lib/utils/webauthn-utils.ts index eaa3b0febb..6a1a601d03 100644 --- a/packages/core/src/lib/utils/webauthn-utils.ts +++ b/packages/core/src/lib/utils/webauthn-utils.ts @@ -262,7 +262,7 @@ export async function verifyAuthenticate( // Make sure the response was verified if (!verified) { throw new WebAuthnVerificationError( - "WebAuthn authentication response could not be verified." + "WebAuthn authentication response could not be verified" ) } diff --git a/packages/core/src/providers/webauthn.ts b/packages/core/src/providers/webauthn.ts index f0e66f6b4a..2cbc56bd38 100644 --- a/packages/core/src/providers/webauthn.ts +++ b/packages/core/src/providers/webauthn.ts @@ -241,7 +241,7 @@ const getUserInfo: GetUserInfo = async (options, request) => { const { adapter } = options if (!adapter) throw new MissingAdapter( - "WebAuthn provider requires a database adapter to be configured." + "WebAuthn provider requires a database adapter to be configured" ) // Get email address from the query. diff --git a/packages/core/test/assert-config.test.ts b/packages/core/test/assert-config.test.ts index b1f338f6ce..3667db2709 100644 --- a/packages/core/test/assert-config.test.ts +++ b/packages/core/test/assert-config.test.ts @@ -29,7 +29,7 @@ describe("Assert user config correctness", () => { "There was a problem with the server configuration. Check the server logs for more information.", }) expect(logger?.error).toHaveBeenCalledWith( - new MissingSecret("Please define a `secret`.") + new MissingSecret("Please define a `secret`") ) }) @@ -92,11 +92,11 @@ describe("Assert user config correctness", () => { it.each<[Provider, string]>([ [ () => ({ type: "oidc", id: "provider-id", name: "" }), - 'Provider "provider-id" is missing both `issuer` and `authorization` endpoint config. At least one of them is required.', + 'Provider "provider-id" is missing both `issuer` and `authorization` endpoint config. At least one of them is required', ], [ { type: "oidc", id: "provider-id", name: "" }, - 'Provider "provider-id" is missing both `issuer` and `authorization` endpoint config. At least one of them is required.', + 'Provider "provider-id" is missing both `issuer` and `authorization` endpoint config. At least one of them is required', ], [ { @@ -105,7 +105,7 @@ describe("Assert user config correctness", () => { id: "provider-id", name: "", }, - 'Provider "provider-id" is missing both `issuer` and `token` endpoint config. At least one of them is required.', + 'Provider "provider-id" is missing both `issuer` and `token` endpoint config. At least one of them is required', ], [ { @@ -115,7 +115,7 @@ describe("Assert user config correctness", () => { id: "provider-id", name: "", }, - 'Provider "provider-id" is missing both `issuer` and `userinfo` endpoint config. At least one of them is required.', + 'Provider "provider-id" is missing both `issuer` and `userinfo` endpoint config. At least one of them is required', ], [ { @@ -127,7 +127,7 @@ describe("Assert user config correctness", () => { id: "oauth-provider", name: "", }, - 'Provider "oauth-provider" is missing both `issuer` and `userinfo` endpoint config. At least one of them is required.', + 'Provider "oauth-provider" is missing both `issuer` and `userinfo` endpoint config. At least one of them is required', ], ])("OAuth/OIDC: invalid endpoints %j", async (provider, error) => { const { response, logger } = await makeAuthRequest({