@kya-os/contracts 1.2.1 → 1.2.2

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 (57) hide show
  1. package/dist/delegation/constraints.d.ts +982 -0
  2. package/dist/delegation/constraints.js +205 -0
  3. package/dist/delegation/index.d.ts +8 -0
  4. package/dist/delegation/index.js +24 -0
  5. package/dist/delegation/schemas.d.ts +3787 -0
  6. package/dist/delegation/schemas.js +230 -0
  7. package/dist/did/index.d.ts +8 -0
  8. package/dist/did/index.js +24 -0
  9. package/dist/did/resolve-contract.d.ts +220 -0
  10. package/dist/did/resolve-contract.js +32 -0
  11. package/dist/did/types.d.ts +164 -0
  12. package/dist/did/types.js +71 -0
  13. package/dist/env/constants.d.ts +58 -0
  14. package/dist/env/constants.js +60 -0
  15. package/dist/env/index.d.ts +5 -0
  16. package/dist/env/index.js +21 -0
  17. package/dist/index.d.ts +9 -1
  18. package/dist/index.js +17 -2
  19. package/dist/proof/index.d.ts +9 -0
  20. package/dist/proof/index.js +25 -0
  21. package/dist/proof/proof-record.d.ts +838 -0
  22. package/dist/proof/proof-record.js +134 -0
  23. package/dist/proof/signing-spec.d.ts +147 -0
  24. package/dist/proof/signing-spec.js +123 -0
  25. package/dist/runtime/errors.d.ts +348 -0
  26. package/dist/runtime/errors.js +120 -0
  27. package/dist/runtime/headers.d.ts +84 -0
  28. package/dist/runtime/headers.js +82 -0
  29. package/dist/runtime/index.d.ts +6 -0
  30. package/dist/runtime/index.js +22 -0
  31. package/dist/tlkrc/index.d.ts +5 -0
  32. package/dist/tlkrc/index.js +21 -0
  33. package/dist/tlkrc/rotation.d.ts +246 -0
  34. package/dist/tlkrc/rotation.js +127 -0
  35. package/dist/vc/index.d.ts +8 -0
  36. package/dist/vc/index.js +24 -0
  37. package/dist/vc/schemas.d.ts +2484 -0
  38. package/dist/vc/schemas.js +225 -0
  39. package/dist/vc/statuslist.d.ts +494 -0
  40. package/dist/vc/statuslist.js +133 -0
  41. package/package.json +51 -6
  42. package/dist/cli.d.ts.map +0 -1
  43. package/dist/cli.js.map +0 -1
  44. package/dist/handshake.d.ts.map +0 -1
  45. package/dist/handshake.js.map +0 -1
  46. package/dist/index.d.ts.map +0 -1
  47. package/dist/index.js.map +0 -1
  48. package/dist/proof.d.ts.map +0 -1
  49. package/dist/proof.js.map +0 -1
  50. package/dist/registry.d.ts.map +0 -1
  51. package/dist/registry.js.map +0 -1
  52. package/dist/test.d.ts.map +0 -1
  53. package/dist/test.js.map +0 -1
  54. package/dist/utils/validation.d.ts.map +0 -1
  55. package/dist/utils/validation.js.map +0 -1
  56. package/dist/verifier.d.ts.map +0 -1
  57. package/dist/verifier.js.map +0 -1
@@ -0,0 +1,982 @@
1
+ /**
2
+ * CRISP Delegation Constraints
3
+ *
4
+ * Types and schemas for CRISP (Constrained Resource Intent Specification Protocol)
5
+ * constraints on delegations. CRISP enables fine-grained authorization control.
6
+ *
7
+ * Related Spec: MCP-I §4.2
8
+ * Python Reference: Delegation-Documentation.md
9
+ */
10
+ import { z } from 'zod';
11
+ /**
12
+ * Currency types for CRISP budgets
13
+ */
14
+ export declare const CurrencySchema: z.ZodEnum<["USD", "ops", "points"]>;
15
+ export type Currency = z.infer<typeof CurrencySchema>;
16
+ /**
17
+ * Window kind for budget enforcement
18
+ */
19
+ export declare const WindowKindSchema: z.ZodEnum<["rolling", "fixed"]>;
20
+ export type WindowKind = z.infer<typeof WindowKindSchema>;
21
+ /**
22
+ * Budget Window Schema
23
+ *
24
+ * Defines the time window for budget enforcement
25
+ */
26
+ export declare const BudgetWindowSchema: z.ZodObject<{
27
+ /** Type of window (rolling or fixed) */
28
+ kind: z.ZodEnum<["rolling", "fixed"]>;
29
+ /** Duration in seconds */
30
+ durationSec: z.ZodNumber;
31
+ }, "strip", z.ZodTypeAny, {
32
+ kind: "rolling" | "fixed";
33
+ durationSec: number;
34
+ }, {
35
+ kind: "rolling" | "fixed";
36
+ durationSec: number;
37
+ }>;
38
+ export type BudgetWindow = z.infer<typeof BudgetWindowSchema>;
39
+ /**
40
+ * CRISP Budget Schema
41
+ *
42
+ * Defines spending/usage limits for a delegation
43
+ */
44
+ export declare const CrispBudgetSchema: z.ZodObject<{
45
+ /** Unit of the budget */
46
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
47
+ /** Cap/limit for the budget */
48
+ cap: z.ZodNumber;
49
+ /** Optional time window for the budget */
50
+ window: z.ZodOptional<z.ZodObject<{
51
+ /** Type of window (rolling or fixed) */
52
+ kind: z.ZodEnum<["rolling", "fixed"]>;
53
+ /** Duration in seconds */
54
+ durationSec: z.ZodNumber;
55
+ }, "strip", z.ZodTypeAny, {
56
+ kind: "rolling" | "fixed";
57
+ durationSec: number;
58
+ }, {
59
+ kind: "rolling" | "fixed";
60
+ durationSec: number;
61
+ }>>;
62
+ }, "strip", z.ZodTypeAny, {
63
+ unit: "USD" | "ops" | "points";
64
+ cap: number;
65
+ window?: {
66
+ kind: "rolling" | "fixed";
67
+ durationSec: number;
68
+ } | undefined;
69
+ }, {
70
+ unit: "USD" | "ops" | "points";
71
+ cap: number;
72
+ window?: {
73
+ kind: "rolling" | "fixed";
74
+ durationSec: number;
75
+ } | undefined;
76
+ }>;
77
+ export type CrispBudget = z.infer<typeof CrispBudgetSchema>;
78
+ /**
79
+ * Scope matcher types
80
+ */
81
+ export declare const ScopeMatcherSchema: z.ZodEnum<["exact", "prefix", "regex"]>;
82
+ export type ScopeMatcher = z.infer<typeof ScopeMatcherSchema>;
83
+ /**
84
+ * CRISP Scope Schema
85
+ *
86
+ * Defines what resources/actions are allowed in a delegation
87
+ */
88
+ export declare const CrispScopeSchema: z.ZodObject<{
89
+ /** Resource identifier (e.g., "api:users", "data:emails") */
90
+ resource: z.ZodString;
91
+ /** How to match the resource */
92
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
93
+ /** Optional additional constraints on this scope */
94
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
95
+ }, "strip", z.ZodTypeAny, {
96
+ resource: string;
97
+ matcher: "exact" | "prefix" | "regex";
98
+ constraints?: Record<string, any> | undefined;
99
+ }, {
100
+ resource: string;
101
+ matcher: "exact" | "prefix" | "regex";
102
+ constraints?: Record<string, any> | undefined;
103
+ }>;
104
+ export type CrispScope = z.infer<typeof CrispScopeSchema>;
105
+ /**
106
+ * Delegation Constraints Schema (CRISP)
107
+ *
108
+ * Complete constraint specification for a delegation
109
+ */
110
+ export declare const DelegationConstraintsSchema: z.ZodObject<{
111
+ /** Not valid before (Unix timestamp in seconds) */
112
+ notBefore: z.ZodOptional<z.ZodNumber>;
113
+ /** Not valid after (Unix timestamp in seconds) */
114
+ notAfter: z.ZodOptional<z.ZodNumber>;
115
+ /** CRISP-specific constraints */
116
+ crisp: z.ZodObject<{
117
+ /** Optional budget constraint */
118
+ budget: z.ZodOptional<z.ZodObject<{
119
+ /** Unit of the budget */
120
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
121
+ /** Cap/limit for the budget */
122
+ cap: z.ZodNumber;
123
+ /** Optional time window for the budget */
124
+ window: z.ZodOptional<z.ZodObject<{
125
+ /** Type of window (rolling or fixed) */
126
+ kind: z.ZodEnum<["rolling", "fixed"]>;
127
+ /** Duration in seconds */
128
+ durationSec: z.ZodNumber;
129
+ }, "strip", z.ZodTypeAny, {
130
+ kind: "rolling" | "fixed";
131
+ durationSec: number;
132
+ }, {
133
+ kind: "rolling" | "fixed";
134
+ durationSec: number;
135
+ }>>;
136
+ }, "strip", z.ZodTypeAny, {
137
+ unit: "USD" | "ops" | "points";
138
+ cap: number;
139
+ window?: {
140
+ kind: "rolling" | "fixed";
141
+ durationSec: number;
142
+ } | undefined;
143
+ }, {
144
+ unit: "USD" | "ops" | "points";
145
+ cap: number;
146
+ window?: {
147
+ kind: "rolling" | "fixed";
148
+ durationSec: number;
149
+ } | undefined;
150
+ }>>;
151
+ /** Required: at least one scope */
152
+ scopes: z.ZodArray<z.ZodObject<{
153
+ /** Resource identifier (e.g., "api:users", "data:emails") */
154
+ resource: z.ZodString;
155
+ /** How to match the resource */
156
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
157
+ /** Optional additional constraints on this scope */
158
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
159
+ }, "strip", z.ZodTypeAny, {
160
+ resource: string;
161
+ matcher: "exact" | "prefix" | "regex";
162
+ constraints?: Record<string, any> | undefined;
163
+ }, {
164
+ resource: string;
165
+ matcher: "exact" | "prefix" | "regex";
166
+ constraints?: Record<string, any> | undefined;
167
+ }>, "many">;
168
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
169
+ /** Optional budget constraint */
170
+ budget: z.ZodOptional<z.ZodObject<{
171
+ /** Unit of the budget */
172
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
173
+ /** Cap/limit for the budget */
174
+ cap: z.ZodNumber;
175
+ /** Optional time window for the budget */
176
+ window: z.ZodOptional<z.ZodObject<{
177
+ /** Type of window (rolling or fixed) */
178
+ kind: z.ZodEnum<["rolling", "fixed"]>;
179
+ /** Duration in seconds */
180
+ durationSec: z.ZodNumber;
181
+ }, "strip", z.ZodTypeAny, {
182
+ kind: "rolling" | "fixed";
183
+ durationSec: number;
184
+ }, {
185
+ kind: "rolling" | "fixed";
186
+ durationSec: number;
187
+ }>>;
188
+ }, "strip", z.ZodTypeAny, {
189
+ unit: "USD" | "ops" | "points";
190
+ cap: number;
191
+ window?: {
192
+ kind: "rolling" | "fixed";
193
+ durationSec: number;
194
+ } | undefined;
195
+ }, {
196
+ unit: "USD" | "ops" | "points";
197
+ cap: number;
198
+ window?: {
199
+ kind: "rolling" | "fixed";
200
+ durationSec: number;
201
+ } | undefined;
202
+ }>>;
203
+ /** Required: at least one scope */
204
+ scopes: z.ZodArray<z.ZodObject<{
205
+ /** Resource identifier (e.g., "api:users", "data:emails") */
206
+ resource: z.ZodString;
207
+ /** How to match the resource */
208
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
209
+ /** Optional additional constraints on this scope */
210
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
211
+ }, "strip", z.ZodTypeAny, {
212
+ resource: string;
213
+ matcher: "exact" | "prefix" | "regex";
214
+ constraints?: Record<string, any> | undefined;
215
+ }, {
216
+ resource: string;
217
+ matcher: "exact" | "prefix" | "regex";
218
+ constraints?: Record<string, any> | undefined;
219
+ }>, "many">;
220
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
221
+ /** Optional budget constraint */
222
+ budget: z.ZodOptional<z.ZodObject<{
223
+ /** Unit of the budget */
224
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
225
+ /** Cap/limit for the budget */
226
+ cap: z.ZodNumber;
227
+ /** Optional time window for the budget */
228
+ window: z.ZodOptional<z.ZodObject<{
229
+ /** Type of window (rolling or fixed) */
230
+ kind: z.ZodEnum<["rolling", "fixed"]>;
231
+ /** Duration in seconds */
232
+ durationSec: z.ZodNumber;
233
+ }, "strip", z.ZodTypeAny, {
234
+ kind: "rolling" | "fixed";
235
+ durationSec: number;
236
+ }, {
237
+ kind: "rolling" | "fixed";
238
+ durationSec: number;
239
+ }>>;
240
+ }, "strip", z.ZodTypeAny, {
241
+ unit: "USD" | "ops" | "points";
242
+ cap: number;
243
+ window?: {
244
+ kind: "rolling" | "fixed";
245
+ durationSec: number;
246
+ } | undefined;
247
+ }, {
248
+ unit: "USD" | "ops" | "points";
249
+ cap: number;
250
+ window?: {
251
+ kind: "rolling" | "fixed";
252
+ durationSec: number;
253
+ } | undefined;
254
+ }>>;
255
+ /** Required: at least one scope */
256
+ scopes: z.ZodArray<z.ZodObject<{
257
+ /** Resource identifier (e.g., "api:users", "data:emails") */
258
+ resource: z.ZodString;
259
+ /** How to match the resource */
260
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
261
+ /** Optional additional constraints on this scope */
262
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
263
+ }, "strip", z.ZodTypeAny, {
264
+ resource: string;
265
+ matcher: "exact" | "prefix" | "regex";
266
+ constraints?: Record<string, any> | undefined;
267
+ }, {
268
+ resource: string;
269
+ matcher: "exact" | "prefix" | "regex";
270
+ constraints?: Record<string, any> | undefined;
271
+ }>, "many">;
272
+ }, z.ZodTypeAny, "passthrough">>;
273
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
274
+ /** Not valid before (Unix timestamp in seconds) */
275
+ notBefore: z.ZodOptional<z.ZodNumber>;
276
+ /** Not valid after (Unix timestamp in seconds) */
277
+ notAfter: z.ZodOptional<z.ZodNumber>;
278
+ /** CRISP-specific constraints */
279
+ crisp: z.ZodObject<{
280
+ /** Optional budget constraint */
281
+ budget: z.ZodOptional<z.ZodObject<{
282
+ /** Unit of the budget */
283
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
284
+ /** Cap/limit for the budget */
285
+ cap: z.ZodNumber;
286
+ /** Optional time window for the budget */
287
+ window: z.ZodOptional<z.ZodObject<{
288
+ /** Type of window (rolling or fixed) */
289
+ kind: z.ZodEnum<["rolling", "fixed"]>;
290
+ /** Duration in seconds */
291
+ durationSec: z.ZodNumber;
292
+ }, "strip", z.ZodTypeAny, {
293
+ kind: "rolling" | "fixed";
294
+ durationSec: number;
295
+ }, {
296
+ kind: "rolling" | "fixed";
297
+ durationSec: number;
298
+ }>>;
299
+ }, "strip", z.ZodTypeAny, {
300
+ unit: "USD" | "ops" | "points";
301
+ cap: number;
302
+ window?: {
303
+ kind: "rolling" | "fixed";
304
+ durationSec: number;
305
+ } | undefined;
306
+ }, {
307
+ unit: "USD" | "ops" | "points";
308
+ cap: number;
309
+ window?: {
310
+ kind: "rolling" | "fixed";
311
+ durationSec: number;
312
+ } | undefined;
313
+ }>>;
314
+ /** Required: at least one scope */
315
+ scopes: z.ZodArray<z.ZodObject<{
316
+ /** Resource identifier (e.g., "api:users", "data:emails") */
317
+ resource: z.ZodString;
318
+ /** How to match the resource */
319
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
320
+ /** Optional additional constraints on this scope */
321
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
322
+ }, "strip", z.ZodTypeAny, {
323
+ resource: string;
324
+ matcher: "exact" | "prefix" | "regex";
325
+ constraints?: Record<string, any> | undefined;
326
+ }, {
327
+ resource: string;
328
+ matcher: "exact" | "prefix" | "regex";
329
+ constraints?: Record<string, any> | undefined;
330
+ }>, "many">;
331
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
332
+ /** Optional budget constraint */
333
+ budget: z.ZodOptional<z.ZodObject<{
334
+ /** Unit of the budget */
335
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
336
+ /** Cap/limit for the budget */
337
+ cap: z.ZodNumber;
338
+ /** Optional time window for the budget */
339
+ window: z.ZodOptional<z.ZodObject<{
340
+ /** Type of window (rolling or fixed) */
341
+ kind: z.ZodEnum<["rolling", "fixed"]>;
342
+ /** Duration in seconds */
343
+ durationSec: z.ZodNumber;
344
+ }, "strip", z.ZodTypeAny, {
345
+ kind: "rolling" | "fixed";
346
+ durationSec: number;
347
+ }, {
348
+ kind: "rolling" | "fixed";
349
+ durationSec: number;
350
+ }>>;
351
+ }, "strip", z.ZodTypeAny, {
352
+ unit: "USD" | "ops" | "points";
353
+ cap: number;
354
+ window?: {
355
+ kind: "rolling" | "fixed";
356
+ durationSec: number;
357
+ } | undefined;
358
+ }, {
359
+ unit: "USD" | "ops" | "points";
360
+ cap: number;
361
+ window?: {
362
+ kind: "rolling" | "fixed";
363
+ durationSec: number;
364
+ } | undefined;
365
+ }>>;
366
+ /** Required: at least one scope */
367
+ scopes: z.ZodArray<z.ZodObject<{
368
+ /** Resource identifier (e.g., "api:users", "data:emails") */
369
+ resource: z.ZodString;
370
+ /** How to match the resource */
371
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
372
+ /** Optional additional constraints on this scope */
373
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
374
+ }, "strip", z.ZodTypeAny, {
375
+ resource: string;
376
+ matcher: "exact" | "prefix" | "regex";
377
+ constraints?: Record<string, any> | undefined;
378
+ }, {
379
+ resource: string;
380
+ matcher: "exact" | "prefix" | "regex";
381
+ constraints?: Record<string, any> | undefined;
382
+ }>, "many">;
383
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
384
+ /** Optional budget constraint */
385
+ budget: z.ZodOptional<z.ZodObject<{
386
+ /** Unit of the budget */
387
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
388
+ /** Cap/limit for the budget */
389
+ cap: z.ZodNumber;
390
+ /** Optional time window for the budget */
391
+ window: z.ZodOptional<z.ZodObject<{
392
+ /** Type of window (rolling or fixed) */
393
+ kind: z.ZodEnum<["rolling", "fixed"]>;
394
+ /** Duration in seconds */
395
+ durationSec: z.ZodNumber;
396
+ }, "strip", z.ZodTypeAny, {
397
+ kind: "rolling" | "fixed";
398
+ durationSec: number;
399
+ }, {
400
+ kind: "rolling" | "fixed";
401
+ durationSec: number;
402
+ }>>;
403
+ }, "strip", z.ZodTypeAny, {
404
+ unit: "USD" | "ops" | "points";
405
+ cap: number;
406
+ window?: {
407
+ kind: "rolling" | "fixed";
408
+ durationSec: number;
409
+ } | undefined;
410
+ }, {
411
+ unit: "USD" | "ops" | "points";
412
+ cap: number;
413
+ window?: {
414
+ kind: "rolling" | "fixed";
415
+ durationSec: number;
416
+ } | undefined;
417
+ }>>;
418
+ /** Required: at least one scope */
419
+ scopes: z.ZodArray<z.ZodObject<{
420
+ /** Resource identifier (e.g., "api:users", "data:emails") */
421
+ resource: z.ZodString;
422
+ /** How to match the resource */
423
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
424
+ /** Optional additional constraints on this scope */
425
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
426
+ }, "strip", z.ZodTypeAny, {
427
+ resource: string;
428
+ matcher: "exact" | "prefix" | "regex";
429
+ constraints?: Record<string, any> | undefined;
430
+ }, {
431
+ resource: string;
432
+ matcher: "exact" | "prefix" | "regex";
433
+ constraints?: Record<string, any> | undefined;
434
+ }>, "many">;
435
+ }, z.ZodTypeAny, "passthrough">>;
436
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
437
+ /** Not valid before (Unix timestamp in seconds) */
438
+ notBefore: z.ZodOptional<z.ZodNumber>;
439
+ /** Not valid after (Unix timestamp in seconds) */
440
+ notAfter: z.ZodOptional<z.ZodNumber>;
441
+ /** CRISP-specific constraints */
442
+ crisp: z.ZodObject<{
443
+ /** Optional budget constraint */
444
+ budget: z.ZodOptional<z.ZodObject<{
445
+ /** Unit of the budget */
446
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
447
+ /** Cap/limit for the budget */
448
+ cap: z.ZodNumber;
449
+ /** Optional time window for the budget */
450
+ window: z.ZodOptional<z.ZodObject<{
451
+ /** Type of window (rolling or fixed) */
452
+ kind: z.ZodEnum<["rolling", "fixed"]>;
453
+ /** Duration in seconds */
454
+ durationSec: z.ZodNumber;
455
+ }, "strip", z.ZodTypeAny, {
456
+ kind: "rolling" | "fixed";
457
+ durationSec: number;
458
+ }, {
459
+ kind: "rolling" | "fixed";
460
+ durationSec: number;
461
+ }>>;
462
+ }, "strip", z.ZodTypeAny, {
463
+ unit: "USD" | "ops" | "points";
464
+ cap: number;
465
+ window?: {
466
+ kind: "rolling" | "fixed";
467
+ durationSec: number;
468
+ } | undefined;
469
+ }, {
470
+ unit: "USD" | "ops" | "points";
471
+ cap: number;
472
+ window?: {
473
+ kind: "rolling" | "fixed";
474
+ durationSec: number;
475
+ } | undefined;
476
+ }>>;
477
+ /** Required: at least one scope */
478
+ scopes: z.ZodArray<z.ZodObject<{
479
+ /** Resource identifier (e.g., "api:users", "data:emails") */
480
+ resource: z.ZodString;
481
+ /** How to match the resource */
482
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
483
+ /** Optional additional constraints on this scope */
484
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
485
+ }, "strip", z.ZodTypeAny, {
486
+ resource: string;
487
+ matcher: "exact" | "prefix" | "regex";
488
+ constraints?: Record<string, any> | undefined;
489
+ }, {
490
+ resource: string;
491
+ matcher: "exact" | "prefix" | "regex";
492
+ constraints?: Record<string, any> | undefined;
493
+ }>, "many">;
494
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
495
+ /** Optional budget constraint */
496
+ budget: z.ZodOptional<z.ZodObject<{
497
+ /** Unit of the budget */
498
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
499
+ /** Cap/limit for the budget */
500
+ cap: z.ZodNumber;
501
+ /** Optional time window for the budget */
502
+ window: z.ZodOptional<z.ZodObject<{
503
+ /** Type of window (rolling or fixed) */
504
+ kind: z.ZodEnum<["rolling", "fixed"]>;
505
+ /** Duration in seconds */
506
+ durationSec: z.ZodNumber;
507
+ }, "strip", z.ZodTypeAny, {
508
+ kind: "rolling" | "fixed";
509
+ durationSec: number;
510
+ }, {
511
+ kind: "rolling" | "fixed";
512
+ durationSec: number;
513
+ }>>;
514
+ }, "strip", z.ZodTypeAny, {
515
+ unit: "USD" | "ops" | "points";
516
+ cap: number;
517
+ window?: {
518
+ kind: "rolling" | "fixed";
519
+ durationSec: number;
520
+ } | undefined;
521
+ }, {
522
+ unit: "USD" | "ops" | "points";
523
+ cap: number;
524
+ window?: {
525
+ kind: "rolling" | "fixed";
526
+ durationSec: number;
527
+ } | undefined;
528
+ }>>;
529
+ /** Required: at least one scope */
530
+ scopes: z.ZodArray<z.ZodObject<{
531
+ /** Resource identifier (e.g., "api:users", "data:emails") */
532
+ resource: z.ZodString;
533
+ /** How to match the resource */
534
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
535
+ /** Optional additional constraints on this scope */
536
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
537
+ }, "strip", z.ZodTypeAny, {
538
+ resource: string;
539
+ matcher: "exact" | "prefix" | "regex";
540
+ constraints?: Record<string, any> | undefined;
541
+ }, {
542
+ resource: string;
543
+ matcher: "exact" | "prefix" | "regex";
544
+ constraints?: Record<string, any> | undefined;
545
+ }>, "many">;
546
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
547
+ /** Optional budget constraint */
548
+ budget: z.ZodOptional<z.ZodObject<{
549
+ /** Unit of the budget */
550
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
551
+ /** Cap/limit for the budget */
552
+ cap: z.ZodNumber;
553
+ /** Optional time window for the budget */
554
+ window: z.ZodOptional<z.ZodObject<{
555
+ /** Type of window (rolling or fixed) */
556
+ kind: z.ZodEnum<["rolling", "fixed"]>;
557
+ /** Duration in seconds */
558
+ durationSec: z.ZodNumber;
559
+ }, "strip", z.ZodTypeAny, {
560
+ kind: "rolling" | "fixed";
561
+ durationSec: number;
562
+ }, {
563
+ kind: "rolling" | "fixed";
564
+ durationSec: number;
565
+ }>>;
566
+ }, "strip", z.ZodTypeAny, {
567
+ unit: "USD" | "ops" | "points";
568
+ cap: number;
569
+ window?: {
570
+ kind: "rolling" | "fixed";
571
+ durationSec: number;
572
+ } | undefined;
573
+ }, {
574
+ unit: "USD" | "ops" | "points";
575
+ cap: number;
576
+ window?: {
577
+ kind: "rolling" | "fixed";
578
+ durationSec: number;
579
+ } | undefined;
580
+ }>>;
581
+ /** Required: at least one scope */
582
+ scopes: z.ZodArray<z.ZodObject<{
583
+ /** Resource identifier (e.g., "api:users", "data:emails") */
584
+ resource: z.ZodString;
585
+ /** How to match the resource */
586
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
587
+ /** Optional additional constraints on this scope */
588
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
589
+ }, "strip", z.ZodTypeAny, {
590
+ resource: string;
591
+ matcher: "exact" | "prefix" | "regex";
592
+ constraints?: Record<string, any> | undefined;
593
+ }, {
594
+ resource: string;
595
+ matcher: "exact" | "prefix" | "regex";
596
+ constraints?: Record<string, any> | undefined;
597
+ }>, "many">;
598
+ }, z.ZodTypeAny, "passthrough">>;
599
+ }, z.ZodTypeAny, "passthrough">>;
600
+ export type DelegationConstraints = z.infer<typeof DelegationConstraintsSchema>;
601
+ /**
602
+ * Validation Helpers
603
+ */
604
+ /**
605
+ * Validate delegation constraints
606
+ *
607
+ * @param constraints - The constraints to validate
608
+ * @returns Validation result
609
+ */
610
+ export declare function validateDelegationConstraints(constraints: unknown): z.SafeParseReturnType<z.objectInputType<{
611
+ /** Not valid before (Unix timestamp in seconds) */
612
+ notBefore: z.ZodOptional<z.ZodNumber>;
613
+ /** Not valid after (Unix timestamp in seconds) */
614
+ notAfter: z.ZodOptional<z.ZodNumber>;
615
+ /** CRISP-specific constraints */
616
+ crisp: z.ZodObject<{
617
+ /** Optional budget constraint */
618
+ budget: z.ZodOptional<z.ZodObject<{
619
+ /** Unit of the budget */
620
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
621
+ /** Cap/limit for the budget */
622
+ cap: z.ZodNumber;
623
+ /** Optional time window for the budget */
624
+ window: z.ZodOptional<z.ZodObject<{
625
+ /** Type of window (rolling or fixed) */
626
+ kind: z.ZodEnum<["rolling", "fixed"]>;
627
+ /** Duration in seconds */
628
+ durationSec: z.ZodNumber;
629
+ }, "strip", z.ZodTypeAny, {
630
+ kind: "rolling" | "fixed";
631
+ durationSec: number;
632
+ }, {
633
+ kind: "rolling" | "fixed";
634
+ durationSec: number;
635
+ }>>;
636
+ }, "strip", z.ZodTypeAny, {
637
+ unit: "USD" | "ops" | "points";
638
+ cap: number;
639
+ window?: {
640
+ kind: "rolling" | "fixed";
641
+ durationSec: number;
642
+ } | undefined;
643
+ }, {
644
+ unit: "USD" | "ops" | "points";
645
+ cap: number;
646
+ window?: {
647
+ kind: "rolling" | "fixed";
648
+ durationSec: number;
649
+ } | undefined;
650
+ }>>;
651
+ /** Required: at least one scope */
652
+ scopes: z.ZodArray<z.ZodObject<{
653
+ /** Resource identifier (e.g., "api:users", "data:emails") */
654
+ resource: z.ZodString;
655
+ /** How to match the resource */
656
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
657
+ /** Optional additional constraints on this scope */
658
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
659
+ }, "strip", z.ZodTypeAny, {
660
+ resource: string;
661
+ matcher: "exact" | "prefix" | "regex";
662
+ constraints?: Record<string, any> | undefined;
663
+ }, {
664
+ resource: string;
665
+ matcher: "exact" | "prefix" | "regex";
666
+ constraints?: Record<string, any> | undefined;
667
+ }>, "many">;
668
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
669
+ /** Optional budget constraint */
670
+ budget: z.ZodOptional<z.ZodObject<{
671
+ /** Unit of the budget */
672
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
673
+ /** Cap/limit for the budget */
674
+ cap: z.ZodNumber;
675
+ /** Optional time window for the budget */
676
+ window: z.ZodOptional<z.ZodObject<{
677
+ /** Type of window (rolling or fixed) */
678
+ kind: z.ZodEnum<["rolling", "fixed"]>;
679
+ /** Duration in seconds */
680
+ durationSec: z.ZodNumber;
681
+ }, "strip", z.ZodTypeAny, {
682
+ kind: "rolling" | "fixed";
683
+ durationSec: number;
684
+ }, {
685
+ kind: "rolling" | "fixed";
686
+ durationSec: number;
687
+ }>>;
688
+ }, "strip", z.ZodTypeAny, {
689
+ unit: "USD" | "ops" | "points";
690
+ cap: number;
691
+ window?: {
692
+ kind: "rolling" | "fixed";
693
+ durationSec: number;
694
+ } | undefined;
695
+ }, {
696
+ unit: "USD" | "ops" | "points";
697
+ cap: number;
698
+ window?: {
699
+ kind: "rolling" | "fixed";
700
+ durationSec: number;
701
+ } | undefined;
702
+ }>>;
703
+ /** Required: at least one scope */
704
+ scopes: z.ZodArray<z.ZodObject<{
705
+ /** Resource identifier (e.g., "api:users", "data:emails") */
706
+ resource: z.ZodString;
707
+ /** How to match the resource */
708
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
709
+ /** Optional additional constraints on this scope */
710
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
711
+ }, "strip", z.ZodTypeAny, {
712
+ resource: string;
713
+ matcher: "exact" | "prefix" | "regex";
714
+ constraints?: Record<string, any> | undefined;
715
+ }, {
716
+ resource: string;
717
+ matcher: "exact" | "prefix" | "regex";
718
+ constraints?: Record<string, any> | undefined;
719
+ }>, "many">;
720
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
721
+ /** Optional budget constraint */
722
+ budget: z.ZodOptional<z.ZodObject<{
723
+ /** Unit of the budget */
724
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
725
+ /** Cap/limit for the budget */
726
+ cap: z.ZodNumber;
727
+ /** Optional time window for the budget */
728
+ window: z.ZodOptional<z.ZodObject<{
729
+ /** Type of window (rolling or fixed) */
730
+ kind: z.ZodEnum<["rolling", "fixed"]>;
731
+ /** Duration in seconds */
732
+ durationSec: z.ZodNumber;
733
+ }, "strip", z.ZodTypeAny, {
734
+ kind: "rolling" | "fixed";
735
+ durationSec: number;
736
+ }, {
737
+ kind: "rolling" | "fixed";
738
+ durationSec: number;
739
+ }>>;
740
+ }, "strip", z.ZodTypeAny, {
741
+ unit: "USD" | "ops" | "points";
742
+ cap: number;
743
+ window?: {
744
+ kind: "rolling" | "fixed";
745
+ durationSec: number;
746
+ } | undefined;
747
+ }, {
748
+ unit: "USD" | "ops" | "points";
749
+ cap: number;
750
+ window?: {
751
+ kind: "rolling" | "fixed";
752
+ durationSec: number;
753
+ } | undefined;
754
+ }>>;
755
+ /** Required: at least one scope */
756
+ scopes: z.ZodArray<z.ZodObject<{
757
+ /** Resource identifier (e.g., "api:users", "data:emails") */
758
+ resource: z.ZodString;
759
+ /** How to match the resource */
760
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
761
+ /** Optional additional constraints on this scope */
762
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
763
+ }, "strip", z.ZodTypeAny, {
764
+ resource: string;
765
+ matcher: "exact" | "prefix" | "regex";
766
+ constraints?: Record<string, any> | undefined;
767
+ }, {
768
+ resource: string;
769
+ matcher: "exact" | "prefix" | "regex";
770
+ constraints?: Record<string, any> | undefined;
771
+ }>, "many">;
772
+ }, z.ZodTypeAny, "passthrough">>;
773
+ }, z.ZodTypeAny, "passthrough">, z.objectOutputType<{
774
+ /** Not valid before (Unix timestamp in seconds) */
775
+ notBefore: z.ZodOptional<z.ZodNumber>;
776
+ /** Not valid after (Unix timestamp in seconds) */
777
+ notAfter: z.ZodOptional<z.ZodNumber>;
778
+ /** CRISP-specific constraints */
779
+ crisp: z.ZodObject<{
780
+ /** Optional budget constraint */
781
+ budget: z.ZodOptional<z.ZodObject<{
782
+ /** Unit of the budget */
783
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
784
+ /** Cap/limit for the budget */
785
+ cap: z.ZodNumber;
786
+ /** Optional time window for the budget */
787
+ window: z.ZodOptional<z.ZodObject<{
788
+ /** Type of window (rolling or fixed) */
789
+ kind: z.ZodEnum<["rolling", "fixed"]>;
790
+ /** Duration in seconds */
791
+ durationSec: z.ZodNumber;
792
+ }, "strip", z.ZodTypeAny, {
793
+ kind: "rolling" | "fixed";
794
+ durationSec: number;
795
+ }, {
796
+ kind: "rolling" | "fixed";
797
+ durationSec: number;
798
+ }>>;
799
+ }, "strip", z.ZodTypeAny, {
800
+ unit: "USD" | "ops" | "points";
801
+ cap: number;
802
+ window?: {
803
+ kind: "rolling" | "fixed";
804
+ durationSec: number;
805
+ } | undefined;
806
+ }, {
807
+ unit: "USD" | "ops" | "points";
808
+ cap: number;
809
+ window?: {
810
+ kind: "rolling" | "fixed";
811
+ durationSec: number;
812
+ } | undefined;
813
+ }>>;
814
+ /** Required: at least one scope */
815
+ scopes: z.ZodArray<z.ZodObject<{
816
+ /** Resource identifier (e.g., "api:users", "data:emails") */
817
+ resource: z.ZodString;
818
+ /** How to match the resource */
819
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
820
+ /** Optional additional constraints on this scope */
821
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
822
+ }, "strip", z.ZodTypeAny, {
823
+ resource: string;
824
+ matcher: "exact" | "prefix" | "regex";
825
+ constraints?: Record<string, any> | undefined;
826
+ }, {
827
+ resource: string;
828
+ matcher: "exact" | "prefix" | "regex";
829
+ constraints?: Record<string, any> | undefined;
830
+ }>, "many">;
831
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
832
+ /** Optional budget constraint */
833
+ budget: z.ZodOptional<z.ZodObject<{
834
+ /** Unit of the budget */
835
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
836
+ /** Cap/limit for the budget */
837
+ cap: z.ZodNumber;
838
+ /** Optional time window for the budget */
839
+ window: z.ZodOptional<z.ZodObject<{
840
+ /** Type of window (rolling or fixed) */
841
+ kind: z.ZodEnum<["rolling", "fixed"]>;
842
+ /** Duration in seconds */
843
+ durationSec: z.ZodNumber;
844
+ }, "strip", z.ZodTypeAny, {
845
+ kind: "rolling" | "fixed";
846
+ durationSec: number;
847
+ }, {
848
+ kind: "rolling" | "fixed";
849
+ durationSec: number;
850
+ }>>;
851
+ }, "strip", z.ZodTypeAny, {
852
+ unit: "USD" | "ops" | "points";
853
+ cap: number;
854
+ window?: {
855
+ kind: "rolling" | "fixed";
856
+ durationSec: number;
857
+ } | undefined;
858
+ }, {
859
+ unit: "USD" | "ops" | "points";
860
+ cap: number;
861
+ window?: {
862
+ kind: "rolling" | "fixed";
863
+ durationSec: number;
864
+ } | undefined;
865
+ }>>;
866
+ /** Required: at least one scope */
867
+ scopes: z.ZodArray<z.ZodObject<{
868
+ /** Resource identifier (e.g., "api:users", "data:emails") */
869
+ resource: z.ZodString;
870
+ /** How to match the resource */
871
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
872
+ /** Optional additional constraints on this scope */
873
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
874
+ }, "strip", z.ZodTypeAny, {
875
+ resource: string;
876
+ matcher: "exact" | "prefix" | "regex";
877
+ constraints?: Record<string, any> | undefined;
878
+ }, {
879
+ resource: string;
880
+ matcher: "exact" | "prefix" | "regex";
881
+ constraints?: Record<string, any> | undefined;
882
+ }>, "many">;
883
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
884
+ /** Optional budget constraint */
885
+ budget: z.ZodOptional<z.ZodObject<{
886
+ /** Unit of the budget */
887
+ unit: z.ZodEnum<["USD", "ops", "points"]>;
888
+ /** Cap/limit for the budget */
889
+ cap: z.ZodNumber;
890
+ /** Optional time window for the budget */
891
+ window: z.ZodOptional<z.ZodObject<{
892
+ /** Type of window (rolling or fixed) */
893
+ kind: z.ZodEnum<["rolling", "fixed"]>;
894
+ /** Duration in seconds */
895
+ durationSec: z.ZodNumber;
896
+ }, "strip", z.ZodTypeAny, {
897
+ kind: "rolling" | "fixed";
898
+ durationSec: number;
899
+ }, {
900
+ kind: "rolling" | "fixed";
901
+ durationSec: number;
902
+ }>>;
903
+ }, "strip", z.ZodTypeAny, {
904
+ unit: "USD" | "ops" | "points";
905
+ cap: number;
906
+ window?: {
907
+ kind: "rolling" | "fixed";
908
+ durationSec: number;
909
+ } | undefined;
910
+ }, {
911
+ unit: "USD" | "ops" | "points";
912
+ cap: number;
913
+ window?: {
914
+ kind: "rolling" | "fixed";
915
+ durationSec: number;
916
+ } | undefined;
917
+ }>>;
918
+ /** Required: at least one scope */
919
+ scopes: z.ZodArray<z.ZodObject<{
920
+ /** Resource identifier (e.g., "api:users", "data:emails") */
921
+ resource: z.ZodString;
922
+ /** How to match the resource */
923
+ matcher: z.ZodEnum<["exact", "prefix", "regex"]>;
924
+ /** Optional additional constraints on this scope */
925
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
926
+ }, "strip", z.ZodTypeAny, {
927
+ resource: string;
928
+ matcher: "exact" | "prefix" | "regex";
929
+ constraints?: Record<string, any> | undefined;
930
+ }, {
931
+ resource: string;
932
+ matcher: "exact" | "prefix" | "regex";
933
+ constraints?: Record<string, any> | undefined;
934
+ }>, "many">;
935
+ }, z.ZodTypeAny, "passthrough">>;
936
+ }, z.ZodTypeAny, "passthrough">>;
937
+ /**
938
+ * Check if constraints have a valid time range
939
+ *
940
+ * @param constraints - The constraints to check
941
+ * @returns true if time range is valid or no time range specified
942
+ */
943
+ export declare function hasValidTimeRange(constraints: DelegationConstraints): boolean;
944
+ /**
945
+ * Check if child constraints are within parent constraints
946
+ *
947
+ * This performs basic structural checks. Full chain validation
948
+ * requires runtime implementation.
949
+ *
950
+ * @param parent - Parent delegation constraints
951
+ * @param child - Child delegation constraints
952
+ * @returns true if child is within parent bounds
953
+ */
954
+ export declare function areChildConstraintsValid(parent: DelegationConstraints, child: DelegationConstraints): boolean;
955
+ /**
956
+ * Check if a resource matches a scope
957
+ *
958
+ * @param resource - The resource to check
959
+ * @param scope - The scope to match against
960
+ * @returns true if resource matches scope
961
+ */
962
+ export declare function doesResourceMatchScope(resource: string, scope: CrispScope): boolean;
963
+ /**
964
+ * Constants
965
+ */
966
+ /**
967
+ * Supported currency types
968
+ */
969
+ export declare const SUPPORTED_CURRENCIES: Currency[];
970
+ /**
971
+ * Supported scope matchers
972
+ */
973
+ export declare const SUPPORTED_MATCHERS: ScopeMatcher[];
974
+ /**
975
+ * Maximum reasonable budget cap (for validation)
976
+ */
977
+ export declare const MAX_BUDGET_CAP: number;
978
+ /**
979
+ * Maximum reasonable window duration (10 years in seconds)
980
+ */
981
+ export declare const MAX_WINDOW_DURATION_SEC: number;
982
+ //# sourceMappingURL=constraints.d.ts.map