summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/authentication/verifyAuthenticationResponse.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2024-02-24 16:45:51 -0800
committerGitHub <noreply@github.com>2024-02-24 16:45:51 -0800
commit6eb5ac62e778c6c39c936cfce3309b9aa852021d (patch)
tree1d33f0a5ea58d74d0b41e6cc407ef604d76c399e /packages/server/src/authentication/verifyAuthenticationResponse.ts
parentfe2245b9c1b7ada2099a6411c8ce2e6e6f18bbf9 (diff)
parentb835ce41e1936765a49d7f7114116d78ddb67a1c (diff)
Merge pull request #529 from MasterKale/fix/528-simplify-use-of-credential-id
fix/528-simplify-use-of-credential-id
Diffstat (limited to 'packages/server/src/authentication/verifyAuthenticationResponse.ts')
-rw-r--r--packages/server/src/authentication/verifyAuthenticationResponse.ts15
1 files changed, 10 insertions, 5 deletions
diff --git a/packages/server/src/authentication/verifyAuthenticationResponse.ts b/packages/server/src/authentication/verifyAuthenticationResponse.ts
index c938598..c6430c0 100644
--- a/packages/server/src/authentication/verifyAuthenticationResponse.ts
+++ b/packages/server/src/authentication/verifyAuthenticationResponse.ts
@@ -1,6 +1,7 @@
import type {
AuthenticationResponseJSON,
AuthenticatorDevice,
+ Base64URLString,
CredentialDeviceType,
UserVerificationRequirement,
} from '../deps.ts';
@@ -94,11 +95,15 @@ export async function verifyAuthenticationResponse(
if (Array.isArray(expectedType)) {
if (!expectedType.includes(type)) {
const joinedExpectedType = expectedType.join(', ');
- throw new Error(`Unexpected authentication response type "${type}", expected one of: ${joinedExpectedType}`);
+ throw new Error(
+ `Unexpected authentication response type "${type}", expected one of: ${joinedExpectedType}`,
+ );
}
} else if (expectedType) {
if (type !== expectedType) {
- throw new Error(`Unexpected authentication response type "${type}", expected "${expectedType}"`);
+ throw new Error(
+ `Unexpected authentication response type "${type}", expected "${expectedType}"`,
+ );
}
} else if (type !== 'webauthn.get') {
throw new Error(`Unexpected authentication response type: ${type}`);
@@ -133,13 +138,13 @@ export async function verifyAuthenticationResponse(
}
}
- if (!isoBase64URL.isBase64url(assertionResponse.authenticatorData)) {
+ if (!isoBase64URL.isBase64URL(assertionResponse.authenticatorData)) {
throw new Error(
'Credential response authenticatorData was not a base64url string',
);
}
- if (!isoBase64URL.isBase64url(assertionResponse.signature)) {
+ if (!isoBase64URL.isBase64URL(assertionResponse.signature)) {
throw new Error('Credential response signature was not a base64url string');
}
@@ -280,7 +285,7 @@ export async function verifyAuthenticationResponse(
export type VerifiedAuthenticationResponse = {
verified: boolean;
authenticationInfo: {
- credentialID: Uint8Array;
+ credentialID: Base64URLString;
newCounter: number;
userVerified: boolean;
credentialDeviceType: CredentialDeviceType;