Skip to content

Replace http-message-sig with fetch-message-signatures in the web-bot-auth package - #122

Open
panva wants to merge 2 commits into
cloudflare:mainfrom
panva:replace-http-sig
Open

Replace http-message-sig with fetch-message-signatures in the web-bot-auth package#122
panva wants to merge 2 commits into
cloudflare:mainfrom
panva:replace-http-sig

Conversation

@panva

@panva panva commented Aug 8, 2026

Copy link
Copy Markdown

@thibmeu 👋

I built fetch-message-signatures over the course of IETF 126 and finally wrapped it up today, an RFC 9421 implementation built for the Fetch API until it maybe one day supports it natively.

I ported packages/web-bot-auth onto it to test my own API against a real consumer. Opening the result here in case it's useful. If you'd rather keep your own implementation, feel free to close.

Only packages/web-bot-auth changes, I didn't touch packages/http-message-sig. It also drops structured-headers, because the RFC 9651 parser comes from fetch-message-signatures too.

Two commits: the swap, then the Signature-Agent parsing separately.

Breaking for consumers: Signer is now a key id plus a signer factory instead of a sign callback, and verify() takes a verifier factory instead of Verify<T>. Verify<T>, SignerSync, SignOptions and SignSyncOptions are gone, and Directory.schema is optional. Everything else keeps its name.

Fixes: RSA keys are checked for their digest as well as their algorithm, so verifier() rejects an RSA-PSS key made for SHA-256 rather than verifying with SHA-256 under a signature that says rsa-pss-sha512.

@panva
panva force-pushed the replace-http-sig branch from 4e1f48f to 80ddf0a Compare August 8, 2026 15:50
panva added 2 commits August 9, 2026 21:44
The packages/http-message-sig package is unchanged, and is still built,
tested and published from this repo.

This is a breaking change for consumers of web-bot-auth. Signer is now a
key identifier paired with a signer factory rather than a sign callback,
and verify() takes a verifier factory in place of Verify<T>, which is
removed along with SignerSync, SignOptions and SignSyncOptions.
Directory.schema becomes optional. Every other export keeps its name,
including signatureHeadersSync, directoryResponseHeaders, MediaType, Tag
and HTTP_MESSAGE_SIGNATURES_DIRECTORY.

One behaviour changes. RSA keys are validated for their digest as well
as their algorithm, so verifier() rejects an RSA-PSS key created for
SHA-256 rather than verifying with SHA-256 under a signature naming
rsa-pss-sha512. Covered component matching is unchanged: both rules
still match a field or derived component name whatever parameters the
identifier carries.

signatureHeadersSync composes createSignatureBase() and
createSignatureFields(), neither of which returns a Promise. The IETF
draft vectors now assert its Signature-Input byte for byte alongside the
asynchronous path.
fetch-message-signatures exports the Structured Fields parser RFC 9421
is built on, so the separate structured-headers dependency is no longer
needed here. packages/http-message-sig keeps its own.

Values come back tagged rather than as raw JavaScript, so discoveryType
reads a Token's text instead of relying on String() to produce it.
@panva
panva force-pushed the replace-http-sig branch from 80ddf0a to e669545 Compare August 9, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant