summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/server/src')
-rw-r--r--packages/server/src/services/metadataService.ts38
1 files changed, 18 insertions, 20 deletions
diff --git a/packages/server/src/services/metadataService.ts b/packages/server/src/services/metadataService.ts
index 3eac8a1..39586cb 100644
--- a/packages/server/src/services/metadataService.ts
+++ b/packages/server/src/services/metadataService.ts
@@ -11,8 +11,7 @@ import type {
MetadataBLOBPayloadEntry,
} from '../metadata/mdsTypes';
import SettingsService from '../services/settingsService';
-// TODO: Re-enable this once we figure out logging
-// import { log } from '../helpers/logging';
+import { getLogger } from '../helpers/logging';
import parseJWT from '../metadata/parseJWT';
@@ -40,6 +39,8 @@ enum SERVICE_STATE {
// registered AAGUIDs ("strict"). Currently primarily impacts how `getStatement()` operates
type VerificationMode = 'permissive' | 'strict';
+const log = getLogger('MetadataService');
+
/**
* A basic service for coordinating interactions with the FIDO Metadata Service. This includes BLOB
* download and parsing, and on-demand requesting and caching of individual metadata statements.
@@ -99,9 +100,9 @@ export class BaseMetadataService {
// If MDS servers are provided, then process them and add their statements to the cache
if (mdsServers?.length) {
- // TODO: Re-enable this once we figure out logging
- // const currentCacheCount = Object.keys(this.statementCache).length;
- // let numServers = mdsServers.length;
+ // Get a current count so we know how many new statements we've added from MDS servers
+ const currentCacheCount = Object.keys(this.statementCache).length;
+ let numServers = mdsServers.length;
for (const url of mdsServers) {
try {
@@ -112,16 +113,15 @@ export class BaseMetadataService {
});
} catch (err) {
// Notify of the error and move on
- // TODO: Re-enable this once we figure out logging
- // log('warning', `Could not download BLOB from ${url}:`, err);
- // numServers -= 1;
+ log(`Could not download BLOB from ${url}:`, err);
+ numServers -= 1;
}
}
- // TODO: Re-enable this once we figure out logging
- // const newCacheCount = Object.keys(this.statementCache).length;
- // const cacheDiff = newCacheCount - currentCacheCount;
- // log('info', `Downloaded ${cacheDiff} statements from ${numServers} metadata servers`);
+ // Calculate the difference to get the total number of new statements we successfully added
+ const newCacheCount = Object.keys(this.statementCache).length;
+ const cacheDiff = newCacheCount - currentCacheCount;
+ log(`Cached ${cacheDiff} statements from ${numServers} metadata servers`);
}
if (verificationMode) {
@@ -223,10 +223,11 @@ export class BaseMetadataService {
// Validate the certificate chain
const rootCerts = SettingsService.getRootCertificates({ identifier: 'mds' });
await validateCertificatePath(headerCertsPEM, rootCerts);
- } catch (err) {
+ } catch (error) {
+ const _error: Error = error as Error;
// From FIDO MDS docs: "ignore the file if the chain cannot be verified or if one of the
// chain certificates is revoked"
- throw new Error(`BLOB certificate path could not be validated: ${err.message}`);
+ throw new Error(`BLOB certificate path could not be validated: ${_error.message}`);
}
// Verify the BLOB JWT signature
@@ -306,14 +307,11 @@ export class BaseMetadataService {
this.state = newState;
if (newState === SERVICE_STATE.DISABLED) {
- // TODO: Re-enable this once we figure out logging
- // log('MetadataService is DISABLED');
+ log('MetadataService is DISABLED');
} else if (newState === SERVICE_STATE.REFRESHING) {
- // TODO: Re-enable this once we figure out logging
- // log('MetadataService is REFRESHING');
+ log('MetadataService is REFRESHING');
} else if (newState === SERVICE_STATE.READY) {
- // TODO: Re-enable this once we figure out logging
- // log('MetadataService is READY');
+ log('MetadataService is READY');
}
}
}