Skip to content

Commit

Permalink
Migrate server service docstrings so they render
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterKale committed Dec 8, 2024
1 parent a799fbf commit 4d1803a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
38 changes: 19 additions & 19 deletions packages/server/src/services/metadataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,30 @@ type VerificationMode = 'permissive' | 'strict';
const log = getLogger('MetadataService');

interface MetadataService {
/**
* Prepare the service to handle remote MDS servers and/or cache local metadata statements.
*
* **Options:**
*
* @param opts.mdsServers An array of URLs to FIDO Alliance Metadata Service
* (version 3.0)-compatible servers. Defaults to the official FIDO MDS server
* @param opts.statements An array of local metadata statements
* @param opts.verificationMode How MetadataService will handle unregistered AAGUIDs. Defaults to
* `"strict"` which throws errors during registration response verification when an
* unregistered AAGUID is encountered. Set to `"permissive"` to allow registration by
* authenticators with unregistered AAGUIDs
*/
initialize(opts?: {
mdsServers?: string[];
statements?: MetadataStatement[];
verificationMode?: VerificationMode;
}): Promise<void>;
/**
* Get a metadata statement for a given AAGUID.
*
* This method will coordinate updating the cache as per the `nextUpdate` property in the initial
* BLOB download.
*/
getStatement(aaguid: string | Uint8Array): Promise<MetadataStatement | undefined>;
}

Expand All @@ -62,19 +81,6 @@ export class BaseMetadataService implements MetadataService {
private state: SERVICE_STATE = SERVICE_STATE.DISABLED;
private verificationMode: VerificationMode = 'strict';

/**
* Prepare the service to handle remote MDS servers and/or cache local metadata statements.
*
* **Options:**
*
* @param opts.mdsServers An array of URLs to FIDO Alliance Metadata Service
* (version 3.0)-compatible servers. Defaults to the official FIDO MDS server
* @param opts.statements An array of local metadata statements
* @param opts.verificationMode How MetadataService will handle unregistered AAGUIDs. Defaults to
* `"strict"` which throws errors during registration response verification when an
* unregistered AAGUID is encountered. Set to `"permissive"` to allow registration by
* authenticators with unregistered AAGUIDs
*/
async initialize(
opts: {
mdsServers?: string[];
Expand Down Expand Up @@ -144,12 +150,6 @@ export class BaseMetadataService implements MetadataService {
this.setState(SERVICE_STATE.READY);
}

/**
* Get a metadata statement for a given AAGUID.
*
* This method will coordinate updating the cache as per the `nextUpdate` property in the initial
* BLOB download.
*/
async getStatement(
aaguid: string | Uint8Array,
): Promise<MetadataStatement | undefined> {
Expand Down
21 changes: 11 additions & 10 deletions packages/server/src/services/settingsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@ import { GlobalSign_Root_CA_R3 } from './defaultRootCerts/mds.ts';
type RootCertIdentifier = AttestationFormat | 'mds';

interface SettingsService {
/**
* Set potential root certificates for attestation formats that use them. Root certs will be tried
* one-by-one when validating a certificate path.
*
* Certificates can be specified as a raw `Buffer`, or as a PEM-formatted string. If a
* `Buffer` is passed in it will be converted to PEM format.
*/
setRootCertificates(opts: {
identifier: RootCertIdentifier;
certificates: (Uint8Array | string)[];
}): void;

/**
* Get any registered root certificates for the specified attestation format
*/
getRootCertificates(opts: { identifier: RootCertIdentifier }): string[];
}

Expand All @@ -27,13 +38,6 @@ class BaseSettingsService implements SettingsService {
this.pemCertificates = new Map();
}

/**
* Set potential root certificates for attestation formats that use them. Root certs will be tried
* one-by-one when validating a certificate path.
*
* Certificates can be specified as a raw `Buffer`, or as a PEM-formatted string. If a
* `Buffer` is passed in it will be converted to PEM format.
*/
setRootCertificates(opts: {
identifier: RootCertIdentifier;
certificates: (Uint8Array | string)[];
Expand All @@ -52,9 +56,6 @@ class BaseSettingsService implements SettingsService {
this.pemCertificates.set(identifier, newCertificates);
}

/**
* Get any registered root certificates for the specified attestation format
*/
getRootCertificates(opts: { identifier: RootCertIdentifier }): string[] {
const { identifier } = opts;
return this.pemCertificates.get(identifier) ?? [];
Expand Down

0 comments on commit 4d1803a

Please sign in to comment.