@callcium/sdk 0.5.0 → 0.7.0
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/dist/index.d.ts +136 -46
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +871 -1411
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/bytes.ts +100 -0
- package/src/calldata-reader.ts +38 -0
- package/src/constants.ts +395 -0
- package/src/constraint.ts +313 -0
- package/src/descriptor-coder.ts +461 -0
- package/src/descriptor.ts +399 -0
- package/src/errors.ts +138 -0
- package/src/index.ts +105 -0
- package/src/operators.ts +204 -0
- package/src/policy-builder.ts +250 -0
- package/src/policy-coder.ts +668 -0
- package/src/policy-enforcer.ts +600 -0
- package/src/policy-validator.ts +1112 -0
- package/src/signature.ts +97 -0
- package/src/type-desc.ts +205 -0
- package/src/types.ts +280 -0
- package/src/validation-issue.ts +569 -0
package/dist/index.d.ts
CHANGED
|
@@ -45,9 +45,7 @@ type SelectorMismatchViolation = {
|
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
47
|
* A context-scoped rule referenced a property not supplied in the execution context.
|
|
48
|
-
|
|
49
|
-
* `opCode` and `operandData` may be added in future versions as diagnostic context
|
|
50
|
-
* without breaking the contract; consumers should tolerate their presence.
|
|
48
|
+
|
|
51
49
|
*/
|
|
52
50
|
type MissingContextViolation = {
|
|
53
51
|
code: "MISSING_CONTEXT";
|
|
@@ -102,11 +100,9 @@ type CalldataNavigationVariant<C extends NavigationViolationCode> = {
|
|
|
102
100
|
* Calldata structure prevented the rule from being evaluated.
|
|
103
101
|
*
|
|
104
102
|
* The operator was never applied; `opCode`, `operandData`, `typeCode`, and `elementIndex`
|
|
105
|
-
* are diagnostic context describing the failing site, not a constraint claim.
|
|
106
|
-
* must not summarise these as "constraint violated".
|
|
103
|
+
* are diagnostic context describing the failing site, not a constraint claim.
|
|
107
104
|
*
|
|
108
|
-
*
|
|
109
|
-
* `Extract<Violation, { code: "..." }>`.
|
|
105
|
+
* A union of per-code variants, narrowable with `Extract<Violation, { code: "..." }>`.
|
|
110
106
|
*/
|
|
111
107
|
type CalldataNavigationViolation = CalldataNavigationVariant<"CALLDATA_OUT_OF_BOUNDS"> | CalldataNavigationVariant<"ARRAY_INDEX_OUT_OF_BOUNDS">;
|
|
112
108
|
/** A quantified array exceeded `Limits.MAX_QUANTIFIED_ARRAY_LENGTH`. */
|
|
@@ -118,7 +114,24 @@ type QuantifierLimitExceededViolation = {
|
|
|
118
114
|
path: Hex; /** Hex-encoded element count of the offending array. */
|
|
119
115
|
resolvedValue: Hex;
|
|
120
116
|
};
|
|
121
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* A resolved word is not the canonical encoding of its declared type (spec §7.4).
|
|
119
|
+
*
|
|
120
|
+
* `resolvedValue` is the raw 32-byte word as it appeared in calldata, before any masking.
|
|
121
|
+
*/
|
|
122
|
+
type NonCanonicalValueViolation = {
|
|
123
|
+
code: "NON_CANONICAL_VALUE";
|
|
124
|
+
group: number;
|
|
125
|
+
rule: number;
|
|
126
|
+
scope: number;
|
|
127
|
+
path: Hex; /** Type code of the target whose encoding was violated. */
|
|
128
|
+
typeCode: number; /** Raw 32-byte word as it appeared in calldata, before any masking. */
|
|
129
|
+
resolvedValue: Hex;
|
|
130
|
+
opCode?: number;
|
|
131
|
+
operandData?: Hex;
|
|
132
|
+
elementIndex?: number;
|
|
133
|
+
};
|
|
134
|
+
/** An `ANY` quantifier was applied to an empty array. */
|
|
122
135
|
type QuantifierEmptyArrayViolation = {
|
|
123
136
|
code: "QUANTIFIER_EMPTY_ARRAY";
|
|
124
137
|
group: number;
|
|
@@ -129,10 +142,10 @@ type QuantifierEmptyArrayViolation = {
|
|
|
129
142
|
/**
|
|
130
143
|
* Structured details of a single rule failure during enforcement.
|
|
131
144
|
*
|
|
132
|
-
* Carries semantic data only
|
|
145
|
+
* Carries semantic data only; no message strings.
|
|
133
146
|
* Discriminate on `code` to narrow to the matching variant.
|
|
134
147
|
*/
|
|
135
|
-
type Violation = MissingSelectorViolation | SelectorMismatchViolation | MissingContextViolation | ValueMismatchViolation | CalldataNavigationViolation | QuantifierLimitExceededViolation | QuantifierEmptyArrayViolation;
|
|
148
|
+
type Violation = MissingSelectorViolation | SelectorMismatchViolation | MissingContextViolation | ValueMismatchViolation | CalldataNavigationViolation | NonCanonicalValueViolation | QuantifierLimitExceededViolation | QuantifierEmptyArrayViolation;
|
|
136
149
|
/** Machine-readable reason code for an enforcement violation. Derived from `Violation` to prevent drift. */
|
|
137
150
|
type ViolationCode = Violation["code"];
|
|
138
151
|
/** Canonical structured representation of a policy. */
|
|
@@ -147,7 +160,8 @@ type PolicyData = {
|
|
|
147
160
|
type Constraint = {
|
|
148
161
|
scope: number;
|
|
149
162
|
path: Hex;
|
|
150
|
-
operators: Hex[];
|
|
163
|
+
operators: Hex[]; /** Compiled hint block as carried on the wire; absent when the constraint has no encoding. */
|
|
164
|
+
hint?: Hex;
|
|
151
165
|
span?: Span;
|
|
152
166
|
};
|
|
153
167
|
/** A decoded value with its byte position in the source blob. */
|
|
@@ -169,7 +183,8 @@ type DecodedRule = {
|
|
|
169
183
|
ruleSize: Field<number>;
|
|
170
184
|
scope: Field<number>;
|
|
171
185
|
pathDepth: Field<number>;
|
|
172
|
-
path: Field<Hex>;
|
|
186
|
+
path: Field<Hex>; /** Compiled hint block; present for calldata rules only. */
|
|
187
|
+
hint?: Field<Hex>;
|
|
173
188
|
opCode: Field<number>;
|
|
174
189
|
dataLength: Field<number>;
|
|
175
190
|
data: Field<Hex>;
|
|
@@ -332,7 +347,8 @@ declare class PolicyBuilder {
|
|
|
332
347
|
* Throws on any issue, regardless of severity. Use {@link validate} to
|
|
333
348
|
* inspect issues, or {@link buildUnsafe} to encode without validation.
|
|
334
349
|
* @returns The policy as a 0x-prefixed hex string.
|
|
335
|
-
* @throws {CallciumError} If any group is empty
|
|
350
|
+
* @throws {CallciumError} If any group is empty.
|
|
351
|
+
* @throws {ValidationError} If validation finds any issue.
|
|
336
352
|
*/
|
|
337
353
|
build(): Hex;
|
|
338
354
|
/**
|
|
@@ -427,7 +443,7 @@ declare function inspect(desc: Uint8Array, offset: number): TypeInfo;
|
|
|
427
443
|
* @param desc - Raw descriptor bytes.
|
|
428
444
|
* @param steps - Path steps, length >= 1.
|
|
429
445
|
* @returns TypeInfo for the node at the resolved path.
|
|
430
|
-
* @throws {CallciumError} On empty steps, out-of-bounds param, or descent into elementary type.
|
|
446
|
+
* @throws {CallciumError} On empty steps, out-of-bounds param or array index, or descent into elementary type.
|
|
431
447
|
*/
|
|
432
448
|
declare function typeAt(desc: Uint8Array, steps: number[]): TypeInfo;
|
|
433
449
|
/**
|
|
@@ -437,7 +453,7 @@ declare function typeAt(desc: Uint8Array, steps: number[]): TypeInfo;
|
|
|
437
453
|
* @param desc - Raw descriptor bytes.
|
|
438
454
|
* @param steps - Path steps, length >= 1.
|
|
439
455
|
* @returns TypeInfo at the resolved path and the quantified static array length.
|
|
440
|
-
* @throws {CallciumError} On empty steps, out-of-bounds param, or descent into elementary type.
|
|
456
|
+
* @throws {CallciumError} On empty steps, out-of-bounds param or array index, or descent into elementary type.
|
|
441
457
|
*/
|
|
442
458
|
declare function walkPath(desc: Uint8Array, steps: number[]): {
|
|
443
459
|
typeInfo: TypeInfo;
|
|
@@ -460,6 +476,16 @@ declare function staticArrayLength(desc: Uint8Array, offset: number): number;
|
|
|
460
476
|
* @param offset - Byte position of the array node (static or dynamic).
|
|
461
477
|
*/
|
|
462
478
|
declare function arrayElementOffset(offset: number): number;
|
|
479
|
+
/**
|
|
480
|
+
* Compile a calldata rule path into its wire hint block.
|
|
481
|
+
*
|
|
482
|
+
* @param desc - Raw descriptor bytes.
|
|
483
|
+
* @param steps - Path steps, length >= 1.
|
|
484
|
+
* @returns The hint block bytes.
|
|
485
|
+
* @throws {CallciumError} When a step leaves the structure the descriptor declares, quantifies over
|
|
486
|
+
* a non-array node, or repeats a quantifier.
|
|
487
|
+
*/
|
|
488
|
+
declare function compileHint(desc: Uint8Array, steps: number[]): Uint8Array;
|
|
463
489
|
/** Inspect and navigate raw descriptor bytes. */
|
|
464
490
|
declare const Descriptor: {
|
|
465
491
|
paramCount: typeof paramCount;
|
|
@@ -472,6 +498,7 @@ declare const Descriptor: {
|
|
|
472
498
|
nodeLength: typeof nodeLength;
|
|
473
499
|
arrayElementOffset: typeof arrayElementOffset;
|
|
474
500
|
walkPath: typeof walkPath;
|
|
501
|
+
compileHint: typeof compileHint;
|
|
475
502
|
};
|
|
476
503
|
//#endregion
|
|
477
504
|
//#region src/policy-validator.d.ts
|
|
@@ -484,6 +511,8 @@ declare function isOpAllowed(opCode: number, typeInfo: TypeInfo): boolean;
|
|
|
484
511
|
* Validate a policy for type mismatches, contradictions, redundancies, and vacuities.
|
|
485
512
|
* @param data - The canonical policy data to validate.
|
|
486
513
|
* @returns All validation issues found, ordered by group and constraint index.
|
|
514
|
+
* @throws {CallciumError} If the descriptor is not well-formed; semantic validation is
|
|
515
|
+
* defined only over a well-formed descriptor.
|
|
487
516
|
*/
|
|
488
517
|
declare function validate(data: PolicyData): Issue[];
|
|
489
518
|
/** Semantic validation for policies. */
|
|
@@ -530,7 +559,7 @@ declare function toAddress(hex: string): Address;
|
|
|
530
559
|
*
|
|
531
560
|
* @param typesCsv - Comma-separated ABI type strings, e.g. `"address,uint256,(bool,bytes32)[],string"`.
|
|
532
561
|
* @returns Binary descriptor bytes starting with the version+paramCount header.
|
|
533
|
-
* @throws {CallciumError} With code `
|
|
562
|
+
* @throws {CallciumError} With code `MALFORMED_TYPE_STRING` for malformed input.
|
|
534
563
|
* @throws {CallciumError} With code `UNKNOWN_TYPE` for unrecognised type names.
|
|
535
564
|
*/
|
|
536
565
|
declare function fromTypes(typesCsv: string): Uint8Array;
|
|
@@ -551,6 +580,55 @@ declare const DescriptorCoder: {
|
|
|
551
580
|
};
|
|
552
581
|
//#endregion
|
|
553
582
|
//#region src/constants.d.ts
|
|
583
|
+
/** Binary layout constants for the Callcium policy format. */
|
|
584
|
+
declare const PolicyFormat: {
|
|
585
|
+
readonly VERSION: 2;
|
|
586
|
+
readonly VERSION_MASK: 15;
|
|
587
|
+
readonly FLAG_NO_SELECTOR: 16;
|
|
588
|
+
readonly RESERVED_MASK: 224;
|
|
589
|
+
readonly HEADER_SIZE: 1;
|
|
590
|
+
readonly SELECTOR_OFFSET: 1;
|
|
591
|
+
readonly SELECTOR_SIZE: 4;
|
|
592
|
+
readonly DESC_LENGTH_OFFSET: 5;
|
|
593
|
+
readonly DESC_LENGTH_SIZE: 2;
|
|
594
|
+
readonly DESC_OFFSET: 7;
|
|
595
|
+
readonly GROUP_COUNT_SIZE: 1;
|
|
596
|
+
readonly GROUP_RULECOUNT_SIZE: 2;
|
|
597
|
+
readonly GROUP_SIZE_SIZE: 4;
|
|
598
|
+
readonly GROUP_HEADER_SIZE: 6;
|
|
599
|
+
readonly RULE_SIZE_SIZE: 2;
|
|
600
|
+
readonly RULE_SCOPE_OFFSET: 2;
|
|
601
|
+
readonly RULE_DEPTH_OFFSET: 3;
|
|
602
|
+
readonly RULE_PATH_OFFSET: 4;
|
|
603
|
+
readonly PATH_STEP_SIZE: 2;
|
|
604
|
+
readonly RULE_OPCODE_SIZE: 1;
|
|
605
|
+
readonly RULE_DATALENGTH_SIZE: 2;
|
|
606
|
+
readonly RULE_FIXED_OVERHEAD: 7;
|
|
607
|
+
readonly RULE_MIN_SIZE: 9;
|
|
608
|
+
readonly HINT_HEADER_SIZE: 1;
|
|
609
|
+
readonly HINT_HOP_SIZE: 8;
|
|
610
|
+
readonly HINT_HOP_INDEX_OFFSET: 4;
|
|
611
|
+
readonly HINT_HOP_META_OFFSET: 6;
|
|
612
|
+
readonly HINT_FRAME_PREFIX_SIZE: 8;
|
|
613
|
+
readonly HINT_FRAME_COUNT_OFFSET: 4;
|
|
614
|
+
readonly HINT_FRAME_META_OFFSET: 6;
|
|
615
|
+
readonly HINT_TARGET_SIZE: 7;
|
|
616
|
+
readonly HINT_TARGET_META_OFFSET: 4;
|
|
617
|
+
readonly HINT_TARGET_TYPECODE_OFFSET: 6;
|
|
618
|
+
readonly HINT_KIND_NONE: 0;
|
|
619
|
+
readonly HINT_KIND_ALL: 1;
|
|
620
|
+
readonly HINT_KIND_ANY: 2;
|
|
621
|
+
readonly HINT_KIND_MAX: 2;
|
|
622
|
+
readonly HINT_KIND_SHIFT: 6;
|
|
623
|
+
readonly HINT_HOP_COUNT_MASK: 63;
|
|
624
|
+
readonly HINT_SUFFIX_RESERVED_MASK: 192;
|
|
625
|
+
readonly HINT_NO_INDEX: 65535;
|
|
626
|
+
readonly HINT_INDEX_RESERVED: 65534;
|
|
627
|
+
readonly HINT_META_ELEM_DYNAMIC: 32768;
|
|
628
|
+
readonly HINT_META_DYNAMIC_ARRAY: 16384;
|
|
629
|
+
readonly HINT_META_RESERVED_MASK: 12288;
|
|
630
|
+
readonly HINT_META_STRIDE_MASK: 4095;
|
|
631
|
+
};
|
|
554
632
|
/**
|
|
555
633
|
* Extract a `{ KEY: code }` map from a table with `key` and `code` fields.
|
|
556
634
|
* @internal
|
|
@@ -582,13 +660,13 @@ type ScopeInfo = {
|
|
|
582
660
|
declare function lookupScope(code: number): ScopeInfo;
|
|
583
661
|
/** ABI type code ranges and sentinel values for the descriptor format. */
|
|
584
662
|
declare const TypeCode: {
|
|
585
|
-
readonly UINT_MIN:
|
|
586
|
-
readonly UINT_MAX:
|
|
587
|
-
readonly INT_MIN:
|
|
588
|
-
readonly INT_MAX:
|
|
589
|
-
readonly ADDRESS:
|
|
590
|
-
readonly BOOL:
|
|
591
|
-
readonly FUNCTION:
|
|
663
|
+
readonly UINT_MIN: 1;
|
|
664
|
+
readonly UINT_MAX: 32;
|
|
665
|
+
readonly INT_MIN: 33;
|
|
666
|
+
readonly INT_MAX: 64;
|
|
667
|
+
readonly ADDRESS: 65;
|
|
668
|
+
readonly BOOL: 66;
|
|
669
|
+
readonly FUNCTION: 67;
|
|
592
670
|
readonly FIXED_BYTES_MIN: 80;
|
|
593
671
|
readonly FIXED_BYTES_MAX: 111;
|
|
594
672
|
readonly BYTES: 112;
|
|
@@ -602,42 +680,42 @@ declare const ContextProperty: CodeMap<readonly [{
|
|
|
602
680
|
readonly key: "MSG_SENDER";
|
|
603
681
|
readonly code: 0;
|
|
604
682
|
readonly label: "msg.sender";
|
|
605
|
-
readonly typeCode:
|
|
683
|
+
readonly typeCode: 65;
|
|
606
684
|
}, {
|
|
607
685
|
readonly key: "MSG_VALUE";
|
|
608
686
|
readonly code: 1;
|
|
609
687
|
readonly label: "msg.value";
|
|
610
|
-
readonly typeCode:
|
|
688
|
+
readonly typeCode: 32;
|
|
611
689
|
}, {
|
|
612
690
|
readonly key: "BLOCK_TIMESTAMP";
|
|
613
691
|
readonly code: 2;
|
|
614
692
|
readonly label: "block.timestamp";
|
|
615
|
-
readonly typeCode:
|
|
693
|
+
readonly typeCode: 32;
|
|
616
694
|
}, {
|
|
617
695
|
readonly key: "BLOCK_NUMBER";
|
|
618
696
|
readonly code: 3;
|
|
619
697
|
readonly label: "block.number";
|
|
620
|
-
readonly typeCode:
|
|
698
|
+
readonly typeCode: 32;
|
|
621
699
|
}, {
|
|
622
700
|
readonly key: "CHAIN_ID";
|
|
623
701
|
readonly code: 4;
|
|
624
702
|
readonly label: "block.chainid";
|
|
625
|
-
readonly typeCode:
|
|
703
|
+
readonly typeCode: 32;
|
|
626
704
|
}, {
|
|
627
705
|
readonly key: "TX_ORIGIN";
|
|
628
706
|
readonly code: 5;
|
|
629
707
|
readonly label: "tx.origin";
|
|
630
|
-
readonly typeCode:
|
|
708
|
+
readonly typeCode: 65;
|
|
631
709
|
}, {
|
|
632
710
|
readonly key: "BASE_FEE";
|
|
633
711
|
readonly code: 6;
|
|
634
712
|
readonly label: "block.basefee";
|
|
635
|
-
readonly typeCode:
|
|
713
|
+
readonly typeCode: 32;
|
|
636
714
|
}, {
|
|
637
715
|
readonly key: "GAS_PRICE";
|
|
638
716
|
readonly code: 7;
|
|
639
717
|
readonly label: "tx.gasprice";
|
|
640
|
-
readonly typeCode:
|
|
718
|
+
readonly typeCode: 32;
|
|
641
719
|
}]>;
|
|
642
720
|
/** Display metadata for a context property code. */
|
|
643
721
|
type ContextPropertyInfo = {
|
|
@@ -648,7 +726,7 @@ type ContextPropertyInfo = {
|
|
|
648
726
|
/**
|
|
649
727
|
* Map a context property code to its display label and ABI type code.
|
|
650
728
|
* @param code - Context property ID.
|
|
651
|
-
* @returns Display metadata including the
|
|
729
|
+
* @returns Display metadata including the ABI type code for the property value.
|
|
652
730
|
* @throws {CallciumError} If the code is not a recognised context property.
|
|
653
731
|
*/
|
|
654
732
|
declare function lookupContextProperty(code: number): ContextPropertyInfo;
|
|
@@ -656,6 +734,7 @@ declare function lookupContextProperty(code: number): ContextPropertyInfo;
|
|
|
656
734
|
declare const Limits: {
|
|
657
735
|
readonly MAX_PATH_DEPTH: 32;
|
|
658
736
|
readonly MAX_QUANTIFIED_ARRAY_LENGTH: 256;
|
|
737
|
+
readonly MAX_SET_MEMBERS: number;
|
|
659
738
|
};
|
|
660
739
|
/** Operand count category for operator data validation. */
|
|
661
740
|
type Operands = "single" | "range" | "variadic";
|
|
@@ -759,23 +838,19 @@ type OpInfo = {
|
|
|
759
838
|
declare function lookupOp(code: number): OpInfo;
|
|
760
839
|
/** Reserved path step values that trigger quantified evaluation over array elements. */
|
|
761
840
|
declare const Quantifier: CodeMap<readonly [{
|
|
762
|
-
readonly key: "ALL_OR_EMPTY";
|
|
763
|
-
readonly code: 65535;
|
|
764
|
-
readonly label: "all or empty";
|
|
765
|
-
}, {
|
|
766
841
|
readonly key: "ALL";
|
|
767
|
-
readonly code:
|
|
842
|
+
readonly code: 65535;
|
|
768
843
|
readonly label: "all";
|
|
769
844
|
}, {
|
|
770
845
|
readonly key: "ANY";
|
|
771
|
-
readonly code:
|
|
846
|
+
readonly code: 65534;
|
|
772
847
|
readonly label: "any";
|
|
773
848
|
}]>;
|
|
774
849
|
/** Display metadata for a quantifier step. */
|
|
775
850
|
type QuantifierInfo = {
|
|
776
851
|
label: string;
|
|
777
852
|
};
|
|
778
|
-
/** Check whether a path step is a quantifier (
|
|
853
|
+
/** Check whether a path step is a quantifier (ALL or ANY). */
|
|
779
854
|
declare function isQuantifier(step: number): boolean;
|
|
780
855
|
/**
|
|
781
856
|
* Map a quantifier path step to its display label.
|
|
@@ -786,7 +861,7 @@ declare function isQuantifier(step: number): boolean;
|
|
|
786
861
|
declare function lookupQuantifier(code: number): QuantifierInfo;
|
|
787
862
|
/** Structural category for a descriptor type code. */
|
|
788
863
|
type TypeClass = "elementary" | "tuple" | "staticArray" | "dynamicArray";
|
|
789
|
-
/** Structural classification without label
|
|
864
|
+
/** Structural classification without label. */
|
|
790
865
|
type TypeClassInfo = {
|
|
791
866
|
typeClass: TypeClass;
|
|
792
867
|
isDynamic: boolean;
|
|
@@ -796,7 +871,7 @@ type TypeCodeInfo = TypeClassInfo & {
|
|
|
796
871
|
label: string;
|
|
797
872
|
};
|
|
798
873
|
/**
|
|
799
|
-
* Map a raw type code byte to its
|
|
874
|
+
* Map a raw type code byte to its ABI type label, structural category, and dynamism.
|
|
800
875
|
* @param code - A single-byte descriptor type code.
|
|
801
876
|
* @returns Label, type class, and whether the type is ABI-dynamic.
|
|
802
877
|
* @throws {CallciumError} If the code is not a recognised type code.
|
|
@@ -808,8 +883,13 @@ declare function lookupTypeCode(code: number): TypeCodeInfo;
|
|
|
808
883
|
declare function isLengthOp(opCode: number): boolean;
|
|
809
884
|
//#endregion
|
|
810
885
|
//#region src/errors.d.ts
|
|
811
|
-
/**
|
|
812
|
-
|
|
886
|
+
/**
|
|
887
|
+
* Machine-readable error code for structural decoding and validation failures.
|
|
888
|
+
*
|
|
889
|
+
* Each code names one invariant and matches the Solidity error raised for the same
|
|
890
|
+
* invariant, transliterated from `PascalCase` to `SCREAMING_SNAKE_CASE`.
|
|
891
|
+
*/
|
|
892
|
+
type CallciumErrorCode = "UNSUPPORTED_VERSION" | "MALFORMED_HEADER" | "UNEXPECTED_END" | "TRAILING_BYTES" | "EMPTY_POLICY" | "EMPTY_GROUP" | "GROUP_TOO_SMALL" | "GROUP_SIZE_MISMATCH" | "GROUP_OVERFLOW" | "RULE_TOO_SMALL" | "RULE_SIZE_MISMATCH" | "RULE_FIELD_OUT_OF_BOUNDS" | "RULE_OVERFLOW" | "EMPTY_PATH" | "MALFORMED_PATH" | "PATH_TOO_DEEP" | "PARAM_INDEX_OUT_OF_BOUNDS" | "TUPLE_FIELD_OUT_OF_BOUNDS" | "STATIC_ARRAY_INDEX_OUT_OF_BOUNDS" | "NOT_COMPOSITE" | "UNCOMPILABLE_PATH" | "QUANTIFIER_ON_NON_ARRAY" | "NESTED_QUANTIFIER" | "INVALID_SCOPE" | "INVALID_CONTEXT_PATH" | "UNKNOWN_CONTEXT_PROPERTY" | "UNKNOWN_OPERATOR" | "INVALID_OPERATOR_BYTES" | "OPERATOR_TARGET_MISMATCH" | "UNSORTED_IN_SET" | "MALFORMED_HINT" | "NO_CONSTRAINT_OPERATORS" | "DUPLICATE_PATH_IN_GROUP" | "EMPTY_SET" | "SET_TOO_LARGE" | "INVALID_RANGE" | "UNKNOWN_TYPE_CODE" | "NODE_LENGTH_TOO_SMALL" | "NODE_LENGTH_TOO_LARGE" | "NODE_OVERFLOW" | "NESTING_TOO_DEEP" | "INVALID_ARRAY_LENGTH" | "INVALID_TUPLE_FIELD_COUNT" | "STATIC_WORDS_TOO_LARGE" | "PARAM_COUNT_MISMATCH" | "TOO_MANY_PARAMS" | "MALFORMED_TYPE_STRING" | "UNKNOWN_TYPE" | "MALFORMED_SIGNATURE" | "SIGNATURE_CONTAINS_WHITESPACE" | "INVALID_FUNCTION_NAME" | "GROUP_COUNT_OVERFLOW" | "RULE_COUNT_OVERFLOW" | "RULE_SIZE_OVERFLOW" | "DESC_LENGTH_OVERFLOW" | "UNKNOWN_QUANTIFIER" | "INVALID_HEX" | "VALIDATION_ERROR";
|
|
813
893
|
/**
|
|
814
894
|
* Thrown when a policy or descriptor blob is structurally malformed.
|
|
815
895
|
* The optional `offset` indicates the byte position in the source blob where the error was detected.
|
|
@@ -820,10 +900,20 @@ declare class CallciumError extends Error {
|
|
|
820
900
|
readonly offset?: number;
|
|
821
901
|
constructor(code: CallciumErrorCode, message: string, offset?: number);
|
|
822
902
|
}
|
|
903
|
+
/**
|
|
904
|
+
* Thrown by `PolicyBuilder.build` when validation reports any issue.
|
|
905
|
+
*
|
|
906
|
+
* Carries every issue the validator found. The `Error.message` is the first issue's
|
|
907
|
+
* message — a diagnostic summary, not a presentation contract. Consumers rendering
|
|
908
|
+
* issues to users should iterate `issues` directly.
|
|
909
|
+
*/
|
|
910
|
+
declare class ValidationError extends CallciumError {
|
|
911
|
+
readonly issues: Issue[];
|
|
912
|
+
constructor(issues: Issue[]);
|
|
913
|
+
}
|
|
823
914
|
/**
|
|
824
915
|
* Thrown by `PolicyEnforcer.enforce` when calldata fails policy enforcement.
|
|
825
|
-
* Distinct from `
|
|
826
|
-
* issues in the policy itself.
|
|
916
|
+
* Distinct from `ValidationError`, which signals static issues in the policy itself.
|
|
827
917
|
*
|
|
828
918
|
* Carries the full list of structured violations (one per failed group). The
|
|
829
919
|
* `Error.message` is a minimal non-lossy diagnostic summary built from the
|
|
@@ -835,5 +925,5 @@ declare class PolicyViolationError extends Error {
|
|
|
835
925
|
constructor(violations: Violation[]);
|
|
836
926
|
}
|
|
837
927
|
//#endregion
|
|
838
|
-
export { type Address, CallciumError, type CallciumErrorCode, type CalldataNavigationViolation, type Constraint, type ConstraintBuilder, type Context, ContextProperty, type ContextPropertyInfo, type DecodedGroup, type DecodedParam, type DecodedPolicy, type DecodedRule, Descriptor, DescriptorCoder, type EnforceResult, type Field, type Hex, type Issue, type IssueCategory, type IssueSeverity, Limits, type MissingContextViolation, type MissingSelectorViolation, type NavigationViolationCode, Op, type OpInfo, type Operands, PolicyBuilder, PolicyCoder, type PolicyData, PolicyEnforcer, PolicyValidator, PolicyViolationError, Quantifier, type QuantifierEmptyArrayViolation, type QuantifierInfo, type QuantifierLimitExceededViolation, type ScalarValue, Scope, type ScopeInfo, type SelectorMismatchViolation, type Span, type TypeClass, type TypeClassInfo, TypeCode, type TypeCodeInfo, type TypeInfo, type ValueMismatchViolation, type Violation, type ViolationCode, arg, baseFee, blockNumber, blockTimestamp, bytesToHex, chainId, gasPrice, hexToBytes, isLengthOp, isOpAllowed, isQuantifier, lookupContextProperty, lookupOp, lookupQuantifier, lookupScope, lookupTypeCode, msgSender, msgValue, parsePathSteps, toAddress, txOrigin };
|
|
928
|
+
export { type Address, CallciumError, type CallciumErrorCode, type CalldataNavigationViolation, type Constraint, type ConstraintBuilder, type Context, ContextProperty, type ContextPropertyInfo, type DecodedGroup, type DecodedParam, type DecodedPolicy, type DecodedRule, Descriptor, DescriptorCoder, type EnforceResult, type Field, type Hex, type Issue, type IssueCategory, type IssueSeverity, Limits, type MissingContextViolation, type MissingSelectorViolation, type NavigationViolationCode, type NonCanonicalValueViolation, Op, type OpInfo, type Operands, PolicyBuilder, PolicyCoder, type PolicyData, PolicyEnforcer, PolicyFormat, PolicyValidator, PolicyViolationError, Quantifier, type QuantifierEmptyArrayViolation, type QuantifierInfo, type QuantifierLimitExceededViolation, type ScalarValue, Scope, type ScopeInfo, type SelectorMismatchViolation, type Span, type TypeClass, type TypeClassInfo, TypeCode, type TypeCodeInfo, type TypeInfo, ValidationError, type ValueMismatchViolation, type Violation, type ViolationCode, arg, baseFee, blockNumber, blockTimestamp, bytesToHex, chainId, gasPrice, hexToBytes, isLengthOp, isOpAllowed, isQuantifier, lookupContextProperty, lookupOp, lookupQuantifier, lookupScope, lookupTypeCode, msgSender, msgValue, parsePathSteps, toAddress, txOrigin };
|
|
839
929
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/constraint.ts","../src/policy-builder.ts","../src/policy-coder.ts","../src/descriptor.ts","../src/policy-validator.ts","../src/policy-enforcer.ts","../src/bytes.ts","../src/descriptor-coder.ts","../src/constants.ts","../src/operators.ts","../src/errors.ts"],"mappings":";;KAKY,GAAA;;KAGA,OAAA;;KAGA,IAAA;EAAS,KAAA;EAAe,GAAA;AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/constraint.ts","../src/policy-builder.ts","../src/policy-coder.ts","../src/descriptor.ts","../src/policy-validator.ts","../src/policy-enforcer.ts","../src/bytes.ts","../src/descriptor-coder.ts","../src/constants.ts","../src/operators.ts","../src/errors.ts"],"mappings":";;KAKY,GAAA;;KAGA,OAAA;;KAGA,IAAA;EAAS,KAAA;EAAe,GAAA;AAAA;;;AAApC;;;KAWY,OAAA;EACV,SAAA,GAAY,OAAA;EACZ,QAAA;EACA,cAAA;EACA,WAAA;EACA,OAAA;EACA,QAAA,GAAW,OAAA;EACX,OAAA;EACA,QAAA;AAAA;;KAIU,aAAA;EAAkB,EAAA;EAAU,YAAA;AAAA;EAA2B,EAAA;EAAW,UAAA,EAAY,SAAA;AAAA;AAA1F;AAAA,KAGY,uBAAA;;KAGA,wBAAA;EACV,IAAA;AAAA;;KAIU,yBAAA;EACV,IAAA,uBAZiG;EAcjG,aAAA,EAAe,GAAA,EAXL;EAaV,aAAA,EAAe,GAAA;AAAA;;;AAVjB;;KAiBY,uBAAA;EACV,IAAA;EACA,KAAA;EACA,IAAA;EACA,KAAA;EACA,IAAA,EAAM,GAAA,EAZY;EAclB,QAAA;EACA,MAAA;EACA,WAAA,GAAc,GAAA;AAAA;;;;AAThB;;;;;;;;;KAwBY,sBAAA;EACV,IAAA;EACA,KAAA;EACA,IAAA;EACA,KAAA;EACA,IAAA,EAAM,GAAA,EApBW;EAsBjB,MAAA,UAPgC;EAShC,WAAA,EAAa,GAAA,EAJP;EAMN,QAAA;EACA,aAAA,GAAgB,GAAA;EAChB,YAAA;AAAA;;;;;KAOG,yBAAA,WAAoC,uBAAA;EACvC,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