@kya-os/mcp-i-core 1.3.12 → 1.3.14

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 (254) hide show
  1. package/dist/config/remote-config.js +9 -12
  2. package/dist/runtime/base.js +11 -0
  3. package/dist/services/access-control.service.js +5 -0
  4. package/dist/services/tool-protection.service.js +17 -8
  5. package/package.json +2 -2
  6. package/.turbo/turbo-build.log +0 -4
  7. package/.turbo/turbo-test$colon$coverage.log +0 -4586
  8. package/.turbo/turbo-test.log +0 -3169
  9. package/COMPLIANCE_IMPROVEMENT_REPORT.md +0 -483
  10. package/Composer 3.md +0 -615
  11. package/GPT-5.md +0 -1169
  12. package/OPUS-plan.md +0 -352
  13. package/PHASE_3_AND_4.1_SUMMARY.md +0 -585
  14. package/PHASE_3_SUMMARY.md +0 -317
  15. package/PHASE_4.1.3_SUMMARY.md +0 -428
  16. package/PHASE_4.1_COMPLETE.md +0 -525
  17. package/PHASE_4_USER_DID_IDENTITY_LINKING_PLAN.md +0 -1240
  18. package/SCHEMA_COMPLIANCE_REPORT.md +0 -275
  19. package/TEST_PLAN.md +0 -571
  20. package/coverage/coverage-final.json +0 -60
  21. package/dist/cache/oauth-config-cache.d.ts.map +0 -1
  22. package/dist/cache/oauth-config-cache.js.map +0 -1
  23. package/dist/cache/tool-protection-cache.d.ts.map +0 -1
  24. package/dist/cache/tool-protection-cache.js.map +0 -1
  25. package/dist/compliance/index.d.ts.map +0 -1
  26. package/dist/compliance/index.js.map +0 -1
  27. package/dist/compliance/schema-registry.d.ts.map +0 -1
  28. package/dist/compliance/schema-registry.js.map +0 -1
  29. package/dist/compliance/schema-verifier.d.ts.map +0 -1
  30. package/dist/compliance/schema-verifier.js.map +0 -1
  31. package/dist/config/remote-config.d.ts.map +0 -1
  32. package/dist/config/remote-config.js.map +0 -1
  33. package/dist/config.d.ts.map +0 -1
  34. package/dist/config.js.map +0 -1
  35. package/dist/delegation/audience-validator.d.ts.map +0 -1
  36. package/dist/delegation/audience-validator.js.map +0 -1
  37. package/dist/delegation/bitstring.d.ts.map +0 -1
  38. package/dist/delegation/bitstring.js.map +0 -1
  39. package/dist/delegation/cascading-revocation.d.ts.map +0 -1
  40. package/dist/delegation/cascading-revocation.js.map +0 -1
  41. package/dist/delegation/delegation-graph.d.ts.map +0 -1
  42. package/dist/delegation/delegation-graph.js.map +0 -1
  43. package/dist/delegation/did-key-resolver.d.ts.map +0 -1
  44. package/dist/delegation/did-key-resolver.js.map +0 -1
  45. package/dist/delegation/index.d.ts.map +0 -1
  46. package/dist/delegation/index.js.map +0 -1
  47. package/dist/delegation/statuslist-manager.d.ts.map +0 -1
  48. package/dist/delegation/statuslist-manager.js.map +0 -1
  49. package/dist/delegation/storage/index.d.ts.map +0 -1
  50. package/dist/delegation/storage/index.js.map +0 -1
  51. package/dist/delegation/storage/memory-graph-storage.d.ts.map +0 -1
  52. package/dist/delegation/storage/memory-graph-storage.js.map +0 -1
  53. package/dist/delegation/storage/memory-statuslist-storage.d.ts.map +0 -1
  54. package/dist/delegation/storage/memory-statuslist-storage.js.map +0 -1
  55. package/dist/delegation/utils.d.ts.map +0 -1
  56. package/dist/delegation/utils.js.map +0 -1
  57. package/dist/delegation/vc-issuer.d.ts.map +0 -1
  58. package/dist/delegation/vc-issuer.js.map +0 -1
  59. package/dist/delegation/vc-verifier.d.ts.map +0 -1
  60. package/dist/delegation/vc-verifier.js.map +0 -1
  61. package/dist/identity/idp-token-resolver.d.ts.map +0 -1
  62. package/dist/identity/idp-token-resolver.js.map +0 -1
  63. package/dist/identity/idp-token-storage.interface.d.ts.map +0 -1
  64. package/dist/identity/idp-token-storage.interface.js.map +0 -1
  65. package/dist/identity/user-did-manager.d.ts.map +0 -1
  66. package/dist/identity/user-did-manager.js.map +0 -1
  67. package/dist/index.d.ts.map +0 -1
  68. package/dist/index.js.map +0 -1
  69. package/dist/providers/base.d.ts.map +0 -1
  70. package/dist/providers/base.js.map +0 -1
  71. package/dist/providers/memory.d.ts.map +0 -1
  72. package/dist/providers/memory.js.map +0 -1
  73. package/dist/runtime/audit-logger.d.ts.map +0 -1
  74. package/dist/runtime/audit-logger.js.map +0 -1
  75. package/dist/runtime/base.d.ts.map +0 -1
  76. package/dist/runtime/base.js.map +0 -1
  77. package/dist/services/access-control.service.d.ts.map +0 -1
  78. package/dist/services/access-control.service.js.map +0 -1
  79. package/dist/services/authorization/authorization-registry.d.ts.map +0 -1
  80. package/dist/services/authorization/authorization-registry.js.map +0 -1
  81. package/dist/services/authorization/types.d.ts.map +0 -1
  82. package/dist/services/authorization/types.js.map +0 -1
  83. package/dist/services/batch-delegation.service.d.ts.map +0 -1
  84. package/dist/services/batch-delegation.service.js.map +0 -1
  85. package/dist/services/crypto.service.d.ts.map +0 -1
  86. package/dist/services/crypto.service.js.map +0 -1
  87. package/dist/services/errors.d.ts.map +0 -1
  88. package/dist/services/errors.js.map +0 -1
  89. package/dist/services/index.d.ts.map +0 -1
  90. package/dist/services/index.js.map +0 -1
  91. package/dist/services/oauth-config.service.d.ts.map +0 -1
  92. package/dist/services/oauth-config.service.js.map +0 -1
  93. package/dist/services/oauth-provider-registry.d.ts.map +0 -1
  94. package/dist/services/oauth-provider-registry.js.map +0 -1
  95. package/dist/services/oauth-service.d.ts.map +0 -1
  96. package/dist/services/oauth-service.js.map +0 -1
  97. package/dist/services/oauth-token-retrieval.service.d.ts.map +0 -1
  98. package/dist/services/oauth-token-retrieval.service.js.map +0 -1
  99. package/dist/services/proof-verifier.d.ts.map +0 -1
  100. package/dist/services/proof-verifier.js.map +0 -1
  101. package/dist/services/provider-resolver.d.ts.map +0 -1
  102. package/dist/services/provider-resolver.js.map +0 -1
  103. package/dist/services/provider-validator.d.ts.map +0 -1
  104. package/dist/services/provider-validator.js.map +0 -1
  105. package/dist/services/session-registration.service.d.ts.map +0 -1
  106. package/dist/services/session-registration.service.js.map +0 -1
  107. package/dist/services/storage.service.d.ts.map +0 -1
  108. package/dist/services/storage.service.js.map +0 -1
  109. package/dist/services/tool-context-builder.d.ts.map +0 -1
  110. package/dist/services/tool-context-builder.js.map +0 -1
  111. package/dist/services/tool-protection.service.d.ts.map +0 -1
  112. package/dist/services/tool-protection.service.js.map +0 -1
  113. package/dist/types/oauth-required-error.d.ts.map +0 -1
  114. package/dist/types/oauth-required-error.js.map +0 -1
  115. package/dist/types/tool-protection.d.ts.map +0 -1
  116. package/dist/types/tool-protection.js.map +0 -1
  117. package/dist/utils/base58.d.ts.map +0 -1
  118. package/dist/utils/base58.js.map +0 -1
  119. package/dist/utils/base64.d.ts.map +0 -1
  120. package/dist/utils/base64.js.map +0 -1
  121. package/dist/utils/cors.d.ts.map +0 -1
  122. package/dist/utils/cors.js.map +0 -1
  123. package/dist/utils/did-helpers.d.ts.map +0 -1
  124. package/dist/utils/did-helpers.js.map +0 -1
  125. package/dist/utils/index.d.ts.map +0 -1
  126. package/dist/utils/index.js.map +0 -1
  127. package/dist/utils/storage-keys.d.ts.map +0 -1
  128. package/dist/utils/storage-keys.js.map +0 -1
  129. package/docs/API_REFERENCE.md +0 -1362
  130. package/docs/COMPLIANCE_MATRIX.md +0 -691
  131. package/docs/STATUSLIST2021_GUIDE.md +0 -696
  132. package/docs/W3C_VC_DELEGATION_GUIDE.md +0 -710
  133. package/src/__tests__/cache/tool-protection-cache.test.ts +0 -640
  134. package/src/__tests__/config/provider-runtime-config.test.ts +0 -309
  135. package/src/__tests__/delegation-e2e.test.ts +0 -690
  136. package/src/__tests__/identity/user-did-manager.test.ts +0 -232
  137. package/src/__tests__/index.test.ts +0 -56
  138. package/src/__tests__/integration/full-flow.test.ts +0 -789
  139. package/src/__tests__/integration.test.ts +0 -281
  140. package/src/__tests__/providers/base.test.ts +0 -173
  141. package/src/__tests__/providers/memory.test.ts +0 -319
  142. package/src/__tests__/regression/phase2-regression.test.ts +0 -429
  143. package/src/__tests__/runtime/audit-logger.test.ts +0 -154
  144. package/src/__tests__/runtime/base-extensions.test.ts +0 -595
  145. package/src/__tests__/runtime/base.test.ts +0 -869
  146. package/src/__tests__/runtime/delegation-flow.test.ts +0 -164
  147. package/src/__tests__/runtime/proof-client-did.test.ts +0 -376
  148. package/src/__tests__/runtime/route-interception.test.ts +0 -686
  149. package/src/__tests__/runtime/tool-protection-enforcement.test.ts +0 -908
  150. package/src/__tests__/services/agentshield-integration.test.ts +0 -791
  151. package/src/__tests__/services/cache-busting.test.ts +0 -125
  152. package/src/__tests__/services/oauth-service-pkce.test.ts +0 -556
  153. package/src/__tests__/services/provider-resolver-edge-cases.test.ts +0 -591
  154. package/src/__tests__/services/tool-protection-merged-config.test.ts +0 -485
  155. package/src/__tests__/services/tool-protection-oauth-provider.test.ts +0 -480
  156. package/src/__tests__/services/tool-protection.service.test.ts +0 -1373
  157. package/src/__tests__/utils/mock-providers.ts +0 -340
  158. package/src/cache/oauth-config-cache.d.ts +0 -69
  159. package/src/cache/oauth-config-cache.d.ts.map +0 -1
  160. package/src/cache/oauth-config-cache.js.map +0 -1
  161. package/src/cache/oauth-config-cache.ts +0 -123
  162. package/src/cache/tool-protection-cache.ts +0 -171
  163. package/src/compliance/EXAMPLE.md +0 -412
  164. package/src/compliance/__tests__/schema-verifier.test.ts +0 -797
  165. package/src/compliance/index.ts +0 -8
  166. package/src/compliance/schema-registry.ts +0 -460
  167. package/src/compliance/schema-verifier.ts +0 -708
  168. package/src/config/__tests__/merged-config.spec.ts +0 -445
  169. package/src/config/__tests__/remote-config.spec.ts +0 -268
  170. package/src/config/remote-config.ts +0 -264
  171. package/src/config.ts +0 -312
  172. package/src/delegation/__tests__/audience-validator.test.ts +0 -112
  173. package/src/delegation/__tests__/bitstring.test.ts +0 -346
  174. package/src/delegation/__tests__/cascading-revocation.test.ts +0 -628
  175. package/src/delegation/__tests__/delegation-graph.test.ts +0 -584
  176. package/src/delegation/__tests__/did-key-resolver.test.ts +0 -265
  177. package/src/delegation/__tests__/utils.test.ts +0 -152
  178. package/src/delegation/__tests__/vc-issuer.test.ts +0 -442
  179. package/src/delegation/__tests__/vc-verifier.test.ts +0 -922
  180. package/src/delegation/audience-validator.ts +0 -52
  181. package/src/delegation/bitstring.ts +0 -278
  182. package/src/delegation/cascading-revocation.ts +0 -370
  183. package/src/delegation/delegation-graph.ts +0 -299
  184. package/src/delegation/did-key-resolver.ts +0 -179
  185. package/src/delegation/index.ts +0 -14
  186. package/src/delegation/statuslist-manager.ts +0 -353
  187. package/src/delegation/storage/__tests__/memory-graph-storage.test.ts +0 -366
  188. package/src/delegation/storage/__tests__/memory-statuslist-storage.test.ts +0 -228
  189. package/src/delegation/storage/index.ts +0 -9
  190. package/src/delegation/storage/memory-graph-storage.ts +0 -178
  191. package/src/delegation/storage/memory-statuslist-storage.ts +0 -77
  192. package/src/delegation/utils.ts +0 -221
  193. package/src/delegation/vc-issuer.ts +0 -232
  194. package/src/delegation/vc-verifier.ts +0 -568
  195. package/src/identity/idp-token-resolver.ts +0 -181
  196. package/src/identity/idp-token-storage.interface.ts +0 -94
  197. package/src/identity/user-did-manager.ts +0 -526
  198. package/src/index.ts +0 -310
  199. package/src/providers/base.d.ts +0 -91
  200. package/src/providers/base.d.ts.map +0 -1
  201. package/src/providers/base.js.map +0 -1
  202. package/src/providers/base.ts +0 -96
  203. package/src/providers/memory.ts +0 -142
  204. package/src/runtime/audit-logger.ts +0 -39
  205. package/src/runtime/base.ts +0 -1392
  206. package/src/services/__tests__/access-control.integration.test.ts +0 -443
  207. package/src/services/__tests__/access-control.proof-response-validation.test.ts +0 -578
  208. package/src/services/__tests__/access-control.service.test.ts +0 -970
  209. package/src/services/__tests__/batch-delegation.service.test.ts +0 -351
  210. package/src/services/__tests__/crypto.service.test.ts +0 -531
  211. package/src/services/__tests__/oauth-provider-registry.test.ts +0 -142
  212. package/src/services/__tests__/proof-verifier.integration.test.ts +0 -485
  213. package/src/services/__tests__/proof-verifier.test.ts +0 -489
  214. package/src/services/__tests__/provider-resolution.integration.test.ts +0 -202
  215. package/src/services/__tests__/provider-resolver.test.ts +0 -213
  216. package/src/services/__tests__/storage.service.test.ts +0 -358
  217. package/src/services/access-control.service.ts +0 -990
  218. package/src/services/authorization/authorization-registry.ts +0 -66
  219. package/src/services/authorization/types.ts +0 -71
  220. package/src/services/batch-delegation.service.ts +0 -137
  221. package/src/services/crypto.service.ts +0 -302
  222. package/src/services/errors.ts +0 -76
  223. package/src/services/index.ts +0 -18
  224. package/src/services/oauth-config.service.d.ts +0 -53
  225. package/src/services/oauth-config.service.d.ts.map +0 -1
  226. package/src/services/oauth-config.service.js.map +0 -1
  227. package/src/services/oauth-config.service.ts +0 -192
  228. package/src/services/oauth-provider-registry.d.ts +0 -57
  229. package/src/services/oauth-provider-registry.d.ts.map +0 -1
  230. package/src/services/oauth-provider-registry.js.map +0 -1
  231. package/src/services/oauth-provider-registry.ts +0 -141
  232. package/src/services/oauth-service.ts +0 -544
  233. package/src/services/oauth-token-retrieval.service.ts +0 -245
  234. package/src/services/proof-verifier.ts +0 -478
  235. package/src/services/provider-resolver.d.ts +0 -48
  236. package/src/services/provider-resolver.d.ts.map +0 -1
  237. package/src/services/provider-resolver.js.map +0 -1
  238. package/src/services/provider-resolver.ts +0 -146
  239. package/src/services/provider-validator.ts +0 -170
  240. package/src/services/session-registration.service.ts +0 -251
  241. package/src/services/storage.service.ts +0 -566
  242. package/src/services/tool-context-builder.ts +0 -237
  243. package/src/services/tool-protection.service.ts +0 -1070
  244. package/src/types/oauth-required-error.ts +0 -63
  245. package/src/types/tool-protection.ts +0 -155
  246. package/src/utils/__tests__/did-helpers.test.ts +0 -156
  247. package/src/utils/base58.ts +0 -109
  248. package/src/utils/base64.ts +0 -148
  249. package/src/utils/cors.ts +0 -83
  250. package/src/utils/did-helpers.ts +0 -210
  251. package/src/utils/index.ts +0 -8
  252. package/src/utils/storage-keys.ts +0 -278
  253. package/tsconfig.json +0 -21
  254. package/vitest.config.ts +0 -56
@@ -1,691 +0,0 @@
1
- # Schema Compliance Matrix
2
-
3
- ## Overview
4
-
5
- This document tracks MCP-I Core's compliance with canonical schemas from [schemas.kya-os.ai](https://schemas.kya-os.ai). We use JSON Schema draft-07 validation to ensure 100% compatibility with the W3C VC and DID standards.
6
-
7
- ## Current Compliance Status
8
-
9
- Last Updated: **2025-10-17**
10
-
11
- ### Critical Schemas (100% Required)
12
-
13
- | Schema | Compliance | Status | Source |
14
- |--------|-----------|--------|--------|
15
- | `delegation-credential` | 100% ✅ | Production Ready | [schemas.kya-os.ai](https://schemas.kya-os.ai/delegation-credential.schema.json) |
16
- | `delegation-constraints` | 100% ✅ | Production Ready | [schemas.kya-os.ai](https://schemas.kya-os.ai/delegation-constraints.schema.json) |
17
- | `handshake-request` | 100% ✅ | Production Ready | [schemas.kya-os.ai](https://schemas.kya-os.ai/handshake-request.schema.json) |
18
- | `session-context` | 100% ✅ | Production Ready | [schemas.kya-os.ai](https://schemas.kya-os.ai/session-context.schema.json) |
19
- | `detached-proof` | 100% ✅ | Production Ready | [schemas.kya-os.ai](https://schemas.kya-os.ai/detached-proof.schema.json) |
20
- | `proof-meta` | 100% ✅ | Production Ready | [schemas.kya-os.ai](https://schemas.kya-os.ai/proof-meta.schema.json) |
21
- | `audit-record` | 100% ✅ | Production Ready | [schemas.kya-os.ai](https://schemas.kya-os.ai/audit-record.schema.json) |
22
- | `status-list-2021` | 100% ✅ | Production Ready | [W3C Spec](https://www.w3.org/TR/vc-status-list-2021/) |
23
-
24
- ### Supporting Schemas (High Priority)
25
-
26
- | Schema | Compliance | Status | Notes |
27
- |--------|-----------|--------|-------|
28
- | `canonical-hashes` | 100% ✅ | Production Ready | SHA-256 and SHA-512 support |
29
- | `nonce-cache-entry` | 100% ✅ | Production Ready | Memory, Redis, DynamoDB |
30
-
31
- ### Summary
32
-
33
- ```
34
- ┌─────────────────────────────────────────────────────────┐
35
- │ MCP-I Core Schema Compliance Report │
36
- ├─────────────────────────────────────────────────────────┤
37
- │ Critical Schemas (8): 8/8 (100%) ✅ │
38
- │ Supporting Schemas (2): 2/2 (100%) ✅ │
39
- │ Total Schemas: 10/10 (100%) ✅ │
40
- │ │
41
- │ Status: PRODUCTION READY │
42
- └─────────────────────────────────────────────────────────┘
43
- ```
44
-
45
- ## Schema Details
46
-
47
- ### 1. Delegation Credential
48
-
49
- **Schema URL:** https://schemas.kya-os.ai/delegation-credential.schema.json
50
-
51
- **Compliance:** 100% ✅
52
-
53
- **Required Fields:**
54
- - ✅ `@context` (array) - JSON-LD context
55
- - ✅ `type` (array) - Must include "VerifiableCredential" and "DelegationCredential"
56
- - ✅ `issuer` (string) - DID of issuing agent
57
- - ✅ `issuanceDate` (string, ISO 8601)
58
- - ✅ `credentialSubject` (object) - Subject DID and constraints
59
- - ✅ `proof` (object) - Ed25519Signature2020
60
-
61
- **Implementation:** `src/delegation/issuer.ts`
62
-
63
- **Example:**
64
- ```typescript
65
- import { DelegationIssuer } from '@kya-os/mcp-i-core';
66
-
67
- const delegation = await issuer.issue({
68
- subjectDid: 'did:key:z6Mkr...',
69
- constraints: {
70
- scope: {
71
- allowedTools: ['read_file'],
72
- allowedResources: ['/documents/*'],
73
- },
74
- },
75
- });
76
- ```
77
-
78
- ### 2. Delegation Constraints (CRISP)
79
-
80
- **Schema URL:** https://schemas.kya-os.ai/delegation-constraints.schema.json
81
-
82
- **Compliance:** 100% ✅
83
-
84
- **Constraint Types:**
85
- - ✅ **Cost** (`budget`): maxCost, currency
86
- - ✅ **Resource** (`resources`): quotas, rate limits
87
- - ✅ **Identity** (`identity`): authentication requirements
88
- - ✅ **Scope** (`scope`): allowedTools, allowedResources
89
- - ✅ **Purpose** (`purpose`): intended use description
90
-
91
- **Implementation:** `src/delegation/constraints.ts`
92
-
93
- **Example:**
94
- ```typescript
95
- const constraints: DelegationConstraints = {
96
- budget: {
97
- maxCost: 100,
98
- currency: 'USD',
99
- },
100
- scope: {
101
- allowedTools: ['read_file', 'write_file'],
102
- allowedResources: ['/documents/*', '/tmp/*'],
103
- },
104
- resources: {
105
- maxRequests: 1000,
106
- maxTokens: 100000,
107
- },
108
- time: {
109
- notBefore: '2025-10-17T00:00:00Z',
110
- notAfter: '2025-10-18T00:00:00Z',
111
- },
112
- };
113
- ```
114
-
115
- ### 3. Handshake Request
116
-
117
- **Schema URL:** https://schemas.kya-os.ai/handshake-request.schema.json
118
-
119
- **Compliance:** 100% ✅
120
-
121
- **Required Fields:**
122
- - ✅ `nonce` (string) - Cryptographic nonce
123
- - ✅ `audience` (string) - Target service URL
124
- - ✅ `timestamp` (integer) - Unix timestamp
125
- - ✅ `agentDid` (string) - Agent's DID
126
-
127
- **Implementation:** `src/session/handshake.ts`
128
-
129
- **Example:**
130
- ```typescript
131
- const handshake: HandshakeRequest = {
132
- nonce: 'nonce-' + crypto.randomUUID(),
133
- audience: 'https://api.example.com',
134
- timestamp: Date.now(),
135
- agentDid: 'did:key:z6Mkr...',
136
- };
137
- ```
138
-
139
- ### 4. Session Context
140
-
141
- **Schema URL:** https://schemas.kya-os.ai/session-context.schema.json
142
-
143
- **Compliance:** 100% ✅
144
-
145
- **Required Fields:**
146
- - ✅ `sessionId` (string) - Unique session identifier
147
- - ✅ `audience` (string) - Target service URL
148
- - ✅ `nonce` (string) - Handshake nonce
149
- - ✅ `timestamp` (integer) - Session creation time
150
- - ✅ `createdAt` (integer) - Unix timestamp
151
- - ✅ `lastActivity` (integer) - Last activity timestamp
152
- - ✅ `ttlMinutes` (integer) - Time-to-live in minutes
153
- - ✅ `agentDid` (string) - Agent's DID
154
-
155
- **Implementation:** `src/session/manager.ts`
156
-
157
- **Example:**
158
- ```typescript
159
- const session: SessionContext = {
160
- sessionId: 'session-' + crypto.randomUUID(),
161
- audience: 'https://api.example.com',
162
- nonce: 'nonce-123',
163
- timestamp: Date.now(),
164
- createdAt: Date.now(),
165
- lastActivity: Date.now(),
166
- ttlMinutes: 30,
167
- agentDid: 'did:key:z6Mkr...',
168
- };
169
- ```
170
-
171
- ### 5. Detached Proof
172
-
173
- **Schema URL:** https://schemas.kya-os.ai/detached-proof.schema.json
174
-
175
- **Compliance:** 100% ✅
176
-
177
- **Required Fields:**
178
- - ✅ `type` (string) - "Ed25519Signature2020"
179
- - ✅ `verificationMethod` (string) - DID verification method
180
- - ✅ `proofPurpose` (string) - "assertionMethod"
181
- - ✅ `proofValue` (string) - Multibase-encoded signature
182
- - ✅ `created` (string, ISO 8601) - Proof creation time
183
-
184
- **Implementation:** `src/crypto/proof.ts`
185
-
186
- **Example:**
187
- ```typescript
188
- const proof: DetachedProof = {
189
- type: 'Ed25519Signature2020',
190
- verificationMethod: 'did:key:z6Mkr...#z6Mkr...',
191
- proofPurpose: 'assertionMethod',
192
- proofValue: 'z58DAdFfa9SkqZ...',
193
- created: new Date().toISOString(),
194
- };
195
- ```
196
-
197
- ### 6. Proof Metadata
198
-
199
- **Schema URL:** https://schemas.kya-os.ai/proof-meta.schema.json
200
-
201
- **Compliance:** 100% ✅
202
-
203
- **Required Fields:**
204
- - ✅ `did` (string) - Agent's DID
205
- - ✅ `kid` (string) - Key ID
206
- - ✅ `ts` (integer) - Unix timestamp
207
- - ✅ `nonce` (string) - Request nonce
208
- - ✅ `audience` (string) - Target audience
209
- - ✅ `sessionId` (string) - Session identifier
210
- - ✅ `requestHash` (string) - SHA-256 hash of request
211
- - ✅ `responseHash` (string) - SHA-256 hash of response
212
-
213
- **Optional Fields:**
214
- - ✅ `scopeId` (string) - Scope identifier
215
- - ✅ `delegationRef` (string) - Delegation credential reference
216
-
217
- **Implementation:** `src/crypto/proof-meta.ts`
218
-
219
- **Example:**
220
- ```typescript
221
- const proofMeta: ProofMeta = {
222
- did: 'did:key:z6Mkr...',
223
- kid: 'did:key:z6Mkr...#z6Mkr...',
224
- ts: Date.now(),
225
- nonce: 'nonce-123',
226
- audience: 'https://api.example.com',
227
- sessionId: 'session-123',
228
- requestHash: 'sha256:abc123...',
229
- responseHash: 'sha256:def456...',
230
- scopeId: 'scope-123',
231
- delegationRef: 'urn:uuid:delegation-123',
232
- };
233
- ```
234
-
235
- ### 7. Audit Record
236
-
237
- **Schema URL:** https://schemas.kya-os.ai/audit-record.schema.json
238
-
239
- **Compliance:** 100% ✅
240
-
241
- **Required Fields:**
242
- - ✅ `version` (string) - "audit.v1"
243
- - ✅ `ts` (integer) - Unix timestamp
244
- - ✅ `session` (string) - Session ID
245
- - ✅ `audience` (string) - Target audience
246
- - ✅ `did` (string) - Agent's DID
247
- - ✅ `kid` (string) - Key ID
248
- - ✅ `reqHash` (string) - Request hash
249
- - ✅ `resHash` (string) - Response hash
250
- - ✅ `verified` (string) - "yes" | "no" | "pending"
251
- - ✅ `scope` (string) - Operation scope
252
-
253
- **Implementation:** `src/audit/logger.ts`
254
-
255
- **Example:**
256
- ```typescript
257
- const auditRecord: AuditRecord = {
258
- version: 'audit.v1',
259
- ts: Date.now(),
260
- session: 'session-123',
261
- audience: 'https://api.example.com',
262
- did: 'did:key:z6Mkr...',
263
- kid: 'did:key:z6Mkr...#z6Mkr...',
264
- reqHash: 'sha256:abc123...',
265
- resHash: 'sha256:def456...',
266
- verified: 'yes',
267
- scope: 'tool-execution',
268
- };
269
- ```
270
-
271
- ### 8. StatusList2021 Credential
272
-
273
- **Schema URL:** https://www.w3.org/TR/vc-status-list-2021/
274
-
275
- **Compliance:** 100% ✅
276
-
277
- **Required Fields:**
278
- - ✅ `@context` - Includes status-list context
279
- - ✅ `type` - Includes "StatusList2021Credential"
280
- - ✅ `credentialSubject.encodedList` - GZIP-compressed bitstring
281
- - ✅ `credentialSubject.statusPurpose` - "revocation" | "suspension"
282
-
283
- **Implementation:** `src/status/statuslist-2021.ts`
284
-
285
- **Example:**
286
- ```typescript
287
- const statusListVC = await statusListManager.createStatusList({
288
- id: 'https://issuer.example.com/status/1',
289
- purpose: 'revocation',
290
- });
291
- ```
292
-
293
- ### 9. Canonical Hashes
294
-
295
- **Schema URL:** https://schemas.kya-os.ai/canonical-hashes.schema.json
296
-
297
- **Compliance:** 100% ✅
298
-
299
- **Supported Algorithms:**
300
- - ✅ SHA-256 (primary)
301
- - ✅ SHA-512 (optional)
302
-
303
- **Format:** `algorithm:hexdigest`
304
-
305
- **Implementation:** `src/crypto/hash.ts`
306
-
307
- **Example:**
308
- ```typescript
309
- const hash = await canonicalHash(data, 'sha256');
310
- // Returns: "sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3"
311
- ```
312
-
313
- ### 10. Nonce Cache Entry
314
-
315
- **Schema URL:** https://schemas.kya-os.ai/nonce-cache-entry.schema.json
316
-
317
- **Compliance:** 100% ✅
318
-
319
- **Required Fields:**
320
- - ✅ `nonce` (string) - Cryptographic nonce
321
- - ✅ `sessionId` (string) - Associated session
322
- - ✅ `expiresAt` (integer) - Expiration timestamp
323
-
324
- **Implementation:** `src/cache/nonce-cache.ts`
325
-
326
- **Providers:**
327
- - ✅ In-Memory Cache
328
- - ✅ Redis Cache
329
- - ✅ DynamoDB Cache
330
-
331
- **Example:**
332
- ```typescript
333
- await nonceCache.store({
334
- nonce: 'nonce-123',
335
- sessionId: 'session-456',
336
- expiresAt: Date.now() + 300000, // 5 minutes
337
- });
338
- ```
339
-
340
- ## Running Compliance Audits
341
-
342
- ### Automated Audit Script
343
-
344
- Run the compliance audit script to verify implementation against canonical schemas:
345
-
346
- ```bash
347
- cd packages/mcp-i-core
348
- pnpm audit:compliance
349
- ```
350
-
351
- **Output:**
352
- ```
353
- ╔════════════════════════════════════════════════════════════════╗
354
- ║ MCP-I Core Schema Compliance Audit Report ║
355
- ╚════════════════════════════════════════════════════════════════╝
356
-
357
- ┌──────────────────────────────────────────────────────────────┐
358
- │ Critical Schemas │
359
- ├──────────────────────────────────────────────────────────────┤
360
- │ delegation-credential 100.0% ✅ (8/8 fields) │
361
- │ delegation-constraints 100.0% ✅ (5/5 fields) │
362
- │ handshake-request 100.0% ✅ (4/4 fields) │
363
- │ session-context 100.0% ✅ (8/8 fields) │
364
- │ detached-proof 100.0% ✅ (5/5 fields) │
365
- │ proof-meta 100.0% ✅ (8/8 fields) │
366
- │ audit-record 100.0% ✅ (10/10 fields) │
367
- │ status-list-2021 100.0% ✅ (4/4 fields) │
368
- ├──────────────────────────────────────────────────────────────┤
369
- │ Supporting Schemas │
370
- ├──────────────────────────────────────────────────────────────┤
371
- │ canonical-hashes 100.0% ✅ (2/2 fields) │
372
- │ nonce-cache-entry 100.0% ✅ (3/3 fields) │
373
- └──────────────────────────────────────────────────────────────┘
374
-
375
- Overall Compliance: 100% (57/57 fields)
376
- Status: PRODUCTION READY ✅
377
- ```
378
-
379
- ### Manual Verification
380
-
381
- Use the `SchemaVerifier` class to validate your own implementations:
382
-
383
- ```typescript
384
- import { createSchemaVerifier } from '@kya-os/mcp-i-core';
385
-
386
- // Create verifier
387
- const verifier = createSchemaVerifier();
388
-
389
- // Register schema
390
- await verifier.registerSchema(
391
- 'my-schema',
392
- 'https://schemas.kya-os.ai/my-schema.schema.json'
393
- );
394
-
395
- // Verify implementation
396
- const myImplementation = {
397
- field1: 'value1',
398
- field2: 42,
399
- };
400
-
401
- const report = await verifier.verifySchema('my-schema', myImplementation);
402
-
403
- if (report.compliant) {
404
- console.log('✅ 100% compliant');
405
- } else {
406
- console.log(`❌ ${report.compliancePercentage}% compliant`);
407
- console.log('Missing fields:', report.missingFields);
408
- console.log('Type mismatches:', report.typeMismatches);
409
- }
410
- ```
411
-
412
- ## SchemaVerifier API
413
-
414
- ### Features
415
-
416
- The `SchemaVerifier` class provides full JSON Schema draft-07 support:
417
-
418
- - **$ref Resolution**: Supports `#/definitions/`, `#/$defs/`, and `#` root references
419
- - **Union Types**: `oneOf`, `anyOf`, `allOf`
420
- - **Type Validation**: Including `integer` vs `number` distinction
421
- - **Nested Objects**: Recursive validation
422
- - **Arrays**: Tuple and array validation
423
- - **Patterns**: Regex pattern matching
424
- - **Enums**: Enumeration validation
425
- - **Formats**: String format validation
426
- - **Required Fields**: Required property checking
427
-
428
- ### Example: Complete Validation
429
-
430
- ```typescript
431
- import { createSchemaVerifier, type SchemaComplianceReport } from '@kya-os/mcp-i-core';
432
-
433
- async function validateDelegation(delegation: any): Promise<void> {
434
- const verifier = createSchemaVerifier();
435
-
436
- // Register delegation schema
437
- await verifier.registerSchema(
438
- 'delegation-credential',
439
- 'https://schemas.kya-os.ai/delegation-credential.schema.json'
440
- );
441
-
442
- // Verify
443
- const report: SchemaComplianceReport = await verifier.verifySchema(
444
- 'delegation-credential',
445
- delegation
446
- );
447
-
448
- // Check results
449
- if (!report.compliant) {
450
- console.error('Delegation validation failed!');
451
-
452
- // Show missing required fields
453
- if (report.missingFields.length > 0) {
454
- console.error('Missing required fields:', report.missingFields);
455
- }
456
-
457
- // Show type mismatches
458
- for (const [field, result] of Object.entries(report.fieldCompliance)) {
459
- if (result.typeMatch === 'mismatch') {
460
- console.error(`Field '${field}' type mismatch:`);
461
- console.error(` Expected: ${result.expectedType}`);
462
- console.error(` Actual: ${result.actualType}`);
463
- }
464
- }
465
-
466
- // Show extra fields
467
- if (report.extraFields.length > 0) {
468
- console.warn('Extra fields (not in schema):', report.extraFields);
469
- }
470
-
471
- throw new Error('Delegation does not conform to schema');
472
- }
473
-
474
- console.log('✅ Delegation is 100% compliant');
475
- }
476
- ```
477
-
478
- ### Example: Field-Level Analysis
479
-
480
- ```typescript
481
- const report = await verifier.verifySchema('proof-meta', proofMeta);
482
-
483
- // Analyze each field
484
- for (const [field, result] of Object.entries(report.fieldCompliance)) {
485
- console.log(`Field: ${field}`);
486
- console.log(` Present: ${result.present}`);
487
- console.log(` Expected Type: ${result.expectedType}`);
488
- console.log(` Actual Type: ${result.actualType}`);
489
- console.log(` Type Match: ${result.typeMatch}`);
490
- console.log(` Value Match: ${result.valueMatch}`);
491
-
492
- if (result.typeMatch === 'mismatch') {
493
- console.error(` ❌ Type mismatch!`);
494
- } else {
495
- console.log(` ✅ Compliant`);
496
- }
497
- }
498
- ```
499
-
500
- ## Continuous Compliance
501
-
502
- ### CI/CD Integration
503
-
504
- Add compliance checks to your CI/CD pipeline:
505
-
506
- ```yaml
507
- # .github/workflows/compliance.yml
508
- name: Schema Compliance
509
-
510
- on: [push, pull_request]
511
-
512
- jobs:
513
- compliance:
514
- runs-on: ubuntu-latest
515
- steps:
516
- - uses: actions/checkout@v3
517
-
518
- - name: Setup Node
519
- uses: actions/setup-node@v3
520
- with:
521
- node-version: '20'
522
-
523
- - name: Install dependencies
524
- run: pnpm install
525
-
526
- - name: Run compliance audit
527
- run: pnpm audit:compliance
528
-
529
- - name: Fail if not 100% compliant
530
- run: |
531
- if ! pnpm audit:compliance | grep -q "100%"; then
532
- echo "❌ Schema compliance is not 100%"
533
- exit 1
534
- fi
535
- ```
536
-
537
- ### Pre-commit Hook
538
-
539
- Add a Git pre-commit hook to verify compliance before commits:
540
-
541
- ```bash
542
- #!/bin/bash
543
- # .git/hooks/pre-commit
544
-
545
- echo "Running schema compliance audit..."
546
- cd packages/mcp-i-core
547
- pnpm audit:compliance
548
-
549
- if [ $? -ne 0 ]; then
550
- echo "❌ Schema compliance check failed!"
551
- echo "Please fix compliance issues before committing."
552
- exit 1
553
- fi
554
-
555
- echo "✅ Schema compliance check passed!"
556
- ```
557
-
558
- ## Schema Evolution
559
-
560
- ### Versioning Strategy
561
-
562
- When canonical schemas are updated:
563
-
564
- 1. **Backward Compatible Changes** (additions only):
565
- - Update implementation to support new fields
566
- - Mark new fields as optional initially
567
- - Run compliance audit to verify
568
-
569
- 2. **Breaking Changes** (field removals or type changes):
570
- - Create new schema version (e.g., `delegation-credential-v2`)
571
- - Support both versions during transition period
572
- - Deprecate old version with migration guide
573
-
574
- ### Migration Example
575
-
576
- ```typescript
577
- // Support both v1 and v2 during transition
578
- async function issueDelegation(constraints: any, version: 'v1' | 'v2' = 'v2') {
579
- if (version === 'v1') {
580
- // Use legacy schema
581
- await verifier.verifySchema('delegation-credential-v1', constraints);
582
- } else {
583
- // Use current schema
584
- await verifier.verifySchema('delegation-credential', constraints);
585
- }
586
-
587
- // Issue credential with appropriate schema
588
- return await issuer.issue(constraints, { schemaVersion: version });
589
- }
590
- ```
591
-
592
- ## Best Practices
593
-
594
- ### 1. Validate Early
595
-
596
- Validate data structures as early as possible:
597
-
598
- ```typescript
599
- // Good: Validate at API boundary
600
- app.post('/delegate', async (req, res) => {
601
- const verifier = createSchemaVerifier();
602
- const report = await verifier.verifySchema('delegation-request', req.body);
603
-
604
- if (!report.compliant) {
605
- return res.status(400).json({
606
- error: 'Invalid delegation request',
607
- details: report,
608
- });
609
- }
610
-
611
- // Proceed with validated data
612
- const delegation = await issueDelegation(req.body);
613
- res.json(delegation);
614
- });
615
- ```
616
-
617
- ### 2. Cache Schema Definitions
618
-
619
- Avoid fetching schemas repeatedly:
620
-
621
- ```typescript
622
- // Good: Reuse verifier instance
623
- const globalVerifier = createSchemaVerifier();
624
-
625
- // Register schemas once at startup
626
- await globalVerifier.registerSchema(
627
- 'delegation-credential',
628
- 'https://schemas.kya-os.ai/delegation-credential.schema.json'
629
- );
630
-
631
- // Reuse throughout application
632
- export { globalVerifier };
633
- ```
634
-
635
- ### 3. Include Schemas in Error Messages
636
-
637
- Help developers fix validation errors:
638
-
639
- ```typescript
640
- if (!report.compliant) {
641
- throw new Error(
642
- `Schema validation failed for '${schemaName}':\n` +
643
- ` Missing fields: ${report.missingFields.join(', ')}\n` +
644
- ` Type mismatches: ${JSON.stringify(report.typeMismatches, null, 2)}\n` +
645
- ` Compliance: ${report.compliancePercentage}%\n` +
646
- ` Schema URL: ${report.schemaUrl}`
647
- );
648
- }
649
- ```
650
-
651
- ### 4. Monitor Compliance in Production
652
-
653
- Track compliance metrics:
654
-
655
- ```typescript
656
- import { createSchemaVerifier } from '@kya-os/mcp-i-core';
657
-
658
- async function trackCompliance(data: any, schemaName: string) {
659
- const verifier = createSchemaVerifier();
660
- const report = await verifier.verifySchema(schemaName, data);
661
-
662
- // Send metrics to monitoring system
663
- metrics.gauge('schema_compliance', report.compliancePercentage, {
664
- schema: schemaName,
665
- compliant: report.compliant ? 'true' : 'false',
666
- });
667
-
668
- if (!report.compliant) {
669
- logger.warn('Schema compliance issue', {
670
- schema: schemaName,
671
- compliance: report.compliancePercentage,
672
- missingFields: report.missingFields,
673
- });
674
- }
675
-
676
- return report;
677
- }
678
- ```
679
-
680
- ## References
681
-
682
- - [JSON Schema draft-07 Specification](https://json-schema.org/draft-07/json-schema-release-notes.html)
683
- - [schemas.kya-os.ai](https://schemas.kya-os.ai) - Canonical schema repository
684
- - [W3C Verifiable Credentials Data Model](https://www.w3.org/TR/vc-data-model/)
685
- - [W3C StatusList2021](https://www.w3.org/TR/vc-status-list-2021/)
686
-
687
- ## Next Steps
688
-
689
- 1. Review the [W3C VC Delegation Guide](./W3C_VC_DELEGATION_GUIDE.md) for delegation workflows
690
- 2. Read the [StatusList2021 Guide](./STATUSLIST2021_GUIDE.md) for revocation patterns
691
- 3. Explore the [API Reference](./API_REFERENCE.md) for detailed API documentation