Class: WebAuthnService
Defined in: src/auth/webauthn/webauthn-service.ts:173
WebAuthn service implementation.
Remarks
Provides WebAuthn credential registration and authentication using the @simplewebauthn/server library.
Example
const webauthnService = new WebAuthnService({
redis,
logger,
config: {
rpName: 'Chive',
rpId: 'chive.pub',
},
});
// Start registration
const challenge = await webauthnService.generateRegistrationChallenge(did);
// Complete registration (after client response)
const credential = await webauthnService.verifyRegistration(response);
Implements
Constructors
new WebAuthnService()
new WebAuthnService(
options):WebAuthnService
Defined in: src/auth/webauthn/webauthn-service.ts:183
Creates a new WebAuthnService.
Parameters
options
Service options
Returns
Methods
deleteCredential()
deleteCredential(
did,credentialId):Promise<void>
Defined in: src/auth/webauthn/webauthn-service.ts:591
Deletes a credential.
Parameters
did
User's DID (for ownership verification)
credentialId
string
Credential ID to delete
Returns
Promise<void>
Implementation of
IWebAuthnService.deleteCredential
generateAuthenticationChallenge()
generateAuthenticationChallenge(
did?):Promise<AuthenticationChallenge>
Defined in: src/auth/webauthn/webauthn-service.ts:383
Generates an authentication challenge.
Parameters
did?
User's DID (optional for discoverable credentials)
Returns
Promise<AuthenticationChallenge>
Authentication challenge
Implementation of
IWebAuthnService.generateAuthenticationChallenge
generateRegistrationChallenge()
generateRegistrationChallenge(
did,options?):Promise<RegistrationChallenge>
Defined in: src/auth/webauthn/webauthn-service.ts:196
Generates a registration challenge for credential creation.
Parameters
did
User's DID
options?
Registration options
Returns
Promise<RegistrationChallenge>
Registration challenge
Implementation of
IWebAuthnService.generateRegistrationChallenge
listCredentials()
listCredentials(
did):Promise<readonlyWebAuthnCredential[]>
Defined in: src/auth/webauthn/webauthn-service.ts:556
Lists all credentials for a user.
Parameters
did
User's DID
Returns
Promise<readonly WebAuthnCredential[]>
Array of credentials
Implementation of
IWebAuthnService.listCredentials
updateCredentialNickname()
updateCredentialNickname(
did,credentialId,nickname):Promise<void>
Defined in: src/auth/webauthn/webauthn-service.ts:618
Updates a credential's nickname.
Parameters
did
User's DID
credentialId
string
Credential ID
nickname
string
New nickname
Returns
Promise<void>
Implementation of
IWebAuthnService.updateCredentialNickname
verifyAuthentication()
verifyAuthentication(
response):Promise<WebAuthnVerificationResult>
Defined in: src/auth/webauthn/webauthn-service.ts:450
Verifies an authentication response.
Parameters
response
Authentication response from client
Returns
Promise<WebAuthnVerificationResult>
Verification result with credential
Implementation of
IWebAuthnService.verifyAuthentication
verifyRegistration()
verifyRegistration(
response):Promise<WebAuthnCredential>
Defined in: src/auth/webauthn/webauthn-service.ts:291
Verifies a registration response and stores the credential.
Parameters
response
Registration response from client
Returns
Promise<WebAuthnCredential>
Stored credential