@kya-os/checkpoint-shared 1.7.0 → 1.8.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.
- package/CHANGELOG.md +122 -9
- package/README.md +24 -7
- package/dist/beacon-nonce/index.d.mts +1 -0
- package/dist/beacon-nonce/index.d.mts.map +1 -1
- package/dist/beacon-nonce/index.d.ts +1 -0
- package/dist/beacon-nonce/index.d.ts.map +1 -1
- package/dist/beacon-nonce/index.js +9 -3
- package/dist/beacon-nonce/index.mjs +9 -4
- package/dist/beacon-nonce/index.mjs.map +1 -1
- package/dist/beacon-types/index.d.mts +23 -1
- package/dist/beacon-types/index.d.mts.map +1 -1
- package/dist/beacon-types/index.d.ts +23 -1
- package/dist/beacon-types/index.d.ts.map +1 -1
- package/dist/beacon-types/index.js +49 -4
- package/dist/beacon-types/index.mjs +47 -4
- package/dist/beacon-types/index.mjs.map +1 -1
- package/dist/{browser-posture-BLhw-MON.d.mts → browser-posture-5fPrsxx7.d.mts} +6 -6
- package/dist/{browser-posture-BLhw-MON.d.mts.map → browser-posture-5fPrsxx7.d.mts.map} +1 -1
- package/dist/{browser-posture-B8YiPa5c.d.ts → browser-posture-CCR1kh5e.d.ts} +6 -6
- package/dist/{browser-posture-B8YiPa5c.d.ts.map → browser-posture-CCR1kh5e.d.ts.map} +1 -1
- package/dist/browser-posture-proof.d.mts +16 -2
- package/dist/browser-posture-proof.d.mts.map +1 -1
- package/dist/browser-posture-proof.d.ts +16 -2
- package/dist/browser-posture-proof.d.ts.map +1 -1
- package/dist/browser-posture-proof.js +73 -17
- package/dist/browser-posture-proof.mjs +71 -17
- package/dist/browser-posture-proof.mjs.map +1 -1
- package/dist/browser-posture.d.mts +1 -1
- package/dist/browser-posture.d.ts +1 -1
- package/dist/browser-posture.js +6 -5
- package/dist/browser-posture.mjs +4 -3
- package/dist/browser-posture.mjs.map +1 -1
- package/dist/browser.d.mts +25 -4
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +25 -4
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/browser.mjs.map +1 -1
- package/dist/canonical-signer/index.js +30 -28
- package/dist/canonical-signer/index.mjs +31 -1
- package/dist/canonical-signer/index.mjs.map +1 -1
- package/dist/clearance.d.mts +1 -1
- package/dist/clearance.d.ts +1 -1
- package/dist/clearance.js +2 -2
- package/dist/clearance.mjs +2 -2
- package/dist/client-ip-B7w-uHfS.d.mts +55 -0
- package/dist/client-ip-B7w-uHfS.d.mts.map +1 -0
- package/dist/client-ip-B7w-uHfS.d.ts +55 -0
- package/dist/client-ip-B7w-uHfS.d.ts.map +1 -0
- package/dist/{client-ip-CW6pRyLf.js → client-ip-B8wFzJ5f.js} +117 -7
- package/dist/{client-ip-B2Xeo-GK.mjs → client-ip-DIJyr6px.mjs} +113 -9
- package/dist/client-ip-DIJyr6px.mjs.map +1 -0
- package/dist/client-ip.d.mts +2 -2
- package/dist/client-ip.d.ts +2 -2
- package/dist/client-ip.js +3 -2
- package/dist/client-ip.mjs +2 -2
- package/dist/detection-reason-mapping-B9RSkOs8.js +277 -0
- package/dist/detection-reason-mapping-BGymWIPl.mjs +249 -0
- package/dist/detection-reason-mapping-BGymWIPl.mjs.map +1 -0
- package/dist/detection-reason-mapping-CQexNvR7.d.mts +52 -0
- package/dist/detection-reason-mapping-CQexNvR7.d.mts.map +1 -0
- package/dist/detection-reason-mapping-CQexNvR7.d.ts +52 -0
- package/dist/detection-reason-mapping-CQexNvR7.d.ts.map +1 -0
- package/dist/engine-enforcing-AYEcgNsb.js +39 -0
- package/dist/engine-enforcing-B5eNfCpG.mjs +29 -0
- package/dist/engine-enforcing-B5eNfCpG.mjs.map +1 -0
- package/dist/engine-enforcing-DiOclGqf.d.mts +11 -0
- package/dist/engine-enforcing-DiOclGqf.d.mts.map +1 -0
- package/dist/engine-enforcing-DiOclGqf.d.ts +11 -0
- package/dist/engine-enforcing-DiOclGqf.d.ts.map +1 -0
- package/dist/engine-info.d.mts +2 -0
- package/dist/engine-info.d.ts +2 -0
- package/dist/engine-info.js +4 -0
- package/dist/engine-info.mjs +3 -0
- package/dist/errors/index.d.mts +5 -0
- package/dist/errors/index.d.mts.map +1 -1
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +23 -4
- package/dist/errors/index.mjs +23 -4
- package/dist/errors/index.mjs.map +1 -1
- package/dist/{external-B7WI9FyQ.d.ts → external-m3Kmafwj.d.mts} +2 -2
- package/dist/{external-B7WI9FyQ.d.mts.map → external-m3Kmafwj.d.mts.map} +1 -1
- package/dist/{external-B7WI9FyQ.d.mts → external-m3Kmafwj.d.ts} +2 -2
- package/dist/{external-B7WI9FyQ.d.ts.map → external-m3Kmafwj.d.ts.map} +1 -1
- package/dist/fetcher-CivUCbhL.d.ts +44 -0
- package/dist/fetcher-CivUCbhL.d.ts.map +1 -0
- package/dist/fetcher-cXQsbm6s.d.mts +44 -0
- package/dist/fetcher-cXQsbm6s.d.mts.map +1 -0
- package/dist/gateway-client-ip.d.mts +1 -1
- package/dist/gateway-client-ip.d.ts +1 -1
- package/dist/gateway-client-ip.js +2 -2
- package/dist/gateway-client-ip.mjs +2 -2
- package/dist/host-adapter/index.d.mts +2 -2
- package/dist/host-adapter/index.d.ts +2 -2
- package/dist/host-adapter/index.js +2 -1
- package/dist/host-adapter/index.mjs +2 -2
- package/dist/{host-adapter-CwW9YB0U.js → host-adapter-0F8EpbD6.js} +59 -0
- package/dist/{host-adapter-C-4IxmqM.mjs → host-adapter-DHyISsIf.mjs} +55 -2
- package/dist/{host-adapter-C-4IxmqM.mjs.map → host-adapter-DHyISsIf.mjs.map} +1 -1
- package/dist/index-B3cHxr3O.d.mts +156 -0
- package/dist/index-B3cHxr3O.d.mts.map +1 -0
- package/dist/index-CXbOY7gB.d.ts +156 -0
- package/dist/index-CXbOY7gB.d.ts.map +1 -0
- package/dist/index.d.mts +8331 -12630
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +8331 -12630
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2515 -6663
- package/dist/index.mjs +2438 -6371
- package/dist/index.mjs.map +1 -1
- package/dist/kya-http.d.mts +2 -2
- package/dist/kya-http.d.ts +2 -2
- package/dist/kya-http.js +9 -1
- package/dist/kya-http.mjs +3 -2
- package/dist/mcpi/dashboard-config/index.d.mts.map +1 -1
- package/dist/mcpi/dashboard-config/index.d.ts.map +1 -1
- package/dist/mcpi/status-list/index.d.mts +72 -0
- package/dist/mcpi/status-list/index.d.mts.map +1 -0
- package/dist/mcpi/status-list/index.d.ts +72 -0
- package/dist/mcpi/status-list/index.d.ts.map +1 -0
- package/dist/mcpi/status-list/index.js +703 -0
- package/dist/mcpi/status-list/index.mjs +684 -0
- package/dist/mcpi/status-list/index.mjs.map +1 -0
- package/dist/patterns-B2r7M9wR.js +243 -0
- package/dist/patterns-B7dQoeE3.mjs +173 -0
- package/dist/patterns-B7dQoeE3.mjs.map +1 -0
- package/dist/patterns-Bp40cwh2.d.mts +110 -0
- package/dist/patterns-Bp40cwh2.d.mts.map +1 -0
- package/dist/patterns-Bp40cwh2.d.ts +110 -0
- package/dist/patterns-Bp40cwh2.d.ts.map +1 -0
- package/dist/patterns.d.mts +2 -0
- package/dist/patterns.d.ts +2 -0
- package/dist/patterns.js +15 -0
- package/dist/patterns.mjs +3 -0
- package/dist/policy/enforcement.d.mts +3 -2
- package/dist/policy/enforcement.d.ts +3 -2
- package/dist/policy/enforcement.js +8 -2
- package/dist/policy/enforcement.mjs +3 -2
- package/dist/policy/fetcher.d.mts +2 -0
- package/dist/policy/fetcher.d.ts +2 -0
- package/dist/policy/fetcher.js +240 -0
- package/dist/policy/fetcher.mjs +238 -0
- package/dist/policy/fetcher.mjs.map +1 -0
- package/dist/policy/schemas.d.mts +3 -0
- package/dist/policy/schemas.d.ts +3 -0
- package/dist/policy/schemas.js +27 -0
- package/dist/policy/schemas.mjs +4 -0
- package/dist/{posture-origins-Ba83O0cD.mjs → posture-origins-Ci6k4Zh1.js} +24 -173
- package/dist/{posture-origins-CdVOdiMT.js → posture-origins-DGyS4Vuk.mjs} +2 -267
- package/dist/posture-origins-DGyS4Vuk.mjs.map +1 -0
- package/dist/{project-verification-key-BccT12tQ.js → project-verification-key-B-L3D2nC.js} +1 -1
- package/dist/{project-verification-key-66N4edKn.mjs → project-verification-key-CWXdu3-n.mjs} +2 -2
- package/dist/{project-verification-key-66N4edKn.mjs.map → project-verification-key-CWXdu3-n.mjs.map} +1 -1
- package/dist/provider-registry.d.mts +2 -0
- package/dist/provider-registry.d.ts +2 -0
- package/dist/provider-registry.js +51 -0
- package/dist/provider-registry.mjs +3 -0
- package/dist/reason-codes.d.mts +2 -0
- package/dist/reason-codes.d.ts +2 -0
- package/dist/reason-codes.js +8 -0
- package/dist/reason-codes.mjs +3 -0
- package/dist/{registered-sid-hUl-bvM5.mjs → registered-sid-26hNxp6t.mjs} +11 -2
- package/dist/registered-sid-26hNxp6t.mjs.map +1 -0
- package/dist/registered-sid-D6KCaT1E.d.mts +33 -0
- package/dist/registered-sid-D6KCaT1E.d.mts.map +1 -0
- package/dist/registered-sid-D6KCaT1E.d.ts +33 -0
- package/dist/registered-sid-D6KCaT1E.d.ts.map +1 -0
- package/dist/{registered-sid-eLCNZvIF.js → registered-sid-DVGTSH0L.js} +15 -0
- package/dist/ruleset-hash-Cmv8MSO5.js +34 -0
- package/dist/ruleset-hash-IRN5eI9H.d.mts +5 -0
- package/dist/ruleset-hash-IRN5eI9H.d.mts.map +1 -0
- package/dist/ruleset-hash-IRN5eI9H.d.ts +5 -0
- package/dist/ruleset-hash-IRN5eI9H.d.ts.map +1 -0
- package/dist/ruleset-hash-QQIaLuPi.mjs +30 -0
- package/dist/ruleset-hash-QQIaLuPi.mjs.map +1 -0
- package/dist/{index-HaqfPtaL.d.ts → schemas-02CI7jgm.d.mts} +11 -183
- package/dist/schemas-02CI7jgm.d.mts.map +1 -0
- package/dist/{schemas-YhagYDx_.js → schemas-BlScS1it.js} +0 -20
- package/dist/{index-B7rTovHa.d.mts → schemas-C_3C72SR.d.ts} +11 -183
- package/dist/schemas-C_3C72SR.d.ts.map +1 -0
- package/dist/schemas-Cm4C4Z5G.js +703 -0
- package/dist/schemas-DPIT8usF.mjs +525 -0
- package/dist/schemas-DPIT8usF.mjs.map +1 -0
- package/dist/{schemas-7qodsG-Z.mjs → schemas-IHAhH3gV.mjs} +2 -16
- package/dist/schemas-IHAhH3gV.mjs.map +1 -0
- package/dist/{step-up-COlmWJN8.mjs → step-up-BK0oBi11.mjs} +91 -41
- package/dist/step-up-BK0oBi11.mjs.map +1 -0
- package/dist/{step-up-C2d8C20x.js → step-up-Bp8RAQwv.js} +117 -55
- package/dist/{step-up-BjP--hG-.d.mts → step-up-Bz12gYKT.d.mts} +28 -12
- package/dist/step-up-Bz12gYKT.d.mts.map +1 -0
- package/dist/{step-up-BjP--hG-.d.ts → step-up-Bz12gYKT.d.ts} +28 -12
- package/dist/step-up-Bz12gYKT.d.ts.map +1 -0
- package/dist/test-fixtures/index.d.mts +4 -4
- package/dist/test-fixtures/index.d.mts.map +1 -1
- package/dist/test-fixtures/index.d.ts +4 -4
- package/dist/test-fixtures/index.d.ts.map +1 -1
- package/dist/test-fixtures/index.js +4 -4
- package/dist/test-fixtures/index.mjs +4 -4
- package/dist/test-fixtures/index.mjs.map +1 -1
- package/dist/verification-BAw9N8Pt.js +181 -0
- package/dist/verification-Cvvv86TT.mjs +123 -0
- package/dist/verification-Cvvv86TT.mjs.map +1 -0
- package/fixtures/client-ip-resolution.n01.json +101 -0
- package/fixtures/reviewer-grant-revocation.v1.json +53 -81
- package/package.json +37 -2
- package/dist/client-ip-B2Xeo-GK.mjs.map +0 -1
- package/dist/client-ip-DFamiNoz.d.mts +0 -34
- package/dist/client-ip-DFamiNoz.d.mts.map +0 -1
- package/dist/client-ip-DFamiNoz.d.ts +0 -34
- package/dist/client-ip-DFamiNoz.d.ts.map +0 -1
- package/dist/index-B7rTovHa.d.mts.map +0 -1
- package/dist/index-HaqfPtaL.d.ts.map +0 -1
- package/dist/posture-origins-Ba83O0cD.mjs.map +0 -1
- package/dist/registered-sid-D3g-gZQF.d.mts +0 -11
- package/dist/registered-sid-D3g-gZQF.d.mts.map +0 -1
- package/dist/registered-sid-D3g-gZQF.d.ts +0 -11
- package/dist/registered-sid-D3g-gZQF.d.ts.map +0 -1
- package/dist/registered-sid-hUl-bvM5.mjs.map +0 -1
- package/dist/schemas-7qodsG-Z.mjs.map +0 -1
- package/dist/step-up-BjP--hG-.d.mts.map +0 -1
- package/dist/step-up-BjP--hG-.d.ts.map +0 -1
- package/dist/step-up-COlmWJN8.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,119 @@
|
|
|
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-shared
|
|
2
4
|
|
|
3
|
-
##
|
|
5
|
+
## 1.8.0 - 2026-10-21
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
`@kya-os/checkpoint-nextjs` types its `events` option with it, so it no longer depends on `@kya-os/checkpoint`.
|
|
7
|
-
- **Removed:** `DEFAULT_ENV_VARS.AGENTSHIELD_WASM_PATH`, the path to the retired `agentshield_wasm` binary.
|
|
8
|
-
Nothing reads it.
|
|
9
|
-
Shipped under a minor because nothing consumes it yet.
|
|
7
|
+
### Breaking changes
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
- Removed: The legacy JSON policy evaluator, which nothing used: `evaluatePolicy` and its evaluation context and result (`PolicyEvaluationContextSchema`, `PolicyEvaluationContext`, `parseEvaluationContext`, `PolicyEvaluationResultSchema`, `PolicyEvaluationResult`, `PolicyMatchTypeSchema`, `PolicyMatchType`, `POLICY_MATCH_TYPES`).
|
|
10
|
+
Policy decisions come from the engine's Cedar evaluator in `@kya-os/checkpoint-wasm-runtime`; `matchPath` is unchanged. (#6410)
|
|
11
|
+
- Removed: `parsePolicyConfig`; use `safeParsePolicyConfig` or `PolicyConfigSchema`. (#6410)
|
|
12
|
+
- Removed: `StrictEnforcementActionSchema` and `isPassThroughAction`, which nothing used. (#6410)
|
|
13
|
+
- Removed: `pathHasUnnarrowedDenyRule`, `pathHasExplicitDenyRuleFor`, `isUnnarrowedDenyBlock` and `isForbidBlock`, which nothing used.
|
|
14
|
+
Use `analyzePolicySource(cedar)`, whose `humanHazard(path)` and `explicitDenyFor(path, probe)` answer the same questions, or `pathHasUnnarrowedDenyRuleFor(cedar, path, probe)`. (#6413)
|
|
15
|
+
- Removed: Unused legacy types and schemas: everything in the former `types/worker`, `types/transport`, `types/wasm` and `types/session` modules (the worker and transport types remain available from `@kya-os/checkpoint-shared/beacon-types` and `./browser`, which declare their own), the pixel event, install, analytics and session schemas, the fingerprint profile, rule and test-result schemas, three legacy fingerprint log types, the `WasmAgentTypeSchema` alias (use `AgentTypeSchema`), and `callbackSchema`. (#6421)
|
|
16
|
+
- Removed: Unused legacy types: the classification, database and MCP JSON-RPC type modules; the route context and handler types, `API_ERROR_CODES`, `HTTP_STATUS` and the request parameter types from the API types; the `Shared*Response` aliases with the response interfaces and `create*Response` helpers behind them (the root's `SuccessResponse`, `ErrorResponse`, `PaginatedResponse` and `ApiResponse` from the API contracts are unchanged); and unused auth, analytics, admin overview, agent classification, organization, Shopify, rules, entity and detection metadata exports. (#6429)
|
|
17
|
+
- Removed: Unused legacy API types: the v1 public API types (`PublicProject`, `PublicDetection`, `PublicAnalytics*`, `PublicApiResponse`, `PaginationResponse`, `PublicApiQueryParams`, `PublicApiHeaders`, their schemas and the `PublicPagination*` aliases), the signature verification request, response, key and cache types, the fingerprint detect request, enhanced response and validators with the `FingerprintClientDetection*` aliases, `EventStorageRecord`, and four bulk operation types.
|
|
18
|
+
`FingerprintRecord`, `FingerprintRecordSchema`, `BotPattern` and `BotPatternSchema` stay exported from the root, now as the `types/fingerprint` and `constants/bots` declarations. (#6444)
|
|
19
|
+
|
|
20
|
+
### Added
|
|
12
21
|
|
|
13
|
-
|
|
22
|
+
- The `API_ENDPOINT_RETIRED` error code (HTTP 410), for a route that no longer serves requests and names its replacement. (#6443)
|
|
23
|
+
- `PostureReportPathsSchema`, `readPostureReportPathsSetting` and the project setting `settings.postureReportPaths`, validated on project update. (#6434)
|
|
24
|
+
- `contextTag(secret, context)` on `@kya-os/checkpoint-shared/beacon-nonce`, the HMAC context tag the beacon ingest Worker stores with a posture answer. (#6516)
|
|
25
|
+
- `verifyBrowserPostureProofKey` verifies a posture proof against any key and one or several acceptable URLs and returns the key thumbprint or the reason it failed, and `browserPostureKeyThumbprint` computes a public key's thumbprint. `verifyBrowserPostureProof` behaves as before. (#6518)
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- `PolicyFetcher` reads the policy API's allow list of agent names as client-name entries. It rejected any project policy with a non-empty allow list, so the Express and Next.js middleware answered every request on such a project with a retryable 503. (#6464)
|
|
30
|
+
|
|
31
|
+
### Other merged changes
|
|
32
|
+
|
|
33
|
+
- chore(release): set checkpoint-shared package.json to 1.7.0 (#6278)
|
|
34
|
+
- fix(shared): accept the bot types the engine emits (#6291)
|
|
35
|
+
- perf(shared): move provider-registry values off the root entry (#6286)
|
|
36
|
+
- docs(shared): say what the typescript status-list verifier is still for (#6307)
|
|
37
|
+
- fix(wasm-runtime): keep the engine's ruleset hash in sdk detection reports (#6324)
|
|
38
|
+
- perf(sdk): load lean checkpoint-shared entries in express and next.js (#6306)
|
|
39
|
+
- fix(sdk): raise the node floor to the versions that can require an es module (#6293)
|
|
40
|
+
- feat(web): managed workers delegate to the org authorization service [kx-d2b] (#6318)
|
|
41
|
+
- fix(admin): classify native ios installations correctly (#6375)
|
|
42
|
+
- chore(shared): remove dead config, defaults, event and fetcher-factory exports (#6353)
|
|
43
|
+
- perf(gateway): keep the worker off the checkpoint-shared root entry (#6335)
|
|
44
|
+
- fix(beacon-ingest): keep a live posture token when a later answer is unavailable (#6397)
|
|
45
|
+
- fix(beacon-ingest): ack every legitimate resend of a batch as a duplicate (#6365)
|
|
46
|
+
- feat(authz): hash user ids that are not did:web path segments (#6414)
|
|
47
|
+
- fix(admin): count the platform page and /api/admin/metrics the way the overview does (#6409)
|
|
48
|
+
- feat(db): the pr 3 post-deploy contract (c1, c2, c3 and the reviewer fold) (#5919)
|
|
49
|
+
|
|
50
|
+
### org signing keys: `#key-N` kids; `deriveMcpiOrgKid` is removed (#5887)
|
|
51
|
+
|
|
52
|
+
- **Added:** `mcpiOrgKeyFragment(sequence)`, the verification-method fragment of an org's key number `sequence`
|
|
53
|
+
(`key-<sequence>`; throws `RangeError` unless `sequence` is a positive integer).
|
|
54
|
+
- **Added:** `isMcpiOrgKeyId(orgDid, kid)`: true when `kid` is `<orgDid>#key-<n>` with n ≥ 1. Verifiers pin a
|
|
55
|
+
credential's `kid` with it before resolving the issuer's DID document, then take the key from the method with
|
|
56
|
+
that id.
|
|
57
|
+
- **Removed:** `deriveMcpiOrgKid` removed; resolve the current kid from the org's did.json.
|
|
58
|
+
It hardcoded `<org did>#key-1`, but an org now rotates its signing key, and key N signs under
|
|
59
|
+
`<org did>#key-N`. An issuer takes the `kid` from its signer; a verifier takes it from the credential and
|
|
60
|
+
checks it with `isMcpiOrgKeyId`.
|
|
61
|
+
Shipped under a minor: the package has no external users.
|
|
62
|
+
|
|
63
|
+
### the CJS `./canonical-signer` and `./mcpi/status-list` entries load in plain Node (#5887)
|
|
64
|
+
|
|
65
|
+
- **Fixed:** `require('@kya-os/checkpoint-shared/canonical-signer')` threw `ERR_PACKAGE_PATH_NOT_EXPORTED` in plain
|
|
66
|
+
Node (1.6.0). Its CJS build left the ESM-only `canonicalize` 3 external, as a `require('canonicalize')` Node refuses;
|
|
67
|
+
the ESM import was unaffected. The `canonical-signer` and `mcpi/status-list` CJS entries now bundle `canonicalize`,
|
|
68
|
+
as the signals entry already does, so `require()` works in plain Node with no `--conditions=import`.
|
|
69
|
+
A test loads every CJS entry in the `exports` map with plain Node's `require`.
|
|
70
|
+
A patch: nothing in the API changes.
|
|
71
|
+
|
|
72
|
+
### authenticated observed client addresses (#6187)
|
|
73
|
+
|
|
74
|
+
`resolveObservedClientAddress` adds an explicit authenticated-ingress contract with typed observed/unavailable results. Express and Next adapters adopt this API. Proxy origins must verify their actual socket peer and exact forwarding chain; arbitrary Next proxy profiles return no address because NextRequest has no transport peer. Migrate those configurations using the [client-IP resolution runbook](https://github.com/Know-That-Ai/checkpoint/blob/main/docs/runbooks/client-ip-resolution.md). The `vercel` profile resolves only when the caller passes `vercelRuntime: true`; the resolver reads no environment, so the `./client-ip` lean entry keeps no Node globals.
|
|
75
|
+
|
|
76
|
+
`resolveClientIp` retains its existing three-field, platform-assumed compatibility contract. Existing gateway, web, WASM-runtime, and bouncer callers keep their previous behavior until each ingress migrates explicitly. Those legacy callers do not acquire N01 authentication guarantees from this release. Java and .NET continue using the legacy canonical fixtures.
|
|
77
|
+
|
|
78
|
+
## 1.7.0 - 2026-10-20
|
|
79
|
+
|
|
80
|
+
### Other merged changes
|
|
81
|
+
|
|
82
|
+
- chore(release): set shared 1.6.0, wasm-runtime 1.11.0 and checkpoint 1.4.0 (#6244)
|
|
83
|
+
- fix(shared): tighten the uuid pattern, scope device ids by the server rule (#6246)
|
|
84
|
+
- perf(shared): add lean zod-free entry points for request-path code (#6257)
|
|
85
|
+
- fix(shared): verify posture proofs and envelopes without a global buffer (#6266)
|
|
86
|
+
|
|
87
|
+
## 1.6.0 - 2026-10-19
|
|
88
|
+
|
|
89
|
+
### Other merged changes
|
|
90
|
+
|
|
91
|
+
- fix(pixel): normalize allowed domains on write and when matching (#5339)
|
|
92
|
+
- refactor(authz): lib/authz skeleton, ports and CI gates (PR 1·0) (#5853)
|
|
93
|
+
- chore(release): set checkpoint-shared package.json to 1.5.2 (#5873)
|
|
94
|
+
- fix(detection): classify zero-evidence requests as unknown instead of human (#5060)
|
|
95
|
+
- Revert "fix(detection): classify zero-evidence requests as unknown instead of human" (#5881)
|
|
96
|
+
- fix(fingerprint): harden the public routes and redact echoed credentials (#5908)
|
|
97
|
+
- fix(vault): make resolve assertions single use and verify every live agent key (#5888)
|
|
98
|
+
- feat(authz): org authorization service oauth surface (pr 1) (#5926)
|
|
99
|
+
- fix(dotnet): serve no protected resource metadata for a non-https issuer (#5983)
|
|
100
|
+
- fix(provisioning): verify installer account linking (#5711)
|
|
101
|
+
- fix(gateway): scope tool-call audit rows to the upstream's project (#4837)
|
|
102
|
+
- fix: fail closed on the delegation and posture trust boundary (#5652)
|
|
103
|
+
- feat(delegations): lifecycle panel, signed issuance receipt and merkle proof view (#5409)
|
|
104
|
+
- feat(admin): counted and excluded behind every admin number, with a drill-down (#6025)
|
|
105
|
+
- chore: remove artifacts and references from the repo (#6066)
|
|
106
|
+
- fix(review): revoke individual repository grants (#5726)
|
|
107
|
+
- fix(checkpoint-shared): check the approver allowlist before resolving its did (#6097)
|
|
108
|
+
- test(checkpoint-shared): gate test:unit on the 80% coverage thresholds (#6129)
|
|
109
|
+
- test(checkpoint-shared): run the suite on vitest 4, whose worker rpc has no 60 s timeout (#6128)
|
|
110
|
+
- perf(web): faster dashboard loads, activity paging and screen navigation, with a benchmark suite (#6193)
|
|
111
|
+
- fix(detection): separate proxy assertions from hosting (#6186)
|
|
112
|
+
- feat(beacon-ingest): publish replay posture through a durable posture queue (#6163)
|
|
113
|
+
- feat(authz): consent principal, sign-in methods and assurance (pr 2b) [kx-b] (#6164)
|
|
114
|
+
- fix(cli): approve pairing v2 on the claim page so the cli finishes on its own (#5720)
|
|
115
|
+
|
|
116
|
+
### zero-evidence requests and the `no_evidence` policy category (#5886)
|
|
14
117
|
|
|
15
118
|
The engine now sends a zero-evidence request as `IncompleteData` with `metadata.detection_basis = "no_evidence"`, and
|
|
16
119
|
composed policies see it as the category `no_evidence`. `withNoEvidenceExclusion(cedar)` is the serve-time rewrite that
|
|
@@ -84,7 +187,7 @@ visitors were counted as human before, including a visit that also sent a reques
|
|
|
84
187
|
counted in `totalRequests` and `humanSessions`; sessions whose incomplete data all comes from other reasons, such as
|
|
85
188
|
suspicious headers, are in no counter.
|
|
86
189
|
|
|
87
|
-
|
|
190
|
+
#### Security
|
|
88
191
|
|
|
89
192
|
`verifySignedApprovalQuorum` now checks a grant's `approverDid` against `quorum.approvers` before it resolves the
|
|
90
193
|
approver's key. Before, it resolved the request-supplied DID first and checked the allowlist after, so a did:web
|
|
@@ -93,6 +196,16 @@ before and the result is unchanged (`quorum_not_met:k/n`); it just never reaches
|
|
|
93
196
|
`verifyApprovalGrant` on its own still resolves whatever DID it is given, so a caller with an allowlist must check it
|
|
94
197
|
first.
|
|
95
198
|
|
|
199
|
+
### `CheckpointEvents` moves here; `AGENTSHIELD_WASM_PATH` is removed (#6084)
|
|
200
|
+
|
|
201
|
+
- **Added:** `CheckpointEvents`, the event-handler map the Checkpoint SDKs accept, moved from `@kya-os/checkpoint`.
|
|
202
|
+
`@kya-os/checkpoint-nextjs` types its `events` option with it, so it no longer depends on `@kya-os/checkpoint`.
|
|
203
|
+
- **Removed:** `DEFAULT_ENV_VARS.AGENTSHIELD_WASM_PATH`, the path to the retired `agentshield_wasm` binary.
|
|
204
|
+
Nothing reads it.
|
|
205
|
+
Shipped under a minor because nothing consumes it yet.
|
|
206
|
+
|
|
207
|
+
RELEASE ORDER: publish this first; the `@kya-os/checkpoint-nextjs` release that drops `@kya-os/checkpoint` needs `CheckpointEvents`.
|
|
208
|
+
|
|
96
209
|
## 1.5.2
|
|
97
210
|
|
|
98
211
|
### Changed
|
package/README.md
CHANGED
|
@@ -22,6 +22,30 @@ This package provides:
|
|
|
22
22
|
- **API Types**: Request/response schemas for API communication
|
|
23
23
|
- **Event Types**: Behavioral and real-time event definitions
|
|
24
24
|
|
|
25
|
+
## Resolve authenticated observed addresses
|
|
26
|
+
|
|
27
|
+
New ingress integrations use `resolveObservedClientAddress`. Supply the real transport peer and the deployment's actual peer verifier before accepting a proxy header:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { resolveObservedClientAddress } from '@kya-os/checkpoint-shared';
|
|
31
|
+
|
|
32
|
+
const observation = resolveObservedClientAddress({
|
|
33
|
+
headers: req.headers,
|
|
34
|
+
directAddress: req.socket.remoteAddress,
|
|
35
|
+
policy: {
|
|
36
|
+
platform: 'trusted-proxy',
|
|
37
|
+
trustedHops: 0,
|
|
38
|
+
isTrustedPeer: (peer) => peer === '192.0.2.10',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The `vercel` profile resolves only when the caller passes `vercelRuntime: true` after confirming it runs inside Vercel's managed `VERCEL=1` runtime. The resolver reads no environment variables itself, so it stays safe on edge runtimes.
|
|
44
|
+
|
|
45
|
+
Replace the documentation address with your configured proxy allowlist. `observedClientAddress` and its `ip` compatibility alias are null when authentication or parsing fails. Check `status` and `reason`; do not substitute an untrusted header.
|
|
46
|
+
|
|
47
|
+
`resolveClientIp` remains the legacy platform-assumed API with its original three-field result. Existing gateway, web, WASM, and bouncer consumers retain their behavior until migrated explicitly. That compatibility API does not authenticate the nearest peer and does not provide the new N01 guarantees. See the [client-IP resolution runbook](https://github.com/Know-That-Ai/checkpoint/blob/main/docs/runbooks/client-ip-resolution.md) for supported SDK boundaries and migration guidance.
|
|
48
|
+
|
|
25
49
|
## Usage
|
|
26
50
|
|
|
27
51
|
### Import Types
|
|
@@ -30,7 +54,6 @@ This package provides:
|
|
|
30
54
|
import {
|
|
31
55
|
DetectionInput,
|
|
32
56
|
DetectionResult,
|
|
33
|
-
AgentShieldConfig,
|
|
34
57
|
AgentType,
|
|
35
58
|
ConfidenceLevel,
|
|
36
59
|
} from '@kya-os/checkpoint-shared';
|
|
@@ -73,12 +96,6 @@ const openAIPattern = KNOWN_AGENT_PATTERNS.find((p) => p.type === 'openai');
|
|
|
73
96
|
- `AgentInfo` - Information about detected agents
|
|
74
97
|
- `ConfidenceLevel` - Confidence levels (low, medium, high, very_high)
|
|
75
98
|
|
|
76
|
-
### Configuration Types
|
|
77
|
-
|
|
78
|
-
- `AgentShieldConfig` - Main configuration object
|
|
79
|
-
- `ExpressMiddlewareOptions` - Express.js middleware configuration
|
|
80
|
-
- `NextMiddlewareOptions` - Next.js middleware configuration
|
|
81
|
-
|
|
82
99
|
### Event Types
|
|
83
100
|
|
|
84
101
|
- `BehavioralData` - Mouse, keyboard, scroll events
|
|
@@ -22,6 +22,7 @@ export declare function beaconNonceContext(client: {
|
|
|
22
22
|
ip?: string;
|
|
23
23
|
userAgent?: string;
|
|
24
24
|
}): string;
|
|
25
|
+
export declare function contextTag(secret: string, context: string): Promise<string>;
|
|
25
26
|
export declare function isSignedBeaconNonce(nonce: string | undefined): nonce is string;
|
|
26
27
|
export declare function issueSignedBeaconNonce(secret: string, binding: BeaconNonceBinding, issuedAtMs: number): Promise<string>;
|
|
27
28
|
export declare function verifySignedBeaconNonce(secret: string | undefined, binding: BeaconNonceBinding, nonce: string | undefined, nowMs: number): Promise<BeaconNonceVerification>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/beacon-nonce/index.ts"],"mappings":";qBA4Da,uBAAqB;qBAGrB;qBAEA;qBAEA;YAED;YAEA;EACN;;EACA;EAAmB;;EAEnB;EACA;;iBAGW;EACf;EACA;EAEA;;wBA2Cc,mBAAmB;EAAU;EAAa;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/beacon-nonce/index.ts"],"mappings":";qBA4Da,uBAAqB;qBAGrB;qBAEA;qBAEA;YAED;YAEA;EACN;;EACA;EAAmB;;EAEnB;EACA;;iBAGW;EACf;EACA;EAEA;;wBA2Cc,mBAAmB;EAAU;EAAa;;wBA4FpC,WAAW,gBAAgB,kBAAkB;wBAiBnD,oBAAoB,4BAA4B;wBAS1C,uBACpB,gBACA,SAAS,oBACT,qBACC;wBAkBmB,wBACpB,4BACA,SAAS,oBACT,2BACA,gBACC,QAAQ;wBA+DW,kBAAkB,gBAAgB,oBAAoB;qBAS/D,2BAAyB;wBAGtB,kBAAkB;EAAgB;EAAe;;wBAS3C,sBACpB,4BACA,mBACA,iBACC"}
|
|
@@ -22,6 +22,7 @@ export declare function beaconNonceContext(client: {
|
|
|
22
22
|
ip?: string;
|
|
23
23
|
userAgent?: string;
|
|
24
24
|
}): string;
|
|
25
|
+
export declare function contextTag(secret: string, context: string): Promise<string>;
|
|
25
26
|
export declare function isSignedBeaconNonce(nonce: string | undefined): nonce is string;
|
|
26
27
|
export declare function issueSignedBeaconNonce(secret: string, binding: BeaconNonceBinding, issuedAtMs: number): Promise<string>;
|
|
27
28
|
export declare function verifySignedBeaconNonce(secret: string | undefined, binding: BeaconNonceBinding, nonce: string | undefined, nowMs: number): Promise<BeaconNonceVerification>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/beacon-nonce/index.ts"],"mappings":";qBA4Da,uBAAqB;qBAGrB;qBAEA;qBAEA;YAED;YAEA;EACN;;EACA;EAAmB;;EAEnB;EACA;;iBAGW;EACf;EACA;EAEA;;wBA2Cc,mBAAmB;EAAU;EAAa;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/beacon-nonce/index.ts"],"mappings":";qBA4Da,uBAAqB;qBAGrB;qBAEA;qBAEA;YAED;YAEA;EACN;;EACA;EAAmB;;EAEnB;EACA;;iBAGW;EACf;EACA;EAEA;;wBA2Cc,mBAAmB;EAAU;EAAa;;wBA4FpC,WAAW,gBAAgB,kBAAkB;wBAiBnD,oBAAoB,4BAA4B;wBAS1C,uBACpB,gBACA,SAAS,oBACT,qBACC;wBAkBmB,wBACpB,4BACA,SAAS,oBACT,2BACA,gBACC,QAAQ;wBA+DW,kBAAkB,gBAAgB,oBAAoB;qBAS/D,2BAAyB;wBAGtB,kBAAkB;EAAgB;EAAe;;wBAS3C,sBACpB,4BACA,mBACA,iBACC"}
|
|
@@ -155,7 +155,7 @@ async function mac(secret, binding, issuedAt, random) {
|
|
|
155
155
|
const signature = await crypto.subtle.sign("HMAC", await hmacKey(secret), input);
|
|
156
156
|
return base64url(new Uint8Array(signature, 0, MAC_BYTES));
|
|
157
157
|
}
|
|
158
|
-
async function
|
|
158
|
+
async function nonceContextTag(secret, binding, issuedAt, random) {
|
|
159
159
|
const input = canonical([
|
|
160
160
|
CONTEXT_INPUT_PREFIX,
|
|
161
161
|
binding.projectId,
|
|
@@ -167,6 +167,11 @@ async function contextTag(secret, binding, issuedAt, random) {
|
|
|
167
167
|
const signature = await crypto.subtle.sign("HMAC", await hmacKey(secret), input);
|
|
168
168
|
return base64url(new Uint8Array(signature, 0, CONTEXT_TAG_BYTES));
|
|
169
169
|
}
|
|
170
|
+
const POSTURE_CONTEXT_TAG_PREFIX = "checkpoint-beacon-posture-context:v1\0";
|
|
171
|
+
async function contextTag(secret, context) {
|
|
172
|
+
const signature = await crypto.subtle.sign("HMAC", await hmacKey(secret), encoder.encode(`${POSTURE_CONTEXT_TAG_PREFIX}${context}`));
|
|
173
|
+
return base64url(new Uint8Array(signature));
|
|
174
|
+
}
|
|
170
175
|
function constantTimeEqual(left, right) {
|
|
171
176
|
if (left.length !== right.length) return false;
|
|
172
177
|
let diff = 0;
|
|
@@ -191,7 +196,7 @@ async function issueSignedBeaconNonce(secret, binding, issuedAtMs) {
|
|
|
191
196
|
issuedAt,
|
|
192
197
|
random,
|
|
193
198
|
await mac(secret, binding, issuedAt, random),
|
|
194
|
-
await
|
|
199
|
+
await nonceContextTag(secret, binding, issuedAt, random)
|
|
195
200
|
].join(".");
|
|
196
201
|
}
|
|
197
202
|
/**
|
|
@@ -236,7 +241,7 @@ async function verifySignedBeaconNonce(secret, binding, nonce, nowMs) {
|
|
|
236
241
|
verdict: "unverified",
|
|
237
242
|
reason: "expired"
|
|
238
243
|
};
|
|
239
|
-
if (!constantTimeEqual(providedContextTag, await
|
|
244
|
+
if (!constantTimeEqual(providedContextTag, await nonceContextTag(secret, binding, issuedAt, random))) return {
|
|
240
245
|
verdict: "unverified",
|
|
241
246
|
reason: "context"
|
|
242
247
|
};
|
|
@@ -297,6 +302,7 @@ exports.BEACON_NONCE_TTL_SECONDS = BEACON_NONCE_TTL_SECONDS;
|
|
|
297
302
|
exports.HANDOFF_TOKEN_PATTERN = HANDOFF_TOKEN_PATTERN;
|
|
298
303
|
exports.HANDOFF_USER_HASH_PATTERN = HANDOFF_USER_HASH_PATTERN;
|
|
299
304
|
exports.beaconNonceContext = beaconNonceContext;
|
|
305
|
+
exports.contextTag = contextTag;
|
|
300
306
|
exports.handoffTokenAuthentic = handoffTokenAuthentic;
|
|
301
307
|
exports.isSignedBeaconNonce = isSignedBeaconNonce;
|
|
302
308
|
exports.issueHandoffToken = issueHandoffToken;
|
|
@@ -154,7 +154,7 @@ async function mac(secret, binding, issuedAt, random) {
|
|
|
154
154
|
const signature = await crypto.subtle.sign("HMAC", await hmacKey(secret), input);
|
|
155
155
|
return base64url(new Uint8Array(signature, 0, MAC_BYTES));
|
|
156
156
|
}
|
|
157
|
-
async function
|
|
157
|
+
async function nonceContextTag(secret, binding, issuedAt, random) {
|
|
158
158
|
const input = canonical([
|
|
159
159
|
CONTEXT_INPUT_PREFIX,
|
|
160
160
|
binding.projectId,
|
|
@@ -166,6 +166,11 @@ async function contextTag(secret, binding, issuedAt, random) {
|
|
|
166
166
|
const signature = await crypto.subtle.sign("HMAC", await hmacKey(secret), input);
|
|
167
167
|
return base64url(new Uint8Array(signature, 0, CONTEXT_TAG_BYTES));
|
|
168
168
|
}
|
|
169
|
+
const POSTURE_CONTEXT_TAG_PREFIX = "checkpoint-beacon-posture-context:v1\0";
|
|
170
|
+
async function contextTag(secret, context) {
|
|
171
|
+
const signature = await crypto.subtle.sign("HMAC", await hmacKey(secret), encoder.encode(`${POSTURE_CONTEXT_TAG_PREFIX}${context}`));
|
|
172
|
+
return base64url(new Uint8Array(signature));
|
|
173
|
+
}
|
|
169
174
|
function constantTimeEqual(left, right) {
|
|
170
175
|
if (left.length !== right.length) return false;
|
|
171
176
|
let diff = 0;
|
|
@@ -190,7 +195,7 @@ async function issueSignedBeaconNonce(secret, binding, issuedAtMs) {
|
|
|
190
195
|
issuedAt,
|
|
191
196
|
random,
|
|
192
197
|
await mac(secret, binding, issuedAt, random),
|
|
193
|
-
await
|
|
198
|
+
await nonceContextTag(secret, binding, issuedAt, random)
|
|
194
199
|
].join(".");
|
|
195
200
|
}
|
|
196
201
|
/**
|
|
@@ -235,7 +240,7 @@ async function verifySignedBeaconNonce(secret, binding, nonce, nowMs) {
|
|
|
235
240
|
verdict: "unverified",
|
|
236
241
|
reason: "expired"
|
|
237
242
|
};
|
|
238
|
-
if (!constantTimeEqual(providedContextTag, await
|
|
243
|
+
if (!constantTimeEqual(providedContextTag, await nonceContextTag(secret, binding, issuedAt, random))) return {
|
|
239
244
|
verdict: "unverified",
|
|
240
245
|
reason: "context"
|
|
241
246
|
};
|
|
@@ -290,5 +295,5 @@ async function handoffTokenAuthentic(secrets, projectId, token) {
|
|
|
290
295
|
}
|
|
291
296
|
|
|
292
297
|
//#endregion
|
|
293
|
-
export { BEACON_NONCE_CLOCK_SKEW_SECONDS, BEACON_NONCE_MAX_LENGTH, BEACON_NONCE_TTL_SECONDS, HANDOFF_TOKEN_PATTERN, HANDOFF_USER_HASH_PATTERN, beaconNonceContext, handoffTokenAuthentic, isSignedBeaconNonce, issueHandoffToken, issueSignedBeaconNonce, splitHandoffToken, verifySignedBeaconNonce };
|
|
298
|
+
export { BEACON_NONCE_CLOCK_SKEW_SECONDS, BEACON_NONCE_MAX_LENGTH, BEACON_NONCE_TTL_SECONDS, HANDOFF_TOKEN_PATTERN, HANDOFF_USER_HASH_PATTERN, beaconNonceContext, contextTag, handoffTokenAuthentic, isSignedBeaconNonce, issueHandoffToken, issueSignedBeaconNonce, splitHandoffToken, verifySignedBeaconNonce };
|
|
294
299
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/beacon-nonce/index.ts"],"sourcesContent":["/**\n * Stateless, client-bound beacon nonce, issued and verified by both the\n * origin (`apps/web/lib/services/nonce.service.ts`) and the beacon-ingest\n * edge Worker.\n *\n * Every pixel/beacon response hands the browser a per-session nonce that its\n * next post must echo. A queue-only edge returns its receipt before the\n * origin has seen the batch, so the nonce cannot depend on origin state:\n * it is an HMAC-SHA256 under a secret shared by origin and edge. The origin\n * verifies it at synchronous ingest, or on replay using the edge's\n * acceptance time as the clock.\n *\n * Web Crypto only (`crypto.subtle`, `crypto.getRandomValues`): this runs\n * unchanged in Cloudflare Workers, Node ≥ 20 and the browser bundle.\n *\n * Wire format (56 chars, inside the schema's 64-char cap):\n *\n * n2.<issuedAt base36 seconds>.<random 8 bytes b64url>.<HMAC 16 bytes b64url>.<ctx tag 8 bytes b64url>\n *\n * The first HMAC binds the format version + project + session + issue time +\n * random. The trailing context tag additionally binds the requester's\n * network prefix and User-Agent (`beaconNonceContext`), so a nonce lifted\n * from one client does not verify from another. The version is inside the\n * MAC, so a nonce cannot be relabelled to dodge the context tag.\n *\n * Verdict semantics — three states, never two:\n * - `verified`: signature matches THIS project+session, the context matches,\n * and it is within TTL.\n * - `forged`: well-formed but the MAC does not match this session/secret.\n * The only outcome that counts as evidence against the client.\n * - `unverified`: nothing could be proven — not signed-format (absent, or\n * a value from before signing existed), expired, from the future, this\n * side has no secret, or the session signature is genuine but the\n * requester's network/User-Agent differs from the one it was issued to (a\n * roaming phone and a replay from elsewhere look the same, so neither is\n * treated as fabrication). Staleness is not forgery: an edge that stopped\n * issuing (secret unset) leaves clients echoing old values, and that must\n * degrade to \"unknown\", never to \"failed\".\n *\n * Any unexpired signature for the session verifies, so a nonce is not\n * single-use within its TTL. Multi-tab sessions need no window at all.\n */\n\nconst NONCE_VERSION = 'n2';\nconst MAC_INPUT_PREFIX = `checkpoint-beacon-nonce:${NONCE_VERSION}`;\nconst CONTEXT_INPUT_PREFIX = `checkpoint-beacon-nonce:ctx:${NONCE_VERSION}`;\nconst RANDOM_BYTES = 8;\nconst MAC_BYTES = 16;\nconst CONTEXT_TAG_BYTES = 8;\nconst MAX_CONTEXT_USER_AGENT_LENGTH = 512;\nconst IPV4_PATTERN = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/;\nconst IPV6_GROUP_PATTERN = /^[0-9a-f]{1,4}$/;\n// Each wire part has a closed alphabet and is rejected as malformed before any\n// MAC work when it strays outside it — a nonce is no place for `\\0` or `.`.\nconst ISSUED_AT_PATTERN = /^[0-9a-z]{1,16}$/;\nconst BASE64URL_PATTERN = /^[A-Za-z0-9_-]+$/;\nconst HANDOFF_TOKEN_INPUT_PREFIX = 'checkpoint-handoff-token:v1';\nconst HANDOFF_ID_BYTES = 16;\nconst HANDOFF_TAG_BYTES = 16;\n\nexport const HANDOFF_TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;\n\n/** How long an issued nonce stays verifiable. */\nexport const BEACON_NONCE_TTL_SECONDS = 10 * 60;\n/** Edge and origin clocks may disagree; a nonce this far \"in the future\" still verifies. */\nexport const BEACON_NONCE_CLOCK_SKEW_SECONDS = 60;\n/** The beacon wire schema's `nonce: z.string().max(64)`. */\nexport const BEACON_NONCE_MAX_LENGTH = 64;\n\nexport type BeaconNonceVerdict = 'verified' | 'forged' | 'unverified';\n\nexport type BeaconNonceVerification =\n | { verdict: 'verified' }\n | { verdict: 'forged'; reason: 'signature' }\n | {\n verdict: 'unverified';\n reason: 'malformed' | 'expired' | 'future' | 'no_secret' | 'context';\n };\n\nexport interface BeaconNonceBinding {\n projectId: string;\n sessionId: string;\n /** `beaconNonceContext(...)` of the request being issued to or verified. */\n context: string;\n}\n\nfunction ipv4Prefix(ip: string): string | null {\n const match = IPV4_PATTERN.exec(ip);\n return match ? `${match[1]}.${match[2]}.${match[3]}` : null;\n}\n\n/**\n * The first three groups (a /48) of an IPv6 address, expanded so compressed\n * forms agree with their spelled-out equivalents. An IPv4-mapped address\n * (`::ffff:a.b.c.d` or its hex spelling) is a v4 client and keys on its /24.\n * `null` for anything that is not a well-formed address.\n */\nfunction ipv6Prefix(ip: string): string | null {\n const bare = ip.toLowerCase().split('%')[0];\n const lastColon = bare.lastIndexOf(':');\n const embedded = IPV4_PATTERN.exec(bare.slice(lastColon + 1));\n const text = embedded\n ? `${bare.slice(0, lastColon + 1)}${((Number(embedded[1]) << 8) | Number(embedded[2])).toString(16)}:${((Number(embedded[3]) << 8) | Number(embedded[4])).toString(16)}`\n : bare;\n const halves = text.split('::');\n if (halves.length > 2) return null;\n const head = halves[0] ? halves[0].split(':') : [];\n const tail = halves.length === 2 && halves[1] ? halves[1].split(':') : [];\n const missing = 8 - head.length - tail.length;\n if (halves.length === 1 ? missing !== 0 : missing < 1) return null;\n const groups = [...head, ...Array<string>(halves.length === 2 ? missing : 0).fill('0'), ...tail];\n if (!groups.every((group) => IPV6_GROUP_PATTERN.test(group))) return null;\n const words = groups.map((group) => parseInt(group, 16));\n const mapped = words.slice(0, 5).every((word) => word === 0) && words[5] === 0xffff;\n if (mapped) return `${words[6] >> 8}.${words[6] & 0xff}.${words[7] >> 8}`;\n return words\n .slice(0, 3)\n .map((word) => word.toString(16))\n .join(':');\n}\n\n/**\n * The requester facts a nonce is bound to: the network prefix (IPv4 /24,\n * IPv6 /48, so NAT and DHCP churn inside one access network still verify)\n * and the User-Agent. Empty when neither is known, which binds nothing.\n */\nexport function beaconNonceContext(client: { ip?: string; userAgent?: string }): string {\n const ip = client.ip?.trim() ?? '';\n const prefix = ipv4Prefix(ip) ?? (ip.includes(':') ? ipv6Prefix(ip) : null) ?? '';\n const userAgent = (client.userAgent ?? '').slice(0, MAX_CONTEXT_USER_AGENT_LENGTH);\n return prefix || userAgent ? `${prefix}|${userAgent}` : '';\n}\n\nconst encoder = new TextEncoder();\n\nconst keyCache = new Map<string, Promise<CryptoKey>>();\n\nfunction hmacKey(secret: string): Promise<CryptoKey> {\n let key = keyCache.get(secret);\n if (!key) {\n key = crypto.subtle.importKey(\n 'raw',\n encoder.encode(secret),\n { name: 'HMAC', hash: 'SHA-256' },\n false,\n ['sign']\n );\n keyCache.set(secret, key);\n }\n return key;\n}\n\nfunction base64url(bytes: Uint8Array): string {\n let binary = '';\n for (const byte of bytes) binary += String.fromCharCode(byte);\n return btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n}\n\n/**\n * Length-prefixed canonical encoding (`<byteLength>:<field>`), never a bare\n * delimiter join: `sessionId` is caller-controlled at the edge, so a value\n * that embeds the delimiter must not be able to shift the field boundaries\n * and re-bind the MAC to another session (Cursor Bugbot, PR #5255).\n */\nfunction canonical(fields: readonly string[]): Uint8Array<ArrayBuffer> {\n const chunks = fields.map((field) => {\n const bytes = encoder.encode(field);\n return [encoder.encode(`${bytes.length}:`), bytes] as const;\n });\n const total = chunks.reduce((sum, [len, bytes]) => sum + len.length + bytes.length, 0);\n const out = new Uint8Array(new ArrayBuffer(total));\n let offset = 0;\n for (const [len, bytes] of chunks) {\n out.set(len, offset);\n offset += len.length;\n out.set(bytes, offset);\n offset += bytes.length;\n }\n return out;\n}\n\nasync function mac(\n secret: string,\n binding: BeaconNonceBinding,\n issuedAt: string,\n random: string\n): Promise<string> {\n const input = canonical([\n MAC_INPUT_PREFIX,\n binding.projectId,\n binding.sessionId,\n issuedAt,\n random,\n ]);\n const signature = await crypto.subtle.sign('HMAC', await hmacKey(secret), input);\n return base64url(new Uint8Array(signature, 0, MAC_BYTES));\n}\n\nasync function contextTag(\n secret: string,\n binding: BeaconNonceBinding,\n issuedAt: string,\n random: string\n): Promise<string> {\n const input = canonical([\n CONTEXT_INPUT_PREFIX,\n binding.projectId,\n binding.sessionId,\n issuedAt,\n random,\n binding.context,\n ]);\n const signature = await crypto.subtle.sign('HMAC', await hmacKey(secret), input);\n return base64url(new Uint8Array(signature, 0, CONTEXT_TAG_BYTES));\n}\n\nfunction constantTimeEqual(left: string, right: string): boolean {\n if (left.length !== right.length) return false;\n let diff = 0;\n for (let i = 0; i < left.length; i += 1) diff |= left.charCodeAt(i) ^ right.charCodeAt(i);\n return diff === 0;\n}\n\n/** True when `nonce` is in the signed wire format (not necessarily valid). */\nexport function isSignedBeaconNonce(nonce: string | undefined): nonce is string {\n return typeof nonce === 'string' && nonce.startsWith(`${NONCE_VERSION}.`);\n}\n\n/**\n * Mint a nonce for `binding` at `issuedAtMs`. Throws when `secret` is\n * empty — issuing an unsigned value would be indistinguishable from a\n * real one on the wire, so the caller must decide to issue nothing.\n */\nexport async function issueSignedBeaconNonce(\n secret: string,\n binding: BeaconNonceBinding,\n issuedAtMs: number\n): Promise<string> {\n if (!secret) throw new Error('beacon nonce secret is required to issue a signed nonce');\n const issuedAt = Math.floor(issuedAtMs / 1000).toString(36);\n const random = base64url(crypto.getRandomValues(new Uint8Array(RANDOM_BYTES)));\n return [\n NONCE_VERSION,\n issuedAt,\n random,\n await mac(secret, binding, issuedAt, random),\n await contextTag(secret, binding, issuedAt, random),\n ].join('.');\n}\n\n/**\n * Verify `nonce` against `binding` as of `nowMs`. Never throws; every\n * failure mode is a verdict (see the module doc for why expiry is\n * `unverified` rather than `forged`).\n */\nexport async function verifySignedBeaconNonce(\n secret: string | undefined,\n binding: BeaconNonceBinding,\n nonce: string | undefined,\n nowMs: number\n): Promise<BeaconNonceVerification> {\n if (!isSignedBeaconNonce(nonce)) return { verdict: 'unverified', reason: 'malformed' };\n const parts = nonce.split('.');\n if (parts.length !== 5 || parts.some((part) => part.length === 0)) {\n return { verdict: 'unverified', reason: 'malformed' };\n }\n const [, issuedAt, random, providedMac, providedContextTag] = parts;\n if (\n !ISSUED_AT_PATTERN.test(issuedAt) ||\n !BASE64URL_PATTERN.test(random) ||\n !BASE64URL_PATTERN.test(providedMac) ||\n !BASE64URL_PATTERN.test(providedContextTag)\n ) {\n return { verdict: 'unverified', reason: 'malformed' };\n }\n if (!secret) return { verdict: 'unverified', reason: 'no_secret' };\n\n const expectedMac = await mac(secret, binding, issuedAt, random);\n if (!constantTimeEqual(providedMac, expectedMac))\n return { verdict: 'forged', reason: 'signature' };\n\n const issuedAtSeconds = parseInt(issuedAt, 36);\n const nowSeconds = Math.floor(nowMs / 1000);\n if (!Number.isFinite(issuedAtSeconds)) return { verdict: 'unverified', reason: 'malformed' };\n if (issuedAtSeconds - nowSeconds > BEACON_NONCE_CLOCK_SKEW_SECONDS) {\n return { verdict: 'unverified', reason: 'future' };\n }\n if (nowSeconds - issuedAtSeconds > BEACON_NONCE_TTL_SECONDS) {\n return { verdict: 'unverified', reason: 'expired' };\n }\n if (!constantTimeEqual(providedContextTag, await contextTag(secret, binding, issuedAt, random))) {\n return { verdict: 'unverified', reason: 'context' };\n }\n return { verdict: 'verified' };\n}\n\nasync function handoffTag(\n secret: string,\n projectId: string,\n idBytes: Uint8Array\n): Promise<Uint8Array> {\n const input = canonical([HANDOFF_TOKEN_INPUT_PREFIX, projectId, base64url(idBytes)]);\n const signature = await crypto.subtle.sign('HMAC', await hmacKey(secret), input);\n return new Uint8Array(signature, 0, HANDOFF_TAG_BYTES);\n}\n\nfunction base64urlDecode(text: string): Uint8Array {\n const padded = text\n .replace(/-/g, '+')\n .replace(/_/g, '/')\n .padEnd(Math.ceil(text.length / 4) * 4, '=');\n return Uint8Array.from(atob(padded), (char) => char.charCodeAt(0));\n}\n\nfunction bytesEqual(left: Uint8Array, right: Uint8Array): boolean {\n if (left.length !== right.length) return false;\n let diff = 0;\n for (let i = 0; i < left.length; i += 1) diff |= left[i] ^ right[i];\n return diff === 0;\n}\n\nexport async function issueHandoffToken(secret: string, projectId: string): Promise<string> {\n if (!secret) throw new Error('beacon nonce secret is required to issue a handoff token');\n const id = crypto.getRandomValues(new Uint8Array(HANDOFF_ID_BYTES));\n const token = new Uint8Array(HANDOFF_ID_BYTES + HANDOFF_TAG_BYTES);\n token.set(id, 0);\n token.set(await handoffTag(secret, projectId, id), HANDOFF_ID_BYTES);\n return base64url(token);\n}\n\nexport const HANDOFF_USER_HASH_PATTERN = /^[0-9a-f]{8}$/;\nconst HANDOFF_USER_SEPARATOR = '~';\n\nexport function splitHandoffToken(raw: string): { token: string; userHash?: string } {\n const parts = raw.split(HANDOFF_USER_SEPARATOR);\n const [token, userHash] = parts;\n if (parts.length > 2 || (userHash !== undefined && !HANDOFF_USER_HASH_PATTERN.test(userHash))) {\n return { token: raw };\n }\n return { token, ...(userHash === undefined ? {} : { userHash }) };\n}\n\nexport async function handoffTokenAuthentic(\n secrets: readonly string[],\n projectId: string,\n token: unknown\n): Promise<boolean> {\n if (typeof token !== 'string' || !HANDOFF_TOKEN_PATTERN.test(token)) return false;\n const bytes = base64urlDecode(token);\n if (bytes.length !== HANDOFF_ID_BYTES + HANDOFF_TAG_BYTES) return false;\n if (base64url(bytes) !== token) return false;\n const id = bytes.slice(0, HANDOFF_ID_BYTES);\n const providedTag = bytes.slice(HANDOFF_ID_BYTES);\n const matches = await Promise.all(\n secrets\n .filter((secret) => secret.length > 0)\n .map(async (secret) => bytesEqual(providedTag, await handoffTag(secret, projectId, id)))\n );\n return matches.includes(true);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,gBAAgB;AACtB,MAAM,mBAAmB,2BAA2B;AACpD,MAAM,uBAAuB,+BAA+B;AAC5D,MAAM,eAAe;AACrB,MAAM,YAAY;AAClB,MAAM,oBAAoB;AAC1B,MAAM,gCAAgC;AACtC,MAAM,eAAe;AACrB,MAAM,qBAAqB;AAG3B,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;AACnC,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAE1B,MAAa,wBAAwB;;AAGrC,MAAa,2BAA2B;;AAExC,MAAa,kCAAkC;;AAE/C,MAAa,0BAA0B;AAmBvC,SAAS,WAAW,IAA2B;CAC7C,MAAM,QAAQ,aAAa,KAAK,EAAE;CAClC,OAAO,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,MAAM,sBAAsB;CAC9C,MAAM,CAAC,OAAO,YAAY;CAC1B,IAAI,MAAM,SAAS,KAAM,aAAa,UAAa,CAAC,0BAA0B,KAAK,QAAQ,GACzF,OAAO,EAAE,OAAO,IAAI;CAEtB,OAAO;EAAE;EAAO,GAAI,aAAa,SAAY,CAAC,IAAI,EAAE,SAAS;CAAG;AAClE;AAEA,eAAsB,sBACpB,SACA,WACA,OACkB;CAClB,IAAI,OAAO,UAAU,YAAY,CAAC,sBAAsB,KAAK,KAAK,GAAG,OAAO;CAC5E,MAAM,QAAQ,gBAAgB,KAAK;CACnC,IAAI,MAAM,WAAW,IAAsC,OAAO;CAClE,IAAI,UAAU,KAAK,MAAM,OAAO,OAAO;CACvC,MAAM,KAAK,MAAM,MAAM,GAAG,gBAAgB;CAC1C,MAAM,cAAc,MAAM,MAAM,gBAAgB;CAMhD,QAAO,MALe,QAAQ,IAC5B,QACG,QAAQ,WAAW,OAAO,SAAS,CAAC,CAAC,CACrC,IAAI,OAAO,WAAW,WAAW,aAAa,MAAM,WAAW,QAAQ,WAAW,EAAE,CAAC,CAAC,CAC3F,EACc,CAAC,SAAS,IAAI;AAC9B"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/beacon-nonce/index.ts"],"sourcesContent":["/**\n * Stateless, client-bound beacon nonce, issued and verified by both the\n * origin (`apps/web/lib/services/nonce.service.ts`) and the beacon-ingest\n * edge Worker.\n *\n * Every pixel/beacon response hands the browser a per-session nonce that its\n * next post must echo. A queue-only edge returns its receipt before the\n * origin has seen the batch, so the nonce cannot depend on origin state:\n * it is an HMAC-SHA256 under a secret shared by origin and edge. The origin\n * verifies it at synchronous ingest, or on replay using the edge's\n * acceptance time as the clock.\n *\n * Web Crypto only (`crypto.subtle`, `crypto.getRandomValues`): this runs\n * unchanged in Cloudflare Workers, Node ≥ 20 and the browser bundle.\n *\n * Wire format (56 chars, inside the schema's 64-char cap):\n *\n * n2.<issuedAt base36 seconds>.<random 8 bytes b64url>.<HMAC 16 bytes b64url>.<ctx tag 8 bytes b64url>\n *\n * The first HMAC binds the format version + project + session + issue time +\n * random. The trailing context tag additionally binds the requester's\n * network prefix and User-Agent (`beaconNonceContext`), so a nonce lifted\n * from one client does not verify from another. The version is inside the\n * MAC, so a nonce cannot be relabelled to dodge the context tag.\n *\n * Verdict semantics — three states, never two:\n * - `verified`: signature matches THIS project+session, the context matches,\n * and it is within TTL.\n * - `forged`: well-formed but the MAC does not match this session/secret.\n * The only outcome that counts as evidence against the client.\n * - `unverified`: nothing could be proven — not signed-format (absent, or\n * a value from before signing existed), expired, from the future, this\n * side has no secret, or the session signature is genuine but the\n * requester's network/User-Agent differs from the one it was issued to (a\n * roaming phone and a replay from elsewhere look the same, so neither is\n * treated as fabrication). Staleness is not forgery: an edge that stopped\n * issuing (secret unset) leaves clients echoing old values, and that must\n * degrade to \"unknown\", never to \"failed\".\n *\n * Any unexpired signature for the session verifies, so a nonce is not\n * single-use within its TTL. Multi-tab sessions need no window at all.\n */\n\nconst NONCE_VERSION = 'n2';\nconst MAC_INPUT_PREFIX = `checkpoint-beacon-nonce:${NONCE_VERSION}`;\nconst CONTEXT_INPUT_PREFIX = `checkpoint-beacon-nonce:ctx:${NONCE_VERSION}`;\nconst RANDOM_BYTES = 8;\nconst MAC_BYTES = 16;\nconst CONTEXT_TAG_BYTES = 8;\nconst MAX_CONTEXT_USER_AGENT_LENGTH = 512;\nconst IPV4_PATTERN = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/;\nconst IPV6_GROUP_PATTERN = /^[0-9a-f]{1,4}$/;\n// Each wire part has a closed alphabet and is rejected as malformed before any\n// MAC work when it strays outside it — a nonce is no place for `\\0` or `.`.\nconst ISSUED_AT_PATTERN = /^[0-9a-z]{1,16}$/;\nconst BASE64URL_PATTERN = /^[A-Za-z0-9_-]+$/;\nconst HANDOFF_TOKEN_INPUT_PREFIX = 'checkpoint-handoff-token:v1';\nconst HANDOFF_ID_BYTES = 16;\nconst HANDOFF_TAG_BYTES = 16;\n\nexport const HANDOFF_TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;\n\n/** How long an issued nonce stays verifiable. */\nexport const BEACON_NONCE_TTL_SECONDS = 10 * 60;\n/** Edge and origin clocks may disagree; a nonce this far \"in the future\" still verifies. */\nexport const BEACON_NONCE_CLOCK_SKEW_SECONDS = 60;\n/** The beacon wire schema's `nonce: z.string().max(64)`. */\nexport const BEACON_NONCE_MAX_LENGTH = 64;\n\nexport type BeaconNonceVerdict = 'verified' | 'forged' | 'unverified';\n\nexport type BeaconNonceVerification =\n | { verdict: 'verified' }\n | { verdict: 'forged'; reason: 'signature' }\n | {\n verdict: 'unverified';\n reason: 'malformed' | 'expired' | 'future' | 'no_secret' | 'context';\n };\n\nexport interface BeaconNonceBinding {\n projectId: string;\n sessionId: string;\n /** `beaconNonceContext(...)` of the request being issued to or verified. */\n context: string;\n}\n\nfunction ipv4Prefix(ip: string): string | null {\n const match = IPV4_PATTERN.exec(ip);\n return match ? `${match[1]}.${match[2]}.${match[3]}` : null;\n}\n\n/**\n * The first three groups (a /48) of an IPv6 address, expanded so compressed\n * forms agree with their spelled-out equivalents. An IPv4-mapped address\n * (`::ffff:a.b.c.d` or its hex spelling) is a v4 client and keys on its /24.\n * `null` for anything that is not a well-formed address.\n */\nfunction ipv6Prefix(ip: string): string | null {\n const bare = ip.toLowerCase().split('%')[0];\n const lastColon = bare.lastIndexOf(':');\n const embedded = IPV4_PATTERN.exec(bare.slice(lastColon + 1));\n const text = embedded\n ? `${bare.slice(0, lastColon + 1)}${((Number(embedded[1]) << 8) | Number(embedded[2])).toString(16)}:${((Number(embedded[3]) << 8) | Number(embedded[4])).toString(16)}`\n : bare;\n const halves = text.split('::');\n if (halves.length > 2) return null;\n const head = halves[0] ? halves[0].split(':') : [];\n const tail = halves.length === 2 && halves[1] ? halves[1].split(':') : [];\n const missing = 8 - head.length - tail.length;\n if (halves.length === 1 ? missing !== 0 : missing < 1) return null;\n const groups = [...head, ...Array<string>(halves.length === 2 ? missing : 0).fill('0'), ...tail];\n if (!groups.every((group) => IPV6_GROUP_PATTERN.test(group))) return null;\n const words = groups.map((group) => parseInt(group, 16));\n const mapped = words.slice(0, 5).every((word) => word === 0) && words[5] === 0xffff;\n if (mapped) return `${words[6] >> 8}.${words[6] & 0xff}.${words[7] >> 8}`;\n return words\n .slice(0, 3)\n .map((word) => word.toString(16))\n .join(':');\n}\n\n/**\n * The requester facts a nonce is bound to: the network prefix (IPv4 /24,\n * IPv6 /48, so NAT and DHCP churn inside one access network still verify)\n * and the User-Agent. Empty when neither is known, which binds nothing.\n */\nexport function beaconNonceContext(client: { ip?: string; userAgent?: string }): string {\n const ip = client.ip?.trim() ?? '';\n const prefix = ipv4Prefix(ip) ?? (ip.includes(':') ? ipv6Prefix(ip) : null) ?? '';\n const userAgent = (client.userAgent ?? '').slice(0, MAX_CONTEXT_USER_AGENT_LENGTH);\n return prefix || userAgent ? `${prefix}|${userAgent}` : '';\n}\n\nconst encoder = new TextEncoder();\n\nconst keyCache = new Map<string, Promise<CryptoKey>>();\n\nfunction hmacKey(secret: string): Promise<CryptoKey> {\n let key = keyCache.get(secret);\n if (!key) {\n key = crypto.subtle.importKey(\n 'raw',\n encoder.encode(secret),\n { name: 'HMAC', hash: 'SHA-256' },\n false,\n ['sign']\n );\n keyCache.set(secret, key);\n }\n return key;\n}\n\nfunction base64url(bytes: Uint8Array): string {\n let binary = '';\n for (const byte of bytes) binary += String.fromCharCode(byte);\n return btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n}\n\n/**\n * Length-prefixed canonical encoding (`<byteLength>:<field>`), never a bare\n * delimiter join: `sessionId` is caller-controlled at the edge, so a value\n * that embeds the delimiter must not be able to shift the field boundaries\n * and re-bind the MAC to another session (Cursor Bugbot, PR #5255).\n */\nfunction canonical(fields: readonly string[]): Uint8Array<ArrayBuffer> {\n const chunks = fields.map((field) => {\n const bytes = encoder.encode(field);\n return [encoder.encode(`${bytes.length}:`), bytes] as const;\n });\n const total = chunks.reduce((sum, [len, bytes]) => sum + len.length + bytes.length, 0);\n const out = new Uint8Array(new ArrayBuffer(total));\n let offset = 0;\n for (const [len, bytes] of chunks) {\n out.set(len, offset);\n offset += len.length;\n out.set(bytes, offset);\n offset += bytes.length;\n }\n return out;\n}\n\nasync function mac(\n secret: string,\n binding: BeaconNonceBinding,\n issuedAt: string,\n random: string\n): Promise<string> {\n const input = canonical([\n MAC_INPUT_PREFIX,\n binding.projectId,\n binding.sessionId,\n issuedAt,\n random,\n ]);\n const signature = await crypto.subtle.sign('HMAC', await hmacKey(secret), input);\n return base64url(new Uint8Array(signature, 0, MAC_BYTES));\n}\n\nasync function nonceContextTag(\n secret: string,\n binding: BeaconNonceBinding,\n issuedAt: string,\n random: string\n): Promise<string> {\n const input = canonical([\n CONTEXT_INPUT_PREFIX,\n binding.projectId,\n binding.sessionId,\n issuedAt,\n random,\n binding.context,\n ]);\n const signature = await crypto.subtle.sign('HMAC', await hmacKey(secret), input);\n return base64url(new Uint8Array(signature, 0, CONTEXT_TAG_BYTES));\n}\n\nconst POSTURE_CONTEXT_TAG_PREFIX = 'checkpoint-beacon-posture-context:v1\\0';\n\nexport async function contextTag(secret: string, context: string): Promise<string> {\n const signature = await crypto.subtle.sign(\n 'HMAC',\n await hmacKey(secret),\n encoder.encode(`${POSTURE_CONTEXT_TAG_PREFIX}${context}`)\n );\n return base64url(new Uint8Array(signature));\n}\n\nfunction constantTimeEqual(left: string, right: string): boolean {\n if (left.length !== right.length) return false;\n let diff = 0;\n for (let i = 0; i < left.length; i += 1) diff |= left.charCodeAt(i) ^ right.charCodeAt(i);\n return diff === 0;\n}\n\n/** True when `nonce` is in the signed wire format (not necessarily valid). */\nexport function isSignedBeaconNonce(nonce: string | undefined): nonce is string {\n return typeof nonce === 'string' && nonce.startsWith(`${NONCE_VERSION}.`);\n}\n\n/**\n * Mint a nonce for `binding` at `issuedAtMs`. Throws when `secret` is\n * empty — issuing an unsigned value would be indistinguishable from a\n * real one on the wire, so the caller must decide to issue nothing.\n */\nexport async function issueSignedBeaconNonce(\n secret: string,\n binding: BeaconNonceBinding,\n issuedAtMs: number\n): Promise<string> {\n if (!secret) throw new Error('beacon nonce secret is required to issue a signed nonce');\n const issuedAt = Math.floor(issuedAtMs / 1000).toString(36);\n const random = base64url(crypto.getRandomValues(new Uint8Array(RANDOM_BYTES)));\n return [\n NONCE_VERSION,\n issuedAt,\n random,\n await mac(secret, binding, issuedAt, random),\n await nonceContextTag(secret, binding, issuedAt, random),\n ].join('.');\n}\n\n/**\n * Verify `nonce` against `binding` as of `nowMs`. Never throws; every\n * failure mode is a verdict (see the module doc for why expiry is\n * `unverified` rather than `forged`).\n */\nexport async function verifySignedBeaconNonce(\n secret: string | undefined,\n binding: BeaconNonceBinding,\n nonce: string | undefined,\n nowMs: number\n): Promise<BeaconNonceVerification> {\n if (!isSignedBeaconNonce(nonce)) return { verdict: 'unverified', reason: 'malformed' };\n const parts = nonce.split('.');\n if (parts.length !== 5 || parts.some((part) => part.length === 0)) {\n return { verdict: 'unverified', reason: 'malformed' };\n }\n const [, issuedAt, random, providedMac, providedContextTag] = parts;\n if (\n !ISSUED_AT_PATTERN.test(issuedAt) ||\n !BASE64URL_PATTERN.test(random) ||\n !BASE64URL_PATTERN.test(providedMac) ||\n !BASE64URL_PATTERN.test(providedContextTag)\n ) {\n return { verdict: 'unverified', reason: 'malformed' };\n }\n if (!secret) return { verdict: 'unverified', reason: 'no_secret' };\n\n const expectedMac = await mac(secret, binding, issuedAt, random);\n if (!constantTimeEqual(providedMac, expectedMac))\n return { verdict: 'forged', reason: 'signature' };\n\n const issuedAtSeconds = parseInt(issuedAt, 36);\n const nowSeconds = Math.floor(nowMs / 1000);\n if (!Number.isFinite(issuedAtSeconds)) return { verdict: 'unverified', reason: 'malformed' };\n if (issuedAtSeconds - nowSeconds > BEACON_NONCE_CLOCK_SKEW_SECONDS) {\n return { verdict: 'unverified', reason: 'future' };\n }\n if (nowSeconds - issuedAtSeconds > BEACON_NONCE_TTL_SECONDS) {\n return { verdict: 'unverified', reason: 'expired' };\n }\n if (\n !constantTimeEqual(providedContextTag, await nonceContextTag(secret, binding, issuedAt, random))\n ) {\n return { verdict: 'unverified', reason: 'context' };\n }\n return { verdict: 'verified' };\n}\n\nasync function handoffTag(\n secret: string,\n projectId: string,\n idBytes: Uint8Array\n): Promise<Uint8Array> {\n const input = canonical([HANDOFF_TOKEN_INPUT_PREFIX, projectId, base64url(idBytes)]);\n const signature = await crypto.subtle.sign('HMAC', await hmacKey(secret), input);\n return new Uint8Array(signature, 0, HANDOFF_TAG_BYTES);\n}\n\nfunction base64urlDecode(text: string): Uint8Array {\n const padded = text\n .replace(/-/g, '+')\n .replace(/_/g, '/')\n .padEnd(Math.ceil(text.length / 4) * 4, '=');\n return Uint8Array.from(atob(padded), (char) => char.charCodeAt(0));\n}\n\nfunction bytesEqual(left: Uint8Array, right: Uint8Array): boolean {\n if (left.length !== right.length) return false;\n let diff = 0;\n for (let i = 0; i < left.length; i += 1) diff |= left[i] ^ right[i];\n return diff === 0;\n}\n\nexport async function issueHandoffToken(secret: string, projectId: string): Promise<string> {\n if (!secret) throw new Error('beacon nonce secret is required to issue a handoff token');\n const id = crypto.getRandomValues(new Uint8Array(HANDOFF_ID_BYTES));\n const token = new Uint8Array(HANDOFF_ID_BYTES + HANDOFF_TAG_BYTES);\n token.set(id, 0);\n token.set(await handoffTag(secret, projectId, id), HANDOFF_ID_BYTES);\n return base64url(token);\n}\n\nexport const HANDOFF_USER_HASH_PATTERN = /^[0-9a-f]{8}$/;\nconst HANDOFF_USER_SEPARATOR = '~';\n\nexport function splitHandoffToken(raw: string): { token: string; userHash?: string } {\n const parts = raw.split(HANDOFF_USER_SEPARATOR);\n const [token, userHash] = parts;\n if (parts.length > 2 || (userHash !== undefined && !HANDOFF_USER_HASH_PATTERN.test(userHash))) {\n return { token: raw };\n }\n return { token, ...(userHash === undefined ? {} : { userHash }) };\n}\n\nexport async function handoffTokenAuthentic(\n secrets: readonly string[],\n projectId: string,\n token: unknown\n): Promise<boolean> {\n if (typeof token !== 'string' || !HANDOFF_TOKEN_PATTERN.test(token)) return false;\n const bytes = base64urlDecode(token);\n if (bytes.length !== HANDOFF_ID_BYTES + HANDOFF_TAG_BYTES) return false;\n if (base64url(bytes) !== token) return false;\n const id = bytes.slice(0, HANDOFF_ID_BYTES);\n const providedTag = bytes.slice(HANDOFF_ID_BYTES);\n const matches = await Promise.all(\n secrets\n .filter((secret) => secret.length > 0)\n .map(async (secret) => bytesEqual(providedTag, await handoffTag(secret, projectId, id)))\n );\n return matches.includes(true);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,gBAAgB;AACtB,MAAM,mBAAmB,2BAA2B;AACpD,MAAM,uBAAuB,+BAA+B;AAC5D,MAAM,eAAe;AACrB,MAAM,YAAY;AAClB,MAAM,oBAAoB;AAC1B,MAAM,gCAAgC;AACtC,MAAM,eAAe;AACrB,MAAM,qBAAqB;AAG3B,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;AACnC,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAE1B,MAAa,wBAAwB;;AAGrC,MAAa,2BAA2B;;AAExC,MAAa,kCAAkC;;AAE/C,MAAa,0BAA0B;AAmBvC,SAAS,WAAW,IAA2B;CAC7C,MAAM,QAAQ,aAAa,KAAK,EAAE;CAClC,OAAO,QAAQ,GAAG,MAAM,GAAG,GAAG,MAAM,GAAG,GAAG,MAAM,OAAO;AACzD;;;;;;;AAQA,SAAS,WAAW,IAA2B;CAC7C,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;CACzC,MAAM,YAAY,KAAK,YAAY,GAAG;CACtC,MAAM,WAAW,aAAa,KAAK,KAAK,MAAM,YAAY,CAAC,CAAC;CAI5D,MAAM,UAHO,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AAM,SAAS,KAAM,aAAa,UAAa,CAAC,0BAA0B,KAAK,QAAQ,GACzF,OAAO,EAAE,OAAO,IAAI;CAEtB,OAAO;EAAE;EAAO,GAAI,aAAa,SAAY,CAAC,IAAI,EAAE,SAAS;CAAG;AAClE;AAEA,eAAsB,sBACpB,SACA,WACA,OACkB;CAClB,IAAI,OAAO,UAAU,YAAY,CAAC,sBAAsB,KAAK,KAAK,GAAG,OAAO;CAC5E,MAAM,QAAQ,gBAAgB,KAAK;CACnC,IAAI,MAAM,WAAW,IAAsC,OAAO;CAClE,IAAI,UAAU,KAAK,MAAM,OAAO,OAAO;CACvC,MAAM,KAAK,MAAM,MAAM,GAAG,gBAAgB;CAC1C,MAAM,cAAc,MAAM,MAAM,gBAAgB;CAMhD,QAAO,MALe,QAAQ,IAC5B,QACG,QAAQ,WAAW,OAAO,SAAS,CAAC,CAAC,CACrC,IAAI,OAAO,WAAW,WAAW,aAAa,MAAM,WAAW,QAAQ,WAAW,EAAE,CAAC,CAAC,CAC3F,EACc,CAAC,SAAS,IAAI;AAC9B"}
|
|
@@ -209,12 +209,14 @@ export interface TransportOptions {
|
|
|
209
209
|
publicJwk?: EcPublicJwk;
|
|
210
210
|
deviceId?: string;
|
|
211
211
|
handoffToken?: string;
|
|
212
|
+
batch?: QueuedBatchIdentity;
|
|
212
213
|
}
|
|
213
214
|
export interface TransportResponse {
|
|
214
215
|
success: boolean;
|
|
215
216
|
timestamp: number;
|
|
216
217
|
batchId?: string;
|
|
217
218
|
error?: string;
|
|
219
|
+
queued?: boolean;
|
|
218
220
|
}
|
|
219
221
|
export type TransportState = 'idle' | 'sending' | 'offline' | 'paused' | 'error';
|
|
220
222
|
export interface TransportMetrics {
|
|
@@ -228,6 +230,9 @@ export interface TransportMetrics {
|
|
|
228
230
|
averageLatency?: number;
|
|
229
231
|
lastSuccessTimestamp?: number;
|
|
230
232
|
lastErrorTimestamp?: number;
|
|
233
|
+
eventsEvicted?: number;
|
|
234
|
+
eventsExpired?: number;
|
|
235
|
+
entriesCorrupt?: number;
|
|
231
236
|
}
|
|
232
237
|
export type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
|
|
233
238
|
export interface NetworkInfo {
|
|
@@ -389,6 +394,13 @@ export interface RetryStrategy {
|
|
|
389
394
|
factor: number;
|
|
390
395
|
jitter: boolean;
|
|
391
396
|
}
|
|
397
|
+
export interface QueuedBatchIdentity {
|
|
398
|
+
batchId: string;
|
|
399
|
+
sessionId: string;
|
|
400
|
+
timestamp: number;
|
|
401
|
+
projectId?: string;
|
|
402
|
+
handoffToken?: string;
|
|
403
|
+
}
|
|
392
404
|
export interface OfflineQueueEntry {
|
|
393
405
|
id: string;
|
|
394
406
|
events: BeaconEvent[];
|
|
@@ -396,6 +408,7 @@ export interface OfflineQueueEntry {
|
|
|
396
408
|
expiresAt: number;
|
|
397
409
|
retryCount: number;
|
|
398
410
|
size: number;
|
|
411
|
+
batch?: QueuedBatchIdentity;
|
|
399
412
|
}
|
|
400
413
|
export interface EcPublicJwk {
|
|
401
414
|
kty: 'EC';
|
|
@@ -424,6 +437,9 @@ export interface BeaconBatch {
|
|
|
424
437
|
nonce?: string;
|
|
425
438
|
nonceEcho?: boolean;
|
|
426
439
|
publicJwk?: EcPublicJwk;
|
|
440
|
+
queueEvictions?: number;
|
|
441
|
+
queueExpirations?: number;
|
|
442
|
+
queueCorruptions?: number;
|
|
427
443
|
}
|
|
428
444
|
export interface BeaconCollectorData {
|
|
429
445
|
userAgent?: string;
|
|
@@ -477,7 +493,12 @@ export declare const BEACON_MAX_EVENTS_PER_BATCH = 100;
|
|
|
477
493
|
export declare const SESSION_IDLE_GAP_MAX_MS = 21600000;
|
|
478
494
|
export declare const BEACON_MAX_BATCH_ID_LENGTH = 255;
|
|
479
495
|
export declare const BEACON_ORIGIN_CONTRACT_VERSION = 1;
|
|
480
|
-
export declare const BEACON_ORIGIN_CAPABILITIES: readonly ["batch-replay-v1", "receipt-status-v1", "receipt-posture-v1"];
|
|
496
|
+
export declare const BEACON_ORIGIN_CAPABILITIES: readonly ["batch-replay-v1", "receipt-status-v1", "receipt-posture-v1", "batch-identity-digest-v1"];
|
|
497
|
+
export declare function withAdoptedSession<B extends {
|
|
498
|
+
sessionId: string;
|
|
499
|
+
events: ReadonlyArray<Record<string, unknown>>;
|
|
500
|
+
}>(batch: B, sessionId: string): B;
|
|
501
|
+
export declare function beaconBodyIdentity(body: object): string;
|
|
481
502
|
export declare const POSTURE_TTL_SECONDS = 120;
|
|
482
503
|
export interface CachedPosture {
|
|
483
504
|
token: string;
|
|
@@ -486,6 +507,7 @@ export interface CachedPosture {
|
|
|
486
507
|
export interface PostureAnswer {
|
|
487
508
|
posture?: CachedPosture;
|
|
488
509
|
postureStatus?: string;
|
|
510
|
+
postureReason?: string;
|
|
489
511
|
sessionId?: string;
|
|
490
512
|
answeredAtMs?: number;
|
|
491
513
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/beacon-types/index.ts"],"mappings":";YAOY;YACA,YAAY,gBAAgB;GAAiB,cAAc;;YAC3D,kBAAkB;YAClB,kBAAkB;YAClB,mBAAmB,eAAe;YAClC,gBAAgB,sBAAsB;YACtC;wBA4KI,iBAAiB,iBAAiB,SAAS;iBA+C1C,+BAA+B;EAC9C;EACA;EACA;EACA;EACA;;iBAGe,wCAAwC;EACvD,aAAa;EACb,gBAAgB;EAChB,mBAAmB;EACnB;EACA;EACA;EACA;;iBAGe,iCAAiC;EAChD;EACA;IACE;;;iBAIa;EACf,gBAAgB;EAChB,aAAa;;iBAGE,+BAA+B;EAC9C;IACE,aACE,cACA;MACE,mBAAmB;MACnB,gBAAgB;QAEjB;;;iBAIU;EACf;EACA;EACA;;iBAGe,8BAA8B;EAC7C,SAAS;EACT,uCAAuC;;iBAGxB,oCAAoC;EACnD;EACA;;iBAiBe;EAKf;;iBAIe;EAEf;EAEA;EAEA;EAEA;EAEA;EAEA;EASA;;iBAGe;EAEf;EAOA,WAAW;EAaX;EAGA;EAGA,OAAO;EAQP;EAOA;EAOA;EAOA;EASA;EAOA;EAcA;EAcA;EAUA;EAMA;EASA;EAWA;EASA,aAAa,SAAS;EAOtB;EASA;EAUA;EAUA;EAOA,WAAW;EAkBX;EAUA;EAWA;EAUA;EASA;EAMA;EAWA;EAOA;EAOA;EAOA;EASA;EAUA;EAMA;EAQA;EAOA,eAAe;EAEf;;iBAOe;EAEf,MAAM;EAGN,MAAM;EAGN,UAAU;;iBAGK;EAEf;EAGA;EAGA;EAGA,WAAW;GAGV;;iBAOc;EAIf,QAAQ,mBAAmB,OAAO,gBAAgB;EAKlD,WAAW,mBAAmB,YAAY,gBAAgB;EAK1D,cAAc,WAAW,gBAAgB;EAKzC,mBAAmB;EAKnB,aAAa,SAAS,QAAQ;EAK9B,WAAW;;iBAOI;EAEf;EAGA;EAGA;IACE;IACA;;;iBAQa;EAEf;IACE;IACA;IACA;;EAIF;IACE;IACA;;EAIF;IACE;IACA;IACA;;EAIF;IACE;IACA;IACA;IACA;;EAIF;IACE;IACA;IACA;IACA;IACA;;;iBAQa;EAEf;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;IACE;IACA;IACA;IACA;IACA;;;iBAQa;EAEf;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;;iBAOe;EACf;EACA;EACA;EACA;EACA;EAEA;;iBAGe;EACf;EACA;EACA;EACA;EACA,YAAY;EACZ;EACA;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/beacon-types/index.ts"],"mappings":";YAOY;YACA,YAAY,gBAAgB;GAAiB,cAAc;;YAC3D,kBAAkB;YAClB,kBAAkB;YAClB,mBAAmB,eAAe;YAClC,gBAAgB,sBAAsB;YACtC;wBA4KI,iBAAiB,iBAAiB,SAAS;iBA+C1C,+BAA+B;EAC9C;EACA;EACA;EACA;EACA;;iBAGe,wCAAwC;EACvD,aAA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e;EACf;EACA;EACA;EACA;EACA,YAAY;EACZ;EACA;EACA,QAAQ;;iBAGO;EACf;EACA;EACA;EACA;EACA;;YAGU;iBAEK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU;iBAUK;EACf;EACA;EACA;EACA;EACA;;YAOU;YACA;YAWA;YAQA;iBAEK;EACf;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,WAAW;EACX;;YAGU;YAUA;iBAEK;EACf;EACA;EACA;EACA;EACA;EACA,cAAc;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;;iBAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;;EAEF;IACE;IACA;;;iBAIa;EACf;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;;iBAGe;EACf;IACE;IACA;IACA;;EAEF;IACE;IACA;;EAEF;IACE;IACA;IACA;IACA;;EAEF;;iBAGe;EACf;EACA;EACA;EACA;EACA,gBAAgB;EAChB;EACA;EACA;;YAGU;YAWA;iBAEK;EACf,MAAM;EACN,OAAO;EACP,UAAU;EACV;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAWA;;iBAOe;EACf;EACA;EACA;;YAGU;iBAEK;EACf;EACA;EACA;EACA;EACA;;iBAOe;EACf;EACA;EACA;EACA;EACA;;iBAGe;EACf;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA,QAAQ;;iBAUO;EACf;EACA;EACA;EACA;;iBAIe;EAOf;EAKA;EAEA;IAAY;IAAe;;EAE3B;;iBAGe;EACf;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;EAEA;EAEA;EAEA;EAIA,YAAY;EACZ;EACA;EACA;;iBAGe;EAEf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EAGA;EACA;GAGC;;YAGS;wBAaI,mBAAmB,iBAAiB;wBAWpC,0BAA0B,iBAAiB;wBAgC3C,uBAAuB,iBAAiB;wBA6BxC,yBAAyB,iBAAiB;wBA8C1C,mBAAmB,iBAAiB;wBAkBpC,iBAAiB,iBAAiB;wBAclC,sBAAsB,iBAAiB;wBAcvC,mBAAmB,iBAAiB;qBAUvC;gBAAA;;qBAIA;gBAAA;;wBAIG,wBAAwB,iBAAiB;wBAiCzC,kBACd,gBACA,UAAU,2BACT;qBA6HkB,6BAA6B;EACpC,YAAA,QAAQ;EACpB,QAAQ,mBAAmB,OAAO,gBAAgB;EAClD,WAAW,mBAAmB,YAAY,gBAAgB;EAC1D,cAAc,WAAW,gBAAgB;EACzC,mBAAmB;EACnB,aAAa,SAAS,QAAQ;EAC9B,WAAW;;qBAQA;qBAEA;qBACA;qBAEA;qBAEA;wBAOG,mBACd;EAAY;EAAmB,QAAQ,cAAc;GACrD,OAAO,GAAG,oBAAoB;wBAWhB,mBAAmB;qBAoBtB;iBAEI;EACf;EACA;;iBAGe;EACf,UAAU;EACV;EACA;EACA;EACA;;wBAGc,mBAAmB,iBAAiB"}
|
|
@@ -209,12 +209,14 @@ export interface TransportOptions {
|
|
|
209
209
|
publicJwk?: EcPublicJwk;
|
|
210
210
|
deviceId?: string;
|
|
211
211
|
handoffToken?: string;
|
|
212
|
+
batch?: QueuedBatchIdentity;
|
|
212
213
|
}
|
|
213
214
|
export interface TransportResponse {
|
|
214
215
|
success: boolean;
|
|
215
216
|
timestamp: number;
|
|
216
217
|
batchId?: string;
|
|
217
218
|
error?: string;
|
|
219
|
+
queued?: boolean;
|
|
218
220
|
}
|
|
219
221
|
export type TransportState = 'idle' | 'sending' | 'offline' | 'paused' | 'error';
|
|
220
222
|
export interface TransportMetrics {
|
|
@@ -228,6 +230,9 @@ export interface TransportMetrics {
|
|
|
228
230
|
averageLatency?: number;
|
|
229
231
|
lastSuccessTimestamp?: number;
|
|
230
232
|
lastErrorTimestamp?: number;
|
|
233
|
+
eventsEvicted?: number;
|
|
234
|
+
eventsExpired?: number;
|
|
235
|
+
entriesCorrupt?: number;
|
|
231
236
|
}
|
|
232
237
|
export type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
|
|
233
238
|
export interface NetworkInfo {
|
|
@@ -389,6 +394,13 @@ export interface RetryStrategy {
|
|
|
389
394
|
factor: number;
|
|
390
395
|
jitter: boolean;
|
|
391
396
|
}
|
|
397
|
+
export interface QueuedBatchIdentity {
|
|
398
|
+
batchId: string;
|
|
399
|
+
sessionId: string;
|
|
400
|
+
timestamp: number;
|
|
401
|
+
projectId?: string;
|
|
402
|
+
handoffToken?: string;
|
|
403
|
+
}
|
|
392
404
|
export interface OfflineQueueEntry {
|
|
393
405
|
id: string;
|
|
394
406
|
events: BeaconEvent[];
|
|
@@ -396,6 +408,7 @@ export interface OfflineQueueEntry {
|
|
|
396
408
|
expiresAt: number;
|
|
397
409
|
retryCount: number;
|
|
398
410
|
size: number;
|
|
411
|
+
batch?: QueuedBatchIdentity;
|
|
399
412
|
}
|
|
400
413
|
export interface EcPublicJwk {
|
|
401
414
|
kty: 'EC';
|
|
@@ -424,6 +437,9 @@ export interface BeaconBatch {
|
|
|
424
437
|
nonce?: string;
|
|
425
438
|
nonceEcho?: boolean;
|
|
426
439
|
publicJwk?: EcPublicJwk;
|
|
440
|
+
queueEvictions?: number;
|
|
441
|
+
queueExpirations?: number;
|
|
442
|
+
queueCorruptions?: number;
|
|
427
443
|
}
|
|
428
444
|
export interface BeaconCollectorData {
|
|
429
445
|
userAgent?: string;
|
|
@@ -477,7 +493,12 @@ export declare const BEACON_MAX_EVENTS_PER_BATCH = 100;
|
|
|
477
493
|
export declare const SESSION_IDLE_GAP_MAX_MS = 21600000;
|
|
478
494
|
export declare const BEACON_MAX_BATCH_ID_LENGTH = 255;
|
|
479
495
|
export declare const BEACON_ORIGIN_CONTRACT_VERSION = 1;
|
|
480
|
-
export declare const BEACON_ORIGIN_CAPABILITIES: readonly ["batch-replay-v1", "receipt-status-v1", "receipt-posture-v1"];
|
|
496
|
+
export declare const BEACON_ORIGIN_CAPABILITIES: readonly ["batch-replay-v1", "receipt-status-v1", "receipt-posture-v1", "batch-identity-digest-v1"];
|
|
497
|
+
export declare function withAdoptedSession<B extends {
|
|
498
|
+
sessionId: string;
|
|
499
|
+
events: ReadonlyArray<Record<string, unknown>>;
|
|
500
|
+
}>(batch: B, sessionId: string): B;
|
|
501
|
+
export declare function beaconBodyIdentity(body: object): string;
|
|
481
502
|
export declare const POSTURE_TTL_SECONDS = 120;
|
|
482
503
|
export interface CachedPosture {
|
|
483
504
|
token: string;
|
|
@@ -486,6 +507,7 @@ export interface CachedPosture {
|
|
|
486
507
|
export interface PostureAnswer {
|
|
487
508
|
posture?: CachedPosture;
|
|
488
509
|
postureStatus?: string;
|
|
510
|
+
postureReason?: string;
|
|
489
511
|
sessionId?: string;
|
|
490
512
|
answeredAtMs?: number;
|
|
491
513
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/beacon-types/index.ts"],"mappings":";YAOY;YACA,YAAY,gBAAgB;GAAiB,cAAc;;YAC3D,kBAAkB;YAClB,kBAAkB;YAClB,mBAAmB,eAAe;YAClC,gBAAgB,sBAAsB;YACtC;wBA4KI,iBAAiB,iBAAiB,SAAS;iBA+C1C,+BAA+B;EAC9C;EACA;EACA;EACA;EACA;;iBAGe,wCAAwC;EACvD,aAAa;EACb,gBAAgB;EAChB,mBAAmB;EACnB;EACA;EACA;EACA;;iBAGe,iCAAiC;EAChD;EACA;IACE;;;iBAIa;EACf,gBAAgB;EAChB,aAAa;;iBAGE,+BAA+B;EAC9C;IACE,aACE,cACA;MACE,mBAAmB;MAC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A;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;IACE;IACA;IACA;IACA;IACA;;;iBAQa;EAEf;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;;iBAOe;EACf;EACA;EACA;EACA;EACA;EAEA;;iBAGe;EACf;EACA;EACA;EACA;EACA,YAAY;EACZ;EACA;EACA,QAAQ;;iBAGO;EACf;EACA;EACA;EACA;EACA;;YAGU;iBAEK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU;iBAUK;EACf;EACA;EACA;EACA;EACA;;YAOU;YACA;YAWA;YAQA;iBAEK;EACf;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,WAAW;EACX;;YAGU;YAUA;iBAEK;EACf;EACA;EACA;EACA;EACA;EACA,cAAc;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;;iBAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;;EAEF;IACE;IACA;;;iBAIa;EACf;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;;iBAGe;EACf;IACE;IACA;IACA;;EAEF;IACE;IACA;;EAEF;IACE;IACA;IACA;IACA;;EAEF;;iBAGe;EACf;EACA;EACA;EACA;EACA,gBAAgB;EAChB;EACA;EACA;;YAGU;YAWA;iBAEK;EACf,MAAM;EACN,OAAO;EACP,UAAU;EACV;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAWA;;iBAOe;EACf;EACA;EACA;;YAGU;iBAEK;EACf;EACA;EACA;EACA;EACA;;iBAOe;EACf;EACA;EACA;EACA;EACA;;iBAGe;EACf;EACA,QAAQ;EACR;EACA;EACA;EACA;E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