@kya-os/mcp-i-cloudflare 1.18.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 (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 +3 -4
  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
@@ -1,20 +1,44 @@
1
1
  /**
2
2
  * Delegation Service
3
3
  *
4
- * Handles delegation token retrieval, verification, and cache management
5
- * for MCP-I Cloudflare servers.
4
+ * Verifies a presented delegation VC-JWT for MCP-I Cloudflare servers.
6
5
  *
7
- * Supports both:
8
- * - Local VC-JWT verification (offline, cryptographic), restricted to pinned
9
- * issuers and accepted audiences (see ./delegation-trust)
10
- * - Checkpoint API verification (online, centralized)
6
+ * Local verification is the authority (`verifyLocally`): the issuer is the
7
+ * org this resource trusts, its key is the one the token's `kid` names in the
8
+ * org's DID document, the audience is this worker's resource DID, and the
9
+ * status entry is clear on the issuer's own signed list (see
10
+ * ./delegation-trust). Checkpoint is an optional decision hook on top
11
+ * (see ./checkpoint-decision), never the source of authority.
12
+ *
13
+ * Nothing here looks a delegation up by session, user or agent: the client
14
+ * presents the credential on every call.
11
15
  */
16
+ import type { DIDResolver } from "@kya-os/mcp";
12
17
  import type { CloudflareEnv } from "../types";
13
18
  import type { CloudflareRuntime } from "../runtime";
14
- import { type DelegationDidResolver, type DelegationTrustOptions } from "./delegation-trust";
19
+ import { type DelegationTrustOptions } from "./delegation-trust";
15
20
  export interface DelegationServiceOptions extends DelegationTrustOptions {
16
21
  /** DID resolution seam. Defaults to one shared did:key + did:web resolver. */
17
- didResolver?: DelegationDidResolver;
22
+ didResolver?: DIDResolver;
23
+ }
24
+ /**
25
+ * Why a credential was refused, in the verifier vocabulary the runtime maps
26
+ * onto client-facing denials (`delegation_revoked`, …).
27
+ */
28
+ export type LocalVerificationCode = "invalid_token" | "delegation_expired" | "delegation_not_yet_valid" | "delegation_revoked" | "revocation_check_failed" | "holder_proof_required" | "holder_mismatch";
29
+ export interface VerifyLocallyOptions {
30
+ /**
31
+ * The holder DID request admission proved for this call
32
+ * (`getMcpRequestHolder()`), never a client-supplied value. Without it a
33
+ * holder-bound credential is refused.
34
+ */
35
+ holderDid?: string;
36
+ /**
37
+ * Leave the holder check to the caller, which reads `holderBound` from the
38
+ * result. Only for a caller that cannot see the call's proof yet, such as
39
+ * the Bearer gate in front of admission.
40
+ */
41
+ deferHolderBinding?: boolean;
18
42
  }
19
43
  /**
20
44
  * Result of VC-JWT verification with extracted delegation data
@@ -24,6 +48,8 @@ export interface VCJWTVerificationResult {
24
48
  valid: boolean;
25
49
  /** Error message if invalid */
26
50
  error?: string;
51
+ /** Machine-readable refusal reason if invalid */
52
+ code?: LocalVerificationCode;
27
53
  /** The credential's handle: `vc.id`, else the `jti` claim */
28
54
  delegationId?: string;
29
55
  /** Agent DID (from sub claim) */
@@ -42,121 +68,73 @@ export interface VCJWTVerificationResult {
42
68
  issuerDid?: string;
43
69
  /** Expiration timestamp (seconds since epoch) */
44
70
  expiresAt?: number;
45
- /** Whether a credentialStatus entry was read and found clear */
46
- hasCredentialStatus?: boolean;
71
+ /** The verified credential (`vc` claim), for scope matching */
72
+ credential?: Record<string, unknown>;
73
+ /** `delegation.constraints`, as the issuer signed them */
74
+ constraints?: Record<string, unknown>;
75
+ /** Issued-at (seconds since epoch) */
76
+ issuedAt?: number;
77
+ /**
78
+ * How the credential's person signed in: the issuer-signed top-level `amr`
79
+ * claim, string values only. Set only on a verified result.
80
+ */
81
+ amr?: string[];
82
+ /**
83
+ * Whether the credential is bound to a holder key (`cnf`, or a key-bound,
84
+ * registered or delegated assurance). Set only on a verified result.
85
+ */
86
+ holderBound?: boolean;
47
87
  }
48
88
  export declare class DelegationService {
49
89
  private env;
50
- private runtime?;
51
90
  private trust;
52
91
  private didResolver;
53
- constructor(env: CloudflareEnv, runtime?: CloudflareRuntime, options?: DelegationServiceOptions);
54
92
  /**
55
- * Get delegation token from cache or storage
56
- * @param sessionId - Optional session ID for session-based lookup
57
- * @returns Delegation token or null if not found
93
+ * @param env - Deployment configuration (trust, audience, Checkpoint hook)
94
+ * @param _runtime - Unused: verification never consults the runtime. Kept
95
+ * so existing `new DelegationService(env, runtime)` callers compile.
96
+ * @param options - Extra pinned issuers and a DID resolution seam
58
97
  */
59
- getDelegationToken(sessionId?: string): Promise<string | null>;
98
+ constructor(env: CloudflareEnv, _runtime?: CloudflareRuntime, options?: DelegationServiceOptions);
60
99
  /**
61
- * Check if a token is a VC-JWT (Verifiable Credential JWT)
62
- *
63
- * VC-JWTs are distinguished from legacy delegation tokens by:
64
- * - alg: 'EdDSA' (Ed25519 signing) vs legacy HS256
65
- * - typ: 'vc+jwt' or 'JWT' (both are valid VC-JWT type indicators), or any
66
- * typ when the payload carries a `vc` object (Checkpoint's own rule), so a
67
- * nonstandard typ cannot route a credential around local verification
100
+ * Verify a delegation VC-JWT locally. This is the authority: nothing else
101
+ * can make a credential it refuses valid.
68
102
  *
69
- * This allows legacy HS256 tokens to fall through to API verification
70
- * while VC-JWTs are verified locally using cryptographic verification.
71
- */
72
- private isVCJWT;
73
- /**
74
- * Whether a cached development verdict still holds under THIS deployment's
75
- * trust: the token's issuer is the one the verdict was granted to, it is
76
- * still pinned, and the token's `aud` is still this worker's resource DID
77
- * (a KV namespace may be shared by deployments with different resources).
78
- */
79
- private servesCachedVerdict;
80
- /** Whether `issuerDid` is pinned: statically, or as the Checkpoint platform signer. */
81
- private isPinnedIssuer;
82
- /**
83
- * Verify a VC-JWT locally: audience, issuer pin, signature, content and
84
- * credential status, in that order. The cheap checks come first, and the
85
- * only fetch an unpinned issuer can cause is the configured Checkpoint's own
86
- * DID document (cached).
87
- *
88
- * Audience: `aud` must be `did:web:<the host this request was routed for>`,
89
- * and that DID must be in `KYA_OS_RESOURCE_DIDS` (see ./delegation-trust),
90
- * whoever the issuer and whether or not a Checkpoint API key is set. A
91
- * credential without `aud`, or naming anything else (another of this
92
- * worker's hosts, the org DID, the worker's own DID, a project id), is
93
- * refused. Without a valid resource list, or without a routed host (a
94
- * verification with no request behind it), every credential is refused.
95
- *
96
- * Issuer: only pinned issuers are resolved and verified. An untrusted or
97
- * unresolvable issuer fails closed.
103
+ * Checks, cheap ones first so an untrusted token causes no fetch:
104
+ * 1. an EdDSA compact JWS carrying a `vc` object;
105
+ * 2. `aud` names this worker's resource DID;
106
+ * 3. `iss` is a trusted org issuer;
107
+ * 4. the signature verifies under the key the protected `kid` names in
108
+ * the issuer's DID document (assertion methods only; no kid, no key);
109
+ * 5. a DelegationCredential, inside its validity window, whose inner
110
+ * `delegation.constraints.audience` (when present) is also this worker;
111
+ * 6. a status entry, clear on the issuer's own signed list;
112
+ * 7. a holder-bound credential, the holder this call proved
113
+ * (../security/holder-binding).
98
114
  *
99
115
  * @param vcJwt - The VC-JWT string to verify
116
+ * @param options - The call's proved holder, or a deferred holder check
100
117
  * @returns Verification result with extracted delegation data
101
118
  */
102
- private verifyVCJWTLocally;
103
- /**
104
- * Check if a JWT token is expired by examining the exp claim.
105
- * This is a lightweight check that doesn't verify signatures.
106
- *
107
- * @param token - JWT token string
108
- * @returns true if token is expired, false otherwise
109
- */
110
- private isTokenExpired;
111
- /**
112
- * Collision-resistant cache-key input for a token: SHA-256 hex of the FULL
113
- * token. NOT a prefix — the first 16 chars of every EdDSA JWT are the
114
- * identical base64url header (`eyJhbGciOiJFZERT` = `{"alg":"EdDSA"`), so a
115
- * prefixed key collides across all EdDSA tokens; one cached positive would
116
- * then admit any forged token. Keying on the full-token digest gives each
117
- * distinct token a distinct cache entry.
118
- */
119
- private hashToken;
119
+ verifyLocally(vcJwt: string, options?: VerifyLocallyOptions): Promise<VCJWTVerificationResult>;
120
120
  /**
121
- * Verify delegation token - supports both VC-JWT and legacy tokens
122
- *
123
- * Verification strategy:
124
- * 1. Early expiration check (cheap, before any crypto)
125
- * 2. Check cache (development only, VC-JWTs only)
126
- * 3. If token is a VC-JWT, verify it locally: accepted audience, pinned
127
- * issuer, signature, content and any credentialStatus entry. This refuses
128
- * a forged, foreign or revoked credential with or without Checkpoint.
129
- * 4. Confirm with Checkpoint that the delegation is still in force. A valid
130
- * signature proves who issued the credential, not that it was never
131
- * revoked; revocation of status-less credentials lives at Checkpoint.
132
- * Only a deployment with no Checkpoint API key (development) skips this.
133
- *
134
- * Legacy (non VC-JWT) tokens can only be checked by Checkpoint. Without an
135
- * API key they are refused unless KYA_OS_INSECURE_DEV_TOKENS opts in.
136
- *
137
- * With a Checkpoint API key no verdict is cached: every verification asks
138
- * Checkpoint, so a revocation refuses the very next call. Development caches
139
- * only a pinned issuer's status-less VC-JWT, for
140
- * DEFAULT_VERIFICATION_CACHE_TTL seconds, and a hit counts only while that
141
- * issuer is still pinned.
121
+ * Verify a presented delegation: local verification, then, when this
122
+ * deployment has a Checkpoint API key, the decision hook. Checkpoint can
123
+ * only refuse a locally valid credential for a stateful reason; it can
124
+ * never accept one local verification refused.
142
125
  *
143
126
  * @param token - Delegation token to verify
144
127
  * @returns True if token is valid, false otherwise
145
128
  */
146
129
  verifyDelegation(token: string): Promise<boolean>;
147
- /**
148
- * Asks Checkpoint whether the delegation behind `token` is in force.
149
- * Checkpoint answers every verification with HTTP 200 and the verdict in
150
- * `data.valid` (a revoked delegation is `valid: false`), so only an explicit
151
- * `valid: true` counts; any other answer or error fails closed.
152
- */
153
- private confirmWithCheckpoint;
154
- /**
155
- * Invalidate delegation token in all caches
156
- * @param sessionId - Session ID to clear
157
- * @param token - Token to invalidate
158
- * @param agentDid - Agent DID to clear
159
- */
160
- invalidateCache(sessionId?: string, token?: string, agentDid?: string): Promise<void>;
161
130
  }
131
+ /**
132
+ * The verifier for one request to a deployment: the environment's trust (the
133
+ * native issuer binding, `KYA_OS_TRUSTED_DELEGATION_ISSUERS`,
134
+ * `KYA_OS_RESOURCE_DIDS`) and the host this request was routed for. Nothing in
135
+ * the runtime configuration adds an issuer, so the edge's bearer check and the
136
+ * Durable Object trust exactly the same issuers. The runtime's verifier and the
137
+ * agent's account lookup both use it, so they apply the same rule.
138
+ */
139
+ export declare function createDeploymentDelegationService(env: CloudflareEnv, routedHost: string | undefined, didResolver?: DIDResolver): DelegationService;
162
140
  //# sourceMappingURL=delegation.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"delegation.service.d.ts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