@valiron/sdk 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/bin/valiron-card.mjs +211 -0
- package/dist/card.d.ts +565 -0
- package/dist/card.js +722 -0
- package/dist/clients.js +2 -2
- package/dist/edge.d.ts +87 -0
- package/dist/edge.js +164 -0
- package/dist/edgeGate.d.ts +146 -0
- package/dist/edgeGate.js +230 -0
- package/dist/edgeGateVerify.d.ts +146 -0
- package/dist/edgeGateVerify.js +243 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/middleware.d.ts +2 -0
- package/dist/middleware.js +6 -3
- package/dist/operatorSdk.d.ts +8 -0
- package/dist/operatorSdk.js +8 -0
- package/docs/API-REFERENCE.md +59 -80
- package/docs/CLOUDFLARE-GATE-MIDDLEWARE.md +196 -0
- package/docs/CRAWLER-PROTECTION.md +509 -25
- package/docs/DASHBOARD.md +72 -214
- package/docs/E2E-MIDDLEWARE-INTEGRATION.md +9 -46
- package/docs/ERRORS.md +3 -11
- package/docs/PROVIDER-IDENTITY.md +1 -1
- package/docs/QUICKSTART.md +7 -22
- package/docs/README.md +10 -9
- package/docs/SDK-REFERENCE.md +51 -7
- package/docs/SECURITY-UPGRADE-2026-10-31.md +3 -3
- package/docs/llms.txt +19 -14
- package/examples/cloudflare-gate-worker/README.md +198 -0
- package/examples/cloudflare-gate-worker/package.json +20 -0
- package/examples/cloudflare-gate-worker/worker.ts +309 -0
- package/examples/cloudflare-gate-worker/wrangler.toml +46 -0
- package/examples/cloudflare-worker/package.json +8 -0
- package/examples/cloudflare-worker/worker.ts +495 -0
- package/examples/cloudflare-worker/wrangler.toml +57 -0
- package/package.json +34 -4
- package/docs/AGENT-READY-APIS.md +0 -294
package/docs/API-REFERENCE.md
CHANGED
|
@@ -4,7 +4,9 @@ See the [security upgrade guide](SECURITY-UPGRADE-2026-10-31.md) before upgradin
|
|
|
4
4
|
|
|
5
5
|
[Valiron Crawler Protection](./CRAWLER-PROTECTION.md) runs as a standalone HTTP gateway or in-process middleware with shared admission state. Its private per-deployment work API lets other server languages acquire/release database capacity; it is not part of this hosted public REST API and must remain on private authenticated ingress. The package includes its protocol contract. The website dashboard validates/exports account-scoped configuration without deploying protection and displays optional runtime-reported crawler analytics. Its exports belong to the `@valiron/crawler-protection` package, not `@valiron/sdk`.
|
|
6
6
|
|
|
7
|
-
SDK 0.
|
|
7
|
+
Crawler SDK 0.3.0+ requires an operator API key for a Pro account with the Crawler Protection add-on (or Enterprise) and account-bound activation via `activateCrawlerProtection()` before constructing its runtime. Activation uses a short-lived local lease, refreshed in the background. Each protected HTTP request requires hosted monthly quota admission; database operations are not counted again. See the crawler guide for revocation, outage and recovery behavior.
|
|
8
|
+
|
|
9
|
+
For the current crawler integration, install `@valiron/crawler-protection@^0.6.0`. It adds official Anthropic and Google agent/Notebook feeds alongside OpenAI support, and `crawlerAccessDefault` / `unverifiedAccess` configuration. These are customer-runtime controls, not hosted policy-deployment APIs. See [selected AI services and upgrade steps](./CRAWLER-PROTECTION.md#allow-selected-ai-services); source verification does not grant unlimited access or authorize account actions.
|
|
8
10
|
|
|
9
11
|
Machine-readable contract: [Valiron OpenAPI](https://www.valiron.co/openapi.json).
|
|
10
12
|
|
|
@@ -13,7 +15,6 @@ Base URL: `https://valiron-edge-proxy.onrender.com`
|
|
|
13
15
|
Supported integration endpoints:
|
|
14
16
|
|
|
15
17
|
- **Trust evaluation** (`/operator/agent/*`, `/operator/gate/*`, etc.) — Profile reads, runtime gate and identity-verification requests require an operator key; Only Social Graph (Icebreaker) requires Pro signal access; use `Authorization: Bearer val_op_...`.
|
|
16
|
-
- **Agent-ready wrappers** (`/wrap/:operatorId/*`) — Public agent-facing URLs created from Dashboard endpoint configs. These can enforce x402/MPP payment, optional trust checks, rate limits, and upstream forwarding.
|
|
17
18
|
|
|
18
19
|
---
|
|
19
20
|
|
|
@@ -27,20 +28,18 @@ Health and key-identity enrollment remain accessible without an operator key. En
|
|
|
27
28
|
|
|
28
29
|
Profile endpoints require operator authentication and return identity and trust summaries. They do not return raw behavioral metrics, stored-evidence links, RPC URLs, internal errors, or verification-provider records. Self and World ID responses return an allowlisted verification summary; nullifiers, credential subjects, and provider storage references are private.
|
|
29
30
|
|
|
30
|
-
Sandbox runs require an operator API key. World ID/Self profiles, wallet intelligence, the trust-gated proxy, analytics, and webhook registration are included with Free and require an operator API key. Social Graph (Icebreaker) requires Pro. Crawler Protection
|
|
31
|
+
Sandbox runs require an operator API key. World ID/Self profiles, wallet intelligence, the trust-gated proxy, analytics, and webhook registration are included with Free and require an operator API key. Social Graph (Icebreaker) requires Pro. Crawler Protection traffic insights and the edge rules simulator require Pro; enforcement at your edge or in the installed runtime requires the Crawler Protection add-on ($29.99/month on top of Pro) or Enterprise. Webhook deliveries are scoped to the operator that initiated the evaluation and the selected chain. Legacy global evaluation history and platform statistics are restricted to Valiron administrators; view your own account analytics in the dashboard.
|
|
31
32
|
|
|
32
|
-
Hosted gates, proxy forwarding, World ID enrollment and Self session creation also require a fresh registry-owner signature over the agent ID, chain, HTTP method, full destination URL and JSON body. Send `x-agent-timestamp`, `x-agent-nonce` and `x-agent-request-signature`; see the [exact signing contract](./SECURITY-UPGRADE-2026-10-31.md#hosted-
|
|
33
|
+
Hosted gates, proxy forwarding, World ID enrollment and Self session creation also require a fresh registry-owner signature over the agent ID, chain, HTTP method, full destination URL and JSON body. Send `x-agent-timestamp`, `x-agent-nonce` and `x-agent-request-signature`; see the [exact signing contract](./SECURITY-UPGRADE-2026-10-31.md#hosted-gates-and-proxy). Legacy key-registration challenges and `x-agent-session` do not authorize these routes.
|
|
33
34
|
|
|
34
35
|
## Monthly request allowance
|
|
35
36
|
|
|
36
|
-
Free includes **10,000 metered
|
|
37
|
-
Request 10,000 on Free (100,000 on Pro) is
|
|
38
|
-
|
|
39
|
-
`
|
|
40
|
-
|
|
41
|
-
the
|
|
42
|
-
protections still apply. Crossing the limit never automatically subscribes or
|
|
43
|
-
charges an account.
|
|
37
|
+
Free includes **10,000 metered Agent Access requests per account per UTC calendar month**. Pro includes **100,000**. Bot protection has its own allowance of 10,000 on Free and 100,000 on Pro. Enterprise: email founders@valiron.co.
|
|
38
|
+
Request 10,000 on Free (100,000 on Pro) is included. Active paid Pro accounts can explicitly enable additional Agent Access calls at $0.001 each. Crawler Protection and Agent Access allowances, prices and opt-ins are separate. Without an enabled agreement, subsequent calls return HTTP 429 with `code: "MONTHLY_REQUEST_LIMIT_EXCEEDED"`, `error: "upgrade_required"`, `limit`, `used`, `resetsAt` and `upgradeUrl`. Free must upgrade; Pro can enable additional calls in the dashboard or wait for the next UTC month. Crossing a limit never subscribes or opts in an account automatically. Enterprise remains available for custom terms. Feature gates, per-endpoint limits and traffic protections still apply.
|
|
39
|
+
|
|
40
|
+
`GET /operator/usage/billing` returns account-scoped Agent Access usage, allowance, additional calls and enrollment status using the dashboard session. The website's authenticated `GET /api/middleware/billing` adds the current rate; `POST /api/middleware/billing` accepts `{ "acceptedPriceId": "price_..." }` to opt in to exactly that displayed price. The crawler equivalents remain `/operator/crawlers/billing` and `/api/crawler-protection/billing`. One product's acceptance never opts in the other.
|
|
41
|
+
|
|
42
|
+
Both hosted usage responses include `used`, `included` (`null` for custom Enterprise terms), `overageRequests`, `overagesEnabled`, `needsReview`, `monthStart`, `resetsAt` and `asOf`. `charges` contains accrued request-overage estimates grouped by currency as `{ currency, amount }` entries; `amount` is a decimal string in major currency units. Empty `charges` means no accrued request overages in the current UTC month, not a zero total subscription invoice. Historical accepted terms determine these amounts; optional traffic telemetry and the currently offered rate do not. The website preserves successfully fetched usage if a current-rate lookup fails, returning `price: null` and `priceUnavailable: true`.
|
|
44
43
|
|
|
45
44
|
The shared account allowance counts admitted calls to:
|
|
46
45
|
|
|
@@ -48,11 +47,9 @@ The shared account allowance counts admitted calls to:
|
|
|
48
47
|
- `POST /operator/identity/verify`
|
|
49
48
|
- `POST /operator/trigger-sandbox/:agentId` and `/operator/trigger-sandbox-key/:agentAddress`
|
|
50
49
|
- `POST /proxy/:agentId` (available on Free within usage limits)
|
|
51
|
-
- Any configured `/wrap/:operatorId/*` request, charged to the endpoint owner.
|
|
52
50
|
|
|
53
51
|
Direct metered calls require `Authorization: Bearer val_op_...`. Gate/proxy agent identity requirements still apply.
|
|
54
|
-
|
|
55
|
-
is included in the wrapper request, not counted again. For hosted wrappers, payment validation, local rate checks and trust admission precede the monthly counter. Rejected payment, rate or trust requests do not consume the owner's monthly allowance. Once admitted, a wrapper request can still count if its upstream subsequently fails. Authentication and monthly-limit rejections do not count.
|
|
52
|
+
Authentication and monthly-limit rejections do not count.
|
|
56
53
|
Summary profile/discovery reads, identity challenges, health, account management,
|
|
57
54
|
checkout, and analytics are outside this allowance.
|
|
58
55
|
|
|
@@ -372,7 +369,7 @@ Execute real-time sandbox tests against an agent and compute a trust evaluation.
|
|
|
372
369
|
|
|
373
370
|
## POST /operator/gate/:agentId
|
|
374
371
|
|
|
375
|
-
Trust gate — combined on-chain reputation + sandbox check. Returns an allow/deny decision. Designed for protecting
|
|
372
|
+
Trust gate — combined on-chain reputation + sandbox check. Returns an allow/deny decision. Designed for protecting expensive or sensitive endpoints.
|
|
376
373
|
|
|
377
374
|
### Parameters
|
|
378
375
|
|
|
@@ -932,81 +929,63 @@ curl -H "Authorization: Bearer $VALIRON_API_KEY" -X POST "https://valiron-edge-p
|
|
|
932
929
|
```
|
|
933
930
|
|
|
934
931
|
|
|
935
|
-
##
|
|
932
|
+
## Crawler Protection telemetry (Pro with the Protection add-on / Enterprise)
|
|
936
933
|
|
|
937
|
-
|
|
934
|
+
`POST /operator/crawlers/telemetry` accepts bounded cumulative reports using a server-side operator API key. `GET /operator/crawlers/analytics` uses the dashboard operator session and returns only that account's rolling origin metrics, instance status, shared capacity and monitoring alerts. Neither endpoint accepts a caller-selected account. Both require a Pro account with the Crawler Protection add-on, or Enterprise, and return private, non-cacheable responses. Invalid snapshots return 400, authentication failures 401, plan/tenant failures 403, counter/cardinality conflicts 409, excessive reporting frequency 429 and unavailable storage 503. Duplicate or older sequences return `{ "accepted": false }` without adding counts. The first accepted report establishes a baseline. See [reporting setup and limits](./CRAWLER-PROTECTION.md#runtime-telemetry). The private work-admission API remains on customer infrastructure.
|
|
938
935
|
|
|
939
|
-
|
|
936
|
+
Usage billing: website signup and a server-side operator API key are required. Free includes 10,000 requests per product per UTC month; Pro includes 100,000 per product. An active paid Pro subscriber can separately enable additional Crawler Protection or Agent Access calls at $0.001 each. Each product has its own allowance, meter and opt-in. Without opt-in, that product stops at 100,000; Free must upgrade after 10,000. Billing uses durable hosted admission counters, not optional telemetry or every local SDK function call. SDK 0.5.0 also requires account activation for returning-browser recognition.
|
|
940
937
|
|
|
941
|
-
|
|
942
|
-
https://valiron-edge-proxy.onrender.com/wrap/{operatorId}/{path}
|
|
943
|
-
```
|
|
944
|
-
|
|
945
|
-
The wrapper matches the operator ID, path, and HTTP method to an active endpoint config. It can enforce payment, optional trust checks, rate limits, SSRF protection, upstream auth injection, and request forwarding. These controls apply only to traffic sent to this wrapper URL. Protect a public upstream with `hmac` auth and reject direct, unsigned origin traffic. See [API Scaffolding](./AGENT-READY-APIS.md#recommended-production-pattern-hmac-origin-verification).
|
|
938
|
+
## Crawler Protection traffic insights (Pro / Enterprise)
|
|
946
939
|
|
|
947
|
-
|
|
940
|
+
Passive request-log ingestion and observed-traffic analytics. These endpoints never affect customer traffic. See [Connect traffic sources](./CRAWLER-PROTECTION.md#connect-traffic-sources) for setup and data handling.
|
|
948
941
|
|
|
949
|
-
|
|
950
|
-
|--------|----------|-------------|
|
|
951
|
-
| `X-PAYMENT` | paid x402 retry | x402 payment payload returned by an x402-capable client. |
|
|
952
|
-
| `Authorization: Payment ...` | paid MPP retry | MPP payment authorization header. |
|
|
953
|
-
| `x-agent-id` | if trust enabled | Registry agent ID; this header alone cannot authorize the caller. |
|
|
954
|
-
| `x-agent-timestamp` | if trust enabled | Signed timestamp in milliseconds; accepted within 60 seconds. |
|
|
955
|
-
| `x-agent-nonce` | if trust enabled | Fresh 24–128 character URL-safe nonce; single use. |
|
|
956
|
-
| `x-agent-request-signature` | if trust enabled | Current registry-owner signature over the v2 wallet-request payload. |
|
|
957
|
-
| `x-chain` | explicit chain recommended | Selects the wrapper registry network; the signed chain must match. |
|
|
958
|
-
| `x-agent-address` | not supported by hosted trust wrappers | Use SDK middleware in your own backend when you need key/address identity support. |
|
|
942
|
+
`POST /ingest/crawler/logs/:connectionId` accepts request logs for one website. Authenticate with that connection's token as `Authorization: Bearer vcl_…`, or as `X-Amz-Firehose-Access-Key` for Amazon Data Firehose. Operator API keys and dashboard sessions are not accepted, and a connection token authorizes nothing else. The body is newline-delimited records in the connection's format (`cloudflare`, `aws_waf`, `cloudfront`, `cloudfront_realtime`, `aws_alb`, `combined`, `vercel`, `valiron` or `auto`), plain or gzip, up to 16 MB (64 MB decompressed, 500,000 records). Requests with `X-Amz-Firehose-Request-Id` are read as Firehose envelopes and answered with `{ requestId, timestamp }`. Success returns `{ accepted: true, duplicate, batch }`; processing is asynchronous, and an identical payload on the same connection is accepted once. Errors: `401 authentication_required`, `400 empty_payload | invalid_gzip | invalid_firehose_payload`, `413`, `415 unsupported_encoding`, `429 too_many_batches` (over 240 deliveries per minute), `503 ingestion_unavailable`.
|
|
959
943
|
|
|
960
|
-
|
|
944
|
+
Dashboard-session endpoints (operator API keys and `vcl_` tokens return 401; another account's website returns `404 site_not_found`; responses are `private, no-store`):
|
|
961
945
|
|
|
962
|
-
|
|
946
|
+
| Method | Path | Purpose |
|
|
947
|
+
|---|---|---|
|
|
948
|
+
| `GET`, `POST` | `/operator/crawlers/sites` | List websites with connection count, last delivery and stored events; add `{ hostname }` (up to 25 per account) |
|
|
949
|
+
| `PATCH` | `/operator/crawlers/sites/:siteId` | Set `{ excludedPaths }` (up to 20 path prefixes counted without storing the full path) |
|
|
950
|
+
| `DELETE` | `/operator/crawlers/sites/:siteId?confirm=<hostname>` | Remove a website from the dashboard and revoke its connections. Observed data is retained. Returns `{ removed: true, retained: true }`; `409 disable_protection_first` while Valiron rules are deployed |
|
|
951
|
+
| `GET`, `POST` | `/operator/crawlers/sites/:siteId/connections` | List connections; create `{ kind: "push", format }`, `{ kind: "sdk" }`, or `cloudfront_realtime` with ordered `fields`. Returns the token once with `ingestPath` |
|
|
952
|
+
| `DELETE` | `/operator/crawlers/connections/:connectionId` | Revoke a connection immediately |
|
|
953
|
+
| `POST` | `/operator/crawlers/sites/:siteId/uploads?format=auto&name=<file name>` | Upload one log file as the raw request body |
|
|
954
|
+
| `DELETE` | `/operator/crawlers/sites/:siteId/uploads/:uploadId` | Remove a finished upload from the dashboard and analytics; its data is retained and uploading the same file again restores it. Returns `{ removed: true, retained: true, requests }`; `409 upload_processing` while it is processing |
|
|
955
|
+
| `GET` | `/operator/crawlers/sites/:siteId/batches` | `uploads=1` lists up to 200 file uploads with `fileName`; otherwise the last 50 deliveries with status and record counts (stored, duplicate, unreadable, over allowance; over-allowance records are stored and flagged) |
|
|
956
|
+
| `GET` | `/operator/crawlers/traffic/overview` | Totals by traffic class, categories, status classes, cache, edge actions, verification states, Valiron-attributed actions, coverage and sources |
|
|
957
|
+
| `GET` | `/operator/crawlers/traffic/timeseries` | Requests per hour or day (`bucket=hour|day`) by traffic class |
|
|
958
|
+
| `GET` | `/operator/crawlers/traffic/providers` | Crawlers by provider/class and verification state, top routes and daily trend |
|
|
959
|
+
| `GET` | `/operator/crawlers/traffic/pages` | Top 200 routes (`audience`, `provider`, `q` filters), daily granularity |
|
|
960
|
+
| `GET` | `/operator/crawlers/traffic/events` | Recent requests by delivery time (`limit` 1–200, `before` cursor, `provider`, `path` prefix; `audience`, `verification` (`verified`, `claim_mismatch`, `verification_unavailable`, `unverified`), `status` (`0`–`5`, `0` = not reported) and `edge` (`none`, `allow`, `block`, `challenge`, `count`, `log`, `skip`, `other`) accept comma-separated lists) |
|
|
963
961
|
|
|
964
|
-
|
|
965
|
-
curl https://valiron-edge-proxy.onrender.com/wrap/{operatorId}/status
|
|
966
|
-
```
|
|
967
|
-
|
|
968
|
-
#### x402 Paid Wrapper Response
|
|
969
|
-
|
|
970
|
-
If `paymentProtocol` is `x402` and no valid payment is attached, the wrapper returns:
|
|
971
|
-
|
|
972
|
-
```http
|
|
973
|
-
HTTP/1.1 402 Payment Required
|
|
974
|
-
X-PAYMENT-RESPONSE: ...
|
|
975
|
-
Content-Type: application/json
|
|
976
|
-
```
|
|
962
|
+
Traffic endpoints take `site=<siteId>` and optional `from`/`to` (Unix milliseconds or ISO 8601; default last 24 hours, maximum about five years). Traffic classes are `verified`, `claimed_unverified`, `declared` and `unclassified`; none means human. Invalid filters return `400` with an `invalid_*` code. Free accounts receive `403 upgrade_required` with `feature: "crawler_observe"`.
|
|
977
963
|
|
|
978
|
-
|
|
964
|
+
## Crawler Protection edge rules and edge protection
|
|
979
965
|
|
|
980
|
-
|
|
966
|
+
Dashboard-session endpoints with the same authentication and isolation rules. The simulator, policies and integration endpoints require Pro. Deployment additionally requires the Crawler Protection add-on (`403 protection_upgrade_required`). Status, history, actual actions, disconnecting and `disable` remain available without a plan, so enforcement can always be turned off. See [Simulator](./CRAWLER-PROTECTION.md#simulator) and [Edge protection](./CRAWLER-PROTECTION.md#edge-protection).
|
|
981
967
|
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
|
999
|
-
|
|
1000
|
-
| 402 | `payment_required` | Paid wrapper needs valid x402 or MPP payment. |
|
|
1001
|
-
| 403 | `trust_denied` | Trust checks are enabled and the agent did not pass. |
|
|
1002
|
-
| 404 | `wrapper_not_found` | No active wrapper matched operator ID, path, and method. |
|
|
1003
|
-
| 413 | `payload_too_large` | Request body exceeds wrapper limit. |
|
|
1004
|
-
| 429 | `rate_limit_exceeded` | Caller exceeded wrapper rate limit. |
|
|
1005
|
-
| 502 | `wrapper_request_failed` | Upstream request failed or returned an invalid response. |
|
|
1006
|
-
|
|
1007
|
-
---
|
|
968
|
+
| Method | Path | Purpose |
|
|
969
|
+
|---|---|---|
|
|
970
|
+
| `GET` | `/operator/crawlers/catalog` | Agent IDs, categories, verifiability, evidence availability and target limits |
|
|
971
|
+
| `GET`, `POST` | `/operator/crawlers/policy?site=<id>` | Latest policy and revisions; save `{ rules, note? }` as a new immutable revision (`400 invalid_policy` with `details`) |
|
|
972
|
+
| `POST` | `/operator/crawlers/simulations` | `{ site, policy \| policyId, target: "cloudflare" \| "aws_waf", range: "24h" \| "7d" \| "30d" \| from/to }`; returns a queued or stored simulation |
|
|
973
|
+
| `GET` | `/operator/crawlers/simulations?site=<id>`, `/operator/crawlers/simulations/:id` | Recent runs; one run with `result` (totals, coverage, exclusions, per-rule matches and enforceability, rate-replay qualification) |
|
|
974
|
+
| `GET` | `/operator/crawlers/protection/entitlement` | `{ plan, entitled, source: plan \| stripe \| complimentary, status, periodEnd }` |
|
|
975
|
+
| `GET` | `/operator/crawlers/edge/status?site=<id>` | Display state, provider state, entitlement, integration and permission check, policy revisions, assessments, pending/last deployment, drift |
|
|
976
|
+
| `GET` | `/operator/crawlers/edge/capabilities?site=<id>` | Provider capabilities and plan limits |
|
|
977
|
+
| `GET` | `/operator/crawlers/edge/aws-setup?site=<id>` | External ID, trust policy and least-privilege permissions policy |
|
|
978
|
+
| `POST`, `DELETE` | `/operator/crawlers/edge/integration?site=<id>` | Connect `{ provider: "cloudflare", zoneId, apiToken }` or `{ provider: "aws_waf", roleArn, webAclArn }` (runs the permission check); disconnect. Both require Protection off (`409 disable_protection_first`) |
|
|
979
|
+
| `POST` | `/operator/crawlers/edge/preflight?site=<id>` | Re-run the permission check |
|
|
980
|
+
| `POST` | `/operator/crawlers/edge/enable?site=<id>` | Deploy `{ policyId? }` (default latest). `409 rules_not_enforceable` lists rules with their status and reason |
|
|
981
|
+
| `POST` | `/operator/crawlers/edge/rollback?site=<id>` | Deploy an earlier `{ policyId }` |
|
|
982
|
+
| `POST` | `/operator/crawlers/edge/reapply?site=<id>` | Re-deploy the deployed revision (after drift) |
|
|
983
|
+
| `POST` | `/operator/crawlers/edge/disable?site=<id>` | Remove Valiron-owned rules |
|
|
984
|
+
| `GET` | `/operator/crawlers/edge/history?site=<id>` | Deployments with outcomes and the audit trail |
|
|
985
|
+
| `GET` | `/operator/crawlers/edge/actions?site=<id>&from&to` | Actual blocks and rate limits by Valiron rules, by rule/revision, route and source |
|
|
1008
986
|
|
|
987
|
+
Deployments run asynchronously; poll `edge/status`. Only one deployment per website runs at a time (`409 deployment_in_progress`). Credentials are never returned.
|
|
1009
988
|
|
|
1010
|
-
## Crawler
|
|
989
|
+
## Crawler managed controls (0.7.0+)
|
|
1011
990
|
|
|
1012
|
-
`
|
|
991
|
+
`createCrawlerControlClient({ configuration, apiKey, site })` adds background policy polling; pass it as `controlClient` to `createCrawlerRuntime`. The dashboard manages crawler access and tighter request budgets within installed ceilings, with publish/rollback, runtime revision acknowledgments, optional bounded recent decision logs and opt-in alerts. It does not deploy customer infrastructure or change work concurrency. Static runtimes are unchanged. See [Dashboard controls](./CRAWLER-PROTECTION.md#managed-controls) for the setup, API endpoints, leases and retention limits.
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Valiron trust gate on Cloudflare Workers
|
|
2
|
+
|
|
3
|
+
Run the general Valiron trust gate - the same middleware semantics as the
|
|
4
|
+
Express, Fastify, Next.js and generic adapters in `@valiron/sdk` - as a
|
|
5
|
+
Cloudflare Worker in front of your API. Agents are identified, ownership is
|
|
6
|
+
proven per request, the live trust profile is evaluated, and only allowed
|
|
7
|
+
requests reach your origin.
|
|
8
|
+
|
|
9
|
+
This document describes the current source contract on this branch. Package
|
|
10
|
+
publication and production deployment are separate release steps; confirm the
|
|
11
|
+
installed `@valiron/sdk` exposes the `edge-gate` subpath and the
|
|
12
|
+
`examples/cloudflare-gate-worker` template before building on them.
|
|
13
|
+
|
|
14
|
+
## Who this is for, and whether it is required
|
|
15
|
+
|
|
16
|
+
This is an optional integration for a business that sells or exposes an API and
|
|
17
|
+
wants agent ownership and trust checks before requests reach its backend. The
|
|
18
|
+
business runs the Worker in its Cloudflare account, chooses the routes, score
|
|
19
|
+
threshold and trust signals, and protects its origin from direct access. The
|
|
20
|
+
backend can use any language. Valiron still serves profile reads and sandbox
|
|
21
|
+
evaluation; the default verifier also reads the current owner from Valiron.
|
|
22
|
+
|
|
23
|
+
Cloudflare is not required to use Valiron. Businesses can keep Node middleware,
|
|
24
|
+
call the API from their own enforcement code, or use this Worker. Use one
|
|
25
|
+
trust-gate layer per protected route. Agents calling those routes must identify
|
|
26
|
+
themselves and sign fresh requests. The gate verifies agent ownership and
|
|
27
|
+
applies the business's trust policy. Customer permissions, benefits and payment
|
|
28
|
+
authorization remain application responsibilities.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Components
|
|
32
|
+
|
|
33
|
+
- **`@valiron/sdk/edge-gate`.** A WebCrypto-only SDK subpath that loads in
|
|
34
|
+
Workers and other edge runtimes without Node APIs: `runValironEdgeGate`,
|
|
35
|
+
`createEdgeIdentityVerifier`, `stripEdgeGateHeaders`,
|
|
36
|
+
`edgeSha256RequestDigest`, and an edge-safe `ValironClient` re-export. The
|
|
37
|
+
gate decision itself is computed by the exact same `valironGateCheck`
|
|
38
|
+
implementation the Node middleware uses, so statuses, error bodies, cache
|
|
39
|
+
behavior and allow/deny semantics are identical.
|
|
40
|
+
- **Worker template.** `packages/valiron-sdk/examples/cloudflare-gate-worker/`
|
|
41
|
+
is a deployable Worker: identity extraction, per-request proof
|
|
42
|
+
verification, live profile evaluation, trusted-header strip/set, and
|
|
43
|
+
path scoping. `packages/valiron-sdk/test/edge-gate-worker/` is a committed
|
|
44
|
+
miniflare (workerd) regression harness for the template.
|
|
45
|
+
|
|
46
|
+
## Request flow
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
Agent request
|
|
50
|
+
-> Worker reads x-agent-id / x-agent-address
|
|
51
|
+
-> Worker verifies the request-bound proof (before any decision, cache hits included)
|
|
52
|
+
-> Worker evaluates the live profile through the Valiron operator API
|
|
53
|
+
-> allow: strip client x-valiron-gate-*, set trusted decision headers, forward to origin
|
|
54
|
+
-> deny: 401 / 403 / 503 response; the origin never runs
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Decision semantics are the Node gate's, unchanged:
|
|
58
|
+
|
|
59
|
+
| Condition | Status | Code |
|
|
60
|
+
| --- | --- | --- |
|
|
61
|
+
| No identity headers | 401 | `MISSING_AGENT_IDENTITY` |
|
|
62
|
+
| Missing or invalid request proof | 401 | `AGENT_OWNERSHIP_REQUIRED` |
|
|
63
|
+
| Route not production-eligible, or score below `minScore` | 403 | `TRUST_GATE_DENIED` |
|
|
64
|
+
| New agent (no reputation yet) | 403 | `AGENT_EVALUATION_PENDING` |
|
|
65
|
+
| Evaluation error / API unreachable (after a successful proof) | 503 | `TRUST_GATE_UNAVAILABLE` (fail closed) |
|
|
66
|
+
| API unreachable during hosted proof verification | 401 | `AGENT_OWNERSHIP_REQUIRED` (fail closed) |
|
|
67
|
+
|
|
68
|
+
Allow requires routing `prod` or `prod_throttled` AND the combined score at
|
|
69
|
+
or above `minScore` (default 65). A new agent's denial triggers a background
|
|
70
|
+
sandbox evaluation, exactly like the Node gate.
|
|
71
|
+
|
|
72
|
+
Outage behavior depends on where the failure lands. The default wallet
|
|
73
|
+
verifier checks signatures locally, but first reads the current owner from
|
|
74
|
+
Valiron; failure of that lookup returns 401 `AGENT_OWNERSHIP_REQUIRED`.
|
|
75
|
+
Hosted verification failures also return 401. If proof verification succeeds
|
|
76
|
+
and the later trust-profile evaluation fails, the gate returns 503
|
|
77
|
+
`TRUST_GATE_UNAVAILABLE`. The origin is never touched on failure.
|
|
78
|
+
|
|
79
|
+
## Deploy the Worker template
|
|
80
|
+
|
|
81
|
+
Copy `packages/valiron-sdk/examples/cloudflare-gate-worker/`, configure
|
|
82
|
+
`wrangler.toml`, and `wrangler deploy`. Required: `VALIRON_ENDPOINT` (the
|
|
83
|
+
Valiron operator API), `VALIRON_API_KEY` (secret - profile routes are
|
|
84
|
+
operator-authenticated) and the `VALIRON_NONCE_STORE` Durable Object binding
|
|
85
|
+
(durable replay protection; the gate fails closed without it). Recommended:
|
|
86
|
+
`VALIRON_ORIGIN_SECRET` (secret forwarded to the origin as
|
|
87
|
+
`x-valiron-gate-secret`). Optional: `VALIRON_MIN_SCORE`,
|
|
88
|
+
`VALIRON_GATE_PATHS`, `VALIRON_TRUST_SIGNALS`, `VALIRON_CACHE_TTL_MS`,
|
|
89
|
+
`VALIRON_VERIFIER` (`hosted` selects hosted ANS verification - see below),
|
|
90
|
+
`VALIRON_PUBLIC_ORIGIN` (audience for the hosted variant only).
|
|
91
|
+
|
|
92
|
+
## Required trust boundary
|
|
93
|
+
|
|
94
|
+
1. **The origin must reject anything that did not pass the gate.** The
|
|
95
|
+
Worker strips client-supplied `x-valiron-gate-*` headers and sets its own
|
|
96
|
+
(`x-valiron-gate-decision`, `-agent-id`, `-score`, `-tier`,
|
|
97
|
+
`-risk-level`, `-route`), and forwards `x-valiron-gate-secret` when
|
|
98
|
+
`VALIRON_ORIGIN_SECRET` is set. The origin must reject requests missing
|
|
99
|
+
that secret, or use an exclusive authenticated origin path (private Tunnel or custom
|
|
100
|
+
per-zone mTLS). Cloudflare IP allowlisting or a shared origin-pull
|
|
101
|
+
certificate alone does not identify this Worker. If the origin is reachable
|
|
102
|
+
directly, the gate is bypassable.
|
|
103
|
+
2. **Replay protection is durable.** The default verifier refuses to run
|
|
104
|
+
without the `VALIRON_NONCE_STORE` Durable Object binding (503,
|
|
105
|
+
fail-closed). Nonces are claimed atomically in one named Durable Object
|
|
106
|
+
with a 121-second TTL matching the proof validity window, so a proof
|
|
107
|
+
replayed against any isolate or after a restart is rejected. The SDK's
|
|
108
|
+
in-memory `MemoryNonceStore` is for local tests only.
|
|
109
|
+
3. **Enforce the gate at one layer per route.** Do not run the origin's
|
|
110
|
+
`createValironGate` on the same routes the Worker gates; requests would be
|
|
111
|
+
evaluated twice.
|
|
112
|
+
4. **Header claims alone never authorize.** Every identified request carries
|
|
113
|
+
a fresh proof or is denied `401 AGENT_OWNERSHIP_REQUIRED` before trust
|
|
114
|
+
evaluation. The default verifier first reads the current registry owner
|
|
115
|
+
from a live profile to determine which key must sign.
|
|
116
|
+
5. **The profile cache is per isolate** (default 30000 ms, matching the Node
|
|
117
|
+
gate's per-process default). It is not shared across isolates or colos.
|
|
118
|
+
The ownership proof is verified on every request regardless of cache.
|
|
119
|
+
|
|
120
|
+
## Request-bound proofs
|
|
121
|
+
|
|
122
|
+
The template's default `verifyRequest` is `createEdgeWalletProofVerifier`:
|
|
123
|
+
application-owned verification of the `valiron-wallet-request-v2` signed
|
|
124
|
+
request scheme (see `SECURITY-UPGRADE-2026-10-31.md`), the same scheme the
|
|
125
|
+
hosted API enforces server-side. Agents send `x-agent-timestamp`,
|
|
126
|
+
`x-agent-nonce` and `x-agent-request-signature`: the registry owner's EIP-191
|
|
127
|
+
(EVM) or Ed25519 (Solana) signature over the canonical payload binding the
|
|
128
|
+
agent id, chain, method, the exact public URL, a canonical JSON body digest,
|
|
129
|
+
a millisecond timestamp (60-second window) and a fresh nonce. The Worker
|
|
130
|
+
verifies the signature against the agent's current registry owner wallet
|
|
131
|
+
from the live profile, then consumes the nonce in the Durable Object; a
|
|
132
|
+
replayed proof is rejected for 121 seconds. Key-based web2 agents send
|
|
133
|
+
`x-agent-address` and sign with that address's key (chain `key`). The sign
|
|
134
|
+
side ships in the SDK's hosted clients (`signRequest`) and the recipe is in
|
|
135
|
+
the template README.
|
|
136
|
+
|
|
137
|
+
`VALIRON_VERIFIER=hosted` switches to `createEdgeIdentityVerifier`: Valiron's
|
|
138
|
+
hosted ANS provider-identity verification (`POST /operator/identity/verify`,
|
|
139
|
+
`x-valiron-identity-*` headers from `createAgentIdentityProof`, canonical
|
|
140
|
+
`valiron-agent-request-v2` payload). That variant requires Valiron backend
|
|
141
|
+
ANS configuration and a registered `ans://` identity, and was not exercised
|
|
142
|
+
in the template's isolated test deployment.
|
|
143
|
+
|
|
144
|
+
Operators with their own request-signing scheme replace `verifyRequest` in
|
|
145
|
+
`worker.ts` - the same application-owned verifier contract as the Node
|
|
146
|
+
middleware (`verifyAgentRequest` in the end-to-end guide). The verifier must
|
|
147
|
+
bind identity, method, full URL and body, enforce freshness, and reject
|
|
148
|
+
replayed nonces in durable shared storage.
|
|
149
|
+
|
|
150
|
+
## What this is not
|
|
151
|
+
|
|
152
|
+
- It does not cache or replicate trust scores at the edge beyond the short
|
|
153
|
+
per-isolate profile cache the Node middleware already has; the operator API
|
|
154
|
+
remains the decision source.
|
|
155
|
+
- It grants no Cloudflare verified-agent status and changes no scoring or
|
|
156
|
+
privacy behavior.
|
|
157
|
+
|
|
158
|
+
## Verification
|
|
159
|
+
|
|
160
|
+
- SDK suite: `pnpm --filter @valiron/sdk test` includes
|
|
161
|
+
`test/validate-edge-gate.mjs` (decision parity with the Node gate, digest
|
|
162
|
+
parity with Node `sha256RequestDigest`, header constants, verifier
|
|
163
|
+
binding rules).
|
|
164
|
+
- Workers-runtime harness: `packages/valiron-sdk/test/edge-gate-worker/`
|
|
165
|
+
(miniflare; allow/deny, both signing chains through the default
|
|
166
|
+
wallet-proof verifier with real signatures, Durable Object replay
|
|
167
|
+
rejection, tampered/stale/wrong-key rejection, fail-closed without the
|
|
168
|
+
nonce-store binding, origin-secret forwarding, hosted-variant coverage,
|
|
169
|
+
header stripping, path scoping, profile cache, digest recomputation). This
|
|
170
|
+
is hermetic coverage with a mocked API; it complements a live deployment
|
|
171
|
+
test and does not replace one.
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
## Origin targeting and nonce expiry
|
|
175
|
+
|
|
176
|
+
For a standalone `workers.dev` deployment, set `VALIRON_ORIGIN` to the fixed
|
|
177
|
+
HTTPS origin, for example `https://origin.example.com`. It must have no
|
|
178
|
+
credentials, path, query, or fragment and must differ from the incoming
|
|
179
|
+
origin. Leave it unset only when Cloudflare zone-route origin resolution is
|
|
180
|
+
configured. The Worker verifies the original incoming URL and body before
|
|
181
|
+
rewriting the destination. Path and query are preserved; caller-provided
|
|
182
|
+
URLs and host-like paths cannot select another host. Redirects from an
|
|
183
|
+
explicit origin are returned without following them, so trusted headers and
|
|
184
|
+
the origin secret are never sent to a redirect destination. Out-of-scope
|
|
185
|
+
paths are forwarded without the gate secret and cannot access protected
|
|
186
|
+
origin routes.
|
|
187
|
+
|
|
188
|
+
Durable Object nonce claims use a storage transaction and an explicit expiry
|
|
189
|
+
timestamp, not KV-only `expirationTtl`. A scheduled alarm removes expired
|
|
190
|
+
entries. Concurrent claims have exactly one winner; a claimed nonce stays
|
|
191
|
+
blocked until its 121-second expiry, including across isolates. Expiry makes
|
|
192
|
+
the nonce reusable but does not make an old signature fresh.
|
|
193
|
+
|
|
194
|
+
The template registers sandbox-trigger promises with `ExecutionContext.waitUntil` so pending evaluations can continue after the denial response. All inbound `x-valiron-gate-*` headers, including a forged origin secret, are stripped before forwarding.
|
|
195
|
+
|
|
196
|
+
Wallet proof freshness can be tightened with `maxAgeMs`; values above 60,000 ms are rejected. Durable nonce retention is 121 seconds to cover the entire 60-second past/future validity horizon, including its boundary.
|