@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.
Files changed (224) hide show
  1. package/CHANGELOG.md +122 -9
  2. package/README.md +24 -7
  3. package/dist/beacon-nonce/index.d.mts +1 -0
  4. package/dist/beacon-nonce/index.d.mts.map +1 -1
  5. package/dist/beacon-nonce/index.d.ts +1 -0
  6. package/dist/beacon-nonce/index.d.ts.map +1 -1
  7. package/dist/beacon-nonce/index.js +9 -3
  8. package/dist/beacon-nonce/index.mjs +9 -4
  9. package/dist/beacon-nonce/index.mjs.map +1 -1
  10. package/dist/beacon-types/index.d.mts +23 -1
  11. package/dist/beacon-types/index.d.mts.map +1 -1
  12. package/dist/beacon-types/index.d.ts +23 -1
  13. package/dist/beacon-types/index.d.ts.map +1 -1
  14. package/dist/beacon-types/index.js +49 -4
  15. package/dist/beacon-types/index.mjs +47 -4
  16. package/dist/beacon-types/index.mjs.map +1 -1
  17. package/dist/{browser-posture-BLhw-MON.d.mts → browser-posture-5fPrsxx7.d.mts} +6 -6
  18. package/dist/{browser-posture-BLhw-MON.d.mts.map → browser-posture-5fPrsxx7.d.mts.map} +1 -1
  19. package/dist/{browser-posture-B8YiPa5c.d.ts → browser-posture-CCR1kh5e.d.ts} +6 -6
  20. package/dist/{browser-posture-B8YiPa5c.d.ts.map → browser-posture-CCR1kh5e.d.ts.map} +1 -1
  21. package/dist/browser-posture-proof.d.mts +16 -2
  22. package/dist/browser-posture-proof.d.mts.map +1 -1
  23. package/dist/browser-posture-proof.d.ts +16 -2
  24. package/dist/browser-posture-proof.d.ts.map +1 -1
  25. package/dist/browser-posture-proof.js +73 -17
  26. package/dist/browser-posture-proof.mjs +71 -17
  27. package/dist/browser-posture-proof.mjs.map +1 -1
  28. package/dist/browser-posture.d.mts +1 -1
  29. package/dist/browser-posture.d.ts +1 -1
  30. package/dist/browser-posture.js +6 -5
  31. package/dist/browser-posture.mjs +4 -3
  32. package/dist/browser-posture.mjs.map +1 -1
  33. package/dist/browser.d.mts +25 -4
  34. package/dist/browser.d.mts.map +1 -1
  35. package/dist/browser.d.ts +25 -4
  36. package/dist/browser.d.ts.map +1 -1
  37. package/dist/browser.js +1 -1
  38. package/dist/browser.mjs +1 -1
  39. package/dist/browser.mjs.map +1 -1
  40. package/dist/canonical-signer/index.js +30 -28
  41. package/dist/canonical-signer/index.mjs +31 -1
  42. package/dist/canonical-signer/index.mjs.map +1 -1
  43. package/dist/clearance.d.mts +1 -1
  44. package/dist/clearance.d.ts +1 -1
  45. package/dist/clearance.js +2 -2
  46. package/dist/clearance.mjs +2 -2
  47. package/dist/client-ip-B7w-uHfS.d.mts +55 -0
  48. package/dist/client-ip-B7w-uHfS.d.mts.map +1 -0
  49. package/dist/client-ip-B7w-uHfS.d.ts +55 -0
  50. package/dist/client-ip-B7w-uHfS.d.ts.map +1 -0
  51. package/dist/{client-ip-CW6pRyLf.js → client-ip-B8wFzJ5f.js} +117 -7
  52. package/dist/{client-ip-B2Xeo-GK.mjs → client-ip-DIJyr6px.mjs} +113 -9
  53. package/dist/client-ip-DIJyr6px.mjs.map +1 -0
  54. package/dist/client-ip.d.mts +2 -2
  55. package/dist/client-ip.d.ts +2 -2
  56. package/dist/client-ip.js +3 -2
  57. package/dist/client-ip.mjs +2 -2
  58. package/dist/detection-reason-mapping-B9RSkOs8.js +277 -0
  59. package/dist/detection-reason-mapping-BGymWIPl.mjs +249 -0
  60. package/dist/detection-reason-mapping-BGymWIPl.mjs.map +1 -0
  61. package/dist/detection-reason-mapping-CQexNvR7.d.mts +52 -0
  62. package/dist/detection-reason-mapping-CQexNvR7.d.mts.map +1 -0
  63. package/dist/detection-reason-mapping-CQexNvR7.d.ts +52 -0
  64. package/dist/detection-reason-mapping-CQexNvR7.d.ts.map +1 -0
  65. package/dist/engine-enforcing-AYEcgNsb.js +39 -0
  66. package/dist/engine-enforcing-B5eNfCpG.mjs +29 -0
  67. package/dist/engine-enforcing-B5eNfCpG.mjs.map +1 -0
  68. package/dist/engine-enforcing-DiOclGqf.d.mts +11 -0
  69. package/dist/engine-enforcing-DiOclGqf.d.mts.map +1 -0
  70. package/dist/engine-enforcing-DiOclGqf.d.ts +11 -0
  71. package/dist/engine-enforcing-DiOclGqf.d.ts.map +1 -0
  72. package/dist/engine-info.d.mts +2 -0
  73. package/dist/engine-info.d.ts +2 -0
  74. package/dist/engine-info.js +4 -0
  75. package/dist/engine-info.mjs +3 -0
  76. package/dist/errors/index.d.mts +5 -0
  77. package/dist/errors/index.d.mts.map +1 -1
  78. package/dist/errors/index.d.ts +5 -0
  79. package/dist/errors/index.d.ts.map +1 -1
  80. package/dist/errors/index.js +23 -4
  81. package/dist/errors/index.mjs +23 -4
  82. package/dist/errors/index.mjs.map +1 -1
  83. package/dist/{external-B7WI9FyQ.d.ts → external-m3Kmafwj.d.mts} +2 -2
  84. package/dist/{external-B7WI9FyQ.d.mts.map → external-m3Kmafwj.d.mts.map} +1 -1
  85. package/dist/{external-B7WI9FyQ.d.mts → external-m3Kmafwj.d.ts} +2 -2
  86. package/dist/{external-B7WI9FyQ.d.ts.map → external-m3Kmafwj.d.ts.map} +1 -1
  87. package/dist/fetcher-CivUCbhL.d.ts +44 -0
  88. package/dist/fetcher-CivUCbhL.d.ts.map +1 -0
  89. package/dist/fetcher-cXQsbm6s.d.mts +44 -0
  90. package/dist/fetcher-cXQsbm6s.d.mts.map +1 -0
  91. package/dist/gateway-client-ip.d.mts +1 -1
  92. package/dist/gateway-client-ip.d.ts +1 -1
  93. package/dist/gateway-client-ip.js +2 -2
  94. package/dist/gateway-client-ip.mjs +2 -2
  95. package/dist/host-adapter/index.d.mts +2 -2
  96. package/dist/host-adapter/index.d.ts +2 -2
  97. package/dist/host-adapter/index.js +2 -1
  98. package/dist/host-adapter/index.mjs +2 -2
  99. package/dist/{host-adapter-CwW9YB0U.js → host-adapter-0F8EpbD6.js} +59 -0
  100. package/dist/{host-adapter-C-4IxmqM.mjs → host-adapter-DHyISsIf.mjs} +55 -2
  101. package/dist/{host-adapter-C-4IxmqM.mjs.map → host-adapter-DHyISsIf.mjs.map} +1 -1
  102. package/dist/index-B3cHxr3O.d.mts +156 -0
  103. package/dist/index-B3cHxr3O.d.mts.map +1 -0
  104. package/dist/index-CXbOY7gB.d.ts +156 -0
  105. package/dist/index-CXbOY7gB.d.ts.map +1 -0
  106. package/dist/index.d.mts +8331 -12630
  107. package/dist/index.d.mts.map +1 -1
  108. package/dist/index.d.ts +8331 -12630
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +2515 -6663
  111. package/dist/index.mjs +2438 -6371
  112. package/dist/index.mjs.map +1 -1
  113. package/dist/kya-http.d.mts +2 -2
  114. package/dist/kya-http.d.ts +2 -2
  115. package/dist/kya-http.js +9 -1
  116. package/dist/kya-http.mjs +3 -2
  117. package/dist/mcpi/dashboard-config/index.d.mts.map +1 -1
  118. package/dist/mcpi/dashboard-config/index.d.ts.map +1 -1
  119. package/dist/mcpi/status-list/index.d.mts +72 -0
  120. package/dist/mcpi/status-list/index.d.mts.map +1 -0
  121. package/dist/mcpi/status-list/index.d.ts +72 -0
  122. package/dist/mcpi/status-list/index.d.ts.map +1 -0
  123. package/dist/mcpi/status-list/index.js +703 -0
  124. package/dist/mcpi/status-list/index.mjs +684 -0
  125. package/dist/mcpi/status-list/index.mjs.map +1 -0
  126. package/dist/patterns-B2r7M9wR.js +243 -0
  127. package/dist/patterns-B7dQoeE3.mjs +173 -0
  128. package/dist/patterns-B7dQoeE3.mjs.map +1 -0
  129. package/dist/patterns-Bp40cwh2.d.mts +110 -0
  130. package/dist/patterns-Bp40cwh2.d.mts.map +1 -0
  131. package/dist/patterns-Bp40cwh2.d.ts +110 -0
  132. package/dist/patterns-Bp40cwh2.d.ts.map +1 -0
  133. package/dist/patterns.d.mts +2 -0
  134. package/dist/patterns.d.ts +2 -0
  135. package/dist/patterns.js +15 -0
  136. package/dist/patterns.mjs +3 -0
  137. package/dist/policy/enforcement.d.mts +3 -2
  138. package/dist/policy/enforcement.d.ts +3 -2
  139. package/dist/policy/enforcement.js +8 -2
  140. package/dist/policy/enforcement.mjs +3 -2
  141. package/dist/policy/fetcher.d.mts +2 -0
  142. package/dist/policy/fetcher.d.ts +2 -0
  143. package/dist/policy/fetcher.js +240 -0
  144. package/dist/policy/fetcher.mjs +238 -0
  145. package/dist/policy/fetcher.mjs.map +1 -0
  146. package/dist/policy/schemas.d.mts +3 -0
  147. package/dist/policy/schemas.d.ts +3 -0
  148. package/dist/policy/schemas.js +27 -0
  149. package/dist/policy/schemas.mjs +4 -0
  150. package/dist/{posture-origins-Ba83O0cD.mjs → posture-origins-Ci6k4Zh1.js} +24 -173
  151. package/dist/{posture-origins-CdVOdiMT.js → posture-origins-DGyS4Vuk.mjs} +2 -267
  152. package/dist/posture-origins-DGyS4Vuk.mjs.map +1 -0
  153. package/dist/{project-verification-key-BccT12tQ.js → project-verification-key-B-L3D2nC.js} +1 -1
  154. package/dist/{project-verification-key-66N4edKn.mjs → project-verification-key-CWXdu3-n.mjs} +2 -2
  155. package/dist/{project-verification-key-66N4edKn.mjs.map → project-verification-key-CWXdu3-n.mjs.map} +1 -1
  156. package/dist/provider-registry.d.mts +2 -0
  157. package/dist/provider-registry.d.ts +2 -0
  158. package/dist/provider-registry.js +51 -0
  159. package/dist/provider-registry.mjs +3 -0
  160. package/dist/reason-codes.d.mts +2 -0
  161. package/dist/reason-codes.d.ts +2 -0
  162. package/dist/reason-codes.js +8 -0
  163. package/dist/reason-codes.mjs +3 -0
  164. package/dist/{registered-sid-hUl-bvM5.mjs → registered-sid-26hNxp6t.mjs} +11 -2
  165. package/dist/registered-sid-26hNxp6t.mjs.map +1 -0
  166. package/dist/registered-sid-D6KCaT1E.d.mts +33 -0
  167. package/dist/registered-sid-D6KCaT1E.d.mts.map +1 -0
  168. package/dist/registered-sid-D6KCaT1E.d.ts +33 -0
  169. package/dist/registered-sid-D6KCaT1E.d.ts.map +1 -0
  170. package/dist/{registered-sid-eLCNZvIF.js → registered-sid-DVGTSH0L.js} +15 -0
  171. package/dist/ruleset-hash-Cmv8MSO5.js +34 -0
  172. package/dist/ruleset-hash-IRN5eI9H.d.mts +5 -0
  173. package/dist/ruleset-hash-IRN5eI9H.d.mts.map +1 -0
  174. package/dist/ruleset-hash-IRN5eI9H.d.ts +5 -0
  175. package/dist/ruleset-hash-IRN5eI9H.d.ts.map +1 -0
  176. package/dist/ruleset-hash-QQIaLuPi.mjs +30 -0
  177. package/dist/ruleset-hash-QQIaLuPi.mjs.map +1 -0
  178. package/dist/{index-HaqfPtaL.d.ts → schemas-02CI7jgm.d.mts} +11 -183
  179. package/dist/schemas-02CI7jgm.d.mts.map +1 -0
  180. package/dist/{schemas-YhagYDx_.js → schemas-BlScS1it.js} +0 -20
  181. package/dist/{index-B7rTovHa.d.mts → schemas-C_3C72SR.d.ts} +11 -183
  182. package/dist/schemas-C_3C72SR.d.ts.map +1 -0
  183. package/dist/schemas-Cm4C4Z5G.js +703 -0
  184. package/dist/schemas-DPIT8usF.mjs +525 -0
  185. package/dist/schemas-DPIT8usF.mjs.map +1 -0
  186. package/dist/{schemas-7qodsG-Z.mjs → schemas-IHAhH3gV.mjs} +2 -16
  187. package/dist/schemas-IHAhH3gV.mjs.map +1 -0
  188. package/dist/{step-up-COlmWJN8.mjs → step-up-BK0oBi11.mjs} +91 -41
  189. package/dist/step-up-BK0oBi11.mjs.map +1 -0
  190. package/dist/{step-up-C2d8C20x.js → step-up-Bp8RAQwv.js} +117 -55
  191. package/dist/{step-up-BjP--hG-.d.mts → step-up-Bz12gYKT.d.mts} +28 -12
  192. package/dist/step-up-Bz12gYKT.d.mts.map +1 -0
  193. package/dist/{step-up-BjP--hG-.d.ts → step-up-Bz12gYKT.d.ts} +28 -12
  194. package/dist/step-up-Bz12gYKT.d.ts.map +1 -0
  195. package/dist/test-fixtures/index.d.mts +4 -4
  196. package/dist/test-fixtures/index.d.mts.map +1 -1
  197. package/dist/test-fixtures/index.d.ts +4 -4
  198. package/dist/test-fixtures/index.d.ts.map +1 -1
  199. package/dist/test-fixtures/index.js +4 -4
  200. package/dist/test-fixtures/index.mjs +4 -4
  201. package/dist/test-fixtures/index.mjs.map +1 -1
  202. package/dist/verification-BAw9N8Pt.js +181 -0
  203. package/dist/verification-Cvvv86TT.mjs +123 -0
  204. package/dist/verification-Cvvv86TT.mjs.map +1 -0
  205. package/fixtures/client-ip-resolution.n01.json +101 -0
  206. package/fixtures/reviewer-grant-revocation.v1.json +53 -81
  207. package/package.json +37 -2
  208. package/dist/client-ip-B2Xeo-GK.mjs.map +0 -1
  209. package/dist/client-ip-DFamiNoz.d.mts +0 -34
  210. package/dist/client-ip-DFamiNoz.d.mts.map +0 -1
  211. package/dist/client-ip-DFamiNoz.d.ts +0 -34
  212. package/dist/client-ip-DFamiNoz.d.ts.map +0 -1
  213. package/dist/index-B7rTovHa.d.mts.map +0 -1
  214. package/dist/index-HaqfPtaL.d.ts.map +0 -1
  215. package/dist/posture-origins-Ba83O0cD.mjs.map +0 -1
  216. package/dist/registered-sid-D3g-gZQF.d.mts +0 -11
  217. package/dist/registered-sid-D3g-gZQF.d.mts.map +0 -1
  218. package/dist/registered-sid-D3g-gZQF.d.ts +0 -11
  219. package/dist/registered-sid-D3g-gZQF.d.ts.map +0 -1
  220. package/dist/registered-sid-hUl-bvM5.mjs.map +0 -1
  221. package/dist/schemas-7qodsG-Z.mjs.map +0 -1
  222. package/dist/step-up-BjP--hG-.d.mts.map +0 -1
  223. package/dist/step-up-BjP--hG-.d.ts.map +0 -1
  224. package/dist/step-up-COlmWJN8.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/test-fixtures/vault-wire-contract.ts","../../src/test-fixtures/mcpi-delegation-fixture.ts","../../src/test-fixtures/fetcher-200-predicate.ts","../../src/mcpi/delegation-verdict.ts","../../src/test-fixtures/verdict-evidence-fixture.ts"],"sourcesContent":["/**\n * Shared test fixture for the #1532 gateway ↔ vault wire contract.\n *\n * **DO NOT IMPORT FROM PRODUCTION CODE.** This file is exposed only via\n * the `@kya-os/checkpoint-shared/test-fixtures` subpath export so\n * production bundles that import from the root package entry point\n * can't reach it — the tree-shaker has no path to these symbols unless\n * a caller explicitly imports from the test-fixtures subpath.\n *\n * ## Purpose\n *\n * #1532 spans two services that must agree byte-for-byte on:\n *\n * 1. The shape of the JWT assertion the gateway signs\n * 2. The HTTP request body the gateway POSTs to the vault endpoint\n * 3. The claims the vault endpoint extracts after verifying the JWT\n *\n * This fixture pins a known-good input/output pair that both sides'\n * unit tests import. If either side's implementation drifts from the\n * contract (wrong field order, wrong base64url encoding, wrong key\n * derivation, etc), the test against this fixture fails loudly without\n * requiring a live end-to-end test.\n *\n * The fixture values below were generated ONCE by running the gateway\n * side's `signAssertion` function against a deterministic seed + the\n * canonical claims. Ed25519 is deterministic per RFC 8032 §5.1.6, so\n * the same inputs ALWAYS produce the same signature — which is what\n * lets us commit `expectedJwt` as a string literal and assert equality\n * across both sides' test runs.\n *\n * ## Test keypair (NOT PRODUCTION)\n *\n * The private key below is 32 bytes of `0x01` — the simplest possible\n * deterministic seed. It is NOT a real private key and must NEVER be\n * used to sign any real vault assertion. Its only purpose is to produce\n * reproducible fixture bytes that both engineers can check against.\n *\n * The corresponding public key was derived via Node's\n * `createPublicKey(privateKey)` and is included here for Engineer 2's\n * vault-side verification tests — vault tests don't need to reconstruct\n * the private half, only to verify signatures against this public key.\n *\n * ## Claim fixture\n *\n * The `canonicalPayload` matches the wire contract §2.2 sample verbatim:\n * eight claims in the exact order `iss, projectId, userDid, toolName,\n * sessionId, nonce, iat, exp`. Field order is load-bearing because\n * `JSON.stringify` preserves insertion order in V8 and the resulting\n * byte sequence is what Ed25519 signs over — reordering would produce\n * a different signature, breaking cross-service determinism.\n *\n * The `iat`/`exp` timestamps are frozen at `1712975940` / `1712976000`\n * (60-second window ending 2024-04-13T01:20:00Z-ish). Tests that run\n * against this fixture must either (a) not validate `exp` against wall\n * clock time, or (b) use `vi.useFakeTimers({ now: 1712975940000 })` to\n * freeze the clock inside the fixture window.\n */\n\n/**\n * Test keypair for the wire-contract fixture. Ed25519 private seed is\n * 32 bytes of `0x01`; public key is derived from it.\n *\n * **DO NOT USE IN PRODUCTION.**\n */\nexport const VAULT_WIRE_CONTRACT_TEST_KEYPAIR = {\n /** 32 bytes of 0x01, base64-encoded. Load into the signer via `loadSigningKey`. */\n privateKeyBase64: 'AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=',\n /** Raw 32-byte Ed25519 public key derived from the private seed, base64-encoded. */\n publicKeyBase64: 'iojj3XQJ8ZX9UtstPLpdcspnCb8dlBIb83SIAbQPb1w=',\n} as const;\n\n/**\n * The canonical JWT header both sides expect. Wire contract §2.1:\n * `alg` is `EdDSA` (NOT `Ed25519` — common mistake), `typ` is `JWT`,\n * `crv` is included for disambiguation per RFC 8037 §3.1.\n */\nexport const VAULT_WIRE_CONTRACT_EXPECTED_HEADER = {\n alg: 'EdDSA',\n typ: 'JWT',\n crv: 'Ed25519',\n} as const;\n\n/**\n * The canonical payload both sides assert against. Wire contract §2.2\n * order is load-bearing — rearranging these fields will produce a\n * different `expectedJwt` because `JSON.stringify` preserves insertion\n * order.\n */\nexport const VAULT_WIRE_CONTRACT_CANONICAL_PAYLOAD = {\n iss: 'did:web:gateway.knowthat.ai',\n projectId: '00000000-0000-0000-0000-000000000001',\n userDid: 'alice@example.test',\n toolName: 'create_issue',\n sessionId: 'gateway-oauth-test-sess-01',\n nonce: '0123456789abcdef',\n iat: 1712975940,\n exp: 1712976000,\n} as const;\n\n/**\n * The deterministic JWT produced by signing\n * {@link VAULT_WIRE_CONTRACT_CANONICAL_PAYLOAD} with the private half of\n * {@link VAULT_WIRE_CONTRACT_TEST_KEYPAIR}, via the gateway-side\n * `signAssertion` helper.\n *\n * Generated ONCE by running:\n *\n * ```\n * pnpm --filter @kya-os/checkpoint-gateway exec tsx -e \"...\"\n * ```\n *\n * and committed as a string literal. DO NOT regenerate this value\n * without understanding that both sides of the contract will need to\n * re-validate. If your implementation produces a different JWT for the\n * same canonical inputs, the bug is in YOUR code, not the fixture.\n *\n * Ed25519's deterministic signing property (RFC 8032 §5.1.6) is what\n * makes this string stable across runs, machines, and invocations.\n */\nexport const VAULT_WIRE_CONTRACT_EXPECTED_JWT =\n 'eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCIsImNydiI6IkVkMjU1MTkifQ.eyJpc3MiOiJkaWQ6d2ViOmdhdGV3YXkua25vd3RoYXQuYWkiLCJwcm9qZWN0SWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDEiLCJ1c2VyRGlkIjoiYWxpY2VAZXhhbXBsZS50ZXN0IiwidG9vbE5hbWUiOiJjcmVhdGVfaXNzdWUiLCJzZXNzaW9uSWQiOiJnYXRld2F5LW9hdXRoLXRlc3Qtc2Vzcy0wMSIsIm5vbmNlIjoiMDEyMzQ1Njc4OWFiY2RlZiIsImlhdCI6MTcxMjk3NTk0MCwiZXhwIjoxNzEyOTc2MDAwfQ.i-7vlvhLiohx6Qg0pXjfmllaDoZ_Fiu8KYW7vovHlQOPw9gsDrOECtM5qymv8bTf__hZKQeU8PyxBHtDusTDAg';\n\n/**\n * The expected HTTP request body the gateway sends to the vault\n * endpoint for the canonical payload. Wire contract §2.4 — all 5\n * fields are required, `assertion` is the full JWT from\n * {@link VAULT_WIRE_CONTRACT_EXPECTED_JWT}, and `userDid` MUST match\n * the assertion's `userDid` claim (the vault side rejects mismatches\n * with a 403).\n */\nexport const VAULT_WIRE_CONTRACT_EXPECTED_REQUEST_BODY = {\n userDid: 'alice@example.test',\n envVarNames: ['GITHUB_TOKEN'],\n toolName: 'create_issue',\n sessionId: 'gateway-oauth-test-sess-01',\n assertion: VAULT_WIRE_CONTRACT_EXPECTED_JWT,\n} as const;\n\n/**\n * The canonical vault endpoint URL path for the fixture's projectId.\n * Both sides use this to verify their URL construction logic. Base URL\n * is NOT included — this is the path portion only.\n *\n * Path note: the gateway's vault endpoint lives under\n * `/api/v1/gateway/vault/...`, NOT `/api/v1/vault/...`. The unprefixed\n * `/api/v1/vault/{projectId}/resolve` path is owned by the #1299\n * (VAULT-5) KYA-OS worker flow, which uses `X-API-Key` auth and is\n * architecturally incompatible with #1532's Ed25519-only model per\n * #1542 Decision 1 = B. The gateway gets its own parallel namespace\n * under `/api/v1/gateway/vault/*` so the two flows can coexist\n * without the KYA-OS handler needing auth-branching logic.\n *\n * See the corrected wire contract §2.4 on issue #1532.\n */\nexport const VAULT_WIRE_CONTRACT_URL_PATH =\n '/api/v1/gateway/vault/00000000-0000-0000-0000-000000000001/resolve';\n","/**\n * Shared test fixture for #1531 gateway OAuth ↔ KYA-OS delegation credential contract.\n *\n * **DO NOT IMPORT FROM PRODUCTION CODE.** Exposed only via the\n * `@kya-os/checkpoint-shared/test-fixtures` subpath export.\n *\n * ## Purpose\n *\n * #1531 spans two services that must agree on the VC-JWT wire format:\n *\n * 1. Engineer 2's authorization server (Vercel) — issues the VC-JWT\n * 2. Engineer 1's gateway resolver (Fly) — verifies the VC-JWT\n *\n * This fixture pins a known-good VC-JWT that both sides' tests import.\n * If either side drifts from the contract, the test against this fixture\n * fails loudly.\n *\n * ## Test keypair (NOT PRODUCTION)\n *\n * Reuses the #1532 convention: private key is 32 bytes of `0x01`.\n * Ed25519 is deterministic (RFC 8032 §5.1.6), so same inputs always\n * produce the same signature — which is what makes the expected JWT\n * string stable across runs.\n *\n * ## VC-JWT structure\n *\n * The JWT follows the KYA-OS §6.2 DelegationCredential as W3C VC pattern:\n * - Header: { alg: \"EdDSA\", typ: \"JWT\", kid: \"<issuer-key-id>\" }\n * - Payload: { iss, sub, aud, iat, exp, vc: { ... W3C VC ... }, orgId, orgSlug, sessionId }\n * - vc.credentialSubject.delegation contains the KYA-OS delegation record\n * - vc.credentialStatus contains StatusList2021 revocation reference\n *\n * ## Clock note\n *\n * Timestamps are frozen at iat=1712975940 (April 2024). Tests that validate\n * expiry must use vi.useFakeTimers({ now: 1712975940000 }).\n */\n\n// ---------------------------------------------------------------------------\n// Test keypair (32 bytes of 0x01 — same convention as #1532 vault fixture)\n// ---------------------------------------------------------------------------\n\n/** Ed25519 test keypair. DO NOT USE IN PRODUCTION. */\nexport const MCPI_DELEGATION_TEST_KEYPAIR = {\n /** 32 bytes of 0x01, base64-encoded. */\n privateKeyBase64: 'AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=',\n /** Raw 32-byte Ed25519 public key derived from the private seed, base64-encoded. */\n publicKeyBase64: 'iojj3XQJ8ZX9UtstPLpdcspnCb8dlBIb83SIAbQPb1w=',\n} as const;\n\n// ---------------------------------------------------------------------------\n// Canonical constants\n// ---------------------------------------------------------------------------\n\n/** DID of the org issuer (signs the VC-JWT). */\nexport const MCPI_DELEGATION_ISSUER_DID = 'did:web:kya.vouched.id:orgs:test-org';\n\n/**\n * Key ID of the OAuth signing key in the DID document.\n *\n * DR-1 / E1-P1 moved delegation issuance from the gateway operational DID\n * to per-org issuer DIDs. The verifier resolves the org DID document and\n * looks up that org's `#key-1` method.\n */\nexport const MCPI_DELEGATION_ISSUER_KID = 'did:web:kya.vouched.id:orgs:test-org#key-1';\n\n/** DID of the test MCP client (agent). */\nexport const MCPI_DELEGATION_AGENT_DID = 'did:key:z6MkTestAgent123';\n\n/** DID of the authorizing user. */\nexport const MCPI_DELEGATION_USER_DID = 'did:key:z6MkTestUser456';\n\n/** StatusList2021 endpoint URL. */\nexport const MCPI_DELEGATION_STATUS_LIST_URL =\n 'https://kya.vouched.id/api/v1/gateway/oauth/status-list';\n\n/** Audience claim — the gateway's HTTPS origin. */\nexport const MCPI_DELEGATION_AUDIENCE = 'https://gateway.knowthat.ai';\n\n// ---------------------------------------------------------------------------\n// Canonical payload (decoded JWT claims)\n// ---------------------------------------------------------------------------\n\n/**\n * The canonical JWT payload. Field order is load-bearing because\n * JSON.stringify preserves insertion order and Ed25519 signs over\n * the resulting bytes.\n */\nexport const MCPI_DELEGATION_CANONICAL_PAYLOAD = {\n iss: 'did:web:kya.vouched.id:orgs:test-org',\n sub: 'did:key:z6MkTestAgent123',\n aud: 'https://gateway.knowthat.ai',\n iat: 1712975940,\n exp: 1712979540,\n vc: {\n // Pinned to the legacy `modelcontextprotocol-identity.io` host ON PURPOSE.\n // This array is signed over by MCPI_DELEGATION_EXPECTED_JWT (below) and must\n // byte-match it, and it must agree with the counterparty's pinned context in\n // xmcp-i (`packages/contracts/src/delegation/schemas.ts`). The live minter's\n // host migration (`vc-jwt.service.ts` → `schema.kya-os.org`) deliberately does\n // NOT move this vector — that requires re-signing both sides of the #1531\n // contract in lockstep. Do not \"fix\" this URL without regenerating the JWT.\n '@context': [\n 'https://www.w3.org/2018/credentials/v1',\n 'https://schema.modelcontextprotocol-identity.io/xmcp-i/credentials/delegation.v1.0.0.json',\n ],\n type: ['VerifiableCredential', 'DelegationCredential'],\n issuer: 'did:web:kya.vouched.id:orgs:test-org',\n issuanceDate: '2024-04-13T02:39:00.000Z',\n expirationDate: '2024-04-13T03:39:00.000Z',\n credentialSubject: {\n id: 'did:key:z6MkTestAgent123',\n delegation: {\n id: 'del-test-001',\n issuerDid: 'did:web:kya.vouched.id:orgs:test-org',\n subjectDid: 'did:key:z6MkTestAgent123',\n userDid: 'did:key:z6MkTestUser456',\n userIdentifier: 'alice@vouched.id',\n scopes: ['mcp'],\n constraints: {\n notBefore: 1712975940,\n notAfter: 1712979540,\n scopes: ['mcp'],\n audience: 'https://gateway.knowthat.ai',\n },\n status: 'active',\n },\n },\n credentialStatus: {\n id: 'https://kya.vouched.id/api/v1/gateway/oauth/status-list#42',\n type: 'StatusList2021Entry',\n statusPurpose: 'revocation',\n statusListIndex: '42',\n statusListCredential: 'https://kya.vouched.id/api/v1/gateway/oauth/status-list',\n },\n },\n orgId: '00000000-0000-0000-0000-000000000010',\n orgSlug: 'test-org',\n sessionId: '00000000-0000-0000-0000-000000000020',\n} as const;\n\n// ---------------------------------------------------------------------------\n// Canonical header\n// ---------------------------------------------------------------------------\n\nexport const MCPI_DELEGATION_EXPECTED_HEADER = {\n alg: 'EdDSA',\n typ: 'JWT',\n kid: 'did:web:kya.vouched.id:orgs:test-org#key-1',\n} as const;\n\n// ---------------------------------------------------------------------------\n// Expected VC-JWT (deterministic — Ed25519 + frozen claims)\n// ---------------------------------------------------------------------------\n\n/**\n * The deterministic VC-JWT produced by signing\n * {@link MCPI_DELEGATION_CANONICAL_PAYLOAD} with the private half of\n * {@link MCPI_DELEGATION_TEST_KEYPAIR}.\n *\n * Generated ONCE. DO NOT regenerate without understanding that both\n * sides of the #1531 contract will need to re-validate.\n *\n * Size: ~1.8KB — well within the 8KB HTTP header budget.\n */\nexport const MCPI_DELEGATION_EXPECTED_JWT =\n 'eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCIsImtpZCI6ImRpZDp3ZWI6a3lhLnZvdWNoZWQuaWQ6b3Jnczp0ZXN0LW9yZyNrZXktMSJ9.eyJpc3MiOiJkaWQ6d2ViOmt5YS52b3VjaGVkLmlkOm9yZ3M6dGVzdC1vcmciLCJzdWIiOiJkaWQ6a2V5Ono2TWtUZXN0QWdlbnQxMjMiLCJhdWQiOiJodHRwczovL2dhdGV3YXkua25vd3RoYXQuYWkiLCJpYXQiOjE3MTI5NzU5NDAsImV4cCI6MTcxMjk3OTU0MCwidmMiOnsiQGNvbnRleHQiOlsiaHR0cHM6Ly93d3cudzMub3JnLzIwMTgvY3JlZGVudGlhbHMvdjEiLCJodHRwczovL3NjaGVtYS5tb2RlbGNvbnRleHRwcm90b2NvbC1pZGVudGl0eS5pby94bWNwLWkvY3JlZGVudGlhbHMvZGVsZWdhdGlvbi52MS4wLjAuanNvbiJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiRGVsZWdhdGlvbkNyZWRlbnRpYWwiXSwiaXNzdWVyIjoiZGlkOndlYjpreWEudm91Y2hlZC5pZDpvcmdzOnRlc3Qtb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MDAwMDEwIiwib3JnU2x1ZyI6InRlc3Qtb3JnIiwic2Vzc2lvbklkIjoiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDIwIn0.KEF-cDuLUb-OTJHAXhK2A7VGWpGzdIRY0v4jK-0OXoPqKEadPOHAw1EaEl2V_1NeGyw69V3CRtKug_gx9ZIUBA';\n","/**\n * Shared selection-predicate vectors for the §8.1 fetcher-200 dual envelope.\n *\n * The `kya-http/challenge.delegation.fetcher-200.json` fixture freezes the\n * envelope BYTES; these vectors freeze the SELECTION — the decision of WHICH\n * envelope (body-readable 200 vs spec 401/422) a `negotiated`-mode PEP serves\n * for a given request. Because every PEP re-implements its own wiring (TS\n * shared impl here, plus .NET and the gateway worker), a single shared vector\n * set is the only thing that keeps the choice from drifting across them.\n *\n * The canonical TS predicate is `serveBodyReadable200` (host-adapter). Every\n * PEP MUST agree with these vectors. Selection is a cooperative-UX bridge,\n * NOT an access control: a non-cooperative caller simply gets the spec 401.\n */\n\n/** Detection class in its wire form, or `null` when detection is absent. */\nexport type FetcherPredicateDetectionClass =\n | 'human'\n | 'ai_agent'\n | 'bot'\n | 'incomplete_data'\n | null;\n\nexport interface FetcherEnvelopePredicateVector {\n /** Human-readable description of the case. */\n description: string;\n /** Request headers (lowercase keys), e.g. the `kya-accept-challenge` opt-in. */\n headers: Record<string, string>;\n /** The caller's detection class (wire form), or `null` if absent. */\n detectionClass: FetcherPredicateDetectionClass;\n /**\n * The engine's `isAgent` verdict for the caller. The transitional UA heuristic\n * fires ONLY when `isAgent` AND `detectionClass === 'ai_agent'` agree — matching\n * .NET `IsInteractiveAiAgent` (`IsAgent && DetectionClass.Type == AiAgent`) and the\n * gateway worker. A class/`isAgent` disagreement is treated as non-cooperative\n * (spec 401), so an `ai_agent` class with `isAgent: false` does NOT get the 200.\n */\n isAgent: boolean;\n /** Expected predicate result: `true` → body-readable 200; `false` → spec 401/422. */\n expected: boolean;\n}\n\n/**\n * The frozen cross-PEP predicate vectors. Keep additions semantic (a new\n * distinct case), never a re-statement of an existing one.\n */\nexport const FETCHER_200_PREDICATE_VECTORS: readonly FetcherEnvelopePredicateVector[] = [\n {\n description: 'opt-in header present, non-agent detection → 200 (header is the primary signal)',\n headers: { 'kya-accept-challenge': 'delegation' },\n detectionClass: 'human',\n isAgent: false,\n expected: true,\n },\n {\n description: 'opt-in header present, detection absent → 200',\n headers: { 'kya-accept-challenge': 'delegation' },\n detectionClass: null,\n isAgent: false,\n expected: true,\n },\n {\n description: 'detected ai_agent (isAgent agrees), no opt-in → 200 (transitional UA heuristic)',\n headers: {},\n detectionClass: 'ai_agent',\n isAgent: true,\n expected: true,\n },\n {\n description: 'Accept: text/html on a detected agent → 200 (Accept MUST NOT branch the body)',\n headers: { accept: 'text/markdown, text/html, */*' },\n detectionClass: 'ai_agent',\n isAgent: true,\n expected: true,\n },\n {\n description:\n 'ai_agent class but isAgent=false (signals disagree) → 401 (require both, matches .NET + worker)',\n headers: {},\n detectionClass: 'ai_agent',\n isAgent: false,\n expected: false,\n },\n {\n description: 'human, no opt-in → 401 (spec path)',\n headers: {},\n detectionClass: 'human',\n isAgent: false,\n expected: false,\n },\n {\n description: 'bot, no opt-in → 401 (non-cooperative / spoofer lands on spec path)',\n headers: {},\n detectionClass: 'bot',\n isAgent: false,\n expected: false,\n },\n {\n description: 'incomplete_data, no opt-in → 401',\n headers: {},\n detectionClass: 'incomplete_data',\n isAgent: false,\n expected: false,\n },\n {\n description: 'no signals at all → 401',\n headers: {},\n detectionClass: null,\n isAgent: false,\n expected: false,\n },\n {\n description: 'empty opt-in value is ignored, human → 401',\n headers: { 'kya-accept-challenge': '' },\n detectionClass: 'human',\n isAgent: false,\n expected: false,\n },\n];\n","/**\n * Common delegation-verdict shape (verifier/engine unification series).\n *\n * The `delegation` cross-runtime-parity track\n * (`tests/cross-runtime-parity/delegation/`) checks multiple independent\n * delegation-verify implementations — the Fly gateway (`apps/gateway/src/lib/\n * mcpi-auth-resolver.ts` + `dashboard-delegation-verifier.ts`, both engine-\n * backed as of PR6/PR7) and `rust/crates/kya-os-engine`'s `verify_delegation`\n * — against one canonical vector set. Every emitter normalizes its runtime's\n * result to this shape before writing `runtime-outputs/<name>.json`. Lives\n * under the package's main entrypoint (not `test-fixtures`) because the\n * parity-harness test imports it as production infrastructure;\n * `test-fixtures/delegation-verdict.ts` re-exports it for the existing\n * parity-harness imports.\n *\n * Deliberately verdict-only (`kind` + coarse `reason.kind`), not the full\n * delegation record: the gateway's audit extractions (`delegationId`,\n * `clientDid`, `orgId`, `accountableAdminDid`) are deterministic claim reads,\n * not verification decisions, so they don't belong in a cross-implementation\n * agreement check — their correctness is covered by the gateway's own unit\n * tests (`mcpi-auth-resolver.test.ts`, `dashboard-delegation-verifier.test.ts`),\n * which is their natural home. Keeping this shape to exactly what\n * `scripts/assert-cross-runtime-parity.ts` already matches on (`kind`,\n * `reason.kind`, `reason.kindStartsWith`, `oneOf`) means that script needs no\n * per-track special-casing.\n *\n * `reason.kind` is deliberately coarse — a structural reason CLASS, not a\n * fine-grained cause. Each runtime's native vocabulary is many-to-one mapped\n * onto this fixed set via `toCoarseReasonKind`:\n *\n * - `signature` — bad/absent cryptographic signature\n * - `claim` — any issuer / audience / subject / orgId / other claim or\n * authorization mismatch (including \"no identity material\n * presented at all\")\n * - `time` — expired OR not-yet-valid\n * - `revocation` — revoked, or status-unavailable (fail-closed)\n * - `scope` — delegation doesn't grant the requested scope\n * - `resolve` — DID / context could not be resolved\n *\n * This is the coarsest granularity both the gateway (whose own top-level\n * verifier already folds iss/aud/orgId/sub into one `claim_invalid` /\n * `claim_mismatch`) and the engine (whose `BlockReason` has no\n * audience/issuer/not-yet-valid-specific variants) can already express\n * without changing either side's production reason taxonomy. Fine-grained\n * reason parity is an observability nice-to-have, not a security property —\n * the gate's job is to catch security-relevant WHY-drift (a different\n * structural reason class, or accept-vs-reject), not whether both sides spell\n * a claim rejection the same way. If per-cause parity is ever wanted, extend\n * each runtime's own reason vocabulary deliberately on its own timeline —\n * never bundle it with this track's blocking gate.\n */\n\nexport type DelegationVerdictKind = 'Permit' | 'Block';\n\nexport type CoarseReasonKind = 'signature' | 'claim' | 'time' | 'revocation' | 'scope' | 'resolve';\n\nexport interface DelegationVerdictReason {\n kind: CoarseReasonKind;\n}\n\nexport interface DelegationVerdict {\n kind: DelegationVerdictKind;\n reason: DelegationVerdictReason | null;\n}\n\n/**\n * Every raw reason discriminator either runtime can natively emit for the\n * delegation path, mapped onto the coarse taxonomy above.\n *\n * Gateway (`McpiAuthErrorReason` in `mcpi-auth-resolver.ts`,\n * `DashboardVerifyFailure['reason']` in `dashboard-delegation-verifier.ts`):\n * snake_case. Engine (`BlockReason` in `rust/crates/kya-os-engine/src/types.rs`):\n * PascalCase variant names. Unrecognized input is a harness bug (an emitter\n * started producing a reason string neither side has ever emitted before) —\n * `toCoarseReasonKind` throws rather than silently defaulting, so a new raw\n * reason gets a deliberate classification instead of landing in the wrong\n * bucket unnoticed.\n */\nconst REASON_KIND_MAP: Record<string, CoarseReasonKind> = {\n // --- gateway: apps/gateway/src/lib/mcpi-auth-resolver.ts ---\n missing_bearer_token: 'claim',\n parse_error: 'claim',\n did_resolve_failed: 'resolve',\n signature_invalid: 'signature',\n audience_mismatch: 'claim',\n expired: 'time',\n not_yet_valid: 'time',\n revoked: 'revocation',\n delegation_inactive: 'revocation',\n missing_claim: 'claim',\n claim_invalid: 'claim',\n // --- gateway: apps/gateway/src/lib/dashboard-delegation-verifier.ts ---\n not_configured: 'claim',\n header_missing: 'claim',\n claim_mismatch: 'claim',\n malformed: 'claim',\n // --- engine-rust: rust/crates/kya-os-engine/src/types.rs BlockReason ---\n Revoked: 'revocation',\n InvalidSignature: 'signature',\n Unauthenticated: 'claim',\n Expired: 'time',\n OutOfScope: 'scope',\n};\n\n/** Map a runtime's native reason discriminator onto the coarse taxonomy. */\nexport function toCoarseReasonKind(rawReasonKind: string): CoarseReasonKind {\n const coarse = REASON_KIND_MAP[rawReasonKind];\n if (!coarse) {\n throw new Error(\n `toCoarseReasonKind: unrecognized raw reason kind ${JSON.stringify(rawReasonKind)} — ` +\n `add it to REASON_KIND_MAP in delegation-verdict.ts with a deliberate coarse classification`\n );\n }\n return coarse;\n}\n\n/** Build a `Permit` verdict. */\nexport function permitDelegationVerdict(): DelegationVerdict {\n return { kind: 'Permit', reason: null };\n}\n\n/** Build a `Block` verdict from a runtime-native reason discriminator. */\nexport function blockDelegationVerdict(rawReasonKind: string): DelegationVerdict {\n return { kind: 'Block', reason: { kind: toCoarseReasonKind(rawReasonKind) } };\n}\n","/**\n * Shared test fixture for P20 verdict-evidence tests (`buildVerdictEvidence`,\n * `reconstructConfidenceFromEvidence` — see `../core/verdict-evidence.ts`).\n *\n * **DO NOT IMPORT FROM PRODUCTION CODE.** Exposed only via the\n * `@kya-os/checkpoint-shared/test-fixtures` subpath export.\n *\n * ## Purpose\n *\n * Four independent test suites each need \"one signal, minimal defaults\" and\n * \"two independent signals whose Noisy-Or reconstruction is a known,\n * hand-verified number\" — checkpoint-shared's own unit tests, the\n * enforcement-metadata envelope tests, the activity-log read-side tests, and\n * the pixel-route persistence test. Before this fixture existed, all four\n * hardcoded the SAME two fixtures and the SAME derivation comment\n * independently — a change to one could silently drift from the others.\n * This is the one place that number is computed; every test imports it\n * rather than re-deriving it.\n *\n * ## The known reconstruction\n *\n * `TWO_SIGNAL_EVIDENCE_FIXTURE`'s Noisy-Or confidence, by hand — INCLUDING\n * the `UNCALIBRATED_NOISY_OR_PRIOR` (0.10) leak term every live verdict\n * folds in (bestbrian, PR #4747 review — the earlier version of this\n * fixture omitted it and asserted the wrong number, 94.2):\n *\n * 1 - (1 - 0.10) * (1 - 1.0*0.9) * (1 - 0.6*0.7)\n * = 1 - 0.9 * 0.1 * 0.58\n * = 1 - 0.0522\n * = 0.9478 -> 94.78 (0-100 scale)\n */\n\n/** A minimal, valid `DetectionSignal`-shaped wire object with sane defaults. */\nexport function detectionSignalFixture(\n overrides: Partial<{\n signalType: 'signature' | 'pattern' | 'behavioral' | 'network' | 'fingerprint';\n confidence: number;\n weight: number;\n source: string;\n explanation: string;\n }> = {}\n) {\n return {\n signalType: 'pattern' as const,\n confidence: 80,\n weight: 0.4,\n source: 'tier3_ua_pattern',\n explanation: 'Matches a known agent UA pattern',\n ...overrides,\n };\n}\n\n/**\n * Two independent signals (a pattern match at weight 1.0/confidence 90, a\n * network match at weight 0.6/confidence 70) whose combined Noisy-Or\n * confidence is the hand-verified 94.78 — see the module doc above.\n */\nexport const TWO_SIGNAL_EVIDENCE_FIXTURE = [\n detectionSignalFixture({\n source: 'known_scraper_ua',\n signalType: 'pattern',\n weight: 1.0,\n confidence: 90,\n }),\n detectionSignalFixture({\n source: 'datacenter_ip',\n signalType: 'network',\n weight: 0.6,\n confidence: 70,\n }),\n];\n\n/** The confidence (0-100 scale) `TWO_SIGNAL_EVIDENCE_FIXTURE` reconstructs to,\n * including the Noisy-Or prior — see the module doc above. */\nexport const TWO_SIGNAL_EVIDENCE_EXPECTED_CONFIDENCE = 94.78;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,MAAa,mCAAmC;;CAE9C,kBAAkB;;CAElB,iBAAiB;AACnB;;;;;;AAOA,MAAa,sCAAsC;CACjD,KAAK;CACL,KAAK;CACL,KAAK;AACP;;;;;;;AAQA,MAAa,wCAAwC;CACnD,KAAK;CACL,WAAW;CACX,SAAS;CACT,UAAU;CACV,WAAW;CACX,OAAO;CACP,KAAK;CACL,KAAK;AACP;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,mCACX;;;;;;;;;AAUF,MAAa,4CAA4C;CACvD,SAAS;CACT,aAAa,CAAC,cAAc;CAC5B,UAAU;CACV,WAAW;CACX,WAAW;AACb;;;;;;;;;;;;;;;;;AAkBA,MAAa,+BACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChHF,MAAa,+BAA+B;;CAE1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;;AAOA,MAAa,8BAA8B,CACzC,uBAAuB;CACrB,QAAQ;CACR,YAAY;CACZ,QAAQ;CACR,YAAY;AACd,CAAC,GACD,uBAAuB;CACrB,QAAQ;CACR,YAAY;CACZ,QAAQ;CACR,YAAY;AACd,CAAC,CACH;;;AAIA,MAAa,0CAA0C"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/test-fixtures/vault-wire-contract.ts","../../src/test-fixtures/mcpi-delegation-fixture.ts","../../src/test-fixtures/fetcher-200-predicate.ts","../../src/mcpi/delegation-verdict.ts","../../src/test-fixtures/verdict-evidence-fixture.ts"],"sourcesContent":["/**\n * Shared test fixture for the #1532 gateway ↔ vault wire contract.\n *\n * **DO NOT IMPORT FROM PRODUCTION CODE.** This file is exposed only via\n * the `@kya-os/checkpoint-shared/test-fixtures` subpath export so\n * production bundles that import from the root package entry point\n * can't reach it — the tree-shaker has no path to these symbols unless\n * a caller explicitly imports from the test-fixtures subpath.\n *\n * ## Purpose\n *\n * #1532 spans two services that must agree byte-for-byte on:\n *\n * 1. The shape of the JWT assertion the gateway signs\n * 2. The HTTP request body the gateway POSTs to the vault endpoint\n * 3. The claims the vault endpoint extracts after verifying the JWT\n *\n * This fixture pins a known-good input/output pair that both sides'\n * unit tests import. If either side's implementation drifts from the\n * contract (wrong field order, wrong base64url encoding, wrong key\n * derivation, etc), the test against this fixture fails loudly without\n * requiring a live end-to-end test.\n *\n * The fixture values below were generated ONCE by running the gateway\n * side's `signAssertion` function against a deterministic seed + the\n * canonical claims. Ed25519 is deterministic per RFC 8032 §5.1.6, so\n * the same inputs ALWAYS produce the same signature — which is what\n * lets us commit `expectedJwt` as a string literal and assert equality\n * across both sides' test runs.\n *\n * ## Test keypair (NOT PRODUCTION)\n *\n * The private key below is 32 bytes of `0x01` — the simplest possible\n * deterministic seed. It is NOT a real private key and must NEVER be\n * used to sign any real vault assertion. Its only purpose is to produce\n * reproducible fixture bytes that both engineers can check against.\n *\n * The corresponding public key was derived via Node's\n * `createPublicKey(privateKey)` and is included here for Engineer 2's\n * vault-side verification tests — vault tests don't need to reconstruct\n * the private half, only to verify signatures against this public key.\n *\n * ## Claim fixture\n *\n * The `canonicalPayload` matches the wire contract §2.2 sample verbatim:\n * eight claims in the exact order `iss, projectId, userDid, toolName,\n * sessionId, nonce, iat, exp`. Field order is load-bearing because\n * `JSON.stringify` preserves insertion order in V8 and the resulting\n * byte sequence is what Ed25519 signs over — reordering would produce\n * a different signature, breaking cross-service determinism.\n *\n * The `iat`/`exp` timestamps are frozen at `1712975940` / `1712976000`\n * (60-second window ending 2024-04-13T01:20:00Z-ish). Tests that run\n * against this fixture must either (a) not validate `exp` against wall\n * clock time, or (b) use `vi.useFakeTimers({ now: 1712975940000 })` to\n * freeze the clock inside the fixture window.\n */\n\n/**\n * Test keypair for the wire-contract fixture. Ed25519 private seed is\n * 32 bytes of `0x01`; public key is derived from it.\n *\n * **DO NOT USE IN PRODUCTION.**\n */\nexport const VAULT_WIRE_CONTRACT_TEST_KEYPAIR = {\n /** 32 bytes of 0x01, base64-encoded. Load into the signer via `loadSigningKey`. */\n privateKeyBase64: 'AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=',\n /** Raw 32-byte Ed25519 public key derived from the private seed, base64-encoded. */\n publicKeyBase64: 'iojj3XQJ8ZX9UtstPLpdcspnCb8dlBIb83SIAbQPb1w=',\n} as const;\n\n/**\n * The canonical JWT header both sides expect. Wire contract §2.1:\n * `alg` is `EdDSA` (NOT `Ed25519` — common mistake), `typ` is `JWT`,\n * `crv` is included for disambiguation per RFC 8037 §3.1.\n */\nexport const VAULT_WIRE_CONTRACT_EXPECTED_HEADER = {\n alg: 'EdDSA',\n typ: 'JWT',\n crv: 'Ed25519',\n} as const;\n\n/**\n * The canonical payload both sides assert against. Wire contract §2.2\n * order is load-bearing — rearranging these fields will produce a\n * different `expectedJwt` because `JSON.stringify` preserves insertion\n * order.\n */\nexport const VAULT_WIRE_CONTRACT_CANONICAL_PAYLOAD = {\n iss: 'did:web:gateway.knowthat.ai',\n projectId: '00000000-0000-0000-0000-000000000001',\n userDid: 'alice@example.test',\n toolName: 'create_issue',\n sessionId: 'gateway-oauth-test-sess-01',\n nonce: '0123456789abcdef',\n iat: 1712975940,\n exp: 1712976000,\n} as const;\n\n/**\n * The deterministic JWT produced by signing\n * {@link VAULT_WIRE_CONTRACT_CANONICAL_PAYLOAD} with the private half of\n * {@link VAULT_WIRE_CONTRACT_TEST_KEYPAIR}, via the gateway-side\n * `signAssertion` helper.\n *\n * Generated ONCE by running:\n *\n * ```\n * pnpm --filter @kya-os/checkpoint-gateway exec tsx -e \"...\"\n * ```\n *\n * and committed as a string literal. DO NOT regenerate this value\n * without understanding that both sides of the contract will need to\n * re-validate. If your implementation produces a different JWT for the\n * same canonical inputs, the bug is in YOUR code, not the fixture.\n *\n * Ed25519's deterministic signing property (RFC 8032 §5.1.6) is what\n * makes this string stable across runs, machines, and invocations.\n */\nexport const VAULT_WIRE_CONTRACT_EXPECTED_JWT =\n 'eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCIsImNydiI6IkVkMjU1MTkifQ.eyJpc3MiOiJkaWQ6d2ViOmdhdGV3YXkua25vd3RoYXQuYWkiLCJwcm9qZWN0SWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDEiLCJ1c2VyRGlkIjoiYWxpY2VAZXhhbXBsZS50ZXN0IiwidG9vbE5hbWUiOiJjcmVhdGVfaXNzdWUiLCJzZXNzaW9uSWQiOiJnYXRld2F5LW9hdXRoLXRlc3Qtc2Vzcy0wMSIsIm5vbmNlIjoiMDEyMzQ1Njc4OWFiY2RlZiIsImlhdCI6MTcxMjk3NTk0MCwiZXhwIjoxNzEyOTc2MDAwfQ.i-7vlvhLiohx6Qg0pXjfmllaDoZ_Fiu8KYW7vovHlQOPw9gsDrOECtM5qymv8bTf__hZKQeU8PyxBHtDusTDAg';\n\n/**\n * The expected HTTP request body the gateway sends to the vault\n * endpoint for the canonical payload. Wire contract §2.4 — all 5\n * fields are required, `assertion` is the full JWT from\n * {@link VAULT_WIRE_CONTRACT_EXPECTED_JWT}, and `userDid` MUST match\n * the assertion's `userDid` claim (the vault side rejects mismatches\n * with a 403).\n */\nexport const VAULT_WIRE_CONTRACT_EXPECTED_REQUEST_BODY = {\n userDid: 'alice@example.test',\n envVarNames: ['GITHUB_TOKEN'],\n toolName: 'create_issue',\n sessionId: 'gateway-oauth-test-sess-01',\n assertion: VAULT_WIRE_CONTRACT_EXPECTED_JWT,\n} as const;\n\n/**\n * The canonical vault endpoint URL path for the fixture's projectId.\n * Both sides use this to verify their URL construction logic. Base URL\n * is NOT included — this is the path portion only.\n *\n * Path note: the gateway's vault endpoint lives under\n * `/api/v1/gateway/vault/...`, NOT `/api/v1/vault/...`. The unprefixed\n * `/api/v1/vault/{projectId}/resolve` path is owned by the #1299\n * (VAULT-5) KYA-OS worker flow, which uses `X-API-Key` auth and is\n * architecturally incompatible with #1532's Ed25519-only model per\n * #1542 Decision 1 = B. The gateway gets its own parallel namespace\n * under `/api/v1/gateway/vault/*` so the two flows can coexist\n * without the KYA-OS handler needing auth-branching logic.\n *\n * See the corrected wire contract §2.4 on issue #1532.\n */\nexport const VAULT_WIRE_CONTRACT_URL_PATH =\n '/api/v1/gateway/vault/00000000-0000-0000-0000-000000000001/resolve';\n","/**\n * Shared test fixture for #1531 gateway OAuth ↔ KYA-OS delegation credential contract.\n *\n * **DO NOT IMPORT FROM PRODUCTION CODE.** Exposed only via the\n * `@kya-os/checkpoint-shared/test-fixtures` subpath export.\n *\n * ## Purpose\n *\n * #1531 spans two services that must agree on the VC-JWT wire format:\n *\n * 1. Engineer 2's authorization server (Vercel) — issues the VC-JWT\n * 2. Engineer 1's gateway resolver (Fly) — verifies the VC-JWT\n *\n * This fixture pins a known-good VC-JWT that both sides' tests import.\n * If either side drifts from the contract, the test against this fixture\n * fails loudly.\n *\n * ## Test keypair (NOT PRODUCTION)\n *\n * Reuses the #1532 convention: private key is 32 bytes of `0x01`.\n * Ed25519 is deterministic (RFC 8032 §5.1.6), so same inputs always\n * produce the same signature — which is what makes the expected JWT\n * string stable across runs.\n *\n * ## VC-JWT structure\n *\n * The JWT follows the KYA-OS §6.2 DelegationCredential as W3C VC pattern:\n * - Header: { alg: \"EdDSA\", typ: \"JWT\", kid: \"<issuer-key-id>\" }\n * - Payload: { iss, sub, aud, iat, exp, vc: { ... W3C VC ... }, orgId, orgSlug, sessionId }\n * - vc.credentialSubject.delegation contains the KYA-OS delegation record\n * - vc.credentialStatus contains StatusList2021 revocation reference\n *\n * ## Clock note\n *\n * Timestamps are frozen at iat=1712975940 (April 2024). Tests that validate\n * expiry must use vi.useFakeTimers({ now: 1712975940000 }).\n */\n\n// ---------------------------------------------------------------------------\n// Test keypair (32 bytes of 0x01 — same convention as #1532 vault fixture)\n// ---------------------------------------------------------------------------\n\n/** Ed25519 test keypair. DO NOT USE IN PRODUCTION. */\nexport const MCPI_DELEGATION_TEST_KEYPAIR = {\n /** 32 bytes of 0x01, base64-encoded. */\n privateKeyBase64: 'AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=',\n /** Raw 32-byte Ed25519 public key derived from the private seed, base64-encoded. */\n publicKeyBase64: 'iojj3XQJ8ZX9UtstPLpdcspnCb8dlBIb83SIAbQPb1w=',\n} as const;\n\n// ---------------------------------------------------------------------------\n// Canonical constants\n// ---------------------------------------------------------------------------\n\n/** DID of the org issuer (signs the VC-JWT). */\nexport const MCPI_DELEGATION_ISSUER_DID = 'did:web:kya.vouched.id:orgs:test-org';\n\n/**\n * Key ID of the OAuth signing key in the DID document.\n *\n * DR-1 / E1-P1 moved delegation issuance from the gateway operational DID\n * to per-org issuer DIDs. The verifier resolves the org DID document and\n * looks up that org's `#key-1` method.\n */\nexport const MCPI_DELEGATION_ISSUER_KID = 'did:web:kya.vouched.id:orgs:test-org#key-1';\n\n/** DID of the test MCP client (agent). */\nexport const MCPI_DELEGATION_AGENT_DID = 'did:key:z6MkTestAgent123';\n\n/** DID of the authorizing user. */\nexport const MCPI_DELEGATION_USER_DID = 'did:key:z6MkTestUser456';\n\n/** StatusList2021 endpoint URL. */\nexport const MCPI_DELEGATION_STATUS_LIST_URL =\n 'https://kya.vouched.id/orgs/test-org/status-lists/7f1c2a9e-4b3d-4e5f-8a6b-1c2d3e4f5a6b';\n\n/** Audience claim — the gateway's HTTPS origin. */\nexport const MCPI_DELEGATION_AUDIENCE = 'https://gateway.knowthat.ai';\n\n// ---------------------------------------------------------------------------\n// Canonical payload (decoded JWT claims)\n// ---------------------------------------------------------------------------\n\n/**\n * The canonical JWT payload. Field order is load-bearing because\n * JSON.stringify preserves insertion order and Ed25519 signs over\n * the resulting bytes.\n */\nexport const MCPI_DELEGATION_CANONICAL_PAYLOAD = {\n iss: 'did:web:kya.vouched.id:orgs:test-org',\n sub: 'did:key:z6MkTestAgent123',\n aud: 'https://gateway.knowthat.ai',\n iat: 1712975940,\n exp: 1712979540,\n vc: {\n // Pinned to the legacy `modelcontextprotocol-identity.io` host ON PURPOSE.\n // This array is signed over by MCPI_DELEGATION_EXPECTED_JWT (below) and must\n // byte-match it, and it must agree with the counterparty's pinned context in\n // xmcp-i (`packages/contracts/src/delegation/schemas.ts`). The live minter's\n // host migration (`vc-jwt.service.ts` → `schema.kya-os.org`) deliberately does\n // NOT move this vector — that requires re-signing both sides of the #1531\n // contract in lockstep. Do not \"fix\" this URL without regenerating the JWT.\n '@context': [\n 'https://www.w3.org/2018/credentials/v1',\n 'https://schema.modelcontextprotocol-identity.io/xmcp-i/credentials/delegation.v1.0.0.json',\n ],\n type: ['VerifiableCredential', 'DelegationCredential'],\n issuer: 'did:web:kya.vouched.id:orgs:test-org',\n issuanceDate: '2024-04-13T02:39:00.000Z',\n expirationDate: '2024-04-13T03:39:00.000Z',\n credentialSubject: {\n id: 'did:key:z6MkTestAgent123',\n delegation: {\n id: 'del-test-001',\n issuerDid: 'did:web:kya.vouched.id:orgs:test-org',\n subjectDid: 'did:key:z6MkTestAgent123',\n userDid: 'did:key:z6MkTestUser456',\n userIdentifier: 'alice@vouched.id',\n scopes: ['mcp'],\n constraints: {\n notBefore: 1712975940,\n notAfter: 1712979540,\n scopes: ['mcp'],\n audience: 'https://gateway.knowthat.ai',\n },\n status: 'active',\n },\n },\n credentialStatus: {\n id: 'https://kya.vouched.id/orgs/test-org/status-lists/7f1c2a9e-4b3d-4e5f-8a6b-1c2d3e4f5a6b#42',\n type: 'StatusList2021Entry',\n statusPurpose: 'revocation',\n statusListIndex: '42',\n statusListCredential:\n 'https://kya.vouched.id/orgs/test-org/status-lists/7f1c2a9e-4b3d-4e5f-8a6b-1c2d3e4f5a6b',\n },\n },\n orgId: '00000000-0000-0000-0000-000000000010',\n orgSlug: 'test-org',\n sessionId: '00000000-0000-0000-0000-000000000020',\n} as const;\n\n// ---------------------------------------------------------------------------\n// Canonical header\n// ---------------------------------------------------------------------------\n\nexport const MCPI_DELEGATION_EXPECTED_HEADER = {\n alg: 'EdDSA',\n typ: 'JWT',\n kid: 'did:web:kya.vouched.id:orgs:test-org#key-1',\n} as const;\n\n// ---------------------------------------------------------------------------\n// Expected VC-JWT (deterministic — Ed25519 + frozen claims)\n// ---------------------------------------------------------------------------\n\n/**\n * The deterministic VC-JWT produced by signing\n * {@link MCPI_DELEGATION_CANONICAL_PAYLOAD} with the private half of\n * {@link MCPI_DELEGATION_TEST_KEYPAIR}.\n *\n * Generated ONCE. DO NOT regenerate without understanding that both\n * sides of the #1531 contract will need to re-validate.\n *\n * Size: ~1.8KB — well within the 8KB HTTP header budget.\n */\nexport const MCPI_DELEGATION_EXPECTED_JWT =\n 'eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCIsImtpZCI6ImRpZDp3ZWI6a3lhLnZvdWNoZWQuaWQ6b3Jnczp0ZXN0LW9yZyNrZXktMSJ9.eyJpc3MiOiJkaWQ6d2ViOmt5YS52b3VjaGVkLmlkOm9yZ3M6dGVzdC1vcmciLCJ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R0cHM6Ly9nYXRld2F5Lmtub3d0aGF0LmFpIn0sInN0YXR1cyI6ImFjdGl2ZSJ9fSwiY3JlZGVudGlhbFN0YXR1cyI6eyJpZCI6Imh0dHBzOi8va3lhLnZvdWNoZWQuaWQvb3Jncy90ZXN0LW9yZy9zdGF0dXMtbGlzdHMvN2YxYzJhOWUtNGIzZC00ZTVmLThhNmItMWMyZDNlNGY1YTZiIzQyIiwidHlwZSI6IlN0YXR1c0xpc3QyMDIxRW50cnkiLCJzdGF0dXNQdXJwb3NlIjoicmV2b2NhdGlvbiIsInN0YXR1c0xpc3RJbmRleCI6IjQyIiwic3RhdHVzTGlzdENyZWRlbnRpYWwiOiJodHRwczovL2t5YS52b3VjaGVkLmlkL29yZ3MvdGVzdC1vcmcvc3RhdHVzLWxpc3RzLzdmMWMyYTllLTRiM2QtNGU1Zi04YTZiLTFjMmQzZTRmNWE2YiJ9fSwib3JnSWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMTAiLCJvcmdTbHVnIjoidGVzdC1vcmciLCJzZXNzaW9uSWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMjAifQ.A8FI0qQPYxOF_Jo7YVoY88Q6n3X8DKfln6Ak_HxpUH089z9HQjX1PKBJjDsFVyO0ma2Yf_2Mgg6wm7TiEav2DA';\n","/**\n * Shared selection-predicate vectors for the §8.1 fetcher-200 dual envelope.\n *\n * The `kya-http/challenge.delegation.fetcher-200.json` fixture freezes the\n * envelope BYTES; these vectors freeze the SELECTION — the decision of WHICH\n * envelope (body-readable 200 vs spec 401/422) a `negotiated`-mode PEP serves\n * for a given request. Because every PEP re-implements its own wiring (TS\n * shared impl here, plus .NET and the gateway worker), a single shared vector\n * set is the only thing that keeps the choice from drifting across them.\n *\n * The canonical TS predicate is `serveBodyReadable200` (host-adapter). Every\n * PEP MUST agree with these vectors. Selection is a cooperative-UX bridge,\n * NOT an access control: a non-cooperative caller simply gets the spec 401.\n */\n\n/** Detection class in its wire form, or `null` when detection is absent. */\nexport type FetcherPredicateDetectionClass =\n | 'human'\n | 'ai_agent'\n | 'bot'\n | 'incomplete_data'\n | null;\n\nexport interface FetcherEnvelopePredicateVector {\n /** Human-readable description of the case. */\n description: string;\n /** Request headers (lowercase keys), e.g. the `kya-accept-challenge` opt-in. */\n headers: Record<string, string>;\n /** The caller's detection class (wire form), or `null` if absent. */\n detectionClass: FetcherPredicateDetectionClass;\n /**\n * The engine's `isAgent` verdict for the caller. The transitional UA heuristic\n * fires ONLY when `isAgent` AND `detectionClass === 'ai_agent'` agree — matching\n * .NET `IsInteractiveAiAgent` (`IsAgent && DetectionClass.Type == AiAgent`) and the\n * gateway worker. A class/`isAgent` disagreement is treated as non-cooperative\n * (spec 401), so an `ai_agent` class with `isAgent: false` does NOT get the 200.\n */\n isAgent: boolean;\n /** Expected predicate result: `true` → body-readable 200; `false` → spec 401/422. */\n expected: boolean;\n}\n\n/**\n * The frozen cross-PEP predicate vectors. Keep additions semantic (a new\n * distinct case), never a re-statement of an existing one.\n */\nexport const FETCHER_200_PREDICATE_VECTORS: readonly FetcherEnvelopePredicateVector[] = [\n {\n description: 'opt-in header present, non-agent detection → 200 (header is the primary signal)',\n headers: { 'kya-accept-challenge': 'delegation' },\n detectionClass: 'human',\n isAgent: false,\n expected: true,\n },\n {\n description: 'opt-in header present, detection absent → 200',\n headers: { 'kya-accept-challenge': 'delegation' },\n detectionClass: null,\n isAgent: false,\n expected: true,\n },\n {\n description: 'detected ai_agent (isAgent agrees), no opt-in → 200 (transitional UA heuristic)',\n headers: {},\n detectionClass: 'ai_agent',\n isAgent: true,\n expected: true,\n },\n {\n description: 'Accept: text/html on a detected agent → 200 (Accept MUST NOT branch the body)',\n headers: { accept: 'text/markdown, text/html, */*' },\n detectionClass: 'ai_agent',\n isAgent: true,\n expected: true,\n },\n {\n description:\n 'ai_agent class but isAgent=false (signals disagree) → 401 (require both, matches .NET + worker)',\n headers: {},\n detectionClass: 'ai_agent',\n isAgent: false,\n expected: false,\n },\n {\n description: 'human, no opt-in → 401 (spec path)',\n headers: {},\n detectionClass: 'human',\n isAgent: false,\n expected: false,\n },\n {\n description: 'bot, no opt-in → 401 (non-cooperative / spoofer lands on spec path)',\n headers: {},\n detectionClass: 'bot',\n isAgent: false,\n expected: false,\n },\n {\n description: 'incomplete_data, no opt-in → 401',\n headers: {},\n detectionClass: 'incomplete_data',\n isAgent: false,\n expected: false,\n },\n {\n description: 'no signals at all → 401',\n headers: {},\n detectionClass: null,\n isAgent: false,\n expected: false,\n },\n {\n description: 'empty opt-in value is ignored, human → 401',\n headers: { 'kya-accept-challenge': '' },\n detectionClass: 'human',\n isAgent: false,\n expected: false,\n },\n];\n","/**\n * Common delegation-verdict shape (verifier/engine unification series).\n *\n * The `delegation` cross-runtime-parity track\n * (`tests/cross-runtime-parity/delegation/`) checks multiple independent\n * delegation-verify implementations — the Fly gateway (`apps/gateway/src/lib/\n * mcpi-auth-resolver.ts` + `dashboard-delegation-verifier.ts`, both engine-\n * backed as of PR6/PR7) and `rust/crates/kya-os-engine`'s `verify_delegation`\n * — against one canonical vector set. Every emitter normalizes its runtime's\n * result to this shape before writing `runtime-outputs/<name>.json`. Lives\n * under the package's main entrypoint (not `test-fixtures`) because the\n * parity-harness test imports it as production infrastructure;\n * `test-fixtures/delegation-verdict.ts` re-exports it for the existing\n * parity-harness imports.\n *\n * Deliberately verdict-only (`kind` + coarse `reason.kind`), not the full\n * delegation record: the gateway's audit extractions (`delegationId`,\n * `clientDid`, `orgId`, `accountableAdminDid`) are deterministic claim reads,\n * not verification decisions, so they don't belong in a cross-implementation\n * agreement check — their correctness is covered by the gateway's own unit\n * tests (`mcpi-auth-resolver.test.ts`, `dashboard-delegation-verifier.test.ts`),\n * which is their natural home. Keeping this shape to exactly what\n * `scripts/assert-cross-runtime-parity.ts` already matches on (`kind`,\n * `reason.kind`, `reason.kindStartsWith`, `oneOf`) means that script needs no\n * per-track special-casing.\n *\n * `reason.kind` is deliberately coarse — a structural reason CLASS, not a\n * fine-grained cause. Each runtime's native vocabulary is many-to-one mapped\n * onto this fixed set via `toCoarseReasonKind`:\n *\n * - `signature` — bad/absent cryptographic signature\n * - `claim` — any issuer / audience / subject / orgId / other claim or\n * authorization mismatch (including \"no identity material\n * presented at all\")\n * - `time` — expired OR not-yet-valid\n * - `revocation` — revoked, or status-unavailable (fail-closed)\n * - `scope` — delegation doesn't grant the requested scope\n * - `resolve` — DID / context could not be resolved\n *\n * This is the coarsest granularity both the gateway (whose own top-level\n * verifier already folds iss/aud/orgId/sub into one `claim_invalid` /\n * `claim_mismatch`) and the engine (whose `BlockReason` has no\n * audience/issuer/not-yet-valid-specific variants) can already express\n * without changing either side's production reason taxonomy. Fine-grained\n * reason parity is an observability nice-to-have, not a security property —\n * the gate's job is to catch security-relevant WHY-drift (a different\n * structural reason class, or accept-vs-reject), not whether both sides spell\n * a claim rejection the same way. If per-cause parity is ever wanted, extend\n * each runtime's own reason vocabulary deliberately on its own timeline —\n * never bundle it with this track's blocking gate.\n */\n\nexport type DelegationVerdictKind = 'Permit' | 'Block';\n\nexport type CoarseReasonKind = 'signature' | 'claim' | 'time' | 'revocation' | 'scope' | 'resolve';\n\nexport interface DelegationVerdictReason {\n kind: CoarseReasonKind;\n}\n\nexport interface DelegationVerdict {\n kind: DelegationVerdictKind;\n reason: DelegationVerdictReason | null;\n}\n\n/**\n * Every raw reason discriminator either runtime can natively emit for the\n * delegation path, mapped onto the coarse taxonomy above.\n *\n * Gateway (`McpiAuthErrorReason` in `mcpi-auth-resolver.ts`,\n * `DashboardVerifyFailure['reason']` in `dashboard-delegation-verifier.ts`):\n * snake_case. Engine (`BlockReason` in `rust/crates/kya-os-engine/src/types.rs`):\n * PascalCase variant names. Unrecognized input is a harness bug (an emitter\n * started producing a reason string neither side has ever emitted before) —\n * `toCoarseReasonKind` throws rather than silently defaulting, so a new raw\n * reason gets a deliberate classification instead of landing in the wrong\n * bucket unnoticed.\n */\nconst REASON_KIND_MAP: Record<string, CoarseReasonKind> = {\n // --- gateway: apps/gateway/src/lib/mcpi-auth-resolver.ts ---\n missing_bearer_token: 'claim',\n parse_error: 'claim',\n did_resolve_failed: 'resolve',\n signature_invalid: 'signature',\n audience_mismatch: 'claim',\n expired: 'time',\n not_yet_valid: 'time',\n revoked: 'revocation',\n delegation_inactive: 'revocation',\n missing_claim: 'claim',\n claim_invalid: 'claim',\n // --- gateway: apps/gateway/src/lib/dashboard-delegation-verifier.ts ---\n not_configured: 'claim',\n header_missing: 'claim',\n claim_mismatch: 'claim',\n malformed: 'claim',\n // --- engine-rust: rust/crates/kya-os-engine/src/types.rs BlockReason ---\n Revoked: 'revocation',\n InvalidSignature: 'signature',\n Unauthenticated: 'claim',\n Expired: 'time',\n OutOfScope: 'scope',\n};\n\n/** Map a runtime's native reason discriminator onto the coarse taxonomy. */\nexport function toCoarseReasonKind(rawReasonKind: string): CoarseReasonKind {\n const coarse = REASON_KIND_MAP[rawReasonKind];\n if (!coarse) {\n throw new Error(\n `toCoarseReasonKind: unrecognized raw reason kind ${JSON.stringify(rawReasonKind)} — ` +\n `add it to REASON_KIND_MAP in delegation-verdict.ts with a deliberate coarse classification`\n );\n }\n return coarse;\n}\n\n/** Build a `Permit` verdict. */\nexport function permitDelegationVerdict(): DelegationVerdict {\n return { kind: 'Permit', reason: null };\n}\n\n/** Build a `Block` verdict from a runtime-native reason discriminator. */\nexport function blockDelegationVerdict(rawReasonKind: string): DelegationVerdict {\n return { kind: 'Block', reason: { kind: toCoarseReasonKind(rawReasonKind) } };\n}\n","/**\n * Shared test fixture for P20 verdict-evidence tests (`buildVerdictEvidence`,\n * `reconstructConfidenceFromEvidence` — see `../core/verdict-evidence.ts`).\n *\n * **DO NOT IMPORT FROM PRODUCTION CODE.** Exposed only via the\n * `@kya-os/checkpoint-shared/test-fixtures` subpath export.\n *\n * ## Purpose\n *\n * Four independent test suites each need \"one signal, minimal defaults\" and\n * \"two independent signals whose Noisy-Or reconstruction is a known,\n * hand-verified number\" — checkpoint-shared's own unit tests, the\n * enforcement-metadata envelope tests, the activity-log read-side tests, and\n * the pixel-route persistence test. Before this fixture existed, all four\n * hardcoded the SAME two fixtures and the SAME derivation comment\n * independently — a change to one could silently drift from the others.\n * This is the one place that number is computed; every test imports it\n * rather than re-deriving it.\n *\n * ## The known reconstruction\n *\n * `TWO_SIGNAL_EVIDENCE_FIXTURE`'s Noisy-Or confidence, by hand — INCLUDING\n * the `UNCALIBRATED_NOISY_OR_PRIOR` (0.10) leak term every live verdict\n * folds in (bestbrian, PR #4747 review — the earlier version of this\n * fixture omitted it and asserted the wrong number, 94.2):\n *\n * 1 - (1 - 0.10) * (1 - 1.0*0.9) * (1 - 0.6*0.7)\n * = 1 - 0.9 * 0.1 * 0.58\n * = 1 - 0.0522\n * = 0.9478 -> 94.78 (0-100 scale)\n */\n\n/** A minimal, valid `DetectionSignal`-shaped wire object with sane defaults. */\nexport function detectionSignalFixture(\n overrides: Partial<{\n signalType: 'signature' | 'pattern' | 'behavioral' | 'network' | 'fingerprint';\n confidence: number;\n weight: number;\n source: string;\n explanation: string;\n }> = {}\n) {\n return {\n signalType: 'pattern' as const,\n confidence: 80,\n weight: 0.4,\n source: 'tier3_ua_pattern',\n explanation: 'Matches a known agent UA pattern',\n ...overrides,\n };\n}\n\n/**\n * Two independent signals (a pattern match at weight 1.0/confidence 90, a\n * network match at weight 0.6/confidence 70) whose combined Noisy-Or\n * confidence is the hand-verified 94.78 — see the module doc above.\n */\nexport const TWO_SIGNAL_EVIDENCE_FIXTURE = [\n detectionSignalFixture({\n source: 'known_scraper_ua',\n signalType: 'pattern',\n weight: 1.0,\n confidence: 90,\n }),\n detectionSignalFixture({\n source: 'datacenter_ip',\n signalType: 'network',\n weight: 0.6,\n confidence: 70,\n }),\n];\n\n/** The confidence (0-100 scale) `TWO_SIGNAL_EVIDENCE_FIXTURE` reconstructs to,\n * including the Noisy-Or prior — see the module doc above. */\nexport const TWO_SIGNAL_EVIDEN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B,gBAAgB;CAChB,gBAAgB;CAChB,WAAW;CAEX,SAAS;CACT,kBAAkB;CAClB,iBAAiB;CACjB,SAAS;CACT,YAAY;AACd;;AAGA,SAAgB,mBAAmB,eAAyC;CAC1E,MAAM,SAAS,gBAAgB;CAC/B,IAAI,CAAC,QACH,MAAM,IAAI,MACR,oDAAoD,KAAK,UAAU,aAAa,EAAE,8FAEpF;CAEF,OAAO;AACT;;AAGA,SAAgB,0BAA6C;CAC3D,OAAO;EAAE,MAAM;EAAU,QAAQ;CAAK;AACxC;;AAGA,SAAgB,uBAAuB,eAA0C;CAC/E,OAAO;EAAE,MAAM;EAAS,QAAQ,EAAE,MAAM,mBAAmB,aAAa,EAAE;CAAE;AAC9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC3FA,SAAgB,uBACd,YAMK,CAAC,GACN;CACA,OAAO;EACL,YAAY;EACZ,YAAY;EACZ,QAAQ;EACR,QAAQ;EACR,aAAa;EACb,GAAG;CACL;AACF;;;;;;AAOA,MAAa,8BAA8B,CACzC,uBAAuB;CACrB,QAAQ;CACR,YAAY;CACZ,QAAQ;CACR,YAAY;AACd,CAAC,GACD,uBAAuB;CACrB,QAAQ;CACR,YAAY;CACZ,QAAQ;CACR,YAAY;AACd,CAAC,CACH;;;AAIA,MAAa,0CAA0C"}
@@ -0,0 +1,181 @@
1
+ //#region src/utils/verification.ts
2
+ /**
3
+ * KYA-OS verification-method vocabulary rename (`mcp-i` → `kya-os`), read side.
4
+ *
5
+ * Mirrors the Vocab-1 dual-accept shape in `policy/constants.ts`: a canonical
6
+ * value plus a deprecated legacy alias kept for a read-side cutover window.
7
+ * **This widens READERS only** — nothing emits the canonical value yet (the
8
+ * Rust engine still emits `mcp_i_handshake`; the gateway worker still emits the
9
+ * wire value `mcp-i`). The canonical spelling matches the `kyaos-jws` token
10
+ * chosen for the `verified_protocol` axis in #2937.
11
+ *
12
+ * Two distinct value spaces — do not conflate:
13
+ * - **ENGINE value** — emitted by the detection engine (`mcp_i_handshake`).
14
+ * - **WIRE value** — the normalized form stored/exposed downstream (`mcp-i`).
15
+ *
16
+ * This module is the SINGLE source of the legacy↔canonical alias map for both
17
+ * spaces. Every downstream "accept both" site routes through the predicates
18
+ * (`isKyaOs*Method`) or normalizers (`normalize*Method`) below, so the literal
19
+ * alias strings live in exactly one place; adding or retiring an alias is a
20
+ * one-file change, and no consumer can drift into a single-alias bypass.
21
+ */
22
+ const KYA_OS_HANDSHAKE_METHODS = {
23
+ /** New canonical engine value. Not emitted yet — accepted on read. */
24
+ CANONICAL: "kyaos_handshake",
25
+ /** @deprecated Legacy engine value. Still emitted by the Rust engine. */
26
+ LEGACY: "mcp_i_handshake"
27
+ };
28
+ const KYA_OS_WIRE_METHODS = {
29
+ /** New canonical wire value. Not emitted yet — accepted on read. */
30
+ CANONICAL: "kya-os",
31
+ /** @deprecated Legacy wire value. Still emitted by the gateway worker. */
32
+ LEGACY: "mcp-i"
33
+ };
34
+ /** True for either the legacy or canonical KYA-OS handshake ENGINE value. */
35
+ function isKyaOsHandshakeMethod(value) {
36
+ return value === KYA_OS_HANDSHAKE_METHODS.LEGACY || value === KYA_OS_HANDSHAKE_METHODS.CANONICAL;
37
+ }
38
+ /** True for either the legacy or canonical KYA-OS delegation WIRE value. */
39
+ function isKyaOsWireMethod(value) {
40
+ return value === KYA_OS_WIRE_METHODS.LEGACY || value === KYA_OS_WIRE_METHODS.CANONICAL;
41
+ }
42
+ /**
43
+ * Collapse a KYA-OS handshake ENGINE value to its canonical form for INTERNAL
44
+ * comparison. Either alias (`mcp_i_handshake` | `kyaos_handshake`) maps to
45
+ * `KYA_OS_HANDSHAKE_METHODS.CANONICAL`; every other value (including
46
+ * null/undefined) passes through unchanged. The return type widens the caller's
47
+ * type by the canonical alias (`T | 'kyaos_handshake'`), which is honest (no
48
+ * `as` cast) and still drops cleanly into a typed `switch`.
49
+ *
50
+ * Use this to normalize ONCE at a boundary so downstream decisions compare a
51
+ * single value instead of re-listing both aliases. It does NOT touch the wire
52
+ * value space; a wire value like `mcp-i` passes straight through.
53
+ *
54
+ * SECURITY/DATA NOTE: this is for comparison/decisions only. Do NOT use it to
55
+ * rewrite a value that gets PERSISTED or EMITTED. Historical DB rows, the Rust
56
+ * engine, and the gateway worker all still use the legacy spelling, so changing
57
+ * a stored/emitted value would be a data-format change. Sites that map to a
58
+ * stored/wire value keep emitting the legacy value deliberately.
59
+ */
60
+ function normalizeHandshakeMethod(value) {
61
+ return isKyaOsHandshakeMethod(value) ? KYA_OS_HANDSHAKE_METHODS.CANONICAL : value;
62
+ }
63
+ /**
64
+ * Collapse a KYA-OS delegation WIRE value to its canonical form for INTERNAL
65
+ * comparison. Either alias (`mcp-i` | `kya-os`) maps to
66
+ * `KYA_OS_WIRE_METHODS.CANONICAL`; every other value (including null/undefined)
67
+ * passes through unchanged. Does NOT touch the engine value space.
68
+ *
69
+ * Same comparison-only contract and honest `T | 'kya-os'` return type as
70
+ * `normalizeHandshakeMethod`; never use it to change a persisted/emitted value.
71
+ */
72
+ function normalizeWireMethod(value) {
73
+ return isKyaOsWireMethod(value) ? KYA_OS_WIRE_METHODS.CANONICAL : value;
74
+ }
75
+ /**
76
+ * Gets a human-readable description for a verification method
77
+ */
78
+ function getVerificationMethodDescription(method) {
79
+ switch (normalizeHandshakeMethod(method)) {
80
+ case "signature": return "HTTP Signature Verification";
81
+ case "pattern": return "User-Agent Pattern Matching";
82
+ case "behavioral": return "Behavioral Analysis";
83
+ case "network": return "Network-based Detection";
84
+ case KYA_OS_HANDSHAKE_METHODS.CANONICAL: return "MCP Handshake Detection";
85
+ case "error": return "Detection Error";
86
+ default: return "No Verification";
87
+ }
88
+ }
89
+ /**
90
+ * Gets the reliability/confidence modifier for a verification method
91
+ * Higher values indicate more reliable verification methods
92
+ */
93
+ function getVerificationReliability(method) {
94
+ switch (normalizeHandshakeMethod(method)) {
95
+ case "signature": return 1;
96
+ case KYA_OS_HANDSHAKE_METHODS.CANONICAL: return .95;
97
+ case "behavioral": return .8;
98
+ case "network": return .6;
99
+ case "pattern": return .5;
100
+ case "none": return .3;
101
+ default: return .1;
102
+ }
103
+ }
104
+ /**
105
+ * Determines if a verification method indicates high confidence detection
106
+ */
107
+ function isHighConfidenceVerification(method) {
108
+ return method === "signature" || isKyaOsHandshakeMethod(method);
109
+ }
110
+ /**
111
+ * Maps verification method to appropriate risk level
112
+ */
113
+ function getVerificationRiskLevel(method, confidence) {
114
+ if (method === "signature") return "low";
115
+ if (isKyaOsHandshakeMethod(method)) return "low";
116
+ if (confidence >= .9) return method === "behavioral" ? "medium" : "high";
117
+ if (confidence >= .7) return "medium";
118
+ return "high";
119
+ }
120
+
121
+ //#endregion
122
+ Object.defineProperty(exports, 'KYA_OS_HANDSHAKE_METHODS', {
123
+ enumerable: true,
124
+ get: function () {
125
+ return KYA_OS_HANDSHAKE_METHODS;
126
+ }
127
+ });
128
+ Object.defineProperty(exports, 'KYA_OS_WIRE_METHODS', {
129
+ enumerable: true,
130
+ get: function () {
131
+ return KYA_OS_WIRE_METHODS;
132
+ }
133
+ });
134
+ Object.defineProperty(exports, 'getVerificationMethodDescription', {
135
+ enumerable: true,
136
+ get: function () {
137
+ return getVerificationMethodDescription;
138
+ }
139
+ });
140
+ Object.defineProperty(exports, 'getVerificationReliability', {
141
+ enumerable: true,
142
+ get: function () {
143
+ return getVerificationReliability;
144
+ }
145
+ });
146
+ Object.defineProperty(exports, 'getVerificationRiskLevel', {
147
+ enumerable: true,
148
+ get: function () {
149
+ return getVerificationRiskLevel;
150
+ }
151
+ });
152
+ Object.defineProperty(exports, 'isHighConfidenceVerification', {
153
+ enumerable: true,
154
+ get: function () {
155
+ return isHighConfidenceVerification;
156
+ }
157
+ });
158
+ Object.defineProperty(exports, 'isKyaOsHandshakeMethod', {
159
+ enumerable: true,
160
+ get: function () {
161
+ return isKyaOsHandshakeMethod;
162
+ }
163
+ });
164
+ Object.defineProperty(exports, 'isKyaOsWireMethod', {
165
+ enumerable: true,
166
+ get: function () {
167
+ return isKyaOsWireMethod;
168
+ }
169
+ });
170
+ Object.defineProperty(exports, 'normalizeHandshakeMethod', {
171
+ enumerable: true,
172
+ get: function () {
173
+ return normalizeHandshakeMethod;
174
+ }
175
+ });
176
+ Object.defineProperty(exports, 'normalizeWireMethod', {
177
+ enumerable: true,
178
+ get: function () {
179
+ return normalizeWireMethod;
180
+ }
181
+ });
@@ -0,0 +1,123 @@
1
+ //#region src/utils/verification.ts
2
+ /**
3
+ * KYA-OS verification-method vocabulary rename (`mcp-i` → `kya-os`), read side.
4
+ *
5
+ * Mirrors the Vocab-1 dual-accept shape in `policy/constants.ts`: a canonical
6
+ * value plus a deprecated legacy alias kept for a read-side cutover window.
7
+ * **This widens READERS only** — nothing emits the canonical value yet (the
8
+ * Rust engine still emits `mcp_i_handshake`; the gateway worker still emits the
9
+ * wire value `mcp-i`). The canonical spelling matches the `kyaos-jws` token
10
+ * chosen for the `verified_protocol` axis in #2937.
11
+ *
12
+ * Two distinct value spaces — do not conflate:
13
+ * - **ENGINE value** — emitted by the detection engine (`mcp_i_handshake`).
14
+ * - **WIRE value** — the normalized form stored/exposed downstream (`mcp-i`).
15
+ *
16
+ * This module is the SINGLE source of the legacy↔canonical alias map for both
17
+ * spaces. Every downstream "accept both" site routes through the predicates
18
+ * (`isKyaOs*Method`) or normalizers (`normalize*Method`) below, so the literal
19
+ * alias strings live in exactly one place; adding or retiring an alias is a
20
+ * one-file change, and no consumer can drift into a single-alias bypass.
21
+ */
22
+ const KYA_OS_HANDSHAKE_METHODS = {
23
+ /** New canonical engine value. Not emitted yet — accepted on read. */
24
+ CANONICAL: "kyaos_handshake",
25
+ /** @deprecated Legacy engine value. Still emitted by the Rust engine. */
26
+ LEGACY: "mcp_i_handshake"
27
+ };
28
+ const KYA_OS_WIRE_METHODS = {
29
+ /** New canonical wire value. Not emitted yet — accepted on read. */
30
+ CANONICAL: "kya-os",
31
+ /** @deprecated Legacy wire value. Still emitted by the gateway worker. */
32
+ LEGACY: "mcp-i"
33
+ };
34
+ /** True for either the legacy or canonical KYA-OS handshake ENGINE value. */
35
+ function isKyaOsHandshakeMethod(value) {
36
+ return value === KYA_OS_HANDSHAKE_METHODS.LEGACY || value === KYA_OS_HANDSHAKE_METHODS.CANONICAL;
37
+ }
38
+ /** True for either the legacy or canonical KYA-OS delegation WIRE value. */
39
+ function isKyaOsWireMethod(value) {
40
+ return value === KYA_OS_WIRE_METHODS.LEGACY || value === KYA_OS_WIRE_METHODS.CANONICAL;
41
+ }
42
+ /**
43
+ * Collapse a KYA-OS handshake ENGINE value to its canonical form for INTERNAL
44
+ * comparison. Either alias (`mcp_i_handshake` | `kyaos_handshake`) maps to
45
+ * `KYA_OS_HANDSHAKE_METHODS.CANONICAL`; every other value (including
46
+ * null/undefined) passes through unchanged. The return type widens the caller's
47
+ * type by the canonical alias (`T | 'kyaos_handshake'`), which is honest (no
48
+ * `as` cast) and still drops cleanly into a typed `switch`.
49
+ *
50
+ * Use this to normalize ONCE at a boundary so downstream decisions compare a
51
+ * single value instead of re-listing both aliases. It does NOT touch the wire
52
+ * value space; a wire value like `mcp-i` passes straight through.
53
+ *
54
+ * SECURITY/DATA NOTE: this is for comparison/decisions only. Do NOT use it to
55
+ * rewrite a value that gets PERSISTED or EMITTED. Historical DB rows, the Rust
56
+ * engine, and the gateway worker all still use the legacy spelling, so changing
57
+ * a stored/emitted value would be a data-format change. Sites that map to a
58
+ * stored/wire value keep emitting the legacy value deliberately.
59
+ */
60
+ function normalizeHandshakeMethod(value) {
61
+ return isKyaOsHandshakeMethod(value) ? KYA_OS_HANDSHAKE_METHODS.CANONICAL : value;
62
+ }
63
+ /**
64
+ * Collapse a KYA-OS delegation WIRE value to its canonical form for INTERNAL
65
+ * comparison. Either alias (`mcp-i` | `kya-os`) maps to
66
+ * `KYA_OS_WIRE_METHODS.CANONICAL`; every other value (including null/undefined)
67
+ * passes through unchanged. Does NOT touch the engine value space.
68
+ *
69
+ * Same comparison-only contract and honest `T | 'kya-os'` return type as
70
+ * `normalizeHandshakeMethod`; never use it to change a persisted/emitted value.
71
+ */
72
+ function normalizeWireMethod(value) {
73
+ return isKyaOsWireMethod(value) ? KYA_OS_WIRE_METHODS.CANONICAL : value;
74
+ }
75
+ /**
76
+ * Gets a human-readable description for a verification method
77
+ */
78
+ function getVerificationMethodDescription(method) {
79
+ switch (normalizeHandshakeMethod(method)) {
80
+ case "signature": return "HTTP Signature Verification";
81
+ case "pattern": return "User-Agent Pattern Matching";
82
+ case "behavioral": return "Behavioral Analysis";
83
+ case "network": return "Network-based Detection";
84
+ case KYA_OS_HANDSHAKE_METHODS.CANONICAL: return "MCP Handshake Detection";
85
+ case "error": return "Detection Error";
86
+ default: return "No Verification";
87
+ }
88
+ }
89
+ /**
90
+ * Gets the reliability/confidence modifier for a verification method
91
+ * Higher values indicate more reliable verification methods
92
+ */
93
+ function getVerificationReliability(method) {
94
+ switch (normalizeHandshakeMethod(method)) {
95
+ case "signature": return 1;
96
+ case KYA_OS_HANDSHAKE_METHODS.CANONICAL: return .95;
97
+ case "behavioral": return .8;
98
+ case "network": return .6;
99
+ case "pattern": return .5;
100
+ case "none": return .3;
101
+ default: return .1;
102
+ }
103
+ }
104
+ /**
105
+ * Determines if a verification method indicates high confidence detection
106
+ */
107
+ function isHighConfidenceVerification(method) {
108
+ return method === "signature" || isKyaOsHandshakeMethod(method);
109
+ }
110
+ /**
111
+ * Maps verification method to appropriate risk level
112
+ */
113
+ function getVerificationRiskLevel(method, confidence) {
114
+ if (method === "signature") return "low";
115
+ if (isKyaOsHandshakeMethod(method)) return "low";
116
+ if (confidence >= .9) return method === "behavioral" ? "medium" : "high";
117
+ if (confidence >= .7) return "medium";
118
+ return "high";
119
+ }
120
+
121
+ //#endregion
122
+ export { getVerificationRiskLevel as a, isKyaOsWireMethod as c, getVerificationReliability as i, normalizeHandshakeMethod as l, KYA_OS_WIRE_METHODS as n, isHighConfidenceVerification as o, getVerificationMethodDescription as r, isKyaOsHandshakeMethod as s, KYA_OS_HANDSHAKE_METHODS as t, normalizeWireMethod as u };
123
+ //# sourceMappingURL=verification-Cvvv86TT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verification-Cvvv86TT.mjs","names":[],"sources":["../src/utils/verification.ts"],"sourcesContent":["/**\n * Shared utilities for verification method mapping and handling\n */\n\nexport type VerificationMethod =\n | 'signature'\n | 'pattern'\n | 'behavioral'\n | 'network'\n | 'mcp_i_handshake'\n | 'kyaos_handshake'\n | 'none'\n | 'error';\n\n/**\n * KYA-OS verification-method vocabulary rename (`mcp-i` → `kya-os`), read side.\n *\n * Mirrors the Vocab-1 dual-accept shape in `policy/constants.ts`: a canonical\n * value plus a deprecated legacy alias kept for a read-side cutover window.\n * **This widens READERS only** — nothing emits the canonical value yet (the\n * Rust engine still emits `mcp_i_handshake`; the gateway worker still emits the\n * wire value `mcp-i`). The canonical spelling matches the `kyaos-jws` token\n * chosen for the `verified_protocol` axis in #2937.\n *\n * Two distinct value spaces — do not conflate:\n * - **ENGINE value** — emitted by the detection engine (`mcp_i_handshake`).\n * - **WIRE value** — the normalized form stored/exposed downstream (`mcp-i`).\n *\n * This module is the SINGLE source of the legacy↔canonical alias map for both\n * spaces. Every downstream \"accept both\" site routes through the predicates\n * (`isKyaOs*Method`) or normalizers (`normalize*Method`) below, so the literal\n * alias strings live in exactly one place; adding or retiring an alias is a\n * one-file change, and no consumer can drift into a single-alias bypass.\n */\nexport const KYA_OS_HANDSHAKE_METHODS = {\n /** New canonical engine value. Not emitted yet — accepted on read. */\n CANONICAL: 'kyaos_handshake',\n /** @deprecated Legacy engine value. Still emitted by the Rust engine. */\n LEGACY: 'mcp_i_handshake',\n} as const;\n\nexport const KYA_OS_WIRE_METHODS = {\n /** New canonical wire value. Not emitted yet — accepted on read. */\n CANONICAL: 'kya-os',\n /** @deprecated Legacy wire value. Still emitted by the gateway worker. */\n LEGACY: 'mcp-i',\n} as const;\n\n/** True for either the legacy or canonical KYA-OS handshake ENGINE value. */\nexport function isKyaOsHandshakeMethod(value: string | null | undefined): boolean {\n return value === KYA_OS_HANDSHAKE_METHODS.LEGACY || value === KYA_OS_HANDSHAKE_METHODS.CANONICAL;\n}\n\n/** True for either the legacy or canonical KYA-OS delegation WIRE value. */\nexport function isKyaOsWireMethod(value: string | null | undefined): boolean {\n return value === KYA_OS_WIRE_METHODS.LEGACY || value === KYA_OS_WIRE_METHODS.CANONICAL;\n}\n\n/**\n * Collapse a KYA-OS handshake ENGINE value to its canonical form for INTERNAL\n * comparison. Either alias (`mcp_i_handshake` | `kyaos_handshake`) maps to\n * `KYA_OS_HANDSHAKE_METHODS.CANONICAL`; every other value (including\n * null/undefined) passes through unchanged. The return type widens the caller's\n * type by the canonical alias (`T | 'kyaos_handshake'`), which is honest (no\n * `as` cast) and still drops cleanly into a typed `switch`.\n *\n * Use this to normalize ONCE at a boundary so downstream decisions compare a\n * single value instead of re-listing both aliases. It does NOT touch the wire\n * value space; a wire value like `mcp-i` passes straight through.\n *\n * SECURITY/DATA NOTE: this is for comparison/decisions only. Do NOT use it to\n * rewrite a value that gets PERSISTED or EMITTED. Historical DB rows, the Rust\n * engine, and the gateway worker all still use the legacy spelling, so changing\n * a stored/emitted value would be a data-format change. Sites that map to a\n * stored/wire value keep emitting the legacy value deliberately.\n */\nexport function normalizeHandshakeMethod<T extends string | null | undefined>(\n value: T\n): T | typeof KYA_OS_HANDSHAKE_METHODS.CANONICAL {\n return isKyaOsHandshakeMethod(value) ? KYA_OS_HANDSHAKE_METHODS.CANONICAL : value;\n}\n\n/**\n * Collapse a KYA-OS delegation WIRE value to its canonical form for INTERNAL\n * comparison. Either alias (`mcp-i` | `kya-os`) maps to\n * `KYA_OS_WIRE_METHODS.CANONICAL`; every other value (including null/undefined)\n * passes through unchanged. Does NOT touch the engine value space.\n *\n * Same comparison-only contract and honest `T | 'kya-os'` return type as\n * `normalizeHandshakeMethod`; never use it to change a persisted/emitted value.\n */\nexport function normalizeWireMethod<T extends string | null | undefined>(\n value: T\n): T | typeof KYA_OS_WIRE_METHODS.CANONICAL {\n return isKyaOsWireMethod(value) ? KYA_OS_WIRE_METHODS.CANONICAL : value;\n}\n\n/**\n * Gets a human-readable description for a verification method\n */\nexport function getVerificationMethodDescription(method: VerificationMethod): string {\n // Normalize the handshake alias pair to canonical FIRST, so only the\n // canonical case is listed here; the legacy-to-canonical map lives solely in\n // `normalizeHandshakeMethod`.\n switch (normalizeHandshakeMethod(method)) {\n case 'signature':\n return 'HTTP Signature Verification';\n case 'pattern':\n return 'User-Agent Pattern Matching';\n case 'behavioral':\n return 'Behavioral Analysis';\n case 'network':\n return 'Network-based Detection';\n case KYA_OS_HANDSHAKE_METHODS.CANONICAL:\n return 'MCP Handshake Detection';\n case 'error':\n return 'Detection Error';\n case 'none':\n default:\n return 'No Verification';\n }\n}\n\n/**\n * Gets the reliability/confidence modifier for a verification method\n * Higher values indicate more reliable verification methods\n */\nexport function getVerificationReliability(method: VerificationMethod): number {\n // Normalize the handshake alias pair to canonical FIRST (see above).\n switch (normalizeHandshakeMethod(method)) {\n case 'signature':\n return 1.0; // Highest reliability\n case KYA_OS_HANDSHAKE_METHODS.CANONICAL:\n return 0.95;\n case 'behavioral':\n return 0.8;\n case 'network':\n return 0.6;\n case 'pattern':\n return 0.5;\n case 'none':\n return 0.3;\n case 'error':\n default:\n return 0.1; // Lowest reliability\n }\n}\n\n/**\n * Determines if a verification method indicates high confidence detection\n */\nexport function isHighConfidenceVerification(method: VerificationMethod): boolean {\n // Dual-accept via the shared predicate (legacy + canonical handshake).\n return method === 'signature' || isKyaOsHandshakeMethod(method);\n}\n\n/**\n * Maps verification method to appropriate risk level\n */\nexport function getVerificationRiskLevel(\n method: VerificationMethod,\n confidence: number\n): 'low' | 'medium' | 'high' {\n if (method === 'signature') {\n return 'low'; // Signatures are hard to forge\n }\n\n // Dual-accept via the shared predicate (legacy + canonical handshake).\n if (isKyaOsHandshakeMethod(method)) {\n return 'low'; // MCP handshakes are reliable\n }\n\n if (confidence >= 0.9) {\n return method === 'behavioral' ? 'medium' : 'high';\n }\n\n if (confidence >= 0.7) {\n return 'medium';\n }\n\n return 'high'; // Low confidence = high risk of false positive\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,2BAA2B;;CAEtC,WAAW;;CAEX,QAAQ;AACV;AAEA,MAAa,sBAAsB;;CAEjC,WAAW;;CAEX,QAAQ;AACV;;AAGA,SAAgB,uBAAuB,OAA2C;CAChF,OAAO,UAAU,yBAAyB,UAAU,UAAU,yBAAyB;AACzF;;AAGA,SAAgB,kBAAkB,OAA2C;CAC3E,OAAO,UAAU,oBAAoB,UAAU,UAAU,oBAAoB;AAC/E;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,yBACd,OAC+C;CAC/C,OAAO,uBAAuB,KAAK,IAAI,yBAAyB,YAAY;AAC9E;;;;;;;;;;AAWA,SAAgB,oBACd,OAC0C;CAC1C,OAAO,kBAAkB,KAAK,IAAI,oBAAoB,YAAY;AACpE;;;;AAKA,SAAgB,iCAAiC,QAAoC;CAInF,QAAQ,yBAAyB,MAAM,GAAvC;EACE,KAAK,aACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,yBAAyB,WAC5B,OAAO;EACT,KAAK,SACH,OAAO;EAET,SACE,OAAO;CACX;AACF;;;;;AAMA,SAAgB,2BAA2B,QAAoC;CAE7E,QAAQ,yBAAyB,MAAM,GAAvC;EACE,KAAK,aACH,OAAO;EACT,KAAK,yBAAyB,WAC5B,OAAO;EACT,KAAK,cACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,QACH,OAAO;EAET,SACE,OAAO;CACX;AACF;;;;AAKA,SAAgB,6BAA6B,QAAqC;CAEhF,OAAO,WAAW,eAAe,uBAAuB,MAAM;AAChE;;;;AAKA,SAAgB,yBACd,QACA,YAC2B;CAC3B,IAAI,WAAW,aACb,OAAO;CAIT,IAAI,uBAAuB,MAAM,GAC/B,OAAO;CAGT,IAAI,cAAc,IAChB,OAAO,WAAW,eAAe,WAAW;CAG9C,IAAI,cAAc,IAChB,OAAO;CAGT,OAAO;AACT"}
@@ -0,0 +1,101 @@
1
+ [
2
+ {
3
+ "name": "direct ignores forged forwarding with socket provenance",
4
+ "headers": {
5
+ "x-forwarded-for": "6.6.6.6"
6
+ },
7
+ "directAddress": "192.0.2.10",
8
+ "policy": {
9
+ "platform": "direct"
10
+ },
11
+ "expected": {
12
+ "ip": "192.0.2.10",
13
+ "observedClientAddress": "192.0.2.10",
14
+ "source": "socket",
15
+ "trusted": true,
16
+ "status": "observed",
17
+ "reason": "direct-peer"
18
+ }
19
+ },
20
+ {
21
+ "name": "proxy configuration alone never authenticates a direct caller",
22
+ "headers": {
23
+ "x-forwarded-for": "6.6.6.6"
24
+ },
25
+ "directAddress": "198.51.100.1",
26
+ "trustedPeer": "192.0.2.10",
27
+ "policy": {
28
+ "platform": "trusted-proxy",
29
+ "trustedHops": 0
30
+ },
31
+ "expected": {
32
+ "ip": null,
33
+ "observedClientAddress": null,
34
+ "source": "none",
35
+ "trusted": false,
36
+ "status": "unavailable",
37
+ "reason": "untrusted-peer"
38
+ }
39
+ },
40
+ {
41
+ "name": "exact authenticated receiving-side proxy chain",
42
+ "headers": {
43
+ "x-forwarded-for": "2001:db8::1,192.0.2.1"
44
+ },
45
+ "directAddress": "192.0.2.10",
46
+ "trustedPeer": "192.0.2.10",
47
+ "policy": {
48
+ "platform": "trusted-proxy",
49
+ "trustedHops": 1
50
+ },
51
+ "expected": {
52
+ "ip": "2001:db8::1",
53
+ "observedClientAddress": "2001:db8::1",
54
+ "source": "x-forwarded-for",
55
+ "trusted": true,
56
+ "status": "observed",
57
+ "reason": "authenticated-proxy"
58
+ }
59
+ },
60
+ {
61
+ "name": "extra attacker-controlled prefix rejects the entire observation",
62
+ "headers": {
63
+ "x-forwarded-for": "6.6.6.6,203.0.113.1,192.0.2.1"
64
+ },
65
+ "directAddress": "192.0.2.10",
66
+ "trustedPeer": "192.0.2.10",
67
+ "policy": {
68
+ "platform": "trusted-proxy",
69
+ "trustedHops": 1
70
+ },
71
+ "expected": {
72
+ "ip": null,
73
+ "observedClientAddress": null,
74
+ "source": "none",
75
+ "trusted": false,
76
+ "status": "unavailable",
77
+ "reason": "invalid-chain"
78
+ }
79
+ },
80
+ {
81
+ "name": "authenticated pseudo IPv4 overwrite preserves native IPv6",
82
+ "headers": {
83
+ "cf-connecting-ip": "240.1.2.3",
84
+ "cf-connecting-ipv6": "2001:db8::1"
85
+ },
86
+ "directAddress": "192.0.2.10",
87
+ "trustedPeer": "192.0.2.10",
88
+ "policy": {
89
+ "platform": "cloudflare",
90
+ "pseudoIpv4": "overwrite"
91
+ },
92
+ "expected": {
93
+ "ip": "2001:db8::1",
94
+ "observedClientAddress": "2001:db8::1",
95
+ "source": "cf-connecting-ipv6",
96
+ "trusted": true,
97
+ "status": "observed",
98
+ "reason": "authenticated-proxy"
99
+ }
100
+ }
101
+ ]