@kya-os/checkpoint-shared 1.1.0 → 1.2.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 (38) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/beacon-types/index.d.mts +427 -0
  3. package/dist/beacon-types/index.d.ts +427 -0
  4. package/dist/beacon-types/index.js +204 -0
  5. package/dist/beacon-types/index.mjs +191 -0
  6. package/dist/deploy/index.d.mts +380 -0
  7. package/dist/deploy/index.d.ts +380 -0
  8. package/dist/deploy/index.js +221 -0
  9. package/dist/deploy/index.mjs +207 -0
  10. package/dist/gateway/index.d.mts +575 -0
  11. package/dist/gateway/index.d.ts +575 -0
  12. package/dist/gateway/index.js +98 -0
  13. package/dist/gateway/index.mjs +88 -0
  14. package/dist/index.d.mts +1471 -106
  15. package/dist/index.d.ts +1471 -106
  16. package/dist/index.js +1869 -1029
  17. package/dist/index.mjs +1826 -1028
  18. package/dist/mcpi/agentshield-api/index.d.mts +47 -0
  19. package/dist/mcpi/agentshield-api/index.d.ts +47 -0
  20. package/dist/mcpi/agentshield-api/index.js +2 -0
  21. package/dist/mcpi/agentshield-api/index.mjs +1 -0
  22. package/dist/mcpi/approval-grant/index.d.mts +79 -0
  23. package/dist/mcpi/approval-grant/index.d.ts +79 -0
  24. package/dist/mcpi/approval-grant/index.js +157 -0
  25. package/dist/mcpi/approval-grant/index.mjs +150 -0
  26. package/dist/mcpi/dashboard-config/index.d.mts +14075 -0
  27. package/dist/mcpi/dashboard-config/index.d.ts +14075 -0
  28. package/dist/mcpi/dashboard-config/index.js +517 -0
  29. package/dist/mcpi/dashboard-config/index.mjs +492 -0
  30. package/dist/test-fixtures/index.d.mts +17 -8
  31. package/dist/test-fixtures/index.d.ts +17 -8
  32. package/dist/test-fixtures/index.js +73 -7
  33. package/dist/test-fixtures/index.mjs +73 -8
  34. package/dist/tool-protection/index.d.mts +1120 -0
  35. package/dist/tool-protection/index.d.ts +1120 -0
  36. package/dist/tool-protection/index.js +370 -0
  37. package/dist/tool-protection/index.mjs +338 -0
  38. package/package.json +40 -3
@@ -0,0 +1,517 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+
5
+ // src/mcpi/dashboard-config/schemas.ts
6
+ var ENV_VAR_PATTERN = /^[A-Z][A-Z0-9_]*$/;
7
+ var envVarNameSchema = zod.z.string().regex(ENV_VAR_PATTERN, "Must be a valid env var name (e.g., X_API_KEY)").max(255);
8
+ zod.z.object({
9
+ error: zod.z.literal("auth_required"),
10
+ type: zod.z.enum(["apikey", "oauth", "credential"]),
11
+ envVarNames: zod.z.array(zod.z.string()).optional(),
12
+ configUrl: zod.z.string(),
13
+ message: zod.z.string()
14
+ });
15
+ var AuthorizationRequirementSchema = zod.z.discriminatedUnion("type", [
16
+ // Deprecated: 'oauth' is an alias for 'oauth2'
17
+ // Will be removed in v2.0.0. Use 'oauth2' instead.
18
+ zod.z.object({
19
+ type: zod.z.literal("oauth"),
20
+ provider: zod.z.string(),
21
+ requiredScopes: zod.z.array(zod.z.string()).optional()
22
+ }),
23
+ // OAuth 2.0 provider authentication (canonical)
24
+ zod.z.object({
25
+ type: zod.z.literal("oauth2"),
26
+ provider: zod.z.string(),
27
+ requiredScopes: zod.z.array(zod.z.string()).optional()
28
+ }),
29
+ zod.z.object({
30
+ type: zod.z.literal("password"),
31
+ provider: zod.z.string()
32
+ }),
33
+ zod.z.object({
34
+ type: zod.z.literal("mdl"),
35
+ issuer: zod.z.string(),
36
+ credentialType: zod.z.string().optional()
37
+ }),
38
+ zod.z.object({
39
+ type: zod.z.literal("idv"),
40
+ provider: zod.z.string(),
41
+ verificationLevel: zod.z.enum(["basic", "enhanced", "loa3"]).optional()
42
+ }),
43
+ zod.z.object({
44
+ type: zod.z.literal("verifiable_credential"),
45
+ credentialType: zod.z.string(),
46
+ issuer: zod.z.string().optional()
47
+ }),
48
+ // Deprecated: 'credential' is an alias for 'verifiable_credential'
49
+ // Will be removed in v2.0.0. Use 'verifiable_credential' instead.
50
+ zod.z.object({
51
+ type: zod.z.literal("credential"),
52
+ credentialType: zod.z.string(),
53
+ issuer: zod.z.string().optional()
54
+ }),
55
+ // WebAuthn/Passkey authentication
56
+ zod.z.object({
57
+ type: zod.z.literal("webauthn"),
58
+ rpId: zod.z.string().optional(),
59
+ userVerification: zod.z.enum(["required", "preferred", "discouraged"]).optional()
60
+ }),
61
+ // Sign-In with Ethereum (EIP-4361)
62
+ zod.z.object({
63
+ type: zod.z.literal("siwe"),
64
+ chainId: zod.z.number().optional(),
65
+ domain: zod.z.string().optional()
66
+ }),
67
+ // API Key from per-user vault
68
+ zod.z.object({
69
+ type: zod.z.literal("apikey"),
70
+ envVarNames: zod.z.array(envVarNameSchema).min(1),
71
+ headerMapping: zod.z.record(zod.z.string(), zod.z.string())
72
+ }),
73
+ zod.z.object({
74
+ type: zod.z.literal("none")
75
+ })
76
+ ]);
77
+ var ToolProtectionSchema = zod.z.object({
78
+ requiresDelegation: zod.z.boolean(),
79
+ requiredScopes: zod.z.array(zod.z.string()),
80
+ riskLevel: zod.z.enum(["low", "medium", "high", "critical"]).optional(),
81
+ oauthProvider: zod.z.string().optional(),
82
+ // Phase 2: Tool-specific OAuth provider
83
+ authorization: AuthorizationRequirementSchema.optional()
84
+ });
85
+ var ToolProtectionMapSchema = zod.z.record(zod.z.string(), ToolProtectionSchema);
86
+ zod.z.object({
87
+ toolProtections: ToolProtectionMapSchema,
88
+ metadata: zod.z.object({
89
+ lastUpdated: zod.z.string().optional(),
90
+ version: zod.z.string().optional(),
91
+ source: zod.z.string().optional()
92
+ }).optional()
93
+ });
94
+ zod.z.object({
95
+ toolName: zod.z.string(),
96
+ requiredScopes: zod.z.array(zod.z.string()),
97
+ consentUrl: zod.z.string().optional(),
98
+ authorizationUrl: zod.z.string().optional(),
99
+ reason: zod.z.string().optional()
100
+ });
101
+
102
+ // src/mcpi/dashboard-config/schemas.ts
103
+ var identityConfigSchema = zod.z.object({
104
+ /**
105
+ * @deprecated Use serverDid instead. Will be removed in v2.0
106
+ */
107
+ agentDid: zod.z.string().min(1).optional(),
108
+ serverDid: zod.z.string().min(1),
109
+ environment: zod.z.enum(["development", "production"]),
110
+ storageLocation: zod.z.enum(["cloudflare-kv", "file-system", "env-vars"])
111
+ });
112
+ var proofingConfigSchema = zod.z.object({
113
+ enabled: zod.z.boolean(),
114
+ destinations: zod.z.array(
115
+ zod.z.object({
116
+ type: zod.z.enum(["agentshield", "kta", "custom"]),
117
+ apiUrl: zod.z.string().url(),
118
+ apiKey: zod.z.string().optional()
119
+ })
120
+ ),
121
+ batchQueue: zod.z.object({
122
+ maxBatchSize: zod.z.number().int().positive().default(10),
123
+ flushIntervalMs: zod.z.number().int().positive().default(5e3),
124
+ maxRetries: zod.z.number().int().nonnegative().default(3)
125
+ })
126
+ });
127
+ var delegationVerifierTypeSchema = zod.z.enum([
128
+ "agentshield",
129
+ "kta",
130
+ "memory",
131
+ "cloudflare-kv",
132
+ "redis",
133
+ "dynamodb",
134
+ "custom"
135
+ ]);
136
+ var delegationConfigSchema = zod.z.object({
137
+ enabled: zod.z.boolean(),
138
+ enforceStrictly: zod.z.boolean(),
139
+ verifier: zod.z.object({
140
+ type: delegationVerifierTypeSchema,
141
+ apiUrl: zod.z.string().url().optional(),
142
+ cacheTtl: zod.z.number().int().positive().optional()
143
+ }),
144
+ authorization: zod.z.object({
145
+ authorizationUrl: zod.z.string().url().optional(),
146
+ minReputationScore: zod.z.number().int().min(0).max(100).optional(),
147
+ resumeTokenTtl: zod.z.number().int().positive().optional(),
148
+ requireAuthForUnknown: zod.z.boolean().optional()
149
+ })
150
+ });
151
+ var toolProtectionConfigSchema = zod.z.object({
152
+ source: zod.z.enum(["agentshield", "inline", "file"]),
153
+ agentShield: zod.z.object({
154
+ apiUrl: zod.z.string().url(),
155
+ cacheTtl: zod.z.number().int().positive()
156
+ }).optional(),
157
+ fallback: ToolProtectionMapSchema.optional()
158
+ });
159
+ var mergedToolProtectionConfigSchema = toolProtectionConfigSchema.extend({
160
+ tools: ToolProtectionMapSchema
161
+ });
162
+ var auditConfigSchema = zod.z.object({
163
+ enabled: zod.z.boolean(),
164
+ includeProofHashes: zod.z.boolean(),
165
+ includePayloads: zod.z.boolean()
166
+ });
167
+ var sessionConfigSchema = zod.z.object({
168
+ timestampSkewSeconds: zod.z.number().int().positive().default(120),
169
+ ttlMinutes: zod.z.number().int().positive().default(30),
170
+ absoluteLifetime: zod.z.number().int().positive().optional()
171
+ });
172
+ var cloudflarePlatformConfigSchema = zod.z.object({
173
+ workers: zod.z.object({
174
+ cpuMs: zod.z.number().int().positive().default(50),
175
+ memoryMb: zod.z.number().int().positive().default(128)
176
+ }),
177
+ kvNamespaces: zod.z.array(
178
+ zod.z.object({
179
+ name: zod.z.string().min(1),
180
+ purpose: zod.z.enum(["sessions", "delegations", "cache", "general"])
181
+ })
182
+ ),
183
+ environmentVariables: zod.z.array(
184
+ zod.z.object({
185
+ name: zod.z.string().min(1),
186
+ value: zod.z.string(),
187
+ source: zod.z.enum(["wrangler.toml", "secrets", ".dev.vars"])
188
+ })
189
+ )
190
+ });
191
+ var nodePlatformConfigSchema = zod.z.object({
192
+ server: zod.z.object({
193
+ port: zod.z.number().int().positive().default(3e3),
194
+ host: zod.z.string().default("0.0.0.0"),
195
+ cors: zod.z.boolean().default(true),
196
+ timeout: zod.z.number().int().positive().default(3e4)
197
+ }),
198
+ storage: zod.z.object({
199
+ type: zod.z.enum(["memory", "redis", "postgres", "mongodb"]),
200
+ connection: zod.z.object({
201
+ host: zod.z.string().optional(),
202
+ port: zod.z.number().int().positive().optional(),
203
+ database: zod.z.string().optional()
204
+ }).optional()
205
+ })
206
+ });
207
+ var vercelPlatformConfigSchema = zod.z.object({
208
+ environmentVariables: zod.z.array(
209
+ zod.z.object({
210
+ name: zod.z.string().min(1),
211
+ value: zod.z.string(),
212
+ source: zod.z.enum(["vercel-dashboard", ".env.local"])
213
+ })
214
+ ),
215
+ edgeRuntime: zod.z.object({
216
+ maxDuration: zod.z.number().int().positive().optional(),
217
+ regions: zod.z.array(zod.z.string()).optional()
218
+ }).optional()
219
+ });
220
+ var platformConfigSchema = zod.z.object({
221
+ type: zod.z.enum(["cloudflare", "node", "vercel"]),
222
+ cloudflare: cloudflarePlatformConfigSchema.optional(),
223
+ node: nodePlatformConfigSchema.optional(),
224
+ vercel: vercelPlatformConfigSchema.optional()
225
+ });
226
+ var configMetadataSchema = zod.z.object({
227
+ version: zod.z.string(),
228
+ lastUpdated: zod.z.string(),
229
+ source: zod.z.enum(["dashboard", "code", "mixed"]),
230
+ serverUrl: zod.z.string().url().optional(),
231
+ deploymentStatus: zod.z.enum(["active", "inactive", "error"]).optional()
232
+ });
233
+ var mcpIServerConfigSchema = zod.z.object({
234
+ identity: identityConfigSchema,
235
+ proofing: proofingConfigSchema,
236
+ delegation: delegationConfigSchema,
237
+ toolProtection: toolProtectionConfigSchema,
238
+ audit: auditConfigSchema,
239
+ session: sessionConfigSchema,
240
+ platform: platformConfigSchema,
241
+ metadata: configMetadataSchema
242
+ });
243
+ var mergedMcpIServerConfigSchema = mcpIServerConfigSchema.extend({
244
+ toolProtection: mergedToolProtectionConfigSchema
245
+ });
246
+ var getServerConfigRequestSchema = zod.z.object({
247
+ projectId: zod.z.string().min(1)
248
+ });
249
+ var getServerConfigResponseSchema = zod.z.object({
250
+ success: zod.z.boolean(),
251
+ data: zod.z.object({
252
+ config: mcpIServerConfigSchema
253
+ }),
254
+ metadata: zod.z.object({
255
+ requestId: zod.z.string().optional(),
256
+ timestamp: zod.z.string().optional()
257
+ }).optional()
258
+ });
259
+ var getMergedServerConfigResponseSchema = zod.z.object({
260
+ success: zod.z.boolean(),
261
+ data: zod.z.object({
262
+ config: mergedMcpIServerConfigSchema,
263
+ /** @deprecated Use config.toolProtection.tools instead */
264
+ toolProtections: ToolProtectionMapSchema.optional()
265
+ }),
266
+ metadata: zod.z.object({
267
+ requestId: zod.z.string().optional(),
268
+ timestamp: zod.z.string().optional(),
269
+ cachedUntil: zod.z.string().optional()
270
+ }).optional()
271
+ });
272
+ var updateServerConfigRequestSchema = zod.z.object({
273
+ projectId: zod.z.string().min(1),
274
+ config: mcpIServerConfigSchema.partial()
275
+ });
276
+ var updateServerConfigResponseSchema = zod.z.object({
277
+ success: zod.z.boolean(),
278
+ data: zod.z.object({
279
+ config: mcpIServerConfigSchema,
280
+ changes: zod.z.array(
281
+ zod.z.object({
282
+ path: zod.z.string(),
283
+ oldValue: zod.z.unknown(),
284
+ newValue: zod.z.unknown()
285
+ })
286
+ )
287
+ }),
288
+ metadata: zod.z.object({
289
+ requestId: zod.z.string().optional(),
290
+ timestamp: zod.z.string().optional()
291
+ }).optional()
292
+ });
293
+ var validateServerConfigRequestSchema = zod.z.object({
294
+ projectId: zod.z.string().min(1),
295
+ config: mcpIServerConfigSchema.partial()
296
+ });
297
+ var validateServerConfigResponseSchema = zod.z.object({
298
+ success: zod.z.boolean(),
299
+ data: zod.z.object({
300
+ valid: zod.z.boolean(),
301
+ errors: zod.z.array(
302
+ zod.z.object({
303
+ path: zod.z.string(),
304
+ message: zod.z.string(),
305
+ code: zod.z.string()
306
+ })
307
+ ).optional(),
308
+ warnings: zod.z.array(
309
+ zod.z.object({
310
+ path: zod.z.string(),
311
+ message: zod.z.string()
312
+ })
313
+ ).optional()
314
+ }),
315
+ metadata: zod.z.object({
316
+ requestId: zod.z.string().optional(),
317
+ timestamp: zod.z.string().optional()
318
+ }).optional()
319
+ });
320
+ var defaultConfigJson = {
321
+ identity: {
322
+ // agentDid removed - deprecated, use serverDid instead
323
+ serverDid: "",
324
+ // New field - will be populated when identity is generated
325
+ environment: "development",
326
+ storageLocation: "env-vars"
327
+ },
328
+ proofing: {
329
+ enabled: true,
330
+ destinations: [
331
+ {
332
+ type: "agentshield",
333
+ apiUrl: "https://kya.vouched.id"
334
+ }
335
+ ],
336
+ batchQueue: {
337
+ maxBatchSize: 10,
338
+ flushIntervalMs: 5e3,
339
+ maxRetries: 3
340
+ }
341
+ },
342
+ delegation: {
343
+ enabled: true,
344
+ enforceStrictly: false,
345
+ verifier: {
346
+ type: "agentshield",
347
+ apiUrl: "https://kya.vouched.id/api/v1/bouncer/delegations/verify",
348
+ cacheTtl: 3e5
349
+ },
350
+ authorization: {
351
+ authorizationUrl: "https://kya.vouched.id/api/v1/bouncer/delegations/authorize",
352
+ minReputationScore: 80,
353
+ resumeTokenTtl: 36e5,
354
+ requireAuthForUnknown: false
355
+ }
356
+ },
357
+ toolProtection: {
358
+ source: "agentshield",
359
+ agentShield: {
360
+ apiUrl: "https://kya.vouched.id",
361
+ cacheTtl: 3e5
362
+ },
363
+ fallback: {}
364
+ },
365
+ audit: {
366
+ enabled: true,
367
+ includeProofHashes: false,
368
+ includePayloads: false
369
+ },
370
+ session: {
371
+ timestampSkewSeconds: 120,
372
+ ttlMinutes: 30
373
+ },
374
+ platform: {
375
+ type: "node",
376
+ node: {
377
+ server: {
378
+ port: 3e3,
379
+ host: "0.0.0.0",
380
+ cors: true,
381
+ timeout: 3e4
382
+ },
383
+ storage: {
384
+ type: "memory"
385
+ }
386
+ },
387
+ cloudflare: {
388
+ workers: {
389
+ cpuMs: 50,
390
+ memoryMb: 128
391
+ },
392
+ kvNamespaces: [],
393
+ environmentVariables: []
394
+ },
395
+ vercel: {
396
+ environmentVariables: [],
397
+ edgeRuntime: {}
398
+ }
399
+ },
400
+ metadata: {
401
+ version: "1.0.0",
402
+ lastUpdated: "",
403
+ source: "dashboard",
404
+ deploymentStatus: "inactive"
405
+ }
406
+ };
407
+ var defaultConfigSchema = mcpIServerConfigSchema.extend({
408
+ identity: mcpIServerConfigSchema.shape.identity.extend({
409
+ agentDid: zod.z.string().optional(),
410
+ // Allow empty string or undefined for defaults (deprecated)
411
+ serverDid: zod.z.string()
412
+ // Allow empty string for defaults (will be populated later)
413
+ }),
414
+ metadata: mcpIServerConfigSchema.shape.metadata.extend({
415
+ lastUpdated: zod.z.string()
416
+ // Allow empty string (will be set dynamically)
417
+ })
418
+ });
419
+ var defaultConfig = defaultConfigSchema.parse(
420
+ defaultConfigJson
421
+ );
422
+ var platformDefaults = {
423
+ node: {
424
+ platform: {
425
+ type: "node",
426
+ node: {
427
+ server: {
428
+ port: 3e3,
429
+ host: "0.0.0.0",
430
+ cors: true,
431
+ timeout: 3e4
432
+ },
433
+ storage: {
434
+ type: "memory"
435
+ }
436
+ }
437
+ }
438
+ },
439
+ cloudflare: {
440
+ platform: {
441
+ type: "cloudflare",
442
+ cloudflare: {
443
+ workers: {
444
+ cpuMs: 50,
445
+ memoryMb: 128
446
+ },
447
+ kvNamespaces: [],
448
+ environmentVariables: []
449
+ }
450
+ }
451
+ },
452
+ vercel: {
453
+ platform: {
454
+ type: "vercel",
455
+ vercel: {
456
+ environmentVariables: [],
457
+ edgeRuntime: {}
458
+ }
459
+ }
460
+ }
461
+ };
462
+ function getDefaultConfigForPlatform(platform) {
463
+ const platformDefault = platformDefaults[platform];
464
+ return {
465
+ ...defaultConfig,
466
+ platform: platformDefault.platform
467
+ };
468
+ }
469
+ function deepMerge(target, source) {
470
+ const result = { ...target };
471
+ for (const key in source) {
472
+ const sourceValue = source[key];
473
+ if (sourceValue && typeof sourceValue === "object" && !Array.isArray(sourceValue)) {
474
+ const targetValue = target[key];
475
+ if (targetValue && typeof targetValue === "object" && !Array.isArray(targetValue)) {
476
+ result[key] = deepMerge(
477
+ targetValue,
478
+ sourceValue
479
+ );
480
+ }
481
+ } else if (sourceValue !== void 0) {
482
+ result[key] = sourceValue;
483
+ }
484
+ }
485
+ return result;
486
+ }
487
+ function mergeWithDefaults(partial) {
488
+ return deepMerge(
489
+ defaultConfig,
490
+ partial
491
+ );
492
+ }
493
+
494
+ exports.auditConfigSchema = auditConfigSchema;
495
+ exports.cloudflarePlatformConfigSchema = cloudflarePlatformConfigSchema;
496
+ exports.configMetadataSchema = configMetadataSchema;
497
+ exports.defaultConfig = defaultConfig;
498
+ exports.delegationConfigSchema = delegationConfigSchema;
499
+ exports.getDefaultConfigForPlatform = getDefaultConfigForPlatform;
500
+ exports.getMergedServerConfigResponseSchema = getMergedServerConfigResponseSchema;
501
+ exports.getServerConfigRequestSchema = getServerConfigRequestSchema;
502
+ exports.getServerConfigResponseSchema = getServerConfigResponseSchema;
503
+ exports.identityConfigSchema = identityConfigSchema;
504
+ exports.mcpIServerConfigSchema = mcpIServerConfigSchema;
505
+ exports.mergeWithDefaults = mergeWithDefaults;
506
+ exports.mergedMcpIServerConfigSchema = mergedMcpIServerConfigSchema;
507
+ exports.mergedToolProtectionConfigSchema = mergedToolProtectionConfigSchema;
508
+ exports.nodePlatformConfigSchema = nodePlatformConfigSchema;
509
+ exports.platformConfigSchema = platformConfigSchema;
510
+ exports.proofingConfigSchema = proofingConfigSchema;
511
+ exports.sessionConfigSchema = sessionConfigSchema;
512
+ exports.toolProtectionConfigSchema = toolProtectionConfigSchema;
513
+ exports.updateServerConfigRequestSchema = updateServerConfigRequestSchema;
514
+ exports.updateServerConfigResponseSchema = updateServerConfigResponseSchema;
515
+ exports.validateServerConfigRequestSchema = validateServerConfigRequestSchema;
516
+ exports.validateServerConfigResponseSchema = validateServerConfigResponseSchema;
517
+ exports.vercelPlatformConfigSchema = vercelPlatformConfigSchema;