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