@kya-os/checkpoint-nextjs 1.9.0 → 1.11.0

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.
Files changed (156) hide show
  1. package/CHANGELOG.md +322 -0
  2. package/README.md +205 -31
  3. package/dist/adapt-BdQ9R7Iw.mjs +97 -0
  4. package/dist/adapt-BdQ9R7Iw.mjs.map +1 -0
  5. package/dist/adapt-CCSKGjVH.js +107 -0
  6. package/dist/api-client-JHOrRUA_.d.mts +222 -0
  7. package/dist/api-client-JHOrRUA_.d.mts.map +1 -0
  8. package/dist/api-client-JHOrRUA_.d.ts +222 -0
  9. package/dist/api-client-JHOrRUA_.d.ts.map +1 -0
  10. package/dist/api-client.d.mts +2 -213
  11. package/dist/api-client.d.ts +2 -213
  12. package/dist/api-client.js +221 -206
  13. package/dist/api-client.mjs +222 -202
  14. package/dist/api-client.mjs.map +1 -0
  15. package/dist/api-middleware-BWjokNis.d.mts +131 -0
  16. package/dist/api-middleware-BWjokNis.d.mts.map +1 -0
  17. package/dist/api-middleware-Bf3xmM9W.js +391 -0
  18. package/dist/api-middleware-C-ngFX_8.mjs +387 -0
  19. package/dist/api-middleware-C-ngFX_8.mjs.map +1 -0
  20. package/dist/api-middleware-DyLDqOYF.d.ts +131 -0
  21. package/dist/api-middleware-DyLDqOYF.d.ts.map +1 -0
  22. package/dist/api-middleware.d.mts +2 -166
  23. package/dist/api-middleware.d.ts +2 -166
  24. package/dist/api-middleware.js +3 -526
  25. package/dist/api-middleware.mjs +2 -521
  26. package/dist/cedar-wasm.d.mts +20 -0
  27. package/dist/cedar-wasm.d.mts.map +1 -0
  28. package/dist/cedar-wasm.d.ts +19 -0
  29. package/dist/cedar-wasm.d.ts.map +1 -0
  30. package/dist/cedar-wasm.js +24 -0
  31. package/dist/cedar-wasm.mjs +23 -0
  32. package/dist/cedar-wasm.mjs.map +1 -0
  33. package/dist/config-CPP1RV0f.d.mts +291 -0
  34. package/dist/config-CPP1RV0f.d.mts.map +1 -0
  35. package/dist/config-DVgOFxJs.d.ts +291 -0
  36. package/dist/config-DVgOFxJs.d.ts.map +1 -0
  37. package/dist/engine-wasm.d.mts +20 -0
  38. package/dist/engine-wasm.d.mts.map +1 -0
  39. package/dist/engine-wasm.d.ts +19 -0
  40. package/dist/engine-wasm.d.ts.map +1 -0
  41. package/dist/engine-wasm.js +24 -0
  42. package/dist/engine-wasm.mjs +23 -0
  43. package/dist/engine-wasm.mjs.map +1 -0
  44. package/dist/index-edge.d.mts +8 -0
  45. package/dist/index-edge.d.ts +8 -0
  46. package/dist/index-edge.js +14 -0
  47. package/dist/index-edge.mjs +7 -0
  48. package/dist/index.d.mts +8 -17
  49. package/dist/index.d.ts +8 -17
  50. package/dist/index.js +36 -1275
  51. package/dist/index.mjs +29 -1234
  52. package/dist/index.mjs.map +1 -0
  53. package/dist/middleware-bundler.d.mts +6 -12
  54. package/dist/middleware-bundler.d.mts.map +1 -0
  55. package/dist/middleware-bundler.d.ts +6 -12
  56. package/dist/middleware-bundler.d.ts.map +1 -0
  57. package/dist/middleware-bundler.js +12 -350
  58. package/dist/middleware-bundler.mjs +11 -347
  59. package/dist/middleware-bundler.mjs.map +1 -0
  60. package/dist/middleware-core-B0jf5_Hm.mjs +264 -0
  61. package/dist/middleware-core-B0jf5_Hm.mjs.map +1 -0
  62. package/dist/middleware-core-Bol44X9C.d.ts +17 -0
  63. package/dist/middleware-core-Bol44X9C.d.ts.map +1 -0
  64. package/dist/middleware-core-CMc-2QkU.js +274 -0
  65. package/dist/middleware-core-DycsbHUd.d.mts +17 -0
  66. package/dist/middleware-core-DycsbHUd.d.mts.map +1 -0
  67. package/dist/middleware-edge.d.mts +16 -14
  68. package/dist/middleware-edge.d.mts.map +1 -0
  69. package/dist/middleware-edge.d.ts +16 -14
  70. package/dist/middleware-edge.d.ts.map +1 -0
  71. package/dist/middleware-edge.js +94 -355
  72. package/dist/middleware-edge.mjs +90 -347
  73. package/dist/middleware-edge.mjs.map +1 -0
  74. package/dist/middleware-node-context-591KsiYg.js +39 -0
  75. package/dist/middleware-node-context-D_ZyUEcA.mjs +35 -0
  76. package/dist/middleware-node-context-D_ZyUEcA.mjs.map +1 -0
  77. package/dist/middleware-node.d.mts +10 -25
  78. package/dist/middleware-node.d.mts.map +1 -0
  79. package/dist/middleware-node.d.ts +10 -25
  80. package/dist/middleware-node.d.ts.map +1 -0
  81. package/dist/middleware-node.js +21 -351
  82. package/dist/middleware-node.mjs +19 -347
  83. package/dist/middleware-node.mjs.map +1 -0
  84. package/dist/posture-outcome-Ccujx_9V.d.mts +14 -0
  85. package/dist/posture-outcome-Ccujx_9V.d.mts.map +1 -0
  86. package/dist/posture-outcome-Ccujx_9V.d.ts +14 -0
  87. package/dist/posture-outcome-Ccujx_9V.d.ts.map +1 -0
  88. package/dist/posture-outcome-DQ4fdMfq.mjs +21 -0
  89. package/dist/posture-outcome-DQ4fdMfq.mjs.map +1 -0
  90. package/dist/posture-outcome-DddsJtL8.js +25 -0
  91. package/dist/public-api-CYsHrTQI.d.ts +5 -0
  92. package/dist/public-api-DkG7pRE0.d.mts +5 -0
  93. package/dist/rolldown-runtime-C24Yb2bl.js +33 -0
  94. package/dist/utils-Cnwg0VrY.mjs +88 -0
  95. package/dist/utils-Cnwg0VrY.mjs.map +1 -0
  96. package/dist/utils-dyFxqlFI.js +104 -0
  97. package/package.json +31 -66
  98. package/EDGE_RUNTIME_WASM_SETUP.md +0 -342
  99. package/bin/setup-edge-wasm.js +0 -513
  100. package/dist/adapt.d.mts +0 -39
  101. package/dist/adapt.d.ts +0 -39
  102. package/dist/adapt.js +0 -59
  103. package/dist/adapt.mjs +0 -57
  104. package/dist/composed-policy.d.mts +0 -115
  105. package/dist/composed-policy.d.ts +0 -115
  106. package/dist/composed-policy.js +0 -103
  107. package/dist/composed-policy.mjs +0 -97
  108. package/dist/config-CleTeeoW.d.mts +0 -233
  109. package/dist/config-XMOIkxFN.d.ts +0 -233
  110. package/dist/create-middleware.d.mts +0 -22
  111. package/dist/create-middleware.d.ts +0 -22
  112. package/dist/create-middleware.js +0 -34
  113. package/dist/create-middleware.mjs +0 -31
  114. package/dist/edge/index.d.mts +0 -112
  115. package/dist/edge/index.d.ts +0 -112
  116. package/dist/edge/index.js +0 -277
  117. package/dist/edge/index.mjs +0 -275
  118. package/dist/edge-runtime-loader.d.mts +0 -77
  119. package/dist/edge-runtime-loader.d.ts +0 -77
  120. package/dist/edge-runtime-loader.js +0 -242
  121. package/dist/edge-runtime-loader.mjs +0 -235
  122. package/dist/edge-wasm-middleware.d.mts +0 -62
  123. package/dist/edge-wasm-middleware.d.ts +0 -62
  124. package/dist/edge-wasm-middleware.js +0 -26
  125. package/dist/edge-wasm-middleware.mjs +0 -22
  126. package/dist/middleware.d.mts +0 -45
  127. package/dist/middleware.d.ts +0 -45
  128. package/dist/middleware.js +0 -19
  129. package/dist/middleware.mjs +0 -15
  130. package/dist/nodejs-wasm-loader.d.mts +0 -41
  131. package/dist/nodejs-wasm-loader.d.ts +0 -41
  132. package/dist/nodejs-wasm-loader.js +0 -36
  133. package/dist/nodejs-wasm-loader.mjs +0 -30
  134. package/dist/policy.d.mts +0 -162
  135. package/dist/policy.d.ts +0 -162
  136. package/dist/policy.js +0 -198
  137. package/dist/policy.mjs +0 -174
  138. package/dist/session-tracker.d.mts +0 -55
  139. package/dist/session-tracker.d.ts +0 -55
  140. package/dist/session-tracker.js +0 -172
  141. package/dist/session-tracker.mjs +0 -169
  142. package/dist/translate.d.mts +0 -63
  143. package/dist/translate.d.ts +0 -63
  144. package/dist/translate.js +0 -44
  145. package/dist/translate.mjs +0 -42
  146. package/dist/types-Chgi5TFC.d.mts +0 -105
  147. package/dist/types-Chgi5TFC.d.ts +0 -105
  148. package/dist/wasm-setup.d.mts +0 -46
  149. package/dist/wasm-setup.d.ts +0 -46
  150. package/dist/wasm-setup.js +0 -122
  151. package/dist/wasm-setup.mjs +0 -118
  152. package/wasm/agentshield_wasm.d.ts +0 -479
  153. package/wasm/agentshield_wasm.js +0 -1536
  154. package/wasm/agentshield_wasm_bg.wasm +0 -0
  155. package/wasm/package.json +0 -30
  156. package/wasm.d.ts +0 -21
package/CHANGELOG.md CHANGED
@@ -1,5 +1,299 @@
1
+ <!-- Generated by `pnpm changelog:generate` from the "## Release notes" sections of merged pull requests. Do not edit this file by hand: change the PR's release notes and regenerate. -->
2
+
1
3
  # @kya-os/checkpoint-nextjs
2
4
 
5
+ ## 1.11.0 - 2026-10-21
6
+
7
+ ### Added
8
+
9
+ - `withCheckpoint` claims an accepted signed request once, before it reaches the handler, using the dashboard's shared ledger when `apiKey` and `projectId` are set, or an in-process store otherwise; the new `requestClaimStore` option picks the store. (#6422)
10
+
11
+ ### Changed
12
+
13
+ - On the Node.js runtime (`proxy.ts`, or `middleware.ts` with `runtime: 'nodejs'`), `@kya-os/checkpoint-nextjs` now runs the engine's Node build, the same as `./node`. Under Turbopack a `proxy.ts` with `withCheckpoint` traces 117 files (5.6 MiB) instead of about 257 MiB, well inside Vercel's 250 MB function limit, with the same verdicts.
14
+ If the engine cannot load, every request is answered 503, the cause is logged, and the next request tries again.
15
+ webpack on the Node.js runtime is still not supported: it now builds, then answers every request 503 with the cause logged. (#6438)
16
+
17
+ ### Other merged changes
18
+
19
+ - chore(release): set nextjs and express to 1.10.0 in package.json and the version literal (#5192)
20
+ - chore: remove comments that excuse unresolved design debt (#5224)
21
+ - fix(deps): update next to 16.3.5 security release (#4993)
22
+ - chore(deps): remove unused dependencies and import cycles (#5299)
23
+ - fix(detection): detection pattern and fingerprint accuracy pass (#5437)
24
+ - fix(policy): verify authentication and make backfill claims atomic (#5687)
25
+ - chore(deps): patch security advisories (next 16.3.8, pnpm overrides) (#5833)
26
+ - Revert "fix(detection): classify zero-evidence requests as unknown instead of human" (#5881)
27
+ - fix(detection): classify zero-evidence requests as unknown instead of human (#5886)
28
+ - feat(nextjs): make @kya-os/checkpoint-nextjs engine-only and fix its next.js entries (#6271)
29
+ - fix(nextjs): load every entry in plain node esm (#6312)
30
+ - fix(nextjs): fail closed on edge when an enforcing cedar policy has no module (#6298)
31
+ - refactor(wasm-runtime): add make engine defaults and share it across the sdks (#6303)
32
+ - perf(sdk): load lean checkpoint-shared entries in express and next.js (#6306)
33
+ - fix(wasm-runtime): stop fetching a tenant policy that does not exist (#6301)
34
+ - fix(sdk): raise the node floor to the versions that can require an es module (#6293)
35
+ - feat(nextjs): run edge detection and cedar on one module (#6343)
36
+ - refactor(wasm-runtime): one composed-policy context for express and next.js (#6360)
37
+
38
+ ### Notes (#5387)
39
+
40
+ - Browser posture is also read from the `KYA-Posture` and
41
+ `KYA-Posture-Session` request headers, which a page on another host, or one
42
+ that blocks cookies, sends from the beacon's `onReceipt`. Each header wins
43
+ over its cookie. Needs `@kya-os/checkpoint-wasm-runtime` and
44
+ `@kya-os/checkpoint-shared` releases that carry `postureFromRequest`.
45
+
46
+ ### Notes (#5508)
47
+
48
+ - `withCheckpointApi` now reports the decision it acted on, the engine that
49
+ made it, and itself. The detection it logs carries `enforcement.action`,
50
+ the gateway's engine info under the name `checkpoint-remote`, and an `sdk`
51
+ block (package, version, and `node` or `edge`). Activity previously showed
52
+ these rows as "Unrecognized runtime" with no verdict. The `sdk` block is
53
+ omitted when the build injected no package version.
54
+
55
+ ### Notes (#5410)
56
+
57
+ #### Changed
58
+
59
+ - **Action for Next.js 15 users:** set `clientIpPolicy` on `withCheckpoint`,
60
+ `withCheckpointApi` and `createEdgeCheckpoint`. Next.js 15 removed
61
+ `request.ip`, so the default `direct` policy resolves no IP. The engine
62
+ used to fall back to `x-real-ip` or `x-forwarded-for` when a signature
63
+ failed; it no longer does (see `@kya-os/checkpoint-wasm-runtime`), so on
64
+ the default policy a request with a failed signature loses the
65
+ `vendor_ip_feed` match, the Tier-4 cloud check and reputation. On Vercel
66
+ set `{ platform: 'vercel' }`; self-hosted, use the `trusted-proxy` profile
67
+ with `trustedHops`.
68
+ - The `vercel` client-IP profile is honored only when `VERCEL=1`. Anywhere else
69
+ it resolves like `direct`, so a self-hosted app that copies a Vercel
70
+ snippet can no longer have its IP chosen by a client-sent
71
+ `x-vercel-forwarded-for` or `x-forwarded-for`.
72
+ - `trustedHops` counts the trusted proxy addresses at the right of
73
+ `x-forwarded-for`, which is one fewer than the number of proxies, and now
74
+ accepts `0` (the rightmost entry) for a single proxy; `0` needs the
75
+ `@kya-os/checkpoint-shared` release that carries this change, and resolves
76
+ no IP with an older one.
77
+ - An untrusted resolution (an `x-real-ip` or `x-forwarded-for` fallback the
78
+ selected profile does not vouch for) is no longer forwarded as the client
79
+ IP to the engine, the reporter or the API middleware.
80
+
81
+ ### Notes (#5438)
82
+
83
+ - `withCheckpointApi` answers a `rate_limited` enforce decision (the project
84
+ policy's `requestsPerMinute` throttle) with a `429`, a `Retry-After` header
85
+ and a `RATE_LIMITED` body instead of the `403` access-denied shape. It is not
86
+ turned into a redirect by `onBlock: 'redirect'`; `customBlockedResponse` and
87
+ `blockedResponse.headers` still apply. The limit is counted per client IP
88
+ the middleware relays, so set `clientIpPolicy` to the platform that fronts
89
+ your app: with the default `direct` policy on Next.js 15 no IP is relayed
90
+ and the limit is skipped.
91
+
92
+ ### Notes (#5594)
93
+
94
+ #### Added
95
+
96
+ - `getCheckpointPostureOutcome(request, { browserPosture, projectId })` returns the
97
+ browser-posture outcome for a request in a route handler or page:
98
+ `{ status, reason?, posture? }` with `status` `verified`, `absent` or `rejected`, and the
99
+ verified claims (a frozen copy) only when verified. It verifies the token from the
100
+ `KYA-Posture` headers or cookies with the same verifier and posture config
101
+ `withCheckpoint` takes, so nothing is forwarded from the middleware and no secret is
102
+ needed. It always checks, whether or not the middleware ran for the route.
103
+ `status: 'verified'` means the token signature and claims are valid, so check
104
+ `posture.verdict` before treating the visitor as human. The accessor runs the
105
+ same config validation as `withCheckpoint` (`projectId` must be the lowercase project
106
+ UUID) and throws on an invalid config. Needs a
107
+ `@kya-os/checkpoint-wasm-runtime` release that carries `postureOutcomeView`.
108
+
109
+ ### Notes (#5707)
110
+
111
+ - Policy-load timeouts and fast origin failures now follow the documented
112
+ `failOpen` and `fallbackPolicy` settings. The default remains fail-open;
113
+ `failOpen: false` with no fallback returns `503 POLICY_UNAVAILABLE`.
114
+
115
+ ### Notes (#5579)
116
+
117
+ #### Fixed
118
+
119
+ - `CheckpointApiClient.enforce` and `quickCheck` no longer send cookies,
120
+ `Authorization` or other credential-looking headers (any name containing
121
+ `authorization`, `auth`, `token`, `secret`, `password`, `api-key`,
122
+ `subscription-key` or `credential`, except `kya-` headers) to Checkpoint, so
123
+ `withCheckpointApi` and direct callers are covered alike. The only exceptions
124
+ are every `_as_beacon_session` cookie and a KYA delegation credential bearer,
125
+ which the engine verifies.
126
+
127
+ ### zero-evidence requests are `IncompleteData`, not `Human` (breaking wire change) (#5060)
128
+
129
+ - **Behavior change:** the embedded engine no longer classifies a request that carries no evidence as `Human`. For
130
+ that request `detectionDetail.detectionClass.type` is now `IncompleteData` and `detectionDetail.riskLevel` is
131
+ `medium` instead of `low`. `isAgent` stays false.
132
+ - The engine marks that verdict with `detectionDetail.metadata.detection_basis = "no_evidence"`. It is the only thing
133
+ that separates a zero-evidence request from other `IncompleteData` verdicts, and the composed-policy projection reads
134
+ it to give the visitor the category `no_evidence`.
135
+ - A request with suspicious headers is still `IncompleteData` (the engine's internal Unknown class), but its
136
+ `detectionDetail.verificationMethod` is now `none` instead of `pattern`.
137
+ - Composed rules aimed at all agents now exempt only `human` and `no_evidence` visitors, so any other `incomplete_data`
138
+ visitor is matched by them. A forged `mcp_i_handshake` or `kyaos_handshake` envelope that the engine blocks projects
139
+ as category `unknown`, not `incomplete_data`.
140
+ - For a zero-evidence request `detectionDetail.isBot` and `detectionDetail.isAiCrawler` are now absent; they were `false`.
141
+ Read a missing value as false. Its `reasons` now read `Request did not carry enough signal to classify confidently`
142
+ where they read `No known agent indicators matched`.
143
+ - A deployed rule that does not compare the category to `no_evidence` reads it as `human` because the composed-policy
144
+ compile rewrites the policy text (`withNoEvidenceExclusion` in `@kya-os/checkpoint-shared`). The dashboard serves the
145
+ stored text, so a release that predates the rewrite reads it, `@scopes` included, exactly as before.
146
+ - Composed-policy evaluation now applies that same rewrite to the policy text inside the compile, once per distinct policy
147
+ text on a cache miss and not on every request, so a custom `PolicyFetcher` is covered and text that already carries
148
+ the rewrite is unchanged. Apart from computed reads, a statement is skipped only when it compares the category to the literal `"no_evidence"`.
149
+ The rewrite takes a direct read of the category, including a parenthesized principal and a bracket key written with
150
+ escapes; whitespace between tokens is the 25 Unicode `White_Space` characters and a `//` comment ends at a line feed
151
+ or a lone carriage return. A statement that reads the category through a computed value holding the principal, such as an `if` or a record
152
+ that carries `principal`, is left as written and sees `no_evidence`, and a `principal` that is an attribute name or
153
+ record key is never rewritten. If the engine rejects the rewritten text as invalid Cedar, the authored text is
154
+ compiled instead, a `no_evidence` visitor is still read as `human` for that policy, and the new optional
155
+ `ComposedPolicyLogger.compileFallback(projectId, error)` is called once per policy text, or `console.warn` when the
156
+ logger does not supply it. A policy nested deeper than 32 levels is refused as invalid Cedar before the engine
157
+ compiles it. Needs a `@kya-os/checkpoint-wasm-runtime` release that carries the rewrite.
158
+ - `engineInfo.version` and `engineInfo.rulesetVersion` are now `0.2.1` (they were `0.2.0`). `engineInfo.rulesetHash` is
159
+ unchanged: it hashes the bundled vendor keys, vendor feeds and user-agent pattern table, and none of them changed.
160
+ - `withCheckpoint` reports through `@kya-os/checkpoint-wasm-runtime`, whose reporter now sends `detection.detectionBasis`
161
+ to `POST /api/v1/log-detection`. Needs a `@kya-os/checkpoint-wasm-runtime` release that carries it. The
162
+ `CheckpointApiClient.logDetection` call used by `withCheckpointApi` sends the top-level `detectionBasis` that the
163
+ gateway's `/__detect/enforce` returns on the detection. It used to read `metadata.detection_basis`, which that route
164
+ does not set, so nothing was forwarded. `ApiDetectionDetail` gained the optional `detectionBasis` field. The
165
+ dashboard accepts only `no_evidence` and `posture_evidence` and stores it only on an `incomplete_data` row.
166
+ - `withCheckpoint` results (Node and Edge) never carry `Human` now. It still comes from the older
167
+ `createEdgeCheckpoint` detector in `@kya-os/checkpoint-nextjs/edge-runtime-loader`, which reports `Human` when its
168
+ WASM call or its pattern fallback finds no agent.
169
+
170
+ ### Notes (#5968)
171
+
172
+ - `resolveDelegationChallenge` is now also called for a `Block` the engine marks `consent_remediable` (a scope
173
+ shortfall against the host's required scopes, or a delegation whose own `exp` passed or whose status list says
174
+ revoked). Return context with the route's required scopes, from your route configuration and never from
175
+ `result.decision.reason.requested`, and the request gets the same Delegation challenge a first-contact `Challenge`
176
+ gets, so the agent can send the human back to consent. Return `undefined` and the request keeps its block. Every
177
+ other block still renders as before and never calls the resolver. Needs the `@kya-os/checkpoint-wasm-runtime`
178
+ release that carries the re-challenge.
179
+
180
+ ### Notes (#5652)
181
+
182
+ #### Fail-closed credential handling
183
+
184
+ A request presenting a KYA credential that fails verification returns 503 even when `failOpen` is enabled. Trusted roots are resolved for KYA signatures, delegation-proof headers, and structurally recognized VC-JWTs. Opaque and unrelated bearer tokens do not trigger root lookup. Credential claims still require engine verification, including issuer, project, holder, expiry, and revocation checks. Cedar evaluation errors on enforcing projects fail closed; shadow mode keeps the structured decision.
185
+
186
+ #### Changed
187
+
188
+ ### Node 20.16+ or 22.3+ required; did:web and status-list fetches are hardened (breaking) (#6094)
189
+
190
+ - **BREAKING:** `engines.node` is now `^20.16.0 || >=22.3.0` (was `>=18.0.0`), so installing on older Node warns.
191
+ Node 18 and Node 20 before 20.16 are end of life and have no `process.getBuiltinModule`, which the default DID
192
+ resolver needs for its connect-time address check. There every did:web and status-list fetch is refused: a request
193
+ with a did:web identity is blocked and one whose credential has a status list gets a 503. One warning per process
194
+ names the Node version.
195
+ - **BREAKING for hosts whose only route out is a proxy:** on Node the default `didResolver` and `statusListCache`
196
+ fetch with `https.get` and `agent: false`. That ignores an undici global dispatcher
197
+ (`setGlobalDispatcher(new ProxyAgent(...))`) and Node 24's `NODE_USE_ENV_PROXY`, which global `fetch` honoured
198
+ before, so such a host fails every did:web and status-list fetch (503). Workaround: pass your proxied fetch,
199
+ `adapters: { didResolver: makeDidResolver({ fetch: proxiedFetch }), statusListCache: makeStatusListCache({ fetch: proxiedFetch }) }`
200
+ (both from `@kya-os/checkpoint-wasm-runtime/adapters`). Redirects, ports and size stay checked, but the
201
+ connect-time address check is then your job.
202
+ - The default DID resolver and status-list cache now refuse redirects, ports other than 443, bodies over 64 KiB and,
203
+ on Node, hosts that resolve to a private, loopback, link-local, CGNAT or metadata address. See the
204
+ `@kya-os/checkpoint-wasm-runtime` changelog (#3331).
205
+
206
+ ### the `agentshield_wasm` setup CLI and binary are removed (breaking) (#6084)
207
+
208
+ Shipped under a minor because nothing consumes this package yet.
209
+
210
+ #### BREAKING, removal
211
+
212
+ - **The `checkpoint-setup-edge` bin, the bundled `wasm/` files, `wasm.d.ts` and `EDGE_RUNTIME_WASM_SETUP.md`.**
213
+ The CLI copied the retired `agentshield_wasm` binary into an app for `createEdgeWasmMiddleware`, which already throws.
214
+ **Migration path:** `withCheckpoint` (from `@kya-os/checkpoint-nextjs/edge` on the edge runtime), which runs the `kya-os-engine` build that `@kya-os/checkpoint-wasm-runtime` ships.
215
+ - **The `@kya-os/checkpoint` dependency.**
216
+ `CheckpointEvents`, the type of the `events` option, now comes from `@kya-os/checkpoint-shared`.
217
+ Import it from there if your code names it.
218
+
219
+ RELEASE ORDER: publish `@kya-os/checkpoint-shared` (which adds `CheckpointEvents`) and `@kya-os/checkpoint-wasm-runtime` first.
220
+
221
+ ### Notes (#6187)
222
+
223
+ - **Breaking:** verification and reporting now withhold unauthenticated client addresses. NextRequest exposes no socket peer, so `trusted-proxy` and `cloudflare` return no address even with a peer callback. Current NextRequest objects also lack the legacy `request.ip` used by `direct`. On Vercel, select its managed `vercel` profile. For self-hosted deployments, authenticate addresses at a transport-aware ingress and keep Next address evidence unavailable. See [migration steps](https://github.com/Know-That-Ai/checkpoint/blob/main/docs/runbooks/client-ip-resolution.md#migrate-existing-configurations).
224
+
225
+ ### Notes (#5748)
226
+
227
+ Client-IP handling tightens after the engine stopped deriving an IP from
228
+ forwarded headers. Next.js 15 users on Vercel must now set `clientIpPolicy`.
229
+
230
+ #### Added
231
+
232
+ - OpenAI Tier-1 signing keys now rotate without an SDK release. Verification
233
+ fetches a signed key feed from `feeds.kya.vouched.id` through
234
+ `@kya-os/checkpoint-wasm-runtime`, and a request that misses on an unknown or
235
+ expired OpenAI key is answered at once while the feed refreshes in the background, so the next
236
+ request uses the new keys. This adds
237
+ outbound HTTPS from your server to that host, so allow-list it if you filter
238
+ egress. Point it elsewhere with `KYA_VENDOR_KEY_FEED_URL`. Needs a
239
+ `@kya-os/checkpoint-wasm-runtime` release that carries the feed hook; this
240
+ package needs no code change.
241
+
242
+ ### Notes (#5783)
243
+
244
+ #### Changed
245
+
246
+ - The browser posture reader now applies the token's `detection` claim, `automation_disclosed` and an `agent-driven` verdict, in that order, over a human or incomplete-data baseline, and `automation_corroborated` last as incomplete data. A webdriver-disclosed session now upgrades to a bot, so a policy that blocks bots now blocks it. Needs the `@kya-os/checkpoint-wasm-runtime` release that carries this reader.
247
+
248
+ ## 1.10.0
249
+
250
+ Picks up the Zod 4 flip through its dependency ranges, plus two behaviour
251
+ changes and a build-tooling swap.
252
+
253
+ ### Changed
254
+
255
+ - Dependency ranges move to the Zod 4 family: `@kya-os/checkpoint-shared`
256
+ `^1.3.0` to `^1.4.0`, `@kya-os/checkpoint-wasm-runtime` `^1.8.2` to
257
+ `^1.9.0`, and `@kya-os/checkpoint` `1.2.0` to `1.3.0` (an exact pin, not a
258
+ range). See `@kya-os/checkpoint-shared` 1.4.0 for the validation and
259
+ error-shape changes that come with it. This package's own public surface
260
+ re-exports no Zod object, so nothing Zod-shaped reaches a consumer's
261
+ `.d.ts` from here.
262
+ - Built with `tsdown` instead of `tsup` (#5131). Entrypoints, export
263
+ conditions, and emitted formats are unchanged; this is a toolchain swap,
264
+ but it does regenerate every file in `dist`.
265
+ - A2A Agent Card verification now counts as a verified identity in policy
266
+ context (#4987). `createContextFromDetection` adds
267
+ `verificationMethod === 'a2a'` to the set that marks a request verified,
268
+ alongside `signature`, `tier1_rfc9421`, `kya-http`, and
269
+ `kya-http-delegated`. The engine that emits `'a2a'` ships in
270
+ `@kya-os/checkpoint-wasm-runtime`, and the range above resolves 1.9.0,
271
+ which predates that engine build, so this branch stays inert until a
272
+ wasm-runtime carrying the A2A verifier is published. Behaviour against
273
+ 1.9.0 is unchanged.
274
+ - The API middleware now sets `source: 'middleware'` explicitly on the
275
+ detection it logs (#5018). Previously it inherited `logDetection`'s
276
+ default of `'gateway'`, which describes the transport rather than the
277
+ installation, so Next.js API-middleware detections were attributed to the
278
+ gateway in the dashboard. Projects on this path will see their detections
279
+ move from the gateway source to the middleware source.
280
+
281
+ ### Documentation
282
+
283
+ - `@default` annotations added across the config surface, and the
284
+ self-justifying comment sweep in #4976 removed stale inline notes. No
285
+ runtime change.
286
+
287
+ ### Known issue, pre-existing
288
+
289
+ `require('@kya-os/checkpoint-nextjs/edge')` fails under CommonJS with
290
+ `Package subpath './policy-edge' is not defined by "exports"`. This package
291
+ declares a `require` condition for `./edge`, but that file transitively
292
+ requires `@kya-os/checkpoint-wasm-runtime/policy-edge`, which declares only
293
+ `types`, `edge-runtime`, and `import`. Published 1.9.0 fails the same way, so
294
+ this release does not introduce or worsen it. Bundled Next.js builds resolve
295
+ through the `edge-runtime` condition and are unaffected.
296
+
3
297
  ## 1.9.0
4
298
 
5
299
  - Add the `@kya-os/checkpoint-nextjs/bundler` entry for applications that bundle the WASM runtime, including the first-party browser integrity lab.
@@ -9,6 +303,34 @@
9
303
  Vercel and trusted-proxy forwarding require an explicit profile.
10
304
  - Authenticated server-to-server body addresses are normalized only after the
11
305
  caller has passed the endpoint authentication boundary.
306
+ - Browser posture verification (#4940). New `browserPosture` option on
307
+ `withCheckpoint`: `{ origin, keyId, publicKey, protectedRoutes, sessionCookieName? }`.
308
+ The ES256 posture token from the beacon's `__Host-checkpoint_posture_<projectId>`
309
+ cookie is verified locally against the pinned public key (exact HTTPS origin,
310
+ `keyId`, `projectId`, 120s lifetime, SHA-256 binding to the beacon session
311
+ cookie) and projected into Cedar as `context.integrity`. The default step-up
312
+ rule challenges only the listed protected routes (exact path, or subtree with
313
+ a trailing `/*`; longest match wins; scopes nonempty and unique) when the
314
+ verified verdict is `agent-driven` and the request carries no verified
315
+ delegation (`attested-bearer` or `delegated`) covering every listed scope.
316
+ - An `agent-driven` verified posture promotes a Human or IncompleteData result to
317
+ `Browser agent (unsigned)` (`ai_agent`, `verificationMethod: 'behavioral'`,
318
+ confidence bounded to 50..85). Posture never supplies identity and never
319
+ creates a Permit.
320
+ - New `resourceOrgDid` and `trustedDelegationRoots` config options: pin the
321
+ consent credential audience and the trusted delegation issuers instead of
322
+ resolving them from project policy.
323
+ - Startup validation: `browserPosture` requires `projectId`, an exact HTTPS
324
+ `origin`, `keyId`, and a public P-256 key (no private scalar); invalid or
325
+ duplicate `protectedRoutes` paths throw. Configuring `protectedRoutes`
326
+ without `resolveDelegationChallenge` throws. Use
327
+ `createBrowserIntegrityChallengeResolver` from
328
+ `@kya-os/checkpoint-wasm-runtime/composed-policy`; a challenge whose
329
+ registered scopes do not cover the required scopes renders 503 rather than a
330
+ fabricated consent link.
331
+ - Applies to the in-process `withCheckpoint` middleware (node, edge, bundler).
332
+ `withCheckpointApi` does not verify posture locally.
333
+ - Entries added after publication. See `docs/runbooks/browser-integrity.md`.
12
334
 
13
335
  ## 1.8.0 — fetcher-200 envelope active by default (#3530)
14
336
 
package/README.md CHANGED
@@ -4,45 +4,166 @@ Next.js middleware for Checkpoint AI agent detection and enforcement.
4
4
 
5
5
  ## Features
6
6
 
7
- - 🚀 **Next.js Middleware**: Edge-compatible middleware for all routes
8
- - 🧩 **Two Deployment Shapes**: In-process WASM engine or SaaS gateway
7
+ - 🚀 **Next.js Middleware**: Node.js (`proxy.ts`) and Edge runtime middleware
8
+ - 🧩 **Two Deployment Shapes**: In-process WebAssembly engine or SaaS gateway
9
9
  - 🎯 **Flexible Actions**: Block, redirect, or challenge detected agents
10
10
  - 🛡️ **Edge Runtime**: Optimized for Vercel Edge Functions
11
11
  - 📊 **Dashboard Reporting**: Detections land in your Checkpoint dashboard
12
12
 
13
13
  ## Two deployment shapes
14
14
 
15
- This package ships two complementary middleware factories. Pick the one that
16
- fits your runtime; both are first-class and supported.
15
+ This package ships two middleware factories.
16
+ Both return a Next.js middleware function with the same request and response contract, and you can use both in one app on different routes.
17
17
 
18
- | Shape | Factory | Where verification runs | Use when |
19
- | ---------------- | ------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
20
- | **Local engine** | `withCheckpoint` | In-process, via WASM (`kya-os-engine`) | You want the lowest possible latency, deterministic verdicts, no network round-trip per request, and your runtime can load the WASM artifact (Vercel Node, Vercel Edge with the bundled artifact, Cloudflare Workers with `nodejs_compat`). This is the canonical Phase D output. |
21
- | **SaaS gateway** | `withCheckpointApi` | Cloudflare DNS gateway (`https://detect.checkpoint-gateway.ai`) | You want centralized policy + dashboard rules without a redeploy, you're on a runtime where the WASM artifact won't load (bare-Edge, browser embedding), or you want a single HTTPS hop with cached verdicts. Trades ~30–50ms of edge latency for zero local engine state. |
22
-
23
- Both factories return a Next.js middleware function — the request/response
24
- contract is identical. You can run both side-by-side in the same app on
25
- different routes if your policy demands it.
18
+ | Shape | Factory | Where verification runs | Use when |
19
+ | ---------------- | ------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
20
+ | **Local engine** | `withCheckpoint` | In-process, through WebAssembly (`kya-os-engine`) | You want the lowest latency, verdicts from the engine itself, and no network round trip per request. On Next.js, run it as Edge middleware; see [Runtimes and bundlers](#runtimes-and-bundlers). |
21
+ | **SaaS gateway** | `withCheckpointApi` | Cloudflare DNS gateway (`https://detect.checkpoint-gateway.ai`) | You run somewhere WebAssembly can't load, or want one HTTPS hop with centralized policy. It adds about 30 to 50 ms per request and sends request metadata to the gateway. |
26
22
 
27
23
  ```ts
28
- // middleware.ts — local engine
24
+ // middleware.ts (Edge runtime): local engine
25
+ import engineWasmModule from '@kya-os/checkpoint-nextjs/engine-wasm';
29
26
  import { withCheckpoint } from '@kya-os/checkpoint-nextjs';
30
- export default withCheckpoint({ tenantHost: 'demo.example' });
31
27
 
32
- // middleware.ts — SaaS gateway
28
+ export default withCheckpoint({
29
+ // Honor platform headers only inside Vercel's managed runtime.
30
+ clientIpPolicy: { platform: 'vercel' },
31
+ tenantHost: 'demo.example',
32
+ engineWasmModule,
33
+ });
34
+ ```
35
+
36
+ ```ts
37
+ // middleware.ts: SaaS gateway
33
38
  import { withCheckpointApi } from '@kya-os/checkpoint-nextjs';
39
+
34
40
  export default withCheckpointApi({
41
+ // Honor platform headers only inside Vercel's managed runtime.
42
+ clientIpPolicy: { platform: 'vercel' },
35
43
  apiKey: process.env.CHECKPOINT_API_KEY!,
36
44
  onBlock: 'redirect',
37
45
  redirectUrl: '/blocked',
38
46
  });
39
47
  ```
40
48
 
41
- > Pre-Phase-D the SaaS-gateway factory shipped as `withAgentShield`; the
42
- > name is preserved as a `@deprecated` alias for one release. Same for
43
- > `AgentShieldClient` / `AgentShieldClientConfig` → `CheckpointApiClient`
44
- > / `CheckpointApiClientConfig`. New code should import the
45
- > `Checkpoint*` names.
49
+ ## Runtimes and bundlers
50
+
51
+ `withCheckpoint` loads the engine's WebAssembly inside your middleware, so what works depends on the runtime and the bundler.
52
+ On Next.js, run it as Edge middleware: that works with Turbopack and webpack.
53
+
54
+ | Middleware file | Import | Turbopack (Next.js 16 default) | webpack (Next.js 15 default) |
55
+ | ------------------------------------------------------- | --------------------------------------------------- | ------------------------------ | -------------------------------------------------- |
56
+ | `middleware.ts` on the Edge runtime (recommended) | `@kya-os/checkpoint-nextjs` with `engineWasmModule` | Supported | Supported with [`unstable_allowDynamic`](#webpack) |
57
+ | `proxy.ts`, or `middleware.ts` with `runtime: 'nodejs'` | `@kya-os/checkpoint-nextjs` | Supported | Not supported yet |
58
+
59
+ `withCheckpointApi` needs no WebAssembly and works with either bundler and either runtime; on webpack's Edge runtime it needs the [`unstable_allowDynamic`](#webpack) config too.
60
+
61
+ ### Edge runtime
62
+
63
+ The Edge runtime does not let code compile WebAssembly from bytes, so the engine has to arrive as a compiled `WebAssembly.Module`.
64
+ Import it from `@kya-os/checkpoint-nextjs/engine-wasm` and pass it as `engineWasmModule`:
65
+
66
+ ```ts
67
+ // middleware.ts (Edge runtime)
68
+ import engineWasmModule from '@kya-os/checkpoint-nextjs/engine-wasm';
69
+ import { withCheckpoint } from '@kya-os/checkpoint-nextjs';
70
+
71
+ export default withCheckpoint({
72
+ clientIpPolicy: { platform: 'vercel' },
73
+ tenantHost: 'demo.example',
74
+ engineWasmModule,
75
+ });
76
+
77
+ export const config = {
78
+ matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
79
+ };
80
+ ```
81
+
82
+ `/engine-wasm` imports the binary from this package's own `@kya-os/checkpoint-wasm-runtime` dependency, so it always matches the engine code that loads it, and your app needs no direct dependency on that package.
83
+ On the Edge runtime, `@kya-os/checkpoint-nextjs` resolves to the Edge build (export conditions `edge-light`, `edge-runtime`, `workerd` and `worker`, the same as `/edge`), and without `engineWasmModule` every request is answered 503 and the missing module is logged.
84
+
85
+ #### Cedar policies on the Edge runtime
86
+
87
+ To evaluate the project's Cedar policy on the Edge runtime, pass the Cedar build as `engineWasmModule`, in place of the engine-only build.
88
+ The Cedar build is the engine plus the Cedar policy evaluator, so one module runs detection and the policy:
89
+
90
+ ```ts
91
+ import engineWasmModule from '@kya-os/checkpoint-nextjs/cedar-wasm';
92
+ import { withCheckpoint } from '@kya-os/checkpoint-nextjs';
93
+
94
+ export default withCheckpoint({
95
+ tenantHost: 'demo.example',
96
+ projectId: process.env.CHECKPOINT_PROJECT_ID,
97
+ engineWasmModule,
98
+ });
99
+ ```
100
+
101
+ It is opt-in because it is larger than the engine-only build.
102
+ Configs that pass it as `cedarWasmModule` keep working: on its own it serves both roles, and next to the engine-only build it runs as a second instance, so the bundle carries the engine twice (with `debug`, a hint is logged).
103
+
104
+ Without a Cedar module the project's policy is still fetched and never skipped.
105
+ A project with no Cedar policy is unaffected, and a policy in shadow mode keeps the structured decision.
106
+ A project whose Cedar policy is enforcing has every request answered 503, and the missing module is logged once.
107
+
108
+ The Edge middleware bundle, gzipped, measured in a Next.js 16 app (Turbopack) whose middleware is `withCheckpoint` alone:
109
+
110
+ | Modules | Edge bundle | Vercel Edge limit |
111
+ | ------------------------------------------------------ | ------------- | -------------------------- |
112
+ | `/engine-wasm` as `engineWasmModule` | about 0.94 MB | fits Hobby (1 MB) |
113
+ | `/cedar-wasm` as `engineWasmModule` | about 1.38 MB | fits Pro (2 MB), not Hobby |
114
+ | `/engine-wasm` plus `/cedar-wasm` as `cedarWasmModule` | about 2.13 MB | exceeds Pro |
115
+
116
+ Your own middleware code adds to these.
117
+ If the bundle does not fit your plan, use `withCheckpointApi`, which carries no WebAssembly.
118
+
119
+ ### webpack
120
+
121
+ On the Edge runtime, webpack rejects any module that contains code able to evaluate code at runtime, even when that code never runs.
122
+ Two dependencies trip the check, so allow them in the middleware config:
123
+
124
+ ```ts
125
+ export const config = {
126
+ matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
127
+ unstable_allowDynamic: [
128
+ // The Zod schema library bundled into checkpoint-shared probes for `new Function`
129
+ // support inside a try/catch (its allowsEval check).
130
+ '**/@kya-os/checkpoint-shared/dist/**',
131
+ // The engine's wasm-bindgen glue can compile WebAssembly from bytes; passing
132
+ // engineWasmModule means that path never runs.
133
+ '**/@kya-os/checkpoint-wasm-runtime/wasm/**',
134
+ ],
135
+ };
136
+ ```
137
+
138
+ `withCheckpointApi` needs both entries when you import it from `@kya-os/checkpoint-nextjs`, because on the Edge runtime that is the Edge build, which includes the engine glue.
139
+ Import it from `@kya-os/checkpoint-nextjs/api-middleware` and only the `checkpoint-shared` entry is needed.
140
+
141
+ ### Node.js runtime
142
+
143
+ On the Node.js runtime, `@kya-os/checkpoint-nextjs` runs the engine's Node build, which loads its `.wasm` through `new URL(..., import.meta.url)`.
144
+ Next.js always bundles `proxy.ts` and `middleware.ts`, and Turbopack follows that URL and copies the file into the build output, so the same build works bundled and unbundled.
145
+ `@kya-os/checkpoint-nextjs/node` is the same build.
146
+
147
+ In a minimal Next.js 16 app, `proxy.ts` with `withCheckpoint` traces 117 files (5.6 MiB), against 111 files for a `proxy.ts` without it.
148
+ If the engine cannot load (a missing or unreadable `.wasm`), every request is answered 503, the cause is logged, and the next request tries again.
149
+
150
+ On webpack, the Node.js runtime is not supported yet: the build succeeds, but webpack rewrites the `.wasm` URL into a value Node's file read rejects, so the engine fails to load and every request is answered 503.
151
+
152
+ ### Background work
153
+
154
+ A request can start work that outlives its response: a refresh of the engine's vendor keys, and the detection report when `apiKey` is set.
155
+ `withCheckpoint` registers that work with the `waitUntil` of the event Next.js passes to middleware, so Vercel does not cancel it once the response is sent.
156
+ If you wrap `withCheckpoint` in your own middleware, pass the event through:
157
+
158
+ ```ts
159
+ const checkpoint = withCheckpoint({ tenantHost: 'demo.example' });
160
+
161
+ export default function middleware(request: NextRequest, event: NextFetchEvent) {
162
+ return checkpoint(request, event);
163
+ }
164
+ ```
165
+
166
+ Without an event, it falls back to `waitUntil` from `@vercel/functions`, which only has an effect on Vercel.
46
167
 
47
168
  ## Installation
48
169
 
@@ -54,17 +175,23 @@ npm install @kya-os/checkpoint-nextjs
54
175
 
55
176
  ## Client-IP trust policy
56
177
 
57
- Client-IP resolution defaults to the direct framework or socket peer. For a
58
- Next.js deployment behind Vercel, select the Vercel profile explicitly:
178
+ Set `clientIpPolicy` to resolve an observed client address only where the runtime can authenticate its source. Next.js 15 removed `request.ip`; the default `direct` policy therefore returns no address on current NextRequest objects.
179
+
180
+ | Deployment | Configuration and result |
181
+ | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
182
+ | Vercel managed runtime | `{ platform: 'vercel' }` accepts Vercel's overwritten singleton address header when `VERCEL=1` |
183
+ | Legacy Next runtime with a platform-provided `request.ip` | `{ platform: 'direct' }` uses that framework address |
184
+ | Self-hosted Next behind a proxy or Cloudflare | No authenticated address is available through NextRequest; `trusted-proxy` and `cloudflare` return no address |
185
+
186
+ The Next adapter adopts the strict `resolveObservedClientAddress` contract. Selecting a profile does not authenticate a forwarding header. NextRequest exposes no socket peer for the SDK to verify. Supplying `isTrustedPeer` cannot provide the missing transport address. The SDK withholds the address from both verification and reporting when that boundary is unavailable.
187
+
188
+ For Vercel, keep `clientIpPolicy: { platform: 'vercel' }` and use the runtime-provided `VERCEL=1` signal. Do not set that variable manually on a self-hosted application to enable header trust. Outside Vercel, the Next adapter resolves this profile like `direct`.
59
189
 
60
- withCheckpoint({
61
- tenantHost: 'your.tenant.example',
62
- clientIpPolicy: { platform: 'vercel' },
63
- });
190
+ #### Migrate self-hosted proxy configurations
64
191
 
65
- Forwarding headers are normalized and are not trusted by the middleware
66
- without a matching deployment profile. See the client-IP resolution runbook
67
- for the profile matrix and proxy-chain guidance.
192
+ Earlier versions accepted Cloudflare or X-Forwarded-For values when a profile was selected. Those configurations now return no address through NextRequest. Configure a transport-aware ingress, such as `@kya-os/checkpoint-express`, to verify the actual proxy peer and exact forwarding chain. Keep the Next application on `direct` until it has an authenticated address source. Do not copy a header into `request.ip` or invent a peer value to restore the old behavior.
193
+
194
+ Unavailable address evidence does not establish a clean network result. The strict resolver returns `status: 'unavailable'`, a reason, and a null `observedClientAddress`; the Next adapter returns `undefined` for its compatibility API. See the [client-IP resolution runbook](https://github.com/Know-That-Ai/checkpoint/blob/main/docs/runbooks/client-ip-resolution.md) for the supported boundaries and migration checks.
68
195
 
69
196
  ### Middleware Setup
70
197
 
@@ -74,6 +201,8 @@ Create `middleware.js` (or `middleware.ts`) in your project root:
74
201
  import { withCheckpointApi } from '@kya-os/checkpoint-nextjs';
75
202
 
76
203
  export default withCheckpointApi({
204
+ // Honor platform headers only inside Vercel's managed runtime.
205
+ clientIpPolicy: { platform: 'vercel' },
77
206
  apiKey: process.env.CHECKPOINT_API_KEY,
78
207
  });
79
208
 
@@ -129,8 +258,9 @@ export default withCheckpointApi({
129
258
  // Request timeout in ms. Default: 5000
130
259
  timeout: 5000,
131
260
 
132
- // Fail open (allow) on API errors. Default: true
133
- failOpen: true,
261
+ // Fail open (allow) on API errors. Default: false (503 + Retry-After).
262
+ // Requests that present a credential are answered 503 even when true.
263
+ failOpen: false,
134
264
 
135
265
  // Observability callback when an agent is detected
136
266
  onAgentDetected: async (request, decision) => {
@@ -149,6 +279,21 @@ your deployed dashboard policy in-process), and more. See the
149
279
  [middleware docs](https://kya.vouched.id/docs/enforce/middleware) for the
150
280
  full option tables for both shapes.
151
281
 
282
+ ## Failure behavior
283
+
284
+ `withCheckpoint` answers `503` (`Retry-After: 3`, `Cache-Control: no-store`)
285
+ when the verification pipeline errors; it never passes the request through or
286
+ returns a 500. If the policy API is unreachable, the last successfully fetched
287
+ policy (at most 24h old) is served; with none, the request is answered `503`
288
+ and the default policy is never substituted. The last-good copy lives in
289
+ process memory and, when a `PolicyCacheAdapter` is configured, in that adapter
290
+ (so a cold process or isolate can still serve it). A policy-origin 401/403/404
291
+ or a body that is not a policy-API response is treated like an outage:
292
+ last-good is served for up to 24h.
293
+
294
+ `withCheckpoint` itself never throws, because a Next.js middleware module that fails to load can let requests through unchecked.
295
+ An invalid configuration (for example a missing `engineWasmModule` on the Edge runtime) and an engine that fails to load (for example an unreadable `.wasm`) are logged with a `[checkpoint]` prefix and every request is answered `503`.
296
+
152
297
  ## Actions
153
298
 
154
299
  ### Block Agents
@@ -318,3 +463,32 @@ MIT OR Apache-2.0
318
463
 
319
464
  For opt-in classification, signed posture and scoped consent step-up, see the
320
465
  [browser integrity rollout runbook](../../docs/runbooks/browser-integrity.md).
466
+
467
+ ### Reading the browser posture outcome
468
+
469
+ With `browserPosture` configured, read the posture outcome for a request in a route
470
+ handler or page. The accessor verifies the posture token from the request's `KYA-Posture`
471
+ headers or cookies with the same verifier and the same posture config the middleware
472
+ uses, so nothing is forwarded and there is no extra secret:
473
+
474
+ ```ts
475
+ import { getCheckpointPostureOutcome } from '@kya-os/checkpoint-nextjs';
476
+ import { browserPosture, projectId } from '@/checkpoint-config';
477
+
478
+ export async function POST(request: Request) {
479
+ const outcome = await getCheckpointPostureOutcome(request, { browserPosture, projectId });
480
+ return Response.json({ posture: outcome.status, verdict: outcome.posture?.verdict });
481
+ }
482
+ ```
483
+
484
+ The result is `{ status: 'verified' | 'absent' | 'rejected', reason?, posture? }`, with
485
+ `posture` (the verified claims, as a frozen copy) only when verified. The accessor always
486
+ checks: it returns `verified`, `absent` or `rejected` for the request it is given, and does
487
+ not depend on the middleware having run or on the route matching it. `status: 'verified'`
488
+ means the token signature and claims are valid, so check `posture.verdict` before treating
489
+ the visitor as human. Given a bare `Headers` (for example `await headers()` in a server
490
+ component), pass those instead of a request. Verification is a single ES256 check, so
491
+ calling it in a handler as well as in the middleware costs little. A verified token that carries
492
+ the beacon's agent or bot verdict (`posture.detection`), or discloses automation, also
493
+ reclassifies a request the engine called human or incomplete data.
494
+ The accessor validates `browserPosture` and `projectId` with the same check `withCheckpoint` runs at startup: `projectId` must be the lowercase project UUID, not the friendly id, and any invalid config throws. Pass the same config object the middleware takes. Treat `absent` and `rejected` alike (neither is usable posture evidence), and log `reason` on the server rather than returning it to the client.