@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.
- package/README.md +273 -54
- package/dist/adapter.d.ts +3 -17
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +30 -477
- package/dist/adapter.js.map +1 -1
- package/dist/agent.d.ts +59 -35
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +383 -406
- package/dist/agent.js.map +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +150 -94
- package/dist/app.js.map +1 -1
- package/dist/audit/deployment-binding.d.ts +16 -16
- package/dist/authority-outcome.d.ts +110 -0
- package/dist/authority-outcome.d.ts.map +1 -0
- package/dist/authority-outcome.js +154 -0
- package/dist/authority-outcome.js.map +1 -0
- package/dist/config.d.ts +8 -77
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -83
- package/dist/config.js.map +1 -1
- package/dist/delegation-http/bearer-retry.d.ts +84 -32
- package/dist/delegation-http/bearer-retry.d.ts.map +1 -1
- package/dist/delegation-http/bearer-retry.js +124 -139
- package/dist/delegation-http/bearer-retry.js.map +1 -1
- package/dist/delegation-http/connect-gate.d.ts +47 -0
- package/dist/delegation-http/connect-gate.d.ts.map +1 -0
- package/dist/delegation-http/connect-gate.js +104 -0
- package/dist/delegation-http/connect-gate.js.map +1 -0
- package/dist/delegation-http/constants.d.ts +4 -49
- package/dist/delegation-http/constants.d.ts.map +1 -1
- package/dist/delegation-http/constants.js +4 -58
- package/dist/delegation-http/constants.js.map +1 -1
- package/dist/delegation-http/issuer-binding.d.ts +26 -0
- package/dist/delegation-http/issuer-binding.d.ts.map +1 -0
- package/dist/delegation-http/issuer-binding.js +51 -0
- package/dist/delegation-http/issuer-binding.js.map +1 -0
- package/dist/delegation-http/lazy-auth-gate.d.ts +88 -0
- package/dist/delegation-http/lazy-auth-gate.d.ts.map +1 -0
- package/dist/delegation-http/lazy-auth-gate.js +203 -0
- package/dist/delegation-http/lazy-auth-gate.js.map +1 -0
- package/dist/delegation-http/native-challenge.d.ts +52 -0
- package/dist/delegation-http/native-challenge.d.ts.map +1 -0
- package/dist/delegation-http/native-challenge.js +124 -0
- package/dist/delegation-http/native-challenge.js.map +1 -0
- package/dist/delegation-http/native-consent-redirect.d.ts +21 -0
- package/dist/delegation-http/native-consent-redirect.d.ts.map +1 -0
- package/dist/delegation-http/native-consent-redirect.js +43 -0
- package/dist/delegation-http/native-consent-redirect.js.map +1 -0
- package/dist/delegation-http/native-http.d.ts +1 -86
- package/dist/delegation-http/native-http.d.ts.map +1 -1
- package/dist/delegation-http/native-http.js +2 -130
- package/dist/delegation-http/native-http.js.map +1 -1
- package/dist/delegation-http/native-oauth-state-do.d.ts +13 -35
- package/dist/delegation-http/native-oauth-state-do.d.ts.map +1 -1
- package/dist/delegation-http/native-oauth-state-do.js +10 -165
- package/dist/delegation-http/native-oauth-state-do.js.map +1 -1
- package/dist/delegation-http/protected-resource.d.ts +37 -0
- package/dist/delegation-http/protected-resource.d.ts.map +1 -0
- package/dist/delegation-http/protected-resource.js +43 -0
- package/dist/delegation-http/protected-resource.js.map +1 -0
- package/dist/delegation-http/request-proof.d.ts +20 -0
- package/dist/delegation-http/request-proof.d.ts.map +1 -0
- package/dist/delegation-http/request-proof.js +29 -0
- package/dist/delegation-http/request-proof.js.map +1 -0
- package/dist/delegation-http/sid.d.ts +4 -12
- package/dist/delegation-http/sid.d.ts.map +1 -1
- package/dist/delegation-http/sid.js +4 -19
- package/dist/delegation-http/sid.js.map +1 -1
- package/dist/delegation-http/well-known-capability.d.ts +8 -12
- package/dist/delegation-http/well-known-capability.d.ts.map +1 -1
- package/dist/delegation-http/well-known-capability.js +9 -18
- package/dist/delegation-http/well-known-capability.js.map +1 -1
- package/dist/helpers/env-mapper.d.ts.map +1 -1
- package/dist/helpers/env-mapper.js +7 -29
- package/dist/helpers/env-mapper.js.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/proof-generator.d.ts +24 -17
- package/dist/proof-generator.d.ts.map +1 -1
- package/dist/proof-generator.js +42 -56
- package/dist/proof-generator.js.map +1 -1
- package/dist/runtime/oauth-handler.d.ts +1 -1
- package/dist/runtime/oauth-handler.d.ts.map +1 -1
- package/dist/runtime/oauth-handler.js +15 -30
- package/dist/runtime/oauth-handler.js.map +1 -1
- package/dist/runtime.d.ts +34 -10
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +54 -12
- package/dist/runtime.js.map +1 -1
- package/dist/security/admission-refusal.d.ts +3 -3
- package/dist/security/admission-refusal.d.ts.map +1 -1
- package/dist/security/admission-refusal.js +14 -6
- package/dist/security/admission-refusal.js.map +1 -1
- package/dist/security/holder-binding.d.ts +34 -0
- package/dist/security/holder-binding.d.ts.map +1 -0
- package/dist/security/holder-binding.js +75 -0
- package/dist/security/holder-binding.js.map +1 -0
- package/dist/security/mcp-admission.d.ts +29 -1
- package/dist/security/mcp-admission.d.ts.map +1 -1
- package/dist/security/mcp-admission.js +78 -12
- package/dist/security/mcp-admission.js.map +1 -1
- package/dist/security/native-holder-admission.d.ts +39 -0
- package/dist/security/native-holder-admission.d.ts.map +1 -0
- package/dist/security/native-holder-admission.js +65 -0
- package/dist/security/native-holder-admission.js.map +1 -0
- package/dist/security/outcome-proof.d.ts +39 -0
- package/dist/security/outcome-proof.d.ts.map +1 -0
- package/dist/security/outcome-proof.js +54 -0
- package/dist/security/outcome-proof.js.map +1 -0
- package/dist/security/request-nonce-store.d.ts +43 -0
- package/dist/security/request-nonce-store.d.ts.map +1 -0
- package/dist/security/request-nonce-store.js +129 -0
- package/dist/security/request-nonce-store.js.map +1 -0
- package/dist/security/routed-request.d.ts +41 -0
- package/dist/security/routed-request.d.ts.map +1 -0
- package/dist/security/routed-request.js +86 -0
- package/dist/security/routed-request.js.map +1 -0
- package/dist/security/sign-in-amr.d.ts +23 -0
- package/dist/security/sign-in-amr.d.ts.map +1 -0
- package/dist/security/sign-in-amr.js +44 -0
- package/dist/security/sign-in-amr.js.map +1 -0
- package/dist/services/approval-route.d.ts +3 -2
- package/dist/services/approval-route.d.ts.map +1 -1
- package/dist/services/approval-route.js.map +1 -1
- package/dist/services/checkpoint-decision.d.ts +56 -0
- package/dist/services/checkpoint-decision.d.ts.map +1 -0
- package/dist/services/checkpoint-decision.js +109 -0
- package/dist/services/checkpoint-decision.js.map +1 -0
- package/dist/services/consent-page-renderer.d.ts.map +1 -1
- package/dist/services/consent-page-renderer.js +2 -3
- package/dist/services/consent-page-renderer.js.map +1 -1
- package/dist/services/consent.service.d.ts +11 -49
- package/dist/services/consent.service.d.ts.map +1 -1
- package/dist/services/consent.service.js +81 -307
- package/dist/services/consent.service.js.map +1 -1
- package/dist/services/credential-auth.handler.d.ts.map +1 -1
- package/dist/services/credential-auth.handler.js +2 -8
- package/dist/services/credential-auth.handler.js.map +1 -1
- package/dist/services/delegation-authority.d.ts +53 -0
- package/dist/services/delegation-authority.d.ts.map +1 -0
- package/dist/services/delegation-authority.js +130 -0
- package/dist/services/delegation-authority.js.map +1 -0
- package/dist/services/delegation-trust.d.ts +35 -64
- package/dist/services/delegation-trust.d.ts.map +1 -1
- package/dist/services/delegation-trust.js +98 -279
- package/dist/services/delegation-trust.js.map +1 -1
- package/dist/services/delegation.service.d.ts +83 -105
- package/dist/services/delegation.service.d.ts.map +1 -1
- package/dist/services/delegation.service.js +166 -518
- package/dist/services/delegation.service.js.map +1 -1
- package/dist/services/idp-token-storage.d.ts +32 -12
- package/dist/services/idp-token-storage.d.ts.map +1 -1
- package/dist/services/idp-token-storage.js +79 -36
- package/dist/services/idp-token-storage.js.map +1 -1
- package/dist/services/issuer-keys.d.ts +55 -0
- package/dist/services/issuer-keys.d.ts.map +1 -0
- package/dist/services/issuer-keys.js +184 -0
- package/dist/services/issuer-keys.js.map +1 -0
- package/dist/services/oauth-security.service.d.ts +17 -1
- package/dist/services/oauth-security.service.d.ts.map +1 -1
- package/dist/services/oauth-security.service.js +29 -10
- package/dist/services/oauth-security.service.js.map +1 -1
- package/dist/services/resource-audience.d.ts +12 -9
- package/dist/services/resource-audience.d.ts.map +1 -1
- package/dist/services/resource-audience.js +12 -9
- package/dist/services/resource-audience.js.map +1 -1
- package/dist/services/unenforceable-tool-protection.d.ts +32 -0
- package/dist/services/unenforceable-tool-protection.d.ts.map +1 -0
- package/dist/services/unenforceable-tool-protection.js +90 -0
- package/dist/services/unenforceable-tool-protection.js.map +1 -0
- package/dist/services/upstream-fetch.d.ts +14 -0
- package/dist/services/upstream-fetch.d.ts.map +1 -0
- package/dist/services/upstream-fetch.js +56 -0
- package/dist/services/upstream-fetch.js.map +1 -0
- package/dist/types.d.ts +5 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/tool-security-schemes.d.ts +65 -0
- package/dist/utils/tool-security-schemes.d.ts.map +1 -0
- package/dist/utils/tool-security-schemes.js +168 -0
- package/dist/utils/tool-security-schemes.js.map +1 -0
- package/package.json +4 -5
- package/dist/delegation-http/anchor-do.d.ts +0 -84
- package/dist/delegation-http/anchor-do.d.ts.map +0 -1
- package/dist/delegation-http/anchor-do.js +0 -412
- package/dist/delegation-http/anchor-do.js.map +0 -1
- package/dist/delegation-http/anchor-registration-validate.d.ts +0 -61
- package/dist/delegation-http/anchor-registration-validate.d.ts.map +0 -1
- package/dist/delegation-http/anchor-registration-validate.js +0 -191
- package/dist/delegation-http/anchor-registration-validate.js.map +0 -1
- package/dist/delegation-http/anchor-registration.d.ts +0 -62
- package/dist/delegation-http/anchor-registration.d.ts.map +0 -1
- package/dist/delegation-http/anchor-registration.js +0 -337
- package/dist/delegation-http/anchor-registration.js.map +0 -1
- package/dist/delegation-http/anchor-routing.d.ts +0 -20
- package/dist/delegation-http/anchor-routing.d.ts.map +0 -1
- package/dist/delegation-http/anchor-routing.js +0 -27
- package/dist/delegation-http/anchor-routing.js.map +0 -1
- package/dist/delegation-http/challenge-middleware.d.ts +0 -28
- package/dist/delegation-http/challenge-middleware.d.ts.map +0 -1
- package/dist/delegation-http/challenge-middleware.js +0 -190
- package/dist/delegation-http/challenge-middleware.js.map +0 -1
- package/dist/delegation-http/challenge.d.ts +0 -102
- package/dist/delegation-http/challenge.d.ts.map +0 -1
- package/dist/delegation-http/challenge.js +0 -223
- package/dist/delegation-http/challenge.js.map +0 -1
- package/dist/delegation-http/consent-anchor-bridge.d.ts +0 -70
- package/dist/delegation-http/consent-anchor-bridge.d.ts.map +0 -1
- package/dist/delegation-http/consent-anchor-bridge.js +0 -1130
- package/dist/delegation-http/consent-anchor-bridge.js.map +0 -1
- package/dist/delegation-http/consent-preparation-page.d.ts +0 -18
- package/dist/delegation-http/consent-preparation-page.d.ts.map +0 -1
- package/dist/delegation-http/consent-preparation-page.js +0 -172
- package/dist/delegation-http/consent-preparation-page.js.map +0 -1
- package/dist/delegation-http/credential-consent.d.ts +0 -149
- package/dist/delegation-http/credential-consent.d.ts.map +0 -1
- package/dist/delegation-http/credential-consent.js +0 -338
- package/dist/delegation-http/credential-consent.js.map +0 -1
- package/dist/delegation-http/native-capabilities.d.ts +0 -4
- package/dist/delegation-http/native-capabilities.d.ts.map +0 -1
- package/dist/delegation-http/native-capabilities.js +0 -53
- package/dist/delegation-http/native-capabilities.js.map +0 -1
- package/dist/delegation-http/native-oauth-state.d.ts +0 -28
- package/dist/delegation-http/native-oauth-state.d.ts.map +0 -1
- package/dist/delegation-http/native-oauth-state.js +0 -146
- package/dist/delegation-http/native-oauth-state.js.map +0 -1
- package/dist/delegation-http/native-oauth.d.ts +0 -26
- package/dist/delegation-http/native-oauth.d.ts.map +0 -1
- package/dist/delegation-http/native-oauth.js +0 -401
- package/dist/delegation-http/native-oauth.js.map +0 -1
- package/dist/delegation-http/native-pickup.d.ts +0 -20
- package/dist/delegation-http/native-pickup.d.ts.map +0 -1
- package/dist/delegation-http/native-pickup.js +0 -227
- package/dist/delegation-http/native-pickup.js.map +0 -1
- package/dist/delegation-http/pickup-routes.d.ts +0 -43
- package/dist/delegation-http/pickup-routes.d.ts.map +0 -1
- package/dist/delegation-http/pickup-routes.js +0 -166
- package/dist/delegation-http/pickup-routes.js.map +0 -1
- package/dist/delegation-http/register.d.ts +0 -26
- package/dist/delegation-http/register.d.ts.map +0 -1
- package/dist/delegation-http/register.js +0 -95
- package/dist/delegation-http/register.js.map +0 -1
- package/dist/delegation-http/registrar-auth.d.ts +0 -24
- package/dist/delegation-http/registrar-auth.d.ts.map +0 -1
- package/dist/delegation-http/registrar-auth.js +0 -61
- package/dist/delegation-http/registrar-auth.js.map +0 -1
- package/dist/delegation-http/remote-issuer.d.ts +0 -52
- package/dist/delegation-http/remote-issuer.d.ts.map +0 -1
- package/dist/delegation-http/remote-issuer.js +0 -324
- package/dist/delegation-http/remote-issuer.js.map +0 -1
- package/dist/delegation-http/types.d.ts +0 -116
- package/dist/delegation-http/types.d.ts.map +0 -1
- package/dist/delegation-http/types.js +0 -11
- package/dist/delegation-http/types.js.map +0 -1
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Delegation Service
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* for MCP-I Cloudflare servers.
|
|
4
|
+
* Verifies a presented delegation VC-JWT for MCP-I Cloudflare servers.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
|
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?:
|
|
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
|
-
/**
|
|
46
|
-
|
|
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
|
-
*
|
|
56
|
-
* @param
|
|
57
|
-
*
|
|
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
|
-
|
|
98
|
+
constructor(env: CloudflareEnv, _runtime?: CloudflareRuntime, options?: DelegationServiceOptions);
|
|
60
99
|
/**
|
|
61
|
-
*
|
|
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
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
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
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
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","sourceRoot":"","sources":["../../src/services/delegation.service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"delegation.service.d.ts","sourceRoot":"","sources":["../../src/services/delegation.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAOL,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAoB5B,MAAM,WAAW,wBAAyB,SAAQ,sBAAsB;IACtE,8EAA8E;IAC9E,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAC7B,eAAe,GACf,oBAAoB,GACpB,0BAA0B,GAC1B,oBAAoB,GACpB,yBAAyB,GACzB,uBAAuB,GACvB,iBAAiB,CAAC;AAEtB,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,iCAAiC;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAMD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,GAAG,CAAgB;IAC3B,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,WAAW,CAAc;IAEjC;;;;;OAKG;gBAED,GAAG,EAAE,aAAa,EAClB,QAAQ,CAAC,EAAE,iBAAiB,EAC5B,OAAO,GAAE,wBAA6B;IAOxC;;;;;;;;;;;;;;;;;;;OAmBG;IACG,aAAa,CACjB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,uBAAuB,CAAC;IAsLnC;;;;;;;;OAQG;IACG,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAmBxD;AAED;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,CAAC,EAAE,WAAW,GACxB,iBAAiB,CAKnB"}
|