diff options
author | Matthew Miller <matthew@millerti.me> | 2021-01-21 13:51:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-21 13:51:59 -0800 |
commit | 9ad5f7d214a707af9c3f9d6d078323e41ce1a017 (patch) | |
tree | 907fa11bd2ecafc5ebe2837296e16316e0791620 /example/index.ts | |
parent | 2d607eabf00a6216caf818293c6ff74879a140bd (diff) | |
parent | 5f4d3485d0cbe286a3fa439ed8519f951d37f63b (diff) |
Merge pull request #89 from MasterKale/feat/W3C-L2-update
feat/W3C-L2-update
Diffstat (limited to 'example/index.ts')
-rw-r--r-- | example/index.ts | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/example/index.ts b/example/index.ts index b3ecd4d..1492395 100644 --- a/example/index.ts +++ b/example/index.ts @@ -21,6 +21,10 @@ import { generateAssertionOptions, verifyAssertionResponse, } from '@simplewebauthn/server'; +import type { + AttestationCredentialJSON, + AuthenticatorDevice, +} from '@simplewebauthn/typescript-types'; import { LoggedInUser } from './example-server'; @@ -65,15 +69,7 @@ const inMemoryUserDeviceDB: { [loggedInUserId: string]: LoggedInUser } = { [loggedInUserId]: { id: loggedInUserId, username: `user@${rpID}`, - devices: [ - /** - * { - * credentialID: string, - * publicKey: string, - * counter: number, - * } - */ - ], + devices: [], /** * A simple way of storing a user's current challenge being signed by attestation or assertion. * It should be expired after `timeout` milliseconds (optional argument for `generate` methods, @@ -135,7 +131,7 @@ app.get('/generate-attestation-options', (req, res) => { }); app.post('/verify-attestation', async (req, res) => { - const { body } = req; + const body: AttestationCredentialJSON = req.body; const user = inMemoryUserDeviceDB[loggedInUserId]; @@ -165,11 +161,12 @@ app.post('/verify-attestation', async (req, res) => { /** * Add the returned device to the user's list of devices */ - user.devices.push({ + const newDevice: AuthenticatorDevice = { publicKey: base64PublicKey, credentialID: base64CredentialID, counter, - }); + }; + user.devices.push(newDevice); } } |