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
@thibmeu thibmeu added the enhancement New feature or request label Aug 12, 2026
@thibmeu
thibmeu self-requested a review August 12, 2026 12:48
@thibmeu

thibmeu commented Aug 12, 2026

Copy link
Copy Markdown
Member

Thanks for the PR. I checked a few cases, and this looks useful for addressing rough edges in http-message-sig. That package was primarily built for the web-bot-auth use case when no suitable implementation was available.

My main question is long-term maintenance. Keeping the RFC 9421 implementation in this repository preserves change control and avoids another external dependency. On the other hand, consolidating on a well-maintained ecosystem package avoids duplicating effort. I’m happy to help maintain or contribute to that package if we take this route (some of the changes from the below commit for instance).

For this change, I think preserving as much of the existing API as possible while improving correctness is important. I pushed an additional commit on top of your branch:
https://github.com/panva/web-bot-auth/compare/main...thibmeu:web-bot-auth:replace-http-sig?expand=1

I can’t open a PR targeting your fork’s branch, but the commit can be cherry-picked or stacked onto this PR.

@panva

panva commented Aug 13, 2026

Copy link
Copy Markdown
Author

@thibmeu you can push directly to this repo's PR head. I'm on PTO so feel free to do whatever you feel is best for web-bot-auth. As I said I used it merely to validate my API and identify gaps. I'll be test driving the module some more after PTO and then call it 1.0 stable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants