@kya-os/mcp-i-cloudflare 1.17.0 → 1.18.1

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 (268) 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 +39 -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 +386 -404
  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/amount-limit-refusal.d.ts +3 -0
  86. package/dist/runtime/amount-limit-refusal.d.ts.map +1 -0
  87. package/dist/runtime/amount-limit-refusal.js +7 -0
  88. package/dist/runtime/amount-limit-refusal.js.map +1 -0
  89. package/dist/runtime/oauth-handler.d.ts +1 -1
  90. package/dist/runtime/oauth-handler.d.ts.map +1 -1
  91. package/dist/runtime/oauth-handler.js +31 -34
  92. package/dist/runtime/oauth-handler.js.map +1 -1
  93. package/dist/runtime.d.ts +34 -10
  94. package/dist/runtime.d.ts.map +1 -1
  95. package/dist/runtime.js +65 -16
  96. package/dist/runtime.js.map +1 -1
  97. package/dist/security/admission-refusal.d.ts +3 -3
  98. package/dist/security/admission-refusal.d.ts.map +1 -1
  99. package/dist/security/admission-refusal.js +14 -6
  100. package/dist/security/admission-refusal.js.map +1 -1
  101. package/dist/security/holder-binding.d.ts +34 -0
  102. package/dist/security/holder-binding.d.ts.map +1 -0
  103. package/dist/security/holder-binding.js +75 -0
  104. package/dist/security/holder-binding.js.map +1 -0
  105. package/dist/security/mcp-admission.d.ts +29 -1
  106. package/dist/security/mcp-admission.d.ts.map +1 -1
  107. package/dist/security/mcp-admission.js +78 -12
  108. package/dist/security/mcp-admission.js.map +1 -1
  109. package/dist/security/native-holder-admission.d.ts +39 -0
  110. package/dist/security/native-holder-admission.d.ts.map +1 -0
  111. package/dist/security/native-holder-admission.js +65 -0
  112. package/dist/security/native-holder-admission.js.map +1 -0
  113. package/dist/security/outcome-proof.d.ts +39 -0
  114. package/dist/security/outcome-proof.d.ts.map +1 -0
  115. package/dist/security/outcome-proof.js +54 -0
  116. package/dist/security/outcome-proof.js.map +1 -0
  117. package/dist/security/request-nonce-store.d.ts +43 -0
  118. package/dist/security/request-nonce-store.d.ts.map +1 -0
  119. package/dist/security/request-nonce-store.js +129 -0
  120. package/dist/security/request-nonce-store.js.map +1 -0
  121. package/dist/security/routed-request.d.ts +41 -0
  122. package/dist/security/routed-request.d.ts.map +1 -0
  123. package/dist/security/routed-request.js +86 -0
  124. package/dist/security/routed-request.js.map +1 -0
  125. package/dist/security/sign-in-amr.d.ts +23 -0
  126. package/dist/security/sign-in-amr.d.ts.map +1 -0
  127. package/dist/security/sign-in-amr.js +44 -0
  128. package/dist/security/sign-in-amr.js.map +1 -0
  129. package/dist/services/approval-route.d.ts +3 -2
  130. package/dist/services/approval-route.d.ts.map +1 -1
  131. package/dist/services/approval-route.js.map +1 -1
  132. package/dist/services/checkpoint-decision.d.ts +56 -0
  133. package/dist/services/checkpoint-decision.d.ts.map +1 -0
  134. package/dist/services/checkpoint-decision.js +109 -0
  135. package/dist/services/checkpoint-decision.js.map +1 -0
  136. package/dist/services/consent-page-renderer.d.ts.map +1 -1
  137. package/dist/services/consent-page-renderer.js +2 -3
  138. package/dist/services/consent-page-renderer.js.map +1 -1
  139. package/dist/services/consent.service.d.ts +11 -49
  140. package/dist/services/consent.service.d.ts.map +1 -1
  141. package/dist/services/consent.service.js +81 -307
  142. package/dist/services/consent.service.js.map +1 -1
  143. package/dist/services/credential-auth.handler.d.ts.map +1 -1
  144. package/dist/services/credential-auth.handler.js +2 -8
  145. package/dist/services/credential-auth.handler.js.map +1 -1
  146. package/dist/services/delegation-authority.d.ts +53 -0
  147. package/dist/services/delegation-authority.d.ts.map +1 -0
  148. package/dist/services/delegation-authority.js +130 -0
  149. package/dist/services/delegation-authority.js.map +1 -0
  150. package/dist/services/delegation-trust.d.ts +35 -64
  151. package/dist/services/delegation-trust.d.ts.map +1 -1
  152. package/dist/services/delegation-trust.js +98 -279
  153. package/dist/services/delegation-trust.js.map +1 -1
  154. package/dist/services/delegation.service.d.ts +83 -105
  155. package/dist/services/delegation.service.d.ts.map +1 -1
  156. package/dist/services/delegation.service.js +166 -518
  157. package/dist/services/delegation.service.js.map +1 -1
  158. package/dist/services/idp-token-storage.d.ts +32 -12
  159. package/dist/services/idp-token-storage.d.ts.map +1 -1
  160. package/dist/services/idp-token-storage.js +79 -36
  161. package/dist/services/idp-token-storage.js.map +1 -1
  162. package/dist/services/issuer-keys.d.ts +55 -0
  163. package/dist/services/issuer-keys.d.ts.map +1 -0
  164. package/dist/services/issuer-keys.js +184 -0
  165. package/dist/services/issuer-keys.js.map +1 -0
  166. package/dist/services/oauth-security.service.d.ts +17 -1
  167. package/dist/services/oauth-security.service.d.ts.map +1 -1
  168. package/dist/services/oauth-security.service.js +29 -10
  169. package/dist/services/oauth-security.service.js.map +1 -1
  170. package/dist/services/proof.service.d.ts +10 -0
  171. package/dist/services/proof.service.d.ts.map +1 -1
  172. package/dist/services/proof.service.js +28 -6
  173. package/dist/services/proof.service.js.map +1 -1
  174. package/dist/services/resource-audience.d.ts +12 -9
  175. package/dist/services/resource-audience.d.ts.map +1 -1
  176. package/dist/services/resource-audience.js +12 -9
  177. package/dist/services/resource-audience.js.map +1 -1
  178. package/dist/services/unenforceable-tool-protection.d.ts +32 -0
  179. package/dist/services/unenforceable-tool-protection.d.ts.map +1 -0
  180. package/dist/services/unenforceable-tool-protection.js +90 -0
  181. package/dist/services/unenforceable-tool-protection.js.map +1 -0
  182. package/dist/services/upstream-fetch.d.ts +14 -0
  183. package/dist/services/upstream-fetch.d.ts.map +1 -0
  184. package/dist/services/upstream-fetch.js +56 -0
  185. package/dist/services/upstream-fetch.js.map +1 -0
  186. package/dist/types.d.ts +5 -18
  187. package/dist/types.d.ts.map +1 -1
  188. package/dist/utils/oauth-profile.d.ts +19 -0
  189. package/dist/utils/oauth-profile.d.ts.map +1 -1
  190. package/dist/utils/oauth-profile.js +54 -1
  191. package/dist/utils/oauth-profile.js.map +1 -1
  192. package/dist/utils/tool-security-schemes.d.ts +65 -0
  193. package/dist/utils/tool-security-schemes.d.ts.map +1 -0
  194. package/dist/utils/tool-security-schemes.js +168 -0
  195. package/dist/utils/tool-security-schemes.js.map +1 -0
  196. package/package.json +5 -6
  197. package/dist/delegation-http/anchor-do.d.ts +0 -84
  198. package/dist/delegation-http/anchor-do.d.ts.map +0 -1
  199. package/dist/delegation-http/anchor-do.js +0 -412
  200. package/dist/delegation-http/anchor-do.js.map +0 -1
  201. package/dist/delegation-http/anchor-registration-validate.d.ts +0 -61
  202. package/dist/delegation-http/anchor-registration-validate.d.ts.map +0 -1
  203. package/dist/delegation-http/anchor-registration-validate.js +0 -191
  204. package/dist/delegation-http/anchor-registration-validate.js.map +0 -1
  205. package/dist/delegation-http/anchor-registration.d.ts +0 -62
  206. package/dist/delegation-http/anchor-registration.d.ts.map +0 -1
  207. package/dist/delegation-http/anchor-registration.js +0 -337
  208. package/dist/delegation-http/anchor-registration.js.map +0 -1
  209. package/dist/delegation-http/anchor-routing.d.ts +0 -20
  210. package/dist/delegation-http/anchor-routing.d.ts.map +0 -1
  211. package/dist/delegation-http/anchor-routing.js +0 -27
  212. package/dist/delegation-http/anchor-routing.js.map +0 -1
  213. package/dist/delegation-http/challenge-middleware.d.ts +0 -28
  214. package/dist/delegation-http/challenge-middleware.d.ts.map +0 -1
  215. package/dist/delegation-http/challenge-middleware.js +0 -190
  216. package/dist/delegation-http/challenge-middleware.js.map +0 -1
  217. package/dist/delegation-http/challenge.d.ts +0 -102
  218. package/dist/delegation-http/challenge.d.ts.map +0 -1
  219. package/dist/delegation-http/challenge.js +0 -223
  220. package/dist/delegation-http/challenge.js.map +0 -1
  221. package/dist/delegation-http/consent-anchor-bridge.d.ts +0 -70
  222. package/dist/delegation-http/consent-anchor-bridge.d.ts.map +0 -1
  223. package/dist/delegation-http/consent-anchor-bridge.js +0 -1130
  224. package/dist/delegation-http/consent-anchor-bridge.js.map +0 -1
  225. package/dist/delegation-http/consent-preparation-page.d.ts +0 -18
  226. package/dist/delegation-http/consent-preparation-page.d.ts.map +0 -1
  227. package/dist/delegation-http/consent-preparation-page.js +0 -172
  228. package/dist/delegation-http/consent-preparation-page.js.map +0 -1
  229. package/dist/delegation-http/credential-consent.d.ts +0 -149
  230. package/dist/delegation-http/credential-consent.d.ts.map +0 -1
  231. package/dist/delegation-http/credential-consent.js +0 -338
  232. package/dist/delegation-http/credential-consent.js.map +0 -1
  233. package/dist/delegation-http/native-capabilities.d.ts +0 -4
  234. package/dist/delegation-http/native-capabilities.d.ts.map +0 -1
  235. package/dist/delegation-http/native-capabilities.js +0 -53
  236. package/dist/delegation-http/native-capabilities.js.map +0 -1
  237. package/dist/delegation-http/native-oauth-state.d.ts +0 -28
  238. package/dist/delegation-http/native-oauth-state.d.ts.map +0 -1
  239. package/dist/delegation-http/native-oauth-state.js +0 -146
  240. package/dist/delegation-http/native-oauth-state.js.map +0 -1
  241. package/dist/delegation-http/native-oauth.d.ts +0 -26
  242. package/dist/delegation-http/native-oauth.d.ts.map +0 -1
  243. package/dist/delegation-http/native-oauth.js +0 -393
  244. package/dist/delegation-http/native-oauth.js.map +0 -1
  245. package/dist/delegation-http/native-pickup.d.ts +0 -20
  246. package/dist/delegation-http/native-pickup.d.ts.map +0 -1
  247. package/dist/delegation-http/native-pickup.js +0 -227
  248. package/dist/delegation-http/native-pickup.js.map +0 -1
  249. package/dist/delegation-http/pickup-routes.d.ts +0 -43
  250. package/dist/delegation-http/pickup-routes.d.ts.map +0 -1
  251. package/dist/delegation-http/pickup-routes.js +0 -166
  252. package/dist/delegation-http/pickup-routes.js.map +0 -1
  253. package/dist/delegation-http/register.d.ts +0 -26
  254. package/dist/delegation-http/register.d.ts.map +0 -1
  255. package/dist/delegation-http/register.js +0 -95
  256. package/dist/delegation-http/register.js.map +0 -1
  257. package/dist/delegation-http/registrar-auth.d.ts +0 -24
  258. package/dist/delegation-http/registrar-auth.d.ts.map +0 -1
  259. package/dist/delegation-http/registrar-auth.js +0 -61
  260. package/dist/delegation-http/registrar-auth.js.map +0 -1
  261. package/dist/delegation-http/remote-issuer.d.ts +0 -52
  262. package/dist/delegation-http/remote-issuer.d.ts.map +0 -1
  263. package/dist/delegation-http/remote-issuer.js +0 -324
  264. package/dist/delegation-http/remote-issuer.js.map +0 -1
  265. package/dist/delegation-http/types.d.ts +0 -116
  266. package/dist/delegation-http/types.d.ts.map +0 -1
  267. package/dist/delegation-http/types.js +0 -11
  268. package/dist/delegation-http/types.js.map +0 -1
@@ -1,175 +1,20 @@
1
1
  export const NATIVE_OAUTH_INTERNAL_PREFIX = "/_internal/native-oauth/";
2
- export const NATIVE_OAUTH_STATE_KEY = "native-oauth-state:v1";
3
- export const NATIVE_OAUTH_MAX_TTL_MS = 600_000;
4
- export const NATIVE_OAUTH_MAX_CIPHERTEXT = 32_768;
5
- export const NATIVE_OAUTH_STORAGE_PROFILE = "dedicated-expiry-alarm-v1";
6
- export const NATIVE_OAUTH_PROFILE_HEADER = "X-KYA-Native-OAuth-Storage";
7
- export const NATIVE_OAUTH_ALARM_MAX_RETRIES = 6;
8
- /** Pure transition, evaluated with the persisted record inside one transaction. */
9
- export function reduceNativeOAuthState(record, operation, input, now) {
10
- if (operation === "create") {
11
- // Never refresh or replace an in-flight or already consumed state.
12
- if (record)
13
- return { status: 409 };
14
- const value = input;
15
- if (!value ||
16
- value.version !== 1 ||
17
- !Number.isSafeInteger(value.expiresAt) ||
18
- value.expiresAt <= now ||
19
- value.expiresAt > now + NATIVE_OAUTH_MAX_TTL_MS ||
20
- typeof value.ciphertext !== "string" ||
21
- value.ciphertext.length < 38 ||
22
- value.ciphertext.length > NATIVE_OAUTH_MAX_CIPHERTEXT ||
23
- !/^[A-Za-z0-9_-]+$/.test(value.ciphertext))
24
- return { status: 400 };
25
- return {
26
- status: 201,
27
- record: {
28
- version: 1,
29
- expiresAt: value.expiresAt,
30
- ciphertext: value.ciphertext,
31
- },
32
- };
33
- }
34
- if (!record)
35
- return { status: 404 };
36
- if (record.version !== 1 ||
37
- !Number.isSafeInteger(record.expiresAt) ||
38
- record.expiresAt <= now)
39
- return { status: 410, remove: true };
40
- if (!record.ciphertext)
41
- return { status: 404 };
42
- // Retain only a non-secret tombstone, removed by its expiry alarm; a duplicate
43
- // create cannot resurrect consumed state. The encrypted verifier is removed now.
44
- return {
45
- status: 200,
46
- record: { version: 1, expiresAt: record.expiresAt },
47
- body: record,
48
- };
49
- }
50
- function response(status, body) {
51
- return Response.json(body ?? {}, {
52
- status,
53
- headers: {
54
- "Cache-Control": "no-store",
55
- [NATIVE_OAUTH_PROFILE_HEADER]: NATIVE_OAUTH_STORAGE_PROFILE,
56
- },
57
- });
58
- }
59
- export async function handleNativeOAuthStateInternal(ctx, request) {
60
- const url = new URL(request.url);
61
- const operation = url.pathname.slice(NATIVE_OAUTH_INTERNAL_PREFIX.length);
62
- if (url.origin !== "https://do.internal" ||
63
- !url.pathname.startsWith(NATIVE_OAUTH_INTERNAL_PREFIX) ||
64
- (operation !== "create" && operation !== "consume" && operation !== "ready"))
65
- return response(404);
66
- if (request.method !== "POST")
67
- return response(405);
68
- if (operation === "ready")
69
- return response(200);
70
- let input;
71
- try {
72
- const text = await request.text();
73
- if (text.length > NATIVE_OAUTH_MAX_CIPHERTEXT + 128)
74
- return response(413);
75
- input = JSON.parse(text);
76
- }
77
- catch {
78
- return response(400);
79
- }
80
- try {
81
- // Only storage awaits inside this transaction. No crypto, network, logging,
82
- // or externally visible side effects: a platform retry remains harmless.
83
- const result = await ctx.storage.transaction(async (txn) => {
84
- const current = await txn.get(NATIVE_OAUTH_STATE_KEY);
85
- const transition = reduceNativeOAuthState(current, operation, input, Date.now());
86
- if (transition.remove) {
87
- await txn.delete(NATIVE_OAUTH_STATE_KEY);
88
- // Leave its existing expiry alarm to reclaim all object metadata too.
89
- }
90
- else if (transition.record) {
91
- await txn.put(NATIVE_OAUTH_STATE_KEY, transition.record);
92
- // Commit the deadline with creation. A failed alarm write cannot leave
93
- // an acknowledged, abandoned ciphertext without scheduled cleanup.
94
- if (operation === "create")
95
- await txn.setAlarm(transition.record.expiresAt);
96
- }
97
- return transition;
98
- });
99
- return response(result.status, result.body);
100
- }
101
- catch {
102
- // Storage errors must never yield the encrypted state or trigger KV fallback.
103
- return response(503);
104
- }
105
- }
106
- /** Dedicated binding only: never inherit or override the MCP Agent scheduler.
107
- * A plain DO class matches the package's AuditProducer export convention and
108
- * keeps the SDK root import usable outside workerd (no cloudflare:workers import).
109
- */
2
+ /** A plain DO class, like AuditProducer, so the SDK root import works outside workerd. */
110
3
  export class NativeOAuthState {
111
4
  ctx;
112
5
  constructor(ctx) {
113
6
  this.ctx = ctx;
114
7
  }
115
- async fetch(request) {
116
- const url = new URL(request.url);
117
- if (url.origin === "https://do.internal" &&
118
- url.pathname === NATIVE_OAUTH_INTERNAL_PREFIX + "cleanup-expired") {
119
- if (request.method !== "POST")
120
- return response(405);
121
- try {
122
- const removed = await this.cleanup({ retryCount: 0, isRetry: false }, "manual");
123
- return response(removed ? 200 : 202, {
124
- status: removed ? "expired-data-removed" : "live-state-retained",
125
- });
126
- }
127
- catch {
128
- return response(503);
129
- }
130
- }
131
- return handleNativeOAuthStateInternal(this.ctx, request);
132
- }
133
- async alarm(info = {
134
- retryCount: 0,
135
- isRetry: false,
136
- }) {
137
- await this.cleanup(info, "alarm");
8
+ async fetch(_request) {
9
+ return new Response(null, {
10
+ status: 404,
11
+ headers: { "Cache-Control": "no-store" },
12
+ });
138
13
  }
139
- async cleanup(info, trigger) {
140
- try {
141
- // Storage input gates serialize this storage-only sequence with requests.
142
- // deleteAll cannot run inside a transaction; it also reclaims per-object
143
- // metadata that deleting the single state key would leave behind.
144
- const record = await this.ctx.storage.get(NATIVE_OAUTH_STATE_KEY);
145
- if (record?.version === 1 &&
146
- Number.isSafeInteger(record.expiresAt) &&
147
- record.expiresAt > Date.now()) {
148
- // An early/duplicate wake must not erase live authority or its alarm.
149
- await this.ctx.storage.setAlarm(record.expiresAt);
150
- return false;
151
- }
152
- // Clear data first. If deleting the alarm fails, retry is harmless and
153
- // must not restore a consumed/expired record.
154
- await this.ctx.storage.deleteAll();
155
- await this.ctx.storage.deleteAlarm();
156
- return true;
157
- }
158
- catch {
159
- // Cloudflare retries a throwing alarm up to six times. Do not swallow a
160
- // failure or log the exception: storage errors can contain request data.
161
- console.error({
162
- component: "native-oauth-state",
163
- objectId: this.ctx.id.toString(),
164
- trigger,
165
- event: info.retryCount >= NATIVE_OAUTH_ALARM_MAX_RETRIES
166
- ? "cleanup_retry_exhausted"
167
- : "cleanup_failed",
168
- retryCount: info.retryCount,
169
- isRetry: info.isRetry,
170
- });
171
- throw new Error("Native OAuth state cleanup failed");
172
- }
14
+ /** Clear state an earlier release left behind. A throw makes Cloudflare retry. */
15
+ async alarm() {
16
+ await this.ctx.storage.deleteAll();
17
+ await this.ctx.storage.deleteAlarm();
173
18
  }
174
19
  }
175
20
  //# sourceMappingURL=native-oauth-state-do.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"native-oauth-state-do.js","sourceRoot":"","sources":["../../src/delegation-http/native-oauth-state-do.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,4BAA4B,GAAG,0BAA0B,CAAC;AACvE,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAC9D,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;AAC/C,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAClD,MAAM,CAAC,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;AACxE,MAAM,CAAC,MAAM,2BAA2B,GAAG,4BAA4B,CAAC;AACxE,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC;AAehD,mFAAmF;AACnF,MAAM,UAAU,sBAAsB,CACpC,MAA0C,EA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O,IAAI,QAAQ,CAAC,IAAI,EAAE;YACxB,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE;SACzC,CAAC,CAAC;IACL,CAAC;IAED,kFAAkF;IAClF,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACnC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Protected-resource metadata (RFC 9728) for the worker's own resource.
3
+ *
4
+ * The edge's 401s (lazy auth, and a deployment that requires a token to
5
+ * connect) name `https://<routed host>/.well-known/oauth-protected-resource`,
6
+ * where an OAuth client finds the authorization server to use. The worker is
7
+ * the resource server, so it serves that document:
8
+ * - `resource`: `https://<routed host>`, the resource its native challenges
9
+ * register and the host whose `did:web` the org's credentials name as
10
+ * audience;
11
+ * - `authorization_servers`: the org's issuer from the deployment's issuer
12
+ * binding, `<authorizationOrigin>/oauth/<org slug>`, whose RFC 8414
13
+ * metadata Checkpoint serves;
14
+ * - `bearer_methods_supported`: `header`.
15
+ *
16
+ * A deployment without a valid issuer binding names no authorization server,
17
+ * so it has no such document.
18
+ *
19
+ * @module @kya-os/mcp-i-cloudflare/delegation-http/protected-resource
20
+ */
21
+ import type { RuntimeBinding } from "./issuer-binding";
22
+ /** The well-known path of the document (RFC 9728 §3). */
23
+ export declare const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource";
24
+ /**
25
+ * The org authorization server's issuer: `<authorizationOrigin>/oauth/<slug>`,
26
+ * with the slug from `did:web:<host>:orgs:<slug>`. Undefined for an issuer DID
27
+ * of any other shape.
28
+ */
29
+ export declare function orgAuthorizationServer(binding: Pick<RuntimeBinding, "issuerDid" | "authorizationOrigin">): string | undefined;
30
+ export interface ProtectedResourceMetadata {
31
+ resource: string;
32
+ authorization_servers: [string];
33
+ bearer_methods_supported: ["header"];
34
+ }
35
+ /** The document for `routedHost`, or null when the binding names no issuer. */
36
+ export declare function protectedResourceMetadata(routedHost: string, binding: Pick<RuntimeBinding, "issuerDid" | "authorizationOrigin"> | null): ProtectedResourceMetadata | null;
37
+ //# sourceMappingURL=protected-resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protected-resource.d.ts","sourceRoot":"","sources":["../../src/delegation-http/protected-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,yDAAyD;AACzD,eAAO,MAAM,gCAAgC,0CACJ,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,qBAAqB,CAAC,GACjE,MAAM,GAAG,SAAS,CAKpB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB,EAAE,CAAC,MAAM,CAAC,CAAC;IAChC,wBAAwB,EAAE,CAAC,QAAQ,CAAC,CAAC;CACtC;AAED,+EAA+E;AAC/E,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,qBAAqB,CAAC,GAAG,IAAI,GACxE,yBAAyB,GAAG,IAAI,CAQlC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Protected-resource metadata (RFC 9728) for the worker's own resource.
3
+ *
4
+ * The edge's 401s (lazy auth, and a deployment that requires a token to
5
+ * connect) name `https://<routed host>/.well-known/oauth-protected-resource`,
6
+ * where an OAuth client finds the authorization server to use. The worker is
7
+ * the resource server, so it serves that document:
8
+ * - `resource`: `https://<routed host>`, the resource its native challenges
9
+ * register and the host whose `did:web` the org's credentials name as
10
+ * audience;
11
+ * - `authorization_servers`: the org's issuer from the deployment's issuer
12
+ * binding, `<authorizationOrigin>/oauth/<org slug>`, whose RFC 8414
13
+ * metadata Checkpoint serves;
14
+ * - `bearer_methods_supported`: `header`.
15
+ *
16
+ * A deployment without a valid issuer binding names no authorization server,
17
+ * so it has no such document.
18
+ *
19
+ * @module @kya-os/mcp-i-cloudflare/delegation-http/protected-resource
20
+ */
21
+ /** The well-known path of the document (RFC 9728 §3). */
22
+ export const PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource";
23
+ /**
24
+ * The org authorization server's issuer: `<authorizationOrigin>/oauth/<slug>`,
25
+ * with the slug from `did:web:<host>:orgs:<slug>`. Undefined for an issuer DID
26
+ * of any other shape.
27
+ */
28
+ export function orgAuthorizationServer(binding) {
29
+ const slug = /^did:web:[^:/?#]+:orgs:([a-z0-9][a-z0-9-]*)$/.exec(binding.issuerDid)?.[1];
30
+ return slug ? `${binding.authorizationOrigin}/oauth/${slug}` : undefined;
31
+ }
32
+ /** The document for `routedHost`, or null when the binding names no issuer. */
33
+ export function protectedResourceMetadata(routedHost, binding) {
34
+ const issuer = binding ? orgAuthorizationServer(binding) : undefined;
35
+ if (!issuer)
36
+ return null;
37
+ return {
38
+ resource: `https://${routedHost}`,
39
+ authorization_servers: [issuer],
40
+ bearer_methods_supported: ["header"],
41
+ };
42
+ }
43
+ //# sourceMappingURL=protected-resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protected-resource.js","sourceRoot":"","sources":["../../src/delegation-http/protected-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,yDAAyD;AACzD,MAAM,CAAC,MAAM,gCAAgC,GAC3C,uCAAuC,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAkE;IAElE,MAAM,IAAI,GAAG,8CAA8C,CAAC,IAAI,CAC9D,OAAO,CAAC,SAAS,CAClB,EAAE,CAAC,CAAC,CAAC,CAAC;IACP,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,mBAAmB,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC;AAQD,+EAA+E;AAC/E,MAAM,UAAU,yBAAyB,CACvC,UAAkB,EAClB,OAAyE;IAEzE,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO;QACL,QAAQ,EAAE,WAAW,UAAU,EAAE;QACjC,qBAAqB,EAAE,CAAC,MAAM,CAAC;QAC/B,wBAAwB,EAAE,CAAC,QAAQ,CAAC;KACrC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Whether an MCP request carries a KYA-OS request proof.
3
+ *
4
+ * One detection for every edge step in front of the agent: the pass-through
5
+ * that moves a presented delegation into the call, and the gate that decides
6
+ * which calls may be answered with an HTTP status. A request proof is either
7
+ * an HTTP message signature header or a card proof carrier in `params._meta`.
8
+ * The card keys come only from the validated card proof support accessor;
9
+ * when that cannot be validated, the proof-shaped superset decides, so a
10
+ * proof-shaped call counts as proved. Presence is sufficient: verification
11
+ * stays mandatory downstream, including for malformed proof values.
12
+ *
13
+ * @module @kya-os/mcp-i-cloudflare/delegation-http/request-proof
14
+ */
15
+ import { type CardProofSupportGetter } from "../security/card-proof-support";
16
+ /** Headers whose signature covers the body, so the body must not change. */
17
+ export declare const SIGNED_REQUEST_HEADERS: readonly ["Signature", "Signature-Input", "KYA-OS-Delegation-Proof"];
18
+ /** Whether the headers or the call's `_meta` carry a request proof. */
19
+ export declare function carriesRequestProof(headers: Headers, meta: unknown, getProofSupport?: CardProofSupportGetter): Promise<boolean>;
20
+ //# sourceMappingURL=request-proof.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-proof.d.ts","sourceRoot":"","sources":["../../src/delegation-http/request-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,gCAAgC,CAAC;AAGxC,4EAA4E;AAC5E,eAAO,MAAM,sBAAsB,sEAIzB,CAAC;AAEX,uEAAuE;AACvE,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,OAAO,EACb,eAAe,GAAE,sBAA4C,GAC5D,OAAO,CAAC,OAAO,CAAC,CAGlB"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Whether an MCP request carries a KYA-OS request proof.
3
+ *
4
+ * One detection for every edge step in front of the agent: the pass-through
5
+ * that moves a presented delegation into the call, and the gate that decides
6
+ * which calls may be answered with an HTTP status. A request proof is either
7
+ * an HTTP message signature header or a card proof carrier in `params._meta`.
8
+ * The card keys come only from the validated card proof support accessor;
9
+ * when that cannot be validated, the proof-shaped superset decides, so a
10
+ * proof-shaped call counts as proved. Presence is sufficient: verification
11
+ * stays mandatory downstream, including for malformed proof values.
12
+ *
13
+ * @module @kya-os/mcp-i-cloudflare/delegation-http/request-proof
14
+ */
15
+ import { getCardProofSupport, } from "../security/card-proof-support";
16
+ import { hasMcpRequestProofAsync } from "../security/presented-delegation";
17
+ /** Headers whose signature covers the body, so the body must not change. */
18
+ export const SIGNED_REQUEST_HEADERS = [
19
+ "Signature",
20
+ "Signature-Input",
21
+ "KYA-OS-Delegation-Proof",
22
+ ];
23
+ /** Whether the headers or the call's `_meta` carry a request proof. */
24
+ export async function carriesRequestProof(headers, meta, getProofSupport = getCardProofSupport) {
25
+ if (SIGNED_REQUEST_HEADERS.some((name) => headers.has(name)))
26
+ return true;
27
+ return hasMcpRequestProofAsync(meta, getProofSupport);
28
+ }
29
+ //# sourceMappingURL=request-proof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-proof.js","sourceRoot":"","sources":["../../src/delegation-http/request-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAEL,mBAAmB,GACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,WAAW;IACX,iBAAiB;IACjB,yBAAyB;CACjB,CAAC;AAEX,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAAgB,EAChB,IAAa,EACb,kBAA0C,mBAAmB;IAE7D,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1E,OAAO,uBAAuB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACxD,CAAC"}
@@ -1,23 +1,15 @@
1
1
  /**
2
- * draft-kya-http-02 delegation layer — anchor session id (sid).
2
+ * draft-kya-http-02 delegation layer — challenge session id (sid).
3
3
  *
4
4
  * The `kya-…` wire format is unrelated to the C4 `kyaos_` session prefix flip — it
5
- * is the opaque correlation id shared across the challenge, the consent surface,
6
- * the pickup endpoint, and the durable-object instance name.
5
+ * is the opaque correlation id a native challenge registration proposes, shared
6
+ * by the challenge, the org's consent page, and its pickup endpoint.
7
7
  *
8
8
  * @module @kya-os/mcp-i-cloudflare/delegation-http/sid
9
9
  */
10
10
  /**
11
- * Generate a fresh anchor sid: `"kya-"` + 32 lowercase hex characters (16 random
11
+ * Generate a fresh sid: `"kya-"` + 32 lowercase hex characters (16 random
12
12
  * bytes from `crypto.getRandomValues`).
13
13
  */
14
14
  export declare function generateSid(): string;
15
- /**
16
- * Validate anchor ID syntax, including externally registered opaque HTTP IDs.
17
- * Syntax alone cannot select the anchor route: legacy UUID session IDs also
18
- * pass this guard. Use it only for an explicit anchor field or dedicated route.
19
- */
20
- export declare function isAnchorSid(s: string | null | undefined): s is string;
21
- /** Recognize the original anchor namespace in a generic legacy session_id. */
22
- export declare function isNamespacedAnchorSid(s: unknown): s is string;
23
15
  //# sourceMappingURL=sid.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sid.d.ts","sourceRoot":"","sources":["../../src/delegation-http/sid.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAQpC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,IAAI,MAAM,CAKrE;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAE7D"}
1
+ {"version":3,"file":"sid.d.ts","sourceRoot":"","sources":["../../src/delegation-http/sid.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAQpC"}
@@ -1,16 +1,14 @@
1
1
  /**
2
- * draft-kya-http-02 delegation layer — anchor session id (sid).
2
+ * draft-kya-http-02 delegation layer — challenge session id (sid).
3
3
  *
4
4
  * The `kya-…` wire format is unrelated to the C4 `kyaos_` session prefix flip — it
5
- * is the opaque correlation id shared across the challenge, the consent surface,
6
- * the pickup endpoint, and the durable-object instance name.
5
+ * is the opaque correlation id a native challenge registration proposes, shared
6
+ * by the challenge, the org's consent page, and its pickup endpoint.
7
7
  *
8
8
  * @module @kya-os/mcp-i-cloudflare/delegation-http/sid
9
9
  */
10
- /** Matches generated sids (`kya-` + 32 hex) and the shorter fixture sids (16 hex). */
11
- const ANCHOR_SID_RE = /^kya-[0-9a-f]{16,64}$/;
12
10
  /**
13
- * Generate a fresh anchor sid: `"kya-"` + 32 lowercase hex characters (16 random
11
+ * Generate a fresh sid: `"kya-"` + 32 lowercase hex characters (16 random
14
12
  * bytes from `crypto.getRandomValues`).
15
13
  */
16
14
  export function generateSid() {
@@ -22,17 +20,4 @@ export function generateSid() {
22
20
  }
23
21
  return `kya-${hex}`;
24
22
  }
25
- /**
26
- * Validate anchor ID syntax, including externally registered opaque HTTP IDs.
27
- * Syntax alone cannot select the anchor route: legacy UUID session IDs also
28
- * pass this guard. Use it only for an explicit anchor field or dedicated route.
29
- */
30
- export function isAnchorSid(s) {
31
- return (isNamespacedAnchorSid(s) ||
32
- (typeof s === "string" && /^[A-Za-z0-9._~-]{22,255}$/.test(s)));
33
- }
34
- /** Recognize the original anchor namespace in a generic legacy session_id. */
35
- export function isNamespacedAnchorSid(s) {
36
- return typeof s === "string" && ANCHOR_SID_RE.test(s);
37
- }
38
23
  //# sourceMappingURL=sid.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sid.js","sourceRoot":"","sources":["../../src/delegation-http/sid.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,sFAAsF;AACtF,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACjC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,GAAG,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,OAAO,GAAG,EAAE,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,CAA4B;IACtD,OAAO,CACL,qBAAqB,CAAC,CAAC,CAAC;QACxB,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAC/D,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,qBAAqB,CAAC,CAAU;IAC9C,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC"}
1
+ {"version":3,"file":"sid.js","sourceRoot":"","sources":["../../src/delegation-http/sid.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACjC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,GAAG,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,OAAO,GAAG,EAAE,CAAC;AACtB,CAAC"}
@@ -8,25 +8,21 @@
8
8
  * Cloudflare-worker-specific feature, not a general MCP-I identity concept.
9
9
  *
10
10
  * This module is a small, pure seam that merges it in afterward, scoped to
11
- * exactly the one well-known path a consumer (checkpoint's authorization-host
12
- * picker) needs to probe before trusting a deployment as an authorization host.
11
+ * exactly the one well-known path. The worker is a resource server only: the
12
+ * org authorization service hosts consent, sign-in and pickup, so nothing here
13
+ * advertises the worker as an authorization host.
13
14
  *
14
15
  * @module @kya-os/mcp-i-cloudflare/delegation-http/well-known-capability
15
16
  */
16
- import type { HttpChallengeConfig } from "../config";
17
17
  import type { EffectiveAuditAssurance } from "../audit/assurance";
18
18
  /**
19
19
  * Merge a `delegationHttp` capability field into the kya-os-identity well-known
20
- * response — the real resolved `enabled` state (never hardcoded true), this
21
- * package's own version, and whether the external anchor-registration surface
22
- * (`POST /api/v1/bouncer/sessions`) is actually served (`anchorRegistration`,
23
- * the gate checkpoint's C3 redirect must verify before pointing a challenge
24
- * here). Every other well-known path, and a null/undefined result (nothing to
25
- * augment), passes through unchanged.
20
+ * response: `enabled: true` and this package's own version, plus the effective audit assurance when known. Every
21
+ * other well-known path, and a null/undefined result (nothing to augment),
22
+ * passes through unchanged.
26
23
  *
27
24
  * `{ enabled, version }` is a LOCKED wire contract with checkpoint's
28
- * authorization-host capability probe; `anchorRegistration` is additive (the
29
- * current probe ignores unknown fields).
25
+ * capability probe.
30
26
  */
31
- export declare function augmentKyaOsIdentityWellKnown(wellKnownPath: string, result: Record<string, unknown> | null | undefined, cfg: Required<HttpChallengeConfig> | null, anchorRegistration: boolean, auditAssurance?: EffectiveAuditAssurance): Record<string, unknown> | null | undefined;
27
+ export declare function augmentKyaOsIdentityWellKnown(wellKnownPath: string, result: Record<string, unknown> | null | undefined, auditAssurance?: EffectiveAuditAssurance): Record<string, unknown> | null | undefined;
32
28
  //# sourceMappingURL=well-known-capability.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"well-known-capability.d.ts","sourceRoot":"","sources":["../../src/delegation-http/well-known-capability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAOlE;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAC3C,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAClD,GAAG,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GAAG,IAAI,EACzC,kBAAkB,EAAE,OAAO,EAC3B,cAAc,CAAC,EAAE,uBAAuB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,CAmB5C"}
1
+ {"version":3,"file":"well-known-capability.d.ts","sourceRoot":"","sources":["../../src/delegation-http/well-known-capability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAOlE;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAClD,cAAc,CAAC,EAAE,uBAAuB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,CAa5C"}
@@ -8,8 +8,9 @@
8
8
  * Cloudflare-worker-specific feature, not a general MCP-I identity concept.
9
9
  *
10
10
  * This module is a small, pure seam that merges it in afterward, scoped to
11
- * exactly the one well-known path a consumer (checkpoint's authorization-host
12
- * picker) needs to probe before trusting a deployment as an authorization host.
11
+ * exactly the one well-known path. The worker is a resource server only: the
12
+ * org authorization service hosts consent, sign-in and pickup, so nothing here
13
+ * advertises the worker as an authorization host.
13
14
  *
14
15
  * @module @kya-os/mcp-i-cloudflare/delegation-http/well-known-capability
15
16
  */
@@ -19,32 +20,22 @@ import ownPackageJson from "../../package.json";
19
20
  const KYA_OS_IDENTITY_WELL_KNOWN_PATH = "/.well-known/kya-os-identity";
20
21
  /**
21
22
  * Merge a `delegationHttp` capability field into the kya-os-identity well-known
22
- * response — the real resolved `enabled` state (never hardcoded true), this
23
- * package's own version, and whether the external anchor-registration surface
24
- * (`POST /api/v1/bouncer/sessions`) is actually served (`anchorRegistration`,
25
- * the gate checkpoint's C3 redirect must verify before pointing a challenge
26
- * here). Every other well-known path, and a null/undefined result (nothing to
27
- * augment), passes through unchanged.
23
+ * response: `enabled: true` and this package's own version, plus the effective audit assurance when known. Every
24
+ * other well-known path, and a null/undefined result (nothing to augment),
25
+ * passes through unchanged.
28
26
  *
29
27
  * `{ enabled, version }` is a LOCKED wire contract with checkpoint's
30
- * authorization-host capability probe; `anchorRegistration` is additive (the
31
- * current probe ignores unknown fields).
28
+ * capability probe.
32
29
  */
33
- export function augmentKyaOsIdentityWellKnown(wellKnownPath, result, cfg, anchorRegistration, auditAssurance) {
30
+ export function augmentKyaOsIdentityWellKnown(wellKnownPath, result, auditAssurance) {
34
31
  if (wellKnownPath !== KYA_OS_IDENTITY_WELL_KNOWN_PATH || !result) {
35
32
  return result;
36
33
  }
37
34
  return {
38
35
  ...result,
39
- nativeHttpIssuer: {
40
- version: 1,
41
- ready: !!(anchorRegistration && cfg?.native?.remoteIssuer),
42
- ...(cfg?.native?.remoteIssuer ? { issuerDid: cfg.native.issuerDid, authorizationOrigin: cfg.native.authorizationOrigin } : {}),
43
- },
44
36
  delegationHttp: {
45
- enabled: cfg !== null,
37
+ enabled: true,
46
38
  version: ownPackageJson.version,
47
- anchorRegistration,
48
39
  },
49
40
  ...(auditAssurance === undefined ? {} : { auditAssurance }),
50
41
  };
@@ -1 +1 @@
1
- {"version":3,"file":"well-known-capability.js","sourceRoot":"","sources":["../../src/delegation-http/well-known-capability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,+EAA+E;AAC/E,iFAAiF;AACjF,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAEhD,MAAM,+BAA+B,GAAG,8BAA8B,CAAC;AAEvE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,6BAA6B,CAC3C,aAAqB,EACrB,MAAkD,EAClD,GAAyC,EACzC,kBAA2B,EAC3B,cAAwC;IAExC,IAAI,aAAa,KAAK,+BAA+B,IAAI,CAAC,MAAM,EAAE,CAAC;QACjE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,GAAG,MAAM;QACT,gBAAgB,EAAE;YAChB,OAAO,EAAE,CAAC;YACV,KAAK,EAAE,CAAC,CAAC,CAAC,kBAAkB,IAAI,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC;YAC1D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/H;QACD,cAAc,EAAE;YACd,OAAO,EAAE,GAAG,KAAK,IAAI;YACrB,OAAO,EAAE,cAAc,CAAC,OAAO;YAC/B,kBAAkB;SACnB;QACD,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"well-known-capability.js","sourceRoot":"","sources":["../../src/delegation-http/well-known-capability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,+EAA+E;AAC/E,iFAAiF;AACjF,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAEhD,MAAM,+BAA+B,GAAG,8BAA8B,CAAC;AAEvE;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAC3C,aAAqB,EACrB,MAAkD,EAClD,cAAwC;IAExC,IAAI,aAAa,KAAK,+BAA+B,IAAI,CAAC,MAAM,EAAE,CAAC;QACjE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,GAAG,MAAM;QACT,cAAc,EAAE;YACd,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,cAAc,CAAC,OAAO;SAChC;QACD,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"env-mapper.d.ts","sourceRoot":"","sources":["../../src/helpers/env-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU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;;;GAoBG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,MAAM,GACb,aAAa,CA8If;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,GAAG,EACX,MAAM,CAAC,EAAE,MAAM,GACd,aAAa,CAqIf"}
@@ -175,17 +175,10 @@ export function mapPrefixedEnv(source, prefix) {
175
175
  MCPI_NATIVE_HTTP_ISSUER_CONFIG: typeof env.MCPI_NATIVE_HTTP_ISSUER_CONFIG === "string"
176
176
  ? env.MCPI_NATIVE_HTTP_ISSUER_CONFIG
177
177
  : undefined,
178
- MCPI_NATIVE_HTTP_INGRESS: typeof env.MCPI_NATIVE_HTTP_INGRESS === "string"
179
- ? env.MCPI_NATIVE_HTTP_INGRESS
180
- : undefined,
181
- MCPI_NATIVE_HTTP_ISSUER_API_KEY: typeof env.MCPI_NATIVE_HTTP_ISSUER_API_KEY === "string"
182
- ? env.MCPI_NATIVE_HTTP_ISSUER_API_KEY
183
- : undefined,
184
178
  // Delegation trust policy (DelegationService); set unprefixed like the
185
179
  // native issuer binding above.
186
180
  KYA_OS_TRUSTED_DELEGATION_ISSUERS: stringValue(env.KYA_OS_TRUSTED_DELEGATION_ISSUERS),
187
181
  KYA_OS_RESOURCE_DIDS: stringValue(env.KYA_OS_RESOURCE_DIDS),
188
- KYA_OS_INSECURE_DEV_TOKENS: stringValue(env.KYA_OS_INSECURE_DEV_TOKENS),
189
182
  CHECKPOINT_API_URL: typeof env.CHECKPOINT_API_URL === "string"
190
183
  ? env.CHECKPOINT_API_URL
191
184
  : undefined,
@@ -216,22 +209,18 @@ export function mapPrefixedEnv(source, prefix) {
216
209
  : undefined,
217
210
  // Scalar config flags are set unprefixed (like the secrets above), so copy
218
211
  // them across verbatim — otherwise a prefixed deployment silently loses the
219
- // documented MCPI_HTTP_CHALLENGE / MCPI_TEST_CONSENT / MCPI_INLINE_CONSENT
220
- // overrides. These are read off this mapped env downstream (resolveHttpChallengeConfig,
221
- // agent.ts inline-consent; the consent-anchor-bridge reader lands on integration).
222
- MCPI_HTTP_CHALLENGE: typeof env.MCPI_HTTP_CHALLENGE === "string"
223
- ? env.MCPI_HTTP_CHALLENGE
224
- : undefined,
212
+ // documented MCPI_TEST_CONSENT / MCPI_INLINE_CONSENT /
213
+ // MCPI_REQUIRE_TOKEN_TO_CONNECT overrides. These are read off this mapped
214
+ // env downstream (agent.ts inline-consent, app.ts connect gate).
225
215
  MCPI_TEST_CONSENT: typeof env.MCPI_TEST_CONSENT === "string"
226
216
  ? env.MCPI_TEST_CONSENT
227
217
  : undefined,
228
218
  MCPI_INLINE_CONSENT: typeof env.MCPI_INLINE_CONSENT === "string"
229
219
  ? env.MCPI_INLINE_CONSENT
230
220
  : undefined,
231
- MCPI_ANCHOR_REGISTRATION: typeof env.MCPI_ANCHOR_REGISTRATION === "string"
232
- ? env.MCPI_ANCHOR_REGISTRATION
221
+ MCPI_REQUIRE_TOKEN_TO_CONNECT: typeof env.MCPI_REQUIRE_TOKEN_TO_CONNECT === "string"
222
+ ? env.MCPI_REQUIRE_TOKEN_TO_CONNECT
233
223
  : undefined,
234
- MCPI_REALM: typeof env.MCPI_REALM === "string" ? env.MCPI_REALM : undefined,
235
224
  CONSENT_REQUIRE_IDENTITY: typeof env.CONSENT_REQUIRE_IDENTITY === "string"
236
225
  ? env.CONSENT_REQUIRE_IDENTITY
237
226
  : undefined,
@@ -324,17 +313,10 @@ export function normalizeCloudflareEnv(source, prefix) {
324
313
  MCPI_NATIVE_HTTP_ISSUER_CONFIG: typeof env.MCPI_NATIVE_HTTP_ISSUER_CONFIG === "string"
325
314
  ? env.MCPI_NATIVE_HTTP_ISSUER_CONFIG
326
315
  : undefined,
327
- MCPI_NATIVE_HTTP_INGRESS: typeof env.MCPI_NATIVE_HTTP_INGRESS === "string"
328
- ? env.MCPI_NATIVE_HTTP_INGRESS
329
- : undefined,
330
- MCPI_NATIVE_HTTP_ISSUER_API_KEY: typeof env.MCPI_NATIVE_HTTP_ISSUER_API_KEY === "string"
331
- ? env.MCPI_NATIVE_HTTP_ISSUER_API_KEY
332
- : undefined,
333
316
  // Delegation trust policy (DelegationService); set unprefixed like the
334
317
  // native issuer binding above.
335
318
  KYA_OS_TRUSTED_DELEGATION_ISSUERS: stringValue(env.KYA_OS_TRUSTED_DELEGATION_ISSUERS),
336
319
  KYA_OS_RESOURCE_DIDS: stringValue(env.KYA_OS_RESOURCE_DIDS),
337
- KYA_OS_INSECURE_DEV_TOKENS: stringValue(env.KYA_OS_INSECURE_DEV_TOKENS),
338
320
  CHECKPOINT_API_URL: typeof env.CHECKPOINT_API_URL === "string"
339
321
  ? env.CHECKPOINT_API_URL
340
322
  : undefined,
@@ -362,19 +344,15 @@ export function normalizeCloudflareEnv(source, prefix) {
362
344
  ? env.REPUTATION_API_KEY
363
345
  : undefined,
364
346
  // Scalar config flags (see mapPrefixedEnv) — preserved on the no-prefix path too.
365
- MCPI_HTTP_CHALLENGE: typeof env.MCPI_HTTP_CHALLENGE === "string"
366
- ? env.MCPI_HTTP_CHALLENGE
367
- : undefined,
368
347
  MCPI_TEST_CONSENT: typeof env.MCPI_TEST_CONSENT === "string"
369
348
  ? env.MCPI_TEST_CONSENT
370
349
  : undefined,
371
350
  MCPI_INLINE_CONSENT: typeof env.MCPI_INLINE_CONSENT === "string"
372
351
  ? env.MCPI_INLINE_CONSENT
373
352
  : undefined,
374
- MCPI_ANCHOR_REGISTRATION: typeof env.MCPI_ANCHOR_REGISTRATION === "string"
375
- ? env.MCPI_ANCHOR_REGISTRATION
353
+ MCPI_REQUIRE_TOKEN_TO_CONNECT: typeof env.MCPI_REQUIRE_TOKEN_TO_CONNECT === "string"
354
+ ? env.MCPI_REQUIRE_TOKEN_TO_CONNECT
376
355
  : undefined,
377
- MCPI_REALM: typeof env.MCPI_REALM === "string" ? env.MCPI_REALM : undefined,
378
356
  CONSENT_REQUIRE_IDENTITY: typeof env.CONSENT_REQUIRE_IDENTITY === "string"
379
357
  ? env.CONSENT_REQUIRE_IDENTITY
380
358
  : undefined,