Interface WebAuthn4JS

Implements Web Authentication for applications. Uses the Go WebAuthn library, compiled to Web Assembly, to do the heavy lifting.

Note that WebAuthn4JS doesn't store any data itself. Users and credentials are left for the application to store, for example in a database.

No Inherit Doc

interface WebAuthn4JS {
    beginLogin(user, ...opts): Promise<{
        options: CredentialAssertion;
        sessionData: SessionData;
    }>;
    beginRegistration(user, ...opts): Promise<{
        options: CredentialCreation;
        sessionData: SessionData;
    }>;
    exit(code?): void;
    finishLogin(user, sessionData, response): Promise<Credential>;
    finishRegistration(user, sessionData, response): Promise<Credential>;
}

Hierarchy

Methods

  • Generate a new set of login data (including assertion challenge) to be sent to the browser.

    Parameters

    Returns Promise<{
        options: CredentialAssertion;
        sessionData: SessionData;
    }>

    A promise which resolves to the options which the browser should pass to navigator.credentials.get() and session data which the caller should store securely for the duration of the registration ceremony.

  • Generate a new set of registration data (including attestation challenge) to be sent to the browser.

    Parameters

    Returns Promise<{
        options: CredentialCreation;
        sessionData: SessionData;
    }>

    A promise which resolves to the options which the browser should pass to navigator.credentials.create() and session data which the caller should store securely for the duration of the registration ceremony.

  • Tell the Web Assembly code which is running the Go WebAuthn library for this instance to stop.

    Don't call any more methods after you call this.

    Parameters

    Returns void

  • Take the response from the browser and validate it against the user's credentials and the login ceremony's session data.

    Parameters

    Returns Promise<Credential>

    Credential that was verified (against the challenge in the session data).

    It's also checked to belong to the user's existing credentials.

    Note that the caller is responsible for checking the Authenticator.cloneWarning property, indicating the credential has been cloned, and treating it as an error.

    The caller should also use the Authenticator.signCount property to update the sign count it holds on record (for example in a database) for this credential. It can use the Credential.id property to identify credentials.

  • Take the response from the browser and verify the credential against the registration ceremony's session data.

    Parameters

    Returns Promise<Credential>

    Credential that was verified (against the challenge in the session data).

    Note that the caller is responsible for associating this credential with the user (for example in a database) and for checking the same credential isn't registered to another user.

Generated using TypeDoc