@kya-os/contracts 1.0.0-alpha
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 +130 -0
- package/dist/cli.d.ts +242 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +91 -0
- package/dist/cli.js.map +1 -0
- package/dist/handshake.d.ts +153 -0
- package/dist/handshake.d.ts.map +1 -0
- package/dist/handshake.js +53 -0
- package/dist/handshake.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/proof.d.ts +155 -0
- package/dist/proof.d.ts.map +1 -0
- package/dist/proof.js +41 -0
- package/dist/proof.js.map +1 -0
- package/dist/registry.d.ts +343 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +115 -0
- package/dist/registry.js.map +1 -0
- package/dist/test.d.ts +252 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +115 -0
- package/dist/test.js.map +1 -0
- package/dist/verifier.d.ts +136 -0
- package/dist/verifier.d.ts.map +1 -0
- package/dist/verifier.js +63 -0
- package/dist/verifier.js.map +1 -0
- package/package.json +72 -0
- package/schemas/cli/register-output/v1.0.0.json +69 -0
- package/schemas/proof/v1.0.0.json +80 -0
- package/schemas/registry/receipt-v1.0.0.json +60 -0
- package/schemas/verifier/verify-page/v1.0.0.json +94 -0
- package/schemas/well-known/agent/v1.0.0.json +49 -0
package/dist/registry.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Registry integration schemas (Know-That-AI and MCP Registry)
|
|
4
|
+
*/
|
|
5
|
+
export const RegistrationInputSchema = z.object({
|
|
6
|
+
agentDID: z.string().min(1),
|
|
7
|
+
agentURL: z.string().url(),
|
|
8
|
+
verificationEndpoint: z.string().url(),
|
|
9
|
+
conformanceCapabilities: z.array(z.enum(["handshake", "signing", "verification"])),
|
|
10
|
+
metadata: z.record(z.any()).optional(),
|
|
11
|
+
});
|
|
12
|
+
export const RegistrationResultSchema = z.object({
|
|
13
|
+
agentDID: z.string().min(1),
|
|
14
|
+
agentURL: z.string().url(),
|
|
15
|
+
agentId: z.string().min(1),
|
|
16
|
+
agentSlug: z.string().min(1),
|
|
17
|
+
claimURL: z.string().url().optional(),
|
|
18
|
+
verificationEndpoint: z.string().url(),
|
|
19
|
+
conformanceCapabilities: z.tuple([
|
|
20
|
+
z.literal("handshake"),
|
|
21
|
+
z.literal("signing"),
|
|
22
|
+
z.literal("verification"),
|
|
23
|
+
]),
|
|
24
|
+
mirrorStatus: z.enum(["pending", "success", "error"]),
|
|
25
|
+
mirrorLink: z.string().url().optional(),
|
|
26
|
+
});
|
|
27
|
+
export const ClaimTokenSchema = z.object({
|
|
28
|
+
token: z.string().min(1),
|
|
29
|
+
expiresAt: z.number().int().positive(),
|
|
30
|
+
ttlHours: z.number().int().positive().default(24),
|
|
31
|
+
});
|
|
32
|
+
export const MirrorStatusSchema = z.object({
|
|
33
|
+
status: z.enum(["pending", "success", "error"]),
|
|
34
|
+
lastUpdated: z.number().int().positive(),
|
|
35
|
+
errorMessage: z.string().optional(),
|
|
36
|
+
registryURL: z.string().url().optional(),
|
|
37
|
+
});
|
|
38
|
+
export const AgentStatusSchema = z.object({
|
|
39
|
+
did: z.string().min(1),
|
|
40
|
+
keyId: z.string().min(1),
|
|
41
|
+
ktaURL: z.string().url(),
|
|
42
|
+
mirrorStatus: MirrorStatusSchema,
|
|
43
|
+
lastHandshake: z.number().int().positive().optional(),
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Delegation schemas for verifiable credentials
|
|
47
|
+
*/
|
|
48
|
+
export const DelegationSchema = z.object({
|
|
49
|
+
issuer: z.string().min(1), // DID of the issuer
|
|
50
|
+
subject: z.string().min(1), // DID of the subject
|
|
51
|
+
scopes: z.array(z.string()),
|
|
52
|
+
nbf: z.number().int().positive(), // Not before (unix timestamp)
|
|
53
|
+
exp: z.number().int().positive(), // Expires (unix timestamp)
|
|
54
|
+
aud: z.string().optional(), // Audience (optional)
|
|
55
|
+
delegationRef: z.string().optional(), // Reference to parent delegation
|
|
56
|
+
});
|
|
57
|
+
export const DelegationRequestSchema = z.object({
|
|
58
|
+
subject: z.string().min(1),
|
|
59
|
+
scopes: z.array(z.string()),
|
|
60
|
+
duration: z.number().int().positive().optional(), // Duration in seconds
|
|
61
|
+
audience: z.string().optional(),
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Storage mode configuration for verifiable credentials and delegations
|
|
65
|
+
*/
|
|
66
|
+
export const StorageModeSchema = z.enum([
|
|
67
|
+
"ktaEncrypted",
|
|
68
|
+
"hybridReceiptsOnly",
|
|
69
|
+
"selfHostedAuthoritative",
|
|
70
|
+
]);
|
|
71
|
+
/**
|
|
72
|
+
* Receipt object returned by KTA for verifiable operations
|
|
73
|
+
* Schema ID: https://schemas.kya.dev/xmcpi/receipt/v1.0.0.json
|
|
74
|
+
*/
|
|
75
|
+
export const ReceiptSchema = z.object({
|
|
76
|
+
$schema: z
|
|
77
|
+
.literal("https://schemas.kya.dev/xmcpi/receipt/v1.0.0.json")
|
|
78
|
+
.optional(),
|
|
79
|
+
ref: z.string().min(1),
|
|
80
|
+
contentHash: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
81
|
+
action: z.enum(["issue", "revoke"]),
|
|
82
|
+
ts: z.number().int().positive(),
|
|
83
|
+
logIndex: z.number().int().nonnegative(),
|
|
84
|
+
logRoot: z.string().min(1),
|
|
85
|
+
inclusionProof: z.array(z.string()),
|
|
86
|
+
});
|
|
87
|
+
export const DelegationResponseSchema = z.object({
|
|
88
|
+
delegation: DelegationSchema,
|
|
89
|
+
receipt: ReceiptSchema,
|
|
90
|
+
encryptedPayload: z.string().optional(), // For ktaEncrypted mode
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Storage configuration for different deployment modes
|
|
94
|
+
*/
|
|
95
|
+
export const StorageConfigSchema = z.object({
|
|
96
|
+
mode: StorageModeSchema,
|
|
97
|
+
encryptionEnabled: z.boolean().default(false),
|
|
98
|
+
receiptVerificationEnabled: z.boolean().default(true),
|
|
99
|
+
ktaBaseURL: z.string().url().default("https://knowthat.ai"),
|
|
100
|
+
});
|
|
101
|
+
// Constants
|
|
102
|
+
export const MCP_I_CAPABILITIES = [
|
|
103
|
+
"handshake",
|
|
104
|
+
"signing",
|
|
105
|
+
"verification",
|
|
106
|
+
];
|
|
107
|
+
export const CLAIM_TOKEN_TTL_HOURS = 24;
|
|
108
|
+
export const KTA_BASE_URL = "https://knowthat.ai"; // Placeholder for docs/tests
|
|
109
|
+
// Storage mode constants
|
|
110
|
+
export const DEFAULT_STORAGE_MODE = "ktaEncrypted";
|
|
111
|
+
export const STORAGE_MODE_ENV_VAR = "XMCPI_STORAGE_MODE";
|
|
112
|
+
// Receipt schema constants
|
|
113
|
+
export const RECEIPT_SCHEMA_ID = "https://schemas.kya.dev/xmcpi/receipt/v1.0.0.json";
|
|
114
|
+
export const CONTENT_HASH_REGEX = /^sha256:[a-f0-9]{64}$/;
|
|
115
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC1B,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACtC,uBAAuB,EAAE,CAAC,CAAC,KAAK,CAC9B,CAAC,CAAC,IAAI,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,GAAgB,cAAc,CAAC;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAEzD,2BAA2B;AAC3B,MAAM,CAAC,MAAM,iBAAiB,GAC5B,mDAAmD,CAAC;AACtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC"}
|
package/dist/test.d.ts
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test infrastructure types and schemas for XMCP-I
|
|
3
|
+
*
|
|
4
|
+
* This module provides types and utilities for testing XMCP-I applications
|
|
5
|
+
* without hitting external services like KTA.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
/**
|
|
9
|
+
* Test environment configuration
|
|
10
|
+
*/
|
|
11
|
+
export declare const TestEnvironmentSchema: z.ZodObject<{
|
|
12
|
+
mode: z.ZodLiteral<"test">;
|
|
13
|
+
seed: z.ZodOptional<z.ZodString>;
|
|
14
|
+
deterministicKeys: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
skipKTACalls: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
mode: "test";
|
|
18
|
+
deterministicKeys: boolean;
|
|
19
|
+
skipKTACalls: boolean;
|
|
20
|
+
seed?: string | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
mode: "test";
|
|
23
|
+
seed?: string | undefined;
|
|
24
|
+
deterministicKeys?: boolean | undefined;
|
|
25
|
+
skipKTACalls?: boolean | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export type TestEnvironment = z.infer<typeof TestEnvironmentSchema>;
|
|
28
|
+
/**
|
|
29
|
+
* Mock identity configuration for testing
|
|
30
|
+
*/
|
|
31
|
+
export declare const MockIdentitySchema: z.ZodObject<{
|
|
32
|
+
did: z.ZodString;
|
|
33
|
+
keyId: z.ZodString;
|
|
34
|
+
privateKey: z.ZodString;
|
|
35
|
+
publicKey: z.ZodString;
|
|
36
|
+
createdAt: z.ZodString;
|
|
37
|
+
lastRotated: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
did: string;
|
|
40
|
+
keyId: string;
|
|
41
|
+
privateKey: string;
|
|
42
|
+
publicKey: string;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
lastRotated: string;
|
|
45
|
+
}, {
|
|
46
|
+
did: string;
|
|
47
|
+
keyId: string;
|
|
48
|
+
privateKey: string;
|
|
49
|
+
publicKey: string;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
lastRotated: string;
|
|
52
|
+
}>;
|
|
53
|
+
export type MockIdentity = z.infer<typeof MockIdentitySchema>;
|
|
54
|
+
/**
|
|
55
|
+
* Mock delegation status for testing
|
|
56
|
+
*/
|
|
57
|
+
export declare const MockDelegationStatusSchema: z.ZodEnum<["active", "revoked", "pending"]>;
|
|
58
|
+
export type MockDelegationStatus = z.infer<typeof MockDelegationStatusSchema>;
|
|
59
|
+
/**
|
|
60
|
+
* Mock KTA failure scenarios for testing
|
|
61
|
+
*/
|
|
62
|
+
export declare const MockKTAFailureTypeSchema: z.ZodEnum<["network", "auth", "invalid", "timeout"]>;
|
|
63
|
+
export type MockKTAFailureType = z.infer<typeof MockKTAFailureTypeSchema>;
|
|
64
|
+
/**
|
|
65
|
+
* Mock identity provider configuration
|
|
66
|
+
*/
|
|
67
|
+
export declare const MockIdentityProviderConfigSchema: z.ZodObject<{
|
|
68
|
+
identities: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
69
|
+
did: z.ZodString;
|
|
70
|
+
keyId: z.ZodString;
|
|
71
|
+
privateKey: z.ZodString;
|
|
72
|
+
publicKey: z.ZodString;
|
|
73
|
+
createdAt: z.ZodString;
|
|
74
|
+
lastRotated: z.ZodString;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
did: string;
|
|
77
|
+
keyId: string;
|
|
78
|
+
privateKey: string;
|
|
79
|
+
publicKey: string;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
lastRotated: string;
|
|
82
|
+
}, {
|
|
83
|
+
did: string;
|
|
84
|
+
keyId: string;
|
|
85
|
+
privateKey: string;
|
|
86
|
+
publicKey: string;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
lastRotated: string;
|
|
89
|
+
}>>;
|
|
90
|
+
delegations: z.ZodRecord<z.ZodString, z.ZodEnum<["active", "revoked", "pending"]>>;
|
|
91
|
+
ktaFailures: z.ZodDefault<z.ZodArray<z.ZodEnum<["network", "auth", "invalid", "timeout"]>, "many">>;
|
|
92
|
+
deterministicSeed: z.ZodOptional<z.ZodString>;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
identities: Record<string, {
|
|
95
|
+
did: string;
|
|
96
|
+
keyId: string;
|
|
97
|
+
privateKey: string;
|
|
98
|
+
publicKey: string;
|
|
99
|
+
createdAt: string;
|
|
100
|
+
lastRotated: string;
|
|
101
|
+
}>;
|
|
102
|
+
delegations: Record<string, "pending" | "active" | "revoked">;
|
|
103
|
+
ktaFailures: ("network" | "auth" | "invalid" | "timeout")[];
|
|
104
|
+
deterministicSeed?: string | undefined;
|
|
105
|
+
}, {
|
|
106
|
+
identities: Record<string, {
|
|
107
|
+
did: string;
|
|
108
|
+
keyId: string;
|
|
109
|
+
privateKey: string;
|
|
110
|
+
publicKey: string;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
lastRotated: string;
|
|
113
|
+
}>;
|
|
114
|
+
delegations: Record<string, "pending" | "active" | "revoked">;
|
|
115
|
+
ktaFailures?: ("network" | "auth" | "invalid" | "timeout")[] | undefined;
|
|
116
|
+
deterministicSeed?: string | undefined;
|
|
117
|
+
}>;
|
|
118
|
+
export type MockIdentityProviderConfig = z.infer<typeof MockIdentityProviderConfigSchema>;
|
|
119
|
+
/**
|
|
120
|
+
* Local verification result for offline testing
|
|
121
|
+
*/
|
|
122
|
+
export declare const LocalVerificationResultSchema: z.ZodObject<{
|
|
123
|
+
valid: z.ZodBoolean;
|
|
124
|
+
did: z.ZodOptional<z.ZodString>;
|
|
125
|
+
keyId: z.ZodOptional<z.ZodString>;
|
|
126
|
+
signature: z.ZodObject<{
|
|
127
|
+
valid: z.ZodBoolean;
|
|
128
|
+
algorithm: z.ZodString;
|
|
129
|
+
error: z.ZodOptional<z.ZodString>;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
valid: boolean;
|
|
132
|
+
algorithm: string;
|
|
133
|
+
error?: string | undefined;
|
|
134
|
+
}, {
|
|
135
|
+
valid: boolean;
|
|
136
|
+
algorithm: string;
|
|
137
|
+
error?: string | undefined;
|
|
138
|
+
}>;
|
|
139
|
+
proof: z.ZodObject<{
|
|
140
|
+
valid: z.ZodBoolean;
|
|
141
|
+
structure: z.ZodBoolean;
|
|
142
|
+
timestamps: z.ZodBoolean;
|
|
143
|
+
hashes: z.ZodBoolean;
|
|
144
|
+
error: z.ZodOptional<z.ZodString>;
|
|
145
|
+
}, "strip", z.ZodTypeAny, {
|
|
146
|
+
valid: boolean;
|
|
147
|
+
structure: boolean;
|
|
148
|
+
timestamps: boolean;
|
|
149
|
+
hashes: boolean;
|
|
150
|
+
error?: string | undefined;
|
|
151
|
+
}, {
|
|
152
|
+
valid: boolean;
|
|
153
|
+
structure: boolean;
|
|
154
|
+
timestamps: boolean;
|
|
155
|
+
hashes: boolean;
|
|
156
|
+
error?: string | undefined;
|
|
157
|
+
}>;
|
|
158
|
+
session: z.ZodObject<{
|
|
159
|
+
valid: z.ZodBoolean;
|
|
160
|
+
expired: z.ZodBoolean;
|
|
161
|
+
error: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, "strip", z.ZodTypeAny, {
|
|
163
|
+
valid: boolean;
|
|
164
|
+
expired: boolean;
|
|
165
|
+
error?: string | undefined;
|
|
166
|
+
}, {
|
|
167
|
+
valid: boolean;
|
|
168
|
+
expired: boolean;
|
|
169
|
+
error?: string | undefined;
|
|
170
|
+
}>;
|
|
171
|
+
errors: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
172
|
+
warnings: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
173
|
+
}, "strip", z.ZodTypeAny, {
|
|
174
|
+
valid: boolean;
|
|
175
|
+
warnings: string[];
|
|
176
|
+
session: {
|
|
177
|
+
valid: boolean;
|
|
178
|
+
expired: boolean;
|
|
179
|
+
error?: string | undefined;
|
|
180
|
+
};
|
|
181
|
+
signature: {
|
|
182
|
+
valid: boolean;
|
|
183
|
+
algorithm: string;
|
|
184
|
+
error?: string | undefined;
|
|
185
|
+
};
|
|
186
|
+
proof: {
|
|
187
|
+
valid: boolean;
|
|
188
|
+
structure: boolean;
|
|
189
|
+
timestamps: boolean;
|
|
190
|
+
hashes: boolean;
|
|
191
|
+
error?: string | undefined;
|
|
192
|
+
};
|
|
193
|
+
errors: string[];
|
|
194
|
+
did?: string | undefined;
|
|
195
|
+
keyId?: string | undefined;
|
|
196
|
+
}, {
|
|
197
|
+
valid: boolean;
|
|
198
|
+
session: {
|
|
199
|
+
valid: boolean;
|
|
200
|
+
expired: boolean;
|
|
201
|
+
error?: string | undefined;
|
|
202
|
+
};
|
|
203
|
+
signature: {
|
|
204
|
+
valid: boolean;
|
|
205
|
+
algorithm: string;
|
|
206
|
+
error?: string | undefined;
|
|
207
|
+
};
|
|
208
|
+
proof: {
|
|
209
|
+
valid: boolean;
|
|
210
|
+
structure: boolean;
|
|
211
|
+
timestamps: boolean;
|
|
212
|
+
hashes: boolean;
|
|
213
|
+
error?: string | undefined;
|
|
214
|
+
};
|
|
215
|
+
did?: string | undefined;
|
|
216
|
+
keyId?: string | undefined;
|
|
217
|
+
warnings?: string[] | undefined;
|
|
218
|
+
errors?: string[] | undefined;
|
|
219
|
+
}>;
|
|
220
|
+
export type LocalVerificationResult = z.infer<typeof LocalVerificationResultSchema>;
|
|
221
|
+
/**
|
|
222
|
+
* Test DID and Key ID constants
|
|
223
|
+
*/
|
|
224
|
+
export declare const TEST_DIDS: {
|
|
225
|
+
readonly AGENT_1: "did:test:agent-1";
|
|
226
|
+
readonly AGENT_2: "did:test:agent-2";
|
|
227
|
+
readonly VERIFIER_1: "did:test:verifier-1";
|
|
228
|
+
};
|
|
229
|
+
export declare const TEST_KEY_IDS: {
|
|
230
|
+
readonly KEY_TEST_1: "key-test-1";
|
|
231
|
+
readonly KEY_TEST_2: "key-test-2";
|
|
232
|
+
readonly KEY_VERIFIER_1: "key-verifier-1";
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Test environment detection
|
|
236
|
+
*/
|
|
237
|
+
export declare function isTestEnvironment(): boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Get test seed from environment or test name
|
|
240
|
+
*/
|
|
241
|
+
export declare function getTestSeed(testName?: string): string;
|
|
242
|
+
/**
|
|
243
|
+
* Error codes for test infrastructure
|
|
244
|
+
*/
|
|
245
|
+
export declare const TEST_ERROR_CODES: {
|
|
246
|
+
readonly MOCK_KTA_FAILURE: "XMCP_I_TEST_MOCK_KTA_FAILURE";
|
|
247
|
+
readonly DETERMINISTIC_KEY_GENERATION_FAILED: "XMCP_I_TEST_DETERMINISTIC_KEY_FAILED";
|
|
248
|
+
readonly LOCAL_VERIFICATION_FAILED: "XMCP_I_TEST_LOCAL_VERIFICATION_FAILED";
|
|
249
|
+
readonly INVALID_TEST_CONFIGURATION: "XMCP_I_TEST_INVALID_CONFIG";
|
|
250
|
+
};
|
|
251
|
+
export type TestErrorCode = (typeof TEST_ERROR_CODES)[keyof typeof TEST_ERROR_CODES];
|
|
252
|
+
//# sourceMappingURL=test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;EAKhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,C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a,GACvB,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC"}
|
package/dist/test.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test infrastructure types and schemas for XMCP-I
|
|
3
|
+
*
|
|
4
|
+
* This module provides types and utilities for testing XMCP-I applications
|
|
5
|
+
* without hitting external services like KTA.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
/**
|
|
9
|
+
* Test environment configuration
|
|
10
|
+
*/
|
|
11
|
+
export const TestEnvironmentSchema = z.object({
|
|
12
|
+
mode: z.literal("test"),
|
|
13
|
+
seed: z.string().optional(),
|
|
14
|
+
deterministicKeys: z.boolean().default(true),
|
|
15
|
+
skipKTACalls: z.boolean().default(true),
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Mock identity configuration for testing
|
|
19
|
+
*/
|
|
20
|
+
export const MockIdentitySchema = z.object({
|
|
21
|
+
did: z.string(),
|
|
22
|
+
keyId: z.string(),
|
|
23
|
+
privateKey: z.string(),
|
|
24
|
+
publicKey: z.string(),
|
|
25
|
+
createdAt: z.string(),
|
|
26
|
+
lastRotated: z.string(),
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Mock delegation status for testing
|
|
30
|
+
*/
|
|
31
|
+
export const MockDelegationStatusSchema = z.enum([
|
|
32
|
+
"active",
|
|
33
|
+
"revoked",
|
|
34
|
+
"pending",
|
|
35
|
+
]);
|
|
36
|
+
/**
|
|
37
|
+
* Mock KTA failure scenarios for testing
|
|
38
|
+
*/
|
|
39
|
+
export const MockKTAFailureTypeSchema = z.enum([
|
|
40
|
+
"network",
|
|
41
|
+
"auth",
|
|
42
|
+
"invalid",
|
|
43
|
+
"timeout",
|
|
44
|
+
]);
|
|
45
|
+
/**
|
|
46
|
+
* Mock identity provider configuration
|
|
47
|
+
*/
|
|
48
|
+
export const MockIdentityProviderConfigSchema = z.object({
|
|
49
|
+
identities: z.record(z.string(), MockIdentitySchema),
|
|
50
|
+
delegations: z.record(z.string(), MockDelegationStatusSchema),
|
|
51
|
+
ktaFailures: z.array(MockKTAFailureTypeSchema).default([]),
|
|
52
|
+
deterministicSeed: z.string().optional(),
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Local verification result for offline testing
|
|
56
|
+
*/
|
|
57
|
+
export const LocalVerificationResultSchema = z.object({
|
|
58
|
+
valid: z.boolean(),
|
|
59
|
+
did: z.string().optional(),
|
|
60
|
+
keyId: z.string().optional(),
|
|
61
|
+
signature: z.object({
|
|
62
|
+
valid: z.boolean(),
|
|
63
|
+
algorithm: z.string(),
|
|
64
|
+
error: z.string().optional(),
|
|
65
|
+
}),
|
|
66
|
+
proof: z.object({
|
|
67
|
+
valid: z.boolean(),
|
|
68
|
+
structure: z.boolean(),
|
|
69
|
+
timestamps: z.boolean(),
|
|
70
|
+
hashes: z.boolean(),
|
|
71
|
+
error: z.string().optional(),
|
|
72
|
+
}),
|
|
73
|
+
session: z.object({
|
|
74
|
+
valid: z.boolean(),
|
|
75
|
+
expired: z.boolean(),
|
|
76
|
+
error: z.string().optional(),
|
|
77
|
+
}),
|
|
78
|
+
errors: z.array(z.string()).default([]),
|
|
79
|
+
warnings: z.array(z.string()).default([]),
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Test DID and Key ID constants
|
|
83
|
+
*/
|
|
84
|
+
export const TEST_DIDS = {
|
|
85
|
+
AGENT_1: "did:test:agent-1",
|
|
86
|
+
AGENT_2: "did:test:agent-2",
|
|
87
|
+
VERIFIER_1: "did:test:verifier-1",
|
|
88
|
+
};
|
|
89
|
+
export const TEST_KEY_IDS = {
|
|
90
|
+
KEY_TEST_1: "key-test-1",
|
|
91
|
+
KEY_TEST_2: "key-test-2",
|
|
92
|
+
KEY_VERIFIER_1: "key-verifier-1",
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Test environment detection
|
|
96
|
+
*/
|
|
97
|
+
export function isTestEnvironment() {
|
|
98
|
+
return process.env.XMCP_ENV === "test";
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get test seed from environment or test name
|
|
102
|
+
*/
|
|
103
|
+
export function getTestSeed(testName) {
|
|
104
|
+
return process.env.XMCP_TEST_SEED || testName || "default-test-seed";
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Error codes for test infrastructure
|
|
108
|
+
*/
|
|
109
|
+
export const TEST_ERROR_CODES = {
|
|
110
|
+
MOCK_KTA_FAILURE: "XMCP_I_TEST_MOCK_KTA_FAILURE",
|
|
111
|
+
DETERMINISTIC_KEY_GENERATION_FAILED: "XMCP_I_TEST_DETERMINISTIC_KEY_FAILED",
|
|
112
|
+
LOCAL_VERIFICATION_FAILED: "XMCP_I_TEST_LOCAL_VERIFICATION_FAILED",
|
|
113
|
+
INVALID_TEST_CONFIGURATION: "XMCP_I_TEST_INVALID_CONFIG",
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=test.js.map
|
package/dist/test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAC5C,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CACxC,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,C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C,QAAQ,KAAK,MAAM,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,QAAiB;IAC3C,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,QAAQ,IAAI,mBAAmB,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,gBAAgB,EAAE,8BAA8B;IAChD,mCAAmC,EAAE,sCAAsC;IAC3E,yBAAyB,EAAE,uCAAuC;IAClE,0BAA0B,EAAE,4BAA4B;CAChD,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Verifier middleware schemas and headers
|
|
4
|
+
*/
|
|
5
|
+
export declare const AgentContextSchema: z.ZodObject<{
|
|
6
|
+
did: z.ZodString;
|
|
7
|
+
keyId: z.ZodString;
|
|
8
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
9
|
+
scopes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
session: z.ZodString;
|
|
11
|
+
confidence: z.ZodLiteral<"verified">;
|
|
12
|
+
delegationRef: z.ZodOptional<z.ZodString>;
|
|
13
|
+
registry: z.ZodString;
|
|
14
|
+
verifiedAt: z.ZodNumber;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
did: string;
|
|
17
|
+
keyId: string;
|
|
18
|
+
session: string;
|
|
19
|
+
scopes: string[];
|
|
20
|
+
confidence: "verified";
|
|
21
|
+
registry: string;
|
|
22
|
+
verifiedAt: number;
|
|
23
|
+
delegationRef?: string | undefined;
|
|
24
|
+
subject?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
did: string;
|
|
27
|
+
keyId: string;
|
|
28
|
+
session: string;
|
|
29
|
+
confidence: "verified";
|
|
30
|
+
registry: string;
|
|
31
|
+
verifiedAt: number;
|
|
32
|
+
delegationRef?: string | undefined;
|
|
33
|
+
subject?: string | undefined;
|
|
34
|
+
scopes?: string[] | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
export declare const VerifierResultSchema: z.ZodObject<{
|
|
37
|
+
success: z.ZodBoolean;
|
|
38
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
39
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
code: z.ZodString;
|
|
41
|
+
message: z.ZodString;
|
|
42
|
+
details: z.ZodOptional<z.ZodAny>;
|
|
43
|
+
httpStatus: z.ZodNumber;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
code: string;
|
|
46
|
+
message: string;
|
|
47
|
+
httpStatus: number;
|
|
48
|
+
details?: any;
|
|
49
|
+
}, {
|
|
50
|
+
code: string;
|
|
51
|
+
message: string;
|
|
52
|
+
httpStatus: number;
|
|
53
|
+
details?: any;
|
|
54
|
+
}>>;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
success: boolean;
|
|
57
|
+
error?: {
|
|
58
|
+
code: string;
|
|
59
|
+
message: string;
|
|
60
|
+
httpStatus: number;
|
|
61
|
+
details?: any;
|
|
62
|
+
} | undefined;
|
|
63
|
+
headers?: Record<string, string> | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
success: boolean;
|
|
66
|
+
error?: {
|
|
67
|
+
code: string;
|
|
68
|
+
message: string;
|
|
69
|
+
httpStatus: number;
|
|
70
|
+
details?: any;
|
|
71
|
+
} | undefined;
|
|
72
|
+
headers?: Record<string, string> | undefined;
|
|
73
|
+
}>;
|
|
74
|
+
export declare const StructuredErrorSchema: z.ZodObject<{
|
|
75
|
+
code: z.ZodString;
|
|
76
|
+
message: z.ZodString;
|
|
77
|
+
details: z.ZodOptional<z.ZodObject<{
|
|
78
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
79
|
+
expected: z.ZodOptional<z.ZodAny>;
|
|
80
|
+
received: z.ZodOptional<z.ZodAny>;
|
|
81
|
+
remediation: z.ZodOptional<z.ZodString>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
expected?: any;
|
|
84
|
+
received?: any;
|
|
85
|
+
reason?: string | undefined;
|
|
86
|
+
remediation?: string | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
expected?: any;
|
|
89
|
+
received?: any;
|
|
90
|
+
reason?: string | undefined;
|
|
91
|
+
remediation?: string | undefined;
|
|
92
|
+
}>>;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
code: string;
|
|
95
|
+
message: string;
|
|
96
|
+
details?: {
|
|
97
|
+
expected?: any;
|
|
98
|
+
received?: any;
|
|
99
|
+
reason?: string | undefined;
|
|
100
|
+
remediation?: string | undefined;
|
|
101
|
+
} | undefined;
|
|
102
|
+
}, {
|
|
103
|
+
code: string;
|
|
104
|
+
message: string;
|
|
105
|
+
details?: {
|
|
106
|
+
expected?: any;
|
|
107
|
+
received?: any;
|
|
108
|
+
reason?: string | undefined;
|
|
109
|
+
remediation?: string | undefined;
|
|
110
|
+
} | undefined;
|
|
111
|
+
}>;
|
|
112
|
+
export type AgentContext = z.infer<typeof AgentContextSchema>;
|
|
113
|
+
export type VerifierResult = z.infer<typeof VerifierResultSchema>;
|
|
114
|
+
export type StructuredError = z.infer<typeof StructuredErrorSchema>;
|
|
115
|
+
export declare const AGENT_HEADERS: {
|
|
116
|
+
readonly DID: "X-Agent-DID";
|
|
117
|
+
readonly KEY_ID: "X-Agent-KeyId";
|
|
118
|
+
readonly SUBJECT: "X-Agent-Subject";
|
|
119
|
+
readonly SCOPES: "X-Agent-Scopes";
|
|
120
|
+
readonly SESSION: "X-Agent-Session";
|
|
121
|
+
readonly CONFIDENCE: "X-Agent-Confidence";
|
|
122
|
+
readonly DELEGATION_REF: "X-Agent-Delegation-Ref";
|
|
123
|
+
readonly REGISTRY: "X-Agent-Registry";
|
|
124
|
+
readonly VERIFIED_AT: "X-Agent-Verified-At";
|
|
125
|
+
};
|
|
126
|
+
export declare const ERROR_HTTP_STATUS: {
|
|
127
|
+
readonly XMCP_I_EBADPROOF: 403;
|
|
128
|
+
readonly XMCP_I_ENOIDENTITY: 500;
|
|
129
|
+
readonly XMCP_I_EMIRRORPENDING: 200;
|
|
130
|
+
readonly XMCP_I_EHANDSHAKE: 401;
|
|
131
|
+
readonly XMCP_I_ESESSION: 401;
|
|
132
|
+
readonly XMCP_I_ECLAIM: 400;
|
|
133
|
+
readonly XMCP_I_ECONFIG: 500;
|
|
134
|
+
readonly XMCP_I_ERUNTIME: 500;
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=verifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifier.d.ts","sourceRoot":"","sources":["../src/verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU7B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW/B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWhC,CAAC;AAGH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAGpE,eAAO,MAAM,aAAa;;;;;;;;;;CAUhB,CAAC;AAGX,eAAO,MAAM,iBAAiB;;;;;;;;;CASpB,CAAC"}
|