View as Markdown

Identify · Guide

Verify signed agents

Run the Identify middleware in front of your site so every request gets a traffic assessment without a network call per request. The middleware verifies Web Bot Auth signatures, applies your traffic policy and reports decisions in batches.

Before you begin: create a secret key for your account in the console, and install the package.

This package isn't on npm yet. This package isn't on PyPI 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-rails-1.0.0.tgz ../provenance-packs/provenanceauth-identify-1.0.0.tgz
git clone https://github.com/michaelnbane-jpg/provenance.git provenance
pip install ./provenance/python/sdk ./provenance/python/identify

Availability: @provenanceauth/identify and provenanceauth-identify are available to beta customers. The Node package runs in Node 18 and later, Cloudflare Workers and Vercel Edge; the Python package in Python 3.10 and later.

Pricing: the middleware is free on every plan. The policy bundle, the local rules and the decisions it reports aren't billed and don't count toward an allowance. Only hosted checks are metered; prices and allowances are on the pricing page.

1. Load the policy bundle at boot

The bundle holds your route map, traffic policy and lists, Provenance's token keys and the directories of agents registered with Provenance. The middleware refreshes it with its ETag every five minutes and keeps the last good copy when a refresh fails.

import { Identify } from "@provenanceauth/identify";

export const identify = new Identify({ apiKey: process.env.PROVENANCE_KEY });
await identify.ready();

Each bundle request and report batch carries a Provenance-Origin header naming the sites the middleware has served (scheme, host and port only), so your account's usage shows where Identify runs.

Before any bundle has loaded, the middleware answers 503 (failMode: "closed", the default). Pass failMode: "open" to serve and log instead, or pass a bundle you saved at deploy time.

2. Add the middleware

import { identifyExpress } from "@provenanceauth/identify/express";

app.set("trust proxy", true); // so req.ip is the client, not your load balancer
app.use(identifyExpress(identify, { orderFor: (req) => cartToOrder(req) }));
app.get("/products/:id", (req, res) => res.json({ verdict: req.identify }));

The middleware answers three outcomes itself and passes everything else on with the verdict attached:

DecisionYour site answers
block403 with an application/problem+json body naming the rule
rate_limit, over the window429 with Retry-After
require_intent, no valid approval yet401 with WWW-Authenticate: ProvenanceIntent (Require a human)

A challenge decision calls your onChallenge hook, so you can hand the request to the challenge you already run.

Middleware options

Every adapter (Express, Fastify, Next.js, fetch and both edge templates) takes the same options; the Python middleware takes them in snake_case.

OptionWhat it does
orderFor(req)The order for a checkout request (your own cart), so require_intent binds the exact order.
approvals"protocol" (default): the ProvenanceIntent 401 only. "hosted": on an order that needs approval, assess it, open the approval and answer every agent with approve_url, status_url and a plain message (five-minute checkout).
customerFor(req)With "hosted": your signed-in customer's { phone } or { email }, so we send them the approval instead of the agent relaying it.
merchantNameThe store name the shopper sees (default: your Identify settings, else the host).
onUnavailableWith "hosted", when the API can't be reached: "protocol" (default) answers the ProvenanceIntent 401, "block" answers 503. Never an allow; the verdict's decision.reason is approvals_unavailable.
newPasskeyWhat a new passkey needs on approvals this middleware opens: "step_up_contact", "accept", "require_existing", or { setting, minPasskeyAge, noContact } (default: your checkout rules).
onChallenge, onVerdict, skip, ipOf, urlOf, bodyOfHooks for a challenge decision, every verdict, requests to leave alone, the client address, the URL and a protocol route's body.
networkDirectoriesThe card network agent programs' key directories you trust: [{ program, url, type? }]. Card network agents verify only against these.
operatorKind(req)Reads how a signed agent is run (direct or intermediary) from what your edge passes, when your edge provider labels it. Return null when you don't know.

3. Read the verdict

app.post("/checkout", (req, res) => {
  const v = req.identify;
  if (v.class === "signed_agent") log.info({ agent: v.agent.name, operator: v.agent.operator, person: v.human?.pseudonym });
  // …
});

A verified signature names the agent. For an agent registered with Provenance you also get its id, category and operator; for any other directory, operator is the directory's host.

4. Set your route map and origins

The route map turns paths into the actions your policy reads. Origins are the sites an agent's approval may name as its audience.

export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5

curl -s -X PUT $PROVENANCE_API/v1/identify/settings/site \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "origins": ["https://quillstack.example"],
    "display_name": "Quillstack",
    "route_map": [
      { "path": "/checkout*", "action": "checkout" },
      { "method": "POST", "path": "/account/*", "action": "account_change" },
      { "path": "/*", "action": "browse" }
    ]
  }'
{
  "object": "identify_config",
  "origins": ["https://quillstack.example"],
  "display_name": "Quillstack",
  "fail_mode": "closed",
  "decisions_ttl_days": 30,
  "pseudonyms": "on",
  "is_default": false
}

5. Check from your server instead

When you can't run the middleware, check each request with POST /v1/identify/assessments. Send the client address in ip if you have a per-address rule; it is used for that check and never stored. The verdict carries response, the answer to send instead of serving the request, or null.

Hosted checks are metered per 1,000 past your monthly allowance, and each one adds the server-side signals: the network's record of a verified agent, your risk providers' answers and the person's revocation check.

Card network agents

Card network agent programs sign their agents' requests with HTTP message signatures (RFC 9421) under their own tags. Identify verifies three of them beside Web Bot Auth's web-bot-auth:

Tagagent.program.nameagent.purpose
agent-browser-authvisa_tapbrowse
agent-payer-authvisa_tappay
agent-pay-auth (any case)mastercard_agent_paypay

These signatures verify only against the key directories you configure, never a URL the request names. With no directory for a program, its signatures read unverified with network_directory_unconfigured; a covered Signature-Agent that names another host is signature_invalid with network_directory_mismatch.

  • Window: created and expires at most 8 minutes (480 seconds) apart, instead of Web Bot Auth's 60-second age. All six fields are required, the nonce included; a repeated nonce inside the window is signature_replayed.
  • Algorithms: ed25519 or rsa-pss-sha256 (RSA keys of 2048 bits or more).
  • Directories: with the middleware, pass networkDirectories. type is directory (an origin), jwks_uri (a JWK Set) or key_lookup (a key store answering GET <url>?keyID=<keyid>). A self-hosted API reads the same list from its configuration.
const identify = new Identify({
  apiKey: process.env.PROVENANCE_KEY,
  networkDirectories: [{ program: "mastercard_agent_pay", url: "https://keys.network.example/" }],
});

A verified card network signature adds agent.program: the program, what it signed for, and whether the program's body objects carry the signature's nonce (objects.consumer, objects.payment: match, mismatch or null). Their contents are never read or kept. signature.method is network. A program isn't an agent platform, so request.agent.platform stays as it was.

Every verified signature also carries agent.purpose, and one whose key came from a Signature Agent card carries agent.card (its name and site).

Traffic policy factWhat it reads
agent.network_programThe card network agent program
agent.signed_forWhat the agent signed for
agent.card_nameThe name on its Signature Agent card
agent.operator_kindHow it is run, when your edge passes it

A traffic backtest counts a decision recorded before these facts as unscored for a rule that names one.

A signature under any other tag stays out of verification and adds the signal signature_unrecognized_tag.

Errors you might see

SymptomCauseFix
Every request answers 503No bundle has loaded yet and the fail mode is closedAwait identify.ready() at boot, check the key, or set failMode: "open".
signals has unknown_signature_agentThe agent's directory didn't resolve or doesn't list its keyNothing to fix on your side: the request isn't attributed. The description says why.
signals has signature_invalid behind a proxyThe proxy rewrote the host or path the agent signedForward the original Host and path, or verify at the proxy.
401 authentication_required on the bundleThe middleware has no secret keyPass apiKey from your secret store.
402 trial_ended on a hosted checkA Free account used its trial API calls, or the trial endedChoose a plan in Settings → Plan & usage. The middleware and its reports keep working.

See also