summaryrefslogtreecommitdiffhomepage
path: root/example/index.ts
diff options
context:
space:
mode:
authorJarrett Helton <jaydhelton@gmail.com>2021-02-19 05:44:55 -0500
committerJarrett Helton <jaydhelton@gmail.com>2021-02-19 05:44:55 -0500
commitc469d585a5d28d665e52af8df6c23ae058c25a94 (patch)
tree25723e363c15cd045e3bad0cec78aec61379f858 /example/index.ts
parentb5e80cc42b485f23f7d9fca41d04a9d80b650bd3 (diff)
revert example, stop commiting it
Diffstat (limited to 'example/index.ts')
-rw-r--r--example/index.ts26
1 files changed, 11 insertions, 15 deletions
diff --git a/example/index.ts b/example/index.ts
index 6667fcd..631a0ee 100644
--- a/example/index.ts
+++ b/example/index.ts
@@ -21,16 +21,12 @@ 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';
@@ -99,7 +95,8 @@ app.get('/generate-attestation-options', (req, res) => {
username,
devices,
} = user;
- const attesOptions: GenerateAttestationOptionsOpts = {
+
+ const options = generateAttestationOptions({
rpName: 'SimpleWebAuthn Example',
rpID,
userID: loggedInUserId,
@@ -125,8 +122,7 @@ 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
@@ -143,15 +139,15 @@ app.post('/verify-attestation', async (req, res) => {
const user = inMemoryUserDeviceDB[loggedInUserId];
const expectedChallenge = user.currentChallenge;
- const verifyOptions: VerifyAttestationResponseOptions = {
- credential: body,
- expectedChallenge: `${expectedChallenge}`,
- expectedOrigin,
- expectedRPID: rpID,
- };
- let verification: VerifiedAttestation;
+
+ let verification;
try {
- verification = await verifyAttestationResponse(verifyOptions);
+ verification = await verifyAttestationResponse({
+ credential: body,
+ expectedChallenge: `${expectedChallenge}`,
+ expectedOrigin,
+ expectedRPID: rpID,
+ });
} catch (error) {
console.error(error);
return res.status(400).send({ error: error.message });