@kya-os/contracts 1.3.3 → 1.3.4
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/package.json +3 -2
- package/README.md +0 -130
- package/dist/agentshield-api/endpoints.d.ts +0 -21
- package/dist/agentshield-api/endpoints.js +0 -20
- package/dist/agentshield-api/index.d.ts +0 -5
- package/dist/agentshield-api/index.js +0 -27
- package/dist/agentshield-api/schemas.d.ts +0 -9846
- package/dist/agentshield-api/schemas.js +0 -92
- package/dist/agentshield-api/types.d.ts +0 -92
- package/dist/agentshield-api/types.js +0 -12
- package/dist/cli.d.ts +0 -375
- package/dist/cli.js +0 -109
- package/dist/config/base.d.ts +0 -19
- package/dist/config/base.js +0 -2
- package/dist/config/delegation.d.ts +0 -46
- package/dist/config/delegation.js +0 -2
- package/dist/config/identity.d.ts +0 -22
- package/dist/config/identity.js +0 -2
- package/dist/config/index.d.ts +0 -17
- package/dist/config/index.js +0 -2
- package/dist/config/proofing.d.ts +0 -26
- package/dist/config/proofing.js +0 -2
- package/dist/config/tool-protection.d.ts +0 -36
- package/dist/config/tool-protection.js +0 -2
- package/dist/delegation/constraints.d.ts +0 -726
- package/dist/delegation/constraints.js +0 -103
- package/dist/delegation/index.d.ts +0 -2
- package/dist/delegation/index.js +0 -18
- package/dist/delegation/schemas.d.ts +0 -8042
- package/dist/delegation/schemas.js +0 -232
- package/dist/did/index.d.ts +0 -3
- package/dist/did/index.js +0 -19
- package/dist/did/resolve-contract.d.ts +0 -53
- package/dist/did/resolve-contract.js +0 -12
- package/dist/did/schemas.d.ts +0 -33
- package/dist/did/schemas.js +0 -80
- package/dist/did/types.d.ts +0 -38
- package/dist/did/types.js +0 -37
- package/dist/env/constants.d.ts +0 -13
- package/dist/env/constants.js +0 -15
- package/dist/env/index.d.ts +0 -1
- package/dist/env/index.js +0 -17
- package/dist/handshake.d.ts +0 -138
- package/dist/handshake.js +0 -50
- package/dist/index.d.ts +0 -11
- package/dist/index.js +0 -28
- package/dist/proof/index.d.ts +0 -2
- package/dist/proof/index.js +0 -18
- package/dist/proof/proof-record.d.ts +0 -728
- package/dist/proof/proof-record.js +0 -60
- package/dist/proof/signing-spec.d.ts +0 -73
- package/dist/proof/signing-spec.js +0 -52
- package/dist/proof.d.ts +0 -378
- package/dist/proof.js +0 -59
- package/dist/registry.d.ts +0 -326
- package/dist/registry.js +0 -98
- package/dist/runtime/errors.d.ts +0 -179
- package/dist/runtime/errors.js +0 -51
- package/dist/runtime/headers.d.ts +0 -34
- package/dist/runtime/headers.js +0 -52
- package/dist/runtime/index.d.ts +0 -2
- package/dist/runtime/index.js +0 -18
- package/dist/test.d.ts +0 -215
- package/dist/test.js +0 -83
- package/dist/tlkrc/index.d.ts +0 -1
- package/dist/tlkrc/index.js +0 -17
- package/dist/tlkrc/rotation.d.ts +0 -168
- package/dist/tlkrc/rotation.js +0 -55
- package/dist/tool-protection/index.d.ts +0 -129
- package/dist/tool-protection/index.js +0 -80
- package/dist/utils/validation.d.ts +0 -14
- package/dist/utils/validation.js +0 -56
- package/dist/vc/index.d.ts +0 -2
- package/dist/vc/index.js +0 -18
- package/dist/vc/schemas.d.ts +0 -1888
- package/dist/vc/schemas.js +0 -116
- package/dist/vc/statuslist.d.ts +0 -292
- package/dist/vc/statuslist.js +0 -61
- package/dist/verifier.d.ts +0 -202
- package/dist/verifier.js +0 -76
- package/dist/well-known/index.d.ts +0 -248
- package/dist/well-known/index.js +0 -104
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export interface DownstreamHeaders {
|
|
2
|
-
'X-Agent-DID': string;
|
|
3
|
-
'X-Delegation-Id'?: string;
|
|
4
|
-
'X-Delegation-Chain'?: string;
|
|
5
|
-
'X-MCPI-Proof-Id': string;
|
|
6
|
-
'X-CRISP-Spend'?: string;
|
|
7
|
-
'X-Session-Id'?: string;
|
|
8
|
-
'X-Scopes'?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const DOWNSTREAM_HEADER_NAMES: Readonly<{
|
|
11
|
-
readonly AGENT_DID: "X-Agent-DID";
|
|
12
|
-
readonly DELEGATION_ID: "X-Delegation-Id";
|
|
13
|
-
readonly DELEGATION_CHAIN: "X-Delegation-Chain";
|
|
14
|
-
readonly PROOF_ID: "X-MCPI-Proof-Id";
|
|
15
|
-
readonly CRISP_SPEND: "X-CRISP-Spend";
|
|
16
|
-
readonly SESSION_ID: "X-Session-Id";
|
|
17
|
-
readonly SCOPES: "X-Scopes";
|
|
18
|
-
}>;
|
|
19
|
-
export interface CrispSpendInfo {
|
|
20
|
-
unit: 'USD' | 'ops' | 'points';
|
|
21
|
-
delta?: number;
|
|
22
|
-
remaining?: number;
|
|
23
|
-
}
|
|
24
|
-
export declare function serializeCrispSpend(info: CrispSpendInfo): string;
|
|
25
|
-
export declare function parseCrispSpend(headerValue: string): CrispSpendInfo | null;
|
|
26
|
-
export declare function createDownstreamHeaders(config: {
|
|
27
|
-
agentDid: string;
|
|
28
|
-
proofId: string;
|
|
29
|
-
delegationId?: string;
|
|
30
|
-
delegationChain?: string;
|
|
31
|
-
crispSpend?: CrispSpendInfo;
|
|
32
|
-
sessionId?: string;
|
|
33
|
-
scopes?: string[];
|
|
34
|
-
}): DownstreamHeaders;
|
package/dist/runtime/headers.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DOWNSTREAM_HEADER_NAMES = void 0;
|
|
4
|
-
exports.serializeCrispSpend = serializeCrispSpend;
|
|
5
|
-
exports.parseCrispSpend = parseCrispSpend;
|
|
6
|
-
exports.createDownstreamHeaders = createDownstreamHeaders;
|
|
7
|
-
exports.DOWNSTREAM_HEADER_NAMES = Object.freeze({
|
|
8
|
-
AGENT_DID: 'X-Agent-DID',
|
|
9
|
-
DELEGATION_ID: 'X-Delegation-Id',
|
|
10
|
-
DELEGATION_CHAIN: 'X-Delegation-Chain',
|
|
11
|
-
PROOF_ID: 'X-MCPI-Proof-Id',
|
|
12
|
-
CRISP_SPEND: 'X-CRISP-Spend',
|
|
13
|
-
SESSION_ID: 'X-Session-Id',
|
|
14
|
-
SCOPES: 'X-Scopes',
|
|
15
|
-
});
|
|
16
|
-
function serializeCrispSpend(info) {
|
|
17
|
-
return JSON.stringify(info);
|
|
18
|
-
}
|
|
19
|
-
function parseCrispSpend(headerValue) {
|
|
20
|
-
try {
|
|
21
|
-
const parsed = JSON.parse(headerValue);
|
|
22
|
-
if (parsed && typeof parsed.unit === 'string') {
|
|
23
|
-
return parsed;
|
|
24
|
-
}
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function createDownstreamHeaders(config) {
|
|
32
|
-
const headers = {
|
|
33
|
-
'X-Agent-DID': config.agentDid,
|
|
34
|
-
'X-MCPI-Proof-Id': config.proofId,
|
|
35
|
-
};
|
|
36
|
-
if (config.delegationId) {
|
|
37
|
-
headers['X-Delegation-Id'] = config.delegationId;
|
|
38
|
-
}
|
|
39
|
-
if (config.delegationChain) {
|
|
40
|
-
headers['X-Delegation-Chain'] = config.delegationChain;
|
|
41
|
-
}
|
|
42
|
-
if (config.crispSpend) {
|
|
43
|
-
headers['X-CRISP-Spend'] = serializeCrispSpend(config.crispSpend);
|
|
44
|
-
}
|
|
45
|
-
if (config.sessionId) {
|
|
46
|
-
headers['X-Session-Id'] = config.sessionId;
|
|
47
|
-
}
|
|
48
|
-
if (config.scopes && config.scopes.length > 0) {
|
|
49
|
-
headers['X-Scopes'] = config.scopes.join(',');
|
|
50
|
-
}
|
|
51
|
-
return headers;
|
|
52
|
-
}
|
package/dist/runtime/index.d.ts
DELETED
package/dist/runtime/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./errors.js"), exports);
|
|
18
|
-
__exportStar(require("./headers.js"), exports);
|
package/dist/test.d.ts
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
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];
|
package/dist/test.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TEST_ERROR_CODES = exports.TEST_KEY_IDS = exports.TEST_DIDS = exports.LocalVerificationResultSchema = exports.MockIdentityProviderConfigSchema = exports.MockKTAFailureTypeSchema = exports.MockDelegationStatusSchema = exports.MockIdentitySchema = exports.TestEnvironmentSchema = void 0;
|
|
4
|
-
exports.isTestEnvironment = isTestEnvironment;
|
|
5
|
-
exports.getTestSeed = getTestSeed;
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
exports.TestEnvironmentSchema = zod_1.z.object({
|
|
8
|
-
mode: zod_1.z.literal("test"),
|
|
9
|
-
seed: zod_1.z.string().optional(),
|
|
10
|
-
deterministicKeys: zod_1.z.boolean().default(true),
|
|
11
|
-
skipKTACalls: zod_1.z.boolean().default(true),
|
|
12
|
-
});
|
|
13
|
-
exports.MockIdentitySchema = zod_1.z.object({
|
|
14
|
-
did: zod_1.z.string(),
|
|
15
|
-
kid: zod_1.z.string(),
|
|
16
|
-
privateKey: zod_1.z.string().regex(/^[A-Za-z0-9+/]{43}=$/, "Must be a valid base64-encoded Ed25519 private key (44 characters)"),
|
|
17
|
-
publicKey: zod_1.z.string().regex(/^[A-Za-z0-9+/]{43}=$/, "Must be a valid base64-encoded Ed25519 public key (44 characters)"),
|
|
18
|
-
createdAt: zod_1.z.string(),
|
|
19
|
-
lastRotated: zod_1.z.string().optional(),
|
|
20
|
-
});
|
|
21
|
-
exports.MockDelegationStatusSchema = zod_1.z.enum([
|
|
22
|
-
"active",
|
|
23
|
-
"revoked",
|
|
24
|
-
"pending",
|
|
25
|
-
]);
|
|
26
|
-
exports.MockKTAFailureTypeSchema = zod_1.z.enum([
|
|
27
|
-
"network",
|
|
28
|
-
"auth",
|
|
29
|
-
"invalid",
|
|
30
|
-
"timeout",
|
|
31
|
-
]);
|
|
32
|
-
exports.MockIdentityProviderConfigSchema = zod_1.z.object({
|
|
33
|
-
identities: zod_1.z.record(zod_1.z.string(), exports.MockIdentitySchema),
|
|
34
|
-
delegations: zod_1.z.record(zod_1.z.string(), exports.MockDelegationStatusSchema),
|
|
35
|
-
ktaFailures: zod_1.z.array(exports.MockKTAFailureTypeSchema).default([]),
|
|
36
|
-
deterministicSeed: zod_1.z.string().optional(),
|
|
37
|
-
});
|
|
38
|
-
exports.LocalVerificationResultSchema = zod_1.z.object({
|
|
39
|
-
valid: zod_1.z.boolean(),
|
|
40
|
-
did: zod_1.z.string().optional(),
|
|
41
|
-
kid: zod_1.z.string().optional(),
|
|
42
|
-
signature: zod_1.z.object({
|
|
43
|
-
valid: zod_1.z.boolean(),
|
|
44
|
-
algorithm: zod_1.z.string(),
|
|
45
|
-
error: zod_1.z.string().optional(),
|
|
46
|
-
}),
|
|
47
|
-
proof: zod_1.z.object({
|
|
48
|
-
valid: zod_1.z.boolean(),
|
|
49
|
-
structure: zod_1.z.boolean(),
|
|
50
|
-
timestamps: zod_1.z.boolean(),
|
|
51
|
-
hashes: zod_1.z.boolean(),
|
|
52
|
-
error: zod_1.z.string().optional(),
|
|
53
|
-
}),
|
|
54
|
-
session: zod_1.z.object({
|
|
55
|
-
valid: zod_1.z.boolean(),
|
|
56
|
-
expired: zod_1.z.boolean(),
|
|
57
|
-
error: zod_1.z.string().optional(),
|
|
58
|
-
}),
|
|
59
|
-
errors: zod_1.z.array(zod_1.z.string()).default([]),
|
|
60
|
-
warnings: zod_1.z.array(zod_1.z.string()).default([]),
|
|
61
|
-
});
|
|
62
|
-
exports.TEST_DIDS = {
|
|
63
|
-
AGENT_1: "did:test:agent-1",
|
|
64
|
-
AGENT_2: "did:test:agent-2",
|
|
65
|
-
VERIFIER_1: "did:test:verifier-1",
|
|
66
|
-
};
|
|
67
|
-
exports.TEST_KEY_IDS = {
|
|
68
|
-
KEY_TEST_1: "key-test-1",
|
|
69
|
-
KEY_TEST_2: "key-test-2",
|
|
70
|
-
KEY_VERIFIER_1: "key-verifier-1",
|
|
71
|
-
};
|
|
72
|
-
function isTestEnvironment() {
|
|
73
|
-
return process.env.XMCP_ENV === "test";
|
|
74
|
-
}
|
|
75
|
-
function getTestSeed(testName) {
|
|
76
|
-
return process.env.XMCP_TEST_SEED || testName || "default-test-seed";
|
|
77
|
-
}
|
|
78
|
-
exports.TEST_ERROR_CODES = {
|
|
79
|
-
MOCK_KTA_FAILURE: "XMCP_I_TEST_MOCK_KTA_FAILURE",
|
|
80
|
-
DETERMINISTIC_KEY_GENERATION_FAILED: "XMCP_I_TEST_DETERMINISTIC_KEY_FAILED",
|
|
81
|
-
LOCAL_VERIFICATION_FAILED: "XMCP_I_TEST_LOCAL_VERIFICATION_FAILED",
|
|
82
|
-
INVALID_TEST_CONFIGURATION: "XMCP_I_TEST_INVALID_CONFIG",
|
|
83
|
-
};
|
package/dist/tlkrc/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rotation.js';
|
package/dist/tlkrc/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./rotation.js"), exports);
|
package/dist/tlkrc/rotation.d.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const RotationEventSchema: z.ZodEffects<z.ZodObject<{
|
|
3
|
-
issuerDid: z.ZodString;
|
|
4
|
-
prevKeyId: z.ZodString;
|
|
5
|
-
nextKeyId: z.ZodString;
|
|
6
|
-
effectiveAt: z.ZodNumber;
|
|
7
|
-
issuedAt: z.ZodNumber;
|
|
8
|
-
seq: z.ZodNumber;
|
|
9
|
-
prevEventHash: z.ZodOptional<z.ZodString>;
|
|
10
|
-
signature: z.ZodString;
|
|
11
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
12
|
-
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
signature: string;
|
|
14
|
-
issuerDid: string;
|
|
15
|
-
prevKeyId: string;
|
|
16
|
-
nextKeyId: string;
|
|
17
|
-
effectiveAt: number;
|
|
18
|
-
issuedAt: number;
|
|
19
|
-
seq: number;
|
|
20
|
-
metadata?: Record<string, any> | undefined;
|
|
21
|
-
prevEventHash?: string | undefined;
|
|
22
|
-
}, {
|
|
23
|
-
signature: string;
|
|
24
|
-
issuerDid: string;
|
|
25
|
-
prevKeyId: string;
|
|
26
|
-
nextKeyId: string;
|
|
27
|
-
effectiveAt: number;
|
|
28
|
-
issuedAt: number;
|
|
29
|
-
seq: number;
|
|
30
|
-
metadata?: Record<string, any> | undefined;
|
|
31
|
-
prevEventHash?: string | undefined;
|
|
32
|
-
}>, {
|
|
33
|
-
signature: string;
|
|
34
|
-
issuerDid: string;
|
|
35
|
-
prevKeyId: string;
|
|
36
|
-
nextKeyId: string;
|
|
37
|
-
effectiveAt: number;
|
|
38
|
-
issuedAt: number;
|
|
39
|
-
seq: number;
|
|
40
|
-
metadata?: Record<string, any> | undefined;
|
|
41
|
-
prevEventHash?: string | undefined;
|
|
42
|
-
}, {
|
|
43
|
-
signature: string;
|
|
44
|
-
issuerDid: string;
|
|
45
|
-
prevKeyId: string;
|
|
46
|
-
nextKeyId: string;
|
|
47
|
-
effectiveAt: number;
|
|
48
|
-
issuedAt: number;
|
|
49
|
-
seq: number;
|
|
50
|
-
metadata?: Record<string, any> | undefined;
|
|
51
|
-
prevEventHash?: string | undefined;
|
|
52
|
-
}>;
|
|
53
|
-
export type RotationEvent = z.infer<typeof RotationEventSchema>;
|
|
54
|
-
export declare const RotationChainSchema: z.ZodObject<{
|
|
55
|
-
issuerDid: z.ZodString;
|
|
56
|
-
events: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
57
|
-
issuerDid: z.ZodString;
|
|
58
|
-
prevKeyId: z.ZodString;
|
|
59
|
-
nextKeyId: z.ZodString;
|
|
60
|
-
effectiveAt: z.ZodNumber;
|
|
61
|
-
issuedAt: z.ZodNumber;
|
|
62
|
-
seq: z.ZodNumber;
|
|
63
|
-
prevEventHash: z.ZodOptional<z.ZodString>;
|
|
64
|
-
signature: z.ZodString;
|
|
65
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
66
|
-
}, "strip", z.ZodTypeAny, {
|
|
67
|
-
signature: string;
|
|
68
|
-
issuerDid: string;
|
|
69
|
-
prevKeyId: string;
|
|
70
|
-
nextKeyId: string;
|
|
71
|
-
effectiveAt: number;
|
|
72
|
-
issuedAt: number;
|
|
73
|
-
seq: number;
|
|
74
|
-
metadata?: Record<string, any> | undefined;
|
|
75
|
-
prevEventHash?: string | undefined;
|
|
76
|
-
}, {
|
|
77
|
-
signature: string;
|
|
78
|
-
issuerDid: string;
|
|
79
|
-
prevKeyId: string;
|
|
80
|
-
nextKeyId: string;
|
|
81
|
-
effectiveAt: number;
|
|
82
|
-
issuedAt: number;
|
|
83
|
-
seq: number;
|
|
84
|
-
metadata?: Record<string, any> | undefined;
|
|
85
|
-
prevEventHash?: string | undefined;
|
|
86
|
-
}>, {
|
|
87
|
-
signature: string;
|
|
88
|
-
issuerDid: string;
|
|
89
|
-
prevKeyId: string;
|
|
90
|
-
nextKeyId: string;
|
|
91
|
-
effectiveAt: number;
|
|
92
|
-
issuedAt: number;
|
|
93
|
-
seq: number;
|
|
94
|
-
metadata?: Record<string, any> | undefined;
|
|
95
|
-
prevEventHash?: string | undefined;
|
|
96
|
-
}, {
|
|
97
|
-
signature: string;
|
|
98
|
-
issuerDid: string;
|
|
99
|
-
prevKeyId: string;
|
|
100
|
-
nextKeyId: string;
|
|
101
|
-
effectiveAt: number;
|
|
102
|
-
issuedAt: number;
|
|
103
|
-
seq: number;
|
|
104
|
-
metadata?: Record<string, any> | undefined;
|
|
105
|
-
prevEventHash?: string | undefined;
|
|
106
|
-
}>, "many">;
|
|
107
|
-
currentKeyId: z.ZodString;
|
|
108
|
-
valid: z.ZodBoolean;
|
|
109
|
-
errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
110
|
-
}, "strip", z.ZodTypeAny, {
|
|
111
|
-
valid: boolean;
|
|
112
|
-
issuerDid: string;
|
|
113
|
-
events: {
|
|
114
|
-
signature: string;
|
|
115
|
-
issuerDid: string;
|
|
116
|
-
prevKeyId: string;
|
|
117
|
-
nextKeyId: string;
|
|
118
|
-
effectiveAt: number;
|
|
119
|
-
issuedAt: number;
|
|
120
|
-
seq: number;
|
|
121
|
-
metadata?: Record<string, any> | undefined;
|
|
122
|
-
prevEventHash?: string | undefined;
|
|
123
|
-
}[];
|
|
124
|
-
currentKeyId: string;
|
|
125
|
-
errors?: string[] | undefined;
|
|
126
|
-
}, {
|
|
127
|
-
valid: boolean;
|
|
128
|
-
issuerDid: string;
|
|
129
|
-
events: {
|
|
130
|
-
signature: string;
|
|
131
|
-
issuerDid: string;
|
|
132
|
-
prevKeyId: string;
|
|
133
|
-
nextKeyId: string;
|
|
134
|
-
effectiveAt: number;
|
|
135
|
-
issuedAt: number;
|
|
136
|
-
seq: number;
|
|
137
|
-
metadata?: Record<string, any> | undefined;
|
|
138
|
-
prevEventHash?: string | undefined;
|
|
139
|
-
}[];
|
|
140
|
-
currentKeyId: string;
|
|
141
|
-
errors?: string[] | undefined;
|
|
142
|
-
}>;
|
|
143
|
-
export type RotationChain = z.infer<typeof RotationChainSchema>;
|
|
144
|
-
export declare function validateRotationEvent(event: unknown): z.SafeParseReturnType<{
|
|
145
|
-
signature: string;
|
|
146
|
-
issuerDid: string;
|
|
147
|
-
prevKeyId: string;
|
|
148
|
-
nextKeyId: string;
|
|
149
|
-
effectiveAt: number;
|
|
150
|
-
issuedAt: number;
|
|
151
|
-
seq: number;
|
|
152
|
-
metadata?: Record<string, any> | undefined;
|
|
153
|
-
prevEventHash?: string | undefined;
|
|
154
|
-
}, {
|
|
155
|
-
signature: string;
|
|
156
|
-
issuerDid: string;
|
|
157
|
-
prevKeyId: string;
|
|
158
|
-
nextKeyId: string;
|
|
159
|
-
effectiveAt: number;
|
|
160
|
-
issuedAt: number;
|
|
161
|
-
seq: number;
|
|
162
|
-
metadata?: Record<string, any> | undefined;
|
|
163
|
-
prevEventHash?: string | undefined;
|
|
164
|
-
}>;
|
|
165
|
-
export declare function isRotationChainValid(chain: RotationChain): boolean;
|
|
166
|
-
export declare function getActiveKeyAt(chain: RotationChain, timestamp: number): string | null;
|
|
167
|
-
export declare const DEFAULT_GRACE_PERIOD_SEC: number;
|
|
168
|
-
export declare const MAX_GRACE_PERIOD_SEC: number;
|
package/dist/tlkrc/rotation.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_GRACE_PERIOD_SEC = exports.DEFAULT_GRACE_PERIOD_SEC = exports.RotationChainSchema = exports.RotationEventSchema = void 0;
|
|
4
|
-
exports.validateRotationEvent = validateRotationEvent;
|
|
5
|
-
exports.isRotationChainValid = isRotationChainValid;
|
|
6
|
-
exports.getActiveKeyAt = getActiveKeyAt;
|
|
7
|
-
const zod_1 = require("zod");
|
|
8
|
-
exports.RotationEventSchema = zod_1.z.object({
|
|
9
|
-
issuerDid: zod_1.z.string().min(1),
|
|
10
|
-
prevKeyId: zod_1.z.string().min(1),
|
|
11
|
-
nextKeyId: zod_1.z.string().min(1),
|
|
12
|
-
effectiveAt: zod_1.z.number().int().positive(),
|
|
13
|
-
issuedAt: zod_1.z.number().int().positive(),
|
|
14
|
-
seq: zod_1.z.number().int().nonnegative(),
|
|
15
|
-
prevEventHash: zod_1.z.string().optional(),
|
|
16
|
-
signature: zod_1.z.string().min(1),
|
|
17
|
-
metadata: zod_1.z.record(zod_1.z.any()).optional(),
|
|
18
|
-
}).refine((event) => event.effectiveAt >= event.issuedAt, {
|
|
19
|
-
message: 'effectiveAt must be >= issuedAt',
|
|
20
|
-
});
|
|
21
|
-
exports.RotationChainSchema = zod_1.z.object({
|
|
22
|
-
issuerDid: zod_1.z.string().min(1),
|
|
23
|
-
events: zod_1.z.array(exports.RotationEventSchema).min(1),
|
|
24
|
-
currentKeyId: zod_1.z.string().min(1),
|
|
25
|
-
valid: zod_1.z.boolean(),
|
|
26
|
-
errors: zod_1.z.array(zod_1.z.string()).optional(),
|
|
27
|
-
});
|
|
28
|
-
function validateRotationEvent(event) {
|
|
29
|
-
return exports.RotationEventSchema.safeParse(event);
|
|
30
|
-
}
|
|
31
|
-
function isRotationChainValid(chain) {
|
|
32
|
-
if (chain.events.length === 0) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
for (let i = 1; i < chain.events.length; i++) {
|
|
36
|
-
if (chain.events[i].seq <= chain.events[i - 1].seq) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return chain.valid;
|
|
41
|
-
}
|
|
42
|
-
function getActiveKeyAt(chain, timestamp) {
|
|
43
|
-
if (chain.events.length === 0) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
for (let i = chain.events.length - 1; i >= 0; i--) {
|
|
47
|
-
const event = chain.events[i];
|
|
48
|
-
if (event.effectiveAt <= timestamp) {
|
|
49
|
-
return event.nextKeyId;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return chain.events[0].prevKeyId;
|
|
53
|
-
}
|
|
54
|
-
exports.DEFAULT_GRACE_PERIOD_SEC = 24 * 60 * 60;
|
|
55
|
-
exports.MAX_GRACE_PERIOD_SEC = 30 * 24 * 60 * 60;
|