Skip to content
This repository was archived by the owner on Jul 25, 2021. It is now read-only.

Commit 35d0d7d

Browse files
committed
Create client extension output during credential creation
1 parent 6aa4a47 commit 35d0d7d

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/background.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const createCredential = async (msg, sender: chrome.runtime.MessageSender) => {
5555
);
5656
return {
5757
credential: webauthnStringify(credential),
58+
clientExtensionResults: credential.getClientExtensionResults(),
5859
requestID: msg.requestID,
5960
type: 'create_credential_response',
6061
};

src/inject_webauthn.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const log = getLogger('inject_webauthn');
2525
const webauthnResponse = await cb;
2626
// Because "options" contains functions we must stringify it, otherwise object cloning is illegal.
2727
const credential = webauthnParse(webauthnResponse.resp.credential);
28-
credential.getClientExtensionResults = () => ({}); // ToDo Return actual client extension result
28+
credential.getClientExtensionResults = () => (webauthnResponse.resp.clientExtensionResults);
29+
// extension result
2930
credential.__proto__ = window['PublicKeyCredential'].prototype;
3031
return credential;
3132
};

src/webauthn_client.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function createPublicKeyCredential(origin: string, options: Credent
2222
options.publicKey.rp.id = options.publicKey.rp.id || getDomainFromOrigin(origin);
2323

2424
// Step 11
25-
const clientExtensions = undefined; // ToDo clientExtensions
25+
let clientExtensions = undefined;
2626
let authenticatorExtensions = undefined;
2727
if (options.publicKey.extensions) {
2828
const reqExt: any = options.publicKey.extensions;
@@ -32,6 +32,7 @@ export async function createPublicKeyCredential(origin: string, options: Credent
3232
log.debug('PSK extension has valid client input');
3333
const authenticatorExtensionInput = new Uint8Array(CBOR.encodeCanonical(null));
3434
authenticatorExtensions = new Map([[PSK_EXTENSION_IDENTIFIER, byteArrayToBase64(authenticatorExtensionInput, true)]]);
35+
clientExtensions = {[PSK_EXTENSION_IDENTIFIER]: true};
3536
}
3637
}
3738
}
@@ -66,7 +67,7 @@ export async function createPublicKeyCredential(origin: string, options: Credent
6667
log.debug('Received attestation object');
6768

6869
return {
69-
getClientExtensionResults: () => ({}),
70+
getClientExtensionResults: () => (clientExtensions),
7071
id: attObjWrapper.credentialId,
7172
rawId: base64ToByteArray(attObjWrapper.credentialId, true),
7273
response: {
@@ -87,7 +88,7 @@ export async function getPublicKeyCredential(origin: string, options: Credential
8788
const rpID = options.publicKey.rpId || getDomainFromOrigin(origin);
8889

8990
// Step 8 + 9
90-
// ToDo Each authenticator extension is an client extension!
91+
// ToDo Authenticator Extension
9192

9293
// Step 10 + 11
9394
const clientDataJSON = generateClientDataJSON(Get, options.publicKey.challenge as ArrayBuffer, origin);

0 commit comments

Comments
 (0)