@kya-os/checkpoint-nextjs 1.12.0 → 1.14.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 (75) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +13 -9
  3. package/dist/{adapt-BvqYgrAk.mjs → adapt-BGEyLf44.mjs} +12 -2
  4. package/dist/adapt-BGEyLf44.mjs.map +1 -0
  5. package/dist/{adapt-DUEIfZnx.js → adapt-D2-OBY9M.js} +16 -0
  6. package/dist/{api-client-JHOrRUA_.d.ts → api-client-yjr43Itz.d.mts} +6 -17
  7. package/dist/api-client-yjr43Itz.d.mts.map +1 -0
  8. package/dist/{api-client-JHOrRUA_.d.mts → api-client-yjr43Itz.d.ts} +6 -17
  9. package/dist/api-client-yjr43Itz.d.ts.map +1 -0
  10. package/dist/api-client.d.mts +1 -1
  11. package/dist/api-client.d.ts +1 -1
  12. package/dist/api-client.js +44 -58
  13. package/dist/api-client.mjs +44 -58
  14. package/dist/api-client.mjs.map +1 -1
  15. package/dist/{api-middleware-beNlXd5P.js → api-middleware-BVXf7qCM.js} +5 -3
  16. package/dist/{api-middleware-DvmkJ_Li.mjs → api-middleware-CAarHFKk.mjs} +6 -4
  17. package/dist/api-middleware-CAarHFKk.mjs.map +1 -0
  18. package/dist/{api-middleware-BtsYJU5u.d.mts → api-middleware-CIXuGurw.d.mts} +4 -2
  19. package/dist/{api-middleware-BtsYJU5u.d.mts.map → api-middleware-CIXuGurw.d.mts.map} +1 -1
  20. package/dist/{api-middleware-DyLDqOYF.d.ts → api-middleware-CpAbnkfa.d.ts} +4 -2
  21. package/dist/{api-middleware-DyLDqOYF.d.ts.map → api-middleware-CpAbnkfa.d.ts.map} +1 -1
  22. package/dist/api-middleware.d.mts +1 -1
  23. package/dist/api-middleware.d.ts +1 -1
  24. package/dist/api-middleware.js +1 -1
  25. package/dist/api-middleware.mjs +1 -1
  26. package/dist/cedar-wasm.d.mts +1 -1
  27. package/dist/cedar-wasm.d.ts +1 -1
  28. package/dist/cedar-wasm.js +1 -1
  29. package/dist/cedar-wasm.mjs +1 -1
  30. package/dist/cedar-wasm.mjs.map +1 -1
  31. package/dist/{config-DkXvl4nH.d.ts → config-CVqpjhwT.d.mts} +12 -6
  32. package/dist/config-CVqpjhwT.d.mts.map +1 -0
  33. package/dist/{config-D7h2w_it.d.mts → config-Dn2ptSA2.d.ts} +12 -6
  34. package/dist/config-Dn2ptSA2.d.ts.map +1 -0
  35. package/dist/index-edge.d.mts +5 -5
  36. package/dist/index-edge.d.ts +5 -5
  37. package/dist/index-edge.js +2 -2
  38. package/dist/index-edge.mjs +2 -2
  39. package/dist/index.d.mts +5 -5
  40. package/dist/index.d.ts +5 -5
  41. package/dist/index.js +2 -2
  42. package/dist/index.mjs +2 -2
  43. package/dist/middleware-bundler.d.mts +1 -1
  44. package/dist/middleware-bundler.d.ts +1 -1
  45. package/dist/middleware-bundler.js +1 -1
  46. package/dist/middleware-bundler.mjs +1 -1
  47. package/dist/{middleware-core-BmW2kH8J.d.ts → middleware-core-BLCAErYE.d.ts} +3 -3
  48. package/dist/middleware-core-BLCAErYE.d.ts.map +1 -0
  49. package/dist/{middleware-core-WZeMSRqx.mjs → middleware-core-C4xi1I9I.mjs} +61 -27
  50. package/dist/middleware-core-C4xi1I9I.mjs.map +1 -0
  51. package/dist/{middleware-core-CnPUoD2v.d.mts → middleware-core-D88q8dIt.d.mts} +3 -3
  52. package/dist/middleware-core-D88q8dIt.d.mts.map +1 -0
  53. package/dist/{middleware-core-B1GuspOY.js → middleware-core-tGGPv727.js} +60 -26
  54. package/dist/middleware-edge.d.mts +1 -1
  55. package/dist/middleware-edge.d.ts +1 -1
  56. package/dist/middleware-edge.js +1 -1
  57. package/dist/middleware-edge.mjs +1 -1
  58. package/dist/middleware-node.d.mts +2 -2
  59. package/dist/middleware-node.d.ts +2 -2
  60. package/dist/middleware-node.js +1 -1
  61. package/dist/middleware-node.mjs +1 -1
  62. package/dist/public-api-CBQzjriI.d.mts +5 -0
  63. package/dist/public-api-Ea4jgcwD.d.ts +5 -0
  64. package/package.json +3 -3
  65. package/dist/adapt-BvqYgrAk.mjs.map +0 -1
  66. package/dist/api-client-JHOrRUA_.d.mts.map +0 -1
  67. package/dist/api-client-JHOrRUA_.d.ts.map +0 -1
  68. package/dist/api-middleware-DvmkJ_Li.mjs.map +0 -1
  69. package/dist/config-D7h2w_it.d.mts.map +0 -1
  70. package/dist/config-DkXvl4nH.d.ts.map +0 -1
  71. package/dist/middleware-core-BmW2kH8J.d.ts.map +0 -1
  72. package/dist/middleware-core-CnPUoD2v.d.mts.map +0 -1
  73. package/dist/middleware-core-WZeMSRqx.mjs.map +0 -1
  74. package/dist/public-api-Cw7Zj290.d.ts +0 -5
  75. package/dist/public-api-DgCw1uo6.d.mts +0 -5
package/CHANGELOG.md CHANGED
@@ -2,6 +2,57 @@
2
2
 
3
3
  # @kya-os/checkpoint-nextjs
4
4
 
5
+ ## 1.14.0 - 2026-11-16
6
+
7
+ ### Breaking changes
8
+
9
+ - Removed: the policy helpers, removed in 1.11.0 by #6271 from both the `./policy` entry point and the package root, and listed then only under "Other merged changes". That covers `evaluatePolicyForDetection`, `handlePolicyDecision`, `applyPolicy`, `getPolicy` and `createContextFromDetection`; `buildBlockedResponse` and `buildRedirectResponse`, which the root exported as `buildPolicyBlockedResponse` and `buildPolicyRedirectResponse`; `buildChallengeResponse` (`./policy` only); the re-exported `evaluatePolicy`, `createEvaluationContext`, `ENFORCEMENT_ACTIONS` and `DEFAULT_POLICY`; and the types `PolicyMiddlewareConfig`, `NextJSPolicyMiddlewareConfig`, `PolicyConfig`, `PolicyEvaluationContext` and `PolicyEvaluationResult`. The project's deployed composed policy replaces them: `withCheckpoint({ projectId })` fetches it and evaluates every request in the engine, and `withCheckpointApi` gets the same decision from the hosted gateway. (#6809)
10
+ - Removed: the legacy entry points and aliases, also removed in 1.11.0 by #6271, whose imports now fail at build:
11
+ - the throw stubs `./middleware`, `./edge-wasm-middleware`, `createMiddleware`, `createAgentShieldMiddleware`, `createAgentShieldMiddlewareBase` and `createEnhancedAgentShieldMiddleware`;
12
+ - the TypeScript detector entries `./edge-runtime-loader` and `./wasm-setup`;
13
+ - the `AgentShield*` aliases of the current API: `withAgentShield`, `agentShieldMiddleware`, `AgentShieldClient`, `getAgentShieldClient` and `resetAgentShieldClient`, with `AgentShieldMiddlewareConfig` and `AgentShieldClientConfig`.
14
+ Use `withCheckpoint`, `withCheckpointApi`, `CheckpointApiClient`, `getCheckpointApiClient` and `resetCheckpointApiClient`. (#6809)
15
+ - Changed: In enforce mode, `projectId` (including one set for `browserPosture`) without `apiKey` is a configuration error: it is logged, and every request is answered 503.
16
+ Like every configuration error, it does not throw from the middleware module. (#6973)
17
+
18
+ ### Changed
19
+
20
+ - On the Node.js runtime, the project's policy is read once when the middleware starts, so a refused key is logged before the first request.
21
+ A refused key (HTTP 401 or 403) is logged as a configuration error naming `CHECKPOINT_API_KEY`, at most about once a minute, and so are the detection reports the dashboard refuses for it.
22
+ A policy outage is logged at most about every 5 seconds, and the next request reads the policy again. (#6973)
23
+ - CheckpointApiClient.logDetection retries once, after waiting it out, when the receiver sheds with a 503 whose Retry-After is 1 to 3 seconds. (#7250)
24
+ - `withCheckpointApi` sends its detection reports in gzip batches instead of one request each, with `telemetryBatchSize` and `telemetryFlushIntervalMs` to tune or turn off batching (`telemetryBatchSize: 1`). `CheckpointApiClient.logDetection` no longer rejects when the dashboard is unreachable: it warns and resolves. (#7338)
25
+
26
+ ### Fixed
27
+
28
+ - Since 1.11.0, `withCheckpoint` with `projectId` and no `apiKey` answered every request 503 in observe mode and logged a policy fetch failure for each.
29
+ In observe mode it now serves every request on the engine's decision without fetching the policy, and logs one warning at startup that `projectId` needs `apiKey` to apply the project's policy. (#6973)
30
+ - In observe mode, requests are served when the project's policy cannot be read, as when the policy API is down or refuses the key.
31
+ Enforce mode still answers 503 with `Retry-After: 3`. (#6973)
32
+ - a log-detection report answered with 503 is retried once even when Retry-After is missing, not a whole number or outside 1 to 3 seconds (the wait is clamped to 1-3 s); it was dropped before. (#7250)
33
+
34
+ ## 1.13.0 - 2026-10-22
35
+
36
+ ### Changed
37
+
38
+ - A kya-http/2 signed body over 1 MiB is answered with 413 (`Cache-Control: no-store`, empty body), as the
39
+ .NET adapters do. It is never verified in part. In `enforcementMode: 'observe'` it passes through instead: it is
40
+ verified without its bytes, refused there, and reported as the would-have-been Block (`onResult` and the reporter
41
+ see it). (#6147)
42
+ - `drainJsonBody: false` turns this read off too. A kya-http/2 request whose `Content-Length` or
43
+ `Transfer-Encoding` declares a body is then refused with 403 `kyaos/profile-violation`, unless its `Content-Digest`
44
+ already fails (`kyaos/invalid-signature`). Next.js truncates bodies past `proxyClientMaxBodySize` (10 MB default);
45
+ a body over 1 MiB never gets that far. (#6147)
46
+ - A body the framing declares but Next.js gives no stream for (a GET, for example) counts as unread, never
47
+ as an empty body, so it is refused the same way. (#6147)
48
+
49
+ ### Fixed
50
+
51
+ - A kya-http/2 signed request with a body was always refused as `kyaos/invalid-signature`, because the body
52
+ never reached the engine. The middleware now reads a clone of the body of any request that carries a `kya`
53
+ signature (any content type, up to 1 MiB) and passes the exact bytes. The route handler still gets the original
54
+ body. Vendor (`sig1`) signed requests are not read. Needs the matching `@kya-os/checkpoint-wasm-runtime` release. (#6147)
55
+
5
56
  ## 1.12.0 - 2026-10-22
6
57
 
7
58
  ### Breaking changes
package/README.md CHANGED
@@ -90,6 +90,7 @@ import engineWasmModule from '@kya-os/checkpoint-nextjs/cedar-wasm';
90
90
  import { withCheckpoint } from '@kya-os/checkpoint-nextjs';
91
91
 
92
92
  export default withCheckpoint({
93
+ apiKey: process.env.CHECKPOINT_API_KEY,
93
94
  projectId: process.env.CHECKPOINT_PROJECT_ID,
94
95
  engineWasmModule,
95
96
  });
@@ -149,6 +150,7 @@ On webpack, the Node.js runtime is not supported yet: the build succeeds, but we
149
150
  ### Background work
150
151
 
151
152
  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.
153
+ Detection reports go to the dashboard in gzip batches: `telemetryBatchSize` (default 200, at most 500; `1` sends each report alone) sets the batch and `telemetryFlushIntervalMs` (default 2000) the longest a report waits. Every request is reported, humans included, and the first report after a quiet period is sent at once.
152
154
  `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.
153
155
  If you wrap `withCheckpoint` in your own middleware, pass the event through:
154
156
 
@@ -271,8 +273,10 @@ export default withCheckpointApi({
271
273
 
272
274
  The local-engine shape (`withCheckpoint`) takes a `CheckpointConfig` instead,
273
275
  every field optional: `enforcementMode` (`'enforce'` | `'observe'`), `apiKey`
274
- (enables dashboard reporting), `projectId` (enforces your deployed dashboard
275
- policy in-process), and more. `tenantHost` is deprecated: it is no longer used
276
+ (enables dashboard reporting), `projectId` (applies your deployed dashboard
277
+ policy in-process, and needs `apiKey`: without it, enforce mode is a
278
+ configuration error answered 503, and observe mode serves without the policy and
279
+ warns once), and more. `tenantHost` is deprecated: it is no longer used
276
280
  and will be removed. See the
277
281
  [middleware docs](https://kya.vouched.id/docs/enforce/middleware) for the
278
282
  full option tables for both shapes.
@@ -281,13 +285,13 @@ full option tables for both shapes.
281
285
 
282
286
  `withCheckpoint` answers `503` (`Retry-After: 3`, `Cache-Control: no-store`)
283
287
  when the verification pipeline errors; it never passes the request through or
284
- returns a 500. If the policy API is unreachable, the last successfully fetched
285
- policy (at most 24h old) is served; with none, the request is answered `503`
286
- and the default policy is never substituted. The last-good copy lives in
287
- process memory and, when a `PolicyCacheAdapter` is configured, in that adapter
288
- (so a cold process or isolate can still serve it). A policy-origin 401/403/404
289
- or a body that is not a policy-API response is treated like an outage:
290
- last-good is served for up to 24h.
288
+ returns a 500. If the policy API is unreachable,
289
+ a policy still inside its cache window (`policyCacheTtlSeconds`, 300 by default)
290
+ keeps being used. Once that window ends, or on a cold start, the request is
291
+ answered `503`: no older copy is kept, and the default policy is never
292
+ substituted. A timeout, a 5xx, a policy-origin 401/403/404 or a body that is
293
+ not a policy-API response all end the same way. In observe mode the request is
294
+ served on the engine's decision instead.
291
295
 
292
296
  ### DID documents and status lists
293
297
 
@@ -41,6 +41,16 @@ function failClosedResponse() {
41
41
  });
42
42
  }
43
43
  /**
44
+ * 413 (no-store, empty body) for a kya-http/2 signed body over the 1 MiB read
45
+ * bound, the answer the .NET adapters give. The body is never verified in part.
46
+ */
47
+ function signedBodyTooLargeResponse() {
48
+ return new NextResponse(null, {
49
+ status: 413,
50
+ headers: { "Cache-Control": "no-store" }
51
+ });
52
+ }
53
+ /**
44
54
  * Convert the engine's transport-agnostic `RenderedResponse` into a
45
55
  * `NextResponse`. Sites-1's Playwright suite is the regression gate;
46
56
  * any drift here is caught downstream.
@@ -93,5 +103,5 @@ function applyHeaders(res, rendered) {
93
103
  }
94
104
 
95
105
  //#endregion
96
- export { failClosedResponse as n, adaptToNextResponse as t };
97
- //# sourceMappingURL=adapt-BvqYgrAk.mjs.map
106
+ export { failClosedResponse as n, signedBodyTooLargeResponse as r, adaptToNextResponse as t };
107
+ //# sourceMappingURL=adapt-BGEyLf44.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapt-BGEyLf44.mjs","names":[],"sources":["../src/adapt.ts"],"sourcesContent":["/**\n * D.3 — `RenderedResponse` → `NextResponse` adapter.\n *\n * The host wrapper's *only* job on the outbound path: take the\n * transport-agnostic `RenderedResponse` Phase C's\n * `renderDecisionAsResponse` produces and translate it to a\n * `NextResponse`. Zero verdict decisions, zero engine I/O.\n *\n * Shared between the Node-runtime and Edge-runtime entries. The\n * branching here is identical in both — Next.js `NextResponse` has the\n * same API surface across runtimes; only the underlying response\n * primitive differs (Node http.ServerResponse vs Edge `Response`).\n *\n * Architectural pins per architect § 4.3 / § 4.4:\n *\n * 1. **Verdict-cookie format is contract.** Sites-1's Sonner toast\n * depends on `__checkpoint_verdict=%7B%22verdict%22%3A%22<v>%22...\n * %7D` (single URL-encoded JSON). Byte-format pinned by adapt.test.\n *\n * 2. **HTML-accepting clients → `/blocked` rewrite at status 200**\n * (so the page renders with the verdict cookie set; Sonner picks\n * up the cookie and shows the toast). Non-HTML clients → JSON 4xx.\n *\n * 3. **`X-Checkpoint-Engine` carries `result.engineInfo.name`** —\n * `checkpoint-engine-wasm` after Phase D ships. Brian's Sites-2\n * deviation note confirmed the `X-Checkpoint-*` prefix is canon.\n */\n\nimport { type NextRequest, NextResponse } from 'next/server.js';\n\nimport type { RenderedResponse } from '@kya-os/checkpoint-wasm-runtime/orchestrator';\nimport {\n VERDICT_COOKIE_NAME,\n BLOCKED_PATH,\n encodeVerdictCookie,\n acceptsHtml,\n classifyResponseShape,\n} from '@kya-os/checkpoint-shared/host-adapter';\nimport {\n FAIL_CLOSED_BODY,\n FAIL_CLOSED_HEADERS,\n FAIL_CLOSED_STATUS,\n} from '@kya-os/checkpoint-shared/policy/enforcement';\n\n/**\n * 503 (Retry-After, no-store) for an engine/pipeline fault. Never a 500 and\n * never a pass-through: an unverifiable request is not allowed.\n */\nexport function failClosedResponse(): NextResponse {\n return NextResponse.json(FAIL_CLOSED_BODY, {\n status: FAIL_CLOSED_STATUS,\n headers: FAIL_CLOSED_HEADERS,\n });\n}\n\n/**\n * 413 (no-store, empty body) for a kya-http/2 signed body over the 1 MiB read\n * bound, the answer the .NET adapters give. The body is never verified in part.\n */\nexport function signedBodyTooLargeResponse(): NextResponse {\n return new NextResponse(null, { status: 413, headers: { 'Cache-Control': 'no-store' } });\n}\n\n/**\n * Convert the engine's transport-agnostic `RenderedResponse` into a\n * `NextResponse`. Sites-1's Playwright suite is the regression gate;\n * any drift here is caught downstream.\n */\nexport function adaptToNextResponse(rendered: RenderedResponse, req: NextRequest): NextResponse {\n const clientAcceptsHtml = acceptsHtml(req.headers);\n const verdictCookie = encodeVerdictCookie(rendered);\n const shape = classifyResponseShape(rendered, clientAcceptsHtml);\n\n switch (shape) {\n case 'pass-through': {\n // Permit OR Observe-mode any-verdict.\n const res = NextResponse.next();\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n\n case 'redirect': {\n // Decision::Redirect → 302 + Location.\n const target = new URL(rendered.headers.Location!);\n const res = NextResponse.redirect(target);\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n\n case 'html-block': {\n // Sites-1 contract: HTML clients (browsers) need a renderable page\n // to show the rejection UI. The verdict cookie carries the reason;\n // the /blocked route reads it and renders the toast.\n const blockedUrl = new URL(BLOCKED_PATH, req.url);\n const res = NextResponse.rewrite(blockedUrl, { status: 200 });\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n\n case 'json-block': {\n // The orchestrator's RenderedResponse already supplies the correct\n // status (401/403/422/...); we just need to materialise the body.\n // application/problem+json (Instruct) uses the Content-Type from\n // rendered.headers; defaults to application/json for everything else.\n const body = rendered.body ?? {};\n const res = NextResponse.json(body, { status: rendered.status as number });\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n }\n}\n\n// -----------------------------------------------------------------------------\n// Helpers — Next.js-specific glue. The framework-agnostic primitives\n// (encodeVerdictCookie, acceptsHtml, classifyResponseShape,\n// VERDICT_COOKIE_NAME, BLOCKED_PATH) live in `@kya-os/checkpoint-shared`\n// so checkpoint-express + future host wrappers produce byte-identical\n// cookies and route HTML/JSON branching the same way.\n// -----------------------------------------------------------------------------\n\nfunction setVerdictCookie(res: NextResponse, value: string): void {\n // Path / SameSite / HttpOnly chosen for the Sonner-bridge use case:\n // path=/ so any route can read it, SameSite=Lax so first-party\n // navigations carry it, HttpOnly=false so the client-side toast JS\n // can read it (it's verdict UX, not a session token).\n res.cookies.set({\n name: VERDICT_COOKIE_NAME,\n value,\n path: '/',\n sameSite: 'lax',\n httpOnly: false,\n });\n}\n\nfunction applyHeaders(res: NextResponse, rendered: RenderedResponse): void {\n // NextResponse.next() / rewrite() / json() return responses with\n // some default headers; orchestrator headers (X-Checkpoint-*, Location)\n // override. We don't strip pre-existing headers — only set new ones.\n for (const [key, value] of Object.entries(rendered.headers)) {\n res.headers.set(key, value);\n }\n for (const [key, value] of rendered.headerEntries ?? []) {\n res.headers.append(key, value);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,qBAAmC;CACjD,OAAO,aAAa,KAAK,kBAAkB;EACzC,QAAQ;EACR,SAAS;CACX,CAAC;AACH;;;;;AAMA,SAAgB,6BAA2C;CACzD,OAAO,IAAI,aAAa,MAAM;EAAE,QAAQ;EAAK,SAAS,EAAE,iBAAiB,WAAW;CAAE,CAAC;AACzF;;;;;;AAOA,SAAgB,oBAAoB,UAA4B,KAAgC;CAC9F,MAAM,oBAAoB,YAAY,IAAI,OAAO;CACjD,MAAM,gBAAgB,oBAAoB,QAAQ;CAGlD,QAFc,sBAAsB,UAAU,iBAElC,GAAZ;EACE,KAAK,gBAAgB;GAEnB,MAAM,MAAM,aAAa,KAAK;GAC9B,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;EAEA,KAAK,YAAY;GAEf,MAAM,SAAS,IAAI,IAAI,SAAS,QAAQ,QAAS;GACjD,MAAM,MAAM,aAAa,SAAS,MAAM;GACxC,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;EAEA,KAAK,cAAc;GAIjB,MAAM,aAAa,IAAI,IAAI,cAAc,IAAI,GAAG;GAChD,MAAM,MAAM,aAAa,QAAQ,YAAY,EAAE,QAAQ,IAAI,CAAC;GAC5D,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;EAEA,KAAK,cAAc;GAKjB,MAAM,OAAO,SAAS,QAAQ,CAAC;GAC/B,MAAM,MAAM,aAAa,KAAK,MAAM,EAAE,QAAQ,SAAS,OAAiB,CAAC;GACzE,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;CACF;AACF;AAUA,SAAS,iBAAiB,KAAmB,OAAqB;CAKhE,IAAI,QAAQ,IAAI;EACd,MAAM;EACN;EACA,MAAM;EACN,UAAU;EACV,UAAU;CACZ,CAAC;AACH;AAEA,SAAS,aAAa,KAAmB,UAAkC;CAIzE,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,OAAO,GACxD,IAAI,QAAQ,IAAI,KAAK,KAAK;CAE5B,KAAK,MAAM,CAAC,KAAK,UAAU,SAAS,iBAAiB,CAAC,GACpD,IAAI,QAAQ,OAAO,KAAK,KAAK;AAEjC"}
@@ -41,6 +41,16 @@ function failClosedResponse() {
41
41
  });
42
42
  }
43
43
  /**
44
+ * 413 (no-store, empty body) for a kya-http/2 signed body over the 1 MiB read
45
+ * bound, the answer the .NET adapters give. The body is never verified in part.
46
+ */
47
+ function signedBodyTooLargeResponse() {
48
+ return new next_server_js.NextResponse(null, {
49
+ status: 413,
50
+ headers: { "Cache-Control": "no-store" }
51
+ });
52
+ }
53
+ /**
44
54
  * Convert the engine's transport-agnostic `RenderedResponse` into a
45
55
  * `NextResponse`. Sites-1's Playwright suite is the regression gate;
46
56
  * any drift here is caught downstream.
@@ -104,4 +114,10 @@ Object.defineProperty(exports, 'failClosedResponse', {
104
114
  get: function () {
105
115
  return failClosedResponse;
106
116
  }
117
+ });
118
+ Object.defineProperty(exports, 'signedBodyTooLargeResponse', {
119
+ enumerable: true,
120
+ get: function () {
121
+ return signedBodyTooLargeResponse;
122
+ }
107
123
  });
@@ -19,6 +19,8 @@ interface CheckpointApiClientConfig {
19
19
  timeout?: number;
20
20
  /** Enable debug logging */
21
21
  debug?: boolean;
22
+ telemetryBatchSize?: number;
23
+ telemetryFlushIntervalMs?: number;
22
24
  }
23
25
  /**
24
26
  * Enforcement decision from the API
@@ -176,6 +178,9 @@ declare class CheckpointApiClient {
176
178
  private useEdge;
177
179
  private timeout;
178
180
  private debug;
181
+ private telemetryBatchSize;
182
+ private telemetryFlushIntervalMs;
183
+ private reportSender;
179
184
  constructor(config: CheckpointApiClientConfig);
180
185
  /**
181
186
  * Call the enforce API to check if a request should be allowed
@@ -194,22 +199,6 @@ declare class CheckpointApiClient {
194
199
  * Check if this client is using edge detection (Gateway Worker)
195
200
  */
196
201
  isUsingEdge(): boolean;
197
- /**
198
- * Log a detection result to the Checkpoint database.
199
- * Use after Gateway Worker detection to persist results.
200
- * Fire-and-forget - returns immediately without waiting for DB write.
201
- *
202
- * @example
203
- * ```typescript
204
- * // After receiving Gateway response
205
- * if (client.isUsingEdge() && response.data?.detection) {
206
- * client.logDetection({
207
- * detection: response.data.detection,
208
- * context: { userAgent, ipAddress, path, url, method }
209
- * }).catch(err => console.error('Log failed:', err));
210
- * }
211
- * ```
212
- */
213
202
  logDetection(input: LogDetectionInput): Promise<void>;
214
203
  }
215
204
  declare function getCheckpointApiClient(config?: Partial<CheckpointApiClientConfig>): CheckpointApiClient;
@@ -219,4 +208,4 @@ declare function getCheckpointApiClient(config?: Partial<CheckpointApiClientConf
219
208
  declare function resetCheckpointApiClient(): void;
220
209
  //#endregion
221
210
  export { EnforceResponse as a, LogDetectionInput as c, EnforceInput as i, getCheckpointApiClient as l, CheckpointApiClient as n, EnforcementAction as o, CheckpointApiClientConfig as r, EnforcementDecision as s, ApiDetectionDetail as t, resetCheckpointApiClient as u };
222
- //# sourceMappingURL=api-client-JHOrRUA_.d.ts.map
211
+ //# sourceMappingURL=api-client-yjr43Itz.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client-yjr43Itz.d.mts","names":[],"sources":["../src/api-client.ts"],"mappings":";;;;;UAkBiB;;EAEf;;EAEA;;;;;;;EAOA;;EAEA;;EAEA;EACA;EACA;;;;;UAgBe;EACf,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;MACE;MACA;MACA;MACA;;IAEF;MACE;MACA;MACA;MACA;;;;;;;KAQM,qBAAqB,KAC/B;EAGA;;EAEA;EACA;EACA;EACA,UAAU;EACV,YAAY;;EAEZ;EACA;;;;;;;;;EASA;;;;;UAMe;EACf;EACA;IACE,UAAU;IACV;IACA;IACA,YAAY;;;;;;IAMZ,SAAS;;EAEX;IACE;IACA;;;;;;UAOa;;EAEf,UAAU;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;IAEE;;IAEA;;;;;;UAOa;;EAEf,WAAW;;EAEX;IACE;IACA;IACA;IACA;IACA;;;EAGF;;EAEA;IAAgB,QAAQ;;;EAExB,SAAS;;EAET;IAAQ;IAAc;IAAiB;;;;;;;;;;;;;;;;;;;;;;;cA8B5B;UACH;UACA;UACA;UACA;UACA;UACA;UACA;UACA;EAEI,YAAA,QAAQ;;;;EAkBd,QAAQ,OAAO,eAAe,QAAQ;;;;;;EA4FtC,WAAW,OAAO,eAAe;IACrC,QAAQ;IACR;;;;;EAmBF;EAIM,aAAa,OAAO,oBAAoB;;iBAiFhC,uBACd,SAAS,QAAQ,6BAChB;;;;iBAgBa"}
@@ -19,6 +19,8 @@ interface CheckpointApiClientConfig {
19
19
  timeout?: number;
20
20
  /** Enable debug logging */
21
21
  debug?: boolean;
22
+ telemetryBatchSize?: number;
23
+ telemetryFlushIntervalMs?: number;
22
24
  }
23
25
  /**
24
26
  * Enforcement decision from the API
@@ -176,6 +178,9 @@ declare class CheckpointApiClient {
176
178
  private useEdge;
177
179
  private timeout;
178
180
  private debug;
181
+ private telemetryBatchSize;
182
+ private telemetryFlushIntervalMs;
183
+ private reportSender;
179
184
  constructor(config: CheckpointApiClientConfig);
180
185
  /**
181
186
  * Call the enforce API to check if a request should be allowed
@@ -194,22 +199,6 @@ declare class CheckpointApiClient {
194
199
  * Check if this client is using edge detection (Gateway Worker)
195
200
  */
196
201
  isUsingEdge(): boolean;
197
- /**
198
- * Log a detection result to the Checkpoint database.
199
- * Use after Gateway Worker detection to persist results.
200
- * Fire-and-forget - returns immediately without waiting for DB write.
201
- *
202
- * @example
203
- * ```typescript
204
- * // After receiving Gateway response
205
- * if (client.isUsingEdge() && response.data?.detection) {
206
- * client.logDetection({
207
- * detection: response.data.detection,
208
- * context: { userAgent, ipAddress, path, url, method }
209
- * }).catch(err => console.error('Log failed:', err));
210
- * }
211
- * ```
212
- */
213
202
  logDetection(input: LogDetectionInput): Promise<void>;
214
203
  }
215
204
  declare function getCheckpointApiClient(config?: Partial<CheckpointApiClientConfig>): CheckpointApiClient;
@@ -219,4 +208,4 @@ declare function getCheckpointApiClient(config?: Partial<CheckpointApiClientConf
219
208
  declare function resetCheckpointApiClient(): void;
220
209
  //#endregion
221
210
  export { EnforceResponse as a, LogDetectionInput as c, EnforceInput as i, getCheckpointApiClient as l, CheckpointApiClient as n, EnforcementAction as o, CheckpointApiClientConfig as r, EnforcementDecision as s, ApiDetectionDetail as t, resetCheckpointApiClient as u };
222
- //# sourceMappingURL=api-client-JHOrRUA_.d.mts.map
211
+ //# sourceMappingURL=api-client-yjr43Itz.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-client-yjr43Itz.d.ts","names":[],"sources":["../src/api-client.ts"],"mappings":";;;;;UAkBiB;;EAEf;;EAEA;;;;;;;EAOA;;EAEA;;EAEA;EACA;EACA;;;;;UAgBe;EACf,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;MACE;MACA;MACA;MACA;;IAEF;MACE;MACA;MACA;MACA;;;;;;;KAQM,qBAAqB,KAC/B;EAGA;;EAEA;EACA;EACA;EACA,UAAU;EACV,YAAY;;EAEZ;EACA;;;;;;;;;EASA;;;;;UAMe;EACf;EACA;IACE,UAAU;IACV;IACA;IACA,YAAY;;;;;;IAMZ,SAAS;;EAEX;IACE;IACA;;;;;;UAOa;;EAEf,UAAU;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;IAEE;;IAEA;;;;;;UAOa;;EAEf,WAAW;;EAEX;IACE;IACA;IACA;IACA;IACA;;;EAGF;;EAEA;IAAgB,QAAQ;;;EAExB,SAAS;;EAET;IAAQ;IAAc;IAAiB;;;;;;;;;;;;;;;;;;;;;;;cA8B5B;UACH;UACA;UACA;UACA;UACA;UACA;UACA;UACA;EAEI,YAAA,QAAQ;;;;EAkBd,QAAQ,OAAO,eAAe,QAAQ;;;;;;EA4FtC,WAAW,OAAO,eAAe;IACrC,QAAQ;IACR;;;;;EAmBF;EAIM,aAAa,OAAO,oBAAoB;;iBAiFhC,uBACd,SAAS,QAAQ,6BAChB;;;;iBAgBa"}
@@ -1,2 +1,2 @@
1
- import { a as EnforceResponse, c as LogDetectionInput, i as EnforceInput, l as getCheckpointApiClient, n as CheckpointApiClient, o as EnforcementAction, r as CheckpointApiClientConfig, s as EnforcementDecision, t as ApiDetectionDetail, u as resetCheckpointApiClient } from "./api-client-JHOrRUA_.mjs";
1
+ import { a as EnforceResponse, c as LogDetectionInput, i as EnforceInput, l as getCheckpointApiClient, n as CheckpointApiClient, o as EnforcementAction, r as CheckpointApiClientConfig, s as EnforcementDecision, t as ApiDetectionDetail, u as resetCheckpointApiClient } from "./api-client-yjr43Itz.mjs";
2
2
  export { ApiDetectionDetail, CheckpointApiClient, CheckpointApiClientConfig, EnforceInput, EnforceResponse, type EnforcementAction, EnforcementDecision, LogDetectionInput, getCheckpointApiClient, resetCheckpointApiClient };
@@ -1,2 +1,2 @@
1
- import { a as EnforceResponse, c as LogDetectionInput, i as EnforceInput, l as getCheckpointApiClient, n as CheckpointApiClient, o as EnforcementAction, r as CheckpointApiClientConfig, s as EnforcementDecision, t as ApiDetectionDetail, u as resetCheckpointApiClient } from "./api-client-JHOrRUA_.js";
1
+ import { a as EnforceResponse, c as LogDetectionInput, i as EnforceInput, l as getCheckpointApiClient, n as CheckpointApiClient, o as EnforcementAction, r as CheckpointApiClientConfig, s as EnforcementDecision, t as ApiDetectionDetail, u as resetCheckpointApiClient } from "./api-client-yjr43Itz.js";
2
2
  export { ApiDetectionDetail, CheckpointApiClient, CheckpointApiClientConfig, EnforceInput, EnforceResponse, type EnforcementAction, EnforcementDecision, LogDetectionInput, getCheckpointApiClient, resetCheckpointApiClient };
@@ -1,7 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_utils = require('./utils-dyFxqlFI.js');
3
+ let _kya_os_checkpoint_wasm_runtime_reporter = require("@kya-os/checkpoint-wasm-runtime/reporter");
3
4
 
4
5
  //#region src/api-client.ts
6
+ /**
7
+ * Checkpoint API Client
8
+ *
9
+ * Lightweight client for calling the Checkpoint enforce API from middleware.
10
+ * Designed for Edge Runtime compatibility (no Node.js-specific APIs).
11
+ */
5
12
  const DEFAULT_BASE_URL = "https://kya.vouched.id";
6
13
  const EDGE_DETECT_URL = "https://detect.checkpoint-gateway.ai";
7
14
  const DEFAULT_TIMEOUT = 5e3;
@@ -31,6 +38,9 @@ var CheckpointApiClient = class {
31
38
  useEdge;
32
39
  timeout;
33
40
  debug;
41
+ telemetryBatchSize;
42
+ telemetryFlushIntervalMs;
43
+ reportSender;
34
44
  constructor(config) {
35
45
  if (!config.apiKey) throw new Error("Checkpoint API key is required");
36
46
  this.apiKey = config.apiKey;
@@ -38,6 +48,8 @@ var CheckpointApiClient = class {
38
48
  this.baseUrl = config.baseUrl || (this.useEdge ? EDGE_DETECT_URL : DEFAULT_BASE_URL);
39
49
  this.timeout = config.timeout || DEFAULT_TIMEOUT;
40
50
  this.debug = config.debug || false;
51
+ this.telemetryBatchSize = config.telemetryBatchSize;
52
+ this.telemetryFlushIntervalMs = config.telemetryFlushIntervalMs;
41
53
  }
42
54
  /**
43
55
  * Call the enforce API to check if a request should be allowed
@@ -121,63 +133,33 @@ var CheckpointApiClient = class {
121
133
  isUsingEdge() {
122
134
  return this.useEdge;
123
135
  }
124
- /**
125
- * Log a detection result to the Checkpoint database.
126
- * Use after Gateway Worker detection to persist results.
127
- * Fire-and-forget - returns immediately without waiting for DB write.
128
- *
129
- * @example
130
- * ```typescript
131
- * // After receiving Gateway response
132
- * if (client.isUsingEdge() && response.data?.detection) {
133
- * client.logDetection({
134
- * detection: response.data.detection,
135
- * context: { userAgent, ipAddress, path, url, method }
136
- * }).catch(err => console.error('Log failed:', err));
137
- * }
138
- * ```
139
- */
140
136
  async logDetection(input) {
141
- const logEndpoint = this.useEdge ? `${DEFAULT_BASE_URL}/api/v1/log-detection` : `${this.baseUrl}/api/v1/log-detection`;
142
- try {
143
- const controller = new AbortController();
144
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
145
- try {
146
- const response = await fetch(logEndpoint, {
147
- method: "POST",
148
- headers: {
149
- "Content-Type": "application/json",
150
- Authorization: `Bearer ${this.apiKey}`
151
- },
152
- body: JSON.stringify({
153
- detection: {
154
- isAgent: input.detection.isAgent,
155
- confidence: input.detection.confidence,
156
- agentName: input.detection.agentName,
157
- agentType: input.detection.agentType,
158
- detectionClass: input.detection.detectionClass,
159
- verificationMethod: input.detection.verificationMethod,
160
- reasons: input.detection.reasons,
161
- detectionBasis: typeof input.detection.detectionBasis === "string" ? input.detection.detectionBasis : void 0
162
- },
163
- context: input.context,
164
- source: input.source || "gateway",
165
- enforcement: input.enforcement,
166
- engine: input.engine,
167
- sdk: input.sdk
168
- }),
169
- signal: controller.signal
170
- });
171
- clearTimeout(timeoutId);
172
- if (!response.ok && this.debug) console.warn("[Checkpoint] Log detection returned non-2xx:", response.status);
173
- } catch (error) {
174
- clearTimeout(timeoutId);
175
- throw error;
176
- }
177
- } catch (error) {
178
- if (this.debug) console.error("[Checkpoint] Log detection failed:", error);
179
- throw error;
180
- }
137
+ this.reportSender ??= (0, _kya_os_checkpoint_wasm_runtime_reporter.makeReportSender)({
138
+ apiKey: this.apiKey,
139
+ baseUrl: this.useEdge ? DEFAULT_BASE_URL : this.baseUrl,
140
+ timeoutMs: this.timeout,
141
+ debug: this.debug,
142
+ telemetryBatchSize: this.telemetryBatchSize,
143
+ telemetryFlushIntervalMs: this.telemetryFlushIntervalMs,
144
+ runtime: input.sdk?.runtime
145
+ });
146
+ await this.reportSender.send({
147
+ detection: {
148
+ isAgent: input.detection.isAgent,
149
+ confidence: input.detection.confidence,
150
+ agentName: input.detection.agentName,
151
+ agentType: input.detection.agentType,
152
+ detectionClass: input.detection.detectionClass,
153
+ verificationMethod: input.detection.verificationMethod,
154
+ reasons: input.detection.reasons,
155
+ detectionBasis: typeof input.detection.detectionBasis === "string" ? input.detection.detectionBasis : void 0
156
+ },
157
+ context: input.context,
158
+ source: input.source || "gateway",
159
+ enforcement: input.enforcement,
160
+ engine: input.engine,
161
+ sdk: input.sdk
162
+ });
181
163
  }
182
164
  };
183
165
  /**
@@ -200,7 +182,9 @@ function resolveClientConfig(config) {
200
182
  baseUrl: config?.baseUrl || process.env.CHECKPOINT_API_URL,
201
183
  useEdge: config?.useEdge ?? process.env.CHECKPOINT_USE_EDGE !== "false",
202
184
  timeout: config?.timeout,
203
- debug: config?.debug || process.env.CHECKPOINT_DEBUG === "true"
185
+ debug: config?.debug || process.env.CHECKPOINT_DEBUG === "true",
186
+ telemetryBatchSize: config?.telemetryBatchSize,
187
+ telemetryFlushIntervalMs: config?.telemetryFlushIntervalMs
204
188
  };
205
189
  }
206
190
  function clientCacheKey(config) {
@@ -209,7 +193,9 @@ function clientCacheKey(config) {
209
193
  config.baseUrl ?? "",
210
194
  config.useEdge,
211
195
  config.timeout ?? DEFAULT_TIMEOUT,
212
- config.debug
196
+ config.debug,
197
+ config.telemetryBatchSize ?? null,
198
+ config.telemetryFlushIntervalMs ?? null
213
199
  ]);
214
200
  }
215
201
  function getCheckpointApiClient(config) {
@@ -1,6 +1,13 @@
1
1
  import { n as relayHeaders } from "./utils-Cnwg0VrY.mjs";
2
+ import { makeReportSender } from "@kya-os/checkpoint-wasm-runtime/reporter";
2
3
 
3
4
  //#region src/api-client.ts
5
+ /**
6
+ * Checkpoint API Client
7
+ *
8
+ * Lightweight client for calling the Checkpoint enforce API from middleware.
9
+ * Designed for Edge Runtime compatibility (no Node.js-specific APIs).
10
+ */
4
11
  const DEFAULT_BASE_URL = "https://kya.vouched.id";
5
12
  const EDGE_DETECT_URL = "https://detect.checkpoint-gateway.ai";
6
13
  const DEFAULT_TIMEOUT = 5e3;
@@ -30,6 +37,9 @@ var CheckpointApiClient = class {
30
37
  useEdge;
31
38
  timeout;
32
39
  debug;
40
+ telemetryBatchSize;
41
+ telemetryFlushIntervalMs;
42
+ reportSender;
33
43
  constructor(config) {
34
44
  if (!config.apiKey) throw new Error("Checkpoint API key is required");
35
45
  this.apiKey = config.apiKey;
@@ -37,6 +47,8 @@ var CheckpointApiClient = class {
37
47
  this.baseUrl = config.baseUrl || (this.useEdge ? EDGE_DETECT_URL : DEFAULT_BASE_URL);
38
48
  this.timeout = config.timeout || DEFAULT_TIMEOUT;
39
49
  this.debug = config.debug || false;
50
+ this.telemetryBatchSize = config.telemetryBatchSize;
51
+ this.telemetryFlushIntervalMs = config.telemetryFlushIntervalMs;
40
52
  }
41
53
  /**
42
54
  * Call the enforce API to check if a request should be allowed
@@ -120,63 +132,33 @@ var CheckpointApiClient = class {
120
132
  isUsingEdge() {
121
133
  return this.useEdge;
122
134
  }
123
- /**
124
- * Log a detection result to the Checkpoint database.
125
- * Use after Gateway Worker detection to persist results.
126
- * Fire-and-forget - returns immediately without waiting for DB write.
127
- *
128
- * @example
129
- * ```typescript
130
- * // After receiving Gateway response
131
- * if (client.isUsingEdge() && response.data?.detection) {
132
- * client.logDetection({
133
- * detection: response.data.detection,
134
- * context: { userAgent, ipAddress, path, url, method }
135
- * }).catch(err => console.error('Log failed:', err));
136
- * }
137
- * ```
138
- */
139
135
  async logDetection(input) {
140
- const logEndpoint = this.useEdge ? `${DEFAULT_BASE_URL}/api/v1/log-detection` : `${this.baseUrl}/api/v1/log-detection`;
141
- try {
142
- const controller = new AbortController();
143
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
144
- try {
145
- const response = await fetch(logEndpoint, {
146
- method: "POST",
147
- headers: {
148
- "Content-Type": "application/json",
149
- Authorization: `Bearer ${this.apiKey}`
150
- },
151
- body: JSON.stringify({
152
- detection: {
153
- isAgent: input.detection.isAgent,
154
- confidence: input.detection.confidence,
155
- agentName: input.detection.agentName,
156
- agentType: input.detection.agentType,
157
- detectionClass: input.detection.detectionClass,
158
- verificationMethod: input.detection.verificationMethod,
159
- reasons: input.detection.reasons,
160
- detectionBasis: typeof input.detection.detectionBasis === "string" ? input.detection.detectionBasis : void 0
161
- },
162
- context: input.context,
163
- source: input.source || "gateway",
164
- enforcement: input.enforcement,
165
- engine: input.engine,
166
- sdk: input.sdk
167
- }),
168
- signal: controller.signal
169
- });
170
- clearTimeout(timeoutId);
171
- if (!response.ok && this.debug) console.warn("[Checkpoint] Log detection returned non-2xx:", response.status);
172
- } catch (error) {
173
- clearTimeout(timeoutId);
174
- throw error;
175
- }
176
- } catch (error) {
177
- if (this.debug) console.error("[Checkpoint] Log detection failed:", error);
178
- throw error;
179
- }
136
+ this.reportSender ??= makeReportSender({
137
+ apiKey: this.apiKey,
138
+ baseUrl: this.useEdge ? DEFAULT_BASE_URL : this.baseUrl,
139
+ timeoutMs: this.timeout,
140
+ debug: this.debug,
141
+ telemetryBatchSize: this.telemetryBatchSize,
142
+ telemetryFlushIntervalMs: this.telemetryFlushIntervalMs,
143
+ runtime: input.sdk?.runtime
144
+ });
145
+ await this.reportSender.send({
146
+ detection: {
147
+ isAgent: input.detection.isAgent,
148
+ confidence: input.detection.confidence,
149
+ agentName: input.detection.agentName,
150
+ agentType: input.detection.agentType,
151
+ detectionClass: input.detection.detectionClass,
152
+ verificationMethod: input.detection.verificationMethod,
153
+ reasons: input.detection.reasons,
154
+ detectionBasis: typeof input.detection.detectionBasis === "string" ? input.detection.detectionBasis : void 0
155
+ },
156
+ context: input.context,
157
+ source: input.source || "gateway",
158
+ enforcement: input.enforcement,
159
+ engine: input.engine,
160
+ sdk: input.sdk
161
+ });
180
162
  }
181
163
  };
182
164
  /**
@@ -199,7 +181,9 @@ function resolveClientConfig(config) {
199
181
  baseUrl: config?.baseUrl || process.env.CHECKPOINT_API_URL,
200
182
  useEdge: config?.useEdge ?? process.env.CHECKPOINT_USE_EDGE !== "false",
201
183
  timeout: config?.timeout,
202
- debug: config?.debug || process.env.CHECKPOINT_DEBUG === "true"
184
+ debug: config?.debug || process.env.CHECKPOINT_DEBUG === "true",
185
+ telemetryBatchSize: config?.telemetryBatchSize,
186
+ telemetryFlushIntervalMs: config?.telemetryFlushIntervalMs
203
187
  };
204
188
  }
205
189
  function clientCacheKey(config) {
@@ -208,7 +192,9 @@ function clientCacheKey(config) {
208
192
  config.baseUrl ?? "",
209
193
  config.useEdge,
210
194
  config.timeout ?? DEFAULT_TIMEOUT,
211
- config.debug
195
+ config.debug,
196
+ config.telemetryBatchSize ?? null,
197
+ config.telemetryFlushIntervalMs ?? null
212
198
  ]);
213
199
  }
214
200
  function getCheckpointApiClient(config) {