From 047413af015302639a1bd23934d9eb23fcbec169 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Tue, 2 Jun 2020 13:17:18 -0700 Subject: Explicitly define id and type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It turns out that properties on PublicKeyCredentials are non-enumerable getters, so the spread operator won’t pick them up. This means we need to manually re-construct attestation and assertion credentials when we convert them to JSON. --- packages/browser/src/methods/startAssertion.ts | 6 +++--- packages/browser/src/methods/startAttestation.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'packages/browser/src') diff --git a/packages/browser/src/methods/startAssertion.ts b/packages/browser/src/methods/startAssertion.ts index 81cad60..b65325b 100644 --- a/packages/browser/src/methods/startAssertion.ts +++ b/packages/browser/src/methods/startAssertion.ts @@ -37,7 +37,7 @@ export default async function startAssertion( throw new Error('Assertion was not completed'); } - const { rawId, response } = credential; + const { id, rawId, response, type } = credential; let userHandle = undefined; if (response.userHandle) { @@ -46,14 +46,14 @@ export default async function startAssertion( // Convert values to base64 to make it easier to send back to the server return { - ...credential, + id, rawId: bufferToBase64URLString(rawId), response: { - ...response, authenticatorData: bufferToBase64URLString(response.authenticatorData), clientDataJSON: bufferToBase64URLString(response.clientDataJSON), signature: bufferToBase64URLString(response.signature), userHandle, }, + type, }; } diff --git a/packages/browser/src/methods/startAttestation.ts b/packages/browser/src/methods/startAttestation.ts index 1612961..d5e540f 100644 --- a/packages/browser/src/methods/startAttestation.ts +++ b/packages/browser/src/methods/startAttestation.ts @@ -41,16 +41,16 @@ export default async function startAttestation( throw new Error('Attestation was not completed'); } - const { rawId, response } = credential; + const { id, rawId, response, type } = credential; // Convert values to base64 to make it easier to send back to the server return { - ...credential, + id, rawId: bufferToBase64URLString(rawId), response: { - ...response, attestationObject: bufferToBase64URLString(response.attestationObject), clientDataJSON: bufferToBase64URLString(response.clientDataJSON), }, + type, }; } -- cgit v1.2.3