@kya-os/contracts 1.3.2 → 1.3.3
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/agentshield-api/endpoints.d.ts +21 -0
- package/dist/agentshield-api/endpoints.js +20 -0
- package/dist/agentshield-api/index.d.ts +5 -0
- package/dist/agentshield-api/index.js +27 -0
- package/dist/agentshield-api/schemas.d.ts +9846 -0
- package/dist/agentshield-api/schemas.js +92 -0
- package/dist/agentshield-api/types.d.ts +92 -0
- package/dist/agentshield-api/types.js +12 -0
- package/dist/cli.d.ts +3 -6
- package/dist/cli.js +3 -10
- package/dist/config/base.d.ts +19 -0
- package/dist/config/base.js +2 -0
- package/dist/config/delegation.d.ts +46 -0
- package/dist/config/delegation.js +2 -0
- package/dist/config/identity.d.ts +22 -0
- package/dist/config/identity.js +2 -0
- package/dist/config/index.d.ts +17 -0
- package/dist/config/index.js +2 -0
- package/dist/config/proofing.d.ts +26 -0
- package/dist/config/proofing.js +2 -0
- package/dist/config/tool-protection.d.ts +36 -0
- package/dist/config/tool-protection.js +2 -0
- package/dist/delegation/constraints.d.ts +0 -266
- package/dist/delegation/constraints.js +3 -110
- package/dist/delegation/index.d.ts +0 -6
- package/dist/delegation/index.js +0 -6
- package/dist/delegation/schemas.d.ts +174 -514
- package/dist/delegation/schemas.js +3 -247
- package/dist/did/index.d.ts +0 -6
- package/dist/did/index.js +0 -6
- package/dist/did/resolve-contract.d.ts +0 -167
- package/dist/did/resolve-contract.js +0 -20
- package/dist/did/schemas.d.ts +0 -80
- package/dist/did/schemas.js +4 -97
- package/dist/did/types.d.ts +0 -126
- package/dist/did/types.js +0 -34
- package/dist/env/constants.d.ts +0 -45
- package/dist/env/constants.js +0 -45
- package/dist/env/index.d.ts +0 -4
- package/dist/env/index.js +0 -4
- package/dist/handshake.d.ts +0 -21
- package/dist/handshake.js +3 -11
- package/dist/index.d.ts +0 -15
- package/dist/index.js +0 -25
- package/dist/proof/index.d.ts +0 -7
- package/dist/proof/index.js +0 -7
- package/dist/proof/proof-record.d.ts +62 -172
- package/dist/proof/proof-record.js +0 -74
- package/dist/proof/signing-spec.d.ts +12 -86
- package/dist/proof/signing-spec.js +0 -71
- package/dist/proof.d.ts +16 -38
- package/dist/proof.js +3 -26
- package/dist/registry.d.ts +10 -27
- package/dist/registry.js +9 -30
- package/dist/runtime/errors.d.ts +0 -169
- package/dist/runtime/errors.js +0 -69
- package/dist/runtime/headers.d.ts +0 -50
- package/dist/runtime/headers.js +0 -30
- package/dist/runtime/index.d.ts +0 -4
- package/dist/runtime/index.js +0 -4
- package/dist/test.d.ts +0 -37
- package/dist/test.js +0 -37
- package/dist/tlkrc/index.d.ts +0 -4
- package/dist/tlkrc/index.js +0 -4
- package/dist/tlkrc/rotation.d.ts +12 -90
- package/dist/tlkrc/rotation.js +0 -72
- package/dist/tool-protection/index.d.ts +129 -0
- package/dist/tool-protection/index.js +80 -0
- package/dist/utils/validation.d.ts +0 -17
- package/dist/utils/validation.js +0 -14
- package/dist/vc/index.d.ts +0 -6
- package/dist/vc/index.js +0 -6
- package/dist/vc/schemas.d.ts +0 -596
- package/dist/vc/schemas.js +2 -111
- package/dist/vc/statuslist.d.ts +0 -202
- package/dist/vc/statuslist.js +1 -73
- package/dist/verifier.d.ts +9 -13
- package/dist/verifier.js +0 -8
- package/dist/well-known/index.d.ts +248 -0
- package/dist/well-known/index.js +104 -0
- package/package.json +27 -5
package/dist/tlkrc/rotation.d.ts
CHANGED
|
@@ -1,44 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TLKRC (Transparent Log Key Rotation Contract)
|
|
3
|
-
*
|
|
4
|
-
* Types for key rotation events in a transparent, auditable manner
|
|
5
|
-
*
|
|
6
|
-
* Related Spec: MCP-I Core
|
|
7
|
-
* Python Reference: Core-Documentation.md
|
|
8
|
-
*/
|
|
9
1
|
import { z } from 'zod';
|
|
10
|
-
/**
|
|
11
|
-
* Rotation Event Schema
|
|
12
|
-
*
|
|
13
|
-
* Represents a key rotation event in a transparent log.
|
|
14
|
-
* Events form a hash-linked chain for auditability.
|
|
15
|
-
*
|
|
16
|
-
* **Dual-Key Grace Window:**
|
|
17
|
-
* During rotation, both `prevKeyId` and `nextKeyId` are valid
|
|
18
|
-
* from `effectiveAt` until `effectiveAt + grace period`.
|
|
19
|
-
*/
|
|
20
2
|
export declare const RotationEventSchema: z.ZodEffects<z.ZodObject<{
|
|
21
|
-
/** DID of the issuer performing the rotation */
|
|
22
3
|
issuerDid: z.ZodString;
|
|
23
|
-
/** Previous key ID being rotated out */
|
|
24
4
|
prevKeyId: z.ZodString;
|
|
25
|
-
/** New key ID being rotated in */
|
|
26
5
|
nextKeyId: z.ZodString;
|
|
27
|
-
/** Timestamp when new key becomes effective (Unix seconds) */
|
|
28
6
|
effectiveAt: z.ZodNumber;
|
|
29
|
-
/** Timestamp when event was issued (Unix seconds) */
|
|
30
7
|
issuedAt: z.ZodNumber;
|
|
31
|
-
/** Sequence number (monotonically increasing) */
|
|
32
8
|
seq: z.ZodNumber;
|
|
33
|
-
/** Hash of previous rotation event (null for first rotation) */
|
|
34
9
|
prevEventHash: z.ZodOptional<z.ZodString>;
|
|
35
|
-
/** Signature over the event (using prevKeyId) */
|
|
36
10
|
signature: z.ZodString;
|
|
37
|
-
/** Optional metadata */
|
|
38
11
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
39
12
|
}, "strip", z.ZodTypeAny, {
|
|
40
|
-
issuerDid: string;
|
|
41
13
|
signature: string;
|
|
14
|
+
issuerDid: string;
|
|
42
15
|
prevKeyId: string;
|
|
43
16
|
nextKeyId: string;
|
|
44
17
|
effectiveAt: number;
|
|
@@ -47,8 +20,8 @@ export declare const RotationEventSchema: z.ZodEffects<z.ZodObject<{
|
|
|
47
20
|
metadata?: Record<string, any> | undefined;
|
|
48
21
|
prevEventHash?: string | undefined;
|
|
49
22
|
}, {
|
|
50
|
-
issuerDid: string;
|
|
51
23
|
signature: string;
|
|
24
|
+
issuerDid: string;
|
|
52
25
|
prevKeyId: string;
|
|
53
26
|
nextKeyId: string;
|
|
54
27
|
effectiveAt: number;
|
|
@@ -57,8 +30,8 @@ export declare const RotationEventSchema: z.ZodEffects<z.ZodObject<{
|
|
|
57
30
|
metadata?: Record<string, any> | undefined;
|
|
58
31
|
prevEventHash?: string | undefined;
|
|
59
32
|
}>, {
|
|
60
|
-
issuerDid: string;
|
|
61
33
|
signature: string;
|
|
34
|
+
issuerDid: string;
|
|
62
35
|
prevKeyId: string;
|
|
63
36
|
nextKeyId: string;
|
|
64
37
|
effectiveAt: number;
|
|
@@ -67,8 +40,8 @@ export declare const RotationEventSchema: z.ZodEffects<z.ZodObject<{
|
|
|
67
40
|
metadata?: Record<string, any> | undefined;
|
|
68
41
|
prevEventHash?: string | undefined;
|
|
69
42
|
}, {
|
|
70
|
-
issuerDid: string;
|
|
71
43
|
signature: string;
|
|
44
|
+
issuerDid: string;
|
|
72
45
|
prevKeyId: string;
|
|
73
46
|
nextKeyId: string;
|
|
74
47
|
effectiveAt: number;
|
|
@@ -78,37 +51,21 @@ export declare const RotationEventSchema: z.ZodEffects<z.ZodObject<{
|
|
|
78
51
|
prevEventHash?: string | undefined;
|
|
79
52
|
}>;
|
|
80
53
|
export type RotationEvent = z.infer<typeof RotationEventSchema>;
|
|
81
|
-
/**
|
|
82
|
-
* Rotation Chain
|
|
83
|
-
*
|
|
84
|
-
* Represents a chain of rotation events
|
|
85
|
-
*/
|
|
86
54
|
export declare const RotationChainSchema: z.ZodObject<{
|
|
87
|
-
/** Issuer DID */
|
|
88
55
|
issuerDid: z.ZodString;
|
|
89
|
-
/** All rotation events in order */
|
|
90
56
|
events: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
91
|
-
/** DID of the issuer performing the rotation */
|
|
92
57
|
issuerDid: z.ZodString;
|
|
93
|
-
/** Previous key ID being rotated out */
|
|
94
58
|
prevKeyId: z.ZodString;
|
|
95
|
-
/** New key ID being rotated in */
|
|
96
59
|
nextKeyId: z.ZodString;
|
|
97
|
-
/** Timestamp when new key becomes effective (Unix seconds) */
|
|
98
60
|
effectiveAt: z.ZodNumber;
|
|
99
|
-
/** Timestamp when event was issued (Unix seconds) */
|
|
100
61
|
issuedAt: z.ZodNumber;
|
|
101
|
-
/** Sequence number (monotonically increasing) */
|
|
102
62
|
seq: z.ZodNumber;
|
|
103
|
-
/** Hash of previous rotation event (null for first rotation) */
|
|
104
63
|
prevEventHash: z.ZodOptional<z.ZodString>;
|
|
105
|
-
/** Signature over the event (using prevKeyId) */
|
|
106
64
|
signature: z.ZodString;
|
|
107
|
-
/** Optional metadata */
|
|
108
65
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
109
66
|
}, "strip", z.ZodTypeAny, {
|
|
110
|
-
issuerDid: string;
|
|
111
67
|
signature: string;
|
|
68
|
+
issuerDid: string;
|
|
112
69
|
prevKeyId: string;
|
|
113
70
|
nextKeyId: string;
|
|
114
71
|
effectiveAt: number;
|
|
@@ -117,8 +74,8 @@ export declare const RotationChainSchema: z.ZodObject<{
|
|
|
117
74
|
metadata?: Record<string, any> | undefined;
|
|
118
75
|
prevEventHash?: string | undefined;
|
|
119
76
|
}, {
|
|
120
|
-
issuerDid: string;
|
|
121
77
|
signature: string;
|
|
78
|
+
issuerDid: string;
|
|
122
79
|
prevKeyId: string;
|
|
123
80
|
nextKeyId: string;
|
|
124
81
|
effectiveAt: number;
|
|
@@ -127,8 +84,8 @@ export declare const RotationChainSchema: z.ZodObject<{
|
|
|
127
84
|
metadata?: Record<string, any> | undefined;
|
|
128
85
|
prevEventHash?: string | undefined;
|
|
129
86
|
}>, {
|
|
130
|
-
issuerDid: string;
|
|
131
87
|
signature: string;
|
|
88
|
+
issuerDid: string;
|
|
132
89
|
prevKeyId: string;
|
|
133
90
|
nextKeyId: string;
|
|
134
91
|
effectiveAt: number;
|
|
@@ -137,8 +94,8 @@ export declare const RotationChainSchema: z.ZodObject<{
|
|
|
137
94
|
metadata?: Record<string, any> | undefined;
|
|
138
95
|
prevEventHash?: string | undefined;
|
|
139
96
|
}, {
|
|
140
|
-
issuerDid: string;
|
|
141
97
|
signature: string;
|
|
98
|
+
issuerDid: string;
|
|
142
99
|
prevKeyId: string;
|
|
143
100
|
nextKeyId: string;
|
|
144
101
|
effectiveAt: number;
|
|
@@ -147,18 +104,15 @@ export declare const RotationChainSchema: z.ZodObject<{
|
|
|
147
104
|
metadata?: Record<string, any> | undefined;
|
|
148
105
|
prevEventHash?: string | undefined;
|
|
149
106
|
}>, "many">;
|
|
150
|
-
/** Current active key ID */
|
|
151
107
|
currentKeyId: z.ZodString;
|
|
152
|
-
/** Whether chain is valid */
|
|
153
108
|
valid: z.ZodBoolean;
|
|
154
|
-
/** Optional validation errors */
|
|
155
109
|
errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
156
110
|
}, "strip", z.ZodTypeAny, {
|
|
157
111
|
valid: boolean;
|
|
158
112
|
issuerDid: string;
|
|
159
113
|
events: {
|
|
160
|
-
issuerDid: string;
|
|
161
114
|
signature: string;
|
|
115
|
+
issuerDid: string;
|
|
162
116
|
prevKeyId: string;
|
|
163
117
|
nextKeyId: string;
|
|
164
118
|
effectiveAt: number;
|
|
@@ -173,8 +127,8 @@ export declare const RotationChainSchema: z.ZodObject<{
|
|
|
173
127
|
valid: boolean;
|
|
174
128
|
issuerDid: string;
|
|
175
129
|
events: {
|
|
176
|
-
issuerDid: string;
|
|
177
130
|
signature: string;
|
|
131
|
+
issuerDid: string;
|
|
178
132
|
prevKeyId: string;
|
|
179
133
|
nextKeyId: string;
|
|
180
134
|
effectiveAt: number;
|
|
@@ -187,18 +141,9 @@ export declare const RotationChainSchema: z.ZodObject<{
|
|
|
187
141
|
errors?: string[] | undefined;
|
|
188
142
|
}>;
|
|
189
143
|
export type RotationChain = z.infer<typeof RotationChainSchema>;
|
|
190
|
-
/**
|
|
191
|
-
* Validation Helpers
|
|
192
|
-
*/
|
|
193
|
-
/**
|
|
194
|
-
* Validate a rotation event
|
|
195
|
-
*
|
|
196
|
-
* @param event - The event to validate
|
|
197
|
-
* @returns Validation result
|
|
198
|
-
*/
|
|
199
144
|
export declare function validateRotationEvent(event: unknown): z.SafeParseReturnType<{
|
|
200
|
-
issuerDid: string;
|
|
201
145
|
signature: string;
|
|
146
|
+
issuerDid: string;
|
|
202
147
|
prevKeyId: string;
|
|
203
148
|
nextKeyId: string;
|
|
204
149
|
effectiveAt: number;
|
|
@@ -207,8 +152,8 @@ export declare function validateRotationEvent(event: unknown): z.SafeParseReturn
|
|
|
207
152
|
metadata?: Record<string, any> | undefined;
|
|
208
153
|
prevEventHash?: string | undefined;
|
|
209
154
|
}, {
|
|
210
|
-
issuerDid: string;
|
|
211
155
|
signature: string;
|
|
156
|
+
issuerDid: string;
|
|
212
157
|
prevKeyId: string;
|
|
213
158
|
nextKeyId: string;
|
|
214
159
|
effectiveAt: number;
|
|
@@ -217,30 +162,7 @@ export declare function validateRotationEvent(event: unknown): z.SafeParseReturn
|
|
|
217
162
|
metadata?: Record<string, any> | undefined;
|
|
218
163
|
prevEventHash?: string | undefined;
|
|
219
164
|
}>;
|
|
220
|
-
/**
|
|
221
|
-
* Validate rotation chain integrity
|
|
222
|
-
*
|
|
223
|
-
* @param chain - The chain to validate
|
|
224
|
-
* @returns true if chain is valid
|
|
225
|
-
*/
|
|
226
165
|
export declare function isRotationChainValid(chain: RotationChain): boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Get active key at a specific timestamp
|
|
229
|
-
*
|
|
230
|
-
* @param chain - The rotation chain
|
|
231
|
-
* @param timestamp - Timestamp in seconds
|
|
232
|
-
* @returns Active key ID at that time, or null if none
|
|
233
|
-
*/
|
|
234
166
|
export declare function getActiveKeyAt(chain: RotationChain, timestamp: number): string | null;
|
|
235
|
-
/**
|
|
236
|
-
* Constants
|
|
237
|
-
*/
|
|
238
|
-
/**
|
|
239
|
-
* Default grace period for dual-key validity (24 hours)
|
|
240
|
-
*/
|
|
241
167
|
export declare const DEFAULT_GRACE_PERIOD_SEC: number;
|
|
242
|
-
/**
|
|
243
|
-
* Maximum reasonable grace period (30 days)
|
|
244
|
-
*/
|
|
245
168
|
export declare const MAX_GRACE_PERIOD_SEC: number;
|
|
246
|
-
//# sourceMappingURL=rotation.d.ts.map
|
package/dist/tlkrc/rotation.js
CHANGED
|
@@ -1,90 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* TLKRC (Transparent Log Key Rotation Contract)
|
|
4
|
-
*
|
|
5
|
-
* Types for key rotation events in a transparent, auditable manner
|
|
6
|
-
*
|
|
7
|
-
* Related Spec: MCP-I Core
|
|
8
|
-
* Python Reference: Core-Documentation.md
|
|
9
|
-
*/
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
3
|
exports.MAX_GRACE_PERIOD_SEC = exports.DEFAULT_GRACE_PERIOD_SEC = exports.RotationChainSchema = exports.RotationEventSchema = void 0;
|
|
12
4
|
exports.validateRotationEvent = validateRotationEvent;
|
|
13
5
|
exports.isRotationChainValid = isRotationChainValid;
|
|
14
6
|
exports.getActiveKeyAt = getActiveKeyAt;
|
|
15
7
|
const zod_1 = require("zod");
|
|
16
|
-
/**
|
|
17
|
-
* Rotation Event Schema
|
|
18
|
-
*
|
|
19
|
-
* Represents a key rotation event in a transparent log.
|
|
20
|
-
* Events form a hash-linked chain for auditability.
|
|
21
|
-
*
|
|
22
|
-
* **Dual-Key Grace Window:**
|
|
23
|
-
* During rotation, both `prevKeyId` and `nextKeyId` are valid
|
|
24
|
-
* from `effectiveAt` until `effectiveAt + grace period`.
|
|
25
|
-
*/
|
|
26
8
|
exports.RotationEventSchema = zod_1.z.object({
|
|
27
|
-
/** DID of the issuer performing the rotation */
|
|
28
9
|
issuerDid: zod_1.z.string().min(1),
|
|
29
|
-
/** Previous key ID being rotated out */
|
|
30
10
|
prevKeyId: zod_1.z.string().min(1),
|
|
31
|
-
/** New key ID being rotated in */
|
|
32
11
|
nextKeyId: zod_1.z.string().min(1),
|
|
33
|
-
/** Timestamp when new key becomes effective (Unix seconds) */
|
|
34
12
|
effectiveAt: zod_1.z.number().int().positive(),
|
|
35
|
-
/** Timestamp when event was issued (Unix seconds) */
|
|
36
13
|
issuedAt: zod_1.z.number().int().positive(),
|
|
37
|
-
/** Sequence number (monotonically increasing) */
|
|
38
14
|
seq: zod_1.z.number().int().nonnegative(),
|
|
39
|
-
/** Hash of previous rotation event (null for first rotation) */
|
|
40
15
|
prevEventHash: zod_1.z.string().optional(),
|
|
41
|
-
/** Signature over the event (using prevKeyId) */
|
|
42
16
|
signature: zod_1.z.string().min(1),
|
|
43
|
-
/** Optional metadata */
|
|
44
17
|
metadata: zod_1.z.record(zod_1.z.any()).optional(),
|
|
45
18
|
}).refine((event) => event.effectiveAt >= event.issuedAt, {
|
|
46
19
|
message: 'effectiveAt must be >= issuedAt',
|
|
47
20
|
});
|
|
48
|
-
/**
|
|
49
|
-
* Rotation Chain
|
|
50
|
-
*
|
|
51
|
-
* Represents a chain of rotation events
|
|
52
|
-
*/
|
|
53
21
|
exports.RotationChainSchema = zod_1.z.object({
|
|
54
|
-
/** Issuer DID */
|
|
55
22
|
issuerDid: zod_1.z.string().min(1),
|
|
56
|
-
/** All rotation events in order */
|
|
57
23
|
events: zod_1.z.array(exports.RotationEventSchema).min(1),
|
|
58
|
-
/** Current active key ID */
|
|
59
24
|
currentKeyId: zod_1.z.string().min(1),
|
|
60
|
-
/** Whether chain is valid */
|
|
61
25
|
valid: zod_1.z.boolean(),
|
|
62
|
-
/** Optional validation errors */
|
|
63
26
|
errors: zod_1.z.array(zod_1.z.string()).optional(),
|
|
64
27
|
});
|
|
65
|
-
/**
|
|
66
|
-
* Validation Helpers
|
|
67
|
-
*/
|
|
68
|
-
/**
|
|
69
|
-
* Validate a rotation event
|
|
70
|
-
*
|
|
71
|
-
* @param event - The event to validate
|
|
72
|
-
* @returns Validation result
|
|
73
|
-
*/
|
|
74
28
|
function validateRotationEvent(event) {
|
|
75
29
|
return exports.RotationEventSchema.safeParse(event);
|
|
76
30
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Validate rotation chain integrity
|
|
79
|
-
*
|
|
80
|
-
* @param chain - The chain to validate
|
|
81
|
-
* @returns true if chain is valid
|
|
82
|
-
*/
|
|
83
31
|
function isRotationChainValid(chain) {
|
|
84
32
|
if (chain.events.length === 0) {
|
|
85
33
|
return false;
|
|
86
34
|
}
|
|
87
|
-
// Check sequence numbers are monotonic
|
|
88
35
|
for (let i = 1; i < chain.events.length; i++) {
|
|
89
36
|
if (chain.events[i].seq <= chain.events[i - 1].seq) {
|
|
90
37
|
return false;
|
|
@@ -92,36 +39,17 @@ function isRotationChainValid(chain) {
|
|
|
92
39
|
}
|
|
93
40
|
return chain.valid;
|
|
94
41
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Get active key at a specific timestamp
|
|
97
|
-
*
|
|
98
|
-
* @param chain - The rotation chain
|
|
99
|
-
* @param timestamp - Timestamp in seconds
|
|
100
|
-
* @returns Active key ID at that time, or null if none
|
|
101
|
-
*/
|
|
102
42
|
function getActiveKeyAt(chain, timestamp) {
|
|
103
43
|
if (chain.events.length === 0) {
|
|
104
44
|
return null;
|
|
105
45
|
}
|
|
106
|
-
// Find the most recent event that's effective at the timestamp
|
|
107
46
|
for (let i = chain.events.length - 1; i >= 0; i--) {
|
|
108
47
|
const event = chain.events[i];
|
|
109
48
|
if (event.effectiveAt <= timestamp) {
|
|
110
49
|
return event.nextKeyId;
|
|
111
50
|
}
|
|
112
51
|
}
|
|
113
|
-
// If no event is effective yet, use the initial key
|
|
114
52
|
return chain.events[0].prevKeyId;
|
|
115
53
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Constants
|
|
118
|
-
*/
|
|
119
|
-
/**
|
|
120
|
-
* Default grace period for dual-key validity (24 hours)
|
|
121
|
-
*/
|
|
122
54
|
exports.DEFAULT_GRACE_PERIOD_SEC = 24 * 60 * 60;
|
|
123
|
-
/**
|
|
124
|
-
* Maximum reasonable grace period (30 days)
|
|
125
|
-
*/
|
|
126
55
|
exports.MAX_GRACE_PERIOD_SEC = 30 * 24 * 60 * 60;
|
|
127
|
-
//# sourceMappingURL=rotation.js.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export interface ToolProtection {
|
|
3
|
+
requiresDelegation: boolean;
|
|
4
|
+
requiredScopes: string[];
|
|
5
|
+
riskLevel?: 'low' | 'medium' | 'high' | 'critical';
|
|
6
|
+
}
|
|
7
|
+
export type ToolProtectionMap = Record<string, ToolProtection>;
|
|
8
|
+
export interface ToolProtectionResponse {
|
|
9
|
+
toolProtections: ToolProtectionMap;
|
|
10
|
+
metadata?: {
|
|
11
|
+
lastUpdated?: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
source?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface DelegationRequiredErrorData {
|
|
17
|
+
toolName: string;
|
|
18
|
+
requiredScopes: string[];
|
|
19
|
+
consentUrl?: string;
|
|
20
|
+
authorizationUrl?: string;
|
|
21
|
+
reason?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const ToolProtectionSchema: z.ZodObject<{
|
|
24
|
+
requiresDelegation: z.ZodBoolean;
|
|
25
|
+
requiredScopes: z.ZodArray<z.ZodString, "many">;
|
|
26
|
+
riskLevel: z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
requiresDelegation: boolean;
|
|
29
|
+
requiredScopes: string[];
|
|
30
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
requiresDelegation: boolean;
|
|
33
|
+
requiredScopes: string[];
|
|
34
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
export declare const ToolProtectionMapSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
37
|
+
requiresDelegation: z.ZodBoolean;
|
|
38
|
+
requiredScopes: z.ZodArray<z.ZodString, "many">;
|
|
39
|
+
riskLevel: z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
requiresDelegation: boolean;
|
|
42
|
+
requiredScopes: string[];
|
|
43
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
requiresDelegation: boolean;
|
|
46
|
+
requiredScopes: string[];
|
|
47
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
48
|
+
}>>;
|
|
49
|
+
export declare const ToolProtectionResponseSchema: z.ZodObject<{
|
|
50
|
+
toolProtections: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
51
|
+
requiresDelegation: z.ZodBoolean;
|
|
52
|
+
requiredScopes: z.ZodArray<z.ZodString, "many">;
|
|
53
|
+
riskLevel: z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
requiresDelegation: boolean;
|
|
56
|
+
requiredScopes: string[];
|
|
57
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
requiresDelegation: boolean;
|
|
60
|
+
requiredScopes: string[];
|
|
61
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
62
|
+
}>>;
|
|
63
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
64
|
+
lastUpdated: z.ZodOptional<z.ZodString>;
|
|
65
|
+
version: z.ZodOptional<z.ZodString>;
|
|
66
|
+
source: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
version?: string | undefined;
|
|
69
|
+
lastUpdated?: string | undefined;
|
|
70
|
+
source?: string | undefined;
|
|
71
|
+
}, {
|
|
72
|
+
version?: string | undefined;
|
|
73
|
+
lastUpdated?: string | undefined;
|
|
74
|
+
source?: string | undefined;
|
|
75
|
+
}>>;
|
|
76
|
+
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
toolProtections: Record<string, {
|
|
78
|
+
requiresDelegation: boolean;
|
|
79
|
+
requiredScopes: string[];
|
|
80
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
81
|
+
}>;
|
|
82
|
+
metadata?: {
|
|
83
|
+
version?: string | undefined;
|
|
84
|
+
lastUpdated?: string | undefined;
|
|
85
|
+
source?: string | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
toolProtections: Record<string, {
|
|
89
|
+
requiresDelegation: boolean;
|
|
90
|
+
requiredScopes: string[];
|
|
91
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
92
|
+
}>;
|
|
93
|
+
metadata?: {
|
|
94
|
+
version?: string | undefined;
|
|
95
|
+
lastUpdated?: string | undefined;
|
|
96
|
+
source?: string | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
}>;
|
|
99
|
+
export declare const DelegationRequiredErrorDataSchema: z.ZodObject<{
|
|
100
|
+
toolName: z.ZodString;
|
|
101
|
+
requiredScopes: z.ZodArray<z.ZodString, "many">;
|
|
102
|
+
consentUrl: z.ZodOptional<z.ZodString>;
|
|
103
|
+
authorizationUrl: z.ZodOptional<z.ZodString>;
|
|
104
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
requiredScopes: string[];
|
|
107
|
+
toolName: string;
|
|
108
|
+
reason?: string | undefined;
|
|
109
|
+
consentUrl?: string | undefined;
|
|
110
|
+
authorizationUrl?: string | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
requiredScopes: string[];
|
|
113
|
+
toolName: string;
|
|
114
|
+
reason?: string | undefined;
|
|
115
|
+
consentUrl?: string | undefined;
|
|
116
|
+
authorizationUrl?: string | undefined;
|
|
117
|
+
}>;
|
|
118
|
+
export declare function isToolProtection(obj: any): obj is ToolProtection;
|
|
119
|
+
export declare function isToolProtectionMap(obj: any): obj is ToolProtectionMap;
|
|
120
|
+
export declare function isToolProtectionResponse(obj: any): obj is ToolProtectionResponse;
|
|
121
|
+
export declare function isDelegationRequiredErrorData(obj: any): obj is DelegationRequiredErrorData;
|
|
122
|
+
export declare function validateToolProtection(obj: any): ToolProtection;
|
|
123
|
+
export declare function validateToolProtectionMap(obj: any): ToolProtectionMap;
|
|
124
|
+
export declare function validateToolProtectionResponse(obj: any): ToolProtectionResponse;
|
|
125
|
+
export declare function validateDelegationRequiredErrorData(obj: any): DelegationRequiredErrorData;
|
|
126
|
+
export declare function toolRequiresDelegation(toolName: string, protections: ToolProtectionMap): boolean;
|
|
127
|
+
export declare function getToolRequiredScopes(toolName: string, protections: ToolProtectionMap): string[];
|
|
128
|
+
export declare function getToolRiskLevel(toolName: string, protections: ToolProtectionMap): ToolProtection['riskLevel'] | undefined;
|
|
129
|
+
export declare function createDelegationRequiredError(toolName: string, requiredScopes: string[], consentUrl?: string): DelegationRequiredErrorData;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DelegationRequiredErrorDataSchema = exports.ToolProtectionResponseSchema = exports.ToolProtectionMapSchema = exports.ToolProtectionSchema = void 0;
|
|
4
|
+
exports.isToolProtection = isToolProtection;
|
|
5
|
+
exports.isToolProtectionMap = isToolProtectionMap;
|
|
6
|
+
exports.isToolProtectionResponse = isToolProtectionResponse;
|
|
7
|
+
exports.isDelegationRequiredErrorData = isDelegationRequiredErrorData;
|
|
8
|
+
exports.validateToolProtection = validateToolProtection;
|
|
9
|
+
exports.validateToolProtectionMap = validateToolProtectionMap;
|
|
10
|
+
exports.validateToolProtectionResponse = validateToolProtectionResponse;
|
|
11
|
+
exports.validateDelegationRequiredErrorData = validateDelegationRequiredErrorData;
|
|
12
|
+
exports.toolRequiresDelegation = toolRequiresDelegation;
|
|
13
|
+
exports.getToolRequiredScopes = getToolRequiredScopes;
|
|
14
|
+
exports.getToolRiskLevel = getToolRiskLevel;
|
|
15
|
+
exports.createDelegationRequiredError = createDelegationRequiredError;
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
|
+
exports.ToolProtectionSchema = zod_1.z.object({
|
|
18
|
+
requiresDelegation: zod_1.z.boolean(),
|
|
19
|
+
requiredScopes: zod_1.z.array(zod_1.z.string()),
|
|
20
|
+
riskLevel: zod_1.z.enum(['low', 'medium', 'high', 'critical']).optional()
|
|
21
|
+
});
|
|
22
|
+
exports.ToolProtectionMapSchema = zod_1.z.record(zod_1.z.string(), exports.ToolProtectionSchema);
|
|
23
|
+
exports.ToolProtectionResponseSchema = zod_1.z.object({
|
|
24
|
+
toolProtections: exports.ToolProtectionMapSchema,
|
|
25
|
+
metadata: zod_1.z.object({
|
|
26
|
+
lastUpdated: zod_1.z.string().optional(),
|
|
27
|
+
version: zod_1.z.string().optional(),
|
|
28
|
+
source: zod_1.z.string().optional()
|
|
29
|
+
}).optional()
|
|
30
|
+
});
|
|
31
|
+
exports.DelegationRequiredErrorDataSchema = zod_1.z.object({
|
|
32
|
+
toolName: zod_1.z.string(),
|
|
33
|
+
requiredScopes: zod_1.z.array(zod_1.z.string()),
|
|
34
|
+
consentUrl: zod_1.z.string().optional(),
|
|
35
|
+
authorizationUrl: zod_1.z.string().optional(),
|
|
36
|
+
reason: zod_1.z.string().optional()
|
|
37
|
+
});
|
|
38
|
+
function isToolProtection(obj) {
|
|
39
|
+
return exports.ToolProtectionSchema.safeParse(obj).success;
|
|
40
|
+
}
|
|
41
|
+
function isToolProtectionMap(obj) {
|
|
42
|
+
return exports.ToolProtectionMapSchema.safeParse(obj).success;
|
|
43
|
+
}
|
|
44
|
+
function isToolProtectionResponse(obj) {
|
|
45
|
+
return exports.ToolProtectionResponseSchema.safeParse(obj).success;
|
|
46
|
+
}
|
|
47
|
+
function isDelegationRequiredErrorData(obj) {
|
|
48
|
+
return exports.DelegationRequiredErrorDataSchema.safeParse(obj).success;
|
|
49
|
+
}
|
|
50
|
+
function validateToolProtection(obj) {
|
|
51
|
+
return exports.ToolProtectionSchema.parse(obj);
|
|
52
|
+
}
|
|
53
|
+
function validateToolProtectionMap(obj) {
|
|
54
|
+
return exports.ToolProtectionMapSchema.parse(obj);
|
|
55
|
+
}
|
|
56
|
+
function validateToolProtectionResponse(obj) {
|
|
57
|
+
return exports.ToolProtectionResponseSchema.parse(obj);
|
|
58
|
+
}
|
|
59
|
+
function validateDelegationRequiredErrorData(obj) {
|
|
60
|
+
return exports.DelegationRequiredErrorDataSchema.parse(obj);
|
|
61
|
+
}
|
|
62
|
+
function toolRequiresDelegation(toolName, protections) {
|
|
63
|
+
const protection = protections[toolName];
|
|
64
|
+
return protection?.requiresDelegation ?? false;
|
|
65
|
+
}
|
|
66
|
+
function getToolRequiredScopes(toolName, protections) {
|
|
67
|
+
const protection = protections[toolName];
|
|
68
|
+
return protection?.requiredScopes ?? [];
|
|
69
|
+
}
|
|
70
|
+
function getToolRiskLevel(toolName, protections) {
|
|
71
|
+
return protections[toolName]?.riskLevel;
|
|
72
|
+
}
|
|
73
|
+
function createDelegationRequiredError(toolName, requiredScopes, consentUrl) {
|
|
74
|
+
return {
|
|
75
|
+
toolName,
|
|
76
|
+
requiredScopes,
|
|
77
|
+
consentUrl,
|
|
78
|
+
authorizationUrl: consentUrl
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -1,31 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared validation utilities for mcpi packages
|
|
3
|
-
* Consolidates common validation patterns to follow DRY principles
|
|
4
|
-
*/
|
|
5
1
|
import { z } from "zod";
|
|
6
|
-
/**
|
|
7
|
-
* Generic validation result type
|
|
8
|
-
*/
|
|
9
2
|
export interface ValidationResult<T = any> {
|
|
10
3
|
valid: boolean;
|
|
11
4
|
data?: T;
|
|
12
5
|
errors: string[];
|
|
13
6
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Generic validation function with helpful error messages
|
|
16
|
-
*/
|
|
17
7
|
export declare function validateInput<T>(schema: z.ZodSchema<T>, data: unknown, context?: string): ValidationResult<T>;
|
|
18
|
-
/**
|
|
19
|
-
* Validate object has required properties
|
|
20
|
-
*/
|
|
21
8
|
export declare function hasRequiredProperties(obj: any, properties: string[], context?: string): ValidationResult;
|
|
22
|
-
/**
|
|
23
|
-
* Validate string format patterns
|
|
24
|
-
*/
|
|
25
9
|
export declare const StringValidators: {
|
|
26
10
|
did: (value: string) => boolean;
|
|
27
11
|
kid: (value: string) => boolean;
|
|
28
12
|
url: (value: string) => boolean;
|
|
29
13
|
projectName: (value: string) => boolean;
|
|
30
14
|
};
|
|
31
|
-
//# sourceMappingURL=validation.d.ts.map
|
package/dist/utils/validation.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Shared validation utilities for mcpi packages
|
|
4
|
-
* Consolidates common validation patterns to follow DRY principles
|
|
5
|
-
*/
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
exports.StringValidators = void 0;
|
|
8
4
|
exports.validateInput = validateInput;
|
|
9
5
|
exports.hasRequiredProperties = hasRequiredProperties;
|
|
10
|
-
/**
|
|
11
|
-
* Generic validation function with helpful error messages
|
|
12
|
-
*/
|
|
13
6
|
function validateInput(schema, data, context) {
|
|
14
7
|
const result = schema.safeParse(data);
|
|
15
8
|
if (result.success) {
|
|
@@ -29,9 +22,6 @@ function validateInput(schema, data, context) {
|
|
|
29
22
|
errors,
|
|
30
23
|
};
|
|
31
24
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Validate object has required properties
|
|
34
|
-
*/
|
|
35
25
|
function hasRequiredProperties(obj, properties, context) {
|
|
36
26
|
if (typeof obj !== "object" || obj === null) {
|
|
37
27
|
return {
|
|
@@ -50,9 +40,6 @@ function hasRequiredProperties(obj, properties, context) {
|
|
|
50
40
|
}
|
|
51
41
|
return { valid: true, errors: [] };
|
|
52
42
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Validate string format patterns
|
|
55
|
-
*/
|
|
56
43
|
exports.StringValidators = {
|
|
57
44
|
did: (value) => /^did:[a-z0-9]+:[a-zA-Z0-9._-]+$/.test(value),
|
|
58
45
|
kid: (value) => /^[a-zA-Z0-9._-]+$/.test(value),
|
|
@@ -67,4 +54,3 @@ exports.StringValidators = {
|
|
|
67
54
|
},
|
|
68
55
|
projectName: (value) => /^[a-z0-9-]+$/.test(value) && value.length >= 1 && value.length <= 214,
|
|
69
56
|
};
|
|
70
|
-
//# sourceMappingURL=validation.js.map
|
package/dist/vc/index.d.ts
CHANGED
package/dist/vc/index.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Verifiable Credentials Module Exports
|
|
4
|
-
*
|
|
5
|
-
* W3C Verifiable Credentials types, schemas, and utilities
|
|
6
|
-
*/
|
|
7
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
3
|
if (k2 === undefined) k2 = k;
|
|
9
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -21,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
21
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
17
|
__exportStar(require("./schemas.js"), exports);
|
|
23
18
|
__exportStar(require("./statuslist.js"), exports);
|
|
24
|
-
//# sourceMappingURL=index.js.map
|