@kya-os/checkpoint-shared 1.6.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 (222) 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-BuChqmH5.d.mts → browser-posture-5fPrsxx7.d.mts} +2 -2
  18. package/dist/{browser-posture-BuChqmH5.d.mts.map → browser-posture-5fPrsxx7.d.mts.map} +1 -1
  19. package/dist/{browser-posture-DIaVLuW3.d.ts → browser-posture-CCR1kh5e.d.ts} +2 -2
  20. package/dist/{browser-posture-DIaVLuW3.d.ts.map → browser-posture-CCR1kh5e.d.ts.map} +1 -1
  21. package/dist/browser-posture-cookie.js +1 -1
  22. package/dist/browser-posture-cookie.mjs +1 -1
  23. package/dist/browser-posture-cookie.mjs.map +1 -1
  24. package/dist/browser-posture-proof.d.mts +16 -2
  25. package/dist/browser-posture-proof.d.mts.map +1 -1
  26. package/dist/browser-posture-proof.d.ts +16 -2
  27. package/dist/browser-posture-proof.d.ts.map +1 -1
  28. package/dist/browser-posture-proof.js +114 -17
  29. package/dist/browser-posture-proof.mjs +112 -17
  30. package/dist/browser-posture-proof.mjs.map +1 -1
  31. package/dist/browser-posture.d.mts +1 -1
  32. package/dist/browser-posture.d.ts +1 -1
  33. package/dist/browser-posture.js +6 -5
  34. package/dist/browser-posture.mjs +4 -3
  35. package/dist/browser-posture.mjs.map +1 -1
  36. package/dist/browser.d.mts +25 -4
  37. package/dist/browser.d.mts.map +1 -1
  38. package/dist/browser.d.ts +25 -4
  39. package/dist/browser.d.ts.map +1 -1
  40. package/dist/browser.js +1 -1
  41. package/dist/browser.mjs +1 -1
  42. package/dist/browser.mjs.map +1 -1
  43. package/dist/canonical-signer/index.d.mts.map +1 -1
  44. package/dist/canonical-signer/index.d.ts.map +1 -1
  45. package/dist/canonical-signer/index.js +116 -79
  46. package/dist/canonical-signer/index.mjs +117 -52
  47. package/dist/canonical-signer/index.mjs.map +1 -1
  48. package/dist/clearance.d.mts +1 -1
  49. package/dist/clearance.d.ts +1 -1
  50. package/dist/clearance.js +2 -2
  51. package/dist/clearance.mjs +2 -2
  52. package/dist/client-ip-B7w-uHfS.d.mts +55 -0
  53. package/dist/client-ip-B7w-uHfS.d.mts.map +1 -0
  54. package/dist/client-ip-B7w-uHfS.d.ts +55 -0
  55. package/dist/client-ip-B7w-uHfS.d.ts.map +1 -0
  56. package/dist/{client-ip-CW6pRyLf.js → client-ip-B8wFzJ5f.js} +117 -7
  57. package/dist/{client-ip-B2Xeo-GK.mjs → client-ip-DIJyr6px.mjs} +113 -9
  58. package/dist/client-ip-DIJyr6px.mjs.map +1 -0
  59. package/dist/client-ip.d.mts +2 -0
  60. package/dist/client-ip.d.ts +2 -0
  61. package/dist/client-ip.js +8 -0
  62. package/dist/client-ip.mjs +3 -0
  63. package/dist/detection-reason-mapping-B9RSkOs8.js +277 -0
  64. package/dist/detection-reason-mapping-BGymWIPl.mjs +249 -0
  65. package/dist/detection-reason-mapping-BGymWIPl.mjs.map +1 -0
  66. package/dist/detection-reason-mapping-CQexNvR7.d.mts +52 -0
  67. package/dist/detection-reason-mapping-CQexNvR7.d.mts.map +1 -0
  68. package/dist/detection-reason-mapping-CQexNvR7.d.ts +52 -0
  69. package/dist/detection-reason-mapping-CQexNvR7.d.ts.map +1 -0
  70. package/dist/engine-enforcing-AYEcgNsb.js +39 -0
  71. package/dist/engine-enforcing-B5eNfCpG.mjs +29 -0
  72. package/dist/engine-enforcing-B5eNfCpG.mjs.map +1 -0
  73. package/dist/engine-enforcing-DiOclGqf.d.mts +11 -0
  74. package/dist/engine-enforcing-DiOclGqf.d.mts.map +1 -0
  75. package/dist/engine-enforcing-DiOclGqf.d.ts +11 -0
  76. package/dist/engine-enforcing-DiOclGqf.d.ts.map +1 -0
  77. package/dist/engine-info.d.mts +2 -0
  78. package/dist/engine-info.d.ts +2 -0
  79. package/dist/engine-info.js +4 -0
  80. package/dist/engine-info.mjs +3 -0
  81. package/dist/errors/index.d.mts +5 -0
  82. package/dist/errors/index.d.mts.map +1 -1
  83. package/dist/errors/index.d.ts +5 -0
  84. package/dist/errors/index.d.ts.map +1 -1
  85. package/dist/errors/index.js +23 -4
  86. package/dist/errors/index.mjs +23 -4
  87. package/dist/errors/index.mjs.map +1 -1
  88. package/dist/{external-B7WI9FyQ.d.ts → external-m3Kmafwj.d.mts} +2 -2
  89. package/dist/{external-B7WI9FyQ.d.mts.map → external-m3Kmafwj.d.mts.map} +1 -1
  90. package/dist/{external-B7WI9FyQ.d.mts → external-m3Kmafwj.d.ts} +2 -2
  91. package/dist/{external-B7WI9FyQ.d.ts.map → external-m3Kmafwj.d.ts.map} +1 -1
  92. package/dist/fetcher-CivUCbhL.d.ts +44 -0
  93. package/dist/fetcher-CivUCbhL.d.ts.map +1 -0
  94. package/dist/fetcher-cXQsbm6s.d.mts +44 -0
  95. package/dist/fetcher-cXQsbm6s.d.mts.map +1 -0
  96. package/dist/gateway-client-ip.d.mts +1 -1
  97. package/dist/gateway-client-ip.d.ts +1 -1
  98. package/dist/gateway-client-ip.js +2 -2
  99. package/dist/gateway-client-ip.mjs +2 -2
  100. package/dist/host-adapter/index.d.mts +2 -0
  101. package/dist/host-adapter/index.d.ts +2 -0
  102. package/dist/host-adapter/index.js +24 -0
  103. package/dist/host-adapter/index.mjs +3 -0
  104. package/dist/host-adapter-0F8EpbD6.js +753 -0
  105. package/dist/host-adapter-DHyISsIf.mjs +593 -0
  106. package/dist/host-adapter-DHyISsIf.mjs.map +1 -0
  107. package/dist/index-B3cHxr3O.d.mts +156 -0
  108. package/dist/index-B3cHxr3O.d.mts.map +1 -0
  109. package/dist/index-CXbOY7gB.d.ts +156 -0
  110. package/dist/index-CXbOY7gB.d.ts.map +1 -0
  111. package/dist/index.d.mts +6997 -12170
  112. package/dist/index.d.mts.map +1 -1
  113. package/dist/index.d.ts +6997 -12170
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +2510 -8893
  116. package/dist/index.mjs +2366 -8534
  117. package/dist/index.mjs.map +1 -1
  118. package/dist/kya-http-error-codes-7ewV5RuK.d.mts +29 -0
  119. package/dist/kya-http-error-codes-7ewV5RuK.d.mts.map +1 -0
  120. package/dist/kya-http-error-codes-7ewV5RuK.d.ts +29 -0
  121. package/dist/kya-http-error-codes-7ewV5RuK.d.ts.map +1 -0
  122. package/dist/kya-http-error-codes-C2JiWPsi.mjs +73 -0
  123. package/dist/kya-http-error-codes-C2JiWPsi.mjs.map +1 -0
  124. package/dist/kya-http-error-codes-UYb1zpGM.js +83 -0
  125. package/dist/kya-http.d.mts +3 -0
  126. package/dist/kya-http.d.ts +3 -0
  127. package/dist/kya-http.js +19 -0
  128. package/dist/kya-http.mjs +5 -0
  129. package/dist/mcpi/dashboard-config/index.d.mts.map +1 -1
  130. package/dist/mcpi/dashboard-config/index.d.ts.map +1 -1
  131. package/dist/mcpi/status-list/index.d.mts +72 -0
  132. package/dist/mcpi/status-list/index.d.mts.map +1 -0
  133. package/dist/mcpi/status-list/index.d.ts +72 -0
  134. package/dist/mcpi/status-list/index.d.ts.map +1 -0
  135. package/dist/mcpi/status-list/index.js +703 -0
  136. package/dist/mcpi/status-list/index.mjs +684 -0
  137. package/dist/mcpi/status-list/index.mjs.map +1 -0
  138. package/dist/patterns-B2r7M9wR.js +243 -0
  139. package/dist/patterns-B7dQoeE3.mjs +173 -0
  140. package/dist/patterns-B7dQoeE3.mjs.map +1 -0
  141. package/dist/patterns-Bp40cwh2.d.mts +110 -0
  142. package/dist/patterns-Bp40cwh2.d.mts.map +1 -0
  143. package/dist/patterns-Bp40cwh2.d.ts +110 -0
  144. package/dist/patterns-Bp40cwh2.d.ts.map +1 -0
  145. package/dist/patterns.d.mts +2 -0
  146. package/dist/patterns.d.ts +2 -0
  147. package/dist/patterns.js +15 -0
  148. package/dist/patterns.mjs +3 -0
  149. package/dist/policy/enforcement.d.mts +3 -0
  150. package/dist/policy/enforcement.d.ts +3 -0
  151. package/dist/policy/enforcement.js +21 -0
  152. package/dist/policy/enforcement.mjs +4 -0
  153. package/dist/policy/fetcher.d.mts +2 -0
  154. package/dist/policy/fetcher.d.ts +2 -0
  155. package/dist/policy/fetcher.js +240 -0
  156. package/dist/policy/fetcher.mjs +238 -0
  157. package/dist/policy/fetcher.mjs.map +1 -0
  158. package/dist/policy/schemas.d.mts +3 -0
  159. package/dist/policy/schemas.d.ts +3 -0
  160. package/dist/policy/schemas.js +27 -0
  161. package/dist/policy/schemas.mjs +4 -0
  162. package/dist/{posture-origins-Pn-ii-Pp.mjs → posture-origins-Ci6k4Zh1.js} +24 -173
  163. package/dist/{posture-origins-LFkX80oF.js → posture-origins-DGyS4Vuk.mjs} +2 -267
  164. package/dist/posture-origins-DGyS4Vuk.mjs.map +1 -0
  165. package/dist/{project-verification-key-BccT12tQ.js → project-verification-key-B-L3D2nC.js} +1 -1
  166. package/dist/{project-verification-key-66N4edKn.mjs → project-verification-key-CWXdu3-n.mjs} +2 -2
  167. package/dist/{project-verification-key-66N4edKn.mjs.map → project-verification-key-CWXdu3-n.mjs.map} +1 -1
  168. package/dist/provider-registry.d.mts +2 -0
  169. package/dist/provider-registry.d.ts +2 -0
  170. package/dist/provider-registry.js +51 -0
  171. package/dist/provider-registry.mjs +3 -0
  172. package/dist/reason-codes.d.mts +2 -0
  173. package/dist/reason-codes.d.ts +2 -0
  174. package/dist/reason-codes.js +8 -0
  175. package/dist/reason-codes.mjs +3 -0
  176. package/dist/registered-sid-26hNxp6t.mjs +151 -0
  177. package/dist/registered-sid-26hNxp6t.mjs.map +1 -0
  178. package/dist/registered-sid-D6KCaT1E.d.mts +33 -0
  179. package/dist/registered-sid-D6KCaT1E.d.mts.map +1 -0
  180. package/dist/registered-sid-D6KCaT1E.d.ts +33 -0
  181. package/dist/registered-sid-D6KCaT1E.d.ts.map +1 -0
  182. package/dist/registered-sid-DVGTSH0L.js +185 -0
  183. package/dist/ruleset-hash-Cmv8MSO5.js +34 -0
  184. package/dist/ruleset-hash-IRN5eI9H.d.mts +5 -0
  185. package/dist/ruleset-hash-IRN5eI9H.d.mts.map +1 -0
  186. package/dist/ruleset-hash-IRN5eI9H.d.ts +5 -0
  187. package/dist/ruleset-hash-IRN5eI9H.d.ts.map +1 -0
  188. package/dist/ruleset-hash-QQIaLuPi.mjs +30 -0
  189. package/dist/ruleset-hash-QQIaLuPi.mjs.map +1 -0
  190. package/dist/schemas-02CI7jgm.d.mts +535 -0
  191. package/dist/schemas-02CI7jgm.d.mts.map +1 -0
  192. package/dist/{schemas-YhagYDx_.js → schemas-BlScS1it.js} +0 -20
  193. package/dist/schemas-C_3C72SR.d.ts +535 -0
  194. package/dist/schemas-C_3C72SR.d.ts.map +1 -0
  195. package/dist/schemas-Cm4C4Z5G.js +703 -0
  196. package/dist/schemas-DPIT8usF.mjs +525 -0
  197. package/dist/schemas-DPIT8usF.mjs.map +1 -0
  198. package/dist/{schemas-7qodsG-Z.mjs → schemas-IHAhH3gV.mjs} +2 -16
  199. package/dist/schemas-IHAhH3gV.mjs.map +1 -0
  200. package/dist/step-up-BK0oBi11.mjs +1563 -0
  201. package/dist/step-up-BK0oBi11.mjs.map +1 -0
  202. package/dist/step-up-Bp8RAQwv.js +1759 -0
  203. package/dist/step-up-Bz12gYKT.d.mts +130 -0
  204. package/dist/step-up-Bz12gYKT.d.mts.map +1 -0
  205. package/dist/step-up-Bz12gYKT.d.ts +130 -0
  206. package/dist/step-up-Bz12gYKT.d.ts.map +1 -0
  207. package/dist/test-fixtures/index.d.mts +4 -4
  208. package/dist/test-fixtures/index.d.mts.map +1 -1
  209. package/dist/test-fixtures/index.d.ts +4 -4
  210. package/dist/test-fixtures/index.d.ts.map +1 -1
  211. package/dist/test-fixtures/index.js +4 -4
  212. package/dist/test-fixtures/index.mjs +4 -4
  213. package/dist/test-fixtures/index.mjs.map +1 -1
  214. package/dist/verification-BAw9N8Pt.js +181 -0
  215. package/dist/verification-Cvvv86TT.mjs +123 -0
  216. package/dist/verification-Cvvv86TT.mjs.map +1 -0
  217. package/fixtures/client-ip-resolution.n01.json +101 -0
  218. package/fixtures/reviewer-grant-revocation.v1.json +53 -81
  219. package/package.json +59 -2
  220. package/dist/client-ip-B2Xeo-GK.mjs.map +0 -1
  221. package/dist/posture-origins-Pn-ii-Pp.mjs.map +0 -1
  222. package/dist/schemas-7qodsG-Z.mjs.map +0 -1
@@ -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
+ ]