@kya-os/mcp 1.18.0 → 1.20.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +336 -0
  2. package/CONFORMANCE.md +10 -4
  3. package/README.md +57 -0
  4. package/SPEC.md +37 -3
  5. package/dist/card/cimd.js +6 -2
  6. package/dist/card/cimd.js.map +1 -1
  7. package/dist/card/index.d.ts +1 -0
  8. package/dist/card/index.js +1 -0
  9. package/dist/card/index.js.map +1 -1
  10. package/dist/card/revocation.d.ts +15 -4
  11. package/dist/card/revocation.js +9 -4
  12. package/dist/card/revocation.js.map +1 -1
  13. package/dist/card/status-list-proof.d.ts +32 -0
  14. package/dist/card/status-list-proof.js +102 -0
  15. package/dist/card/status-list-proof.js.map +1 -0
  16. package/dist/delegation/verification-method-key.d.ts +4 -1
  17. package/dist/delegation/verification-method-key.js.map +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/middleware/index.d.ts +3 -1
  22. package/dist/middleware/index.js +2 -0
  23. package/dist/middleware/index.js.map +1 -1
  24. package/dist/middleware/kya-os-transport.d.ts +43 -12
  25. package/dist/middleware/kya-os-transport.js +151 -28
  26. package/dist/middleware/kya-os-transport.js.map +1 -1
  27. package/dist/middleware/mcp-tool-callback.d.ts +48 -0
  28. package/dist/middleware/mcp-tool-callback.js +38 -0
  29. package/dist/middleware/mcp-tool-callback.js.map +1 -0
  30. package/dist/middleware/serve-in-process.d.ts +41 -0
  31. package/dist/middleware/serve-in-process.js +86 -0
  32. package/dist/middleware/serve-in-process.js.map +1 -0
  33. package/dist/middleware/with-kya-os-server.d.ts +14 -3
  34. package/dist/middleware/with-kya-os-server.js +4 -1
  35. package/dist/middleware/with-kya-os-server.js.map +1 -1
  36. package/dist/middleware/with-kya-os.config-types.d.ts +24 -0
  37. package/dist/middleware/with-kya-os.d.ts +4 -0
  38. package/dist/middleware/with-kya-os.delegation-gate.d.ts +2 -1
  39. package/dist/middleware/with-kya-os.delegation-gate.js +12 -18
  40. package/dist/middleware/with-kya-os.delegation-gate.js.map +1 -1
  41. package/dist/middleware/with-kya-os.delegation-verify.d.ts +7 -12
  42. package/dist/middleware/with-kya-os.delegation-verify.js +37 -9
  43. package/dist/middleware/with-kya-os.delegation-verify.js.map +1 -1
  44. package/dist/middleware/with-kya-os.deps.d.ts +15 -4
  45. package/dist/middleware/with-kya-os.helpers.d.ts +5 -0
  46. package/dist/middleware/with-kya-os.helpers.js +13 -0
  47. package/dist/middleware/with-kya-os.helpers.js.map +1 -1
  48. package/dist/middleware/with-kya-os.js +23 -0
  49. package/dist/middleware/with-kya-os.js.map +1 -1
  50. package/dist/middleware/with-kya-os.outcome.d.ts +18 -0
  51. package/dist/middleware/with-kya-os.outcome.js +36 -0
  52. package/dist/middleware/with-kya-os.outcome.js.map +1 -0
  53. package/dist/middleware/with-kya-os.policy-gate.d.ts +2 -1
  54. package/dist/middleware/with-kya-os.policy-gate.js +2 -1
  55. package/dist/middleware/with-kya-os.policy-gate.js.map +1 -1
  56. package/dist/middleware/with-kya-os.session.d.ts +76 -10
  57. package/dist/middleware/with-kya-os.session.js +739 -164
  58. package/dist/middleware/with-kya-os.session.js.map +1 -1
  59. package/dist/middleware/with-kya-os.types.d.ts +102 -8
  60. package/dist/proof/generator.d.ts +13 -0
  61. package/dist/proof/generator.js +15 -0
  62. package/dist/proof/generator.js.map +1 -1
  63. package/dist/proof/verifier.js +14 -9
  64. package/dist/proof/verifier.js.map +1 -1
  65. package/package.json +3 -1
@@ -10,11 +10,13 @@
10
10
  *
11
11
  * `createRevocationChecker` is the DEFAULT implementation over W3C Bitstring Status List v1.0
12
12
  * (`BitstringStatusListEntry` — the StatusList2021 SUCCESSOR). It resolves the entry's
13
- * `statusListCredential` through the injected, SSRF-hardened {@link SafeFetch} seam, inflates
14
- * the multibase / GZIP `encodedList` bitstring, and reads the bit at `statusListIndex`.
13
+ * `statusListCredential` through the injected, SSRF-hardened {@link SafeFetch} seam, checks the
14
+ * list's proof through the injected `verifyStatusList` seam when one is given, inflates the
15
+ * multibase / GZIP `encodedList` bitstring, and reads the bit at `statusListIndex`.
15
16
  *
16
- * FAIL-CLOSED is the invariant: an unreachable status list, a malformed credential, a
17
- * mismatched `statusPurpose`, or an out-of-range index all resolve to `{ revoked: true }` —
17
+ * FAIL-CLOSED is the invariant: an unreachable status list, a malformed credential, a list whose
18
+ * proof is rejected, a mismatched `statusPurpose`, or an out-of-range index all resolve to
19
+ * `{ revoked: true }` —
18
20
  * the absence of proof-of-liveness is treated as revoked, never as "probably fine".
19
21
  *
20
22
  * Each verdict also reports `fresh`: `true` only when read from a LIVE, in-validity-window
@@ -27,6 +29,7 @@
27
29
  */
28
30
  import type { SafeFetch } from '../utils/safe-fetch.js';
29
31
  import type { BitstringStatusListEntry } from './schema.js';
32
+ import type { StatusListProofVerifier } from './status-list-proof.js';
30
33
  /** The `statusPurpose` this checker evaluates by default (revocation, not suspension). */
31
34
  export declare const STATUS_PURPOSE_REVOCATION = "revocation";
32
35
  /**
@@ -72,6 +75,14 @@ export interface RevocationCheckerDeps {
72
75
  now?: () => number;
73
76
  /** `statusPurpose` to honour; default {@link STATUS_PURPOSE_REVOCATION}. */
74
77
  statusPurpose?: string;
78
+ /**
79
+ * Checks the fetched status-list credential's proof before any bit is read, as W3C Bitstring
80
+ * Status List v1.0 requires (SPEC.md §6.10). A list it rejects (`false` or a throw) resolves
81
+ * {@link FAIL_CLOSED}. {@link createStatusListProofVerifier} covers `eddsa-jcs-2022` lists.
82
+ * Without it the bits are read unchecked, so whoever serves the list can clear a revocation;
83
+ * it stays optional until 2.0 only so existing callers keep working.
84
+ */
85
+ verifyStatusList?: StatusListProofVerifier;
75
86
  /**
76
87
  * Injectable GZIP inflation seam ({@link Decompress}). DEFAULT = `node:zlib` `gunzipSync` bounded
77
88
  * to the 16 MiB {@link MAX_STATUS_LIST_BYTES} `maxOutputLength` cap (so a decompression bomb
@@ -10,11 +10,13 @@
10
10
  *
11
11
  * `createRevocationChecker` is the DEFAULT implementation over W3C Bitstring Status List v1.0
12
12
  * (`BitstringStatusListEntry` — the StatusList2021 SUCCESSOR). It resolves the entry's
13
- * `statusListCredential` through the injected, SSRF-hardened {@link SafeFetch} seam, inflates
14
- * the multibase / GZIP `encodedList` bitstring, and reads the bit at `statusListIndex`.
13
+ * `statusListCredential` through the injected, SSRF-hardened {@link SafeFetch} seam, checks the
14
+ * list's proof through the injected `verifyStatusList` seam when one is given, inflates the
15
+ * multibase / GZIP `encodedList` bitstring, and reads the bit at `statusListIndex`.
15
16
  *
16
- * FAIL-CLOSED is the invariant: an unreachable status list, a malformed credential, a
17
- * mismatched `statusPurpose`, or an out-of-range index all resolve to `{ revoked: true }` —
17
+ * FAIL-CLOSED is the invariant: an unreachable status list, a malformed credential, a list whose
18
+ * proof is rejected, a mismatched `statusPurpose`, or an out-of-range index all resolve to
19
+ * `{ revoked: true }` —
18
20
  * the absence of proof-of-liveness is treated as revoked, never as "probably fine".
19
21
  *
20
22
  * Each verdict also reports `fresh`: `true` only when read from a LIVE, in-validity-window
@@ -44,6 +46,9 @@ export function createRevocationChecker(deps) {
44
46
  return async function check(entry) {
45
47
  try {
46
48
  const credential = await fetchStatusList(entry.statusListCredential, deps.fetch);
49
+ if (deps.verifyStatusList && (await deps.verifyStatusList(credential)) !== true) {
50
+ throw new Error('revocation: status-list proof rejected');
51
+ }
47
52
  assertStatusPurpose(statusListSubject(credential).statusPurpose, wantedPurpose);
48
53
  const bits = await decodeStatusList(credential, decompress);
49
54
  const revoked = readStatusBit(bits, parseStatusListIndex(entry.statusListIndex));
@@ -1 +1 @@
1
- {"version":3,"file":"revocation.js","sourceRoot":"","sources":["../../src/card/revocation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,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AS,SAAS,CAAC,KAAc;IAC/B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * KYA-OS Entity Card — status-list PROOF check (W3C Data Integrity, `eddsa-jcs-2022`).
3
+ *
4
+ * W3C Bitstring Status List v1.0 has a verifier check every proof on the status-list credential
5
+ * before it reads a bit: the list is what says a credential is revoked, so a list nobody verified
6
+ * lets whoever serves it clear a revocation. {@link createRevocationChecker} takes that check as
7
+ * its `verifyStatusList` seam, the way the rest of the card layer takes credential proofs, and
8
+ * {@link createStatusListProofVerifier} is a ready implementation for lists signed with
9
+ * `DataIntegrityProof` / `eddsa-jcs-2022` by an Ed25519 key in the list issuer's DID document.
10
+ *
11
+ * The construction is the cryptosuite's, step for step: the proof options without `proofValue`,
12
+ * carrying the document's `@context`, and the document without `proof`, each RFC 8785-canonicalized
13
+ * and SHA-256 hashed; the signature is Ed25519 over the two hashes concatenated, `proofValue` is
14
+ * base58btc multibase. The key is the issuer's verification method `proof.verificationMethod`
15
+ * names, and that method must belong to the list's `issuer`. Every failure returns `false`.
16
+ */
17
+ import type { DIDResolver } from '../delegation/vc-verifier.types.js';
18
+ /**
19
+ * Checks a fetched status-list credential's proof. Resolves `true` only when the proof verifies;
20
+ * `false` or a throw rejects the list, and the revocation checker then fails closed.
21
+ */
22
+ export type StatusListProofVerifier = (credential: Record<string, unknown>) => boolean | Promise<boolean>;
23
+ /** Dependencies for {@link createStatusListProofVerifier}. */
24
+ export interface StatusListProofVerifierDeps {
25
+ /** Resolves the list issuer's DID document, e.g. `createDidWebResolver` or `createDidKeyResolver`. */
26
+ didResolver: DIDResolver;
27
+ }
28
+ /**
29
+ * Build a {@link StatusListProofVerifier} for `DataIntegrityProof` / `eddsa-jcs-2022` status lists.
30
+ * Pass it to {@link createRevocationChecker} as `verifyStatusList`.
31
+ */
32
+ export declare function createStatusListProofVerifier(deps: StatusListProofVerifierDeps): StatusListProofVerifier;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * KYA-OS Entity Card — status-list PROOF check (W3C Data Integrity, `eddsa-jcs-2022`).
3
+ *
4
+ * W3C Bitstring Status List v1.0 has a verifier check every proof on the status-list credential
5
+ * before it reads a bit: the list is what says a credential is revoked, so a list nobody verified
6
+ * lets whoever serves it clear a revocation. {@link createRevocationChecker} takes that check as
7
+ * its `verifyStatusList` seam, the way the rest of the card layer takes credential proofs, and
8
+ * {@link createStatusListProofVerifier} is a ready implementation for lists signed with
9
+ * `DataIntegrityProof` / `eddsa-jcs-2022` by an Ed25519 key in the list issuer's DID document.
10
+ *
11
+ * The construction is the cryptosuite's, step for step: the proof options without `proofValue`,
12
+ * carrying the document's `@context`, and the document without `proof`, each RFC 8785-canonicalized
13
+ * and SHA-256 hashed; the signature is Ed25519 over the two hashes concatenated, `proofValue` is
14
+ * base58btc multibase. The key is the issuer's verification method `proof.verificationMethod`
15
+ * names, and that method must belong to the list's `issuer`. Every failure returns `false`.
16
+ */
17
+ import { canonicalize } from 'json-canonicalize';
18
+ import { isRecord } from '../utils/guards.js';
19
+ import { base58Decode } from '../utils/base58.js';
20
+ import { verificationMethodJwk } from '../delegation/verification-method-key.js';
21
+ import { ed25519VerifyRaw, sha256 } from './proof/canonical.js';
22
+ const ED25519_SIGNATURE_LENGTH = 64;
23
+ /** A 64-byte signature is at most 88 base58 characters; bound the decode before it runs. */
24
+ const MAX_PROOF_VALUE_BASE58 = 100;
25
+ /**
26
+ * Build a {@link StatusListProofVerifier} for `DataIntegrityProof` / `eddsa-jcs-2022` status lists.
27
+ * Pass it to {@link createRevocationChecker} as `verifyStatusList`.
28
+ */
29
+ export function createStatusListProofVerifier(deps) {
30
+ return async function verifyStatusList(credential) {
31
+ try {
32
+ return await verifyEddsaJcs2022(credential, deps.didResolver);
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ };
38
+ }
39
+ async function verifyEddsaJcs2022(document, didResolver) {
40
+ const proof = document.proof;
41
+ // One proof object: a proof set or chain is not a shape this check reads.
42
+ if (!isRecord(proof))
43
+ return false;
44
+ if (proof.type !== 'DataIntegrityProof' || proof.cryptosuite !== 'eddsa-jcs-2022')
45
+ return false;
46
+ if (proof.proofPurpose !== 'assertionMethod')
47
+ return false;
48
+ const { proofValue, verificationMethod } = proof;
49
+ if (typeof proofValue !== 'string' || !proofValue.startsWith('z'))
50
+ return false;
51
+ if (typeof verificationMethod !== 'string')
52
+ return false;
53
+ const issuer = issuerOf(document);
54
+ const did = verificationMethod.split('#')[0];
55
+ if (issuer === undefined || did !== issuer)
56
+ return false;
57
+ const signature = base58Decode(proofValue.slice(1), MAX_PROOF_VALUE_BASE58);
58
+ if (signature.length !== ED25519_SIGNATURE_LENGTH)
59
+ return false;
60
+ const didDocument = await didResolver.resolve(did);
61
+ const method = didDocument?.verificationMethod?.find((vm) => methodId(vm, did) === verificationMethod);
62
+ const jwk = method ? verificationMethodJwk(method) : undefined;
63
+ if (!jwk || jwk.kty !== 'OKP' || jwk.crv !== 'Ed25519')
64
+ return false;
65
+ const unsecured = { ...document };
66
+ delete unsecured.proof;
67
+ const options = { ...proof };
68
+ delete options.proofValue;
69
+ if (options['@context'] !== undefined) {
70
+ // The proof may name its own @context only as a prefix of the document's.
71
+ if (!startsWith(contexts(document['@context']), contexts(options['@context'])))
72
+ return false;
73
+ unsecured['@context'] = options['@context'];
74
+ }
75
+ if (unsecured['@context'] !== undefined)
76
+ options['@context'] = unsecured['@context'];
77
+ const encoder = new TextEncoder();
78
+ const proofHash = await sha256(encoder.encode(canonicalize(options)));
79
+ const documentHash = await sha256(encoder.encode(canonicalize(unsecured)));
80
+ const hashData = new Uint8Array(proofHash.length + documentHash.length);
81
+ hashData.set(proofHash, 0);
82
+ hashData.set(documentHash, proofHash.length);
83
+ return ed25519VerifyRaw(jwk, signature, hashData);
84
+ }
85
+ /** The credential's `issuer` DID, whether a bare string or an `{ id }` object. */
86
+ function issuerOf(document) {
87
+ const issuer = document.issuer;
88
+ if (typeof issuer === 'string')
89
+ return issuer;
90
+ return isRecord(issuer) && typeof issuer.id === 'string' ? issuer.id : undefined;
91
+ }
92
+ /** A verification method's absolute id: DID documents may write it relative (`#key-1`). */
93
+ function methodId(method, did) {
94
+ return method.id.startsWith('#') ? `${did}${method.id}` : method.id;
95
+ }
96
+ function contexts(value) {
97
+ return Array.isArray(value) ? value : value === undefined ? [] : [value];
98
+ }
99
+ function startsWith(whole, prefix) {
100
+ return prefix.length <= whole.length && prefix.every((entry, i) => canonicalize(entry) === canonicalize(whole[i]));
101
+ }
102
+ //# sourceMappingURL=status-list-proof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-list-proof.js","sourceRoot":"","sources":["../../src/card/status-list-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAchE,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,4FAA4F;AAC5F,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAAC,IAAiC;IAC7E,OAAO,KAAK,UAAU,gBAAgB,CAAC,UAAmC;QACxE,IAAI,CAAC;YACH,OAAO,MAAM,kBA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EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrH,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import type { VerificationMethod } from './vc-verifier.types.js';
2
+ /** The verification-method fields that can carry an Ed25519 public key. */
3
+ type VerificationMethodKeyMaterial = Pick<VerificationMethod, 'publicKeyJwk' | 'publicKeyMultibase' | 'publicKeyBase58'>;
2
4
  /**
3
5
  * The verification method's public key as an Ed25519 OKP JWK: an existing
4
6
  * `publicKeyJwk` is returned untouched (byte-for-byte — zero behavior change
@@ -7,8 +9,9 @@ import type { VerificationMethod } from './vc-verifier.types.js';
7
9
  * prefix) or legacy `publicKeyBase58`. `undefined` when no usable Ed25519 key
8
10
  * is present (fail-closed).
9
11
  */
10
- export declare function verificationMethodJwk(method: VerificationMethod): {
12
+ export declare function verificationMethodJwk(method: VerificationMethodKeyMaterial): {
11
13
  kty: string;
12
14
  crv: string;
13
15
  x: string;
14
16
  } | undefined;
17
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"verification-method-key.js","sourceRoot":"","sources":["../../src/delegation/verification-method-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAG/B,sCAAsC;AACtC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAA0B;IAE1B,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,YAAuD,CAAC;IACxE,CAAC;IAED,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,GAAG,CAAC,CAAC,CAAC,cAAc,C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,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAAC;YAC/E,OAAO,OAAO,CAAC,MAAM,KAAK,yBAAyB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5E,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC,CAAC,iCAAiC;IACrD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -51,7 +51,7 @@ export { AuditLogProvider, MemoryAuditLogProvider, NoopAuditLogProvider, buildAu
51
51
  export * from './audit/index.js';
52
52
  export { GrantStore, MemoryGrantStore, type Grant, type MemoryGrantStoreOptions, } from './providers/grant-store.js';
53
53
  export { PendingFlowStore, MemoryPendingFlowStore, type PendingFlow, type MemoryPendingFlowStoreOptions, } from './authz/oidc/pending-flow-store.js';
54
- export { createKyaOsMiddleware, type KyaOsConfig, type KyaOsDelegationConfig, type KyaOsIdentityConfig, type KyaOsMiddleware, type KyaOsToolDefinition, type KyaOsToolHandler, type KyaOsServer, withKyaOs, generateIdentity, type WithKyaOsOptions, } from './middleware/index.js';
54
+ export { createKyaOsMiddleware, type KyaOsConfig, type KyaOsDelegationConfig, type KyaOsIdentityConfig, type KyaOsMiddleware, type KyaOsToolDefinition, type KyaOsToolHandler, type KyaOsToolResult, type KyaOsServer, type KyaOsAuthorizationOutcome, type KyaOsOutcomeProofRequest, type KyaOsOutcomeProver, type KyaOsChallengeResult, type KyaOsChallengeFormatter, withKyaOs, generateIdentity, type WithKyaOsOptions, toMcpToolCallback, type McpToolCallback, type McpToolCallbackResult, createKyaOsTransport, serveInProcess, type InProcessServer, } from './middleware/index.js';
55
55
  export * from './policy/index.js';
56
56
  export { matchScope, scopeSatisfies, type ScopeMatcher, type ScopeSatisfaction, } from './delegation/scope-matcher.js';
57
57
  export { logger, createDefaultConsoleLogger, type Logger, type Level, } from './logging/index.js';
package/dist/index.js CHANGED
@@ -63,7 +63,7 @@ export { GrantStore, MemoryGrantStore, } from './providers/grant-store.js';
63
63
  // Pending OAuth/OIDC PKCE-flow store (durable resume across instances/restarts).
64
64
  export { PendingFlowStore, MemoryPendingFlowStore, } from './authz/oidc/pending-flow-store.js';
65
65
  // Middleware
66
- export { createKyaOsMiddleware, withKyaOs, generateIdentity, } from './middleware/index.js';
66
+ export { createKyaOsMiddleware, withKyaOs, generateIdentity, toMcpToolCallback, createKyaOsTransport, serveInProcess, } from './middleware/index.js';
67
67
  // Policy-as-Code subsystem + step-up gate
68
68
  export * from './policy/index.js';
69
69
  export { matchScope, scopeSatisfies, } from './delegation/scope-matcher.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;AA+B3B,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,2BAA2B,EAC3B,+BAA+B,GAEhC,MAAM,qBAAqB,CAAC;AAE7B,oBAAoB;AACpB,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GAIvB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,GASzB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,sBAAsB,EACtB,qBAAqB,G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,10 @@
6
6
  *
7
7
  * For the low-level `Server` API or custom patterns, use `createKyaOsMiddleware` directly.
8
8
  */
9
- export { createKyaOsMiddleware, type KyaOsConfig, type KyaOsDelegationConfig, type KyaOsIdentityConfig, type KyaOsMiddleware, type KyaOsToolDefinition, type KyaOsToolHandler, type KyaOsServer, } from './with-kya-os.js';
9
+ export { createKyaOsMiddleware, type KyaOsConfig, type KyaOsDelegationConfig, type KyaOsIdentityConfig, type KyaOsMiddleware, type KyaOsToolDefinition, type KyaOsToolHandler, type KyaOsToolResult, type KyaOsServer, type KyaOsAuthorizationOutcome, type KyaOsOutcomeProofRequest, type KyaOsOutcomeProver, type KyaOsChallengeResult, type KyaOsChallengeFormatter, } from './with-kya-os.js';
10
10
  export { withKyaOs, generateIdentity, type WithKyaOsOptions, } from './with-kya-os-server.js';
11
+ export { toMcpToolCallback, type McpToolCallback, type McpToolCallbackResult, } from './mcp-tool-callback.js';
11
12
  export { createKyaOsTransport, type Transport, type JSONRPCMessage, } from './kya-os-transport.js';
13
+ export { serveInProcess, type InProcessServer } from './serve-in-process.js';
12
14
  export { card, CardBuilder, type CardBuilderInit, type AccountableToOptions, type VcInput, } from '../card/builder.js';
13
15
  export { withKyaOsCard, requireProof, readCardProof, type KyaOsCardMount, type ServerJsonLike, type DidDocumentLike, type ProofGuard, type ProofGateResult, type ProofGateError, type ProofGateCode, type RequireProofOptions, type MinProofLevel, } from '../card/middleware.js';
@@ -8,7 +8,9 @@
8
8
  */
9
9
  export { createKyaOsMiddleware, } from './with-kya-os.js';
10
10
  export { withKyaOs, generateIdentity, } from './with-kya-os-server.js';
11
+ export { toMcpToolCallback, } from './mcp-tool-callback.js';
11
12
  export { createKyaOsTransport, } from './kya-os-transport.js';
13
+ export { serveInProcess } from './serve-in-process.js';
12
14
  // Entity Card DevX surface — the 10-minute adoption path. The fluent `card()` builder and the
13
15
  // `withKyaOsCard` / `requireProof` wrappers hide the RFC 9421/9449/8785 machinery behind
14
16
  // ergonomics (see `src/card/builder.ts` + `src/card/middleware.ts`).
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,qBAAqB,GAQtB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,SAAS,EACT,gBAAgB,GAEjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,oBAAoB,GAGrB,MAAM,uBAAuB,CAAC;AAE/B,8FAA8F;AAC9F,yFAAyF;AACzF,qEAAqE;AACrE,OAAO,EACL,IAAI,EACJ,WAAW,GAIZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,GAUd,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,qBAAqB,GActB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,SAAS,EACT,gBAAgB,GAEjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,GAGlB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,oBAAoB,GAGrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAwB,MAAM,uBAAuB,CAAC;AAE7E,8FAA8F;AAC9F,yFAAyF;AACzF,qEAAqE;AACrE,OAAO,EACL,IAAI,EACJ,WAAW,GAIZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,GAUd,MAAM,uBAAuB,CAAC"}
@@ -13,30 +13,61 @@
13
13
  * 1. Incoming `tools/call` requests are captured (by id) to record tool
14
14
  * name and arguments for proof generation.
15
15
  * 2. Outgoing responses for those ids get a proof injected into `_meta`,
16
- * unless the middleware's own wrappers already proved or audited the
17
- * result, which they mark with a private per-middleware stamp.
18
- * 3. All other message types pass through unmodified, except that the
19
- * stamp is removed from every result before it is sent.
16
+ * unless the middleware's own wrappers produced the result, which they
17
+ * mark with a private per-middleware stamp.
18
+ * 3. The wrappers leave their proofs here, and every proof is made in
19
+ * `send()`, over the result as the MCP SDK finished it: the SDK changes
20
+ * a result after the handler returns (`resultType` on the 2026-07-28
21
+ * revision, a filled-in or appended `content`), and the proof covers
22
+ * what it covers of the result the client receives.
23
+ * 4. All other message types pass through unmodified, except that the
24
+ * middleware's private members are removed from every result before it
25
+ * is sent.
20
26
  *
21
27
  * @module kya-os-transport
22
28
  */
23
29
  import type { KyaOsMiddleware } from "./with-kya-os.js";
24
- /** Minimal Transport interface — matches @modelcontextprotocol/sdk Transport */
30
+ /**
31
+ * Minimal Transport interface — matches @modelcontextprotocol/sdk Transport.
32
+ * The callbacks are declared as methods, so an SDK transport, whose callbacks
33
+ * take the SDK's own message type, is accepted as it is (SDK 1 and SDK 2).
34
+ * The SDK's send options and message context (`extra`: the session id,
35
+ * `authInfo`, `requestInfo`) are opaque here and passed through unchanged.
36
+ */
25
37
  export interface Transport {
26
38
  start(): Promise<void>;
27
- send(message: JSONRPCMessage): Promise<void>;
39
+ send(message: JSONRPCMessage, options?: unknown): Promise<void>;
28
40
  close(): Promise<void>;
29
- onmessage?: (message: JSONRPCMessage) => void;
30
- onclose?: () => void;
31
- onerror?: (error: Error) => void;
41
+ onmessage?(message: JSONRPCMessage, extra?: unknown): void;
42
+ onclose?(): void;
43
+ onerror?(error: Error): void;
44
+ sessionId?: string;
45
+ setProtocolVersion?(version: string): void;
46
+ setSupportedProtocolVersions?(versions: string[]): void;
47
+ /** SDK 2: installs per-tool OAuth `scopeChallenge` enforcement on an HTTP transport. */
48
+ setScopeChallengeResolver?(resolver: unknown): void;
49
+ readonly hasPerRequestStream?: boolean;
32
50
  }
33
51
  export type JSONRPCMessage = Record<string, unknown>;
34
52
  /**
35
53
  * Creates a transport wrapper that injects KYA-OS proofs into `tools/call`
36
- * responses.
54
+ * responses, and makes the proofs the middleware's wrappers and
55
+ * `proveOutcome` leave to it, over each result as it is sent. A server on the
56
+ * low-level `Server` API connects through it:
57
+ * `server.connect(createKyaOsTransport(transport, kyaos))`.
58
+ *
59
+ * It proves and audits the result of every tool it is not told to exclude,
60
+ * including tools registered without a wrapper, as `withKyaOs` does. A
61
+ * low-level server that used only the wrappers on an unwrapped transport,
62
+ * which 1.19.0 allowed, sent its unwrapped tools' results unproven; through
63
+ * this transport they carry a proof too.
37
64
  *
38
65
  * @param inner - The real transport (Stdio, HTTP, etc.)
39
66
  * @param kyaos - Configured KyaOsMiddleware instance
40
- * @param exclude - Tool names to skip proof generation for
67
+ * @param exclude - More tool names whose results are not proved by the
68
+ * transport itself, in addition to the protocol tools `_kyaos` and
69
+ * `_kyaos_handshake`, which are always excluded (as `excludeTools` adds
70
+ * to them in `withKyaOs`). A wrapper's own proof is made whatever this
71
+ * says.
41
72
  */
42
- export declare function createKyaOsTransport(inner: Transport, kyaos: KyaOsMiddleware, exclude?: string[]): Transport;
73
+ export declare function createKyaOsTransport(inner: Transport, kyaos: KyaOsMiddleware, exclude?: readonly string[]): Transport;