@kya-os/mcp-i-core 1.7.0 → 1.8.1

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 (121) hide show
  1. package/README.md +1 -1
  2. package/dist/conformance/capability-verifier-adapter.d.ts +66 -0
  3. package/dist/conformance/capability-verifier-adapter.js +61 -0
  4. package/dist/conformance/index.d.ts +10 -0
  5. package/dist/conformance/index.js +19 -0
  6. package/dist/conformance/validate-level2.d.ts +203 -0
  7. package/dist/conformance/validate-level2.js +294 -0
  8. package/dist/conformance/vc-jwt-verifier.d.ts +55 -0
  9. package/dist/conformance/vc-jwt-verifier.js +147 -0
  10. package/dist/delegation/did-web-resolver.d.ts +60 -0
  11. package/dist/delegation/did-web-resolver.js +129 -0
  12. package/dist/delegation/outbound-proof.d.ts +3 -2
  13. package/dist/delegation/outbound-proof.js +3 -2
  14. package/dist/delegation/utils.d.ts +3 -1
  15. package/dist/index.d.ts +9 -63
  16. package/dist/index.js +22 -161
  17. package/dist/utils/base58.d.ts +4 -28
  18. package/dist/utils/base58.js +18 -98
  19. package/dist/utils/base64.d.ts +4 -29
  20. package/dist/utils/base64.js +18 -167
  21. package/dist/utils/did-helpers.d.ts +4 -165
  22. package/dist/utils/did-helpers.js +18 -217
  23. package/package.json +5 -7
  24. package/dist/auth/handshake.d.ts +0 -119
  25. package/dist/auth/handshake.js +0 -250
  26. package/dist/auth/index.d.ts +0 -6
  27. package/dist/auth/index.js +0 -11
  28. package/dist/auth/types.d.ts +0 -46
  29. package/dist/auth/types.js +0 -10
  30. package/dist/cache/oauth-config-cache.d.ts +0 -69
  31. package/dist/cache/oauth-config-cache.js +0 -76
  32. package/dist/cache/tool-protection-cache.d.ts +0 -89
  33. package/dist/cache/tool-protection-cache.js +0 -118
  34. package/dist/compliance/index.d.ts +0 -8
  35. package/dist/compliance/index.js +0 -24
  36. package/dist/compliance/schema-registry.d.ts +0 -50
  37. package/dist/compliance/schema-registry.js +0 -438
  38. package/dist/compliance/schema-verifier.d.ts +0 -110
  39. package/dist/compliance/schema-verifier.js +0 -518
  40. package/dist/config/remote-config.d.ts +0 -173
  41. package/dist/config/remote-config.js +0 -253
  42. package/dist/config.d.ts +0 -182
  43. package/dist/config.js +0 -148
  44. package/dist/identity/idp-token-resolver.d.ts +0 -69
  45. package/dist/identity/idp-token-resolver.js +0 -136
  46. package/dist/identity/idp-token-storage.interface.d.ts +0 -80
  47. package/dist/identity/idp-token-storage.interface.js +0 -14
  48. package/dist/identity/user-did-manager.d.ts +0 -228
  49. package/dist/identity/user-did-manager.js +0 -356
  50. package/dist/logging/index.d.ts +0 -5
  51. package/dist/logging/index.js +0 -10
  52. package/dist/logging/logger.d.ts +0 -33
  53. package/dist/logging/logger.js +0 -104
  54. package/dist/proof/generator.d.ts +0 -109
  55. package/dist/proof/generator.js +0 -236
  56. package/dist/proof/index.d.ts +0 -5
  57. package/dist/proof/index.js +0 -11
  58. package/dist/providers/base.d.ts +0 -95
  59. package/dist/providers/base.js +0 -47
  60. package/dist/providers/memory.d.ts +0 -42
  61. package/dist/providers/memory.js +0 -121
  62. package/dist/runtime/audit-logger.d.ts +0 -37
  63. package/dist/runtime/audit-logger.js +0 -9
  64. package/dist/runtime/base.d.ts +0 -375
  65. package/dist/runtime/base.js +0 -1491
  66. package/dist/runtime/ext-apps-constants.d.ts +0 -14
  67. package/dist/runtime/ext-apps-constants.js +0 -17
  68. package/dist/services/access-control.service.d.ts +0 -138
  69. package/dist/services/access-control.service.js +0 -721
  70. package/dist/services/authorization/authorization-registry.d.ts +0 -29
  71. package/dist/services/authorization/authorization-registry.js +0 -58
  72. package/dist/services/authorization/types.d.ts +0 -53
  73. package/dist/services/authorization/types.js +0 -10
  74. package/dist/services/batch-delegation.service.d.ts +0 -53
  75. package/dist/services/batch-delegation.service.js +0 -95
  76. package/dist/services/crypto.service.d.ts +0 -69
  77. package/dist/services/crypto.service.js +0 -225
  78. package/dist/services/delegation-error-formatter.d.ts +0 -124
  79. package/dist/services/delegation-error-formatter.js +0 -214
  80. package/dist/services/errors.d.ts +0 -49
  81. package/dist/services/errors.js +0 -66
  82. package/dist/services/index.d.ts +0 -9
  83. package/dist/services/index.js +0 -15
  84. package/dist/services/oauth-config.service.d.ts +0 -53
  85. package/dist/services/oauth-config.service.js +0 -141
  86. package/dist/services/oauth-provider-registry.d.ts +0 -88
  87. package/dist/services/oauth-provider-registry.js +0 -128
  88. package/dist/services/oauth-service.d.ts +0 -122
  89. package/dist/services/oauth-service.js +0 -442
  90. package/dist/services/oauth-token-retrieval.service.d.ts +0 -49
  91. package/dist/services/oauth-token-retrieval.service.js +0 -150
  92. package/dist/services/policy.service.d.ts +0 -130
  93. package/dist/services/policy.service.js +0 -399
  94. package/dist/services/proof-verifier.d.ts +0 -98
  95. package/dist/services/proof-verifier.js +0 -319
  96. package/dist/services/provider-resolver.d.ts +0 -89
  97. package/dist/services/provider-resolver.js +0 -196
  98. package/dist/services/provider-validator.d.ts +0 -55
  99. package/dist/services/provider-validator.js +0 -135
  100. package/dist/services/session-registration.service.d.ts +0 -80
  101. package/dist/services/session-registration.service.js +0 -174
  102. package/dist/services/storage.service.d.ts +0 -116
  103. package/dist/services/storage.service.js +0 -411
  104. package/dist/services/tool-context-builder.d.ts +0 -74
  105. package/dist/services/tool-context-builder.js +0 -215
  106. package/dist/services/tool-protection.service.d.ts +0 -193
  107. package/dist/services/tool-protection.service.js +0 -736
  108. package/dist/session/index.d.ts +0 -5
  109. package/dist/session/index.js +0 -11
  110. package/dist/session/manager.d.ts +0 -113
  111. package/dist/session/manager.js +0 -273
  112. package/dist/types/oauth-required-error.d.ts +0 -46
  113. package/dist/types/oauth-required-error.js +0 -42
  114. package/dist/types/tool-protection.d.ts +0 -144
  115. package/dist/types/tool-protection.js +0 -48
  116. package/dist/utils/cors.d.ts +0 -44
  117. package/dist/utils/cors.js +0 -71
  118. package/dist/utils/index.d.ts +0 -8
  119. package/dist/utils/index.js +0 -24
  120. package/dist/utils/storage-keys.d.ts +0 -120
  121. package/dist/utils/storage-keys.js +0 -217
@@ -1,518 +0,0 @@
1
- "use strict";
2
- /**
3
- * Schema Compliance Verification Tool
4
- *
5
- * Supports JSON Schema draft-07 features:
6
- * - $ref resolution
7
- * - oneOf, anyOf, allOf
8
- * - Nested required fields
9
- * - Array tuple validation
10
- * - Format, pattern, enum, const
11
- * - Recursive object validation
12
- */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.SchemaVerifier = void 0;
15
- exports.createSchemaVerifier = createSchemaVerifier;
16
- /**
17
- * Schema Verifier with JSON Schema draft-07 support
18
- */
19
- class SchemaVerifier {
20
- schemasBaseUrl = 'https://schema.modelcontextprotocol-identity.io';
21
- schemaCache = new Map();
22
- constructor(options) {
23
- if (options?.schemasBaseUrl) {
24
- this.schemasBaseUrl = options.schemasBaseUrl;
25
- }
26
- }
27
- /**
28
- * Verify a single schema against implementation
29
- */
30
- async verifySchema(schema, implementation) {
31
- const fields = [];
32
- const issues = [];
33
- const warnings = [];
34
- // Fetch the canonical schema
35
- let canonicalSchema;
36
- try {
37
- canonicalSchema = await this.fetchSchema(schema.url);
38
- }
39
- catch (error) {
40
- return {
41
- schema,
42
- compliant: false,
43
- compliancePercentage: 0,
44
- fields: [],
45
- issues: [
46
- `Failed to fetch schema: ${error instanceof Error ? error.message : 'Unknown error'}`,
47
- ],
48
- warnings: [],
49
- timestamp: Date.now(),
50
- };
51
- }
52
- // Resolve $ref if present at root
53
- const resolvedSchema = this.resolveRef(canonicalSchema, canonicalSchema);
54
- // Validate the implementation against the schema
55
- const validationResult = this.validateAgainstSchema(implementation, resolvedSchema, canonicalSchema, '');
56
- fields.push(...validationResult.fields);
57
- // Separate issues and warnings
58
- for (const field of fields) {
59
- if (field.status === 'fail') {
60
- issues.push(`${field.fieldPath}: ${field.reason}`);
61
- }
62
- else if (field.status === 'warning') {
63
- warnings.push(`${field.fieldPath}: ${field.reason}`);
64
- }
65
- }
66
- // Calculate compliance
67
- const requiredFields = fields.filter((f) => f.required);
68
- const passingRequiredFields = requiredFields.filter((f) => f.status === 'pass').length;
69
- const compliancePercentage = requiredFields.length > 0
70
- ? (passingRequiredFields / requiredFields.length) * 100
71
- : 100; // If no required fields, 100% compliant
72
- const compliant = issues.length === 0 && compliancePercentage >= 95;
73
- return {
74
- schema,
75
- compliant,
76
- compliancePercentage,
77
- fields,
78
- issues,
79
- warnings,
80
- timestamp: Date.now(),
81
- };
82
- }
83
- /**
84
- * Verify all schemas
85
- */
86
- async verifyAll(schemas, implementations) {
87
- const schemaReports = [];
88
- const criticalIssues = [];
89
- for (const schema of schemas) {
90
- const implementation = implementations.get(schema.id);
91
- if (!implementation) {
92
- criticalIssues.push(`No implementation found for schema: ${schema.id}`);
93
- continue;
94
- }
95
- const report = await this.verifySchema(schema, implementation);
96
- schemaReports.push(report);
97
- if (!report.compliant) {
98
- criticalIssues.push(`${schema.id}: ${report.issues.join(', ')}`);
99
- }
100
- }
101
- const compliantSchemas = schemaReports.filter((r) => r.compliant).length;
102
- const overallCompliance = schemas.length > 0 ? (compliantSchemas / schemas.length) * 100 : 0;
103
- return {
104
- totalSchemas: schemas.length,
105
- compliantSchemas,
106
- overallCompliance,
107
- schemaReports,
108
- criticalIssues,
109
- timestamp: Date.now(),
110
- };
111
- }
112
- /**
113
- * Validate implementation against schema recursively
114
- */
115
- validateAgainstSchema(value, schema, rootSchema, path) {
116
- const fields = [];
117
- // Resolve $ref
118
- schema = this.resolveRef(schema, rootSchema);
119
- // Handle oneOf, anyOf, allOf
120
- if (schema.oneOf || schema.anyOf || schema.allOf) {
121
- return this.validateUnion(value, schema, rootSchema, path);
122
- }
123
- // Handle type: object
124
- if (schema.type === 'object' && schema.properties) {
125
- const required = schema.required || [];
126
- for (const [propName, propSchema] of Object.entries(schema.properties)) {
127
- const propPath = path ? `${path}.${propName}` : propName;
128
- const propValue = value?.[propName];
129
- const isRequired = required.includes(propName);
130
- const fieldResult = this.checkField(propPath, propValue, propSchema, rootSchema, isRequired);
131
- fields.push(fieldResult);
132
- // Recurse into nested objects
133
- if (propValue !== undefined && propSchema.type === 'object') {
134
- const nestedResult = this.validateAgainstSchema(propValue, propSchema, rootSchema, propPath);
135
- fields.push(...nestedResult.fields);
136
- }
137
- }
138
- }
139
- // Handle type: array
140
- if (schema.type === 'array' && value && Array.isArray(value)) {
141
- const arrayResult = this.validateArray(value, schema, rootSchema, path);
142
- fields.push(...arrayResult.fields);
143
- }
144
- return { fields };
145
- }
146
- /**
147
- * Validate against oneOf, anyOf, allOf
148
- */
149
- validateUnion(value, schema, rootSchema, path) {
150
- const fields = [];
151
- // For anyOf/oneOf, try to find a matching schema
152
- if (schema.anyOf || schema.oneOf) {
153
- const options = schema.anyOf || schema.oneOf;
154
- let matched = false;
155
- for (const option of options) {
156
- const resolvedOption = this.resolveRef(option, rootSchema);
157
- // Try to validate against this option
158
- try {
159
- if (this.matchesSchema(value, resolvedOption, rootSchema)) {
160
- // Found a match, validate with this schema
161
- const result = this.validateAgainstSchema(value, resolvedOption, rootSchema, path);
162
- fields.push(...result.fields);
163
- matched = true;
164
- break;
165
- }
166
- }
167
- catch (e) {
168
- // Doesn't match this option, try next
169
- continue;
170
- }
171
- }
172
- if (!matched && path) {
173
- // Didn't match any option
174
- fields.push({
175
- fieldPath: path,
176
- present: value !== undefined,
177
- expectedType: 'oneOf/anyOf options',
178
- actualType: typeof value,
179
- typeMatches: false,
180
- required: true,
181
- status: 'fail',
182
- reason: 'Value does not match any of the schema options',
183
- });
184
- }
185
- }
186
- // For allOf, validate against all schemas
187
- if (schema.allOf) {
188
- for (const subSchema of schema.allOf) {
189
- const resolvedSubSchema = this.resolveRef(subSchema, rootSchema);
190
- const result = this.validateAgainstSchema(value, resolvedSubSchema, rootSchema, path);
191
- fields.push(...result.fields);
192
- }
193
- }
194
- return { fields };
195
- }
196
- /**
197
- * Check if value matches schema (lightweight check)
198
- */
199
- matchesSchema(value, schema, rootSchema) {
200
- schema = this.resolveRef(schema, rootSchema);
201
- // Check type
202
- if (schema.type) {
203
- const actualType = Array.isArray(value) ? 'array' : typeof value;
204
- // JSON Schema "integer" matches JavaScript "number" (if it's an integer)
205
- if (schema.type === 'integer' && actualType === 'number') {
206
- if (!Number.isInteger(value)) {
207
- return false;
208
- }
209
- }
210
- else if (schema.type !== actualType) {
211
- return false;
212
- }
213
- }
214
- // Check const
215
- if (schema.const !== undefined && value !== schema.const) {
216
- return false;
217
- }
218
- // Check enum
219
- if (schema.enum && !schema.enum.includes(value)) {
220
- return false;
221
- }
222
- // Check pattern (for strings)
223
- if (schema.pattern && typeof value === 'string') {
224
- const regex = new RegExp(schema.pattern);
225
- if (!regex.test(value)) {
226
- return false;
227
- }
228
- }
229
- // Check required properties (for objects)
230
- if (schema.type === 'object' && schema.required) {
231
- for (const requiredProp of schema.required) {
232
- if (!(requiredProp in value)) {
233
- return false;
234
- }
235
- }
236
- }
237
- return true;
238
- }
239
- /**
240
- * Validate array against schema
241
- */
242
- validateArray(value, schema, rootSchema, path) {
243
- const fields = [];
244
- // Check minItems
245
- if (schema.minItems !== undefined && value.length < schema.minItems) {
246
- fields.push({
247
- fieldPath: `${path}.length`,
248
- present: true,
249
- expectedType: `array with minItems: ${schema.minItems}`,
250
- actualType: `array with length: ${value.length}`,
251
- typeMatches: false,
252
- required: true,
253
- status: 'fail',
254
- reason: `Array length ${value.length} is less than minItems ${schema.minItems}`,
255
- });
256
- }
257
- // Check tuple validation (items as array)
258
- if (Array.isArray(schema.items)) {
259
- for (let i = 0; i < schema.items.length; i++) {
260
- const itemSchema = schema.items[i];
261
- const itemValue = value[i];
262
- const itemPath = `${path}[${i}]`;
263
- if (itemValue !== undefined) {
264
- const resolvedItemSchema = this.resolveRef(itemSchema, rootSchema);
265
- const itemResult = this.validateAgainstSchema(itemValue, resolvedItemSchema, rootSchema, itemPath);
266
- fields.push(...itemResult.fields);
267
- }
268
- }
269
- // Check additionalItems
270
- if (schema.additionalItems !== undefined && value.length > schema.items.length) {
271
- for (let i = schema.items.length; i < value.length; i++) {
272
- const itemValue = value[i];
273
- const itemPath = `${path}[${i}]`;
274
- const itemResult = this.validateAgainstSchema(itemValue, schema.additionalItems, rootSchema, itemPath);
275
- fields.push(...itemResult.fields);
276
- }
277
- }
278
- }
279
- else if (schema.items) {
280
- // Single schema for all items
281
- for (let i = 0; i < value.length; i++) {
282
- const itemValue = value[i];
283
- const itemPath = `${path}[${i}]`;
284
- const resolvedItemSchema = this.resolveRef(schema.items, rootSchema);
285
- const itemResult = this.validateAgainstSchema(itemValue, resolvedItemSchema, rootSchema, itemPath);
286
- fields.push(...itemResult.fields);
287
- }
288
- }
289
- // Check contains (at least one item must match)
290
- if (schema.contains) {
291
- const containsSchema = this.resolveRef(schema.contains, rootSchema);
292
- const hasMatch = value.some((item) => this.matchesSchema(item, containsSchema, rootSchema));
293
- if (!hasMatch) {
294
- fields.push({
295
- fieldPath: `${path}.contains`,
296
- present: true,
297
- expectedType: 'array containing matching item',
298
- actualType: 'array without matching item',
299
- typeMatches: false,
300
- required: true,
301
- status: 'fail',
302
- reason: 'Array does not contain any item matching the "contains" schema',
303
- });
304
- }
305
- }
306
- return { fields };
307
- }
308
- /**
309
- * Check a single field
310
- */
311
- checkField(fieldPath, value, schema, rootSchema, required) {
312
- schema = this.resolveRef(schema, rootSchema);
313
- const present = value !== undefined;
314
- const actualType = this.getActualType(value);
315
- // Get expected type
316
- let expectedType = 'unknown';
317
- if (schema.type) {
318
- expectedType = schema.type;
319
- }
320
- else if (schema.anyOf) {
321
- expectedType = 'anyOf';
322
- }
323
- else if (schema.oneOf) {
324
- expectedType = 'oneOf';
325
- }
326
- else if (schema.allOf) {
327
- expectedType = 'allOf';
328
- }
329
- // Check if required field is missing
330
- if (required && !present) {
331
- return {
332
- fieldPath,
333
- present,
334
- expectedType,
335
- actualType,
336
- typeMatches: false,
337
- required,
338
- status: 'fail',
339
- reason: 'Required field missing',
340
- };
341
- }
342
- // Check if optional field is missing
343
- if (!required && !present) {
344
- return {
345
- fieldPath,
346
- present,
347
- expectedType,
348
- actualType,
349
- typeMatches: true, // Optional field can be missing
350
- required,
351
- status: 'pass',
352
- };
353
- }
354
- // Value is present, check if it matches schema
355
- const typeMatches = this.matchesSchema(value, schema, rootSchema);
356
- if (!typeMatches) {
357
- return {
358
- fieldPath,
359
- present,
360
- expectedType,
361
- actualType,
362
- typeMatches: false,
363
- required,
364
- status: 'fail',
365
- reason: `Type/value mismatch`,
366
- };
367
- }
368
- // All good
369
- return {
370
- fieldPath,
371
- present,
372
- expectedType,
373
- actualType,
374
- typeMatches: true,
375
- required,
376
- status: 'pass',
377
- };
378
- }
379
- /**
380
- * Get actual JavaScript type
381
- */
382
- getActualType(value) {
383
- if (value === null)
384
- return 'null';
385
- if (Array.isArray(value))
386
- return 'array';
387
- if (typeof value === 'number' && Number.isInteger(value))
388
- return 'integer';
389
- return typeof value;
390
- }
391
- /**
392
- * Resolve $ref reference
393
- */
394
- resolveRef(schema, rootSchema) {
395
- if (!schema.$ref) {
396
- return schema;
397
- }
398
- const ref = schema.$ref;
399
- // Handle #/definitions/Foo
400
- if (ref.startsWith('#/definitions/')) {
401
- const defName = ref.substring('#/definitions/'.length);
402
- if (rootSchema.definitions && rootSchema.definitions[defName]) {
403
- return rootSchema.definitions[defName];
404
- }
405
- }
406
- // Handle #/$defs/Foo (draft-07+)
407
- if (ref.startsWith('#/$defs/')) {
408
- const defName = ref.substring('#/$defs/'.length);
409
- if (rootSchema.$defs && rootSchema.$defs[defName]) {
410
- return rootSchema.$defs[defName];
411
- }
412
- }
413
- // Handle # (root)
414
- if (ref === '#') {
415
- return rootSchema;
416
- }
417
- // If we can't resolve, return original
418
- return schema;
419
- }
420
- /**
421
- * Fetch a schema from URL
422
- */
423
- async fetchSchema(url) {
424
- // Check cache
425
- if (this.schemaCache.has(url)) {
426
- return this.schemaCache.get(url);
427
- }
428
- try {
429
- const response = await fetch(url);
430
- if (!response.ok) {
431
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
432
- }
433
- const schema = await response.json();
434
- this.schemaCache.set(url, schema);
435
- return schema;
436
- }
437
- catch (error) {
438
- if (error instanceof Error) {
439
- throw new Error(`Failed to fetch schema from ${url}: ${error.message}`);
440
- }
441
- throw new Error(`Failed to fetch schema from ${url}: Unknown error`);
442
- }
443
- }
444
- /**
445
- * Generate a formatted report
446
- */
447
- generateReport(report) {
448
- const lines = [];
449
- lines.push(`\n${'='.repeat(80)}`);
450
- lines.push(`SCHEMA COMPLIANCE REPORT: ${report.schema.id}`);
451
- lines.push(`${'='.repeat(80)}\n`);
452
- lines.push(`Schema: ${report.schema.type} v${report.schema.version}`);
453
- lines.push(`URL: ${report.schema.url}`);
454
- lines.push(`Status: ${report.compliant ? '✅ COMPLIANT' : '❌ NON-COMPLIANT'}`);
455
- lines.push(`Compliance: ${report.compliancePercentage.toFixed(1)}%\n`);
456
- if (report.issues.length > 0) {
457
- lines.push(`\n🚨 ISSUES (${report.issues.length}):`);
458
- report.issues.forEach((issue, i) => {
459
- lines.push(` ${i + 1}. ${issue}`);
460
- });
461
- }
462
- if (report.warnings.length > 0) {
463
- lines.push(`\n⚠️ WARNINGS (${report.warnings.length}):`);
464
- report.warnings.forEach((warning, i) => {
465
- lines.push(` ${i + 1}. ${warning}`);
466
- });
467
- }
468
- lines.push(`\n📊 FIELD DETAILS:\n`);
469
- const requiredFields = report.fields.filter((f) => f.required);
470
- const passing = requiredFields.filter((f) => f.status === 'pass').length;
471
- const failing = requiredFields.filter((f) => f.status === 'fail').length;
472
- const warnings = report.fields.filter((f) => f.status === 'warning').length;
473
- lines.push(` ✅ Pass: ${passing}/${requiredFields.length} required fields`);
474
- lines.push(` ❌ Fail: ${failing}/${requiredFields.length} required fields`);
475
- lines.push(` ⚠️ Warn: ${warnings} optional fields`);
476
- lines.push(` 📝 Total: ${report.fields.length} fields checked\n`);
477
- lines.push(`${'='.repeat(80)}\n`);
478
- return lines.join('\n');
479
- }
480
- /**
481
- * Generate full report
482
- */
483
- generateFullReport(report) {
484
- const lines = [];
485
- lines.push(`\n${'='.repeat(80)}`);
486
- lines.push(`FULL SCHEMA COMPLIANCE REPORT`);
487
- lines.push(`${'='.repeat(80)}\n`);
488
- lines.push(`Total Schemas: ${report.totalSchemas}`);
489
- lines.push(`Compliant: ${report.compliantSchemas}`);
490
- lines.push(`Non-Compliant: ${report.totalSchemas - report.compliantSchemas}`);
491
- lines.push(`Overall Compliance: ${report.overallCompliance.toFixed(1)}%\n`);
492
- if (report.criticalIssues.length > 0) {
493
- lines.push(`\n🚨 CRITICAL ISSUES (${report.criticalIssues.length}):`);
494
- report.criticalIssues.slice(0, 10).forEach((issue, i) => {
495
- lines.push(` ${i + 1}. ${issue}`);
496
- });
497
- if (report.criticalIssues.length > 10) {
498
- lines.push(` ... and ${report.criticalIssues.length - 10} more issues`);
499
- }
500
- }
501
- lines.push(`\n📊 SCHEMA BREAKDOWN:\n`);
502
- report.schemaReports.forEach((schemaReport) => {
503
- const icon = schemaReport.compliant ? '✅' : '❌';
504
- const percentage = schemaReport.compliancePercentage.toFixed(1);
505
- lines.push(` ${icon} ${schemaReport.schema.id}: ${percentage}%`);
506
- });
507
- lines.push(`\n${'='.repeat(80)}\n`);
508
- return lines.join('\n');
509
- }
510
- }
511
- exports.SchemaVerifier = SchemaVerifier;
512
- /**
513
- * Create a schema verifier
514
- */
515
- function createSchemaVerifier(options) {
516
- return new SchemaVerifier(options);
517
- }
518
- //# sourceMappingURL=schema-verifier.js.map
@@ -1,173 +0,0 @@
1
- /**
2
- * Remote Configuration Fetching
3
- *
4
- * Service for fetching configuration from remote APIs (AgentShield dashboard)
5
- * with caching support for performance optimization.
6
- *
7
- * @module @kya-os/mcp-i-core/config/remote-config
8
- */
9
- import type { MCPIConfig } from '@kya-os/contracts/config';
10
- import type { ToolProtection, ToolProtectionMap } from '@kya-os/contracts/tool-protection';
11
- import type { PolicyConfig } from '@kya-os/contracts';
12
- /**
13
- * Options for fetching remote configuration
14
- */
15
- export interface RemoteConfigOptions {
16
- /**
17
- * API base URL
18
- * @example 'https://kya.vouched.id'
19
- */
20
- apiUrl: string;
21
- /**
22
- * API key for authentication
23
- */
24
- apiKey: string;
25
- /**
26
- * Project ID (optional, preferred over agentDid)
27
- * Used for project-scoped configuration
28
- */
29
- projectId?: string;
30
- /**
31
- * Agent DID (optional, used when projectId not available)
32
- * Used for agent-scoped configuration
33
- */
34
- agentDid?: string;
35
- /**
36
- * Cache TTL in milliseconds
37
- * @default 300000 (5 minutes)
38
- */
39
- cacheTtl?: number;
40
- /**
41
- * Fetch provider function
42
- * Platform-agnostic fetch implementation
43
- */
44
- fetchProvider: (url: string, options: RequestInit) => Promise<Response>;
45
- }
46
- /**
47
- * Cache interface for remote configuration
48
- * Abstracts platform-specific caching (KV, Redis, Memory, etc.)
49
- */
50
- export interface RemoteConfigCache {
51
- /**
52
- * Get a cached value
53
- */
54
- get(key: string): Promise<string | null>;
55
- /**
56
- * Set a cached value with TTL
57
- */
58
- set(key: string, value: string, ttl: number): Promise<void>;
59
- }
60
- /**
61
- * Fetch configuration from remote API (AgentShield dashboard)
62
- *
63
- * Attempts to fetch configuration from the AgentShield API with caching support.
64
- * Falls back gracefully if remote fetch fails.
65
- *
66
- * @param options - Remote config options
67
- * @param cache - Optional cache implementation
68
- * @returns Configuration object or null if fetch fails
69
- */
70
- export declare function fetchRemoteConfig(options: RemoteConfigOptions, cache?: RemoteConfigCache): Promise<MCPIConfig | null>;
71
- /**
72
- * Get tool protection for a specific tool from a merged config
73
- *
74
- * This helper function extracts tool protection from a merged config response.
75
- * It handles both the new format (toolProtection.tools) and returns null
76
- * for unprotected or unknown tools.
77
- *
78
- * @param config - Merged config object (must have toolProtection.tools)
79
- * @param toolName - Name of the tool to look up
80
- * @returns Tool protection or null if tool not protected or not found
81
- *
82
- * @since 1.6.0
83
- */
84
- export declare function getToolProtection(config: {
85
- toolProtection?: {
86
- tools?: ToolProtectionMap;
87
- };
88
- }, toolName: string): ToolProtection | null;
89
- /**
90
- * Extract tool protections map from merged config
91
- *
92
- * This helper function extracts the tool protections map from a merged config.
93
- * Returns an empty object if no tools are found.
94
- *
95
- * @param config - Config object that may contain toolProtection.tools
96
- * @returns Tool protection map or empty object
97
- *
98
- * @since 1.6.0
99
- */
100
- export declare function extractToolProtections(config: {
101
- toolProtection?: {
102
- tools?: ToolProtectionMap;
103
- };
104
- } | null | undefined): ToolProtectionMap;
105
- /**
106
- * Check if config has embedded tool protections
107
- *
108
- * Utility to check if a config response is in the new merged format
109
- * with embedded tool protections.
110
- *
111
- * @param config - Config object to check
112
- * @returns True if config has embedded tools, false otherwise
113
- *
114
- * @since 1.6.0
115
- */
116
- export declare function hasMergedToolProtections(config: unknown): config is {
117
- toolProtection: {
118
- tools: ToolProtectionMap;
119
- };
120
- };
121
- /**
122
- * Get policy configuration from a merged config
123
- *
124
- * This helper function extracts policy configuration from a merged config response.
125
- * Returns null if no policy is present in the config.
126
- *
127
- * @param config - Config object that may contain policy
128
- * @returns Policy configuration or null if not present
129
- *
130
- * @since 1.7.0
131
- */
132
- export declare function getPolicy(config: {
133
- policy?: PolicyConfig;
134
- } | null | undefined): PolicyConfig | null;
135
- /**
136
- * Extract policy configuration from merged config with defaults
137
- *
138
- * This helper function extracts the policy from a merged config.
139
- * Returns the default policy config if no policy is found.
140
- *
141
- * @param config - Config object that may contain policy
142
- * @returns Policy configuration (never null, returns defaults if missing)
143
- *
144
- * @since 1.7.0
145
- */
146
- export declare function extractPolicy(config: {
147
- policy?: PolicyConfig;
148
- } | null | undefined): PolicyConfig;
149
- /**
150
- * Check if config has embedded policy configuration
151
- *
152
- * Utility to check if a config response includes policy configuration.
153
- *
154
- * @param config - Config object to check
155
- * @returns True if config has policy, false otherwise
156
- *
157
- * @since 1.7.0
158
- */
159
- export declare function hasMergedPolicy(config: unknown): config is {
160
- policy: PolicyConfig;
161
- };
162
- /**
163
- * Check if policy enforcement is enabled for a config
164
- *
165
- * @param config - Config object that may contain policy
166
- * @returns True if policy is present and enabled
167
- *
168
- * @since 1.7.0
169
- */
170
- export declare function isPolicyEnabled(config: {
171
- policy?: PolicyConfig;
172
- } | null | undefined): boolean;
173
- //# sourceMappingURL=remote-config.d.ts.map