@kya-os/mcp-i-cloudflare 1.18.0 → 1.18.2

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 (256) hide show
  1. package/README.md +273 -54
  2. package/dist/adapter.d.ts +3 -17
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/adapter.js +30 -477
  5. package/dist/adapter.js.map +1 -1
  6. package/dist/agent.d.ts +59 -35
  7. package/dist/agent.d.ts.map +1 -1
  8. package/dist/agent.js +383 -406
  9. package/dist/agent.js.map +1 -1
  10. package/dist/app.d.ts.map +1 -1
  11. package/dist/app.js +150 -94
  12. package/dist/app.js.map +1 -1
  13. package/dist/audit/deployment-binding.d.ts +16 -16
  14. package/dist/authority-outcome.d.ts +110 -0
  15. package/dist/authority-outcome.d.ts.map +1 -0
  16. package/dist/authority-outcome.js +154 -0
  17. package/dist/authority-outcome.js.map +1 -0
  18. package/dist/config.d.ts +8 -77
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/config.js +0 -83
  21. package/dist/config.js.map +1 -1
  22. package/dist/delegation-http/bearer-retry.d.ts +84 -32
  23. package/dist/delegation-http/bearer-retry.d.ts.map +1 -1
  24. package/dist/delegation-http/bearer-retry.js +124 -139
  25. package/dist/delegation-http/bearer-retry.js.map +1 -1
  26. package/dist/delegation-http/connect-gate.d.ts +47 -0
  27. package/dist/delegation-http/connect-gate.d.ts.map +1 -0
  28. package/dist/delegation-http/connect-gate.js +104 -0
  29. package/dist/delegation-http/connect-gate.js.map +1 -0
  30. package/dist/delegation-http/constants.d.ts +4 -49
  31. package/dist/delegation-http/constants.d.ts.map +1 -1
  32. package/dist/delegation-http/constants.js +4 -58
  33. package/dist/delegation-http/constants.js.map +1 -1
  34. package/dist/delegation-http/issuer-binding.d.ts +26 -0
  35. package/dist/delegation-http/issuer-binding.d.ts.map +1 -0
  36. package/dist/delegation-http/issuer-binding.js +51 -0
  37. package/dist/delegation-http/issuer-binding.js.map +1 -0
  38. package/dist/delegation-http/lazy-auth-gate.d.ts +88 -0
  39. package/dist/delegation-http/lazy-auth-gate.d.ts.map +1 -0
  40. package/dist/delegation-http/lazy-auth-gate.js +203 -0
  41. package/dist/delegation-http/lazy-auth-gate.js.map +1 -0
  42. package/dist/delegation-http/native-challenge.d.ts +52 -0
  43. package/dist/delegation-http/native-challenge.d.ts.map +1 -0
  44. package/dist/delegation-http/native-challenge.js +124 -0
  45. package/dist/delegation-http/native-challenge.js.map +1 -0
  46. package/dist/delegation-http/native-consent-redirect.d.ts +21 -0
  47. package/dist/delegation-http/native-consent-redirect.d.ts.map +1 -0
  48. package/dist/delegation-http/native-consent-redirect.js +43 -0
  49. package/dist/delegation-http/native-consent-redirect.js.map +1 -0
  50. package/dist/delegation-http/native-http.d.ts +1 -86
  51. package/dist/delegation-http/native-http.d.ts.map +1 -1
  52. package/dist/delegation-http/native-http.js +2 -130
  53. package/dist/delegation-http/native-http.js.map +1 -1
  54. package/dist/delegation-http/native-oauth-state-do.d.ts +13 -35
  55. package/dist/delegation-http/native-oauth-state-do.d.ts.map +1 -1
  56. package/dist/delegation-http/native-oauth-state-do.js +10 -165
  57. package/dist/delegation-http/native-oauth-state-do.js.map +1 -1
  58. package/dist/delegation-http/protected-resource.d.ts +37 -0
  59. package/dist/delegation-http/protected-resource.d.ts.map +1 -0
  60. package/dist/delegation-http/protected-resource.js +43 -0
  61. package/dist/delegation-http/protected-resource.js.map +1 -0
  62. package/dist/delegation-http/request-proof.d.ts +20 -0
  63. package/dist/delegation-http/request-proof.d.ts.map +1 -0
  64. package/dist/delegation-http/request-proof.js +29 -0
  65. package/dist/delegation-http/request-proof.js.map +1 -0
  66. package/dist/delegation-http/sid.d.ts +4 -12
  67. package/dist/delegation-http/sid.d.ts.map +1 -1
  68. package/dist/delegation-http/sid.js +4 -19
  69. package/dist/delegation-http/sid.js.map +1 -1
  70. package/dist/delegation-http/well-known-capability.d.ts +8 -12
  71. package/dist/delegation-http/well-known-capability.d.ts.map +1 -1
  72. package/dist/delegation-http/well-known-capability.js +9 -18
  73. package/dist/delegation-http/well-known-capability.js.map +1 -1
  74. package/dist/helpers/env-mapper.d.ts.map +1 -1
  75. package/dist/helpers/env-mapper.js +7 -29
  76. package/dist/helpers/env-mapper.js.map +1 -1
  77. package/dist/index.d.ts +2 -4
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +11 -8
  80. package/dist/index.js.map +1 -1
  81. package/dist/proof-generator.d.ts +24 -17
  82. package/dist/proof-generator.d.ts.map +1 -1
  83. package/dist/proof-generator.js +42 -56
  84. package/dist/proof-generator.js.map +1 -1
  85. package/dist/runtime/oauth-handler.d.ts +1 -1
  86. package/dist/runtime/oauth-handler.d.ts.map +1 -1
  87. package/dist/runtime/oauth-handler.js +15 -30
  88. package/dist/runtime/oauth-handler.js.map +1 -1
  89. package/dist/runtime.d.ts +34 -10
  90. package/dist/runtime.d.ts.map +1 -1
  91. package/dist/runtime.js +54 -12
  92. package/dist/runtime.js.map +1 -1
  93. package/dist/security/admission-refusal.d.ts +3 -3
  94. package/dist/security/admission-refusal.d.ts.map +1 -1
  95. package/dist/security/admission-refusal.js +14 -6
  96. package/dist/security/admission-refusal.js.map +1 -1
  97. package/dist/security/holder-binding.d.ts +34 -0
  98. package/dist/security/holder-binding.d.ts.map +1 -0
  99. package/dist/security/holder-binding.js +75 -0
  100. package/dist/security/holder-binding.js.map +1 -0
  101. package/dist/security/mcp-admission.d.ts +29 -1
  102. package/dist/security/mcp-admission.d.ts.map +1 -1
  103. package/dist/security/mcp-admission.js +78 -12
  104. package/dist/security/mcp-admission.js.map +1 -1
  105. package/dist/security/native-holder-admission.d.ts +39 -0
  106. package/dist/security/native-holder-admission.d.ts.map +1 -0
  107. package/dist/security/native-holder-admission.js +65 -0
  108. package/dist/security/native-holder-admission.js.map +1 -0
  109. package/dist/security/outcome-proof.d.ts +39 -0
  110. package/dist/security/outcome-proof.d.ts.map +1 -0
  111. package/dist/security/outcome-proof.js +54 -0
  112. package/dist/security/outcome-proof.js.map +1 -0
  113. package/dist/security/request-nonce-store.d.ts +43 -0
  114. package/dist/security/request-nonce-store.d.ts.map +1 -0
  115. package/dist/security/request-nonce-store.js +129 -0
  116. package/dist/security/request-nonce-store.js.map +1 -0
  117. package/dist/security/routed-request.d.ts +41 -0
  118. package/dist/security/routed-request.d.ts.map +1 -0
  119. package/dist/security/routed-request.js +86 -0
  120. package/dist/security/routed-request.js.map +1 -0
  121. package/dist/security/sign-in-amr.d.ts +23 -0
  122. package/dist/security/sign-in-amr.d.ts.map +1 -0
  123. package/dist/security/sign-in-amr.js +44 -0
  124. package/dist/security/sign-in-amr.js.map +1 -0
  125. package/dist/services/approval-route.d.ts +3 -2
  126. package/dist/services/approval-route.d.ts.map +1 -1
  127. package/dist/services/approval-route.js.map +1 -1
  128. package/dist/services/checkpoint-decision.d.ts +56 -0
  129. package/dist/services/checkpoint-decision.d.ts.map +1 -0
  130. package/dist/services/checkpoint-decision.js +109 -0
  131. package/dist/services/checkpoint-decision.js.map +1 -0
  132. package/dist/services/consent-page-renderer.d.ts.map +1 -1
  133. package/dist/services/consent-page-renderer.js +2 -3
  134. package/dist/services/consent-page-renderer.js.map +1 -1
  135. package/dist/services/consent.service.d.ts +11 -49
  136. package/dist/services/consent.service.d.ts.map +1 -1
  137. package/dist/services/consent.service.js +81 -307
  138. package/dist/services/consent.service.js.map +1 -1
  139. package/dist/services/credential-auth.handler.d.ts.map +1 -1
  140. package/dist/services/credential-auth.handler.js +2 -8
  141. package/dist/services/credential-auth.handler.js.map +1 -1
  142. package/dist/services/delegation-authority.d.ts +53 -0
  143. package/dist/services/delegation-authority.d.ts.map +1 -0
  144. package/dist/services/delegation-authority.js +130 -0
  145. package/dist/services/delegation-authority.js.map +1 -0
  146. package/dist/services/delegation-trust.d.ts +35 -64
  147. package/dist/services/delegation-trust.d.ts.map +1 -1
  148. package/dist/services/delegation-trust.js +98 -279
  149. package/dist/services/delegation-trust.js.map +1 -1
  150. package/dist/services/delegation.service.d.ts +83 -105
  151. package/dist/services/delegation.service.d.ts.map +1 -1
  152. package/dist/services/delegation.service.js +166 -518
  153. package/dist/services/delegation.service.js.map +1 -1
  154. package/dist/services/idp-token-storage.d.ts +32 -12
  155. package/dist/services/idp-token-storage.d.ts.map +1 -1
  156. package/dist/services/idp-token-storage.js +79 -36
  157. package/dist/services/idp-token-storage.js.map +1 -1
  158. package/dist/services/issuer-keys.d.ts +55 -0
  159. package/dist/services/issuer-keys.d.ts.map +1 -0
  160. package/dist/services/issuer-keys.js +184 -0
  161. package/dist/services/issuer-keys.js.map +1 -0
  162. package/dist/services/oauth-security.service.d.ts +17 -1
  163. package/dist/services/oauth-security.service.d.ts.map +1 -1
  164. package/dist/services/oauth-security.service.js +29 -10
  165. package/dist/services/oauth-security.service.js.map +1 -1
  166. package/dist/services/resource-audience.d.ts +12 -9
  167. package/dist/services/resource-audience.d.ts.map +1 -1
  168. package/dist/services/resource-audience.js +12 -9
  169. package/dist/services/resource-audience.js.map +1 -1
  170. package/dist/services/unenforceable-tool-protection.d.ts +32 -0
  171. package/dist/services/unenforceable-tool-protection.d.ts.map +1 -0
  172. package/dist/services/unenforceable-tool-protection.js +90 -0
  173. package/dist/services/unenforceable-tool-protection.js.map +1 -0
  174. package/dist/services/upstream-fetch.d.ts +14 -0
  175. package/dist/services/upstream-fetch.d.ts.map +1 -0
  176. package/dist/services/upstream-fetch.js +56 -0
  177. package/dist/services/upstream-fetch.js.map +1 -0
  178. package/dist/types.d.ts +5 -18
  179. package/dist/types.d.ts.map +1 -1
  180. package/dist/utils/tool-security-schemes.d.ts +65 -0
  181. package/dist/utils/tool-security-schemes.d.ts.map +1 -0
  182. package/dist/utils/tool-security-schemes.js +168 -0
  183. package/dist/utils/tool-security-schemes.js.map +1 -0
  184. package/package.json +4 -5
  185. package/dist/delegation-http/anchor-do.d.ts +0 -84
  186. package/dist/delegation-http/anchor-do.d.ts.map +0 -1
  187. package/dist/delegation-http/anchor-do.js +0 -412
  188. package/dist/delegation-http/anchor-do.js.map +0 -1
  189. package/dist/delegation-http/anchor-registration-validate.d.ts +0 -61
  190. package/dist/delegation-http/anchor-registration-validate.d.ts.map +0 -1
  191. package/dist/delegation-http/anchor-registration-validate.js +0 -191
  192. package/dist/delegation-http/anchor-registration-validate.js.map +0 -1
  193. package/dist/delegation-http/anchor-registration.d.ts +0 -62
  194. package/dist/delegation-http/anchor-registration.d.ts.map +0 -1
  195. package/dist/delegation-http/anchor-registration.js +0 -337
  196. package/dist/delegation-http/anchor-registration.js.map +0 -1
  197. package/dist/delegation-http/anchor-routing.d.ts +0 -20
  198. package/dist/delegation-http/anchor-routing.d.ts.map +0 -1
  199. package/dist/delegation-http/anchor-routing.js +0 -27
  200. package/dist/delegation-http/anchor-routing.js.map +0 -1
  201. package/dist/delegation-http/challenge-middleware.d.ts +0 -28
  202. package/dist/delegation-http/challenge-middleware.d.ts.map +0 -1
  203. package/dist/delegation-http/challenge-middleware.js +0 -190
  204. package/dist/delegation-http/challenge-middleware.js.map +0 -1
  205. package/dist/delegation-http/challenge.d.ts +0 -102
  206. package/dist/delegation-http/challenge.d.ts.map +0 -1
  207. package/dist/delegation-http/challenge.js +0 -223
  208. package/dist/delegation-http/challenge.js.map +0 -1
  209. package/dist/delegation-http/consent-anchor-bridge.d.ts +0 -70
  210. package/dist/delegation-http/consent-anchor-bridge.d.ts.map +0 -1
  211. package/dist/delegation-http/consent-anchor-bridge.js +0 -1130
  212. package/dist/delegation-http/consent-anchor-bridge.js.map +0 -1
  213. package/dist/delegation-http/consent-preparation-page.d.ts +0 -18
  214. package/dist/delegation-http/consent-preparation-page.d.ts.map +0 -1
  215. package/dist/delegation-http/consent-preparation-page.js +0 -172
  216. package/dist/delegation-http/consent-preparation-page.js.map +0 -1
  217. package/dist/delegation-http/credential-consent.d.ts +0 -149
  218. package/dist/delegation-http/credential-consent.d.ts.map +0 -1
  219. package/dist/delegation-http/credential-consent.js +0 -338
  220. package/dist/delegation-http/credential-consent.js.map +0 -1
  221. package/dist/delegation-http/native-capabilities.d.ts +0 -4
  222. package/dist/delegation-http/native-capabilities.d.ts.map +0 -1
  223. package/dist/delegation-http/native-capabilities.js +0 -53
  224. package/dist/delegation-http/native-capabilities.js.map +0 -1
  225. package/dist/delegation-http/native-oauth-state.d.ts +0 -28
  226. package/dist/delegation-http/native-oauth-state.d.ts.map +0 -1
  227. package/dist/delegation-http/native-oauth-state.js +0 -146
  228. package/dist/delegation-http/native-oauth-state.js.map +0 -1
  229. package/dist/delegation-http/native-oauth.d.ts +0 -26
  230. package/dist/delegation-http/native-oauth.d.ts.map +0 -1
  231. package/dist/delegation-http/native-oauth.js +0 -401
  232. package/dist/delegation-http/native-oauth.js.map +0 -1
  233. package/dist/delegation-http/native-pickup.d.ts +0 -20
  234. package/dist/delegation-http/native-pickup.d.ts.map +0 -1
  235. package/dist/delegation-http/native-pickup.js +0 -227
  236. package/dist/delegation-http/native-pickup.js.map +0 -1
  237. package/dist/delegation-http/pickup-routes.d.ts +0 -43
  238. package/dist/delegation-http/pickup-routes.d.ts.map +0 -1
  239. package/dist/delegation-http/pickup-routes.js +0 -166
  240. package/dist/delegation-http/pickup-routes.js.map +0 -1
  241. package/dist/delegation-http/register.d.ts +0 -26
  242. package/dist/delegation-http/register.d.ts.map +0 -1
  243. package/dist/delegation-http/register.js +0 -95
  244. package/dist/delegation-http/register.js.map +0 -1
  245. package/dist/delegation-http/registrar-auth.d.ts +0 -24
  246. package/dist/delegation-http/registrar-auth.d.ts.map +0 -1
  247. package/dist/delegation-http/registrar-auth.js +0 -61
  248. package/dist/delegation-http/registrar-auth.js.map +0 -1
  249. package/dist/delegation-http/remote-issuer.d.ts +0 -52
  250. package/dist/delegation-http/remote-issuer.d.ts.map +0 -1
  251. package/dist/delegation-http/remote-issuer.js +0 -324
  252. package/dist/delegation-http/remote-issuer.js.map +0 -1
  253. package/dist/delegation-http/types.d.ts +0 -116
  254. package/dist/delegation-http/types.d.ts.map +0 -1
  255. package/dist/delegation-http/types.js +0 -11
  256. package/dist/delegation-http/types.js.map +0 -1
@@ -0,0 +1,129 @@
1
+ /**
2
+ * The request-proof nonce store: one named `MCP_OBJECT` instance that every
3
+ * holder-admission check in a deployment consumes nonces from, so a signed
4
+ * call accepted once is refused everywhere after.
5
+ *
6
+ * One Durable Object instance serialises every consume, and the
7
+ * test-and-set runs inside a storage transaction, so two requests carrying
8
+ * the same nonce can never both be accepted. Any failure throws in the
9
+ * consumer, and the proof verifier turns a throw into a refusal.
10
+ *
11
+ * The card constants the retention depends on are read through the
12
+ * package's validated accessor on each consume, never at module load: in a
13
+ * bundle that holds the agent, esbuild initialises `@kya-os/mcp/card`
14
+ * lazily, so a value read at load can be undefined.
15
+ *
16
+ * @module @kya-os/mcp-i-cloudflare/security/request-nonce-store
17
+ */
18
+ import { PROOF_SUPPORT_UNAVAILABLE, getCardProofSupport, requestProofNonceRetentionSec, } from "./card-proof-support";
19
+ /** The one `MCP_OBJECT` instance that holds every nonce, across all sessions. */
20
+ export const REQUEST_NONCE_INSTANCE = "request-nonces";
21
+ export const REQUEST_NONCE_CONSUME_PATH = "/_internal/request-nonce/consume";
22
+ /**
23
+ * Accepted clock skew for request proofs. The card default is 5 s. The nonce
24
+ * retention follows from it: the proof lifetime, this skew on both sides and
25
+ * one second of rounding.
26
+ */
27
+ export const REQUEST_PROOF_SKEW_SEC = 30;
28
+ const REPLAYS_REFUSED_KEY = "request-nonce:replays-refused";
29
+ /** The retention the last consume applied. */
30
+ const RETENTION_SEC_KEY = "request-nonce:retention-sec";
31
+ /** Every nonce entry lives under this prefix; its value is its expiry (ms). */
32
+ const NONCE_PREFIX = "request-nonce:n:";
33
+ /** Where the expiry sweep resumes. */
34
+ const SWEEP_CURSOR_KEY = "request-nonce:sweep-cursor";
35
+ /** Entries each consume examines for expiry: bounded work per call. */
36
+ const SWEEP_BATCH = 16;
37
+ /** A consumer for the proof verifier, backed by the deployment's nonce instance. */
38
+ export function consumeFromRequestNonceStore(namespace) {
39
+ return async (nonce, did) => {
40
+ if (!namespace)
41
+ throw new Error("MCP_OBJECT binding is required");
42
+ const stub = namespace.get(namespace.idFromName(REQUEST_NONCE_INSTANCE));
43
+ const response = await stub.fetch(`https://request-nonces.internal${REQUEST_NONCE_CONSUME_PATH}`, {
44
+ method: "POST",
45
+ headers: { "Content-Type": "application/json" },
46
+ body: JSON.stringify({ did, nonce }),
47
+ });
48
+ if (!response.ok)
49
+ throw new Error("Request nonce store unavailable");
50
+ const { fresh } = (await response.json());
51
+ return fresh === true;
52
+ };
53
+ }
54
+ async function sha256Hex(value) {
55
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(value));
56
+ return [...new Uint8Array(digest)]
57
+ .map((byte) => byte.toString(16).padStart(2, "0"))
58
+ .join("");
59
+ }
60
+ /**
61
+ * Answer a consume inside the nonce instance: `{ fresh: true }` the first
62
+ * time a holder's nonce is seen within its retention, `{ fresh: false }`
63
+ * after. 400 for a malformed request, 503 when the card constants do not
64
+ * validate (the consumer then throws and the call is refused).
65
+ */
66
+ export async function handleRequestNonceConsume(storage, request, skewSec = REQUEST_PROOF_SKEW_SEC) {
67
+ let body;
68
+ try {
69
+ body = (await request.json());
70
+ }
71
+ catch {
72
+ return Response.json({ error: "invalid_request" }, { status: 400 });
73
+ }
74
+ const { did, nonce } = body ?? {};
75
+ if (typeof did !== "string" || typeof nonce !== "string" || !did || !nonce)
76
+ return Response.json({ error: "invalid_request" }, { status: 400 });
77
+ const support = await getCardProofSupport();
78
+ if (!support.ok)
79
+ return Response.json({ error: PROOF_SUPPORT_UNAVAILABLE }, { status: 503 });
80
+ const retentionSec = requestProofNonceRetentionSec(support.support, skewSec);
81
+ // Scoped by DID and nonce. Hashed so a long nonce cannot exceed the
82
+ // storage key limit.
83
+ const key = `${NONCE_PREFIX}${await sha256Hex(JSON.stringify([did, nonce]))}`;
84
+ const now = Date.now();
85
+ const fresh = await storage.transaction(async (txn) => {
86
+ await txn.put(RETENTION_SEC_KEY, retentionSec);
87
+ const expiresAt = await txn.get(key);
88
+ if (expiresAt !== undefined && expiresAt > now) {
89
+ const refused = (await txn.get(REPLAYS_REFUSED_KEY)) ?? 0;
90
+ await txn.put(REPLAYS_REFUSED_KEY, refused + 1);
91
+ return false;
92
+ }
93
+ await txn.put(key, now + retentionSec * 1000);
94
+ return true;
95
+ });
96
+ await sweepExpiredNonces(storage, now);
97
+ return Response.json({ fresh });
98
+ }
99
+ /**
100
+ * Delete expired nonce entries a few at a time, resuming where the last
101
+ * sweep stopped and wrapping at the end, so the instance's storage stays
102
+ * bounded by the traffic within one retention window.
103
+ */
104
+ async function sweepExpiredNonces(storage, now) {
105
+ const cursor = await storage.get(SWEEP_CURSOR_KEY);
106
+ const batch = await storage.list({
107
+ prefix: NONCE_PREFIX,
108
+ ...(cursor ? { startAfter: cursor } : {}),
109
+ limit: SWEEP_BATCH,
110
+ });
111
+ const expired = [...batch]
112
+ .filter(([, expiresAt]) => typeof expiresAt !== "number" || expiresAt <= now)
113
+ .map(([entry]) => entry);
114
+ if (expired.length)
115
+ await storage.delete(expired);
116
+ const last = [...batch.keys()].at(-1);
117
+ if (batch.size < SWEEP_BATCH || !last)
118
+ await storage.delete(SWEEP_CURSOR_KEY);
119
+ else
120
+ await storage.put(SWEEP_CURSOR_KEY, last);
121
+ }
122
+ /** Replays refused so far, and the retention the last consume applied. */
123
+ export async function requestNonceStats(storage) {
124
+ return {
125
+ replaysRefused: (await storage.get(REPLAYS_REFUSED_KEY)) ?? 0,
126
+ retentionSec: (await storage.get(RETENTION_SEC_KEY)) ?? null,
127
+ };
128
+ }
129
+ //# sourceMappingURL=request-nonce-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-nonce-store.js","sourceRoot":"","sources":["../../src/security/request-nonce-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAE9B,iFAAiF;AACjF,MA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* The Durable Object never sees the request the edge delivered: the worker
5
+ * (createMCPIApp) receives it and forwards a copy. Before forwarding, the
6
+ * worker deletes any client-supplied `X-MCP-Original-Origin` and sets it to
7
+ * the origin of the request URL it received (app.ts `injectOriginalOrigin`).
8
+ * That header is the only source of the routed host in the Durable Object;
9
+ * nothing else the client sends, such as `Host` or `X-Forwarded-Host`, is
10
+ * read. Without it, no host is known and every delegation is refused.
11
+ *
12
+ * The MCP transport hands each tools/call the forwarded request's headers
13
+ * (`extra.requestInfo.headers`); `runInRoutedRequest` scopes them to that one
14
+ * call, so concurrent calls never see each other's host or credential.
15
+ */
16
+ /** Set by the worker on every request it forwards to the Durable Object. */
17
+ export declare const ROUTED_ORIGIN_HEADER = "X-MCP-Original-Origin";
18
+ /** The forwarded request's headers, as the MCP transport passes them. */
19
+ export type ForwardedHeaders = Record<string, string | string[] | undefined>;
20
+ /** The host of an `http(s)` origin with no path, query or credentials. */
21
+ export declare function hostOfOrigin(origin: string | null): string | undefined;
22
+ /**
23
+ * Run `fn` with the routed host and the header-carried delegation of the
24
+ * forwarded request. A malformed or conflicting delegation carrier counts as
25
+ * none; the worker's bearer gate already refused it before forwarding.
26
+ */
27
+ export declare function runInRoutedRequest<T>(headers: ForwardedHeaders | undefined, fn: () => T): T;
28
+ /**
29
+ * Run `fn` for a request the worker itself received (no Durable Object hop):
30
+ * the routed host is that request URL's host.
31
+ */
32
+ export declare function runWithRoutedHost<T>(request: Request, fn: () => T): T;
33
+ /** The host this tools/call was routed for, or undefined (fail closed). */
34
+ export declare function getRoutedHost(): string | undefined;
35
+ /**
36
+ * The delegation this tools/call presented in its headers (`Authorization:
37
+ * Bearer` or `KYA-Delegation`). Unverified input, never an authorization
38
+ * result: the runtime's verifier still decides.
39
+ */
40
+ export declare function getRoutedHeaderDelegation(): string | undefined;
41
+ //# sourceMappingURL=routed-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routed-request.d.ts","sourceRoot":"","sources":["../../src/security/routed-request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,0BAA0B,CAAC;AAE5D,yEAAyE;AACzE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAwB7E,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAetE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,OAAO,EAAE,gBAAgB,GAAG,SAAS,EACrC,EAAE,EAAE,MAAM,CAAC,GACV,CAAC,CAcH;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAErE;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAElD;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,GAAG,SAAS,CAE9D"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * What the worker tells its Durable Object about the request it routed.
3
+ *
4
+ * The Durable Object never sees the request the edge delivered: the worker
5
+ * (createMCPIApp) receives it and forwards a copy. Before forwarding, the
6
+ * worker deletes any client-supplied `X-MCP-Original-Origin` and sets it to
7
+ * the origin of the request URL it received (app.ts `injectOriginalOrigin`).
8
+ * That header is the only source of the routed host in the Durable Object;
9
+ * nothing else the client sends, such as `Host` or `X-Forwarded-Host`, is
10
+ * read. Without it, no host is known and every delegation is refused.
11
+ *
12
+ * The MCP transport hands each tools/call the forwarded request's headers
13
+ * (`extra.requestInfo.headers`); `runInRoutedRequest` scopes them to that one
14
+ * call, so concurrent calls never see each other's host or credential.
15
+ */
16
+ import { AsyncLocalStorage } from "node:async_hooks";
17
+ import { InvalidDelegationPresentation, readHeaderDelegation, } from "./presented-delegation";
18
+ /** Set by the worker on every request it forwards to the Durable Object. */
19
+ export const ROUTED_ORIGIN_HEADER = "X-MCP-Original-Origin";
20
+ const routed = new AsyncLocalStorage();
21
+ /** One header value, case-insensitively; a repeated header counts as none. */
22
+ function single(headers, name) {
23
+ const matches = Object.entries(headers ?? {}).filter(([key, value]) => key.toLowerCase() === name.toLowerCase() && value !== undefined);
24
+ if (matches.length !== 1)
25
+ return null;
26
+ const value = matches[0][1];
27
+ if (Array.isArray(value))
28
+ return value.length === 1 ? value[0] : null;
29
+ return value ?? null;
30
+ }
31
+ /** The host of an `http(s)` origin with no path, query or credentials. */
32
+ export function hostOfOrigin(origin) {
33
+ if (!origin)
34
+ return undefined;
35
+ try {
36
+ const url = new URL(origin);
37
+ if ((url.protocol !== "https:" && url.protocol !== "http:") ||
38
+ url.username ||
39
+ url.password ||
40
+ url.origin !== origin)
41
+ return undefined;
42
+ return url.host;
43
+ }
44
+ catch {
45
+ return undefined;
46
+ }
47
+ }
48
+ /**
49
+ * Run `fn` with the routed host and the header-carried delegation of the
50
+ * forwarded request. A malformed or conflicting delegation carrier counts as
51
+ * none; the worker's bearer gate already refused it before forwarding.
52
+ */
53
+ export function runInRoutedRequest(headers, fn) {
54
+ let headerDelegation;
55
+ try {
56
+ headerDelegation = readHeaderDelegation((name) => single(headers, name));
57
+ }
58
+ catch (error) {
59
+ if (!(error instanceof InvalidDelegationPresentation))
60
+ throw error;
61
+ }
62
+ return routed.run({
63
+ routedHost: hostOfOrigin(single(headers, ROUTED_ORIGIN_HEADER)),
64
+ headerDelegation,
65
+ }, fn);
66
+ }
67
+ /**
68
+ * Run `fn` for a request the worker itself received (no Durable Object hop):
69
+ * the routed host is that request URL's host.
70
+ */
71
+ export function runWithRoutedHost(request, fn) {
72
+ return routed.run({ routedHost: new URL(request.url).host }, fn);
73
+ }
74
+ /** The host this tools/call was routed for, or undefined (fail closed). */
75
+ export function getRoutedHost() {
76
+ return routed.getStore()?.routedHost;
77
+ }
78
+ /**
79
+ * The delegation this tools/call presented in its headers (`Authorization:
80
+ * Bearer` or `KYA-Delegation`). Unverified input, never an authorization
81
+ * result: the runtime's verifier still decides.
82
+ */
83
+ export function getRoutedHeaderDelegation() {
84
+ return routed.getStore()?.headerDelegation;
85
+ }
86
+ //# sourceMappingURL=routed-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routed-request.js","sourceRoot":"","sources":["../../src/security/routed-request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAEhC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAU5D,MAAM,MAAM,GAAG,IAAI,iBAAiB,EAAiB,CAAC;AAEtD,8EAA8E;AAC9E,SAAS,MAAM,CACb,OAAqC,EACrC,IAAY;IAEZ,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAClD,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CACf,GAAG,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,KAAK,SAAS,CAClE,CAAC;IACF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtE,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAED,0EAA0E;AAC1E,MAAM,U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IAC3B,OAAO,MAAM,CAAC,QAAQ,EAAE,EAAE,UAAU,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB;IACvC,OAAO,MAAM,CAAC,QAAQ,EAAE,EAAE,gBAAgB,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * How a credential's person signed in, read from its verified `amr` claim.
3
+ *
4
+ * The org authorization service records the approver's sign-in method as a
5
+ * top-level `amr` claim on every delegation it mints. The vocabulary comes
6
+ * from Checkpoint's `apps/web/lib/authz/domain/sign-in-amr.ts`
7
+ * (`amrForSignInMethod`): `pwd`, `oauth`, `otp`, `email_link`, `passkey`.
8
+ * This table maps those values onto the authorization types a tool can
9
+ * require, and nothing else decides it.
10
+ *
11
+ * Read `amr` only from a credential `DelegationService.verifyLocally` has
12
+ * accepted: before that it is whatever the presenter wrote.
13
+ *
14
+ * @module @kya-os/mcp-i-cloudflare/security/sign-in-amr
15
+ */
16
+ /**
17
+ * Whether a verified credential's `amr` shows its person signed in the way
18
+ * `requiredType` asks, under the strict rule of `authTypeSatisfies`. A
19
+ * missing, malformed or empty `amr`, or one whose values prove nothing, fails
20
+ * closed.
21
+ */
22
+ export declare function amrSatisfiesAuthType(amr: readonly string[] | undefined, requiredType: string | undefined): boolean;
23
+ //# sourceMappingURL=sign-in-amr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-in-amr.d.ts","sourceRoot":"","sources":["../../src/security/sign-in-amr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAgBH;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAClC,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,OAAO,CAUT"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * How a credential's person signed in, read from its verified `amr` claim.
3
+ *
4
+ * The org authorization service records the approver's sign-in method as a
5
+ * top-level `amr` claim on every delegation it mints. The vocabulary comes
6
+ * from Checkpoint's `apps/web/lib/authz/domain/sign-in-amr.ts`
7
+ * (`amrForSignInMethod`): `pwd`, `oauth`, `otp`, `email_link`, `passkey`.
8
+ * This table maps those values onto the authorization types a tool can
9
+ * require, and nothing else decides it.
10
+ *
11
+ * Read `amr` only from a credential `DelegationService.verifyLocally` has
12
+ * accepted: before that it is whatever the presenter wrote.
13
+ *
14
+ * @module @kya-os/mcp-i-cloudflare/security/sign-in-amr
15
+ */
16
+ import { authTypeSatisfies } from "@kya-os/mcp-i-runtime";
17
+ /**
18
+ * Each `amr` value and the tool authorization type it proves, or null when
19
+ * it proves none. A value missing from this table proves nothing either.
20
+ */
21
+ const AUTH_TYPE_BY_AMR = {
22
+ pwd: "password",
23
+ oauth: "oauth2",
24
+ otp: null,
25
+ email_link: null,
26
+ passkey: null,
27
+ };
28
+ /**
29
+ * Whether a verified credential's `amr` shows its person signed in the way
30
+ * `requiredType` asks, under the strict rule of `authTypeSatisfies`. A
31
+ * missing, malformed or empty `amr`, or one whose values prove nothing, fails
32
+ * closed.
33
+ */
34
+ export function amrSatisfiesAuthType(amr, requiredType) {
35
+ if (!Array.isArray(amr))
36
+ return false;
37
+ return amr.some((value) => {
38
+ if (typeof value !== "string" ||
39
+ !Object.prototype.hasOwnProperty.call(AUTH_TYPE_BY_AMR, value))
40
+ return false;
41
+ return authTypeSatisfies(AUTH_TYPE_BY_AMR[value], requiredType);
42
+ });
43
+ }
44
+ //# sourceMappingURL=sign-in-amr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-in-amr.js","sourceRoot":"","sources":["../../src/security/sign-in-amr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;GAGG;AACH,MAAM,gBAAgB,GAA4C;IAChE,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,QAAQ;IACf,GAAG,EAAE,IAAI;IACT,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAI;CACd,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAkC,EAClC,YAAgC;IAEhC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACtC,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QACxB,IACE,OAAO,KAAK,KAAK,QAAQ;YACzB,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC;YAE9D,OAAO,KAAK,CAAC;QACf,OAAO,iBAAiB,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -13,8 +13,9 @@
13
13
  /**
14
14
  * The checks an approval can go through.
15
15
  * - `credential`: real credential sign-in (`handleCredentialApproval`).
16
- * - `clickwrap`: consent-only, or the clickwrap step after a credential or
17
- * OAuth sign-in (the latter two need a signed identity assertion).
16
+ * - `clickwrap`: the clickwrap step after a credential or OAuth sign-in
17
+ * (needs a signed identity assertion). Without a completed sign-in the
18
+ * approval is refused.
18
19
  * - `oauth`: the clickwrap step after OAuth; always needs a signed assertion.
19
20
  */
20
21
  export type ApprovalRoute = "credential" | "clickwrap" | "oauth";
@@ -1 +1 @@
1
- {"version":3,"file":"approval-route.d.ts","sourceRoot":"","sources":["../../src/services/approval-route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;AAmBjE;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAIvE;AAED,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGvD;AAED,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE5D;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAevD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,OAAO,GACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB"}
1
+ {"version":3,"file":"approval-route.d.ts","sourceRoot":"","sources":["../../src/services/approval-route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;AAmBjE;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAIvE;AAED,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGvD;AAED,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE5D;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAevD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,OAAO,GACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB"}
@@ -1 +1 @@
1
- {"version":3,"file":"approval-route.js","sourceRoot":"","sources":["../../src/services/approval-route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH;;;;GAIG;AACH,MAAM,eAAe,GAAuC,IAAI,GAAG,CAAC;IAClE,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,YAAY,EAAE,YAAY,CAAC;IAC5B,CAAC,UAAU,EAAE,YAAY,CAAC;IAC1B,CAAC,OAAO,EAAE,OAAO,CAAC;IAClB,CAAC,Q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AC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAsB;IAC3D,UAAU;IACV,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,oBAAoB;IACpB,YAAY;IACZ,aAAa;IACb,UAAU;IACV,iBAAiB;IACjB,YAAY;IACZ,SAAS;IACT,uBAAuB;IACvB,6BAA6B;IAC7B,gBAAgB;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,YAAqB;IAErB,IACE,CAAC,YAAY;QACb,OAAO,YAAY,KAAK,QAAQ;QAChC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAC3B,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,YAAuC,CAAC,CAAC,MAAM,CAC5D,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,0BAA0B,CAAC,QAAQ,CAAC,GAAG,CAAC,CACrD,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Checkpoint decision hook.
3
+ *
4
+ * Local verification (`DelegationService.verifyLocally`) decides whether a
5
+ * delegation is authentic, in force and meant for this worker. Checkpoint is
6
+ * consulted afterwards, and only when this deployment has an API key, for the
7
+ * questions a credential cannot answer about itself: call caps, quota, policy
8
+ * on the calling context, and revocation fresher than the issuer's status list.
9
+ *
10
+ * Checkpoint is never the authority:
11
+ * - its approval cannot rescue a credential local verification refused,
12
+ * because it is asked only after that verification passed;
13
+ * - it can refuse only with a stateful code (`STATEFUL_DENIALS`). A verdict
14
+ * about the credential's own validity (unknown issuer, not found, bad JWT,
15
+ * expired, scopes) is the worker's to make and is not acted on.
16
+ *
17
+ * When the hook is configured and Checkpoint cannot answer (network failure,
18
+ * non-200, malformed body), the call is refused: an unanswered question about
19
+ * quota or fresh revocation is not a yes.
20
+ */
21
+ import type { CloudflareEnv } from "../types";
22
+ /** Checkpoint codes that answer a stateful question; the only ones acted on. */
23
+ export declare const STATEFUL_DENIALS: ReadonlySet<string>;
24
+ /** The code a refusal carries when Checkpoint could not be asked. */
25
+ export declare const DECISION_UNAVAILABLE = "decision_unavailable";
26
+ export interface DecisionRequest {
27
+ /** The presented credential, already verified locally. */
28
+ token: string;
29
+ /** The delegate the credential names (`sub`). */
30
+ agentDid: string;
31
+ /** Scopes the call needs. */
32
+ scopes: readonly string[];
33
+ /** The authorizing user the credential names, when it names one. */
34
+ userDid?: string;
35
+ }
36
+ /** Grant facts Checkpoint holds that the credential does not carry. */
37
+ export interface DecisionFacts {
38
+ /** The sign-in method recorded on the grant (`credential.authorization`). */
39
+ authorization?: {
40
+ type: string;
41
+ provider?: string;
42
+ credentialType?: string;
43
+ };
44
+ }
45
+ export type DecisionVerdict = ({
46
+ allowed: true;
47
+ } & DecisionFacts) | {
48
+ allowed: false;
49
+ code: string;
50
+ };
51
+ /**
52
+ * Ask Checkpoint's decision endpoint about a locally verified delegation.
53
+ * Returns null when no API key is configured: the hook is optional.
54
+ */
55
+ export declare function askCheckpointDecision(env: CloudflareEnv, request: DecisionRequest, fetchImpl?: typeof fetch): Promise<DecisionVerdict | null>;
56
+ //# sourceMappingURL=checkpoint-decision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint-decision.d.ts","sourceRoot":"","sources":["../../src/services/checkpoint-decision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAQ/C,CAAC;AAEH,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAI3D,MAAM,WAAW,eAAe;IAC9B,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,6BAA6B;IAC7B,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,aAAa,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9E;AAED,MAAM,MAAM,eAAe,GACvB,CAAC;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GAAG,aAAa,CAAC,GACnC;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AA0BrC;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,eAAe,EACxB,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CA+DjC"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Checkpoint decision hook.
3
+ *
4
+ * Local verification (`DelegationService.verifyLocally`) decides whether a
5
+ * delegation is authentic, in force and meant for this worker. Checkpoint is
6
+ * consulted afterwards, and only when this deployment has an API key, for the
7
+ * questions a credential cannot answer about itself: call caps, quota, policy
8
+ * on the calling context, and revocation fresher than the issuer's status list.
9
+ *
10
+ * Checkpoint is never the authority:
11
+ * - its approval cannot rescue a credential local verification refused,
12
+ * because it is asked only after that verification passed;
13
+ * - it can refuse only with a stateful code (`STATEFUL_DENIALS`). A verdict
14
+ * about the credential's own validity (unknown issuer, not found, bad JWT,
15
+ * expired, scopes) is the worker's to make and is not acted on.
16
+ *
17
+ * When the hook is configured and Checkpoint cannot answer (network failure,
18
+ * non-200, malformed body), the call is refused: an unanswered question about
19
+ * quota or fresh revocation is not a yes.
20
+ */
21
+ import { withCheckpointNames } from "@kya-os/contracts/config";
22
+ import { DEFAULT_CHECKPOINT_URL } from "../constants";
23
+ /** Checkpoint codes that answer a stateful question; the only ones acted on. */
24
+ export const STATEFUL_DENIALS = new Set([
25
+ "delegation_revoked",
26
+ "max_calls_exceeded",
27
+ "limit_exceeded",
28
+ "origin_not_allowed",
29
+ "origin_required",
30
+ "ip_not_whitelisted",
31
+ "client_ip_required",
32
+ ]);
33
+ /** The code a refusal carries when Checkpoint could not be asked. */
34
+ export const DECISION_UNAVAILABLE = "decision_unavailable";
35
+ const DECISION_TIMEOUT_MS = 5_000;
36
+ function authorizationFacts(value) {
37
+ if (!value || typeof value !== "object")
38
+ return {};
39
+ const auth = value;
40
+ if (typeof auth.type !== "string")
41
+ return {};
42
+ return {
43
+ authorization: {
44
+ type: auth.type,
45
+ ...(typeof auth.provider === "string" ? { provider: auth.provider } : {}),
46
+ ...(typeof auth.credentialType === "string"
47
+ ? { credentialType: auth.credentialType }
48
+ : {}),
49
+ },
50
+ };
51
+ }
52
+ /**
53
+ * Ask Checkpoint's decision endpoint about a locally verified delegation.
54
+ * Returns null when no API key is configured: the hook is optional.
55
+ */
56
+ export async function askCheckpointDecision(env, request, fetchImpl = fetch) {
57
+ // Deployments may still set the former Checkpoint setting names.
58
+ const settings = withCheckpointNames(env);
59
+ if (!settings.CHECKPOINT_API_KEY)
60
+ return null;
61
+ const base = settings.CHECKPOINT_API_URL || DEFAULT_CHECKPOINT_URL;
62
+ let body;
63
+ try {
64
+ const response = await fetchImpl(`${base}/api/v1/bouncer/delegations/verify`, {
65
+ method: "POST",
66
+ redirect: "manual",
67
+ signal: AbortSignal.timeout(DECISION_TIMEOUT_MS),
68
+ headers: {
69
+ Authorization: `Bearer ${settings.CHECKPOINT_API_KEY}`,
70
+ "Content-Type": "application/json",
71
+ },
72
+ body: JSON.stringify({
73
+ agent_did: request.agentDid,
74
+ delegation_token: request.token,
75
+ scopes: request.scopes,
76
+ ...(request.userDid ? { user_did: request.userDid } : {}),
77
+ }),
78
+ });
79
+ if (response.status !== 200) {
80
+ void response.body?.cancel().catch(() => { });
81
+ console.error("[Delegation] Checkpoint decision unavailable: status", response.status);
82
+ return { allowed: false, code: DECISION_UNAVAILABLE };
83
+ }
84
+ body = (await response.json());
85
+ }
86
+ catch (error) {
87
+ console.error("[Delegation] Checkpoint decision unavailable:", error instanceof Error ? error.message : "request failed");
88
+ return { allowed: false, code: DECISION_UNAVAILABLE };
89
+ }
90
+ const data = body?.data;
91
+ if (data?.valid === true)
92
+ return {
93
+ allowed: true,
94
+ ...authorizationFacts(data.credential?.authorization),
95
+ };
96
+ if (data?.valid !== false)
97
+ return { allowed: false, code: DECISION_UNAVAILABLE };
98
+ const code = typeof data.error?.code === "string"
99
+ ? data.error.code
100
+ : typeof data.reason === "string"
101
+ ? data.reason
102
+ : undefined;
103
+ if (code !== undefined && STATEFUL_DENIALS.has(code))
104
+ return { allowed: false, code };
105
+ // A validity verdict on a credential this worker verified itself.
106
+ console.warn("[Delegation] Checkpoint gave a validity verdict on a locally verified delegation; not acted on:", JSON.stringify(String(code ?? "none").slice(0, 64)));
107
+ return { allowed: true };
108
+ }
109
+ //# sourceMappingURL=checkpoint-decision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint-decision.js","sourceRoot":"","sources":["../../src/services/checkpoint-decision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAGtD,gFAAgF;AAChF,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC;IAC3D,oBAAoB;IACpB,oBAAoB;IACpB,gBAAgB;IAChB,oBAAoB;IACpB,iBAAiB;IACjB,oBAAoB;IACpB,oBAAoB;CACrB,CAAC,CAAC;AAEH,qEAAqE;AACrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAE3D,M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;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IA+JpB;;;;;;;;;;OAUG;IACH,oBAAoB,CAClB,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,wBAAwB,EAClC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,MAAM;IAsBT;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA6B9B;;;;;;;;OAQG;IACH,OAAO,CAAC,oBAAoB;IA8C5B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAwB7B;;OAEG;IACH,OAAO,CAAC,cAAc;IAgBtB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;;;;;;OAOG;IACH,OAAO,CAAC,qBAAqB;IAiD7B;;OAEG;IACH,OAAO,CAAC,eAAe;IAavB;;OAEG;IACH,OAAO,CAAC,cAAc;IAWtB;;OAEG;IACH,OAAO,CAAC,0BAA0B;CAsEnC"}
@@ -546,8 +546,7 @@ export class ConsentPageRenderer {
546
546
 
547
547
  // Determine provider_type based on whether OAuth identity is present
548
548
  // - 'oauth2': User authenticated via OAuth provider
549
- // - 'none': Consent-only mode (clickwrap) - user agrees without authentication
550
- // This is CRITICAL for the backend to generate ephemeral userDid for consent-only flows
549
+ // - 'none': Clickwrap without an OAuth identity
551
550
  const providerType = extractedOAuthIdentity ? '${CONSENT_PROVIDER_TYPES.OAUTH2}' : '${CONSENT_PROVIDER_TYPES.NONE}';
552
551
 
553
552
  const data = {
@@ -559,7 +558,7 @@ export class ConsentPageRenderer {
559
558
  termsAccepted: formData.get('termsAccepted') === 'on',
560
559
  customFields: {},
561
560
  oauth_identity: extractedOAuthIdentity,
562
- provider_type: providerType // CRITICAL: Enables ephemeral userDid generation for consent-only
561
+ provider_type: providerType
563
562
  };
564
563
 
565
564
  // Collect custom fields