Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrliu committed Apr 30, 2023
1 parent 35f2014 commit ef09b6e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions apps/consumer-client/pages/examples/add-pcd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async function addIdentityPCD() {
}

async function addWebAuthnPCD() {
// Generate a new WebAuthn credential
// Register a new WebAuthn credential for testing.
const generatedRegistrationOptions = await generateRegistrationOptions({
rpName: "consumer-client",
rpID: window.location.hostname,
Expand All @@ -179,31 +179,36 @@ async function addWebAuthnPCD() {
response: startRegistrationResponse,
expectedOrigin: window.location.origin,
expectedChallenge: generatedRegistrationOptions.challenge,
supportedAlgorithmIDs: [-7],
supportedAlgorithmIDs: [-7], // support ES256 signing algorithm
});

if (!verificationResponse.registrationInfo) {
throw new Error("Registration failed the return correct response.");
}

// Get relevant credential arguments from registration response.
const { credentialID, credentialPublicKey, counter } =
verificationResponse.registrationInfo;

// Create new WebAuthn PCD. This process initiates the WebAuth
// authentication ceremony, prompting a authorization gesture like
// a fingerprint or Face ID scan, depending on the device.
const newCredential = await WebAuthnPCDPackage.prove({
rpID: window.location.hostname,
authenticator: {
credentialID,
credentialPublicKey,
counter,
},
challenge: "1",
challenge: "1", // arbitrary challenge to be signed
origin: window.location.origin,
});

const serializedNewCredential = await WebAuthnPCDPackage.serialize(
newCredential
);

// Add new WebAuthn PCD to Passport.
const url = constructPassportPcdAddRequestUrl(
PASSPORT_URL,
window.location.origin + "/popup",
Expand Down

0 comments on commit ef09b6e

Please sign in to comment.