diff options
Diffstat (limited to 'packages/server/src')
8 files changed, 31 insertions, 28 deletions
diff --git a/packages/server/src/authentication/verifyAuthenticationResponse.test.ts b/packages/server/src/authentication/verifyAuthenticationResponse.test.ts index 96cc4b5..dbaa946 100644 --- a/packages/server/src/authentication/verifyAuthenticationResponse.test.ts +++ b/packages/server/src/authentication/verifyAuthenticationResponse.test.ts @@ -336,7 +336,7 @@ test('should return authenticator extension output', async () => { } }); - expect(verification.authenticationInfo?.extensionsData).toMatchObject({ + expect(verification.authenticationInfo?.authenticatorExtensionResults).toMatchObject({ 'devicePublicKey': { 'dpk': Buffer.from('A5010203262001215820991AABED9DE4271A9EDEAD8806F9DC96D6DCCD0C476253A5510489EC8379BE5B225820A0973CFDEDBB79E27FEF4EE7481673FB3312504DDCA5434CFD23431D6AD29EDA', 'hex'), 'sig': Buffer.from('3045022049526CD28AEF6B4E621A7D5936D2B504952FC0AE2313A4F0357AAFFFAEA964740221009D513ACAEFB0B32C765AAE6FEBA8C294685EFF63FF1CBF11ECF2107AF4FEB8F8', 'hex'), diff --git a/packages/server/src/authentication/verifyAuthenticationResponse.ts b/packages/server/src/authentication/verifyAuthenticationResponse.ts index 341835c..8ee7f85 100644 --- a/packages/server/src/authentication/verifyAuthenticationResponse.ts +++ b/packages/server/src/authentication/verifyAuthenticationResponse.ts @@ -135,7 +135,7 @@ export default function verifyAuthenticationResponse( const authDataBuffer = base64url.toBuffer(response.authenticatorData); const parsedAuthData = parseAuthenticatorData(authDataBuffer); - const { rpIdHash, flags, counter, extensionsData } = parsedAuthData; + const { rpIdHash, flags, counter, authenticatorExtensionResults } = parsedAuthData; // Make sure the response's RP ID is ours if (typeof expectedRPID === 'string') { @@ -190,7 +190,7 @@ export default function verifyAuthenticationResponse( credentialID: authenticator.credentialID, credentialDeviceType, credentialBackedUp, - extensionsData + authenticatorExtensionResults }, }; @@ -220,6 +220,6 @@ export type VerifiedAuthenticationResponse = { newCounter: number; credentialDeviceType: CredentialDeviceType; credentialBackedUp: boolean; - extensionsData?: AuthenticationExtensionsAuthenticatorOutputs; + authenticatorExtensionResults?: AuthenticationExtensionsAuthenticatorOutputs; }; }; diff --git a/packages/server/src/helpers/decodeAuthenticatorExtensions.test.ts b/packages/server/src/helpers/decodeAuthenticatorExtensions.test.ts index b6af487..5c184a8 100644 --- a/packages/server/src/helpers/decodeAuthenticatorExtensions.test.ts +++ b/packages/server/src/helpers/decodeAuthenticatorExtensions.test.ts @@ -1,7 +1,7 @@ -import decodeAuthenticatorExtensionData from "./decodeAuthenticatorExtensions"; +import { decodeAuthenticatorExtensions } from "./decodeAuthenticatorExtensions"; test('should decode authenticator extensions', () => { - const extensions = decodeAuthenticatorExtensionData(Buffer.from( + const extensions = decodeAuthenticatorExtensions(Buffer.from( 'A16F6465766963655075626C69634B6579A56364706B584DA5010203262001215820991A' + 'ABED9DE4271A9EDEAD8806F9DC96D6DCCD0C476253A5510489EC8379BE5B225820A0973C' + 'FDEDBB79E27FEF4EE7481673FB3312504DDCA5434CFD23431D6AD29EDA63736967584730' + @@ -20,8 +20,3 @@ test('should decode authenticator extensions', () => { } }) }); - -test('should return undefined decoding authenticator extensions', () => { - const extensions = decodeAuthenticatorExtensionData(Buffer.from('A16F')); - expect(extensions).toEqual(undefined); -}); diff --git a/packages/server/src/helpers/decodeAuthenticatorExtensions.ts b/packages/server/src/helpers/decodeAuthenticatorExtensions.ts index 41a907d..a0dc5c2 100644 --- a/packages/server/src/helpers/decodeAuthenticatorExtensions.ts +++ b/packages/server/src/helpers/decodeAuthenticatorExtensions.ts @@ -5,7 +5,7 @@ import cbor from 'cbor'; * * @param extensionData Authenticator Extension Data buffer */ -export default function decodeAuthenticatorExtensionData( +export function decodeAuthenticatorExtensions( extensionData: Buffer ): AuthenticationExtensionsAuthenticatorOutputs | undefined { let toCBOR: AuthenticationExtensionsAuthenticatorOutputs | undefined; diff --git a/packages/server/src/helpers/parseAuthenticatorData.test.ts b/packages/server/src/helpers/parseAuthenticatorData.test.ts index e199898..bc86969 100644 --- a/packages/server/src/helpers/parseAuthenticatorData.test.ts +++ b/packages/server/src/helpers/parseAuthenticatorData.test.ts @@ -43,10 +43,10 @@ test('should parse extension data', () => { const parsed = parseAuthenticatorData(authDataWithED); - const { extensionsData } = parsed; + const { authenticatorExtensionResults } = parsed; - if (extensionsData) { - expect(extensionsData).toEqual({ + if (authenticatorExtensionResults) { + expect(authenticatorExtensionResults).toEqual({ 'example.extension': 'This is an example extension! If you read this message, you probably successfully passing conformance tests. Good job!', }); diff --git a/packages/server/src/helpers/parseAuthenticatorData.ts b/packages/server/src/helpers/parseAuthenticatorData.ts index 439070d..c092e68 100644 --- a/packages/server/src/helpers/parseAuthenticatorData.ts +++ b/packages/server/src/helpers/parseAuthenticatorData.ts @@ -1,6 +1,6 @@ import cbor from 'cbor'; import { decodeCborFirst } from './decodeCbor'; -import decodeAuthenticatorExtensionData, { AuthenticationExtensionsAuthenticatorOutputs } from './decodeAuthenticatorExtensions'; +import { decodeAuthenticatorExtensions, AuthenticationExtensionsAuthenticatorOutputs } from './decodeAuthenticatorExtensions'; /** * Make sense of the authData buffer contained in an Attestation @@ -53,14 +53,14 @@ export default function parseAuthenticatorData(authData: Buffer): ParsedAuthenti pointer += firstEncoded.byteLength; } - let extensionsData: AuthenticationExtensionsAuthenticatorOutputs | undefined = undefined; - let extensionsDataBuffer: Buffer | undefined = undefined; + let authenticatorExtensionResults: AuthenticationExtensionsAuthenticatorOutputs | undefined = undefined; + let authenticatorExtensionsDataBuffer: Buffer | undefined = undefined; if (flags.ed) { const firstDecoded = decodeCborFirst(authData.slice(pointer)); const firstEncoded = Buffer.from(cbor.encode(firstDecoded) as ArrayBuffer); - extensionsDataBuffer = firstEncoded; - extensionsData = decodeAuthenticatorExtensionData(extensionsDataBuffer); + authenticatorExtensionsDataBuffer = firstEncoded; + authenticatorExtensionResults = decodeAuthenticatorExtensions(authenticatorExtensionsDataBuffer); pointer += firstEncoded.byteLength; } @@ -78,8 +78,8 @@ export default function parseAuthenticatorData(authData: Buffer): ParsedAuthenti aaguid, credentialID, credentialPublicKey, - extensionsData, - extensionsDataBuffer + authenticatorExtensionResults, + authenticatorExtensionsDataBuffer }; } @@ -100,6 +100,6 @@ export type ParsedAuthenticatorData = { aaguid?: Buffer; credentialID?: Buffer; credentialPublicKey?: Buffer; - extensionsData?: AuthenticationExtensionsAuthenticatorOutputs; - extensionsDataBuffer?: Buffer; + authenticatorExtensionResults?: AuthenticationExtensionsAuthenticatorOutputs; + authenticatorExtensionsDataBuffer?: Buffer; }; diff --git a/packages/server/src/registration/verifyRegistrationResponse.test.ts b/packages/server/src/registration/verifyRegistrationResponse.test.ts index 4a966b5..d4c4f20 100644 --- a/packages/server/src/registration/verifyRegistrationResponse.test.ts +++ b/packages/server/src/registration/verifyRegistrationResponse.test.ts @@ -607,7 +607,7 @@ test('should return authenticator extension output', async () => { expectedRPID: 'try-webauthn.appspot.com', }); - expect(verification.registrationInfo?.extensionsData).toMatchObject({ + expect(verification.registrationInfo?.authenticatorExtensionResults).toMatchObject({ 'devicePublicKey': { "dpk": Buffer.from('A5010203262001215820991AABED9DE4271A9EDEAD8806F9DC96D6DCCD0C476253A5510489EC8379BE5B225820A0973CFDEDBB79E27FEF4EE7481673FB3312504DDCA5434CFD23431D6AD29EDA', 'hex'), "sig": Buffer.from('3045022100EFB38074BD15B8C82CF09F87FBC6FB3C7169EA4F1806B7E90937374302345B7A02202B7113040731A0E727D338D48542863CE65880AA79E5EA740AC8CCD94347988E', 'hex'), diff --git a/packages/server/src/registration/verifyRegistrationResponse.ts b/packages/server/src/registration/verifyRegistrationResponse.ts index 2377ea4..78228ef 100644 --- a/packages/server/src/registration/verifyRegistrationResponse.ts +++ b/packages/server/src/registration/verifyRegistrationResponse.ts @@ -133,7 +133,15 @@ export default async function verifyRegistrationResponse( const { fmt, authData, attStmt } = decodedAttestationObject; const parsedAuthData = parseAuthenticatorData(authData); - const { aaguid, rpIdHash, flags, credentialID, counter, credentialPublicKey, extensionsData } = parsedAuthData; + const { + aaguid, + rpIdHash, + flags, + credentialID, + counter, + credentialPublicKey, + authenticatorExtensionResults + } = parsedAuthData; // Make sure the response's RP ID is ours if (expectedRPID) { @@ -249,7 +257,7 @@ export default async function verifyRegistrationResponse( userVerified: flags.uv, credentialDeviceType, credentialBackedUp, - extensionsData, + authenticatorExtensionResults, }; } @@ -291,7 +299,7 @@ export type VerifiedRegistrationResponse = { userVerified: boolean; credentialDeviceType: CredentialDeviceType; credentialBackedUp: boolean; - extensionsData?: AuthenticationExtensionsAuthenticatorOutputs; + authenticatorExtensionResults?: AuthenticationExtensionsAuthenticatorOutputs; }; }; |