Skip to content

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 signers and verifiers together. This draft-01 profile cannot interoperate with the draft-00 profile shipped in 0.37.

  • Remove signatureAgent.type and imports of SignatureAgentType. Signature-Agent now contains a direct HTTPS directory URL without parameters; headers with ;type=directory or ;type=jwks_uri are rejected.
  • Set custom signatureAgent.uri, directoryURL, and trusted discovery.uri values to the full directory URL, not just its origin. The default is https://{domain}/.well-known/http-message-signatures-directory; an explicit origin-only URL now addresses /.
  • Directory JWKs omit alg by default. If supplied, it must be Ed25519; ed25519 and EdDSA are rejected. The HTTP signature alg parameter remains ed25519.
Terminal window
npm install @dnsid-ai/web-bot-auth @dnsid-ai/protocol

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.

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.

  • signatureAgent.uri: the HTTPS URL advertised in Signature-Agent. Defaults to https://{domain}/.well-known/http-message-signatures-directory. For a custom endpoint, set the full URL.
  • directoryURL — deprecated alias for a direct HTTPS directory endpoint. Use signatureAgent.uri instead.
  • 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.

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.

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);

new WebBotAuthProfile(opts): WebBotAuthProfile;

Defined in: web-bot-auth/src/index.ts:133

WebBotAuthProfileOptions

WebBotAuthProfile

ArgumentError If opts.domain is not a valid agent FQDN.

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.

Request

Outbound request to sign.

WebBotAuthSigningOptions = {}

Per-request overrides for covered components and TTL.

Promise<Request>

A new signed Request.

ArgumentError If the operational key is not Ed25519, the resolved Signature-Agent URI is invalid, or an additional component identifier is invalid.

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.

Request

Incoming directory request; its @authority is bound into the signature.

Promise<Response>

A 200 response with media type HTTP_MESSAGE_SIGNATURES_DIRECTORY_MEDIA_TYPE.

ArgumentError If the operational key is not Ed25519.

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.

Request

WebBotAuthVerificationOptions = {}

Promise<VerifiedDomain>

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.

SigningIdentityManager & RefreshingIdentityResolver

Manager whose domain and operational key provider back the profile.

WebBotAuthConfig

Optional Web Bot Auth configuration overrides.

WebBotAuthProfile

Defined in: web-bot-auth/src/index.ts:41

Signature-Agent discovery configuration.

optional uri?: string;

Defined in: web-bot-auth/src/index.ts:43

Direct HTTPS key directory endpoint.


Defined in: web-bot-auth/src/index.ts:47

Profile-level Web Bot Auth configuration. All members are optional; defaults are noted per member.

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.

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.

optional directoryURL?: string;

Defined in: web-bot-auth/src/index.ts:51

Use signatureAgent.uri. Also a direct HTTPS directory endpoint.

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.

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.


Defined in: web-bot-auth/src/index.ts:61

Constructor options for WebBotAuthProfile.

optional discoveryFetch?: WebBotAuthDiscoveryFetch;

Defined in: web-bot-auth/src/index.ts:69

Required for verification. Must enforce Web PKI and public-address connection pinning.

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.

optional identityResolver?: RefreshingIdentityResolver;

Defined in: web-bot-auth/src/index.ts:67

Required for DNSid WBA verification; acceptance is enforced on every invocation.

optional keyProvider?: KeyProvider;

Defined in: web-bot-auth/src/index.ts:65

Key provider holding the agent’s Ed25519 operational key. Required for signing.

optional webBotAuth?: WebBotAuthConfig;

Defined in: web-bot-auth/src/index.ts:71

Optional Web Bot Auth configuration overrides.


Defined in: web-bot-auth/src/index.ts:75

Per-request overrides for WebBotAuthProfile.createWebBotAuthSignedRequest.

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).


Defined in: web-bot-auth/src/verify.ts:16

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.

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.

string

string

Date

string

AbortSignal

Promise<boolean>

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;

optional peerCert?: TLSCertificate;

Defined in: web-bot-auth/src/verify.ts:26

Current application peer, never the directory endpoint certificate.

optional requiredComponents?: ComponentIdentifier[];

Defined in: web-bot-auth/src/verify.ts:24

Extra request coverage required by application policy, including exact component parameters.

optional signal?: AbortSignal;

Defined in: protocol/src/verification-budget.ts:6

VerificationOptions.signal

optional signerDomain?: string;

Defined in: web-bot-auth/src/verify.ts:18

Trusted expected signer. Discovery cannot delegate to another host.

optional timeoutMs?: number;

Defined in: protocol/src/verification-budget.ts:5

Overall invocation budget, including all discovery and evidence. Default: 30 seconds.

VerificationOptions.timeoutMs

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.

Request

Promise<Response>

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.


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.


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.


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.


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.

function createWebBotAuthProfile(opts): WebBotAuthProfile;

Defined in: web-bot-auth/src/index.ts:283

Creates a WebBotAuthProfile for an agent domain.

WebBotAuthProfileOptions

WebBotAuthProfile

const profile = createWebBotAuthProfile({
domain: 'agent.example',
keyProvider: myEd25519KeyProvider,
});
const signed = await profile.createWebBotAuthSignedRequest(
new Request('https://api.example/v1/items'),
);
await fetch(signed);

ArgumentError If opts.domain is not a valid agent FQDN.


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'.

DnsIdJWK

Ed25519 JWK (public or private) to publish.

Promise<DnsIdJWK>

The public JWK as listed in the key directory’s keys array.

ArgumentError If the key is not Ed25519.