@kya-os/contracts 1.3.4 → 1.3.5
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/cli.d.ts +375 -0
- package/dist/cli.js +109 -0
- package/dist/handshake.d.ts +138 -0
- package/dist/handshake.js +50 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +28 -0
- package/dist/proof.d.ts +378 -0
- package/dist/proof.js +59 -0
- package/dist/registry.d.ts +326 -0
- package/dist/registry.js +98 -0
- package/dist/test.d.ts +215 -0
- package/dist/test.js +83 -0
- package/dist/utils/validation.d.ts +14 -0
- package/dist/utils/validation.js +56 -0
- package/dist/verifier.d.ts +202 -0
- package/dist/verifier.js +76 -0
- package/package.json +1 -1
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const RegistrationInputSchema: z.ZodObject<{
|
|
3
|
+
agentDID: z.ZodString;
|
|
4
|
+
agentURL: z.ZodString;
|
|
5
|
+
verificationEndpoint: z.ZodString;
|
|
6
|
+
conformanceCapabilities: z.ZodArray<z.ZodEnum<["handshake", "signing", "verification"]>, "many">;
|
|
7
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
agentDID: string;
|
|
10
|
+
agentURL: string;
|
|
11
|
+
verificationEndpoint: string;
|
|
12
|
+
conformanceCapabilities: ("handshake" | "signing" | "verification")[];
|
|
13
|
+
metadata?: Record<string, any> | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
agentDID: string;
|
|
16
|
+
agentURL: string;
|
|
17
|
+
verificationEndpoint: string;
|
|
18
|
+
conformanceCapabilities: ("handshake" | "signing" | "verification")[];
|
|
19
|
+
metadata?: Record<string, any> | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const RegistrationResultSchema: z.ZodObject<{
|
|
22
|
+
agentDID: z.ZodString;
|
|
23
|
+
agentURL: z.ZodString;
|
|
24
|
+
agentId: z.ZodString;
|
|
25
|
+
agentSlug: z.ZodString;
|
|
26
|
+
claimURL: z.ZodOptional<z.ZodString>;
|
|
27
|
+
verificationEndpoint: z.ZodString;
|
|
28
|
+
conformanceCapabilities: z.ZodTuple<[z.ZodLiteral<"handshake">, z.ZodLiteral<"signing">, z.ZodLiteral<"verification">], null>;
|
|
29
|
+
mirrorStatus: z.ZodEnum<["pending", "success", "error"]>;
|
|
30
|
+
mirrorLink: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
mirrorStatus: "success" | "pending" | "error";
|
|
33
|
+
agentDID: string;
|
|
34
|
+
agentURL: string;
|
|
35
|
+
verificationEndpoint: string;
|
|
36
|
+
conformanceCapabilities: ["handshake", "signing", "verification"];
|
|
37
|
+
agentId: string;
|
|
38
|
+
agentSlug: string;
|
|
39
|
+
claimURL?: string | undefined;
|
|
40
|
+
mirrorLink?: string | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
mirrorStatus: "success" | "pending" | "error";
|
|
43
|
+
agentDID: string;
|
|
44
|
+
agentURL: string;
|
|
45
|
+
verificationEndpoint: string;
|
|
46
|
+
conformanceCapabilities: ["handshake", "signing", "verification"];
|
|
47
|
+
agentId: string;
|
|
48
|
+
agentSlug: string;
|
|
49
|
+
claimURL?: string | undefined;
|
|
50
|
+
mirrorLink?: string | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
export declare const ClaimTokenSchema: z.ZodObject<{
|
|
53
|
+
token: z.ZodString;
|
|
54
|
+
expiresAt: z.ZodNumber;
|
|
55
|
+
ttlHours: z.ZodDefault<z.ZodNumber>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
expiresAt: number;
|
|
58
|
+
token: string;
|
|
59
|
+
ttlHours: number;
|
|
60
|
+
}, {
|
|
61
|
+
expiresAt: number;
|
|
62
|
+
token: string;
|
|
63
|
+
ttlHours?: number | undefined;
|
|
64
|
+
}>;
|
|
65
|
+
export declare const MirrorStatusSchema: z.ZodObject<{
|
|
66
|
+
status: z.ZodEnum<["pending", "success", "error"]>;
|
|
67
|
+
lastUpdated: z.ZodNumber;
|
|
68
|
+
errorMessage: z.ZodOptional<z.ZodString>;
|
|
69
|
+
registryURL: z.ZodOptional<z.ZodString>;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
status: "success" | "pending" | "error";
|
|
72
|
+
lastUpdated: number;
|
|
73
|
+
errorMessage?: string | undefined;
|
|
74
|
+
registryURL?: string | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
status: "success" | "pending" | "error";
|
|
77
|
+
lastUpdated: number;
|
|
78
|
+
errorMessage?: string | undefined;
|
|
79
|
+
registryURL?: string | undefined;
|
|
80
|
+
}>;
|
|
81
|
+
export declare const AgentStatusSchema: z.ZodObject<{
|
|
82
|
+
did: z.ZodString;
|
|
83
|
+
kid: z.ZodString;
|
|
84
|
+
ktaURL: z.ZodString;
|
|
85
|
+
mirrorStatus: z.ZodObject<{
|
|
86
|
+
status: z.ZodEnum<["pending", "success", "error"]>;
|
|
87
|
+
lastUpdated: z.ZodNumber;
|
|
88
|
+
errorMessage: z.ZodOptional<z.ZodString>;
|
|
89
|
+
registryURL: z.ZodOptional<z.ZodString>;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
status: "success" | "pending" | "error";
|
|
92
|
+
lastUpdated: number;
|
|
93
|
+
errorMessage?: string | undefined;
|
|
94
|
+
registryURL?: string | undefined;
|
|
95
|
+
}, {
|
|
96
|
+
status: "success" | "pending" | "error";
|
|
97
|
+
lastUpdated: number;
|
|
98
|
+
errorMessage?: string | undefined;
|
|
99
|
+
registryURL?: string | undefined;
|
|
100
|
+
}>;
|
|
101
|
+
lastHandshake: z.ZodOptional<z.ZodNumber>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
did: string;
|
|
104
|
+
kid: string;
|
|
105
|
+
ktaURL: string;
|
|
106
|
+
mirrorStatus: {
|
|
107
|
+
status: "success" | "pending" | "error";
|
|
108
|
+
lastUpdated: number;
|
|
109
|
+
errorMessage?: string | undefined;
|
|
110
|
+
registryURL?: string | undefined;
|
|
111
|
+
};
|
|
112
|
+
lastHandshake?: number | undefined;
|
|
113
|
+
}, {
|
|
114
|
+
did: string;
|
|
115
|
+
kid: string;
|
|
116
|
+
ktaURL: string;
|
|
117
|
+
mirrorStatus: {
|
|
118
|
+
status: "success" | "pending" | "error";
|
|
119
|
+
lastUpdated: number;
|
|
120
|
+
errorMessage?: string | undefined;
|
|
121
|
+
registryURL?: string | undefined;
|
|
122
|
+
};
|
|
123
|
+
lastHandshake?: number | undefined;
|
|
124
|
+
}>;
|
|
125
|
+
export declare const DelegationSchema: z.ZodObject<{
|
|
126
|
+
issuer: z.ZodString;
|
|
127
|
+
subject: z.ZodString;
|
|
128
|
+
scopes: z.ZodArray<z.ZodString, "many">;
|
|
129
|
+
nbf: z.ZodNumber;
|
|
130
|
+
exp: z.ZodNumber;
|
|
131
|
+
aud: z.ZodOptional<z.ZodString>;
|
|
132
|
+
delegationRef: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
subject: string;
|
|
135
|
+
scopes: string[];
|
|
136
|
+
issuer: string;
|
|
137
|
+
nbf: number;
|
|
138
|
+
exp: number;
|
|
139
|
+
delegationRef?: string | undefined;
|
|
140
|
+
aud?: string | undefined;
|
|
141
|
+
}, {
|
|
142
|
+
subject: string;
|
|
143
|
+
scopes: string[];
|
|
144
|
+
issuer: string;
|
|
145
|
+
nbf: number;
|
|
146
|
+
exp: number;
|
|
147
|
+
delegationRef?: string | undefined;
|
|
148
|
+
aud?: string | undefined;
|
|
149
|
+
}>;
|
|
150
|
+
export declare const DelegationRequestSchema: z.ZodObject<{
|
|
151
|
+
subject: z.ZodString;
|
|
152
|
+
scopes: z.ZodArray<z.ZodString, "many">;
|
|
153
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
audience: z.ZodOptional<z.ZodString>;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
subject: string;
|
|
157
|
+
scopes: string[];
|
|
158
|
+
audience?: string | undefined;
|
|
159
|
+
duration?: number | undefined;
|
|
160
|
+
}, {
|
|
161
|
+
subject: string;
|
|
162
|
+
scopes: string[];
|
|
163
|
+
audience?: string | undefined;
|
|
164
|
+
duration?: number | undefined;
|
|
165
|
+
}>;
|
|
166
|
+
export declare const StorageModeSchema: z.ZodEnum<["ktaEncrypted", "hybridReceiptsOnly", "selfHostedAuthoritative"]>;
|
|
167
|
+
export declare const ReceiptSchema: z.ZodObject<{
|
|
168
|
+
$schema: z.ZodOptional<z.ZodLiteral<"https://schemas.kya-os.ai/mcpi/receipt/v1.0.0.json">>;
|
|
169
|
+
ref: z.ZodString;
|
|
170
|
+
contentHash: z.ZodString;
|
|
171
|
+
action: z.ZodEnum<["issue", "revoke"]>;
|
|
172
|
+
ts: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
173
|
+
logIndex: z.ZodNumber;
|
|
174
|
+
logRoot: z.ZodString;
|
|
175
|
+
inclusionProof: z.ZodArray<z.ZodString, "many">;
|
|
176
|
+
}, "strip", z.ZodTypeAny, {
|
|
177
|
+
ts: string | number;
|
|
178
|
+
ref: string;
|
|
179
|
+
contentHash: string;
|
|
180
|
+
action: "issue" | "revoke";
|
|
181
|
+
logIndex: number;
|
|
182
|
+
logRoot: string;
|
|
183
|
+
inclusionProof: string[];
|
|
184
|
+
$schema?: "https://schemas.kya-os.ai/mcpi/receipt/v1.0.0.json" | undefined;
|
|
185
|
+
}, {
|
|
186
|
+
ts: string | number;
|
|
187
|
+
ref: string;
|
|
188
|
+
contentHash: string;
|
|
189
|
+
action: "issue" | "revoke";
|
|
190
|
+
logIndex: number;
|
|
191
|
+
logRoot: string;
|
|
192
|
+
inclusionProof: string[];
|
|
193
|
+
$schema?: "https://schemas.kya-os.ai/mcpi/receipt/v1.0.0.json" | undefined;
|
|
194
|
+
}>;
|
|
195
|
+
export declare const DelegationResponseSchema: z.ZodObject<{
|
|
196
|
+
delegation: z.ZodObject<{
|
|
197
|
+
issuer: z.ZodString;
|
|
198
|
+
subject: z.ZodString;
|
|
199
|
+
scopes: z.ZodArray<z.ZodString, "many">;
|
|
200
|
+
nbf: z.ZodNumber;
|
|
201
|
+
exp: z.ZodNumber;
|
|
202
|
+
aud: z.ZodOptional<z.ZodString>;
|
|
203
|
+
delegationRef: z.ZodOptional<z.ZodString>;
|
|
204
|
+
}, "strip", z.ZodTypeAny, {
|
|
205
|
+
subject: string;
|
|
206
|
+
scopes: string[];
|
|
207
|
+
issuer: string;
|
|
208
|
+
nbf: number;
|
|
209
|
+
exp: number;
|
|
210
|
+
delegationRef?: string | undefined;
|
|
211
|
+
aud?: string | undefined;
|
|
212
|
+
}, {
|
|
213
|
+
subject: string;
|
|
214
|
+
scopes: string[];
|
|
215
|
+
issuer: string;
|
|
216
|
+
nbf: number;
|
|
217
|
+
exp: number;
|
|
218
|
+
delegationRef?: string | undefined;
|
|
219
|
+
aud?: string | undefined;
|
|
220
|
+
}>;
|
|
221
|
+
receipt: z.ZodObject<{
|
|
222
|
+
$schema: z.ZodOptional<z.ZodLiteral<"https://schemas.kya-os.ai/mcpi/receipt/v1.0.0.json">>;
|
|
223
|
+
ref: z.ZodString;
|
|
224
|
+
contentHash: z.ZodString;
|
|
225
|
+
action: z.ZodEnum<["issue", "revoke"]>;
|
|
226
|
+
ts: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
227
|
+
logIndex: z.ZodNumber;
|
|
228
|
+
logRoot: z.ZodString;
|
|
229
|
+
inclusionProof: z.ZodArray<z.ZodString, "many">;
|
|
230
|
+
}, "strip", z.ZodTypeAny, {
|
|
231
|
+
ts: string | number;
|
|
232
|
+
ref: string;
|
|
233
|
+
contentHash: string;
|
|
234
|
+
action: "issue" | "revoke";
|
|
235
|
+
logIndex: number;
|
|
236
|
+
logRoot: string;
|
|
237
|
+
inclusionProof: string[];
|
|
238
|
+
$schema?: "https://schemas.kya-os.ai/mcpi/receipt/v1.0.0.json" | undefined;
|
|
239
|
+
}, {
|
|
240
|
+
ts: string | number;
|
|
241
|
+
ref: string;
|
|
242
|
+
contentHash: string;
|
|
243
|
+
action: "issue" | "revoke";
|
|
244
|
+
logIndex: number;
|
|
245
|
+
logRoot: string;
|
|
246
|
+
inclusionProof: string[];
|
|
247
|
+
$schema?: "https://schemas.kya-os.ai/mcpi/receipt/v1.0.0.json" | undefined;
|
|
248
|
+
}>;
|
|
249
|
+
encryptedPayload: z.ZodOptional<z.ZodString>;
|
|
250
|
+
}, "strip", z.ZodTypeAny, {
|
|
251
|
+
delegation: {
|
|
252
|
+
subject: string;
|
|
253
|
+
scopes: string[];
|
|
254
|
+
issuer: string;
|
|
255
|
+
nbf: number;
|
|
256
|
+
exp: number;
|
|
257
|
+
delegationRef?: string | undefined;
|
|
258
|
+
aud?: string | undefined;
|
|
259
|
+
};
|
|
260
|
+
receipt: {
|
|
261
|
+
ts: string | number;
|
|
262
|
+
ref: string;
|
|
263
|
+
contentHash: string;
|
|
264
|
+
action: "issue" | "revoke";
|
|
265
|
+
logIndex: number;
|
|
266
|
+
logRoot: string;
|
|
267
|
+
inclusionProof: string[];
|
|
268
|
+
$schema?: "https://schemas.kya-os.ai/mcpi/receipt/v1.0.0.json" | undefined;
|
|
269
|
+
};
|
|
270
|
+
encryptedPayload?: string | undefined;
|
|
271
|
+
}, {
|
|
272
|
+
delegation: {
|
|
273
|
+
subject: string;
|
|
274
|
+
scopes: string[];
|
|
275
|
+
issuer: string;
|
|
276
|
+
nbf: number;
|
|
277
|
+
exp: number;
|
|
278
|
+
delegationRef?: string | undefined;
|
|
279
|
+
aud?: string | undefined;
|
|
280
|
+
};
|
|
281
|
+
receipt: {
|
|
282
|
+
ts: string | number;
|
|
283
|
+
ref: string;
|
|
284
|
+
contentHash: string;
|
|
285
|
+
action: "issue" | "revoke";
|
|
286
|
+
logIndex: number;
|
|
287
|
+
logRoot: string;
|
|
288
|
+
inclusionProof: string[];
|
|
289
|
+
$schema?: "https://schemas.kya-os.ai/mcpi/receipt/v1.0.0.json" | undefined;
|
|
290
|
+
};
|
|
291
|
+
encryptedPayload?: string | undefined;
|
|
292
|
+
}>;
|
|
293
|
+
export declare const StorageConfigSchema: z.ZodObject<{
|
|
294
|
+
mode: z.ZodEnum<["ktaEncrypted", "hybridReceiptsOnly", "selfHostedAuthoritative"]>;
|
|
295
|
+
encryptionEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
296
|
+
receiptVerificationEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
297
|
+
ktaBaseURL: z.ZodDefault<z.ZodString>;
|
|
298
|
+
}, "strip", z.ZodTypeAny, {
|
|
299
|
+
mode: "ktaEncrypted" | "hybridReceiptsOnly" | "selfHostedAuthoritative";
|
|
300
|
+
encryptionEnabled: boolean;
|
|
301
|
+
receiptVerificationEnabled: boolean;
|
|
302
|
+
ktaBaseURL: string;
|
|
303
|
+
}, {
|
|
304
|
+
mode: "ktaEncrypted" | "hybridReceiptsOnly" | "selfHostedAuthoritative";
|
|
305
|
+
encryptionEnabled?: boolean | undefined;
|
|
306
|
+
receiptVerificationEnabled?: boolean | undefined;
|
|
307
|
+
ktaBaseURL?: string | undefined;
|
|
308
|
+
}>;
|
|
309
|
+
export type RegistrationInput = z.infer<typeof RegistrationInputSchema>;
|
|
310
|
+
export type RegistrationResult = z.infer<typeof RegistrationResultSchema>;
|
|
311
|
+
export type ClaimToken = z.infer<typeof ClaimTokenSchema>;
|
|
312
|
+
export type MirrorStatus = z.infer<typeof MirrorStatusSchema>;
|
|
313
|
+
export type AgentStatus = z.infer<typeof AgentStatusSchema>;
|
|
314
|
+
export type StorageMode = z.infer<typeof StorageModeSchema>;
|
|
315
|
+
export type Receipt = z.infer<typeof ReceiptSchema>;
|
|
316
|
+
export type StorageConfig = z.infer<typeof StorageConfigSchema>;
|
|
317
|
+
export type Delegation = z.infer<typeof DelegationSchema>;
|
|
318
|
+
export type DelegationRequest = z.infer<typeof DelegationRequestSchema>;
|
|
319
|
+
export type DelegationResponse = z.infer<typeof DelegationResponseSchema>;
|
|
320
|
+
export declare const MCP_I_CAPABILITIES: readonly ["handshake", "signing", "verification"];
|
|
321
|
+
export declare const CLAIM_TOKEN_TTL_HOURS = 24;
|
|
322
|
+
export declare const KTA_BASE_URL = "https://knowthat.ai";
|
|
323
|
+
export declare const DEFAULT_STORAGE_MODE: StorageMode;
|
|
324
|
+
export declare const STORAGE_MODE_ENV_VAR = "MCPI_STORAGE_MODE";
|
|
325
|
+
export declare const RECEIPT_SCHEMA_ID = "https://schemas.kya-os.ai/mcpi/receipt/v1.0.0.json";
|
|
326
|
+
export declare const CONTENT_HASH_REGEX: RegExp;
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONTENT_HASH_REGEX = exports.RECEIPT_SCHEMA_ID = exports.STORAGE_MODE_ENV_VAR = exports.DEFAULT_STORAGE_MODE = exports.KTA_BASE_URL = exports.CLAIM_TOKEN_TTL_HOURS = exports.MCP_I_CAPABILITIES = exports.StorageConfigSchema = exports.DelegationResponseSchema = exports.ReceiptSchema = exports.StorageModeSchema = exports.DelegationRequestSchema = exports.DelegationSchema = exports.AgentStatusSchema = exports.MirrorStatusSchema = exports.ClaimTokenSchema = exports.RegistrationResultSchema = exports.RegistrationInputSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.RegistrationInputSchema = zod_1.z.object({
|
|
6
|
+
agentDID: zod_1.z.string().min(1),
|
|
7
|
+
agentURL: zod_1.z.string().url(),
|
|
8
|
+
verificationEndpoint: zod_1.z.string().url(),
|
|
9
|
+
conformanceCapabilities: zod_1.z.array(zod_1.z.enum(["handshake", "signing", "verification"])),
|
|
10
|
+
metadata: zod_1.z.record(zod_1.z.any()).optional(),
|
|
11
|
+
});
|
|
12
|
+
exports.RegistrationResultSchema = zod_1.z.object({
|
|
13
|
+
agentDID: zod_1.z.string().min(1),
|
|
14
|
+
agentURL: zod_1.z.string().url(),
|
|
15
|
+
agentId: zod_1.z.string().min(1),
|
|
16
|
+
agentSlug: zod_1.z.string().min(1),
|
|
17
|
+
claimURL: zod_1.z.string().url().optional(),
|
|
18
|
+
verificationEndpoint: zod_1.z.string().url(),
|
|
19
|
+
conformanceCapabilities: zod_1.z.tuple([
|
|
20
|
+
zod_1.z.literal("handshake"),
|
|
21
|
+
zod_1.z.literal("signing"),
|
|
22
|
+
zod_1.z.literal("verification"),
|
|
23
|
+
]),
|
|
24
|
+
mirrorStatus: zod_1.z.enum(["pending", "success", "error"]),
|
|
25
|
+
mirrorLink: zod_1.z.string().url().optional(),
|
|
26
|
+
});
|
|
27
|
+
exports.ClaimTokenSchema = zod_1.z.object({
|
|
28
|
+
token: zod_1.z.string().min(1),
|
|
29
|
+
expiresAt: zod_1.z.number().int().positive(),
|
|
30
|
+
ttlHours: zod_1.z.number().int().positive().default(24),
|
|
31
|
+
});
|
|
32
|
+
exports.MirrorStatusSchema = zod_1.z.object({
|
|
33
|
+
status: zod_1.z.enum(["pending", "success", "error"]),
|
|
34
|
+
lastUpdated: zod_1.z.number().int().positive(),
|
|
35
|
+
errorMessage: zod_1.z.string().optional(),
|
|
36
|
+
registryURL: zod_1.z.string().url().optional(),
|
|
37
|
+
});
|
|
38
|
+
exports.AgentStatusSchema = zod_1.z.object({
|
|
39
|
+
did: zod_1.z.string().min(1),
|
|
40
|
+
kid: zod_1.z.string().min(1),
|
|
41
|
+
ktaURL: zod_1.z.string().url(),
|
|
42
|
+
mirrorStatus: exports.MirrorStatusSchema,
|
|
43
|
+
lastHandshake: zod_1.z.number().int().positive().optional(),
|
|
44
|
+
});
|
|
45
|
+
exports.DelegationSchema = zod_1.z.object({
|
|
46
|
+
issuer: zod_1.z.string().min(1),
|
|
47
|
+
subject: zod_1.z.string().min(1),
|
|
48
|
+
scopes: zod_1.z.array(zod_1.z.string()),
|
|
49
|
+
nbf: zod_1.z.number().int().positive(),
|
|
50
|
+
exp: zod_1.z.number().int().positive(),
|
|
51
|
+
aud: zod_1.z.string().optional(),
|
|
52
|
+
delegationRef: zod_1.z.string().optional(),
|
|
53
|
+
});
|
|
54
|
+
exports.DelegationRequestSchema = zod_1.z.object({
|
|
55
|
+
subject: zod_1.z.string().min(1),
|
|
56
|
+
scopes: zod_1.z.array(zod_1.z.string()),
|
|
57
|
+
duration: zod_1.z.number().int().positive().optional(),
|
|
58
|
+
audience: zod_1.z.string().optional(),
|
|
59
|
+
});
|
|
60
|
+
exports.StorageModeSchema = zod_1.z.enum([
|
|
61
|
+
"ktaEncrypted",
|
|
62
|
+
"hybridReceiptsOnly",
|
|
63
|
+
"selfHostedAuthoritative",
|
|
64
|
+
]);
|
|
65
|
+
exports.ReceiptSchema = zod_1.z.object({
|
|
66
|
+
$schema: zod_1.z
|
|
67
|
+
.literal("https://schemas.kya-os.ai/mcpi/receipt/v1.0.0.json")
|
|
68
|
+
.optional(),
|
|
69
|
+
ref: zod_1.z.string().min(1),
|
|
70
|
+
contentHash: zod_1.z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
71
|
+
action: zod_1.z.enum(["issue", "revoke"]),
|
|
72
|
+
ts: zod_1.z.union([zod_1.z.string().datetime(), zod_1.z.number().int().positive()]),
|
|
73
|
+
logIndex: zod_1.z.number().int().nonnegative(),
|
|
74
|
+
logRoot: zod_1.z.string().min(1),
|
|
75
|
+
inclusionProof: zod_1.z.array(zod_1.z.string()),
|
|
76
|
+
});
|
|
77
|
+
exports.DelegationResponseSchema = zod_1.z.object({
|
|
78
|
+
delegation: exports.DelegationSchema,
|
|
79
|
+
receipt: exports.ReceiptSchema,
|
|
80
|
+
encryptedPayload: zod_1.z.string().optional(),
|
|
81
|
+
});
|
|
82
|
+
exports.StorageConfigSchema = zod_1.z.object({
|
|
83
|
+
mode: exports.StorageModeSchema,
|
|
84
|
+
encryptionEnabled: zod_1.z.boolean().default(false),
|
|
85
|
+
receiptVerificationEnabled: zod_1.z.boolean().default(true),
|
|
86
|
+
ktaBaseURL: zod_1.z.string().url().default("https://knowthat.ai"),
|
|
87
|
+
});
|
|
88
|
+
exports.MCP_I_CAPABILITIES = [
|
|
89
|
+
"handshake",
|
|
90
|
+
"signing",
|
|
91
|
+
"verification",
|
|
92
|
+
];
|
|
93
|
+
exports.CLAIM_TOKEN_TTL_HOURS = 24;
|
|
94
|
+
exports.KTA_BASE_URL = "https://knowthat.ai";
|
|
95
|
+
exports.DEFAULT_STORAGE_MODE = "ktaEncrypted";
|
|
96
|
+
exports.STORAGE_MODE_ENV_VAR = "MCPI_STORAGE_MODE";
|
|
97
|
+
exports.RECEIPT_SCHEMA_ID = "https://schemas.kya-os.ai/mcpi/receipt/v1.0.0.json";
|
|
98
|
+
exports.CONTENT_HASH_REGEX = /^sha256:[a-f0-9]{64}$/;
|
package/dist/test.d.ts
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const TestEnvironmentSchema: z.ZodObject<{
|
|
3
|
+
mode: z.ZodLiteral<"test">;
|
|
4
|
+
seed: z.ZodOptional<z.ZodString>;
|
|
5
|
+
deterministicKeys: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
skipKTACalls: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
mode: "test";
|
|
9
|
+
deterministicKeys: boolean;
|
|
10
|
+
skipKTACalls: boolean;
|
|
11
|
+
seed?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
mode: "test";
|
|
14
|
+
seed?: string | undefined;
|
|
15
|
+
deterministicKeys?: boolean | undefined;
|
|
16
|
+
skipKTACalls?: boolean | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export type TestEnvironment = z.infer<typeof TestEnvironmentSchema>;
|
|
19
|
+
export declare const MockIdentitySchema: z.ZodObject<{
|
|
20
|
+
did: z.ZodString;
|
|
21
|
+
kid: z.ZodString;
|
|
22
|
+
privateKey: z.ZodString;
|
|
23
|
+
publicKey: z.ZodString;
|
|
24
|
+
createdAt: z.ZodString;
|
|
25
|
+
lastRotated: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
did: string;
|
|
28
|
+
kid: string;
|
|
29
|
+
privateKey: string;
|
|
30
|
+
publicKey: string;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
lastRotated?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
did: string;
|
|
35
|
+
kid: string;
|
|
36
|
+
privateKey: string;
|
|
37
|
+
publicKey: string;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
lastRotated?: string | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
export type MockIdentity = z.infer<typeof MockIdentitySchema>;
|
|
42
|
+
export declare const MockDelegationStatusSchema: z.ZodEnum<["active", "revoked", "pending"]>;
|
|
43
|
+
export type MockDelegationStatus = z.infer<typeof MockDelegationStatusSchema>;
|
|
44
|
+
export declare const MockKTAFailureTypeSchema: z.ZodEnum<["network", "auth", "invalid", "timeout"]>;
|
|
45
|
+
export type MockKTAFailureType = z.infer<typeof MockKTAFailureTypeSchema>;
|
|
46
|
+
export declare const MockIdentityProviderConfigSchema: z.ZodObject<{
|
|
47
|
+
identities: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
48
|
+
did: z.ZodString;
|
|
49
|
+
kid: z.ZodString;
|
|
50
|
+
privateKey: z.ZodString;
|
|
51
|
+
publicKey: z.ZodString;
|
|
52
|
+
createdAt: z.ZodString;
|
|
53
|
+
lastRotated: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
did: string;
|
|
56
|
+
kid: string;
|
|
57
|
+
privateKey: string;
|
|
58
|
+
publicKey: string;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
lastRotated?: string | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
did: string;
|
|
63
|
+
kid: string;
|
|
64
|
+
privateKey: string;
|
|
65
|
+
publicKey: string;
|
|
66
|
+
createdAt: string;
|
|
67
|
+
lastRotated?: string | undefined;
|
|
68
|
+
}>>;
|
|
69
|
+
delegations: z.ZodRecord<z.ZodString, z.ZodEnum<["active", "revoked", "pending"]>>;
|
|
70
|
+
ktaFailures: z.ZodDefault<z.ZodArray<z.ZodEnum<["network", "auth", "invalid", "timeout"]>, "many">>;
|
|
71
|
+
deterministicSeed: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
identities: Record<string, {
|
|
74
|
+
did: string;
|
|
75
|
+
kid: string;
|
|
76
|
+
privateKey: string;
|
|
77
|
+
publicKey: string;
|
|
78
|
+
createdAt: string;
|
|
79
|
+
lastRotated?: string | undefined;
|
|
80
|
+
}>;
|
|
81
|
+
delegations: Record<string, "pending" | "active" | "revoked">;
|
|
82
|
+
ktaFailures: ("network" | "auth" | "invalid" | "timeout")[];
|
|
83
|
+
deterministicSeed?: string | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
identities: Record<string, {
|
|
86
|
+
did: string;
|
|
87
|
+
kid: string;
|
|
88
|
+
privateKey: string;
|
|
89
|
+
publicKey: string;
|
|
90
|
+
createdAt: string;
|
|
91
|
+
lastRotated?: string | undefined;
|
|
92
|
+
}>;
|
|
93
|
+
delegations: Record<string, "pending" | "active" | "revoked">;
|
|
94
|
+
ktaFailures?: ("network" | "auth" | "invalid" | "timeout")[] | undefined;
|
|
95
|
+
deterministicSeed?: string | undefined;
|
|
96
|
+
}>;
|
|
97
|
+
export type MockIdentityProviderConfig = z.infer<typeof MockIdentityProviderConfigSchema>;
|
|
98
|
+
export declare const LocalVerificationResultSchema: z.ZodObject<{
|
|
99
|
+
valid: z.ZodBoolean;
|
|
100
|
+
did: z.ZodOptional<z.ZodString>;
|
|
101
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
102
|
+
signature: z.ZodObject<{
|
|
103
|
+
valid: z.ZodBoolean;
|
|
104
|
+
algorithm: z.ZodString;
|
|
105
|
+
error: z.ZodOptional<z.ZodString>;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
valid: boolean;
|
|
108
|
+
algorithm: string;
|
|
109
|
+
error?: string | undefined;
|
|
110
|
+
}, {
|
|
111
|
+
valid: boolean;
|
|
112
|
+
algorithm: string;
|
|
113
|
+
error?: string | undefined;
|
|
114
|
+
}>;
|
|
115
|
+
proof: z.ZodObject<{
|
|
116
|
+
valid: z.ZodBoolean;
|
|
117
|
+
structure: z.ZodBoolean;
|
|
118
|
+
timestamps: z.ZodBoolean;
|
|
119
|
+
hashes: z.ZodBoolean;
|
|
120
|
+
error: z.ZodOptional<z.ZodString>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
valid: boolean;
|
|
123
|
+
structure: boolean;
|
|
124
|
+
timestamps: boolean;
|
|
125
|
+
hashes: boolean;
|
|
126
|
+
error?: string | undefined;
|
|
127
|
+
}, {
|
|
128
|
+
valid: boolean;
|
|
129
|
+
structure: boolean;
|
|
130
|
+
timestamps: boolean;
|
|
131
|
+
hashes: boolean;
|
|
132
|
+
error?: string | undefined;
|
|
133
|
+
}>;
|
|
134
|
+
session: z.ZodObject<{
|
|
135
|
+
valid: z.ZodBoolean;
|
|
136
|
+
expired: z.ZodBoolean;
|
|
137
|
+
error: z.ZodOptional<z.ZodString>;
|
|
138
|
+
}, "strip", z.ZodTypeAny, {
|
|
139
|
+
valid: boolean;
|
|
140
|
+
expired: boolean;
|
|
141
|
+
error?: string | undefined;
|
|
142
|
+
}, {
|
|
143
|
+
valid: boolean;
|
|
144
|
+
expired: boolean;
|
|
145
|
+
error?: string | undefined;
|
|
146
|
+
}>;
|
|
147
|
+
errors: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
148
|
+
warnings: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
149
|
+
}, "strip", z.ZodTypeAny, {
|
|
150
|
+
valid: boolean;
|
|
151
|
+
warnings: string[];
|
|
152
|
+
session: {
|
|
153
|
+
valid: boolean;
|
|
154
|
+
expired: boolean;
|
|
155
|
+
error?: string | undefined;
|
|
156
|
+
};
|
|
157
|
+
signature: {
|
|
158
|
+
valid: boolean;
|
|
159
|
+
algorithm: string;
|
|
160
|
+
error?: string | undefined;
|
|
161
|
+
};
|
|
162
|
+
proof: {
|
|
163
|
+
valid: boolean;
|
|
164
|
+
structure: boolean;
|
|
165
|
+
timestamps: boolean;
|
|
166
|
+
hashes: boolean;
|
|
167
|
+
error?: string | undefined;
|
|
168
|
+
};
|
|
169
|
+
errors: string[];
|
|
170
|
+
did?: string | undefined;
|
|
171
|
+
kid?: string | undefined;
|
|
172
|
+
}, {
|
|
173
|
+
valid: boolean;
|
|
174
|
+
session: {
|
|
175
|
+
valid: boolean;
|
|
176
|
+
expired: boolean;
|
|
177
|
+
error?: string | undefined;
|
|
178
|
+
};
|
|
179
|
+
signature: {
|
|
180
|
+
valid: boolean;
|
|
181
|
+
algorithm: string;
|
|
182
|
+
error?: string | undefined;
|
|
183
|
+
};
|
|
184
|
+
proof: {
|
|
185
|
+
valid: boolean;
|
|
186
|
+
structure: boolean;
|
|
187
|
+
timestamps: boolean;
|
|
188
|
+
hashes: boolean;
|
|
189
|
+
error?: string | undefined;
|
|
190
|
+
};
|
|
191
|
+
did?: string | undefined;
|
|
192
|
+
kid?: string | undefined;
|
|
193
|
+
warnings?: string[] | undefined;
|
|
194
|
+
errors?: string[] | undefined;
|
|
195
|
+
}>;
|
|
196
|
+
export type LocalVerificationResult = z.infer<typeof LocalVerificationResultSchema>;
|
|
197
|
+
export declare const TEST_DIDS: {
|
|
198
|
+
readonly AGENT_1: "did:test:agent-1";
|
|
199
|
+
readonly AGENT_2: "did:test:agent-2";
|
|
200
|
+
readonly VERIFIER_1: "did:test:verifier-1";
|
|
201
|
+
};
|
|
202
|
+
export declare const TEST_KEY_IDS: {
|
|
203
|
+
readonly KEY_TEST_1: "key-test-1";
|
|
204
|
+
readonly KEY_TEST_2: "key-test-2";
|
|
205
|
+
readonly KEY_VERIFIER_1: "key-verifier-1";
|
|
206
|
+
};
|
|
207
|
+
export declare function isTestEnvironment(): boolean;
|
|
208
|
+
export declare function getTestSeed(testName?: string): string;
|
|
209
|
+
export declare const TEST_ERROR_CODES: {
|
|
210
|
+
readonly MOCK_KTA_FAILURE: "XMCP_I_TEST_MOCK_KTA_FAILURE";
|
|
211
|
+
readonly DETERMINISTIC_KEY_GENERATION_FAILED: "XMCP_I_TEST_DETERMINISTIC_KEY_FAILED";
|
|
212
|
+
readonly LOCAL_VERIFICATION_FAILED: "XMCP_I_TEST_LOCAL_VERIFICATION_FAILED";
|
|
213
|
+
readonly INVALID_TEST_CONFIGURATION: "XMCP_I_TEST_INVALID_CONFIG";
|
|
214
|
+
};
|
|
215
|
+
export type TestErrorCode = (typeof TEST_ERROR_CODES)[keyof typeof TEST_ERROR_CODES];
|