Skip to main content

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

WebAuthnServiceOptions

Service options

Returns

WebAuthnService

Methods

deleteCredential()

deleteCredential(did, credentialId): Promise<void>

Defined in: src/auth/webauthn/webauthn-service.ts:591

Deletes a credential.

Parameters

did

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?

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

DID

User's DID

options?

RegistrationOptions

Registration options

Returns

Promise<RegistrationChallenge>

Registration challenge

Implementation of

IWebAuthnService.generateRegistrationChallenge


listCredentials()

listCredentials(did): Promise<readonly WebAuthnCredential[]>

Defined in: src/auth/webauthn/webauthn-service.ts:556

Lists all credentials for a user.

Parameters

did

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

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

AuthenticationResponse

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

RegistrationResponse

Registration response from client

Returns

Promise<WebAuthnCredential>

Stored credential

Implementation of

IWebAuthnService.verifyRegistration