diff options
author | Matthew Miller <matthew@millerti.me> | 2020-07-04 14:59:30 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-07-04 14:59:30 -0700 |
commit | c1b9b606fe0260a891365565e521ba2f603db2a6 (patch) | |
tree | 55ea65672b67c45a6d8793c0379b3b0c95179704 | |
parent | 17c54060ef8ee08c383e793783d2216e388e7abd (diff) |
Wire up MetadataService in example conformance
-rw-r--r-- | example/fido-conformance.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/example/fido-conformance.js b/example/fido-conformance.js index d4a3a23..37cd90e 100644 --- a/example/fido-conformance.js +++ b/example/fido-conformance.js @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ +const fs = require('fs'); const express = require('express'); const { v4: uuidv4 } = require('uuid'); @@ -7,8 +8,27 @@ const { verifyAttestationResponse, generateAssertionOptions, verifyAssertionResponse, + MetadataService, } = require('@simplewebauthn/server'); +/** + * Load JSON metadata statements provided by the Conformance Tools + * + * FIDO2 > TESTS CONFIGURATION > DOWNLOAD SERVER METADATA (button) + */ +// Update this to whatever folder you extracted the statements to +const conformanceMetadataPath = './fido-conformance-mds-v1.3.4'; +const conformanceMetadataFilenames = fs.readdirSync(conformanceMetadataPath); +const statements = []; +for (const statementPath of conformanceMetadataFilenames) { + if (statementPath.endsWith('.json')) { + const contents = fs.readFileSync(`${conformanceMetadataPath}/${statementPath}`, 'utf-8'); + statements.push(JSON.parse(contents)); + } +} +// Initialize the metadata service with the prepared statements +MetadataService.initialize(statements); + const inMemoryUserDeviceDB = { // [username]: string: { // id: loggedInUserId, |