@kya-os/mcp 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +91 -0
- package/dist/authz/accountability.d.ts +35 -0
- package/dist/authz/accountability.d.ts.map +1 -0
- package/dist/authz/accountability.js +28 -0
- package/dist/authz/accountability.js.map +1 -0
- package/dist/authz/adapter.d.ts +47 -0
- package/dist/authz/adapter.d.ts.map +1 -0
- package/dist/authz/adapter.js +10 -0
- package/dist/authz/adapter.js.map +1 -0
- package/dist/authz/examples/inmemory-oidc.d.ts +29 -0
- package/dist/authz/examples/inmemory-oidc.d.ts.map +1 -0
- package/dist/authz/examples/inmemory-oidc.js +68 -0
- package/dist/authz/examples/inmemory-oidc.js.map +1 -0
- package/dist/authz/index.d.ts +19 -0
- package/dist/authz/index.d.ts.map +1 -0
- package/dist/authz/index.js +19 -0
- package/dist/authz/index.js.map +1 -0
- package/dist/authz/oidc/authorize.d.ts +25 -0
- package/dist/authz/oidc/authorize.d.ts.map +1 -0
- package/dist/authz/oidc/authorize.js +24 -0
- package/dist/authz/oidc/authorize.js.map +1 -0
- package/dist/authz/oidc/metadata.d.ts +43 -0
- package/dist/authz/oidc/metadata.d.ts.map +1 -0
- package/dist/authz/oidc/metadata.js +32 -0
- package/dist/authz/oidc/metadata.js.map +1 -0
- package/dist/authz/oidc/oidc-adapter.d.ts +52 -0
- package/dist/authz/oidc/oidc-adapter.d.ts.map +1 -0
- package/dist/authz/oidc/oidc-adapter.js +131 -0
- package/dist/authz/oidc/oidc-adapter.js.map +1 -0
- package/dist/authz/oidc/pkce.d.ts +20 -0
- package/dist/authz/oidc/pkce.d.ts.map +1 -0
- package/dist/authz/oidc/pkce.js +29 -0
- package/dist/authz/oidc/pkce.js.map +1 -0
- package/dist/authz/registry.d.ts +29 -0
- package/dist/authz/registry.d.ts.map +1 -0
- package/dist/authz/registry.js +48 -0
- package/dist/authz/registry.js.map +1 -0
- package/dist/authz/requirement.d.ts +38 -0
- package/dist/authz/requirement.d.ts.map +1 -0
- package/dist/authz/requirement.js +45 -0
- package/dist/authz/requirement.js.map +1 -0
- package/dist/delegation/chain-enforcement.d.ts +86 -0
- package/dist/delegation/chain-enforcement.d.ts.map +1 -0
- package/dist/delegation/chain-enforcement.js +224 -0
- package/dist/delegation/chain-enforcement.js.map +1 -0
- package/dist/delegation/holder-binding.d.ts +128 -0
- package/dist/delegation/holder-binding.d.ts.map +1 -0
- package/dist/delegation/holder-binding.js +175 -0
- package/dist/delegation/holder-binding.js.map +1 -0
- package/dist/delegation/index.d.ts +2 -0
- package/dist/delegation/index.d.ts.map +1 -1
- package/dist/delegation/index.js +2 -0
- package/dist/delegation/index.js.map +1 -1
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware/with-kya-os.d.ts +35 -1
- package/dist/middleware/with-kya-os.d.ts.map +1 -1
- package/dist/middleware/with-kya-os.js +100 -200
- package/dist/middleware/with-kya-os.js.map +1 -1
- package/dist/policy/index.d.ts +1 -0
- package/dist/policy/index.d.ts.map +1 -1
- package/dist/policy/index.js +1 -0
- package/dist/policy/index.js.map +1 -1
- package/dist/policy/projection.d.ts +47 -0
- package/dist/policy/projection.d.ts.map +1 -0
- package/dist/policy/projection.js +33 -0
- package/dist/policy/projection.js.map +1 -0
- package/dist/providers/grant-store.d.ts +98 -0
- package/dist/providers/grant-store.d.ts.map +1 -0
- package/dist/providers/grant-store.js +92 -0
- package/dist/providers/grant-store.js.map +1 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +2 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/runtime-fetch.d.ts +14 -0
- package/dist/providers/runtime-fetch.d.ts.map +1 -1
- package/dist/providers/runtime-fetch.js +22 -0
- package/dist/providers/runtime-fetch.js.map +1 -1
- package/dist/providers/web-crypto.d.ts +35 -0
- package/dist/providers/web-crypto.d.ts.map +1 -0
- package/dist/providers/web-crypto.js +91 -0
- package/dist/providers/web-crypto.js.map +1 -0
- package/package.json +14 -2
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,aAAa,EACb,aAAa,GACd,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,EACL,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,UAAU,GACX,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,6BAA6B,EAC7B,iCAAiC,EACjC,4BAA4B,EAC5B,qBAAqB,EACrB,6BAA6B,EAC7B,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,K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MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,QAAQ,EACb,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,aAAa,EACb,aAAa,GACd,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,EACL,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,UAAU,GACX,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,6BAA6B,EAC7B,iCAAiC,EACjC,4BAA4B,EAC5B,qBAAqB,EACrB,6BAA6B,EAC7B,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,6BAA6B,EAC7B,2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AM,+BAA+B,CAAC;AAGvC,OAAO,EACL,MAAM,EACN,0BAA0B,EAC1B,KAAK,MAAM,EACX,KAAK,KAAK,GACX,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,gBAAgB,GACjB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ export { verifyDelegationAudience, } from './delegation/audience-validator.js';
|
|
|
30
30
|
export { buildDelegationProofJWT, buildChainString, } from './delegation/outbound-proof.js';
|
|
31
31
|
export { buildOutboundDelegationHeaders, OUTBOUND_HEADER_NAMES, } from './delegation/outbound-headers.js';
|
|
32
32
|
export { canonicalizeJSON, createUnsignedVCJWT, completeVCJWT, parseVCJWT, } from './delegation/utils.js';
|
|
33
|
+
export { assertHolderBinding, generateRequestProof, toHolderBindingRequest, isHolderBindingApplicable, isKyaOsControlArg, HOLDER_BINDING_ERROR, } from './delegation/holder-binding.js';
|
|
33
34
|
export { MemoryStatusListStorage } from './delegation/storage/memory-statuslist-storage.js';
|
|
34
35
|
export { MemoryDelegationGraphStorage } from './delegation/storage/memory-graph-storage.js';
|
|
35
36
|
export { createDidKeyResolver, resolveDidKeySync, isEd25519DidKey, extractPublicKeyFromDidKey, publicKeyToJwk, } from './delegation/did-key-resolver.js';
|
|
@@ -50,7 +51,7 @@ export { CryptoProvider, ClockProvider, FetchProvider, StorageProvider, NonceCac
|
|
|
50
51
|
export { MemoryStorageProvider, MemoryNonceCacheProvider, MemoryIdentityProvider, } from './providers/memory.js';
|
|
51
52
|
export { NodeCryptoProvider } from './providers/node-crypto.js';
|
|
52
53
|
export { SystemClockProvider } from './providers/system-clock.js';
|
|
53
|
-
export { RuntimeFetchProvider } from './providers/runtime-fetch.js';
|
|
54
|
+
export { RuntimeFetchProvider, NoopFetchProvider } from './providers/runtime-fetch.js';
|
|
54
55
|
export { AuditLogProvider, MemoryAuditLogProvider, NoopAuditLogProvider, buildAuditRecord, } from './providers/audit-log.js';
|
|
55
56
|
// Middleware
|
|
56
57
|
export { createKyaOsMiddleware, withKyaOs, generateIdentity, } from './middleware/index.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,iBAAiB;AACjB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GAGjB,MAAM,aAAa,CAAC;AAErB,2EAA2E;AAC3E,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,aAAa,EACb,aAAa,GACd,MAAM,mBAAmB,CAAC;AA8B3B,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,6BAA6B,EAC7B,iCAAiC,EACjC,4BAA4B,EAC5B,qBAAqB,EACrB,6BAA6B,EAC7B,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAElB,MAAM,qBAAqB,CAAC;AAE7B,oBAAoB;AACpB,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GAIvB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,GAQzB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GAGtB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,qBAAqB,EACrB,uBAAuB,GAGxB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,GAIjC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,gBAAgB,EAChB,UAAU,GAGX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,uBAAuB,EACvB,gBAAgB,GAGjB,MAAM,gCAAgC,CAA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for advanced use cases like the
|
|
15
15
|
* low-level `Server` API or custom request handler patterns.
|
|
16
16
|
*/
|
|
17
|
-
import { type CryptoProvider, type FetchProvider } from "../providers/base.js";
|
|
17
|
+
import { type CryptoProvider, type FetchProvider, type NonceCacheProvider } from "../providers/base.js";
|
|
18
18
|
import { AuditLogProvider } from "../providers/audit-log.js";
|
|
19
19
|
import { SessionManager, type SessionConfig } from "../session/manager.js";
|
|
20
20
|
import { ProofGenerator } from "../proof/generator.js";
|
|
21
21
|
import { type DIDResolver, type StatusListResolver } from "../delegation/vc-verifier.js";
|
|
22
|
+
import { type RevocationChecker } from "../delegation/chain-enforcement.js";
|
|
22
23
|
import { type DelegationCredential, type NeedsAuthorizationError } from "../types/protocol.js";
|
|
23
24
|
import { RiskClassifier } from "../policy/classifier.js";
|
|
24
25
|
import { type ApprovalGrant } from "../policy/approval.js";
|
|
@@ -52,12 +53,45 @@ export interface KyaOsDelegationConfig {
|
|
|
52
53
|
* contain only ancestors (root -> parent) or the full chain (root -> leaf).
|
|
53
54
|
*/
|
|
54
55
|
resolveDelegationChain?: (leafCredential: DelegationCredential) => Promise<DelegationCredential[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Graph-backed ancestor-revocation check. When provided, the chain walk also
|
|
58
|
+
* verifies the leaf is not revoked via a cascade-revoked ANCESTOR — caught
|
|
59
|
+
* independently of how `resolveDelegationChain` hydrated the chain (it walks
|
|
60
|
+
* the delegation graph + StatusList). `CascadingRevocationManager` is the
|
|
61
|
+
* reference adapter. Omit to keep the prior per-credential-status behavior.
|
|
62
|
+
*/
|
|
63
|
+
revocationChecker?: RevocationChecker;
|
|
64
|
+
/**
|
|
65
|
+
* Holder-of-key enforcement for inbound calls (spec §11.8). A valid delegation
|
|
66
|
+
* is a *bearer* credential; holder binding additionally requires the caller to
|
|
67
|
+
* present a per-request proof (`_kyaos_proof`) signed by the delegation
|
|
68
|
+
* SUBJECT's key, closing theft-replay for the key-bearing population.
|
|
69
|
+
*
|
|
70
|
+
* - `'off'` (default): no holder-binding check — current behavior, unchanged.
|
|
71
|
+
* - `'warn'`: check and log failures (missing/unbound proof), but still allow.
|
|
72
|
+
* - `'enforce'`: reject calls whose proof is missing or does not bind the
|
|
73
|
+
* subject. **Breaking for callers that don't yet send `_kyaos_proof`** — opt
|
|
74
|
+
* in only once your agents mint request proofs.
|
|
75
|
+
*
|
|
76
|
+
* Scope is did:key subjects (the DID encodes the key). did:web and other
|
|
77
|
+
* subjects are deferred to cnf-based binding (phase 2) and logged, never
|
|
78
|
+
* rejected — so enabling `'enforce'` never breaks did:web traffic.
|
|
79
|
+
*/
|
|
80
|
+
holderBinding?: "off" | "warn" | "enforce";
|
|
55
81
|
}
|
|
56
82
|
export interface KyaOsConfig {
|
|
57
83
|
/** Agent identity (DID + key material) */
|
|
58
84
|
identity: KyaOsIdentityConfig;
|
|
59
85
|
/** Session configuration overrides */
|
|
60
86
|
session?: Omit<SessionConfig, "nonceCache">;
|
|
87
|
+
/**
|
|
88
|
+
* Replay-protection store, shared by the session handshake AND inbound holder
|
|
89
|
+
* binding so both draw on one nonce namespace. Defaults to an in-memory store
|
|
90
|
+
* (single-process only); inject a Redis / Durable Object / KV-backed
|
|
91
|
+
* {@link NonceCacheProvider} for multi-instance deployments. Set here, not on
|
|
92
|
+
* `session`, so there is exactly one cache and the two cannot diverge.
|
|
93
|
+
*/
|
|
94
|
+
nonceCache?: NonceCacheProvider;
|
|
61
95
|
/** Delegation verification overrides */
|
|
62
96
|
delegation?: KyaOsDelegationConfig;
|
|
63
97
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-kya-os.d.ts","sourceRoot":"","sources":["../../src/middleware/with-kya-os.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"with-kya-os.d.ts","sourceRoot":"","sources":["../../src/middleware/with-kya-os.ts"],"names":[],"mappings":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by `withKyaOs()` and for advanced use cases like the
|
|
15
15
|
* low-level `Server` API or custom request handler patterns.
|
|
16
16
|
*/
|
|
17
|
-
import { RuntimeFetchProvider } from "../providers/runtime-fetch.js";
|
|
17
|
+
import { RuntimeFetchProvider, NoopFetchProvider } from "../providers/runtime-fetch.js";
|
|
18
18
|
import { NoopAuditLogProvider } from "../providers/audit-log.js";
|
|
19
19
|
import { SessionManager, } from "../session/manager.js";
|
|
20
20
|
import { ProofGenerator, } from "../proof/generator.js";
|
|
21
21
|
import { validateHandshakeFormat } from "../session/manager.js";
|
|
22
22
|
import { DelegationCredentialVerifier, } from "../delegation/vc-verifier.js";
|
|
23
23
|
import { createDidKeyResolver } from "../delegation/did-key-resolver.js";
|
|
24
|
+
import { assertHolderBinding, isHolderBindingApplicable, isKyaOsControlArg, toHolderBindingRequest, } from "../delegation/holder-binding.js";
|
|
25
|
+
import { ProofVerifier } from "../proof/verifier.js";
|
|
26
|
+
import { SystemClockProvider } from "../providers/system-clock.js";
|
|
27
|
+
import { MemoryNonceCacheProvider } from "../providers/memory.js";
|
|
24
28
|
import { scopeSatisfies } from "../delegation/scope-matcher.js";
|
|
25
29
|
import { createDidWebResolver } from "../delegation/did-web-resolver.js";
|
|
26
|
-
import {
|
|
27
|
-
import { createNeedsAuthorizationError, createNeedsApprovalError,
|
|
30
|
+
import { validateDelegationChain as validateDelegationChainCore, getDelegationScopes, } from "../delegation/chain-enforcement.js";
|
|
31
|
+
import { createNeedsAuthorizationError, createNeedsApprovalError, } from "../types/protocol.js";
|
|
28
32
|
import { logger } from "../logging/index.js";
|
|
29
33
|
import { RiskClassifier } from "../policy/classifier.js";
|
|
30
34
|
import { DefaultPolicyEngine } from "../policy/default-engine.js";
|
|
31
35
|
import { verifyApprovalQuorum } from "../policy/approval.js";
|
|
36
|
+
import { buildPolicyRequest } from "../policy/projection.js";
|
|
32
37
|
import { KYA_OS_ERROR_CODES } from "../errors.js";
|
|
33
38
|
import { canonicalizeJSON, parseVCJWT } from "../delegation/utils.js";
|
|
34
39
|
import { base64urlDecodeToBytes, base64urlEncodeFromBytes, bytesToBase64 } from "../utils/base64.js";
|
|
35
40
|
export const KYA_OS_ACTIONS = ["handshake", "identity", "reputation"];
|
|
36
|
-
function getDelegationScopes(credential) {
|
|
37
|
-
const scopes = new Set();
|
|
38
|
-
for (const scope of credential.credentialSubject.delegation.scopes ?? []) {
|
|
39
|
-
scopes.add(scope);
|
|
40
|
-
}
|
|
41
|
-
for (const scope of credential.credentialSubject.delegation.constraints?.scopes ?? []) {
|
|
42
|
-
scopes.add(scope);
|
|
43
|
-
}
|
|
44
|
-
return Array.from(scopes);
|
|
45
|
-
}
|
|
46
41
|
/**
|
|
47
42
|
* Strip control characters and cap length on caller-derived values before they
|
|
48
43
|
* are interpolated into client-facing reasons or log lines. A hostile
|
|
@@ -91,44 +86,6 @@ function extractPolicyPrincipal(del) {
|
|
|
91
86
|
return { agentDid: "unknown", delegatedScopes: [] };
|
|
92
87
|
}
|
|
93
88
|
}
|
|
94
|
-
function validateScopeAttenuation(parentCredential, childCredential) {
|
|
95
|
-
const parentScopes = getDelegationScopes(parentCredential);
|
|
96
|
-
const childScopes = getDelegationScopes(childCredential);
|
|
97
|
-
const childDelegation = childCredential.credentialSubject.delegation;
|
|
98
|
-
// CRISP matcher attenuation: getDelegationScopes does NOT see constraints.crisp.scopes,
|
|
99
|
-
// so a re-delegation could otherwise widen authority by introducing a broad
|
|
100
|
-
// prefix/regex matcher (e.g. resource:"" matches every scope). Require the child's
|
|
101
|
-
// crisp matchers to be a subset of the parent's (by matcher+resource). Fail closed.
|
|
102
|
-
const crispKey = (s) => `${s.matcher}\u0000${s.resource}`;
|
|
103
|
-
const parentCrisp = new Set((parentCredential.credentialSubject.delegation.constraints.crisp?.scopes ?? []).map(crispKey));
|
|
104
|
-
const widenedCrisp = (childDelegation.constraints.crisp?.scopes ?? []).filter((s) => !parentCrisp.has(crispKey(s)));
|
|
105
|
-
if (widenedCrisp.length > 0) {
|
|
106
|
-
return {
|
|
107
|
-
valid: false,
|
|
108
|
-
reason: `Delegation ${childDelegation.id} introduces crisp scope matcher(s) absent from parent ${parentCredential.credentialSubject.delegation.id}: ${widenedCrisp
|
|
109
|
-
.map((s) => `${s.matcher}:${s.resource}`)
|
|
110
|
-
.join(", ")}`,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
if (parentScopes.length === 0) {
|
|
114
|
-
return { valid: true };
|
|
115
|
-
}
|
|
116
|
-
if (childScopes.length === 0) {
|
|
117
|
-
return {
|
|
118
|
-
valid: false,
|
|
119
|
-
reason: `Delegation ${childDelegation.id} omits scopes required to prove attenuation from parent ${parentCredential.credentialSubject.delegation.id}`,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
const parentScopeSet = new Set(parentScopes);
|
|
123
|
-
const widenedScopes = childScopes.filter((scope) => !parentScopeSet.has(scope));
|
|
124
|
-
if (widenedScopes.length > 0) {
|
|
125
|
-
return {
|
|
126
|
-
valid: false,
|
|
127
|
-
reason: `Delegation ${childDelegation.id} widens scopes beyond parent ${parentCredential.credentialSubject.delegation.id}: ${widenedScopes.join(", ")}`,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
return { valid: true };
|
|
131
|
-
}
|
|
132
89
|
/**
|
|
133
90
|
* Create KYA-OS middleware for a standard MCP SDK Server.
|
|
134
91
|
*
|
|
@@ -158,13 +115,33 @@ export function createKyaOsMiddleware(config, cryptoProvider) {
|
|
|
158
115
|
privateKey: config.identity.privateKey,
|
|
159
116
|
publicKey: config.identity.publicKey,
|
|
160
117
|
};
|
|
118
|
+
// One replay-protection store, shared by the handshake and holder binding.
|
|
119
|
+
// Defaults to in-memory; SessionManager.cleanup() drives its expiry sweep.
|
|
120
|
+
const nonceCache = config.nonceCache ?? new MemoryNonceCacheProvider();
|
|
161
121
|
const sessionManager = new SessionManager(cryptoProvider, {
|
|
162
122
|
...config.session,
|
|
163
123
|
serverDid: identity.did,
|
|
124
|
+
nonceCache,
|
|
164
125
|
});
|
|
165
126
|
const proofGenerator = new ProofGenerator(identity, cryptoProvider);
|
|
166
127
|
const delegationConfig = config.delegation;
|
|
167
128
|
const auditLog = config.auditLog ?? new NoopAuditLogProvider();
|
|
129
|
+
// Holder binding (spec §11.8). Built once so all tools share one replay cache.
|
|
130
|
+
// The verifier derives the subject key from the did:key DID directly, so its
|
|
131
|
+
// fetchProvider is unused on the phase-1 path — a never-called stub keeps
|
|
132
|
+
// enforcement active even where a runtime fetch is absent.
|
|
133
|
+
const holderBindingMode = delegationConfig?.holderBinding ?? "off";
|
|
134
|
+
const holderBindingVerifier = holderBindingMode === "off"
|
|
135
|
+
? undefined
|
|
136
|
+
: new ProofVerifier({
|
|
137
|
+
cryptoProvider,
|
|
138
|
+
clockProvider: new SystemClockProvider(),
|
|
139
|
+
nonceCacheProvider: nonceCache,
|
|
140
|
+
fetchProvider: delegationConfig?.fetchProvider ??
|
|
141
|
+
(typeof globalThis.fetch === "function"
|
|
142
|
+
? new RuntimeFetchProvider()
|
|
143
|
+
: new NoopFetchProvider()),
|
|
144
|
+
});
|
|
168
145
|
// Session map: sessionId → last nonce (for proof generation)
|
|
169
146
|
const sessionNonces = new Map();
|
|
170
147
|
// Active session tracking — set after handshake (manual or auto)
|
|
@@ -526,143 +503,17 @@ export function createKyaOsMiddleware(config, cryptoProvider) {
|
|
|
526
503
|
],
|
|
527
504
|
isError: true,
|
|
528
505
|
});
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
typeof leafDelegationObj !== "object" ||
|
|
541
|
-
!leafDelegationObj.constraints ||
|
|
542
|
-
typeof leafDelegationObj.constraints !== "object") {
|
|
543
|
-
return {
|
|
544
|
-
valid: false,
|
|
545
|
-
reason: "Malformed delegation credential: missing credentialSubject.delegation or its constraints",
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
const leafDelegation = extractDelegationFromVC(leafCredential);
|
|
549
|
-
let chain = [leafCredential];
|
|
550
|
-
if (leafDelegation.parentId) {
|
|
551
|
-
if (!delegationConfig?.resolveDelegationChain) {
|
|
552
|
-
return {
|
|
553
|
-
valid: false,
|
|
554
|
-
reason: `Delegation ${leafDelegation.id} references parent ${leafDelegation.parentId} but no resolveDelegationChain handler is configured`,
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
let resolvedChain;
|
|
558
|
-
try {
|
|
559
|
-
resolvedChain =
|
|
560
|
-
await delegationConfig.resolveDelegationChain(leafCredential);
|
|
561
|
-
}
|
|
562
|
-
catch (error) {
|
|
563
|
-
return {
|
|
564
|
-
valid: false,
|
|
565
|
-
reason: `Failed to resolve delegation chain: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
if (resolvedChain.length === 0) {
|
|
569
|
-
return {
|
|
570
|
-
valid: false,
|
|
571
|
-
reason: `Delegation ${leafDelegation.id} references parent ${leafDelegation.parentId} but the resolved chain is empty`,
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
const leafIndex = resolvedChain.findIndex((credential) => credential.credentialSubject.delegation.id === leafDelegation.id);
|
|
575
|
-
if (leafIndex !== -1 && leafIndex !== resolvedChain.length - 1) {
|
|
576
|
-
return {
|
|
577
|
-
valid: false,
|
|
578
|
-
reason: `Resolved delegation chain for ${leafDelegation.id} must end with the leaf credential`,
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
chain =
|
|
582
|
-
leafIndex === -1 ? [...resolvedChain, leafCredential] : resolvedChain;
|
|
583
|
-
}
|
|
584
|
-
const seenIds = new Set();
|
|
585
|
-
let previousDelegation;
|
|
586
|
-
let previousCredential;
|
|
587
|
-
for (const credential of chain) {
|
|
588
|
-
const delegation = extractDelegationFromVC(credential);
|
|
589
|
-
if (seenIds.has(delegation.id)) {
|
|
590
|
-
return {
|
|
591
|
-
valid: false,
|
|
592
|
-
reason: `Delegation chain contains a circular reference at ${delegation.id}`,
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
seenIds.add(delegation.id);
|
|
596
|
-
if (credential.credentialStatus && !delegationConfig?.statusListResolver) {
|
|
597
|
-
return {
|
|
598
|
-
valid: false,
|
|
599
|
-
reason: `Delegation ${delegation.id} has credentialStatus but no statusListResolver is configured`,
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
const credentialVerification = await verifier.verifyDelegationCredential(credential, {
|
|
603
|
-
...(options?.skipSignature ? { skipSignature: true } : {}),
|
|
604
|
-
});
|
|
605
|
-
if (!credentialVerification.valid) {
|
|
606
|
-
return {
|
|
607
|
-
valid: false,
|
|
608
|
-
reason: `Delegation ${delegation.id} invalid: ${credentialVerification.reason}`,
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
if (!verifyDelegationAudience(delegation, identity.did)) {
|
|
612
|
-
return {
|
|
613
|
-
valid: false,
|
|
614
|
-
reason: `Delegation ${delegation.id} audience does not include server DID ${identity.did}`,
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
// Every non-root credential in the chain MUST carry an `audience`
|
|
618
|
-
// constraint binding it to the verifying server. This closes the
|
|
619
|
-
// confused-deputy class where a re-delegated credential is forwarded
|
|
620
|
-
// to an unintended server (KYA-OS §11.6). Unconditional as of 1.4.0.
|
|
621
|
-
if (delegation.parentId && !delegation.constraints.audience) {
|
|
622
|
-
return {
|
|
623
|
-
valid: false,
|
|
624
|
-
reason: `Delegation ${delegation.id} is a re-delegation (parentId: ${delegation.parentId}) but has no audience constraint. Re-delegations MUST include an audience constraint (KYA-OS §11.6)`,
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
if (!previousDelegation || !previousCredential) {
|
|
628
|
-
if (delegation.parentId) {
|
|
629
|
-
return {
|
|
630
|
-
valid: false,
|
|
631
|
-
reason: `Resolved delegation chain is incomplete: root delegation ${delegation.id} still references parent ${delegation.parentId}`,
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
previousDelegation = delegation;
|
|
635
|
-
previousCredential = credential;
|
|
636
|
-
continue;
|
|
637
|
-
}
|
|
638
|
-
if (delegation.parentId !== previousDelegation.id) {
|
|
639
|
-
return {
|
|
640
|
-
valid: false,
|
|
641
|
-
reason: `Delegation ${delegation.id} references parent ${delegation.parentId} but expected ${previousDelegation.id}`,
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
if (delegation.issuerDid !== previousDelegation.subjectDid) {
|
|
645
|
-
return {
|
|
646
|
-
valid: false,
|
|
647
|
-
reason: `Delegation ${delegation.id} issued by ${delegation.issuerDid} but parent subject is ${previousDelegation.subjectDid}`,
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
const scopeValidation = validateScopeAttenuation(previousCredential, credential);
|
|
651
|
-
if (!scopeValidation.valid) {
|
|
652
|
-
return scopeValidation;
|
|
653
|
-
}
|
|
654
|
-
previousDelegation = delegation;
|
|
655
|
-
previousCredential = credential;
|
|
656
|
-
}
|
|
657
|
-
const finalDelegation = extractDelegationFromVC(chain[chain.length - 1]);
|
|
658
|
-
if (finalDelegation.id !== leafDelegation.id) {
|
|
659
|
-
return {
|
|
660
|
-
valid: false,
|
|
661
|
-
reason: `Resolved delegation chain ended at ${finalDelegation.id} instead of leaf ${leafDelegation.id}`,
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
return { valid: true };
|
|
665
|
-
};
|
|
506
|
+
// Thin adapter over the framework-agnostic core (E3.1 · chain-enforcement.ts).
|
|
507
|
+
// The walk/attenuation/audience/§11.6/revocation rules live in one place;
|
|
508
|
+
// this binds the host's injected verifier + server DID + resolver + the
|
|
509
|
+
// optional graph-backed RevocationChecker.
|
|
510
|
+
const validateDelegationChain = (leafCredential, options) => validateDelegationChainCore(leafCredential, {
|
|
511
|
+
serverDid: identity.did,
|
|
512
|
+
verifier,
|
|
513
|
+
resolveDelegationChain: delegationConfig?.resolveDelegationChain,
|
|
514
|
+
statusListConfigured: !!delegationConfig?.statusListResolver,
|
|
515
|
+
revocationChecker: delegationConfig?.revocationChecker,
|
|
516
|
+
}, options);
|
|
666
517
|
return async (args, sessionId) => {
|
|
667
518
|
const delegationArg = args["_kyaos_delegation"];
|
|
668
519
|
if (delegationArg === undefined || delegationArg === null) {
|
|
@@ -763,6 +614,55 @@ export function createKyaOsMiddleware(config, cryptoProvider) {
|
|
|
763
614
|
logger.warn(`[kya-os] Delegation verification failed for "${toolName}": ${sanitizeForMessage(reason)}`);
|
|
764
615
|
return attachOutcomeProof(buildDelegationErrorResponse(KYA_OS_ERROR_CODES.delegation_invalid, reason), toolName, args, sessionId, reason);
|
|
765
616
|
}
|
|
617
|
+
// Holder binding (spec §11.8): the delegation is valid, but a valid
|
|
618
|
+
// *credential* is a bearer token until we also prove the caller holds the
|
|
619
|
+
// delegation SUBJECT's key. Opt-in via `delegation.holderBinding`. did:key
|
|
620
|
+
// subjects are bound here; did:web is deferred to cnf binding (phase 2) and
|
|
621
|
+
// logged, never rejected. Runs after identity is established, before scope.
|
|
622
|
+
if (holderBindingMode !== "off" && holderBindingVerifier) {
|
|
623
|
+
const subjectDid = vc.credentialSubject?.id;
|
|
624
|
+
if (subjectDid && isHolderBindingApplicable(subjectDid)) {
|
|
625
|
+
const proofArg = args["_kyaos_proof"];
|
|
626
|
+
if (proofArg === undefined) {
|
|
627
|
+
const reason = "Holder-of-key proof (_kyaos_proof) is required for this delegation subject";
|
|
628
|
+
logger.warn(`[kya-os] Holder binding: "${toolName}" called without _kyaos_proof`);
|
|
629
|
+
if (holderBindingMode === "enforce") {
|
|
630
|
+
return attachOutcomeProof(buildDelegationErrorResponse(KYA_OS_ERROR_CODES.holder_binding_failed, reason), toolName, args, sessionId, reason);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
let parsedProof = proofArg;
|
|
635
|
+
if (typeof proofArg === "string") {
|
|
636
|
+
try {
|
|
637
|
+
parsedProof = JSON.parse(proofArg);
|
|
638
|
+
}
|
|
639
|
+
catch {
|
|
640
|
+
parsedProof = {};
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const binding = await assertHolderBinding({
|
|
644
|
+
proof: parsedProof,
|
|
645
|
+
subjectDid,
|
|
646
|
+
request: toHolderBindingRequest(toolName, args),
|
|
647
|
+
expectedAudience: identity.did,
|
|
648
|
+
proofVerifier: holderBindingVerifier,
|
|
649
|
+
});
|
|
650
|
+
if (binding.status !== "bound") {
|
|
651
|
+
const reason = binding.reason ??
|
|
652
|
+
"Holder-of-key proof did not bind the delegation subject";
|
|
653
|
+
logger.warn(`[kya-os] Holder binding ${binding.status} for "${toolName}": ${sanitizeForMessage(reason)}`);
|
|
654
|
+
if (holderBindingMode === "enforce") {
|
|
655
|
+
return attachOutcomeProof(buildDelegationErrorResponse(KYA_OS_ERROR_CODES.holder_binding_failed, reason), toolName, args, sessionId, reason);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
else if (subjectDid) {
|
|
661
|
+
// Non-did:key subject — phase 1 cannot pin its key; defer to cnf
|
|
662
|
+
// binding (phase 2) rather than reject legitimate traffic.
|
|
663
|
+
logger.warn(`[kya-os] Holder binding: subject "${subjectDid}" is not did:key; deferring to cnf binding (phase 2)`);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
766
666
|
// Safe to call directly: the structural guard + validateDelegationChain
|
|
767
667
|
// above guarantee a well-formed credential here, and scopeSatisfies is
|
|
768
668
|
// bounded (ReDoS-guarded) and returns rather than throws.
|
|
@@ -776,10 +676,12 @@ export function createKyaOsMiddleware(config, cryptoProvider) {
|
|
|
776
676
|
logger.warn(`[kya-os] Delegation missing required scope "${config.scopeId}" for "${toolName}"`);
|
|
777
677
|
return attachOutcomeProof(buildDelegationErrorResponse(KYA_OS_ERROR_CODES.insufficient_scope, reason), toolName, args, sessionId, reason);
|
|
778
678
|
}
|
|
779
|
-
// Strip
|
|
679
|
+
// Strip the reserved _kyaos* control namespace before passing to the
|
|
680
|
+
// handler — same predicate the bound request hash uses, so the handler
|
|
681
|
+
// receives exactly the call the subject signed (no smuggled control arg).
|
|
780
682
|
const cleanArgs = {};
|
|
781
683
|
for (const [k, v] of Object.entries(args)) {
|
|
782
|
-
if (k
|
|
684
|
+
if (!isKyaOsControlArg(k))
|
|
783
685
|
cleanArgs[k] = v;
|
|
784
686
|
}
|
|
785
687
|
logger.debug(`[kya-os] Delegation verified for "${toolName}", scope "${config.scopeId}"`);
|
|
@@ -802,16 +704,17 @@ export function createKyaOsMiddleware(config, cryptoProvider) {
|
|
|
802
704
|
const approvalsKey = opts.approvalsArgKey ?? "_kyaos_approvals";
|
|
803
705
|
const isValidApprovalSignature = opts.isValidApprovalSignature ?? (async () => false);
|
|
804
706
|
return async (args, sessionId) => {
|
|
805
|
-
|
|
707
|
+
// Drop the reserved _kyaos* namespace plus the (possibly custom) approvals
|
|
708
|
+
// key, so no control arg reaches the handler.
|
|
806
709
|
const cleanArgs = {};
|
|
807
710
|
for (const [k, v] of Object.entries(args)) {
|
|
808
|
-
if (!
|
|
711
|
+
if (!isKyaOsControlArg(k) && k !== approvalsKey)
|
|
809
712
|
cleanArgs[k] = v;
|
|
810
713
|
}
|
|
811
714
|
const namespace = opts.resolveNamespace?.(args) ?? toolName;
|
|
812
715
|
const risk = classifier.classify({ toolName, namespace });
|
|
813
716
|
const principal = extractPolicyPrincipal(args["_kyaos_delegation"]);
|
|
814
|
-
const policyRequest = {
|
|
717
|
+
const policyRequest = buildPolicyRequest({
|
|
815
718
|
principal: {
|
|
816
719
|
agentDid: principal.agentDid,
|
|
817
720
|
...(principal.responsibleParty
|
|
@@ -820,13 +723,10 @@ export function createKyaOsMiddleware(config, cryptoProvider) {
|
|
|
820
723
|
},
|
|
821
724
|
action: { toolName },
|
|
822
725
|
resource: { namespace },
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
...risk,
|
|
828
|
-
},
|
|
829
|
-
};
|
|
726
|
+
delegatedScopes: principal.delegatedScopes,
|
|
727
|
+
scopeMatched: opts.scopeMatched ?? false,
|
|
728
|
+
risk,
|
|
729
|
+
});
|
|
830
730
|
const decision = await engine.evaluate(policyRequest);
|
|
831
731
|
if (decision.decision === "allow") {
|
|
832
732
|
return handler(cleanArgs, sessionId);
|