new Fido2Lib(opts)
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object | Options for the server Properties
|
Methods
(async) assertionOptions(optsopt, extraDataopt) → {Promise.<PublicKeyCredentialRequestOptions>}
- Description:
Creates an assertion challenge and any other parameters for the
navigator.credentials.get()
call. Thechallenge
property is anArrayBuffer
and will need to be encoded to be transmitted to the client.
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object |
<optional> |
An object containing various options for the option creation Properties
|
||||||||
extraData |
String |
<optional> |
Extra data to be signed by the authenticator during attestation. The challenge will be a hash:
SHA256(rawChallenge + extraData) and the |
Returns:
The options to be passed to navigator.credentials.get()
- Type
- Promise.<PublicKeyCredentialRequestOptions>
(async) assertionResult(res, expected) → {Promise.<Fido2AssertionResult>}
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
res |
Object | The assertion result that was generated by the client. See AuthenticatorAssertionResponse in the WebAuthn spec. Properties
|
||||||||||||||||||||||||||||
expected |
Object | The expected parameters for the assertion response. If these parameters don't match the recieved values, validation will fail and an error will be thrown. Properties
|
Throws:
-
If parsing or validation fails
- Type
- Error
Returns:
Returns a Promise that resolves to a Fido2AssertionResult
- Type
- Promise.<Fido2AssertionResult>
(async) attestationOptions(optsopt, extraDataopt) → {Promise.<PublicKeyCredentialCreationOptions>}
- Description:
Gets a challenge and any other parameters for the
navigator.credentials.create()
call Thechallenge
property is anArrayBuffer
and will need to be encoded to be transmitted to the client.
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object |
<optional> |
An object containing various options for the option creation Properties
|
||||||||
extraData |
String |
<optional> |
Extra data to be signed by the authenticator during attestation. The challenge will be a hash:
SHA256(rawChallenge + extraData) and the |
Returns:
The options for creating calling navigator.credentials.create()
- Type
- Promise.<PublicKeyCredentialCreationOptions>
(async) attestationResult(res, expected) → {Promise.<Fido2AttestationResult>}
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
res |
Object | The assertion result that was generated by the client. See AuthenticatorAttestationResponse in the WebAuthn spec. Properties
|
||||||||||||||||||||
expected |
Object | The expected parameters for the assertion response. If these parameters don't match the recieved values, validation will fail and an error will be thrown. Properties
|
Throws:
-
If parsing or validation fails
- Type
- Error
Returns:
Returns a Promise that resolves to a Fido2AttestationResult
- Type
- Promise.<Fido2AttestationResult>
disableExtension(extName)
Parameters:
Name | Type | Description |
---|---|---|
extName |
String | The name of the extension to enable. Must be a valid extension that has been registered through Fido2Lib#addExtension |
enableExtension(extName)
Parameters:
Name | Type | Description |
---|---|---|
extName |
String | The name of the extension to enable. Must be a valid extension that has been registered through Fido2Lib#addExtension |
setExtensionOptions(extName, options)
Parameters:
Name | Type | Description |
---|---|---|
extName |
String | The name of the extension to set the options for (e.g. - "appid". Must be a valid extension that has been registered through Fido2Lib#addExtension |
options |
Any | The parameter that will be passed to the option generator function (e.g. - "https://webauthn.org") |
(static) addAttestationFormat(fmt, parseFn, validateFn)
- Description:
Adds a new attestation format that will automatically be recognized and parsed for any future Fido2CreateRequest messages
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fmt |
String | The name of the attestation format, as it appears in the ARIN registry and / or as it will appear in the Fido2CreateRequest message that is received |
parseFn |
function | The function that will be called to parse the
attestation format. It will receive the |
validateFn |
function | The function that will be called to validate the
attestation format. It will receive no arguments, as all the necessary
information for validating the attestation statement will be contained in the
calling context ( |
(static) addExtension(extName, optionGeneratorFn, resultParserFn, resultValidatorFn)
- Description:
Adds a new global extension that will be available to all instantiations of Fido2Lib. Note that the extension must still be enabled by calling enableExtension for each instantiation of a Fido2Lib.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
extName |
String | The name of the extension to add. (e.g. - "appid") |
optionGeneratorFn |
function | Extensions are included in |
resultParserFn |
function | [description] |
resultValidatorFn |
function | [description] |
(async, static) addMdsCollection(mdsCollection)
- Description:
Adds a new MdsCollection to the global MDS collection list that will be used for findMdsEntry
- Source:
- See:
Parameters:
Name | Type | Description |
---|---|---|
mdsCollection |
MdsCollection | The MDS collection that will be used |
(static) clearMdsCollections()
- Description:
Removes all entries from the global MDS collections list. Mostly used for testing.
- Source:
(static) createMdsCollection(collectionName) → {MdsCollection}
- Description:
Creates a new MdsCollection
- Source:
- See:
Parameters:
Name | Type | Description |
---|---|---|
collectionName |
String | The name of the collection to create. Used to identify the source of a MdsEntry when Fido2Lib#findMdsEntry finds multiple matching entries from different sources (e.g. FIDO MDS 1 & FIDO MDS 2) |
Returns:
The MdsCollection that was created
- Type
- MdsCollection
(static) deleteAllAttestationFormats()
(static) deleteAllExtensions()
- Description:
Removes all extensions from the global extension registry. Mostly used for testing.
- Source:
(static) findMdsEntry(id) → {Array.<MdsEntry>}
- Description:
Returns MdsEntry objects that match the requested id. The lookup is done by calling MdsCollection#findEntry on the current global MDS collection. If no global MDS collection has been specified using setMdsCollection, an
Error
will be thrown.
- Source:
- See:
Parameters:
Name | Type | Description |
---|---|---|
id |
String | ArrayBuffer | The authenticator id to look up metadata for |
Returns:
Returns an Array of MdsEntry for the specified id. If no entry was found, the Array will be empty.
- Type
- Array.<MdsEntry>