@kya-os/mcp-i-core 1.1.0 → 1.1.1-canary.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/dist/__tests__/utils/mock-providers.d.ts +102 -0
- package/dist/__tests__/utils/mock-providers.d.ts.map +1 -0
- package/dist/__tests__/utils/mock-providers.js +270 -0
- package/dist/__tests__/utils/mock-providers.js.map +1 -0
- package/dist/cache/tool-protection-cache.d.ts +73 -0
- package/dist/cache/tool-protection-cache.d.ts.map +1 -0
- package/dist/cache/tool-protection-cache.js +83 -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-v2.d.ts +110 -0
- package/dist/compliance/schema-verifier-v2.d.ts.map +1 -0
- package/dist/compliance/schema-verifier-v2.js +510 -0
- package/dist/compliance/schema-verifier-v2.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/delegation/bitstring.d.ts +139 -0
- package/dist/delegation/bitstring.d.ts.map +1 -0
- package/dist/delegation/bitstring.js +213 -0
- package/dist/delegation/bitstring.js.map +1 -0
- package/dist/delegation/cascading-revocation.d.ts +162 -0
- package/dist/delegation/cascading-revocation.d.ts.map +1 -0
- package/dist/delegation/cascading-revocation.js +263 -0
- package/dist/delegation/cascading-revocation.js.map +1 -0
- package/dist/delegation/delegation-graph.d.ts +178 -0
- package/dist/delegation/delegation-graph.d.ts.map +1 -0
- package/dist/delegation/delegation-graph.js +209 -0
- package/dist/delegation/delegation-graph.js.map +1 -0
- package/dist/delegation/index.d.ts +14 -0
- package/dist/delegation/index.d.ts.map +1 -0
- package/dist/delegation/index.js +30 -0
- package/dist/delegation/index.js.map +1 -0
- package/dist/delegation/statuslist-manager.d.ts +148 -0
- package/dist/delegation/statuslist-manager.d.ts.map +1 -0
- package/dist/delegation/statuslist-manager.js +221 -0
- package/dist/delegation/statuslist-manager.js.map +1 -0
- package/dist/delegation/storage/index.d.ts +9 -0
- package/dist/delegation/storage/index.d.ts.map +1 -0
- package/dist/delegation/storage/index.js +25 -0
- package/dist/delegation/storage/index.js.map +1 -0
- package/dist/delegation/storage/memory-graph-storage.d.ts +70 -0
- package/dist/delegation/storage/memory-graph-storage.d.ts.map +1 -0
- package/dist/delegation/storage/memory-graph-storage.js +149 -0
- package/dist/delegation/storage/memory-graph-storage.js.map +1 -0
- package/dist/delegation/storage/memory-statuslist-storage.d.ts +49 -0
- package/dist/delegation/storage/memory-statuslist-storage.d.ts.map +1 -0
- package/dist/delegation/storage/memory-statuslist-storage.js +67 -0
- package/dist/delegation/storage/memory-statuslist-storage.js.map +1 -0
- package/dist/delegation/utils.d.ts +19 -0
- package/dist/delegation/utils.d.ts.map +1 -0
- package/dist/delegation/utils.js +48 -0
- package/dist/delegation/utils.js.map +1 -0
- package/dist/delegation/vc-issuer.d.ts +135 -0
- package/dist/delegation/vc-issuer.d.ts.map +1 -0
- package/dist/delegation/vc-issuer.js +140 -0
- package/dist/delegation/vc-issuer.js.map +1 -0
- package/dist/delegation/vc-verifier.d.ts +213 -0
- package/dist/delegation/vc-verifier.d.ts.map +1 -0
- package/dist/delegation/vc-verifier.js +354 -0
- package/dist/delegation/vc-verifier.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/base.d.ts +1 -1
- package/dist/providers/base.d.ts.map +1 -1
- package/dist/providers/memory.js +2 -2
- package/dist/providers/memory.js.map +1 -1
- package/dist/runtime/base.d.ts +12 -0
- package/dist/runtime/base.d.ts.map +1 -1
- package/dist/runtime/base.js +96 -2
- package/dist/runtime/base.js.map +1 -1
- package/dist/services/tool-protection.service.d.ts +55 -0
- package/dist/services/tool-protection.service.d.ts.map +1 -0
- package/dist/services/tool-protection.service.js +158 -0
- package/dist/services/tool-protection.service.js.map +1 -0
- package/dist/types/tool-protection.d.ts +103 -0
- package/dist/types/tool-protection.d.ts.map +1 -0
- package/dist/types/tool-protection.js +41 -0
- package/dist/types/tool-protection.js.map +1 -0
- package/dist/utils/cors.d.ts +44 -0
- package/dist/utils/cors.d.ts.map +1 -0
- package/dist/utils/cors.js +71 -0
- package/dist/utils/cors.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +9 -6
|
@@ -0,0 +1,518 @@
|
|
|
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://schemas.kya-os.ai';
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-verifier.js","sourceRoot":"","sources":["../../src/compliance/schema-verifier.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAqrBH,oDAIC;AAjpBD;;GAEG;AACH,MAAa,cAAc;IACjB,cAAc,GAAG,2BAA2B,CAAC;IAC7C,WAAW,GAAG,IAAI,GAAG,EAAe,CAAC;IAE7C,YAAY,OAAqC;QAC/C,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;YAC5B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC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AAE,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;gBACtD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;gBACtC,KAAK,CAAC,IAAI,CACR,aAAa,MAAM,CAAC,cAAc,CAAC,MAAM,GAAG,EAAE,cAAc,CAC7D,CAAC;YACJ,CAAC;QACH,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACvC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YAC5C,MAAM,IAAI,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YAChD,MAAM,UAAU,GAAG,YAAY,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAChE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,UAAU,GAAG,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAEpC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAroBD,wCAqoBC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,OAEpC;IACC,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bitstring Utilities for StatusList2021
|
|
3
|
+
*
|
|
4
|
+
* Implements GZIP compression + base64url encoding for efficient status lists.
|
|
5
|
+
* Per W3C StatusList2021 spec, each bit represents credential status:
|
|
6
|
+
* - 0: Not revoked/suspended
|
|
7
|
+
* - 1: Revoked/suspended
|
|
8
|
+
*
|
|
9
|
+
* Related Spec: W3C StatusList2021
|
|
10
|
+
* Python Reference: Delegation-Revocation.md
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Platform-agnostic bitstring operations
|
|
14
|
+
*
|
|
15
|
+
* Implementations must provide compression/decompression functions
|
|
16
|
+
* since these are platform-specific (Node.js uses zlib, Cloudflare uses CompressionStream)
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Compression function interface
|
|
20
|
+
*/
|
|
21
|
+
export interface CompressionFunction {
|
|
22
|
+
/**
|
|
23
|
+
* Compress data using GZIP
|
|
24
|
+
* @param data - Data to compress
|
|
25
|
+
* @returns Compressed data
|
|
26
|
+
*/
|
|
27
|
+
compress(data: Uint8Array): Promise<Uint8Array>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Decompression function interface
|
|
31
|
+
*/
|
|
32
|
+
export interface DecompressionFunction {
|
|
33
|
+
/**
|
|
34
|
+
* Decompress GZIP data
|
|
35
|
+
* @param data - Compressed data
|
|
36
|
+
* @returns Decompressed data
|
|
37
|
+
*/
|
|
38
|
+
decompress(data: Uint8Array): Promise<Uint8Array>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Bitstring encoder/decoder
|
|
42
|
+
*
|
|
43
|
+
* Manages a bitstring for credential status tracking.
|
|
44
|
+
* Platform-agnostic - requires compression functions to be injected.
|
|
45
|
+
*/
|
|
46
|
+
export declare class BitstringManager {
|
|
47
|
+
private compressor;
|
|
48
|
+
private decompressor;
|
|
49
|
+
private bits;
|
|
50
|
+
private size;
|
|
51
|
+
constructor(size: number, compressor: CompressionFunction, decompressor: DecompressionFunction);
|
|
52
|
+
/**
|
|
53
|
+
* Set a bit at a specific index
|
|
54
|
+
*
|
|
55
|
+
* @param index - The bit index (0-based)
|
|
56
|
+
* @param value - true to set (revoked), false to clear (active)
|
|
57
|
+
*/
|
|
58
|
+
setBit(index: number, value: boolean): void;
|
|
59
|
+
/**
|
|
60
|
+
* Get a bit at a specific index
|
|
61
|
+
*
|
|
62
|
+
* @param index - The bit index (0-based)
|
|
63
|
+
* @returns true if set (revoked), false if clear (active)
|
|
64
|
+
*/
|
|
65
|
+
getBit(index: number): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Get all set bit indices
|
|
68
|
+
*
|
|
69
|
+
* @returns Array of indices where bits are set to 1
|
|
70
|
+
*/
|
|
71
|
+
getSetBits(): number[];
|
|
72
|
+
/**
|
|
73
|
+
* Encode bitstring to base64url (GZIP compressed)
|
|
74
|
+
*
|
|
75
|
+
* Per StatusList2021 spec:
|
|
76
|
+
* 1. GZIP compress the bitstring
|
|
77
|
+
* 2. Base64url encode the compressed data
|
|
78
|
+
*
|
|
79
|
+
* @returns Base64url-encoded compressed bitstring
|
|
80
|
+
*/
|
|
81
|
+
encode(): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Decode base64url bitstring (GZIP compressed)
|
|
84
|
+
*
|
|
85
|
+
* @param encodedList - Base64url-encoded compressed bitstring
|
|
86
|
+
* @returns BitstringManager instance
|
|
87
|
+
*/
|
|
88
|
+
static decode(encodedList: string, compressor: CompressionFunction, decompressor: DecompressionFunction): Promise<BitstringManager>;
|
|
89
|
+
/**
|
|
90
|
+
* Get the raw bitstring
|
|
91
|
+
*/
|
|
92
|
+
getRawBits(): Uint8Array;
|
|
93
|
+
/**
|
|
94
|
+
* Get the size (number of bits)
|
|
95
|
+
*/
|
|
96
|
+
getSize(): number;
|
|
97
|
+
/**
|
|
98
|
+
* Base64url encode (RFC 4648)
|
|
99
|
+
*
|
|
100
|
+
* Platform-agnostic implementation.
|
|
101
|
+
*/
|
|
102
|
+
private base64urlEncode;
|
|
103
|
+
/**
|
|
104
|
+
* Base64url decode (RFC 4648)
|
|
105
|
+
*/
|
|
106
|
+
private static base64urlDecode;
|
|
107
|
+
/**
|
|
108
|
+
* Convert bytes to base64
|
|
109
|
+
*
|
|
110
|
+
* Platform-agnostic implementation (works in Node and browsers/Cloudflare)
|
|
111
|
+
*/
|
|
112
|
+
private bytesToBase64;
|
|
113
|
+
/**
|
|
114
|
+
* Convert base64 to bytes
|
|
115
|
+
*/
|
|
116
|
+
private static base64ToBytes;
|
|
117
|
+
/**
|
|
118
|
+
* Create a bitstring from a list of indices to set
|
|
119
|
+
*
|
|
120
|
+
* @param size - Total size of the bitstring
|
|
121
|
+
* @param setBits - Indices to set to 1
|
|
122
|
+
* @param compressor - Compression function
|
|
123
|
+
* @param decompressor - Decompression function
|
|
124
|
+
* @returns BitstringManager instance
|
|
125
|
+
*/
|
|
126
|
+
static fromSetBits(size: number, setBits: number[], compressor: CompressionFunction, decompressor: DecompressionFunction): BitstringManager;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Helper to check if an index is set in an encoded status list
|
|
130
|
+
*
|
|
131
|
+
* Convenience function for quick status checks without creating a full manager.
|
|
132
|
+
*
|
|
133
|
+
* @param encodedList - Base64url-encoded compressed bitstring
|
|
134
|
+
* @param index - The bit index to check
|
|
135
|
+
* @param decompressor - Decompression function
|
|
136
|
+
* @returns true if bit is set (revoked), false otherwise
|
|
137
|
+
*/
|
|
138
|
+
export declare function isIndexSet(encodedList: string, index: number, decompressor: DecompressionFunction): Promise<boolean>;
|
|
139
|
+
//# sourceMappingURL=bitstring.d.ts.map
|