Skip to content

Commit aefae63

Browse files
authored
chore(core): remove extra dot in some AuthError messages (#10964)
1 parent e87a0b6 commit aefae63

File tree

6 files changed

+27
-29
lines changed

6 files changed

+27
-29
lines changed

packages/core/src/lib/actions/callback/oauth/checks.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const pkce = {
7474
const codeVerifier = cookies?.[options.cookies.pkceCodeVerifier.name]
7575

7676
if (!codeVerifier)
77-
throw new InvalidCheck("PKCE code_verifier cookie was missing.")
77+
throw new InvalidCheck("PKCE code_verifier cookie was missing")
7878

7979
const value = await decode<CheckPayload>({
8080
...options.jwt,
@@ -83,7 +83,7 @@ export const pkce = {
8383
})
8484

8585
if (!value?.value)
86-
throw new InvalidCheck("PKCE code_verifier value could not be parsed.")
86+
throw new InvalidCheck("PKCE code_verifier value could not be parsed")
8787

8888
// Clear the pkce code verifier cookie after use
8989
resCookies.push({
@@ -117,7 +117,7 @@ export const state = {
117117
if (!provider.checks.includes("state")) {
118118
if (data) {
119119
throw new InvalidCheck(
120-
"State data was provided but the provider is not configured to use state."
120+
"State data was provided but the provider is not configured to use state"
121121
)
122122
}
123123
return
@@ -155,7 +155,7 @@ export const state = {
155155

156156
const state = cookies?.[options.cookies.state.name]
157157

158-
if (!state) throw new InvalidCheck("State cookie was missing.")
158+
if (!state) throw new InvalidCheck("State cookie was missing")
159159

160160
// IDEA: Let the user do something with the returned state
161161
const encodedState = await decode<CheckPayload>({
@@ -165,12 +165,12 @@ export const state = {
165165
})
166166

167167
if (!encodedState?.value)
168-
throw new InvalidCheck("State (cookie) value could not be parsed.")
168+
throw new InvalidCheck("State (cookie) value could not be parsed")
169169

170170
const decodedState = decodeState(encodedState.value)
171171

172172
if (!decodedState)
173-
throw new InvalidCheck("State (encoded) value could not be parsed.")
173+
throw new InvalidCheck("State (encoded) value could not be parsed")
174174

175175
if (decodedState.random !== paramRandom)
176176
throw new InvalidCheck(
@@ -214,16 +214,15 @@ export const nonce = {
214214
if (!provider?.checks?.includes("nonce")) return
215215

216216
const nonce = cookies?.[options.cookies.nonce.name]
217-
if (!nonce) throw new InvalidCheck("Nonce cookie was missing.")
217+
if (!nonce) throw new InvalidCheck("Nonce cookie was missing")
218218

219219
const value = await decode<CheckPayload>({
220220
...options.jwt,
221221
token: nonce,
222222
salt: options.cookies.nonce.name,
223223
})
224224

225-
if (!value?.value)
226-
throw new InvalidCheck("Nonce value could not be parsed.")
225+
if (!value?.value) throw new InvalidCheck("Nonce value could not be parsed")
227226

228227
// Clear the nonce cookie after use
229228
resCookies.push({
@@ -294,7 +293,7 @@ export const webauthnChallenge = {
294293
): Promise<WebAuthnChallengeCookie> {
295294
const challenge = cookies?.[options.cookies.webauthnChallenge.name]
296295

297-
if (!challenge) throw new InvalidCheck("Challenge cookie missing.")
296+
if (!challenge) throw new InvalidCheck("Challenge cookie missing")
298297

299298
const value = await decode<CheckPayload>({
300299
...options.jwt,
@@ -303,7 +302,7 @@ export const webauthnChallenge = {
303302
})
304303

305304
if (!value?.value)
306-
throw new InvalidCheck("Challenge value could not be parsed.")
305+
throw new InvalidCheck("Challenge value could not be parsed")
307306

308307
// Clear the pkce code verifier cookie after use
309308
const cookie = {

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function assertConfig(
9898
}
9999

100100
if (!options.secret?.length) {
101-
return new MissingSecret("Please define a `secret`.")
101+
return new MissingSecret("Please define a `secret`")
102102
}
103103

104104
const callbackUrlParam = request.query?.callbackUrl as string | undefined
@@ -141,7 +141,7 @@ export function assertConfig(
141141

142142
if (key) {
143143
return new InvalidEndpoints(
144-
`Provider "${provider.id}" is missing both \`issuer\` and \`${key}\` endpoint config. At least one of them is required.`
144+
`Provider "${provider.id}" is missing both \`issuer\` and \`${key}\` endpoint config. At least one of them is required`
145145
)
146146
}
147147
}
@@ -165,7 +165,7 @@ export function assertConfig(
165165
// Make sure only one webauthn provider has "enableConditionalUI" set to true
166166
if (hasConditionalUIProvider) {
167167
return new DuplicateConditionalUI(
168-
`Multiple webauthn providers have 'enableConditionalUI' set to True. Only one provider can have this option enabled at a time.`
168+
`Multiple webauthn providers have 'enableConditionalUI' set to True. Only one provider can have this option enabled at a time`
169169
)
170170
}
171171
hasConditionalUIProvider = true
@@ -177,7 +177,7 @@ export function assertConfig(
177177
)
178178
if (!hasWebauthnFormField) {
179179
return new MissingWebAuthnAutocomplete(
180-
`Provider "${provider.id}" has 'enableConditionalUI' set to True, but none of its formFields have 'webauthn' in their autocomplete param.`
180+
`Provider "${provider.id}" has 'enableConditionalUI' set to True, but none of its formFields have 'webauthn' in their autocomplete param`
181181
)
182182
}
183183
}
@@ -216,12 +216,11 @@ export function assertConfig(
216216
(!session?.strategy && adapter)
217217
) {
218218
if (hasEmail) {
219-
if (!adapter)
220-
return new MissingAdapter("Email login requires an adapter.")
219+
if (!adapter) return new MissingAdapter("Email login requires an adapter")
221220
requiredMethods.push(...emailMethods)
222221
} else {
223222
if (!adapter)
224-
return new MissingAdapter("Database session requires an adapter.")
223+
return new MissingAdapter("Database session requires an adapter")
225224
requiredMethods.push(...sessionMethods)
226225
}
227226
}
@@ -232,11 +231,11 @@ export function assertConfig(
232231
warnings.push("experimental-webauthn")
233232
} else {
234233
return new ExperimentalFeatureNotEnabled(
235-
"WebAuthn is an experimental feature. To enable it, set `experimental.enableWebAuthn` to `true` in your config."
234+
"WebAuthn is an experimental feature. To enable it, set `experimental.enableWebAuthn` to `true` in your config"
236235
)
237236
}
238237

239-
if (!adapter) return new MissingAdapter("WebAuthn requires an adapter.")
238+
if (!adapter) return new MissingAdapter("WebAuthn requires an adapter")
240239
requiredMethods.push(...webauthnMethods)
241240
}
242241

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function toInternalRequest(
2828
): Promise<RequestInternal | undefined> {
2929
try {
3030
if (req.method !== "GET" && req.method !== "POST")
31-
throw new UnknownAction("Only GET and POST requests are supported.")
31+
throw new UnknownAction("Only GET and POST requests are supported")
3232

3333
// Defaults are usually set in the `init` function, but this is needed below
3434
config.basePath ??= "/auth"

packages/core/src/lib/utils/webauthn-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export async function verifyAuthenticate(
262262
// Make sure the response was verified
263263
if (!verified) {
264264
throw new WebAuthnVerificationError(
265-
"WebAuthn authentication response could not be verified."
265+
"WebAuthn authentication response could not be verified"
266266
)
267267
}
268268

packages/core/src/providers/webauthn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ const getUserInfo: GetUserInfo = async (options, request) => {
241241
const { adapter } = options
242242
if (!adapter)
243243
throw new MissingAdapter(
244-
"WebAuthn provider requires a database adapter to be configured."
244+
"WebAuthn provider requires a database adapter to be configured"
245245
)
246246

247247
// Get email address from the query.

packages/core/test/assert-config.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("Assert user config correctness", () => {
2929
"There was a problem with the server configuration. Check the server logs for more information.",
3030
})
3131
expect(logger?.error).toHaveBeenCalledWith(
32-
new MissingSecret("Please define a `secret`.")
32+
new MissingSecret("Please define a `secret`")
3333
)
3434
})
3535

@@ -92,11 +92,11 @@ describe("Assert user config correctness", () => {
9292
it.each<[Provider, string]>([
9393
[
9494
() => ({ type: "oidc", id: "provider-id", name: "" }),
95-
'Provider "provider-id" is missing both `issuer` and `authorization` endpoint config. At least one of them is required.',
95+
'Provider "provider-id" is missing both `issuer` and `authorization` endpoint config. At least one of them is required',
9696
],
9797
[
9898
{ type: "oidc", id: "provider-id", name: "" },
99-
'Provider "provider-id" is missing both `issuer` and `authorization` endpoint config. At least one of them is required.',
99+
'Provider "provider-id" is missing both `issuer` and `authorization` endpoint config. At least one of them is required',
100100
],
101101
[
102102
{
@@ -105,7 +105,7 @@ describe("Assert user config correctness", () => {
105105
id: "provider-id",
106106
name: "",
107107
},
108-
'Provider "provider-id" is missing both `issuer` and `token` endpoint config. At least one of them is required.',
108+
'Provider "provider-id" is missing both `issuer` and `token` endpoint config. At least one of them is required',
109109
],
110110
[
111111
{
@@ -115,7 +115,7 @@ describe("Assert user config correctness", () => {
115115
id: "provider-id",
116116
name: "",
117117
},
118-
'Provider "provider-id" is missing both `issuer` and `userinfo` endpoint config. At least one of them is required.',
118+
'Provider "provider-id" is missing both `issuer` and `userinfo` endpoint config. At least one of them is required',
119119
],
120120
[
121121
{
@@ -127,7 +127,7 @@ describe("Assert user config correctness", () => {
127127
id: "oauth-provider",
128128
name: "",
129129
},
130-
'Provider "oauth-provider" is missing both `issuer` and `userinfo` endpoint config. At least one of them is required.',
130+
'Provider "oauth-provider" is missing both `issuer` and `userinfo` endpoint config. At least one of them is required',
131131
],
132132
])("OAuth/OIDC: invalid endpoints %j", async (provider, error) => {
133133
const { response, logger } = await makeAuthRequest({

0 commit comments

Comments
 (0)