View as Markdown

Identify · Guide

Run Identify at the edge

Run Identify in front of your origin, at the edge, so a block, a rate limit or an approval challenge never reaches your servers. The templates use WebCrypto only and decide from the same policy bundle as the middleware.

Before you begin: create a secret key for your account in the console, and install the package in your Worker or Next.js project.

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-rails-1.0.0.tgz ../provenance-packs/provenanceauth-identify-1.0.0.tgz

Availability: @provenanceauth/identify is available to beta customers. The templates are in the package's templates/ folder.

1. Deploy the Cloudflare Worker

// src/index.ts
import { identifyWorker } from "@provenanceauth/identify/edge/cloudflare";

export default identifyWorker({ origin: (request) => fetch(request) });
npx wrangler secret put PROVENANCE_KEY
npx wrangler deploy

The Worker reads the client address from CF-Connecting-IP, which Cloudflare sets. A request that passes reaches your origin with an X-Provenance-Identify header, such as class=signed_agent;decision=allow;agent=agt_01M5T7VVC8FGYV5V4TGZSFATGN. It names no person.

2. Read Cloudflare's bot score

When your zone has Bot Management, the Worker reports its score as vendor_score next to Identify's own bot_score, never merged with it:

{ "vendor_score": { "vendor": "cloudflare", "status": "ok", "score": 0.99, "raw": 2 } }

score maps Cloudflare's 1 (automated) to 99 (human) onto 1 to 0. A zone without Bot Management reports status: "absent". Write a rule on vendor_score if you want to act on it; a signed agent stays signed_agent whatever the score.

3. Or use Vercel Edge Middleware

// middleware.ts
import { identifyVercel } from "@provenanceauth/identify/edge/vercel";

export default identifyVercel();
export const config = { matcher: "/((?!_next/static|favicon.ico).*)" };

Set PROVENANCE_KEY in the project's environment. Vercel exposes no bot score, so vendor_score is absent unless you pass vendorScore, for example Fingerprint with your own key (add a vendor score).

4. Choose the fail mode

The edge templates default to failMode: "open": before the first bundle loads, requests pass and are logged, so the edge never takes your site down on its own. Pass failMode: "closed" to answer 503 instead. After the first load, the last good bundle keeps deciding even when a refresh fails, and decisions are reported with bundle_stale.

Errors you might see

SymptomCauseFix
Every verdict has bundle_staleThe Worker can't reach the API to refresh its bundleCheck PROVENANCE_KEY and PROVENANCE_API.
vendor_score.status is absent on CloudflareThe zone has no Bot ManagementNothing to fix; Identify's own bot_score still applies.
Signed agents fail behind the WorkerA route rewrote the host or path before the Worker ranRun the Worker on the original hostname and path.

See also