TypeScript: @dnsid-ai/web-bot-auth
DNSid Web Bot Auth profile helpers.
This package signs and verifies DNSid Web Bot Auth requests (RFC 9421 HTTP Message Signatures with the web-bot-auth tag), serves signed key directories, and verifies discovered directories against current DNSid operational (ku) keys. It targets published draft-ietf-webbotauth-httpsig-protocol-01, including its directory format, not the editor’s copy or a finalized WBA standard. This is a narrower DNSid profile, not a general WBA implementation. External partner interoperability has not been tested.
It builds on @dnsid-ai/http-signatures and @dnsid-ai/protocol contracts and performs no DNS or HTTPS transport itself. Signing requires an Ed25519 operational key; the profile throws ArgumentError for other key types.
Upgrade from draft-00
Section titled “Upgrade from draft-00”Upgrade signers and verifiers together. This draft-01 profile cannot interoperate with the draft-00 profile shipped in 0.37.
- Remove
signatureAgent.typeand imports ofSignatureAgentType.Signature-Agentnow contains a direct HTTPS directory URL without parameters; headers with;type=directoryor;type=jwks_uriare rejected. - Set custom
signatureAgent.uri,directoryURL, and trusteddiscovery.urivalues to the full directory URL, not just its origin. The default ishttps://{domain}/.well-known/http-message-signatures-directory; an explicit origin-only URL now addresses/. - Directory JWKs omit
algby default. If supplied, it must beEd25519;ed25519andEdDSAare rejected. The HTTP signaturealgparameter remainsed25519.
Install
Section titled “Install”npm install @dnsid-ai/web-bot-auth @dnsid-ai/protocolExample
Section titled “Example”Sign an outbound request:
import { createWebBotAuthProfile } from '@dnsid-ai/web-bot-auth';
const profile = createWebBotAuthProfile({ domain: 'agent.example', keyProvider, // Ed25519 operational key});
const signed = await profile.createWebBotAuthSignedRequest( new Request('https://origin.example/api'),);await fetch(signed);Serve the key directory (mount at /.well-known/http-message-signatures-directory):
const response = await profile.serveHttpMessageSignaturesDirectory(request);The directory response is signed with the http-message-signatures-directory tag and served as application/http-message-signatures-directory+json. Signatures are backdated by min(5, ttl - 1) seconds without extending their lifetime. The default response has at most 295 seconds of freshness and signed Cache-Control: max-age=295, must-revalidate. Disable CDN stale-serving overrides, stale-while-revalidate, and stale-if-error for this endpoint.
Verify a request
Section titled “Verify a request”Verification-only construction does not need a local identity or signing key:
import { createSsrfSafeFetch } from '@dnsid-ai/transport'; // Node transport
const safeFetch = createSsrfSafeFetch({}, { decompress: false });const verifier = createWebBotAuthProfile({ identityResolver, // RefreshingIdentityResolver, including configured entity acceptance discoveryFetch: request => safeFetch(request),});const identity = await verifier.verifyWebBotAuthSignedRequest(request, { signerDomain: 'agent.example', // trusted application policy requiredComponents: ['@method', '@target-uri'], // enforce operation binding peerCert, // current application peer certificate, required for fl=mtls timeoutMs: 30_000, signal,});Install @dnsid-ai/transport to use this Node transport. The package stays runtime-neutral: discoveryFetch is required and must enforce valid Web PKI, public-address DNS checks and connection pinning on every connection, rejection of all redirects (including same-host HTTPS), cancellation, and unmodified response bytes and headers without decompression. Coded directories are rejected. Ordinary server-side fetch is not safe for untrusted discovery. Do not enable private-address exceptions for WBA discovery.
Alternatively, explicitly set allowSignatureAgentDomain: true to let the signed HTTPS discovery host identify the signer. Cross-host delegation is rejected. Signature-Agent and its exact keyed coverage are mandatory, even with trusted discovery: { uri }, which constrains the signed endpoint rather than replacing it. The signed member points directly to the HTTPS directory and has no parameters. Missing, uncovered, or invalid discovery rejects before network work. Signature relabeling preserves the original covered discovery member.
Every invocation verifies request and directory signatures, content digests, and current DNSid key binding and acceptance. There is no directory-only fallback or internal directory cache. Every discovery request uses cache: 'no-store' and Cache-Control: no-cache. Injected transports must bypass local caches and revalidate upstream on each call. A fresh directory missing the key fails without a retry. Even newly fetched responses are rejected when HTTP-stale. max-age, Date, Age, and fetch latency establish a deadline that is checked again before return. A revalidated max-age=0 response with absent or zero Age may serve its acquiring invocation, as may fresh no-store or no-cache responses. Injected caching transports must enforce RFC 9111 freshness using original acquisition timing and HTTP age metadata, reject reuse without sufficient metadata, and never restart freshness when returning the same response. Key attribution must use the normalized discovery URL and thumbprint within the policy context. Newer resolutions replace older key sets, including removed keys; order signed proofs by created. Failed refreshes must neither evict evidence nor extend freshness. The verifier does not infer cache reuse or derive an HTTP deadline from signed creation time. Results authenticate identity but do not grant application permissions. Default required coverage is @authority, not method or path. Use signing additionalComponents to add bindings and verifier requiredComponents to require them, with exact parameter equality. Nested WBA signing is unsupported. Coverage policy is checked before discovery; malformed policy raises ArgumentError. Covered keyed Content-Digest components must select sha-256; unsupported members are rejected. Profile configuration, including nested discovery settings, is snapshotted and validated on construction.
For one-time requests, supply consumeNonce(entry, signal). It must atomically consume (signerDomain, keyid, nonce) and retain the entry until retainUntil (expires + clockSkew). Return false for reuse; store errors reject verification. Without this hook, time-valid requests can be replayed.
The overall timeout defaults to 30 seconds and covers discovery, reads, DNSid verification, and replay storage. Redirects are rejected. Limits are 256 KiB directory content, 64 keys, JSON depth 16, 16 KiB signature/discovery/digest headers and URLs, 64 KiB aggregate header characters, and 1 MiB request content. The hosting layer must bound incoming request streams before cloning them; verification preserves the original request body. Signature lifetimes cannot exceed 300 seconds. Directory signature creation cannot be in the future, even within configured clock skew. Evidence freshness is checked again before return, including both certificates and key age. Fresh zero-TTL DNS evidence is valid only within the acquiring invocation. Directory timeouts and temporary HTTP failures are transient; invalid TLS, unsafe destinations, and invalid signatures remain permanent.
Options
Section titled “Options”signatureAgent.uri: the HTTPS URL advertised inSignature-Agent. Defaults tohttps://{domain}/.well-known/http-message-signatures-directory. For a custom endpoint, set the full URL.directoryURL— deprecated alias for a direct HTTPS directory endpoint. UsesignatureAgent.uriinstead.signatureTTL/directorySignatureTTL— signature lifetimes in seconds (defaults: 60 for requests, 300 for the directory).clockSkew— non-negative verification tolerance in seconds (default: 5); never permits future directory creation.
You can also build the profile from a signing identity manager with WebBotAuthProfile.fromIdentityManager(idm).
The includeSignatureAgent configuration and per-request signatureAgent omission options have been removed. Only the current DNSid operational key is accepted, without overlapping-key grace. Verification requires RefreshingIdentityResolver; missing refreshDomain raises ArgumentError on construction. After valid request and directory signatures, a current-key mismatch permits one refreshDomain attempt per normalized signer domain per five seconds, shared across concurrent calls and discovery URLs. Failed attempts consume the allowance; concurrent retries are suppressed. Admission state is capped at 1024 domains and fails closed when full. Refreshed evidence must pass normal acceptance, current-peer, current-key, and freshness checks. There is no eviction workaround or stale fallback. Propagation and availability can still interrupt rotation, and learning the new key rejects outstanding old-key requests.
The agent domain is the identity FQDN, not its accountable entity or request destination. WBA discovery must be separate from the live ku JWKS, including query/fragment variants. fromIdentityManager rejects locally configured ku discovery; verification checks the authenticated ku endpoint. Validated HTTPS at the agent’s public ku endpoint supplies DNSid’s agent-FQDN TLS check without inbound access to the crawler process. With fl=mtls, current application-peer evidence remains required.
Use the shared managed rotation/recovery workflow: its pause hook must block new request/directory signing and wait for existing signing operations before resolving. Probe new-key requests through a verifier caching the old key. The shared HTTP signer verifies each returned signature against the public key selected for its metadata and fails on mismatch. Built-in local and AWS providers drain in-flight signatures and reject new signing during activation; custom providers must enforce the same contract. For a lost or suspected compromised key, stop signing and use revocation/reissuance, not routine rotation. Short TTLs and mismatch refresh do not revoke stolen keys. The same ku also authorizes KEY_ROTATION: unrestricted key access on a signing node can authorize identity rotation, not just forge requests. Keeping ek off the fleet does not remove this exposure; dedicated fleet-key delegation requires a separate security design.
DNSid Web Bot Auth profile.
Signs outbound HTTP requests per Web Bot Auth (RFC 9421 HTTP Message Signatures
with the web-bot-auth tag) and serves the signed
/.well-known/http-message-signatures-directory document that advertises the
agent’s public keys. Verification authenticates signed directories and requests
against current DNSid operational keys and configured entity acceptance.
Targets draft-ietf-webbotauth-httpsig-protocol-01.
Web Bot Auth requires an Ed25519 operational key; signing with any other key type raises ArgumentError.
Classes
Section titled “Classes”WebBotAuthProfile
Section titled “WebBotAuthProfile”Defined in: web-bot-auth/src/index.ts:103
DNSid Web Bot Auth signing, directory serving, and verification profile.
Signs outbound requests with the agent’s Ed25519 operational key per
RFC 9421 (tag web-bot-auth) and serves the signed key directory that
verifiers fetch to resolve the signature’s key. Verification-only instances
need an identity resolver and SSRF-safe discovery transport, not a local key.
Example
Section titled “Example”const profile = createWebBotAuthProfile({ domain: 'agent.example', keyProvider: myEd25519KeyProvider,});
const signed = await profile.createWebBotAuthSignedRequest( new Request('https://api.example/v1/items', { method: 'GET' }),);await fetch(signed);Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new WebBotAuthProfile(opts): WebBotAuthProfile;Defined in: web-bot-auth/src/index.ts:133
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Throws
Section titled “Throws”ArgumentError If opts.domain is not a valid agent FQDN.
Methods
Section titled “Methods”createWebBotAuthSignedRequest()
Section titled “createWebBotAuthSignedRequest()”createWebBotAuthSignedRequest(req, opts?): Promise<Request>;Defined in: web-bot-auth/src/index.ts:166
Returns a copy of req carrying a Web Bot Auth signature (tag web-bot-auth).
Covers @authority and keyed signature-agent, plus content-digest
when content is supplied (a SHA-256 Content-Digest header is added).
The signature includes a nonce,
created/expires timestamps, and the operational key’s JWK thumbprint as keyid.
The original request is not modified.
Parameters
Section titled “Parameters”Request
Outbound request to sign.
Per-request overrides for covered components and TTL.
Returns
Section titled “Returns”Promise<Request>
A new signed Request.
Throws
Section titled “Throws”ArgumentError If the operational key is not Ed25519, the resolved Signature-Agent URI is invalid, or an additional component identifier is invalid.
serveHttpMessageSignaturesDirectory()
Section titled “serveHttpMessageSignaturesDirectory()”serveHttpMessageSignaturesDirectory(req): Promise<Response>;Defined in: web-bot-auth/src/index.ts:217
Builds the signed key directory response for HTTP_MESSAGE_SIGNATURES_DIRECTORY_PATH.
The JSON body lists the agent’s public operational key as a JWK. The
response is signed with tag http-message-signatures-directory, covering
the requesting authority, Content-Type, Cache-Control, and Content-Digest.
Parameters
Section titled “Parameters”Request
Incoming directory request; its @authority is bound into the signature.
Returns
Section titled “Returns”Promise<Response>
A 200 response with media type HTTP_MESSAGE_SIGNATURES_DIRECTORY_MEDIA_TYPE.
Throws
Section titled “Throws”ArgumentError If the operational key is not Ed25519.
verifyWebBotAuthSignedRequest()
Section titled “verifyWebBotAuthSignedRequest()”verifyWebBotAuthSignedRequest(req, opts?): Promise<VerifiedDomain>;Defined in: web-bot-auth/src/index.ts:252
Verifies request, signed directory, and DNSid ku binding. Does not grant permissions. requiredComponents enforces extra application coverage before discovery. Without consumeNonce, time-valid requests can be replayed.
Parameters
Section titled “Parameters”Request
WebBotAuthVerificationOptions = {}
Returns
Section titled “Returns”Promise<VerifiedDomain>
fromIdentityManager()
Section titled “fromIdentityManager()”static fromIdentityManager(identityManager, webBotAuth?): WebBotAuthProfile;Defined in: web-bot-auth/src/index.ts:109
Builds a profile from a signing identity manager, reusing its domain and key provider.
Parameters
Section titled “Parameters”identityManager
Section titled “identityManager”SigningIdentityManager & RefreshingIdentityResolver
Manager whose domain and operational key provider back the profile.
webBotAuth?
Section titled “webBotAuth?”Optional Web Bot Auth configuration overrides.
Returns
Section titled “Returns”Interfaces
Section titled “Interfaces”SignatureAgentConfig
Section titled “SignatureAgentConfig”Defined in: web-bot-auth/src/index.ts:41
Signature-Agent discovery configuration.
Properties
Section titled “Properties”optional uri?: string;Defined in: web-bot-auth/src/index.ts:43
Direct HTTPS key directory endpoint.
WebBotAuthConfig
Section titled “WebBotAuthConfig”Defined in: web-bot-auth/src/index.ts:47
Profile-level Web Bot Auth configuration. All members are optional; defaults are noted per member.
Properties
Section titled “Properties”clockSkew?
Section titled “clockSkew?”optional clockSkew?: number;Defined in: web-bot-auth/src/index.ts:57
Allowed verification clock skew in seconds. Default: 5. Never permits future directory creation.
directorySignatureTTL?
Section titled “directorySignatureTTL?”optional directorySignatureTTL?: number;Defined in: web-bot-auth/src/index.ts:55
Directory-signature lifetime in seconds, including up to five seconds of backdating. Defaults to DEFAULT_DIRECTORY_SIGNATURE_TTL_SECONDS.
directoryURL?
Section titled “directoryURL?”optional directoryURL?: string;Defined in: web-bot-auth/src/index.ts:51
Deprecated
Section titled “Deprecated”Use signatureAgent.uri. Also a direct HTTPS directory endpoint.
signatureAgent?
Section titled “signatureAgent?”optional signatureAgent?: SignatureAgentConfig;Defined in: web-bot-auth/src/index.ts:49
Signature-Agent URI. Defaults to the well-known directory URL at the local domain.
signatureTTL?
Section titled “signatureTTL?”optional signatureTTL?: number;Defined in: web-bot-auth/src/index.ts:53
Request-signature lifetime in seconds. Defaults to DEFAULT_WEB_BOT_AUTH_SIGNATURE_TTL_SECONDS.
WebBotAuthProfileOptions
Section titled “WebBotAuthProfileOptions”Defined in: web-bot-auth/src/index.ts:61
Constructor options for WebBotAuthProfile.
Properties
Section titled “Properties”discoveryFetch?
Section titled “discoveryFetch?”optional discoveryFetch?: WebBotAuthDiscoveryFetch;Defined in: web-bot-auth/src/index.ts:69
Required for verification. Must enforce Web PKI and public-address connection pinning.
domain?
Section titled “domain?”optional domain?: string;Defined in: web-bot-auth/src/index.ts:63
Agent FQDN the profile signs for (e.g. agent.example). Required for signing; normalized on construction.
identityResolver?
Section titled “identityResolver?”optional identityResolver?: RefreshingIdentityResolver;Defined in: web-bot-auth/src/index.ts:67
Required for DNSid WBA verification; acceptance is enforced on every invocation.
keyProvider?
Section titled “keyProvider?”optional keyProvider?: KeyProvider;Defined in: web-bot-auth/src/index.ts:65
Key provider holding the agent’s Ed25519 operational key. Required for signing.
webBotAuth?
Section titled “webBotAuth?”optional webBotAuth?: WebBotAuthConfig;Defined in: web-bot-auth/src/index.ts:71
Optional Web Bot Auth configuration overrides.
WebBotAuthSigningOptions
Section titled “WebBotAuthSigningOptions”Defined in: web-bot-auth/src/index.ts:75
Per-request overrides for WebBotAuthProfile.createWebBotAuthSignedRequest.
Properties
Section titled “Properties”additionalComponents?
Section titled “additionalComponents?”optional additionalComponents?: ComponentIdentifier[];Defined in: web-bot-auth/src/index.ts:77
Extra covered components appended to @authority, keyed signature-agent, and content-digest when supplied. Duplicates are ignored; nested signing is unsupported.
optional ttl?: number;Defined in: web-bot-auth/src/index.ts:79
Overrides WebBotAuthConfig.signatureTTL for this request (seconds).
WebBotAuthVerificationOptions
Section titled “WebBotAuthVerificationOptions”Defined in: web-bot-auth/src/verify.ts:16
Extends
Section titled “Extends”Properties
Section titled “Properties”allowSignatureAgentDomain?
Section titled “allowSignatureAgentDomain?”optional allowSignatureAgentDomain?: boolean;Defined in: web-bot-auth/src/verify.ts:20
Explicit permission to use the signed Signature-Agent host as signer identity. Default: false.
consumeNonce?
Section titled “consumeNonce?”optional consumeNonce?: (entry, signal) => Promise<boolean>;Defined in: web-bot-auth/src/verify.ts:30
Atomically consume (domain, keyid, nonce), retaining through retainUntil. False rejects reuse; errors fail closed. Without this policy, valid requests can be replayed.
Parameters
Section titled “Parameters”string
string
retainUntil
Section titled “retainUntil”Date
signerDomain
Section titled “signerDomain”string
signal
Section titled “signal”AbortSignal
Returns
Section titled “Returns”Promise<boolean>
discovery?
Section titled “discovery?”optional discovery?: object;Defined in: web-bot-auth/src/verify.ts:22
Optional trusted endpoint constraint. Must match the covered Signature-Agent endpoint and signerDomain.
uri: string;peerCert?
Section titled “peerCert?”optional peerCert?: TLSCertificate;Defined in: web-bot-auth/src/verify.ts:26
Current application peer, never the directory endpoint certificate.
requiredComponents?
Section titled “requiredComponents?”optional requiredComponents?: ComponentIdentifier[];Defined in: web-bot-auth/src/verify.ts:24
Extra request coverage required by application policy, including exact component parameters.
signal?
Section titled “signal?”optional signal?: AbortSignal;Defined in: protocol/src/verification-budget.ts:6
Inherited from
Section titled “Inherited from”signerDomain?
Section titled “signerDomain?”optional signerDomain?: string;Defined in: web-bot-auth/src/verify.ts:18
Trusted expected signer. Discovery cannot delegate to another host.
timeoutMs?
Section titled “timeoutMs?”optional timeoutMs?: number;Defined in: protocol/src/verification-budget.ts:5
Overall invocation budget, including all discovery and evidence. Default: 30 seconds.
Inherited from
Section titled “Inherited from”Type Aliases
Section titled “Type Aliases”WebBotAuthDiscoveryFetch
Section titled “WebBotAuthDiscoveryFetch”type WebBotAuthDiscoveryFetch = (request) => Promise<Response>;Defined in: web-bot-auth/src/verify.ts:14
Trusted transport must validate Web PKI and pin connections to public DNS addresses. It must never follow redirects, honor cancellation, disable decompression, and preserve received bytes/headers. Every call requires fresh acquisition: honor cache: ‘no-store’ and Cache-Control: no-cache. Never return a cached directory without upstream revalidation. Any upstream cache must enforce original RFC 9111 age/freshness itself and reject reuse without sufficient metadata. Associate keys with normalized discovery URLs and thumbprints; newer resolutions replace older key sets (signed proofs ordered by created). Failed refreshes must not evict evidence or extend freshness. Do not inject ordinary fetch on a server.
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”Promise<Response>
Variables
Section titled “Variables”DEFAULT_DIRECTORY_SIGNATURE_TTL_SECONDS
Section titled “DEFAULT_DIRECTORY_SIGNATURE_TTL_SECONDS”const DEFAULT_DIRECTORY_SIGNATURE_TTL_SECONDS: 300 = 300;Defined in: web-bot-auth/src/index.ts:38
Default directory-signature lifetime (seconds), including backdating.
DEFAULT_WEB_BOT_AUTH_SIGNATURE_TTL_SECONDS
Section titled “DEFAULT_WEB_BOT_AUTH_SIGNATURE_TTL_SECONDS”const DEFAULT_WEB_BOT_AUTH_SIGNATURE_TTL_SECONDS: 60 = 60;Defined in: web-bot-auth/src/index.ts:36
Default request-signature lifetime (seconds) when no TTL is configured.
HTTP_MESSAGE_SIGNATURES_DIRECTORY_MEDIA_TYPE
Section titled “HTTP_MESSAGE_SIGNATURES_DIRECTORY_MEDIA_TYPE”const HTTP_MESSAGE_SIGNATURES_DIRECTORY_MEDIA_TYPE: "application/http-message-signatures-directory+json" = 'application/http-message-signatures-directory+json';Defined in: web-bot-auth/src/index.ts:34
Media type of the key directory document.
HTTP_MESSAGE_SIGNATURES_DIRECTORY_PATH
Section titled “HTTP_MESSAGE_SIGNATURES_DIRECTORY_PATH”const HTTP_MESSAGE_SIGNATURES_DIRECTORY_PATH: "/.well-known/http-message-signatures-directory" = '/.well-known/http-message-signatures-directory';Defined in: web-bot-auth/src/index.ts:32
Well-known path where the agent’s HTTP message signatures key directory is served.
HTTP_MESSAGE_SIGNATURES_DIRECTORY_TAG
Section titled “HTTP_MESSAGE_SIGNATURES_DIRECTORY_TAG”const HTTP_MESSAGE_SIGNATURES_DIRECTORY_TAG: "http-message-signatures-directory" = 'http-message-signatures-directory';Defined in: web-bot-auth/src/index.ts:30
RFC 9421 tag parameter identifying a signed key-directory response.
WEB_BOT_AUTH_SIGNATURE_LABEL
Section titled “WEB_BOT_AUTH_SIGNATURE_LABEL”const WEB_BOT_AUTH_SIGNATURE_LABEL: "sig1" = 'sig1';Defined in: web-bot-auth/src/index.ts:26
Signature label used for the Web Bot Auth member in the Signature/Signature-Input dictionaries.
WEB_BOT_AUTH_TAG
Section titled “WEB_BOT_AUTH_TAG”const WEB_BOT_AUTH_TAG: "web-bot-auth" = 'web-bot-auth';Defined in: web-bot-auth/src/index.ts:28
RFC 9421 tag parameter identifying a Web Bot Auth request signature.
Functions
Section titled “Functions”createWebBotAuthProfile()
Section titled “createWebBotAuthProfile()”function createWebBotAuthProfile(opts): WebBotAuthProfile;Defined in: web-bot-auth/src/index.ts:283
Creates a WebBotAuthProfile for an agent domain.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Example
Section titled “Example”const profile = createWebBotAuthProfile({ domain: 'agent.example', keyProvider: myEd25519KeyProvider,});const signed = await profile.createWebBotAuthSignedRequest( new Request('https://api.example/v1/items'),);await fetch(signed);Throws
Section titled “Throws”ArgumentError If opts.domain is not a valid agent FQDN.
wbaDirectoryJwkFromPublicKey()
Section titled “wbaDirectoryJwkFromPublicKey()”function wbaDirectoryJwkFromPublicKey(key): Promise<DnsIdJWK>;Defined in: web-bot-auth/src/index.ts:295
Converts an operational key JWK into its public directory form: private
members stripped, kid set to the JWK thumbprint, with use: 'sig'.
Parameters
Section titled “Parameters”Ed25519 JWK (public or private) to publish.
Returns
Section titled “Returns”Promise<DnsIdJWK>
The public JWK as listed in the key directory’s keys array.
Throws
Section titled “Throws”ArgumentError If the key is not Ed25519.