@kya-os/mcp-i-runtime 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -0
- package/dist/auth/handshake.d.ts +136 -0
- package/dist/auth/handshake.d.ts.map +1 -0
- package/dist/auth/handshake.js +276 -0
- package/dist/auth/handshake.js.map +1 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +12 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/types.d.ts +52 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +10 -0
- package/dist/auth/types.js.map +1 -0
- 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/cache/tool-protection-cache.d.ts +102 -0
- package/dist/cache/tool-protection-cache.d.ts.map +1 -0
- package/dist/cache/tool-protection-cache.js +131 -0
- package/dist/cache/tool-protection-cache.js.map +1 -0
- package/dist/compliance/index.d.ts +8 -0
- package/dist/compliance/index.d.ts.map +1 -0
- package/dist/compliance/index.js +24 -0
- package/dist/compliance/index.js.map +1 -0
- package/dist/compliance/schema-registry.d.ts +50 -0
- package/dist/compliance/schema-registry.d.ts.map +1 -0
- package/dist/compliance/schema-registry.js +438 -0
- package/dist/compliance/schema-registry.js.map +1 -0
- package/dist/compliance/schema-verifier.d.ts +110 -0
- package/dist/compliance/schema-verifier.d.ts.map +1 -0
- package/dist/compliance/schema-verifier.js +518 -0
- package/dist/compliance/schema-verifier.js.map +1 -0
- package/dist/config/remote-config.d.ts +188 -0
- package/dist/config/remote-config.d.ts.map +1 -0
- package/dist/config/remote-config.js +268 -0
- package/dist/config/remote-config.js.map +1 -0
- package/dist/config.d.ts +182 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +148 -0
- package/dist/config.js.map +1 -0
- package/dist/identity/idp-token-resolver.d.ts +69 -0
- package/dist/identity/idp-token-resolver.d.ts.map +1 -0
- package/dist/identity/idp-token-resolver.js +136 -0
- package/dist/identity/idp-token-resolver.js.map +1 -0
- package/dist/identity/idp-token-storage.interface.d.ts +80 -0
- package/dist/identity/idp-token-storage.interface.d.ts.map +1 -0
- package/dist/identity/idp-token-storage.interface.js +14 -0
- package/dist/identity/idp-token-storage.interface.js.map +1 -0
- package/dist/identity/user-did-manager.d.ts +228 -0
- package/dist/identity/user-did-manager.d.ts.map +1 -0
- package/dist/identity/user-did-manager.js +356 -0
- package/dist/identity/user-did-manager.js.map +1 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +193 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/index.d.ts +5 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +10 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.d.ts +33 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +104 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/proof/generator.d.ts +109 -0
- package/dist/proof/generator.d.ts.map +1 -0
- package/dist/proof/generator.js +236 -0
- package/dist/proof/generator.js.map +1 -0
- package/dist/proof/index.d.ts +5 -0
- package/dist/proof/index.d.ts.map +1 -0
- package/dist/proof/index.js +11 -0
- package/dist/proof/index.js.map +1 -0
- package/dist/providers/base.d.ts +95 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +47 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/memory.d.ts +42 -0
- package/dist/providers/memory.d.ts.map +1 -0
- package/dist/providers/memory.js +121 -0
- package/dist/providers/memory.js.map +1 -0
- 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 +392 -0
- package/dist/runtime/base.d.ts.map +1 -0
- package/dist/runtime/base.js +1527 -0
- package/dist/runtime/base.js.map +1 -0
- package/dist/runtime/dif-core.d.ts +33 -0
- package/dist/runtime/dif-core.d.ts.map +1 -0
- package/dist/runtime/dif-core.js +14 -0
- package/dist/runtime/dif-core.js.map +1 -0
- package/dist/runtime/ext-apps-constants.d.ts +20 -0
- package/dist/runtime/ext-apps-constants.d.ts.map +1 -0
- package/dist/runtime/ext-apps-constants.js +23 -0
- package/dist/runtime/ext-apps-constants.js.map +1 -0
- package/dist/services/access-control.service.d.ts +138 -0
- package/dist/services/access-control.service.d.ts.map +1 -0
- package/dist/services/access-control.service.js +721 -0
- package/dist/services/access-control.service.js.map +1 -0
- 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 +58 -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/crypto.service.d.ts +69 -0
- package/dist/services/crypto.service.d.ts.map +1 -0
- package/dist/services/crypto.service.js +225 -0
- package/dist/services/crypto.service.js.map +1 -0
- package/dist/services/delegation-error-formatter.d.ts +124 -0
- package/dist/services/delegation-error-formatter.d.ts.map +1 -0
- package/dist/services/delegation-error-formatter.js +214 -0
- package/dist/services/delegation-error-formatter.js.map +1 -0
- package/dist/services/errors.d.ts +49 -0
- package/dist/services/errors.d.ts.map +1 -0
- package/dist/services/errors.js +66 -0
- package/dist/services/errors.js.map +1 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +15 -0
- package/dist/services/index.js.map +1 -0
- 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 +122 -0
- package/dist/services/oauth-service.d.ts.map +1 -0
- package/dist/services/oauth-service.js +442 -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/policy.service.d.ts +130 -0
- package/dist/services/policy.service.d.ts.map +1 -0
- package/dist/services/policy.service.js +399 -0
- package/dist/services/policy.service.js.map +1 -0
- package/dist/services/proof-verifier.d.ts +103 -0
- package/dist/services/proof-verifier.d.ts.map +1 -0
- package/dist/services/proof-verifier.js +190 -0
- package/dist/services/proof-verifier.js.map +1 -0
- package/dist/services/provider-resolver.d.ts +89 -0
- package/dist/services/provider-resolver.d.ts.map +1 -0
- package/dist/services/provider-resolver.js +196 -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 +174 -0
- package/dist/services/session-registration.service.js.map +1 -0
- package/dist/services/storage.service.d.ts +116 -0
- package/dist/services/storage.service.d.ts.map +1 -0
- package/dist/services/storage.service.js +411 -0
- package/dist/services/storage.service.js.map +1 -0
- package/dist/services/tool-context-builder.d.ts +74 -0
- package/dist/services/tool-context-builder.d.ts.map +1 -0
- package/dist/services/tool-context-builder.js +215 -0
- package/dist/services/tool-context-builder.js.map +1 -0
- package/dist/services/tool-protection.service.d.ts +209 -0
- package/dist/services/tool-protection.service.d.ts.map +1 -0
- package/dist/services/tool-protection.service.js +752 -0
- package/dist/services/tool-protection.service.js.map +1 -0
- package/dist/session/index.d.ts +5 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +11 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/manager.d.ts +118 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +285 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/types/oauth-required-error.d.ts +46 -0
- package/dist/types/oauth-required-error.d.ts.map +1 -0
- package/dist/types/oauth-required-error.js +42 -0
- package/dist/types/oauth-required-error.js.map +1 -0
- package/dist/types/tool-protection.d.ts +144 -0
- package/dist/types/tool-protection.d.ts.map +1 -0
- package/dist/types/tool-protection.js +48 -0
- package/dist/types/tool-protection.js.map +1 -0
- package/dist/utils/base58.d.ts +31 -0
- package/dist/utils/base58.d.ts.map +1 -0
- package/dist/utils/base58.js +103 -0
- package/dist/utils/base58.js.map +1 -0
- package/dist/utils/base64.d.ts +32 -0
- package/dist/utils/base64.d.ts.map +1 -0
- package/dist/utils/base64.js +172 -0
- package/dist/utils/base64.js.map +1 -0
- package/dist/utils/cors.d.ts +52 -0
- package/dist/utils/cors.d.ts.map +1 -0
- package/dist/utils/cors.js +79 -0
- package/dist/utils/cors.js.map +1 -0
- package/dist/utils/did-helpers.d.ts +168 -0
- package/dist/utils/did-helpers.d.ts.map +1 -0
- package/dist/utils/did-helpers.js +222 -0
- package/dist/utils/did-helpers.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +24 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/storage-keys.d.ts +120 -0
- package/dist/utils/storage-keys.d.ts.map +1 -0
- package/dist/utils/storage-keys.js +217 -0
- package/dist/utils/storage-keys.js.map +1 -0
- package/dist/wire-format.d.ts +62 -0
- package/dist/wire-format.d.ts.map +1 -0
- package/dist/wire-format.js +89 -0
- package/dist/wire-format.js.map +1 -0
- package/package.json +83 -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__/config.test.ts +307 -0
- package/src/__tests__/identity/user-did-manager.test.ts +232 -0
- package/src/__tests__/index.test.ts +56 -0
- package/src/__tests__/integration/full-flow.test.ts +779 -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 +406 -0
- package/src/__tests__/runtime/audit-logger.test.ts +154 -0
- package/src/__tests__/runtime/base-extensions.test.ts +595 -0
- package/src/__tests__/runtime/base.test.ts +1328 -0
- package/src/__tests__/runtime/delegation-flow.test.ts +159 -0
- package/src/__tests__/runtime/process-tool-call-security.test.ts +1024 -0
- package/src/__tests__/runtime/proof-client-did.test.ts +376 -0
- package/src/__tests__/runtime/provider-selection.test.ts +292 -0
- package/src/__tests__/runtime/route-interception.test.ts +670 -0
- package/src/__tests__/runtime/tool-protection-enforcement.test.ts +989 -0
- package/src/__tests__/services/access-control-retry.test.ts +595 -0
- package/src/__tests__/services/agentshield-integration.test.ts +709 -0
- package/src/__tests__/services/cache-busting.test.ts +125 -0
- package/src/__tests__/services/oauth-service-errors.test.ts +704 -0
- package/src/__tests__/services/oauth-service-pkce.test.ts +556 -0
- package/src/__tests__/services/oauth-service-secret-resolution.test.ts +349 -0
- package/src/__tests__/services/provider-resolver-edge-cases.test.ts +591 -0
- package/src/__tests__/services/tool-protection-failsafe.test.ts +683 -0
- package/src/__tests__/services/tool-protection-merged-config.test.ts +664 -0
- package/src/__tests__/services/tool-protection-oauth-provider.test.ts +300 -0
- package/src/__tests__/services/tool-protection.service.test.ts +1201 -0
- package/src/__tests__/utils/mock-providers.ts +340 -0
- package/src/__tests__/wire-format.test.ts +123 -0
- package/src/auth/__tests__/resume-token.test.ts +42 -0
- package/src/auth/handshake.ts +476 -0
- package/src/auth/index.ts +15 -0
- package/src/auth/types.ts +68 -0
- package/src/cache/__tests__/oauth-config-cache.test.ts +215 -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 +184 -0
- package/src/compliance/EXAMPLE.md +412 -0
- package/src/compliance/__tests__/schema-verifier.test.ts +791 -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__/merged-config.spec.ts +445 -0
- package/src/config/__tests__/remote-config-edge-cases.test.ts +424 -0
- package/src/config/__tests__/remote-config-helpers.test.ts +280 -0
- package/src/config/__tests__/remote-config.spec.ts +265 -0
- package/src/config/remote-config.ts +368 -0
- package/src/config.ts +312 -0
- package/src/identity/__tests__/idp-token-resolver.test.ts +340 -0
- package/src/identity/__tests__/user-did-manager.test.ts +487 -0
- package/src/identity/idp-token-resolver.ts +181 -0
- package/src/identity/idp-token-storage.interface.ts +102 -0
- package/src/identity/user-did-manager.ts +592 -0
- package/src/index.ts +331 -0
- package/src/logging/__tests__/logger.test.ts +366 -0
- package/src/logging/index.ts +10 -0
- package/src/logging/logger.ts +112 -0
- package/src/proof/__tests__/crypto-parity.test.ts +202 -0
- package/src/proof/__tests__/proof-generator.test.ts +484 -0
- package/src/proof/generator.ts +347 -0
- package/src/proof/index.ts +12 -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 +100 -0
- package/src/providers/memory.ts +142 -0
- package/src/runtime/__tests__/dif-esm-bridge.test.ts +33 -0
- package/src/runtime/__tests__/ext-apps-consent.test.ts +334 -0
- package/src/runtime/audit-logger.ts +39 -0
- package/src/runtime/base.ts +2100 -0
- package/src/runtime/dif-core.ts +39 -0
- package/src/runtime/ext-apps-constants.ts +20 -0
- package/src/services/__tests__/access-control.integration.test.ts +441 -0
- package/src/services/__tests__/access-control.proof-response-validation.test.ts +578 -0
- package/src/services/__tests__/access-control.service.test.ts +1132 -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__/delegation-error-formatter.test.ts +643 -0
- package/src/services/__tests__/oauth-config.service.test.ts +359 -0
- package/src/services/__tests__/oauth-provider-registry.test.ts +142 -0
- package/src/services/__tests__/oauth-token-retrieval.service.test.ts +365 -0
- package/src/services/__tests__/proof-verifier.integration.test.ts +494 -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__/provider-validator.test.ts +370 -0
- package/src/services/__tests__/session-registration.service.test.ts +312 -0
- package/src/services/__tests__/storage.service.test.ts +358 -0
- package/src/services/__tests__/tool-context-builder.test.ts +438 -0
- package/src/services/access-control.service.ts +1048 -0
- package/src/services/authorization/authorization-registry.ts +67 -0
- package/src/services/authorization/types.ts +71 -0
- package/src/services/batch-delegation.service.ts +136 -0
- package/src/services/crypto.service.ts +296 -0
- package/src/services/delegation-error-formatter.ts +299 -0
- package/src/services/errors.ts +76 -0
- package/src/services/index.ts +34 -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 +652 -0
- package/src/services/oauth-token-retrieval.service.ts +245 -0
- package/src/services/policy.service.ts +527 -0
- package/src/services/proof-verifier.ts +295 -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 +236 -0
- package/src/services/provider-validator.ts +170 -0
- package/src/services/session-registration.service.ts +259 -0
- package/src/services/storage.service.ts +566 -0
- package/src/services/tool-context-builder.ts +285 -0
- package/src/services/tool-protection.service.ts +971 -0
- package/src/session/__tests__/session-manager.test.ts +327 -0
- package/src/session/index.ts +10 -0
- package/src/session/manager.ts +380 -0
- package/src/types/__tests__/oauth-required-error.test.ts +79 -0
- package/src/types/__tests__/tool-protection.test.ts +121 -0
- package/src/types/oauth-required-error.ts +71 -0
- package/src/types/tool-protection.ts +179 -0
- package/src/utils/__tests__/base58.test.ts +281 -0
- package/src/utils/__tests__/base64.test.ts +239 -0
- package/src/utils/__tests__/cors.test.ts +184 -0
- package/src/utils/__tests__/did-helpers.test.ts +156 -0
- package/src/utils/__tests__/storage-keys.test.ts +372 -0
- package/src/utils/base58.ts +109 -0
- package/src/utils/base64.ts +185 -0
- package/src/utils/cors.ts +93 -0
- package/src/utils/did-helpers.ts +229 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/storage-keys.ts +285 -0
- package/src/wire-format.ts +114 -0
- package/tsconfig.json +21 -0
- package/vitest.config.mts +57 -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
|