@kya-os/mcp-i-core 1.3.7-canary.0 → 1.3.7-canary.clientinfo.20251126041014
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/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-test$colon$coverage.log +4239 -0
- package/.turbo/turbo-test.log +2973 -0
- package/COMPLIANCE_IMPROVEMENT_REPORT.md +483 -0
- package/Composer 3.md +615 -0
- package/GPT-5.md +1169 -0
- package/OPUS-plan.md +352 -0
- package/PHASE_3_AND_4.1_SUMMARY.md +585 -0
- package/PHASE_3_SUMMARY.md +317 -0
- package/PHASE_4.1.3_SUMMARY.md +428 -0
- package/PHASE_4.1_COMPLETE.md +525 -0
- package/PHASE_4_USER_DID_IDENTITY_LINKING_PLAN.md +1240 -0
- package/SCHEMA_COMPLIANCE_REPORT.md +275 -0
- package/TEST_PLAN.md +571 -0
- package/coverage/coverage-final.json +57 -0
- package/dist/__tests__/utils/mock-providers.d.ts +1 -2
- package/dist/__tests__/utils/mock-providers.d.ts.map +1 -1
- package/dist/__tests__/utils/mock-providers.js.map +1 -1
- package/dist/cache/oauth-config-cache.d.ts +69 -0
- package/dist/cache/oauth-config-cache.d.ts.map +1 -0
- package/dist/cache/oauth-config-cache.js +76 -0
- package/dist/cache/oauth-config-cache.js.map +1 -0
- package/dist/identity/idp-token-resolver.d.ts +53 -0
- package/dist/identity/idp-token-resolver.d.ts.map +1 -0
- package/dist/identity/idp-token-resolver.js +108 -0
- package/dist/identity/idp-token-resolver.js.map +1 -0
- package/dist/identity/idp-token-storage.interface.d.ts +42 -0
- package/dist/identity/idp-token-storage.interface.d.ts.map +1 -0
- package/dist/identity/idp-token-storage.interface.js +12 -0
- package/dist/identity/idp-token-storage.interface.js.map +1 -0
- package/dist/identity/user-did-manager.d.ts +39 -1
- package/dist/identity/user-did-manager.d.ts.map +1 -1
- package/dist/identity/user-did-manager.js +69 -3
- package/dist/identity/user-did-manager.js.map +1 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/audit-logger.d.ts +37 -0
- package/dist/runtime/audit-logger.d.ts.map +1 -0
- package/dist/runtime/audit-logger.js +9 -0
- package/dist/runtime/audit-logger.js.map +1 -0
- package/dist/runtime/base.d.ts +19 -2
- package/dist/runtime/base.d.ts.map +1 -1
- package/dist/runtime/base.js +227 -11
- package/dist/runtime/base.js.map +1 -1
- package/dist/services/access-control.service.d.ts.map +1 -1
- package/dist/services/access-control.service.js +199 -15
- package/dist/services/access-control.service.js.map +1 -1
- package/dist/services/authorization/authorization-registry.d.ts +29 -0
- package/dist/services/authorization/authorization-registry.d.ts.map +1 -0
- package/dist/services/authorization/authorization-registry.js +57 -0
- package/dist/services/authorization/authorization-registry.js.map +1 -0
- package/dist/services/authorization/types.d.ts +53 -0
- package/dist/services/authorization/types.d.ts.map +1 -0
- package/dist/services/authorization/types.js +10 -0
- package/dist/services/authorization/types.js.map +1 -0
- package/dist/services/batch-delegation.service.d.ts +53 -0
- package/dist/services/batch-delegation.service.d.ts.map +1 -0
- package/dist/services/batch-delegation.service.js +95 -0
- package/dist/services/batch-delegation.service.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +4 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/oauth-config.service.d.ts +53 -0
- package/dist/services/oauth-config.service.d.ts.map +1 -0
- package/dist/services/oauth-config.service.js +141 -0
- package/dist/services/oauth-config.service.js.map +1 -0
- package/dist/services/oauth-provider-registry.d.ts +88 -0
- package/dist/services/oauth-provider-registry.d.ts.map +1 -0
- package/dist/services/oauth-provider-registry.js +128 -0
- package/dist/services/oauth-provider-registry.js.map +1 -0
- package/dist/services/oauth-service.d.ts +77 -0
- package/dist/services/oauth-service.d.ts.map +1 -0
- package/dist/services/oauth-service.js +373 -0
- package/dist/services/oauth-service.js.map +1 -0
- package/dist/services/oauth-token-retrieval.service.d.ts +49 -0
- package/dist/services/oauth-token-retrieval.service.d.ts.map +1 -0
- package/dist/services/oauth-token-retrieval.service.js +150 -0
- package/dist/services/oauth-token-retrieval.service.js.map +1 -0
- package/dist/services/provider-resolver.d.ts +48 -0
- package/dist/services/provider-resolver.d.ts.map +1 -0
- package/dist/services/provider-resolver.js +121 -0
- package/dist/services/provider-resolver.js.map +1 -0
- package/dist/services/provider-validator.d.ts +55 -0
- package/dist/services/provider-validator.d.ts.map +1 -0
- package/dist/services/provider-validator.js +135 -0
- package/dist/services/provider-validator.js.map +1 -0
- package/dist/services/session-registration.service.d.ts +80 -0
- package/dist/services/session-registration.service.d.ts.map +1 -0
- package/dist/services/session-registration.service.js +228 -0
- package/dist/services/session-registration.service.js.map +1 -0
- package/dist/services/tool-context-builder.d.ts +57 -0
- package/dist/services/tool-context-builder.d.ts.map +1 -0
- package/dist/services/tool-context-builder.js +125 -0
- package/dist/services/tool-context-builder.js.map +1 -0
- package/dist/services/tool-protection.service.d.ts +27 -0
- package/dist/services/tool-protection.service.d.ts.map +1 -1
- package/dist/services/tool-protection.service.js +194 -4
- package/dist/services/tool-protection.service.js.map +1 -1
- package/dist/types/oauth-required-error.d.ts +40 -0
- package/dist/types/oauth-required-error.d.ts.map +1 -0
- package/dist/types/oauth-required-error.js +40 -0
- package/dist/types/oauth-required-error.js.map +1 -0
- package/dist/utils/did-helpers.d.ts +33 -0
- package/dist/utils/did-helpers.d.ts.map +1 -1
- package/dist/utils/did-helpers.js +40 -0
- package/dist/utils/did-helpers.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/docs/API_REFERENCE.md +1362 -0
- package/docs/COMPLIANCE_MATRIX.md +691 -0
- package/docs/STATUSLIST2021_GUIDE.md +696 -0
- package/docs/W3C_VC_DELEGATION_GUIDE.md +710 -0
- package/package.json +23 -54
- package/scripts/audit-compliance.ts +724 -0
- package/src/__tests__/cache/tool-protection-cache.test.ts +640 -0
- package/src/__tests__/config/provider-runtime-config.test.ts +309 -0
- package/src/__tests__/delegation-e2e.test.ts +690 -0
- package/src/__tests__/identity/user-did-manager.test.ts +213 -0
- package/src/__tests__/index.test.ts +56 -0
- package/src/__tests__/integration/full-flow.test.ts +776 -0
- package/src/__tests__/integration.test.ts +281 -0
- package/src/__tests__/providers/base.test.ts +173 -0
- package/src/__tests__/providers/memory.test.ts +319 -0
- package/src/__tests__/regression/phase2-regression.test.ts +429 -0
- package/src/__tests__/runtime/audit-logger.test.ts +154 -0
- package/src/__tests__/runtime/base-extensions.test.ts +593 -0
- package/src/__tests__/runtime/base.test.ts +869 -0
- package/src/__tests__/runtime/delegation-flow.test.ts +164 -0
- package/src/__tests__/runtime/proof-client-did.test.ts +375 -0
- package/src/__tests__/runtime/route-interception.test.ts +686 -0
- package/src/__tests__/runtime/tool-protection-enforcement.test.ts +908 -0
- package/src/__tests__/services/agentshield-integration.test.ts +784 -0
- package/src/__tests__/services/cache-busting.test.ts +125 -0
- package/src/__tests__/services/oauth-service-pkce.test.ts +556 -0
- package/src/__tests__/services/provider-resolver-edge-cases.test.ts +591 -0
- package/src/__tests__/services/tool-protection-oauth-provider.test.ts +480 -0
- package/src/__tests__/services/tool-protection.service.test.ts +1366 -0
- package/src/__tests__/utils/mock-providers.ts +340 -0
- package/src/cache/oauth-config-cache.d.ts +69 -0
- package/src/cache/oauth-config-cache.d.ts.map +1 -0
- package/src/cache/oauth-config-cache.js.map +1 -0
- package/src/cache/oauth-config-cache.ts +123 -0
- package/src/cache/tool-protection-cache.ts +171 -0
- package/src/compliance/EXAMPLE.md +412 -0
- package/src/compliance/__tests__/schema-verifier.test.ts +797 -0
- package/src/compliance/index.ts +8 -0
- package/src/compliance/schema-registry.ts +460 -0
- package/src/compliance/schema-verifier.ts +708 -0
- package/src/config/__tests__/remote-config.spec.ts +268 -0
- package/src/config/remote-config.ts +174 -0
- package/src/config.ts +309 -0
- package/src/delegation/__tests__/audience-validator.test.ts +112 -0
- package/src/delegation/__tests__/bitstring.test.ts +346 -0
- package/src/delegation/__tests__/cascading-revocation.test.ts +628 -0
- package/src/delegation/__tests__/delegation-graph.test.ts +584 -0
- package/src/delegation/__tests__/utils.test.ts +152 -0
- package/src/delegation/__tests__/vc-issuer.test.ts +442 -0
- package/src/delegation/__tests__/vc-verifier.test.ts +922 -0
- package/src/delegation/audience-validator.ts +52 -0
- package/src/delegation/bitstring.ts +278 -0
- package/src/delegation/cascading-revocation.ts +370 -0
- package/src/delegation/delegation-graph.ts +299 -0
- package/src/delegation/index.ts +14 -0
- package/src/delegation/statuslist-manager.ts +353 -0
- package/src/delegation/storage/__tests__/memory-graph-storage.test.ts +366 -0
- package/src/delegation/storage/__tests__/memory-statuslist-storage.test.ts +228 -0
- package/src/delegation/storage/index.ts +9 -0
- package/src/delegation/storage/memory-graph-storage.ts +178 -0
- package/src/delegation/storage/memory-statuslist-storage.ts +77 -0
- package/src/delegation/utils.ts +42 -0
- package/src/delegation/vc-issuer.ts +232 -0
- package/src/delegation/vc-verifier.ts +568 -0
- package/src/identity/idp-token-resolver.ts +147 -0
- package/src/identity/idp-token-storage.interface.ts +59 -0
- package/src/identity/user-did-manager.ts +370 -0
- package/src/index.ts +271 -0
- package/src/providers/base.d.ts +91 -0
- package/src/providers/base.d.ts.map +1 -0
- package/src/providers/base.js.map +1 -0
- package/src/providers/base.ts +96 -0
- package/src/providers/memory.ts +142 -0
- package/src/runtime/audit-logger.ts +39 -0
- package/src/runtime/base.ts +1329 -0
- package/src/services/__tests__/access-control.integration.test.ts +443 -0
- package/src/services/__tests__/access-control.proof-response-validation.test.ts +578 -0
- package/src/services/__tests__/access-control.service.test.ts +970 -0
- package/src/services/__tests__/batch-delegation.service.test.ts +351 -0
- package/src/services/__tests__/crypto.service.test.ts +531 -0
- package/src/services/__tests__/oauth-provider-registry.test.ts +142 -0
- package/src/services/__tests__/proof-verifier.integration.test.ts +485 -0
- package/src/services/__tests__/proof-verifier.test.ts +489 -0
- package/src/services/__tests__/provider-resolution.integration.test.ts +202 -0
- package/src/services/__tests__/provider-resolver.test.ts +213 -0
- package/src/services/__tests__/storage.service.test.ts +358 -0
- package/src/services/access-control.service.ts +990 -0
- package/src/services/authorization/authorization-registry.ts +66 -0
- package/src/services/authorization/types.ts +71 -0
- package/src/services/batch-delegation.service.ts +137 -0
- package/src/services/crypto.service.ts +302 -0
- package/src/services/errors.ts +76 -0
- package/src/services/index.ts +18 -0
- package/src/services/oauth-config.service.d.ts +53 -0
- package/src/services/oauth-config.service.d.ts.map +1 -0
- package/src/services/oauth-config.service.js.map +1 -0
- package/src/services/oauth-config.service.ts +192 -0
- package/src/services/oauth-provider-registry.d.ts +57 -0
- package/src/services/oauth-provider-registry.d.ts.map +1 -0
- package/src/services/oauth-provider-registry.js.map +1 -0
- package/src/services/oauth-provider-registry.ts +141 -0
- package/src/services/oauth-service.ts +544 -0
- package/src/services/oauth-token-retrieval.service.ts +245 -0
- package/src/services/proof-verifier.ts +478 -0
- package/src/services/provider-resolver.d.ts +48 -0
- package/src/services/provider-resolver.d.ts.map +1 -0
- package/src/services/provider-resolver.js.map +1 -0
- package/src/services/provider-resolver.ts +146 -0
- package/src/services/provider-validator.ts +170 -0
- package/src/services/session-registration.service.ts +317 -0
- package/src/services/storage.service.ts +566 -0
- package/src/services/tool-context-builder.ts +172 -0
- package/src/services/tool-protection.service.ts +982 -0
- package/src/types/oauth-required-error.ts +63 -0
- package/src/types/tool-protection.ts +155 -0
- package/src/utils/__tests__/did-helpers.test.ts +101 -0
- package/src/utils/base64.ts +148 -0
- package/src/utils/cors.ts +83 -0
- package/src/utils/did-helpers.ts +150 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/storage-keys.ts +278 -0
- package/tsconfig.json +21 -0
- package/vitest.config.ts +56 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
# Schema Compliance Verification - Usage Examples
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Automated verification tool to ensure 100% compliance with canonical schemas from `schemas.kya-os.ai`.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import {
|
|
13
|
+
createSchemaVerifier,
|
|
14
|
+
getAllSchemas,
|
|
15
|
+
getCriticalSchemas,
|
|
16
|
+
getSchemasByCategory,
|
|
17
|
+
} from '@kya-os/mcp-i-core';
|
|
18
|
+
|
|
19
|
+
// Create verifier
|
|
20
|
+
const verifier = createSchemaVerifier({
|
|
21
|
+
schemasBaseUrl: 'https://schemas.kya-os.ai',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Get all schemas
|
|
25
|
+
const allSchemas = getAllSchemas();
|
|
26
|
+
console.log(`Total schemas: ${allSchemas.length}`); // 41
|
|
27
|
+
|
|
28
|
+
// Get critical schemas (must be 100% compliant)
|
|
29
|
+
const criticalSchemas = getCriticalSchemas();
|
|
30
|
+
console.log(`Critical schemas: ${criticalSchemas.length}`); // 7
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Verify Single Schema
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { createSchemaVerifier, getSchemaById } from '@kya-os/mcp-i-core';
|
|
39
|
+
import { DelegationCredential } from '@kya-os/contracts';
|
|
40
|
+
|
|
41
|
+
// Get the delegation credential schema
|
|
42
|
+
const schema = getSchemaById('delegation-credential')!;
|
|
43
|
+
|
|
44
|
+
// Create a sample delegation credential
|
|
45
|
+
const delegationVC: DelegationCredential = {
|
|
46
|
+
'@context': [
|
|
47
|
+
'https://www.w3.org/2018/credentials/v1',
|
|
48
|
+
'https://mcp-i.org/contexts/delegation/v1',
|
|
49
|
+
],
|
|
50
|
+
id: 'urn:uuid:123',
|
|
51
|
+
type: ['VerifiableCredential', 'DelegationCredential'],
|
|
52
|
+
issuer: 'did:key:z6Mkf...',
|
|
53
|
+
issuanceDate: '2025-10-17T00:00:00Z',
|
|
54
|
+
credentialSubject: {
|
|
55
|
+
id: 'did:key:z6Mkf...',
|
|
56
|
+
delegation: {
|
|
57
|
+
id: 'delegation-123',
|
|
58
|
+
issuerDid: 'did:key:z6Mkf...',
|
|
59
|
+
subjectDid: 'did:key:z6Mkf...',
|
|
60
|
+
// ... rest of delegation
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
proof: {
|
|
64
|
+
type: 'Ed25519Signature2020',
|
|
65
|
+
created: '2025-10-17T00:00:00Z',
|
|
66
|
+
verificationMethod: 'did:key:z6Mkf...#keys-1',
|
|
67
|
+
proofPurpose: 'assertionMethod',
|
|
68
|
+
proofValue: 'z58DAdF...',
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Verify compliance
|
|
73
|
+
const verifier = createSchemaVerifier();
|
|
74
|
+
const report = await verifier.verifySchema(schema, delegationVC);
|
|
75
|
+
|
|
76
|
+
// Check results
|
|
77
|
+
console.log(verifier.generateReport(report));
|
|
78
|
+
|
|
79
|
+
if (report.compliant) {
|
|
80
|
+
console.log('✅ 100% Compliant!');
|
|
81
|
+
} else {
|
|
82
|
+
console.log('❌ Issues found:');
|
|
83
|
+
report.issues.forEach((issue) => console.log(` - ${issue}`));
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Output:**
|
|
88
|
+
```
|
|
89
|
+
================================================================================
|
|
90
|
+
SCHEMA COMPLIANCE REPORT: delegation-credential
|
|
91
|
+
================================================================================
|
|
92
|
+
|
|
93
|
+
Schema: DelegationCredential v1.0.0
|
|
94
|
+
URL: https://schemas.kya-os.ai/xmcp-i/delegation/delegation-credential.v1.0.0.json
|
|
95
|
+
Status: ✅ COMPLIANT
|
|
96
|
+
Compliance: 100.0%
|
|
97
|
+
|
|
98
|
+
📊 FIELD DETAILS:
|
|
99
|
+
|
|
100
|
+
✅ Pass: 8
|
|
101
|
+
❌ Fail: 0
|
|
102
|
+
⚠️ Warn: 2
|
|
103
|
+
📝 Total: 10
|
|
104
|
+
|
|
105
|
+
================================================================================
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Verify All Schemas
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import {
|
|
114
|
+
createSchemaVerifier,
|
|
115
|
+
getAllSchemas,
|
|
116
|
+
} from '@kya-os/mcp-i-core';
|
|
117
|
+
|
|
118
|
+
// Import all your implementations
|
|
119
|
+
import * as implementations from '@kya-os/contracts';
|
|
120
|
+
|
|
121
|
+
// Create a map of schema ID to implementation
|
|
122
|
+
const implementationMap = new Map<string, any>([
|
|
123
|
+
['verifiable-credential', implementations.VerifiableCredential],
|
|
124
|
+
['delegation-credential', implementations.DelegationCredential],
|
|
125
|
+
['detached-proof', implementations.DetachedProof],
|
|
126
|
+
// ... add all implementations
|
|
127
|
+
]);
|
|
128
|
+
|
|
129
|
+
// Verify all schemas
|
|
130
|
+
const verifier = createSchemaVerifier();
|
|
131
|
+
const schemas = getAllSchemas();
|
|
132
|
+
const fullReport = await verifier.verifyAll(schemas, implementationMap);
|
|
133
|
+
|
|
134
|
+
// Print summary
|
|
135
|
+
console.log(verifier.generateFullReport(fullReport));
|
|
136
|
+
|
|
137
|
+
console.log(`\nOverall Compliance: ${fullReport.overallCompliance.toFixed(1)}%`);
|
|
138
|
+
console.log(`Compliant: ${fullReport.compliantSchemas}/${fullReport.totalSchemas}`);
|
|
139
|
+
|
|
140
|
+
if (fullReport.criticalIssues.length > 0) {
|
|
141
|
+
console.log('\n🚨 Critical Issues:');
|
|
142
|
+
fullReport.criticalIssues.forEach((issue) => console.log(` - ${issue}`));
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Output:**
|
|
147
|
+
```
|
|
148
|
+
================================================================================
|
|
149
|
+
FULL SCHEMA COMPLIANCE REPORT
|
|
150
|
+
================================================================================
|
|
151
|
+
|
|
152
|
+
Total Schemas: 41
|
|
153
|
+
Compliant: 38
|
|
154
|
+
Non-Compliant: 3
|
|
155
|
+
Overall Compliance: 92.7%
|
|
156
|
+
|
|
157
|
+
🚨 CRITICAL ISSUES (3):
|
|
158
|
+
1. mcp-tool: Missing implementation
|
|
159
|
+
2. mcp-resource: Missing implementation
|
|
160
|
+
3. mcp-prompt: Type mismatch in 'arguments' field
|
|
161
|
+
|
|
162
|
+
📊 SCHEMA BREAKDOWN:
|
|
163
|
+
|
|
164
|
+
✅ verifiable-credential: 100.0%
|
|
165
|
+
✅ delegation-credential: 100.0%
|
|
166
|
+
✅ detached-proof: 100.0%
|
|
167
|
+
✅ statuslist2021-credential: 100.0%
|
|
168
|
+
❌ mcp-tool: 0.0%
|
|
169
|
+
❌ mcp-resource: 0.0%
|
|
170
|
+
⚠️ mcp-prompt: 85.0%
|
|
171
|
+
...
|
|
172
|
+
|
|
173
|
+
================================================================================
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Verify by Category
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import {
|
|
182
|
+
createSchemaVerifier,
|
|
183
|
+
getSchemasByCategory,
|
|
184
|
+
} from '@kya-os/mcp-i-core';
|
|
185
|
+
|
|
186
|
+
// Get only W3C VC schemas
|
|
187
|
+
const w3cSchemas = getSchemasByCategory('w3c');
|
|
188
|
+
console.log(`W3C schemas: ${w3cSchemas.length}`); // 5
|
|
189
|
+
|
|
190
|
+
// Get only delegation schemas
|
|
191
|
+
const delegationSchemas = getSchemasByCategory('delegation');
|
|
192
|
+
console.log(`Delegation schemas: ${delegationSchemas.length}`); // 6
|
|
193
|
+
|
|
194
|
+
// Verify just delegation schemas
|
|
195
|
+
const verifier = createSchemaVerifier();
|
|
196
|
+
const delegationImplementations = new Map<string, any>([
|
|
197
|
+
['delegation-credential', myDelegationCredential],
|
|
198
|
+
['delegation-record', myDelegationRecord],
|
|
199
|
+
// ... add delegation implementations
|
|
200
|
+
]);
|
|
201
|
+
|
|
202
|
+
const report = await verifier.verifyAll(
|
|
203
|
+
delegationSchemas,
|
|
204
|
+
delegationImplementations
|
|
205
|
+
);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Get Statistics
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
import { getSchemaStats } from '@kya-os/mcp-i-core';
|
|
214
|
+
|
|
215
|
+
const stats = getSchemaStats();
|
|
216
|
+
|
|
217
|
+
console.log(`Total schemas: ${stats.total}`); // 41
|
|
218
|
+
|
|
219
|
+
console.log('\nBy Category:');
|
|
220
|
+
Object.entries(stats.byCategory).forEach(([category, count]) => {
|
|
221
|
+
console.log(` ${category}: ${count}`);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
console.log('\nBy Version:');
|
|
225
|
+
Object.entries(stats.byVersion).forEach(([version, count]) => {
|
|
226
|
+
console.log(` v${version}: ${count}`);
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Output:**
|
|
231
|
+
```
|
|
232
|
+
Total schemas: 41
|
|
233
|
+
|
|
234
|
+
By Category:
|
|
235
|
+
w3c: 5
|
|
236
|
+
xmcp-i: 28
|
|
237
|
+
did: 2
|
|
238
|
+
mcp: 3
|
|
239
|
+
tlkrc: 2
|
|
240
|
+
runtime: 1
|
|
241
|
+
|
|
242
|
+
By Version:
|
|
243
|
+
v1.0.0: 38
|
|
244
|
+
v1.1.0: 3
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Integration with Tests
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
import { describe, test, expect } from 'vitest';
|
|
253
|
+
import {
|
|
254
|
+
createSchemaVerifier,
|
|
255
|
+
getCriticalSchemas,
|
|
256
|
+
} from '@kya-os/mcp-i-core';
|
|
257
|
+
|
|
258
|
+
describe('Schema Compliance', () => {
|
|
259
|
+
test('all critical schemas should be 100% compliant', async () => {
|
|
260
|
+
const verifier = createSchemaVerifier();
|
|
261
|
+
const criticalSchemas = getCriticalSchemas();
|
|
262
|
+
|
|
263
|
+
for (const schema of criticalSchemas) {
|
|
264
|
+
const implementation = getImplementation(schema.id);
|
|
265
|
+
const report = await verifier.verifySchema(schema, implementation);
|
|
266
|
+
|
|
267
|
+
expect(report.compliant).toBe(true);
|
|
268
|
+
expect(report.compliancePercentage).toBe(100);
|
|
269
|
+
expect(report.issues).toHaveLength(0);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
test('all schemas should be at least 95% compliant', async () => {
|
|
274
|
+
const verifier = createSchemaVerifier();
|
|
275
|
+
const schemas = getAllSchemas();
|
|
276
|
+
const implementations = getAllImplementations();
|
|
277
|
+
|
|
278
|
+
const fullReport = await verifier.verifyAll(schemas, implementations);
|
|
279
|
+
|
|
280
|
+
expect(fullReport.overallCompliance).toBeGreaterThanOrEqual(95);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Custom Verification Options
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
import { createSchemaVerifier } from '@kya-os/mcp-i-core';
|
|
291
|
+
|
|
292
|
+
// Use custom schemas endpoint (e.g., for testing)
|
|
293
|
+
const verifier = createSchemaVerifier({
|
|
294
|
+
schemasBaseUrl: 'http://localhost:3000/schemas',
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// Verify with custom options
|
|
298
|
+
const report = await verifier.verifySchema(schema, implementation);
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Available Schema Categories
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
const categories = [
|
|
307
|
+
'w3c', // W3C Verifiable Credentials (5 schemas)
|
|
308
|
+
'delegation', // Delegation system (6 schemas)
|
|
309
|
+
'identity', // Agent identity (3 schemas)
|
|
310
|
+
'protocol', // MCP-I protocol (5 schemas)
|
|
311
|
+
'tool-protection', // Tool protection (2 schemas)
|
|
312
|
+
'audit', // Audit logging (2 schemas)
|
|
313
|
+
'nonce', // Nonce cache (2 schemas)
|
|
314
|
+
'mcp', // MCP tools/resources (3 schemas)
|
|
315
|
+
'registry', // Agent registry (2 schemas)
|
|
316
|
+
'verifier', // Verifier service (3 schemas)
|
|
317
|
+
'config', // Configuration (4 schemas)
|
|
318
|
+
'tlkrc', // Tool-level key rotation (2 schemas)
|
|
319
|
+
];
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Critical Schemas (Must Be 100% Compliant)
|
|
325
|
+
|
|
326
|
+
1. `verifiable-credential` - W3C VC base
|
|
327
|
+
2. `delegation-credential` - Delegation VCs
|
|
328
|
+
3. `detached-proof` - MCP-I proofs
|
|
329
|
+
4. `proof-meta` - Proof metadata
|
|
330
|
+
5. `statuslist2021-credential` - Revocation lists
|
|
331
|
+
6. `handshake-request` - Protocol handshakes
|
|
332
|
+
7. `handshake-response` - Protocol responses
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Field-Level Details
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
const report = await verifier.verifySchema(schema, implementation);
|
|
340
|
+
|
|
341
|
+
// Inspect field-level compliance
|
|
342
|
+
report.fields.forEach((field) => {
|
|
343
|
+
console.log(`Field: ${field.fieldPath}`);
|
|
344
|
+
console.log(` Present: ${field.present}`);
|
|
345
|
+
console.log(` Expected Type: ${field.expectedType}`);
|
|
346
|
+
console.log(` Actual Type: ${field.actualType}`);
|
|
347
|
+
console.log(` Type Matches: ${field.typeMatches}`);
|
|
348
|
+
console.log(` Required: ${field.required}`);
|
|
349
|
+
console.log(` Status: ${field.status}`);
|
|
350
|
+
if (field.reason) {
|
|
351
|
+
console.log(` Reason: ${field.reason}`);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## CI/CD Integration
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
# Run compliance check in CI
|
|
362
|
+
node scripts/check-compliance.js
|
|
363
|
+
|
|
364
|
+
# Exit with error if not 100% compliant
|
|
365
|
+
if [ $? -ne 0 ]; then
|
|
366
|
+
echo "❌ Schema compliance check failed"
|
|
367
|
+
exit 1
|
|
368
|
+
fi
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**scripts/check-compliance.js:**
|
|
372
|
+
```javascript
|
|
373
|
+
const { createSchemaVerifier, getAllSchemas } = require('@kya-os/mcp-i-core');
|
|
374
|
+
|
|
375
|
+
async function main() {
|
|
376
|
+
const verifier = createSchemaVerifier();
|
|
377
|
+
const schemas = getAllSchemas();
|
|
378
|
+
const implementations = getImplementations();
|
|
379
|
+
|
|
380
|
+
const report = await verifier.verifyAll(schemas, implementations);
|
|
381
|
+
|
|
382
|
+
console.log(verifier.generateFullReport(report));
|
|
383
|
+
|
|
384
|
+
if (report.overallCompliance < 100) {
|
|
385
|
+
process.exit(1);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
main();
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## Next Steps
|
|
395
|
+
|
|
396
|
+
1. **Implement Schema Fetching**: Add actual HTTP fetching from schemas.kya-os.ai
|
|
397
|
+
2. **Add JSON Schema Validation**: Use AJV or similar for deep validation
|
|
398
|
+
3. **Create Mock Schemas**: For offline testing
|
|
399
|
+
4. **Add Caching**: Cache fetched schemas locally
|
|
400
|
+
5. **Add Watch Mode**: Auto-verify on file changes
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
**Status: Schema Compliance Tool Ready! 🎉**
|
|
405
|
+
|
|
406
|
+
- ✅ 41 schemas cataloged
|
|
407
|
+
- ✅ Automated verification
|
|
408
|
+
- ✅ Field-level checking
|
|
409
|
+
- ✅ Category filtering
|
|
410
|
+
- ✅ Statistics
|
|
411
|
+
- ✅ Report generation
|
|
412
|
+
- ✅ CI/CD ready
|