summaryrefslogtreecommitdiffhomepage
path: root/example/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'example/index.ts')
-rw-r--r--example/index.ts26
1 files changed, 15 insertions, 11 deletions
diff --git a/example/index.ts b/example/index.ts
index 631a0ee..6667fcd 100644
--- a/example/index.ts
+++ b/example/index.ts
@@ -21,12 +21,16 @@ import {
// Login ("Assertion")
generateAssertionOptions,
verifyAssertionResponse,
+ GenerateAttestationOptionsOpts,
+ VerifyAttestationResponseOptions,
+ VerifiedAttestation,
} from '@simplewebauthn/server';
import type {
AttestationCredentialJSON,
AssertionCredentialJSON,
AuthenticatorDevice,
+ PublicKeyCredentialCreationOptionsJSON,
} from '@simplewebauthn/typescript-types';
import { LoggedInUser } from './example-server';
@@ -95,8 +99,7 @@ app.get('/generate-attestation-options', (req, res) => {
username,
devices,
} = user;
-
- const options = generateAttestationOptions({
+ const attesOptions: GenerateAttestationOptionsOpts = {
rpName: 'SimpleWebAuthn Example',
rpID,
userID: loggedInUserId,
@@ -122,7 +125,8 @@ app.get('/generate-attestation-options', (req, res) => {
userVerification: 'preferred',
requireResidentKey: false,
},
- });
+ };
+ const options: PublicKeyCredentialCreationOptionsJSON = generateAttestationOptions(attesOptions);
/**
* The server needs to temporarily remember this value for verification, so don't lose it until
@@ -139,15 +143,15 @@ app.post('/verify-attestation', async (req, res) => {
const user = inMemoryUserDeviceDB[loggedInUserId];
const expectedChallenge = user.currentChallenge;
-
- let verification;
+ const verifyOptions: VerifyAttestationResponseOptions = {
+ credential: body,
+ expectedChallenge: `${expectedChallenge}`,
+ expectedOrigin,
+ expectedRPID: rpID,
+ };
+ let verification: VerifiedAttestation;
try {
- verification = await verifyAttestationResponse({
- credential: body,
- expectedChallenge: `${expectedChallenge}`,
- expectedOrigin,
- expectedRPID: rpID,
- });
+ verification = await verifyAttestationResponse(verifyOptions);
} catch (error) {
console.error(error);
return res.status(400).send({ error: error.message });