@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
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* CRISP Delegation Constraints
|
|
4
|
-
*
|
|
5
|
-
* Types and schemas for CRISP (Constrained Resource Intent Specification Protocol)
|
|
6
|
-
* constraints on delegations. CRISP enables fine-grained authorization control.
|
|
7
|
-
*
|
|
8
|
-
* Related Spec: MCP-I §4.2
|
|
9
|
-
* Python Reference: Delegation-Documentation.md
|
|
10
|
-
*/
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.MAX_WINDOW_DURATION_SEC = exports.MAX_BUDGET_CAP = exports.SUPPORTED_MATCHERS = exports.SUPPORTED_CURRENCIES = exports.DelegationConstraintsSchema = exports.CrispScopeSchema = exports.ScopeMatcherSchema = exports.CrispBudgetSchema = exports.BudgetWindowSchema = exports.WindowKindSchema = exports.CurrencySchema = void 0;
|
|
13
4
|
exports.validateDelegationConstraints = validateDelegationConstraints;
|
|
@@ -15,94 +6,35 @@ exports.hasValidTimeRange = hasValidTimeRange;
|
|
|
15
6
|
exports.areChildConstraintsValid = areChildConstraintsValid;
|
|
16
7
|
exports.doesResourceMatchScope = doesResourceMatchScope;
|
|
17
8
|
const zod_1 = require("zod");
|
|
18
|
-
/**
|
|
19
|
-
* Currency types for CRISP budgets
|
|
20
|
-
*/
|
|
21
9
|
exports.CurrencySchema = zod_1.z.enum(['USD', 'ops', 'points']);
|
|
22
|
-
/**
|
|
23
|
-
* Window kind for budget enforcement
|
|
24
|
-
*/
|
|
25
10
|
exports.WindowKindSchema = zod_1.z.enum(['rolling', 'fixed']);
|
|
26
|
-
/**
|
|
27
|
-
* Budget Window Schema
|
|
28
|
-
*
|
|
29
|
-
* Defines the time window for budget enforcement
|
|
30
|
-
*/
|
|
31
11
|
exports.BudgetWindowSchema = zod_1.z.object({
|
|
32
|
-
/** Type of window (rolling or fixed) */
|
|
33
12
|
kind: exports.WindowKindSchema,
|
|
34
|
-
/** Duration in seconds */
|
|
35
13
|
durationSec: zod_1.z.number().int().positive(),
|
|
36
14
|
});
|
|
37
|
-
/**
|
|
38
|
-
* CRISP Budget Schema
|
|
39
|
-
*
|
|
40
|
-
* Defines spending/usage limits for a delegation
|
|
41
|
-
*/
|
|
42
15
|
exports.CrispBudgetSchema = zod_1.z.object({
|
|
43
|
-
/** Unit of the budget */
|
|
44
16
|
unit: exports.CurrencySchema,
|
|
45
|
-
/** Cap/limit for the budget */
|
|
46
17
|
cap: zod_1.z.number().nonnegative(),
|
|
47
|
-
/** Optional time window for the budget */
|
|
48
18
|
window: exports.BudgetWindowSchema.optional(),
|
|
49
19
|
});
|
|
50
|
-
/**
|
|
51
|
-
* Scope matcher types
|
|
52
|
-
*/
|
|
53
20
|
exports.ScopeMatcherSchema = zod_1.z.enum(['exact', 'prefix', 'regex']);
|
|
54
|
-
/**
|
|
55
|
-
* CRISP Scope Schema
|
|
56
|
-
*
|
|
57
|
-
* Defines what resources/actions are allowed in a delegation
|
|
58
|
-
*/
|
|
59
21
|
exports.CrispScopeSchema = zod_1.z.object({
|
|
60
|
-
/** Resource identifier (e.g., "api:users", "data:emails") */
|
|
61
22
|
resource: zod_1.z.string().min(1),
|
|
62
|
-
/** How to match the resource */
|
|
63
23
|
matcher: exports.ScopeMatcherSchema,
|
|
64
|
-
/** Optional additional constraints on this scope */
|
|
65
24
|
constraints: zod_1.z.record(zod_1.z.any()).optional(),
|
|
66
25
|
});
|
|
67
|
-
/**
|
|
68
|
-
* Delegation Constraints Schema (CRISP)
|
|
69
|
-
*
|
|
70
|
-
* Complete constraint specification for a delegation
|
|
71
|
-
*/
|
|
72
26
|
exports.DelegationConstraintsSchema = zod_1.z.object({
|
|
73
|
-
/** Not valid before (Unix timestamp in seconds) */
|
|
74
27
|
notBefore: zod_1.z.number().int().optional(),
|
|
75
|
-
/** Not valid after (Unix timestamp in seconds) */
|
|
76
28
|
notAfter: zod_1.z.number().int().optional(),
|
|
77
|
-
/** Simple scopes array (for Phase 1 bouncer - simplified model) */
|
|
78
29
|
scopes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
79
|
-
/** CRISP-specific constraints (full model) */
|
|
80
30
|
crisp: zod_1.z.object({
|
|
81
|
-
/** Optional budget constraint */
|
|
82
31
|
budget: exports.CrispBudgetSchema.optional(),
|
|
83
|
-
/** Required: at least one scope */
|
|
84
32
|
scopes: zod_1.z.array(exports.CrispScopeSchema).min(1),
|
|
85
|
-
/** Optional additional CRISP fields */
|
|
86
33
|
}).passthrough().optional(),
|
|
87
|
-
}).passthrough();
|
|
88
|
-
/**
|
|
89
|
-
* Validation Helpers
|
|
90
|
-
*/
|
|
91
|
-
/**
|
|
92
|
-
* Validate delegation constraints
|
|
93
|
-
*
|
|
94
|
-
* @param constraints - The constraints to validate
|
|
95
|
-
* @returns Validation result
|
|
96
|
-
*/
|
|
34
|
+
}).passthrough();
|
|
97
35
|
function validateDelegationConstraints(constraints) {
|
|
98
36
|
return exports.DelegationConstraintsSchema.safeParse(constraints);
|
|
99
37
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Check if constraints have a valid time range
|
|
102
|
-
*
|
|
103
|
-
* @param constraints - The constraints to check
|
|
104
|
-
* @returns true if time range is valid or no time range specified
|
|
105
|
-
*/
|
|
106
38
|
function hasValidTimeRange(constraints) {
|
|
107
39
|
if (constraints.notBefore === undefined && constraints.notAfter === undefined) {
|
|
108
40
|
return true;
|
|
@@ -112,18 +44,7 @@ function hasValidTimeRange(constraints) {
|
|
|
112
44
|
}
|
|
113
45
|
return true;
|
|
114
46
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Check if child constraints are within parent constraints
|
|
117
|
-
*
|
|
118
|
-
* This performs basic structural checks. Full chain validation
|
|
119
|
-
* requires runtime implementation.
|
|
120
|
-
*
|
|
121
|
-
* @param parent - Parent delegation constraints
|
|
122
|
-
* @param child - Child delegation constraints
|
|
123
|
-
* @returns true if child is within parent bounds
|
|
124
|
-
*/
|
|
125
47
|
function areChildConstraintsValid(parent, child) {
|
|
126
|
-
// Time bounds: child must be within parent
|
|
127
48
|
if (parent.notBefore !== undefined && child.notBefore !== undefined) {
|
|
128
49
|
if (child.notBefore < parent.notBefore) {
|
|
129
50
|
return false;
|
|
@@ -134,7 +55,6 @@ function areChildConstraintsValid(parent, child) {
|
|
|
134
55
|
return false;
|
|
135
56
|
}
|
|
136
57
|
}
|
|
137
|
-
// Budget: child must be ≤ parent (if same unit)
|
|
138
58
|
if (parent.crisp?.budget &&
|
|
139
59
|
child.crisp?.budget &&
|
|
140
60
|
parent.crisp.budget.unit === child.crisp.budget.unit) {
|
|
@@ -142,12 +62,9 @@ function areChildConstraintsValid(parent, child) {
|
|
|
142
62
|
return false;
|
|
143
63
|
}
|
|
144
64
|
}
|
|
145
|
-
// Scopes: child scopes must be subset of parent scopes
|
|
146
|
-
// This is a simplified check - full validation is complex
|
|
147
65
|
if (parent.crisp && child.crisp) {
|
|
148
66
|
const parentResources = new Set(parent.crisp.scopes.map((s) => s.resource));
|
|
149
67
|
const allChildResourcesInParent = child.crisp.scopes.every((childScope) => {
|
|
150
|
-
// Check if child resource matches any parent resource
|
|
151
68
|
return parent.crisp.scopes.some((parentScope) => {
|
|
152
69
|
if (parentScope.matcher === 'exact') {
|
|
153
70
|
return parentScope.resource === childScope.resource;
|
|
@@ -155,21 +72,13 @@ function areChildConstraintsValid(parent, child) {
|
|
|
155
72
|
if (parentScope.matcher === 'prefix') {
|
|
156
73
|
return childScope.resource.startsWith(parentScope.resource);
|
|
157
74
|
}
|
|
158
|
-
|
|
159
|
-
return true; // Can't validate regex at type level
|
|
75
|
+
return true;
|
|
160
76
|
});
|
|
161
77
|
});
|
|
162
78
|
return allChildResourcesInParent;
|
|
163
79
|
}
|
|
164
|
-
return true;
|
|
80
|
+
return true;
|
|
165
81
|
}
|
|
166
|
-
/**
|
|
167
|
-
* Check if a resource matches a scope
|
|
168
|
-
*
|
|
169
|
-
* @param resource - The resource to check
|
|
170
|
-
* @param scope - The scope to match against
|
|
171
|
-
* @returns true if resource matches scope
|
|
172
|
-
*/
|
|
173
82
|
function doesResourceMatchScope(resource, scope) {
|
|
174
83
|
switch (scope.matcher) {
|
|
175
84
|
case 'exact':
|
|
@@ -188,23 +97,7 @@ function doesResourceMatchScope(resource, scope) {
|
|
|
188
97
|
return false;
|
|
189
98
|
}
|
|
190
99
|
}
|
|
191
|
-
/**
|
|
192
|
-
* Constants
|
|
193
|
-
*/
|
|
194
|
-
/**
|
|
195
|
-
* Supported currency types
|
|
196
|
-
*/
|
|
197
100
|
exports.SUPPORTED_CURRENCIES = ['USD', 'ops', 'points'];
|
|
198
|
-
/**
|
|
199
|
-
* Supported scope matchers
|
|
200
|
-
*/
|
|
201
101
|
exports.SUPPORTED_MATCHERS = ['exact', 'prefix', 'regex'];
|
|
202
|
-
/**
|
|
203
|
-
* Maximum reasonable budget cap (for validation)
|
|
204
|
-
*/
|
|
205
102
|
exports.MAX_BUDGET_CAP = Number.MAX_SAFE_INTEGER;
|
|
206
|
-
/**
|
|
207
|
-
* Maximum reasonable window duration (10 years in seconds)
|
|
208
|
-
*/
|
|
209
103
|
exports.MAX_WINDOW_DURATION_SEC = 10 * 365 * 24 * 60 * 60;
|
|
210
|
-
//# sourceMappingURL=constraints.js.map
|
package/dist/delegation/index.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Delegation Module Exports
|
|
4
|
-
*
|
|
5
|
-
* Types and schemas for delegation records and CRISP constraints
|
|
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("./constraints.js"), exports);
|
|
24
|
-
//# sourceMappingURL=index.js.map
|