SimpleWebAuthn Documentation

website·Indexed 35 days ago

https://simplewebauthn.dev/docs/

A set of complementary libraries for adding WebAuthn-powered authentication to applications. Includes @simplewebauthn/browser for client-side registration and authentication, and @simplewebauthn/server for server-side logic. Supports Node LTS, Deno, and modern browsers, with features covering passkeys, FIDO conformance, and Post-Quantum Cryptography (PQC) ML-DSA support in version 14.0.x.

Tokens
25.4K
Snippets
113
Records
154
Agent score
69%

What's inside SimpleWebAuthn

  1. Introduction to SimpleWebAuthn libraries

    The SimpleWebAuthn project provides two complementary libraries designed to simplify the integration of WebAuthn into websites: @simplewebauthn/server for server-side logic and @simplewebauthn/browser for client-side browser interactions.
  2. Overview of SimpleWebAuthn libraries

    SimpleWebAuthn provides a pair of libraries to simplify the WebAuthn registration and authentication flow. It abstracts the complexity of the W3C WebAuthn specification, specifically handling the conversion between ArrayBuffer/Uint8Array and JSON-compatible formats required for transmission between the front end and back end.

    • @simplewebauthn/server: Provides methods to generate the required values for registration/authentication and to parse the responses received from the browser.
    • @simplewebauthn/browser: Provides methods to pass server-provided values into the browser's navigator.credentials.create() and navigator.credentials.get() APIs and return the authenticator's response to the server.
  3. Overview of MetadataService in @simplewebauthn/server

    The MetadataService is an opt-in singleton service in @simplewebauthn/server that interacts with the FIDO Alliance Metadata Service (MDS) API (version 3.0). It allows developers to cross-reference authenticators used during registration against cryptographically-signed 'guarantees' provided by manufacturers. This is used to ensure strict adherence to FIDO specifications. Using MetadataService is not required for typical use cases.
    import { MetadataService } from '@simplewebauthn/server';
  4. Introduction to SimpleWebAuthn libraries

    SimpleWebAuthn provides two complementary libraries designed to simplify the integration of WebAuthn into websites: @simplewebauthn/server for server-side logic and @simplewebauthn/browser for client-side browser interactions.
  5. Overview of FIDO Metadata Service (MDS) support in SimpleWebAuthn

    The @simplewebauthn/server package provides a MetadataService singleton to interact with the FIDO Alliance Metadata Service (version 3.0) API. This allows developers to cross-reference authenticators during registration using cryptographically-signed guarantees from manufacturers. This functionality is opt-in and not required for typical use cases.
    import { MetadataService } from '@simplewebauthn/server';
  6. Implement passkey support with SimpleWebAuthn

    Passkeys are WebAuthn credentials that can be synchronized across devices via cloud accounts (Apple, Google, Microsoft). To support passkeys, the Relying Party (RP) must instruct the authenticator to generate discoverable credentials and perform user verification. Passkey support is compatible with existing WebAuthn implementations but requires specific configuration options to optimize for a passwordless experience.
  7. Support for Post-Quantum Cryptography (ML-DSA) in SimpleWebAuthn

    SimpleWebAuthn v14.0.x supports the ML-DSA signature algorithm to protect passkeys against future quantum computer attacks. This is available in the following runtimes:

    • Node: v24.7.0 and up
    • Deno: v2.8.2 and up
  8. Understand the risks of using WebAuthn PRF extension

    The prf (pseudo-random function) extension allows a website to request random bytes associated with a user's passkey, which is useful for end-to-end encryption. However, this creates a critical dependency: if a user deletes their passkey, they will permanently lose access to any information encrypted using that passkey's PRF seed. Because of this risk, SimpleWebAuthn provides minimal helpers rather than a high-level abstraction for PRF.
  9. Understand the risks of using WebAuthn PRF extension

    The prf (pseudo-random function) extension allows a server to request random bytes associated with a user's passkey, which is useful for end-to-end encryption. However, this creates a critical dependency: if a user deletes their passkey, they permanently lose access to any data encrypted using that passkey's PRF seed. SimpleWebAuthn provides minimal abstraction for PRF to ensure developers understand the liability and the underlying WebAuthn specification.
  10. Understand the SimpleWebAuthn architecture for WebAuthn implementation

    WebAuthn requires a coordinated exchange between a server and a browser to handle registration and authentication. The primary challenge is that the native WebAuthn API (navigator.credentials.create() and navigator.credentials.get()) relies heavily on ArrayBuffer objects, which are not natively JSON-compatible for transmission between the front end and back end.

    SimpleWebAuthn solves this by providing two complementary libraries:

    1. @simplewebauthn/server: Handles the generation of options for the authenticator and the parsing of responses from the authenticator.
    2. @simplewebauthn/browser: Handles the interaction with the browser's WebAuthn API and the encoding/decoding of data for transmission to the server.

    Together, these libraries automate the conversion between Uint8Array/ArrayBuffer and JSON-compatible strings, removing the need for manual data transformation.

  11. Handle WebAuthn attestation formats

    When attestationType is set to "direct" during registration options generation, the authenticator returns an attestation statement containing verifiable information about the hardware.

    SimpleWebAuthn supports all current WebAuthn attestation formats, including: Packed, TPM, Android Key, Android SafetyNet, Apple, FIDO U2F, and None. If you do not have specific requirements regarding the hardware your users use, you can ignore attestation statements.