webauthn-client: Software WebAuthn authenticator and JSON/HTTP client

[ bsd3, library, web ] [ Propose Tags ] [ Report a vulnerability ]

A software WebAuthn authenticator: the client half of a passkey ceremony. WebAuthn relying parties verify an ES256 signature over authData || SHA-256(clientDataJSON) by an enrolled public key, so a headless program can perform the same ceremony with a keypair it holds. Use this to sign in to passkey-gated APIs from a CLI or a service. . The library builds registration and assertion responses for the standard WebAuthn JSON shapes, persists credentials owner-only, and can drive an RP's JSON/HTTP endpoints, with a shipped adapter as an example.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies aeson (>=2.0 && <2.4), base (>=4.18 && <5), base64-bytestring (>=1.2 && <1.3), bytestring (>=0.11 && <0.13), crypton (>=1.0 && <1.2), directory (>=1.3 && <1.4), filepath (>=1.4 && <1.6), http-client (>=0.7 && <0.8), http-client-tls (>=0.3 && <0.5), http-types (>=0.12 && <0.13), text (>=2.0 && <2.2), unix (>=2.7 && <2.9) [details]
Tested with ghc ==9.12.4
License BSD-3-Clause
Author Doug Beardsley
Maintainer doug@equitek.ai
Uploaded by DougBeardsley at 2026-12-02T19:15:45Z
Category Web
Source repo head: git clone https://github.com/mightybyte/webauthn-client.git
Distributions
Downloads 2 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-12-02 [all 1 reports]

Readme for webauthn-client-0.1.0.0

[back to package description]

webauthn-client

A software WebAuthn authenticator and JSON/HTTP client for Haskell.

WebAuthn's client side is normally the browser plus a hardware or platform authenticator. What a relying party actually verifies, though, is an ES256 signature by the public key it enrolled for the credential, over

authData || SHA-256(clientDataJSON)

webauthn-client performs that same operation with a P-256 keypair the caller holds. That makes passkey-gated APIs usable from a headless program: a CLI, a daemon, a test suite, or a service that cannot show a WebAuthn prompt.

What it is — and is not

It is a software authenticator. The private key is generated locally, enrolled once with the relying party, and stored by you (the library can write it owner-only with saveCredentialFile).

It is not a way to use an existing platform passkey (Touch ID, iCloud Keychain, Windows Hello) or a hardware security key. Those private keys never leave their authenticator, and are bound to the app/origin that owns them.

Registration uses attestation format none: the authenticator makes no attestation claims, which the WebAuthn specification explicitly permits. A relying party that requires attestation, or that demands a particular AAGUID, will reject these credentials.

Quick start

{-# LANGUAGE OverloadedStrings #-}

import WebAuthn.Client
import WebAuthn.Client.Http

main :: IO ()
main = do
  let endpoints = exampleEndpoints "https://gateway.example.com:9090"

  -- One-time: redeem an enrollment token for a software credential.
  enrolled <- enroll endpoints [("X-Enroll-Token", token)]
  cred <- case enrolled of
    Left err  -> error (show err)
    Right cred -> pure cred
  saveCredentialFile "gateway-credential.json" cred

  -- Later: sign in and get the relying party's session cookie.
  authenticated <- authenticateWithStore
    endpoints
    (\c -> saveCredentialFile "gateway-credential.json" c)
    cred
  case authenticated of
    Left err -> error (show err)
    Right (sessionToken, _updated) ->
      putStrLn ("session: " <> show sessionToken)

Lower-level API

If your relying party does not follow the conventional options/verify JSON endpoints, use the pure ceremony functions directly:

import WebAuthn.Client

-- registration
(cred, registrationResponseJson) <-
  createRegistration "https://rp.example" "rp.example" challenge

-- authentication
(cred', assertionResponseJson) <- createAssertion cred challenge

The response values are ready to be JSON-encoded into the fields a browser would send (clientDataJSON, attestationObject/authenticatorData, signature, rawId), all base64url-encoded as WebAuthn requires.

assertionParts exposes the raw (clientDataJSON, authenticatorData, Signature) triple for tests and custom verifiers.

Credentials and the sign counter

Credential is ToJSON/FromJSON, with the private key as an integer. There is no hardware sign counter, so the library increments a software counter for each assertion and stores it in the credential. Persist the returned credential: authenticateWithStore calls your store before sending the assertion, so a lost response can never make the next attempt replay an older counter.

Treat a stored credential like a password. saveCredentialFile writes it with mode 0600.

Configuration

Endpoints describes the four URLs and the session-cookie name; there is no standard for them, so they are configuration rather than a constant. exampleEndpoints is the adapter this package ships and works as a template for others.

Development

A Nix flake provides a dev shell with GHC 9.12.4 (matching tested-with), cabal-install, hlint and ghcid, and with this project's dependencies already registered — so cabal build inside the shell uses the Nix-provided packages instead of resolving against Hackage.

$ nix develop
$ cabal build all
$ cabal test all

Without entering a shell:

$ nix build          # the library
$ nix build .#test   # build and run the hspec suite
$ nix flake check    # build the library and run the tests

The first invocation downloads a prebuilt GHC and dependency closure from cache.iog.io. nixConfig in flake.nix requests that cache, but Nix only honors it for flake configs you trust — either pass --accept-flake-config once, or add the substituter and key to ~/.config/nix/nix.conf.

License

BSD-3-Clause.