@kya-os/contracts 1.5.2-canary.4 → 1.5.2-canary.5

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 (97) hide show
  1. package/dist/agentshield-api/endpoints.d.ts +50 -0
  2. package/dist/agentshield-api/endpoints.js +46 -0
  3. package/dist/agentshield-api/index.d.ts +13 -0
  4. package/dist/agentshield-api/index.js +37 -0
  5. package/dist/agentshield-api/schemas.d.ts +6032 -0
  6. package/dist/agentshield-api/schemas.js +240 -0
  7. package/dist/agentshield-api/types.d.ts +231 -0
  8. package/dist/agentshield-api/types.js +26 -0
  9. package/dist/cli.d.ts +388 -0
  10. package/dist/cli.js +121 -0
  11. package/dist/config/base.d.ts +96 -0
  12. package/dist/config/base.js +11 -0
  13. package/dist/config/builder.d.ts +33 -0
  14. package/dist/config/builder.js +74 -0
  15. package/dist/config/delegation.d.ts +194 -0
  16. package/dist/config/delegation.js +10 -0
  17. package/dist/config/identity.d.ts +116 -0
  18. package/dist/config/identity.js +10 -0
  19. package/dist/config/index.d.ts +34 -0
  20. package/dist/config/index.js +14 -0
  21. package/dist/config/proofing.d.ts +120 -0
  22. package/dist/config/proofing.js +10 -0
  23. package/dist/config/tool-protection.d.ts +139 -0
  24. package/dist/config/tool-protection.js +10 -0
  25. package/dist/consent/index.d.ts +6 -0
  26. package/dist/consent/index.js +22 -0
  27. package/dist/consent/schemas.d.ts +738 -0
  28. package/dist/consent/schemas.js +186 -0
  29. package/dist/consent/types.d.ts +155 -0
  30. package/dist/consent/types.js +10 -0
  31. package/dist/dashboard-config/default-config.d.ts +49 -0
  32. package/dist/dashboard-config/default-config.js +240 -0
  33. package/dist/dashboard-config/index.d.ts +10 -0
  34. package/dist/dashboard-config/index.js +35 -0
  35. package/dist/dashboard-config/schemas.d.ts +5904 -0
  36. package/dist/dashboard-config/schemas.js +254 -0
  37. package/dist/dashboard-config/types.d.ts +337 -0
  38. package/dist/dashboard-config/types.js +10 -0
  39. package/dist/delegation/constraints.d.ts +1021 -0
  40. package/dist/delegation/constraints.js +218 -0
  41. package/dist/delegation/index.d.ts +7 -0
  42. package/dist/delegation/index.js +23 -0
  43. package/dist/delegation/schemas.d.ts +8457 -0
  44. package/dist/delegation/schemas.js +475 -0
  45. package/dist/did/index.d.ts +8 -0
  46. package/dist/did/index.js +24 -0
  47. package/dist/did/resolve-contract.d.ts +219 -0
  48. package/dist/did/resolve-contract.js +31 -0
  49. package/dist/did/schemas.d.ts +112 -0
  50. package/dist/did/schemas.js +172 -0
  51. package/dist/did/types.d.ts +163 -0
  52. package/dist/did/types.js +70 -0
  53. package/dist/env/constants.d.ts +57 -0
  54. package/dist/env/constants.js +59 -0
  55. package/dist/env/index.d.ts +4 -0
  56. package/dist/env/index.js +20 -0
  57. package/dist/handshake.d.ts +172 -0
  58. package/dist/handshake.js +60 -0
  59. package/dist/index.d.ts +25 -0
  60. package/dist/index.js +55 -0
  61. package/dist/proof/index.d.ts +9 -0
  62. package/dist/proof/index.js +38 -0
  63. package/dist/proof/proof-record.d.ts +837 -0
  64. package/dist/proof/proof-record.js +133 -0
  65. package/dist/proof/signing-spec.d.ts +146 -0
  66. package/dist/proof/signing-spec.js +122 -0
  67. package/dist/proof.d.ts +414 -0
  68. package/dist/proof.js +82 -0
  69. package/dist/registry.d.ts +342 -0
  70. package/dist/registry.js +118 -0
  71. package/dist/runtime/errors.d.ts +347 -0
  72. package/dist/runtime/errors.js +119 -0
  73. package/dist/runtime/headers.d.ts +83 -0
  74. package/dist/runtime/headers.js +81 -0
  75. package/dist/runtime/index.d.ts +5 -0
  76. package/dist/runtime/index.js +21 -0
  77. package/dist/test.d.ts +251 -0
  78. package/dist/test.js +119 -0
  79. package/dist/tlkrc/index.d.ts +4 -0
  80. package/dist/tlkrc/index.js +20 -0
  81. package/dist/tlkrc/rotation.d.ts +245 -0
  82. package/dist/tlkrc/rotation.js +126 -0
  83. package/dist/tool-protection/index.d.ts +227 -0
  84. package/dist/tool-protection/index.js +113 -0
  85. package/dist/utils/validation.d.ts +30 -0
  86. package/dist/utils/validation.js +69 -0
  87. package/dist/vc/index.d.ts +7 -0
  88. package/dist/vc/index.js +23 -0
  89. package/dist/vc/schemas.d.ts +2483 -0
  90. package/dist/vc/schemas.js +224 -0
  91. package/dist/vc/statuslist.d.ts +493 -0
  92. package/dist/vc/statuslist.js +132 -0
  93. package/dist/verifier.d.ts +205 -0
  94. package/dist/verifier.js +83 -0
  95. package/dist/well-known/index.d.ts +308 -0
  96. package/dist/well-known/index.js +134 -0
  97. package/package.json +1 -1
@@ -0,0 +1,218 @@
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
+ /**
80
+ * Optional target server DID(s) for this delegation
81
+ * If omitted, delegation is valid on any server accepting the scopes
82
+ * If specified, delegation is only valid on the specified server(s)
83
+ */
84
+ audience: zod_1.z.union([
85
+ zod_1.z.string().startsWith("did:"),
86
+ zod_1.z.array(zod_1.z.string().startsWith("did:"))
87
+ ]).optional(),
88
+ /** CRISP-specific constraints (full model) */
89
+ crisp: zod_1.z.object({
90
+ /** Optional budget constraint */
91
+ budget: exports.CrispBudgetSchema.optional(),
92
+ /** Required: at least one scope */
93
+ scopes: zod_1.z.array(exports.CrispScopeSchema).min(1),
94
+ /** Optional additional CRISP fields */
95
+ }).passthrough().optional(),
96
+ }).passthrough(); // Allow extensibility
97
+ /**
98
+ * Validation Helpers
99
+ */
100
+ /**
101
+ * Validate delegation constraints
102
+ *
103
+ * @param constraints - The constraints to validate
104
+ * @returns Validation result
105
+ */
106
+ function validateDelegationConstraints(constraints) {
107
+ return exports.DelegationConstraintsSchema.safeParse(constraints);
108
+ }
109
+ /**
110
+ * Check if constraints have a valid time range
111
+ *
112
+ * @param constraints - The constraints to check
113
+ * @returns true if time range is valid or no time range specified
114
+ */
115
+ function hasValidTimeRange(constraints) {
116
+ if (constraints.notBefore === undefined && constraints.notAfter === undefined) {
117
+ return true;
118
+ }
119
+ if (constraints.notBefore !== undefined && constraints.notAfter !== undefined) {
120
+ return constraints.notBefore < constraints.notAfter;
121
+ }
122
+ return true;
123
+ }
124
+ /**
125
+ * Check if child constraints are within parent constraints
126
+ *
127
+ * This performs basic structural checks. Full chain validation
128
+ * requires runtime implementation.
129
+ *
130
+ * @param parent - Parent delegation constraints
131
+ * @param child - Child delegation constraints
132
+ * @returns true if child is within parent bounds
133
+ */
134
+ function areChildConstraintsValid(parent, child) {
135
+ // Time bounds: child must be within parent
136
+ if (parent.notBefore !== undefined && child.notBefore !== undefined) {
137
+ if (child.notBefore < parent.notBefore) {
138
+ return false;
139
+ }
140
+ }
141
+ if (parent.notAfter !== undefined && child.notAfter !== undefined) {
142
+ if (child.notAfter > parent.notAfter) {
143
+ return false;
144
+ }
145
+ }
146
+ // Budget: child must be ≤ parent (if same unit)
147
+ if (parent.crisp?.budget &&
148
+ child.crisp?.budget &&
149
+ parent.crisp.budget.unit === child.crisp.budget.unit) {
150
+ if (child.crisp.budget.cap > parent.crisp.budget.cap) {
151
+ return false;
152
+ }
153
+ }
154
+ // Scopes: child scopes must be subset of parent scopes
155
+ // This is a simplified check - full validation is complex
156
+ if (parent.crisp && child.crisp) {
157
+ const parentResources = new Set(parent.crisp.scopes.map((s) => s.resource));
158
+ const allChildResourcesInParent = child.crisp.scopes.every((childScope) => {
159
+ // Check if child resource matches any parent resource
160
+ return parent.crisp.scopes.some((parentScope) => {
161
+ if (parentScope.matcher === 'exact') {
162
+ return parentScope.resource === childScope.resource;
163
+ }
164
+ if (parentScope.matcher === 'prefix') {
165
+ return childScope.resource.startsWith(parentScope.resource);
166
+ }
167
+ // regex matching would require runtime regex evaluation
168
+ return true; // Can't validate regex at type level
169
+ });
170
+ });
171
+ return allChildResourcesInParent;
172
+ }
173
+ return true; // Can't validate if crisp is not present
174
+ }
175
+ /**
176
+ * Check if a resource matches a scope
177
+ *
178
+ * @param resource - The resource to check
179
+ * @param scope - The scope to match against
180
+ * @returns true if resource matches scope
181
+ */
182
+ function doesResourceMatchScope(resource, scope) {
183
+ switch (scope.matcher) {
184
+ case 'exact':
185
+ return resource === scope.resource;
186
+ case 'prefix':
187
+ return resource.startsWith(scope.resource);
188
+ case 'regex':
189
+ try {
190
+ const regex = new RegExp(scope.resource);
191
+ return regex.test(resource);
192
+ }
193
+ catch {
194
+ return false;
195
+ }
196
+ default:
197
+ return false;
198
+ }
199
+ }
200
+ /**
201
+ * Constants
202
+ */
203
+ /**
204
+ * Supported currency types
205
+ */
206
+ exports.SUPPORTED_CURRENCIES = ['USD', 'ops', 'points'];
207
+ /**
208
+ * Supported scope matchers
209
+ */
210
+ exports.SUPPORTED_MATCHERS = ['exact', 'prefix', 'regex'];
211
+ /**
212
+ * Maximum reasonable budget cap (for validation)
213
+ */
214
+ exports.MAX_BUDGET_CAP = Number.MAX_SAFE_INTEGER;
215
+ /**
216
+ * Maximum reasonable window duration (10 years in seconds)
217
+ */
218
+ exports.MAX_WINDOW_DURATION_SEC = 10 * 365 * 24 * 60 * 60;
@@ -0,0 +1,7 @@
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';
@@ -0,0 +1,23 @@
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);