@kya-os/contracts 1.3.2 → 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.
Files changed (58) hide show
  1. package/package.json +28 -5
  2. package/README.md +0 -130
  3. package/dist/cli.d.ts +0 -378
  4. package/dist/cli.js +0 -116
  5. package/dist/delegation/constraints.d.ts +0 -992
  6. package/dist/delegation/constraints.js +0 -210
  7. package/dist/delegation/index.d.ts +0 -8
  8. package/dist/delegation/index.js +0 -24
  9. package/dist/delegation/schemas.d.ts +0 -8382
  10. package/dist/delegation/schemas.js +0 -476
  11. package/dist/did/index.d.ts +0 -9
  12. package/dist/did/index.js +0 -25
  13. package/dist/did/resolve-contract.d.ts +0 -220
  14. package/dist/did/resolve-contract.js +0 -32
  15. package/dist/did/schemas.d.ts +0 -113
  16. package/dist/did/schemas.js +0 -173
  17. package/dist/did/types.d.ts +0 -164
  18. package/dist/did/types.js +0 -71
  19. package/dist/env/constants.d.ts +0 -58
  20. package/dist/env/constants.js +0 -60
  21. package/dist/env/index.d.ts +0 -5
  22. package/dist/env/index.js +0 -21
  23. package/dist/handshake.d.ts +0 -159
  24. package/dist/handshake.js +0 -58
  25. package/dist/index.d.ts +0 -26
  26. package/dist/index.js +0 -53
  27. package/dist/proof/index.d.ts +0 -9
  28. package/dist/proof/index.js +0 -25
  29. package/dist/proof/proof-record.d.ts +0 -838
  30. package/dist/proof/proof-record.js +0 -134
  31. package/dist/proof/signing-spec.d.ts +0 -147
  32. package/dist/proof/signing-spec.js +0 -123
  33. package/dist/proof.d.ts +0 -400
  34. package/dist/proof.js +0 -82
  35. package/dist/registry.d.ts +0 -343
  36. package/dist/registry.js +0 -119
  37. package/dist/runtime/errors.d.ts +0 -348
  38. package/dist/runtime/errors.js +0 -120
  39. package/dist/runtime/headers.d.ts +0 -84
  40. package/dist/runtime/headers.js +0 -82
  41. package/dist/runtime/index.d.ts +0 -6
  42. package/dist/runtime/index.js +0 -22
  43. package/dist/test.d.ts +0 -252
  44. package/dist/test.js +0 -120
  45. package/dist/tlkrc/index.d.ts +0 -5
  46. package/dist/tlkrc/index.js +0 -21
  47. package/dist/tlkrc/rotation.d.ts +0 -246
  48. package/dist/tlkrc/rotation.js +0 -127
  49. package/dist/utils/validation.d.ts +0 -31
  50. package/dist/utils/validation.js +0 -70
  51. package/dist/vc/index.d.ts +0 -8
  52. package/dist/vc/index.js +0 -24
  53. package/dist/vc/schemas.d.ts +0 -2484
  54. package/dist/vc/schemas.js +0 -225
  55. package/dist/vc/statuslist.d.ts +0 -494
  56. package/dist/vc/statuslist.js +0 -133
  57. package/dist/verifier.d.ts +0 -206
  58. package/dist/verifier.js +0 -84
@@ -1,210 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- 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
- exports.validateDelegationConstraints = validateDelegationConstraints;
14
- exports.hasValidTimeRange = hasValidTimeRange;
15
- exports.areChildConstraintsValid = areChildConstraintsValid;
16
- exports.doesResourceMatchScope = doesResourceMatchScope;
17
- const zod_1 = require("zod");
18
- /**
19
- * Currency types for CRISP budgets
20
- */
21
- exports.CurrencySchema = zod_1.z.enum(['USD', 'ops', 'points']);
22
- /**
23
- * Window kind for budget enforcement
24
- */
25
- exports.WindowKindSchema = zod_1.z.enum(['rolling', 'fixed']);
26
- /**
27
- * Budget Window Schema
28
- *
29
- * Defines the time window for budget enforcement
30
- */
31
- exports.BudgetWindowSchema = zod_1.z.object({
32
- /** Type of window (rolling or fixed) */
33
- kind: exports.WindowKindSchema,
34
- /** Duration in seconds */
35
- durationSec: zod_1.z.number().int().positive(),
36
- });
37
- /**
38
- * CRISP Budget Schema
39
- *
40
- * Defines spending/usage limits for a delegation
41
- */
42
- exports.CrispBudgetSchema = zod_1.z.object({
43
- /** Unit of the budget */
44
- unit: exports.CurrencySchema,
45
- /** Cap/limit for the budget */
46
- cap: zod_1.z.number().nonnegative(),
47
- /** Optional time window for the budget */
48
- window: exports.BudgetWindowSchema.optional(),
49
- });
50
- /**
51
- * Scope matcher types
52
- */
53
- 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
- exports.CrispScopeSchema = zod_1.z.object({
60
- /** Resource identifier (e.g., "api:users", "data:emails") */
61
- resource: zod_1.z.string().min(1),
62
- /** How to match the resource */
63
- matcher: exports.ScopeMatcherSchema,
64
- /** Optional additional constraints on this scope */
65
- constraints: zod_1.z.record(zod_1.z.any()).optional(),
66
- });
67
- /**
68
- * Delegation Constraints Schema (CRISP)
69
- *
70
- * Complete constraint specification for a delegation
71
- */
72
- exports.DelegationConstraintsSchema = zod_1.z.object({
73
- /** Not valid before (Unix timestamp in seconds) */
74
- notBefore: zod_1.z.number().int().optional(),
75
- /** Not valid after (Unix timestamp in seconds) */
76
- notAfter: zod_1.z.number().int().optional(),
77
- /** Simple scopes array (for Phase 1 bouncer - simplified model) */
78
- scopes: zod_1.z.array(zod_1.z.string()).optional(),
79
- /** CRISP-specific constraints (full model) */
80
- crisp: zod_1.z.object({
81
- /** Optional budget constraint */
82
- budget: exports.CrispBudgetSchema.optional(),
83
- /** Required: at least one scope */
84
- scopes: zod_1.z.array(exports.CrispScopeSchema).min(1),
85
- /** Optional additional CRISP fields */
86
- }).passthrough().optional(),
87
- }).passthrough(); // Allow extensibility
88
- /**
89
- * Validation Helpers
90
- */
91
- /**
92
- * Validate delegation constraints
93
- *
94
- * @param constraints - The constraints to validate
95
- * @returns Validation result
96
- */
97
- function validateDelegationConstraints(constraints) {
98
- return exports.DelegationConstraintsSchema.safeParse(constraints);
99
- }
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
- function hasValidTimeRange(constraints) {
107
- if (constraints.notBefore === undefined && constraints.notAfter === undefined) {
108
- return true;
109
- }
110
- if (constraints.notBefore !== undefined && constraints.notAfter !== undefined) {
111
- return constraints.notBefore < constraints.notAfter;
112
- }
113
- return true;
114
- }
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
- function areChildConstraintsValid(parent, child) {
126
- // Time bounds: child must be within parent
127
- if (parent.notBefore !== undefined && child.notBefore !== undefined) {
128
- if (child.notBefore < parent.notBefore) {
129
- return false;
130
- }
131
- }
132
- if (parent.notAfter !== undefined && child.notAfter !== undefined) {
133
- if (child.notAfter > parent.notAfter) {
134
- return false;
135
- }
136
- }
137
- // Budget: child must be ≤ parent (if same unit)
138
- if (parent.crisp?.budget &&
139
- child.crisp?.budget &&
140
- parent.crisp.budget.unit === child.crisp.budget.unit) {
141
- if (child.crisp.budget.cap > parent.crisp.budget.cap) {
142
- return false;
143
- }
144
- }
145
- // Scopes: child scopes must be subset of parent scopes
146
- // This is a simplified check - full validation is complex
147
- if (parent.crisp && child.crisp) {
148
- const parentResources = new Set(parent.crisp.scopes.map((s) => s.resource));
149
- const allChildResourcesInParent = child.crisp.scopes.every((childScope) => {
150
- // Check if child resource matches any parent resource
151
- return parent.crisp.scopes.some((parentScope) => {
152
- if (parentScope.matcher === 'exact') {
153
- return parentScope.resource === childScope.resource;
154
- }
155
- if (parentScope.matcher === 'prefix') {
156
- return childScope.resource.startsWith(parentScope.resource);
157
- }
158
- // regex matching would require runtime regex evaluation
159
- return true; // Can't validate regex at type level
160
- });
161
- });
162
- return allChildResourcesInParent;
163
- }
164
- return true; // Can't validate if crisp is not present
165
- }
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
- function doesResourceMatchScope(resource, scope) {
174
- switch (scope.matcher) {
175
- case 'exact':
176
- return resource === scope.resource;
177
- case 'prefix':
178
- return resource.startsWith(scope.resource);
179
- case 'regex':
180
- try {
181
- const regex = new RegExp(scope.resource);
182
- return regex.test(resource);
183
- }
184
- catch {
185
- return false;
186
- }
187
- default:
188
- return false;
189
- }
190
- }
191
- /**
192
- * Constants
193
- */
194
- /**
195
- * Supported currency types
196
- */
197
- exports.SUPPORTED_CURRENCIES = ['USD', 'ops', 'points'];
198
- /**
199
- * Supported scope matchers
200
- */
201
- exports.SUPPORTED_MATCHERS = ['exact', 'prefix', 'regex'];
202
- /**
203
- * Maximum reasonable budget cap (for validation)
204
- */
205
- exports.MAX_BUDGET_CAP = Number.MAX_SAFE_INTEGER;
206
- /**
207
- * Maximum reasonable window duration (10 years in seconds)
208
- */
209
- exports.MAX_WINDOW_DURATION_SEC = 10 * 365 * 24 * 60 * 60;
210
- //# sourceMappingURL=constraints.js.map
@@ -1,8 +0,0 @@
1
- /**
2
- * Delegation Module Exports
3
- *
4
- * Types and schemas for delegation records and CRISP constraints
5
- */
6
- export * from './schemas.js';
7
- export * from './constraints.js';
8
- //# sourceMappingURL=index.d.ts.map
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /**
3
- * Delegation Module Exports
4
- *
5
- * Types and schemas for delegation records and CRISP constraints
6
- */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- __exportStar(require("./schemas.js"), exports);
23
- __exportStar(require("./constraints.js"), exports);
24
- //# sourceMappingURL=index.js.map