Skip to content

Commit b299b51

Browse files
committed
Update Example to v10.0.0
1 parent 81d9e49 commit b299b51

File tree

4 files changed

+21
-29
lines changed

4 files changed

+21
-29
lines changed

example/fido-conformance.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
verifyAuthenticationResponse,
1212
verifyRegistrationResponse,
1313
} from '@simplewebauthn/server';
14-
import { isoBase64URL, isoUint8Array } from '@simplewebauthn/server/helpers';
1514
import { AuthenticationResponseJSON, RegistrationResponseJSON } from '@simplewebauthn/types';
1615

1716
import { expectedOrigin, rpID } from './index';
@@ -234,6 +233,7 @@ fidoConformanceRouter.post('/assertion/options', async (req, res) => {
234233
const { devices } = user;
235234

236235
const opts = await generateAuthenticationOptions({
236+
rpID,
237237
extensions,
238238
userVerification,
239239
allowCredentials: devices.map((dev) => ({
@@ -269,10 +269,7 @@ fidoConformanceRouter.post('/assertion/result', async (req, res) => {
269269
return res.status(400).send({ errorMessage: msg });
270270
}
271271

272-
const credIDBuffer = isoBase64URL.toBuffer(id);
273-
const existingDevice = user.devices.find((device) =>
274-
isoUint8Array.areEqual(device.credentialID, credIDBuffer)
275-
);
272+
const existingDevice = user.devices.find((device) => device.credentialID === id);
276273

277274
if (!existingDevice) {
278275
const msg = `Could not find device matching ${id}`;

example/index.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
verifyAuthenticationResponse,
2424
verifyRegistrationResponse,
2525
} from '@simplewebauthn/server';
26-
import { isoBase64URL, isoUint8Array } from '@simplewebauthn/server/helpers';
2726
import type {
2827
GenerateAuthenticationOptionsOpts,
2928
GenerateRegistrationOptionsOpts,
@@ -126,7 +125,6 @@ app.get('/generate-registration-options', async (req, res) => {
126125
const opts: GenerateRegistrationOptionsOpts = {
127126
rpName: 'SimpleWebAuthn Example',
128127
rpID,
129-
userID: loggedInUserId,
130128
userName: username,
131129
timeout: 60000,
132130
attestationType: 'none',
@@ -195,9 +193,7 @@ app.post('/verify-registration', async (req, res) => {
195193
if (verified && registrationInfo) {
196194
const { credentialPublicKey, credentialID, counter } = registrationInfo;
197195

198-
const existingDevice = user.devices.find((device) =>
199-
isoUint8Array.areEqual(device.credentialID, credentialID)
200-
);
196+
const existingDevice = user.devices.find((device) => device.credentialID === credentialID);
201197

202198
if (!existingDevice) {
203199
/**
@@ -260,10 +256,9 @@ app.post('/verify-authentication', async (req, res) => {
260256
const expectedChallenge = req.session.currentChallenge;
261257

262258
let dbAuthenticator;
263-
const bodyCredIDBuffer = isoBase64URL.toBuffer(body.rawId);
264259
// "Query the DB" here for an authenticator matching `credentialID`
265260
for (const dev of user.devices) {
266-
if (isoUint8Array.areEqual(dev.credentialID, bodyCredIDBuffer)) {
261+
if (dev.credentialID === body.id) {
267262
dbAuthenticator = dev;
268263
break;
269264
}

example/package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"author": "",
1212
"license": "ISC",
1313
"dependencies": {
14-
"@simplewebauthn/server": "9.0.3",
14+
"@simplewebauthn/server": "10.0.0",
1515
"dotenv": "^10.0.0",
1616
"express": "^4.17.1",
1717
"express-session": "^1.17.3",

0 commit comments

Comments
 (0)