View as Markdown

Identify · Guide

Sign your agent's requests

Sign every request your agent sends so a site can name it. Web Bot Auth is an IETF draft built on HTTP Message Signatures (RFC 9421): each request carries a signature over its method, host and path, and a Signature-Agent header that says where the public key is published. Provenance hosts that directory for you. Signing is free on every plan.

Before you begin: register your agent with a category, and keep its Ed25519 private key in your secret store.

This package isn't on npm yet. Until then, every request in these docs runs over HTTP against the sandbox.

With access to the private Provenance repository, which your Provenance contact grants, install from it:

git clone https://github.com/michaelnbane-jpg/provenance.git provenance
cd provenance && pnpm install && pnpm build
node scripts/check-publishable.mjs --out ../provenance-packs
cd ../your-project
npm install ../provenance-packs/provenanceauth-sdk-1.0.0.tgz ../provenance-packs/provenanceauth-agent-adapters-1.0.0.tgz

1. Wrap your agent's fetch

signedFetch signs each request with a fresh nonce and a 60-second lifetime. With agentId, the Signature-Agent header points at your agent's hosted directory.

import { signedFetch } from "@provenanceauth/agent-adapters";

const agentFetch = signedFetch({
  key: JSON.parse(process.env.AGENT_SIGNING_KEY!), // the private JWK (with d)
  agentId: "agt_01M5T7VVC8FGYV5V4TGZSFATGN",
  apiBaseUrl: process.env.PROVENANCE_API,
});
const page = await agentFetch("https://quillstack.example/products/linen-a5");

Each request then carries three headers:

Signature-Agent: sig1="https://api.provenanceauth.com/v1/public/agents/agt_01M5T7VVC8FGYV5V4TGZSFATGN/directory";type=jwks_uri
Signature-Input: sig1=("@method" "@authority" "@path" "signature-agent";key="sig1");created=1761419772;expires=1761419832;keyid="lyRUHRS4LQGoXlD_Oaa0IK6BCBsxD6DdTLQRUUK3JW4";alg="ed25519";nonce="Q2F0cy1hbmQtZG9ncy1hcmUtZnJpZW5kcw==";tag="web-bot-auth"
Signature: sig1=:9uYcxZ0bOzWwI1XyAm2hA4v1sQYp8qkKpZbL0sX3bQ8w9hK5ZtB7N1hX2cVnK6d0Wm3eT4rYu8iO2pQ5sD7fGA==:

The signature covers @method and @path as well as the draft's minimum, @authority and the Signature-Agent member, so a captured signature can't be replayed against another page or method.

2. Combine it with approvals

When a site answers with a ProvenanceIntent challenge, checkoutFetch gets the person's approval and retries. Give it the signed fetch so both the first request and the retry are signed:

import { checkoutFetch, signedFetch } from "@provenanceauth/agent-adapters";

const shop = checkoutFetch({ client: prov, deviceId, agentSessionId: "pantry-1", agentId, fetch: signedFetch({ key, agentId }) });

3. Rotate and revoke keys

Add the new key, switch the agent to it, then revoke the old one. An agent publishes up to five active keys.

export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
export AGENT_ID=$(curl -s $PROVENANCE_API/v1/mandate/agents -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" -d '{ "name": "Pantry Pal", "category": "shopping_agent" }' | jq -r .id)

curl -s $PROVENANCE_API/v1/identify/agents/$AGENT_ID/signing_keys \
  -H "Authorization: Bearer $PROVENANCE_KEY"
{ "object": "list", "data": [], "has_more": false, "next_cursor": null }

Revoke with DELETE /v1/identify/agents/{id}/signing_keys/{key_id}. Suspending the agent empties its directory, so every one of its signatures stops verifying within five minutes.

4. Publish under your own domain instead

Any Web Bot Auth verifier can resolve three kinds of Signature-Agent member. Pass signatureAgent instead of agentId to use your own:

TypeThe value isExample
directoryYour origin; the keys are at its /.well-known/http-message-signatures-directoryhttps://agents.example
jwks_uriA JWK Set URLthe Provenance-hosted directory
cimdA Signature Agent Card that names the keyshttps://api.provenanceauth.com/v1/public/agents/agt_…/card

Errors you might see

SymptomCauseFix
409 signing_key_limit_reachedThe agent already publishes five keysRevoke a key you've rotated away from.
409 signing_key_existsThat public key is already registeredUse the existing key.
400 parameter_invalid on jwkThe JWK has a private part or isn't Ed25519Send kty, crv and x only.
Sites see signature_expiredThe agent's clock is off, or a request was retried after a minuteSign each attempt again; keep the clock in sync.

See also