@libreflare/worker-runtime 0.7.0 → 0.8.1
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 +235 -13
- package/dist/rule-evaluator/accept-encoding.d.ts +2 -2
- package/dist/rule-evaluator/accept-encoding.d.ts.map +1 -1
- package/dist/rule-evaluator/accept-encoding.js +62 -15
- package/dist/rule-evaluator/accept-encoding.js.map +1 -1
- package/dist/rule-evaluator/access-values.d.ts +77 -14
- package/dist/rule-evaluator/access-values.d.ts.map +1 -1
- package/dist/rule-evaluator/access-values.js +149 -17
- package/dist/rule-evaluator/access-values.js.map +1 -1
- package/dist/rule-evaluator/analysis.d.ts +43 -8
- package/dist/rule-evaluator/analysis.d.ts.map +1 -1
- package/dist/rule-evaluator/analysis.js +72 -29
- package/dist/rule-evaluator/analysis.js.map +1 -1
- package/dist/rule-evaluator/ast.d.ts +145 -11
- package/dist/rule-evaluator/ast.d.ts.map +1 -1
- package/dist/rule-evaluator/ast.js +102 -4
- package/dist/rule-evaluator/ast.js.map +1 -1
- package/dist/rule-evaluator/byte-strings.d.ts +23 -0
- package/dist/rule-evaluator/byte-strings.d.ts.map +1 -0
- package/dist/rule-evaluator/byte-strings.js +150 -0
- package/dist/rule-evaluator/byte-strings.js.map +1 -0
- package/dist/rule-evaluator/constants.d.ts +1 -1
- package/dist/rule-evaluator/constants.d.ts.map +1 -1
- package/dist/rule-evaluator/constants.js +1 -0
- package/dist/rule-evaluator/constants.js.map +1 -1
- package/dist/rule-evaluator/country-codes.generated.js +1 -1
- package/dist/rule-evaluator/custom-lists.d.ts +9 -0
- package/dist/rule-evaluator/custom-lists.d.ts.map +1 -1
- package/dist/rule-evaluator/custom-lists.js +43 -0
- package/dist/rule-evaluator/custom-lists.js.map +1 -1
- package/dist/rule-evaluator/diagnostics.d.ts +1 -3
- package/dist/rule-evaluator/diagnostics.d.ts.map +1 -1
- package/dist/rule-evaluator/diagnostics.js +10 -53
- package/dist/rule-evaluator/diagnostics.js.map +1 -1
- package/dist/rule-evaluator/engine-observations.d.ts +37 -0
- package/dist/rule-evaluator/engine-observations.d.ts.map +1 -0
- package/dist/rule-evaluator/engine-observations.generated.d.ts +991 -0
- package/dist/rule-evaluator/engine-observations.generated.d.ts.map +1 -0
- package/dist/rule-evaluator/engine-observations.generated.js +292 -0
- package/dist/rule-evaluator/engine-observations.generated.js.map +1 -0
- package/dist/rule-evaluator/engine-observations.js +13 -0
- package/dist/rule-evaluator/engine-observations.js.map +1 -0
- package/dist/rule-evaluator/evaluator.d.ts +1 -1
- package/dist/rule-evaluator/evaluator.d.ts.map +1 -1
- package/dist/rule-evaluator/evaluator.js +16 -15
- package/dist/rule-evaluator/evaluator.js.map +1 -1
- package/dist/rule-evaluator/explain.d.ts.map +1 -1
- package/dist/rule-evaluator/explain.js +35 -20
- package/dist/rule-evaluator/explain.js.map +1 -1
- package/dist/rule-evaluator/field-availability.d.ts +11 -10
- package/dist/rule-evaluator/field-availability.d.ts.map +1 -1
- package/dist/rule-evaluator/field-availability.js +136 -97
- package/dist/rule-evaluator/field-availability.js.map +1 -1
- package/dist/rule-evaluator/field-descriptions.generated.d.ts +1 -1
- package/dist/rule-evaluator/field-descriptions.generated.js +1 -1
- package/dist/rule-evaluator/field-descriptions.generated.js.map +1 -1
- package/dist/rule-evaluator/field-value-domains.d.ts.map +1 -1
- package/dist/rule-evaluator/field-value-domains.js +2 -4
- package/dist/rule-evaluator/field-value-domains.js.map +1 -1
- package/dist/rule-evaluator/fields.d.ts +25 -2
- package/dist/rule-evaluator/fields.d.ts.map +1 -1
- package/dist/rule-evaluator/fields.js +276 -119
- package/dist/rule-evaluator/fields.js.map +1 -1
- package/dist/rule-evaluator/function-availability.d.ts +16 -0
- package/dist/rule-evaluator/function-availability.d.ts.map +1 -0
- package/dist/rule-evaluator/function-availability.js +28 -0
- package/dist/rule-evaluator/function-availability.js.map +1 -0
- package/dist/rule-evaluator/function-descriptions.d.ts +15 -1
- package/dist/rule-evaluator/function-descriptions.d.ts.map +1 -1
- package/dist/rule-evaluator/function-descriptions.generated.d.ts +50 -7
- package/dist/rule-evaluator/function-descriptions.generated.d.ts.map +1 -1
- package/dist/rule-evaluator/function-descriptions.generated.js +98 -12
- package/dist/rule-evaluator/function-descriptions.generated.js.map +1 -1
- package/dist/rule-evaluator/function-descriptions.js +11 -2
- package/dist/rule-evaluator/function-descriptions.js.map +1 -1
- package/dist/rule-evaluator/function-signature-validation.d.ts +26 -2
- package/dist/rule-evaluator/function-signature-validation.d.ts.map +1 -1
- package/dist/rule-evaluator/function-signature-validation.js +311 -181
- package/dist/rule-evaluator/function-signature-validation.js.map +1 -1
- package/dist/rule-evaluator/functions.d.ts +24 -5
- package/dist/rule-evaluator/functions.d.ts.map +1 -1
- package/dist/rule-evaluator/functions.js +353 -190
- package/dist/rule-evaluator/functions.js.map +1 -1
- package/dist/rule-evaluator/hash-in-range.d.ts +33 -0
- package/dist/rule-evaluator/hash-in-range.d.ts.map +1 -0
- package/dist/rule-evaluator/hash-in-range.js +72 -0
- package/dist/rule-evaluator/hash-in-range.js.map +1 -0
- package/dist/rule-evaluator/log-sample.d.ts.map +1 -1
- package/dist/rule-evaluator/log-sample.js +14 -6
- package/dist/rule-evaluator/log-sample.js.map +1 -1
- package/dist/rule-evaluator/match-chain.d.ts +3 -3
- package/dist/rule-evaluator/match-chain.d.ts.map +1 -1
- package/dist/rule-evaluator/match-chain.js +19 -13
- package/dist/rule-evaluator/match-chain.js.map +1 -1
- package/dist/rule-evaluator/minifier.d.ts.map +1 -1
- package/dist/rule-evaluator/minifier.js +16 -20
- package/dist/rule-evaluator/minifier.js.map +1 -1
- package/dist/rule-evaluator/normalizer.d.ts.map +1 -1
- package/dist/rule-evaluator/normalizer.js +6 -6
- package/dist/rule-evaluator/normalizer.js.map +1 -1
- package/dist/rule-evaluator/operators.d.ts +11 -4
- package/dist/rule-evaluator/operators.d.ts.map +1 -1
- package/dist/rule-evaluator/operators.js +62 -35
- package/dist/rule-evaluator/operators.js.map +1 -1
- package/dist/rule-evaluator/outcome.d.ts +2 -0
- package/dist/rule-evaluator/outcome.d.ts.map +1 -1
- package/dist/rule-evaluator/outcome.js +4 -0
- package/dist/rule-evaluator/outcome.js.map +1 -1
- package/dist/rule-evaluator/parse-cache.d.ts +3 -3
- package/dist/rule-evaluator/parse-cache.d.ts.map +1 -1
- package/dist/rule-evaluator/parse-cache.js +5 -13
- package/dist/rule-evaluator/parse-cache.js.map +1 -1
- package/dist/rule-evaluator/parser.d.ts +318 -11
- package/dist/rule-evaluator/parser.d.ts.map +1 -1
- package/dist/rule-evaluator/parser.js +1314 -333
- package/dist/rule-evaluator/parser.js.map +1 -1
- package/dist/rule-evaluator/quantifier.d.ts +1 -1
- package/dist/rule-evaluator/quantifier.d.ts.map +1 -1
- package/dist/rule-evaluator/quantifier.js +1 -16
- package/dist/rule-evaluator/quantifier.js.map +1 -1
- package/dist/rule-evaluator/request-headers.d.ts +101 -0
- package/dist/rule-evaluator/request-headers.d.ts.map +1 -0
- package/dist/rule-evaluator/request-headers.js +344 -0
- package/dist/rule-evaluator/request-headers.js.map +1 -0
- package/dist/rule-evaluator/rule-language-types.d.ts +80 -21
- package/dist/rule-evaluator/rule-language-types.d.ts.map +1 -1
- package/dist/rule-evaluator/rule-language-types.js +228 -67
- package/dist/rule-evaluator/rule-language-types.js.map +1 -1
- package/dist/rule-evaluator/tokenizer.d.ts +14 -4
- package/dist/rule-evaluator/tokenizer.d.ts.map +1 -1
- package/dist/rule-evaluator/tokenizer.js +24 -11
- package/dist/rule-evaluator/tokenizer.js.map +1 -1
- package/dist/rule-evaluator/transformation.d.ts.map +1 -1
- package/dist/rule-evaluator/transformation.js +10 -6
- package/dist/rule-evaluator/transformation.js.map +1 -1
- package/dist/rule-evaluator/url-decode.d.ts +8 -0
- package/dist/rule-evaluator/url-decode.d.ts.map +1 -0
- package/dist/rule-evaluator/url-decode.js +126 -0
- package/dist/rule-evaluator/url-decode.js.map +1 -0
- package/dist/rule-evaluator/validation.d.ts.map +1 -1
- package/dist/rule-evaluator/validation.js +509 -251
- package/dist/rule-evaluator/validation.js.map +1 -1
- package/dist/rule-evaluator.d.ts +2 -2
- package/dist/rule-evaluator.d.ts.map +1 -1
- package/dist/rule-evaluator.js.map +1 -1
- package/package.json +5 -2
- package/dist/rule-evaluator/comparison.d.ts +0 -16
- package/dist/rule-evaluator/comparison.d.ts.map +0 -1
- package/dist/rule-evaluator/comparison.js +0 -43
- package/dist/rule-evaluator/comparison.js.map +0 -1
- package/dist/rule-evaluator/custom-security-rule-analysis.d.ts +0 -36
- package/dist/rule-evaluator/custom-security-rule-analysis.d.ts.map +0 -1
- package/dist/rule-evaluator/custom-security-rule-analysis.js +0 -382
- package/dist/rule-evaluator/custom-security-rule-analysis.js.map +0 -1
- package/dist/rule-evaluator/values.d.ts +0 -26
- package/dist/rule-evaluator/values.d.ts.map +0 -1
- package/dist/rule-evaluator/values.js +0 -55
- package/dist/rule-evaluator/values.js.map +0 -1
- package/dist/rule-evaluator/warnings.d.ts +0 -2
- package/dist/rule-evaluator/warnings.d.ts.map +0 -1
- package/dist/rule-evaluator/warnings.js +0 -5
- package/dist/rule-evaluator/warnings.js.map +0 -1
|
@@ -8,9 +8,16 @@ export type StringLiteral = {
|
|
|
8
8
|
kind: 'StringLiteral';
|
|
9
9
|
value: string;
|
|
10
10
|
} & NodeSpan;
|
|
11
|
+
/**
|
|
12
|
+
* `raw` keeps the literal as written, and `integer` its exact value, since
|
|
13
|
+
* `value` loses precision beyond 2^53. A literal that is not a valid integer is
|
|
14
|
+
* an InvalidNode.
|
|
15
|
+
*/
|
|
11
16
|
export type NumberLiteral = {
|
|
12
17
|
kind: 'NumberLiteral';
|
|
13
18
|
value: number;
|
|
19
|
+
raw: string;
|
|
20
|
+
integer: bigint;
|
|
14
21
|
} & NodeSpan;
|
|
15
22
|
export type IpLiteral = {
|
|
16
23
|
kind: 'IpLiteral';
|
|
@@ -26,23 +33,34 @@ export type SetElement = {
|
|
|
26
33
|
type: 'string';
|
|
27
34
|
value: string;
|
|
28
35
|
}
|
|
29
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* An Integer, or an Integer range such as `1..5` kept as written. `raw` keeps
|
|
38
|
+
* the element as written, and `bounds` its inclusive range.
|
|
39
|
+
*/
|
|
30
40
|
| {
|
|
31
41
|
type: 'integer';
|
|
32
42
|
value: number | string;
|
|
43
|
+
raw: string;
|
|
44
|
+
bounds: readonly [bigint, bigint];
|
|
33
45
|
} | {
|
|
34
46
|
type: 'ip';
|
|
35
47
|
value: string;
|
|
36
48
|
};
|
|
49
|
+
/** A member that is not a valid element, which the parser has reported: an InvalidNode, typed as the elements are. */
|
|
50
|
+
export type InvalidSetMember = InvalidNode & {
|
|
51
|
+
type: 'invalid';
|
|
52
|
+
};
|
|
53
|
+
/** An inline list. Its element type comes from its valid members alone. */
|
|
37
54
|
export type SetLiteral = {
|
|
38
55
|
kind: 'SetLiteral';
|
|
39
|
-
elements: SetElement[];
|
|
56
|
+
elements: (SetElement | InvalidSetMember)[];
|
|
40
57
|
} & NodeSpan;
|
|
41
58
|
export type ListRef = {
|
|
42
59
|
kind: 'ListRef';
|
|
43
60
|
name: string;
|
|
44
61
|
} & NodeSpan;
|
|
45
62
|
export type LiteralNode = StringLiteral | NumberLiteral | IpLiteral | BoolLiteral | SetLiteral | ListRef;
|
|
63
|
+
/** An access segment, from its `[` to its `]`. One that is not valid is an InvalidNode, which the parser has reported. */
|
|
46
64
|
export type AccessNode = ({
|
|
47
65
|
kind: 'MapKeyAccess';
|
|
48
66
|
key: string;
|
|
@@ -51,7 +69,7 @@ export type AccessNode = ({
|
|
|
51
69
|
index: number;
|
|
52
70
|
} & NodeSpan) | ({
|
|
53
71
|
kind: 'ArrayWildcardAccess';
|
|
54
|
-
} & NodeSpan);
|
|
72
|
+
} & NodeSpan) | InvalidNode;
|
|
55
73
|
export type FieldNode = {
|
|
56
74
|
kind: 'Field';
|
|
57
75
|
name: string;
|
|
@@ -62,16 +80,48 @@ export type FieldNode = {
|
|
|
62
80
|
export type CompOp = 'eq' | 'ne' | 'lt' | 'le' | 'gt' | 'ge' | 'contains' | 'matches' | 'wildcard' | 'strict_wildcard' | 'in';
|
|
63
81
|
/** Equality and ordering operators, the only ones that accept a field, indexed value, or function result on the right side. */
|
|
64
82
|
export declare const EQUALITY_ORDERING_OPERATORS: ReadonlySet<CompOp>;
|
|
83
|
+
/**
|
|
84
|
+
* Stands in for invalid syntax, whose error the parser has reported, wherever
|
|
85
|
+
* a condition, an argument, a value, or an access segment belongs. `raw` is
|
|
86
|
+
* its source text, empty where nothing was written, as in an empty argument
|
|
87
|
+
* slot. It has no type, so nothing judges it, and nothing around it is judged
|
|
88
|
+
* by what it might have been.
|
|
89
|
+
*/
|
|
90
|
+
export type InvalidNode = {
|
|
91
|
+
kind: 'Invalid';
|
|
92
|
+
raw: string;
|
|
93
|
+
/**
|
|
94
|
+
* Set on an argument that holds no value: an empty slot, or one with only
|
|
95
|
+
* a token that cannot start an argument, which a stray comma may have
|
|
96
|
+
* left, or an unterminated comment. It counts as missing for a required
|
|
97
|
+
* parameter where no comma may be stray, and never toward too many
|
|
98
|
+
* arguments. Any other invalid argument takes its slot, as a `[` with an
|
|
99
|
+
* argument in it does, since that may be the argument.
|
|
100
|
+
*/
|
|
101
|
+
empty?: true;
|
|
102
|
+
/**
|
|
103
|
+
* The field or call that stands as a condition only because recovery from
|
|
104
|
+
* a syntax error cut it short: the token after it that the parser could
|
|
105
|
+
* not place may stand for a comparison operator, which would make it a
|
|
106
|
+
* comparison's left side, as `*` may in `http.host * "x"`. In a call
|
|
107
|
+
* without its `)`, so may the token with the error in its last argument,
|
|
108
|
+
* with the `)` before it, as `=` may in `lower(http.host = "x"`. Or a
|
|
109
|
+
* field with an access path that no comparison follows. Its own checks
|
|
110
|
+
* run, but nothing judges it as a condition. A Boolean field or call is
|
|
111
|
+
* never cut short, since Cloudflare compares no Boolean.
|
|
112
|
+
*/
|
|
113
|
+
operand?: FieldNode | FuncNode;
|
|
114
|
+
} & NodeSpan;
|
|
65
115
|
/** A field, indexed field, or function result used as a comparison operand. */
|
|
66
116
|
export type DynamicValueNode = FieldNode | FuncNode;
|
|
67
|
-
export type ComparisonValueNode = LiteralNode | DynamicValueNode;
|
|
117
|
+
export type ComparisonValueNode = LiteralNode | DynamicValueNode | InvalidNode;
|
|
68
118
|
export type ComparisonNode = {
|
|
69
119
|
kind: 'Comparison';
|
|
70
120
|
left: DynamicValueNode;
|
|
71
121
|
op: CompOp;
|
|
72
122
|
right?: ComparisonValueNode;
|
|
73
123
|
raw: string;
|
|
74
|
-
};
|
|
124
|
+
} & NodeSpan;
|
|
75
125
|
export type BoolFieldNode = {
|
|
76
126
|
kind: 'BoolField';
|
|
77
127
|
name: string;
|
|
@@ -81,31 +131,115 @@ export type AndNode = {
|
|
|
81
131
|
kind: 'And';
|
|
82
132
|
operands: ExprNode[];
|
|
83
133
|
raw: string;
|
|
84
|
-
};
|
|
134
|
+
} & NodeSpan;
|
|
85
135
|
export type OrNode = {
|
|
86
136
|
kind: 'Or';
|
|
87
137
|
operands: ExprNode[];
|
|
88
138
|
raw: string;
|
|
89
|
-
};
|
|
139
|
+
} & NodeSpan;
|
|
90
140
|
export type XorNode = {
|
|
91
141
|
kind: 'Xor';
|
|
92
142
|
operands: ExprNode[];
|
|
93
143
|
raw: string;
|
|
94
|
-
};
|
|
144
|
+
} & NodeSpan;
|
|
95
145
|
export type NotNode = {
|
|
96
146
|
kind: 'Not';
|
|
97
147
|
operand: ExprNode;
|
|
98
148
|
raw: string;
|
|
99
|
-
};
|
|
149
|
+
} & NodeSpan;
|
|
100
150
|
export type FuncNode = {
|
|
101
151
|
kind: 'Func';
|
|
102
152
|
name: string;
|
|
103
153
|
args: (ExprNode | FieldNode | LiteralNode)[];
|
|
104
154
|
accessPath: AccessNode[];
|
|
105
155
|
raw: string;
|
|
156
|
+
/**
|
|
157
|
+
* Set on a call that makes up a whole logical argument, such as
|
|
158
|
+
* `(has_value(...))` in `coalesce((has_value(...)), ssl)`. Such a call is a
|
|
159
|
+
* condition rather than a value: its result must be Boolean, and nil counts
|
|
160
|
+
* as false.
|
|
161
|
+
*/
|
|
162
|
+
condition?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Set when recovery from a syntax error leaves arguments uncertain: the
|
|
165
|
+
* index of the first one that is. That is the argument in which recovery
|
|
166
|
+
* skipped a token after the one with the error, which may belong to it, so
|
|
167
|
+
* it may have gone on, and the ones after it may have shifted. So is the
|
|
168
|
+
* argument before a missing comma, since the token read as the next one
|
|
169
|
+
* may be a stray one in it (see strayArgument); the one before a `[`
|
|
170
|
+
* after a comma, which may be its access, split off by a stray comma; and
|
|
171
|
+
* one after a comparison operator that the parser skipped, which may have
|
|
172
|
+
* lost its left side and made the argument a comparison. Without its `)`,
|
|
173
|
+
* it is the number of arguments, since more may follow. The checks that
|
|
174
|
+
* read an argument skip the arguments from here on, and a call's result
|
|
175
|
+
* type does not come from them.
|
|
176
|
+
*/
|
|
177
|
+
uncertainFrom?: number;
|
|
178
|
+
/**
|
|
179
|
+
* Set when more arguments may be written than the parser read: recovery
|
|
180
|
+
* skipped a token after the one with the error, which may come after a
|
|
181
|
+
* missing comma, or the call has no `)`, so more may follow it. The
|
|
182
|
+
* missing-argument checks skip such a call. A missing comma or a skipped
|
|
183
|
+
* comparison operator leaves arguments uncertain, but never hides one.
|
|
184
|
+
*/
|
|
185
|
+
moreArguments?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Set on a call without its `)` inside a call that takes commas. Its `)`
|
|
188
|
+
* may be missing before any of its commas, which would make them the
|
|
189
|
+
* outer call's, so only its first argument is certainly its own:
|
|
190
|
+
* `uncertainFrom` is at most 1, and some of the arguments read may not be
|
|
191
|
+
* its own.
|
|
192
|
+
*/
|
|
193
|
+
openInCall?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Set on a call that read as an argument what may be none: a token after
|
|
196
|
+
* a complete argument, read as the next one after a missing comma, which
|
|
197
|
+
* may be a stray token instead, or a `[` with something in it after a
|
|
198
|
+
* comma, which may be an access that a stray comma split off. So some of
|
|
199
|
+
* the arguments read may not be arguments at all.
|
|
200
|
+
*/
|
|
201
|
+
strayArgument?: boolean;
|
|
106
202
|
} & NodeSpan;
|
|
107
|
-
export type ExprNode = ComparisonNode | BoolFieldNode | AndNode | OrNode | XorNode | NotNode | FuncNode;
|
|
203
|
+
export type ExprNode = ComparisonNode | BoolFieldNode | AndNode | OrNode | XorNode | NotNode | FuncNode | InvalidNode;
|
|
204
|
+
/**
|
|
205
|
+
* Ends a switch that lists every node kind, so that a new kind fails
|
|
206
|
+
* compilation until each such switch handles it.
|
|
207
|
+
*/
|
|
208
|
+
export declare function unhandledNode(node: never): never;
|
|
209
|
+
/**
|
|
210
|
+
* How many of a call's arguments recovery from a syntax error left certain,
|
|
211
|
+
* in value and position: those before FuncNode.uncertainFrom.
|
|
212
|
+
*/
|
|
213
|
+
export declare function certainArgumentCount(node: FuncNode): number;
|
|
214
|
+
/**
|
|
215
|
+
* Whether a call's argument at an index is uncertain: one the parser read
|
|
216
|
+
* that a syntax error left uncertain, or one after them that may be written
|
|
217
|
+
* where the `)` is missing; see FuncNode.uncertainFrom.
|
|
218
|
+
*/
|
|
219
|
+
export declare function isUncertainArgument(node: FuncNode, index: number): boolean;
|
|
220
|
+
/** Whether a call may have more arguments written than the parser read: recovery hid some, or its `)` is missing. */
|
|
221
|
+
export declare function mayHaveMoreArguments(node: FuncNode): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Whether some of the arguments the parser read for a call may be another
|
|
224
|
+
* call's, or no arguments at all; see FuncNode.openInCall and
|
|
225
|
+
* FuncNode.strayArgument.
|
|
226
|
+
*/
|
|
227
|
+
export declare function mayHaveFewerArguments(node: FuncNode): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Whether a function argument is a condition, which Cloudflare evaluates as a
|
|
230
|
+
* Boolean that is never nil: a comparison, a logical expression, a Boolean
|
|
231
|
+
* field, or a function call the parser marked as one, such as
|
|
232
|
+
* `(has_value(...))`. Invalid syntax is not one.
|
|
233
|
+
*/
|
|
234
|
+
export declare function isConditionArgument(arg: FuncNode['args'][number]): boolean;
|
|
235
|
+
/** Whether a function argument holds no value, as a stray comma may leave; see InvalidNode.empty. */
|
|
236
|
+
export declare function isEmptyArgument(arg: FuncNode['args'][number]): boolean;
|
|
237
|
+
/** Whether a function argument is an expression node: a condition, a call, or invalid syntax. */
|
|
238
|
+
export declare function isExpressionNode(arg: FuncNode['args'][number] | undefined): arg is ExprNode;
|
|
239
|
+
/** Whether a field name is `true` or `false`, which the tokenizer reads as a Boolean, not an identifier. */
|
|
240
|
+
export declare function isBooleanLiteralName(name: string): boolean;
|
|
241
|
+
/** The valid elements of an inline list, without its invalid members. */
|
|
242
|
+
export declare function validSetElements(node: SetLiteral): SetElement[];
|
|
108
243
|
export declare function isDynamicValueNode(node: ComparisonValueNode | undefined): node is DynamicValueNode;
|
|
109
|
-
export declare function pushWarning(warnings: string[], message: string): void;
|
|
110
244
|
export {};
|
|
111
245
|
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/rule-evaluator/ast.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,OAAO,GAAG,aAAa,GAAG,OAAO,EAAE,CAAC;AAEhD,KAAK,QAAQ,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,QAAQ,CAAC;AAChF,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MA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oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAuB1E;AAED,qGAAqG;AACrG,wBAAgB,eAAe,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAEtE;AAED,iGAAiG;AACjG,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,GAAG,IAAI,QAAQ,CAuB3F;AAED,4GAA4G;AAC5G,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,EAAE,CAE/D;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI,IAAI,gBAAgB,CAElG"}
|
|
@@ -1,10 +1,108 @@
|
|
|
1
1
|
/** Equality and ordering operators, the only ones that accept a field, indexed value, or function result on the right side. */
|
|
2
2
|
export const EQUALITY_ORDERING_OPERATORS = new Set(['eq', 'ne', 'lt', 'le', 'gt', 'ge']);
|
|
3
|
+
/**
|
|
4
|
+
* Ends a switch that lists every node kind, so that a new kind fails
|
|
5
|
+
* compilation until each such switch handles it.
|
|
6
|
+
*/
|
|
7
|
+
export function unhandledNode(node) {
|
|
8
|
+
throw new Error(`unhandled node kind: ${node.kind}`);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* How many of a call's arguments recovery from a syntax error left certain,
|
|
12
|
+
* in value and position: those before FuncNode.uncertainFrom.
|
|
13
|
+
*/
|
|
14
|
+
export function certainArgumentCount(node) {
|
|
15
|
+
return node.uncertainFrom ?? node.args.length;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether a call's argument at an index is uncertain: one the parser read
|
|
19
|
+
* that a syntax error left uncertain, or one after them that may be written
|
|
20
|
+
* where the `)` is missing; see FuncNode.uncertainFrom.
|
|
21
|
+
*/
|
|
22
|
+
export function isUncertainArgument(node, index) {
|
|
23
|
+
return node.uncertainFrom !== undefined && index >= node.uncertainFrom;
|
|
24
|
+
}
|
|
25
|
+
/** Whether a call may have more arguments written than the parser read: recovery hid some, or its `)` is missing. */
|
|
26
|
+
export function mayHaveMoreArguments(node) {
|
|
27
|
+
return node.moreArguments === true;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether some of the arguments the parser read for a call may be another
|
|
31
|
+
* call's, or no arguments at all; see FuncNode.openInCall and
|
|
32
|
+
* FuncNode.strayArgument.
|
|
33
|
+
*/
|
|
34
|
+
export function mayHaveFewerArguments(node) {
|
|
35
|
+
return node.openInCall === true || node.strayArgument === true;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether a function argument is a condition, which Cloudflare evaluates as a
|
|
39
|
+
* Boolean that is never nil: a comparison, a logical expression, a Boolean
|
|
40
|
+
* field, or a function call the parser marked as one, such as
|
|
41
|
+
* `(has_value(...))`. Invalid syntax is not one.
|
|
42
|
+
*/
|
|
43
|
+
export function isConditionArgument(arg) {
|
|
44
|
+
switch (arg.kind) {
|
|
45
|
+
case 'Comparison':
|
|
46
|
+
case 'And':
|
|
47
|
+
case 'Or':
|
|
48
|
+
case 'Xor':
|
|
49
|
+
case 'Not':
|
|
50
|
+
case 'BoolField':
|
|
51
|
+
return true;
|
|
52
|
+
case 'Func':
|
|
53
|
+
return arg.condition === true;
|
|
54
|
+
case 'Field':
|
|
55
|
+
case 'StringLiteral':
|
|
56
|
+
case 'NumberLiteral':
|
|
57
|
+
case 'IpLiteral':
|
|
58
|
+
case 'BoolLiteral':
|
|
59
|
+
case 'SetLiteral':
|
|
60
|
+
case 'ListRef':
|
|
61
|
+
case 'Invalid':
|
|
62
|
+
return false;
|
|
63
|
+
default:
|
|
64
|
+
return unhandledNode(arg);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Whether a function argument holds no value, as a stray comma may leave; see InvalidNode.empty. */
|
|
68
|
+
export function isEmptyArgument(arg) {
|
|
69
|
+
return arg.kind === 'Invalid' && arg.empty === true;
|
|
70
|
+
}
|
|
71
|
+
/** Whether a function argument is an expression node: a condition, a call, or invalid syntax. */
|
|
72
|
+
export function isExpressionNode(arg) {
|
|
73
|
+
if (!arg)
|
|
74
|
+
return false;
|
|
75
|
+
switch (arg.kind) {
|
|
76
|
+
case 'Comparison':
|
|
77
|
+
case 'And':
|
|
78
|
+
case 'Or':
|
|
79
|
+
case 'Xor':
|
|
80
|
+
case 'Not':
|
|
81
|
+
case 'BoolField':
|
|
82
|
+
case 'Func':
|
|
83
|
+
case 'Invalid':
|
|
84
|
+
return true;
|
|
85
|
+
case 'Field':
|
|
86
|
+
case 'StringLiteral':
|
|
87
|
+
case 'NumberLiteral':
|
|
88
|
+
case 'IpLiteral':
|
|
89
|
+
case 'BoolLiteral':
|
|
90
|
+
case 'SetLiteral':
|
|
91
|
+
case 'ListRef':
|
|
92
|
+
return false;
|
|
93
|
+
default:
|
|
94
|
+
return unhandledNode(arg);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Whether a field name is `true` or `false`, which the tokenizer reads as a Boolean, not an identifier. */
|
|
98
|
+
export function isBooleanLiteralName(name) {
|
|
99
|
+
return name === 'true' || name === 'false';
|
|
100
|
+
}
|
|
101
|
+
/** The valid elements of an inline list, without its invalid members. */
|
|
102
|
+
export function validSetElements(node) {
|
|
103
|
+
return node.elements.filter((element) => element.type !== 'invalid');
|
|
104
|
+
}
|
|
3
105
|
export function isDynamicValueNode(node) {
|
|
4
106
|
return node?.kind === 'Field' || node?.kind === 'Func';
|
|
5
107
|
}
|
|
6
|
-
export function pushWarning(warnings, message) {
|
|
7
|
-
if (!warnings.includes(message))
|
|
8
|
-
warnings.push(message);
|
|
9
|
-
}
|
|
10
108
|
//# sourceMappingURL=ast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/rule-evaluator/ast.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/rule-evaluator/ast.ts"],"names":[],"mappings":"AAmDA,+HAA+H;AAC/H,MAAM,CAAC,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AA2G9G;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAW;IACxC,MAAM,IAAI,KAAK,CAAC,wBAAyB,IAA2B,CAAC,IAAI,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAc;IAClD,OAAO,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAc,EAAE,KAAa;IAChE,OAAO,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC;AACxE,CAAC;AAED,qHAAqH;AACrH,MAAM,UAAU,oBAAoB,CAAC,IAAc;IAClD,OAAO,IAAI,CAAC,aAAa,KAAK,IAAI,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAc;IACnD,OAAO,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,CAAC;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAA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,KAAK,CAAC;QACd;YACC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;AACF,CAAC;AAED,4GAA4G;AAC5G,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAChD,OAAO,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,OAAO,CAAC;AAC5C,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,gBAAgB,CAAC,IAAgB;IAChD,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAyB,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAqC;IACvE,OAAO,IAAI,EAAE,IAAI,KAAK,OAAO,IAAI,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare's String and Bytes values are bytes, which this evaluator holds as
|
|
3
|
+
* JavaScript strings: UTF-8 characters as themselves, and each byte that is not
|
|
4
|
+
* part of a UTF-8 character as a lone surrogate from U+DC80 to U+DCFF, as
|
|
5
|
+
* Python's surrogateescape does. Valid UTF-8 never decodes to a lone surrogate,
|
|
6
|
+
* so each string holds one byte sequence. Joining strings can hold a sequence
|
|
7
|
+
* in another form, such as the two halves of "é" as two lone surrogates, so
|
|
8
|
+
* function results are kept in the form bytesToText() gives. Text such as a
|
|
9
|
+
* rule literal then compares with a string as the bytes would.
|
|
10
|
+
*/
|
|
11
|
+
/** Holds bytes as a string, escaping each byte that is not part of a UTF-8 character. */
|
|
12
|
+
export declare function bytesToText(bytes: Uint8Array): string;
|
|
13
|
+
/** Returns a string in the one form bytesToText() gives its bytes. */
|
|
14
|
+
export declare function canonicalText(text: string): string;
|
|
15
|
+
/** Returns the bytes a string holds. */
|
|
16
|
+
export declare function textToBytes(text: string): Uint8Array;
|
|
17
|
+
/** Counts the bytes a string holds without encoding it. */
|
|
18
|
+
export declare function byteLength(text: string): number;
|
|
19
|
+
/** Orders byte sequences as Cloudflare does, byte by byte. */
|
|
20
|
+
export declare function compareBytes(left: Uint8Array, right: Uint8Array): number;
|
|
21
|
+
/** Whether a code point is a lone surrogate, which a string holds for a byte that is not UTF-8. */
|
|
22
|
+
export declare function isSurrogate(code: number): boolean;
|
|
23
|
+
//# sourceMappingURL=byte-strings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"byte-strings.d.ts","sourceRoot":"","sources":["../../src/rule-evaluator/byte-strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAYH,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAMrD;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wCAAwC;AACxC,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAWpD;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY/C;AAED,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAMxE;AAED,mGAAmG;AACnG,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare's String and Bytes values are bytes, which this evaluator holds as
|
|
3
|
+
* JavaScript strings: UTF-8 characters as themselves, and each byte that is not
|
|
4
|
+
* part of a UTF-8 character as a lone surrogate from U+DC80 to U+DCFF, as
|
|
5
|
+
* Python's surrogateescape does. Valid UTF-8 never decodes to a lone surrogate,
|
|
6
|
+
* so each string holds one byte sequence. Joining strings can hold a sequence
|
|
7
|
+
* in another form, such as the two halves of "é" as two lone surrogates, so
|
|
8
|
+
* function results are kept in the form bytesToText() gives. Text such as a
|
|
9
|
+
* rule literal then compares with a string as the bytes would.
|
|
10
|
+
*/
|
|
11
|
+
const UTF8_ENCODER = new TextEncoder();
|
|
12
|
+
// Fatal, so bytes that are not UTF-8 throw; ignoreBOM keeps a byte order mark,
|
|
13
|
+
// including one after an escaped byte.
|
|
14
|
+
const UTF8_DECODER = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
|
|
15
|
+
/** A lone surrogate holds the byte it adds to this. */
|
|
16
|
+
const ESCAPE_BASE = 0xdc00;
|
|
17
|
+
/** TextEncoder writes another lone surrogate, which no bytes give, as U+FFFD. */
|
|
18
|
+
const REPLACEMENT_CHARACTER_BYTES = [0xef, 0xbf, 0xbd];
|
|
19
|
+
/** Holds bytes as a string, escaping each byte that is not part of a UTF-8 character. */
|
|
20
|
+
export function bytesToText(bytes) {
|
|
21
|
+
try {
|
|
22
|
+
return UTF8_DECODER.decode(bytes);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return decodeEscaping(bytes);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Returns a string in the one form bytesToText() gives its bytes. */
|
|
29
|
+
export function canonicalText(text) {
|
|
30
|
+
return text.isWellFormed() ? text : bytesToText(textToBytes(text));
|
|
31
|
+
}
|
|
32
|
+
/** Returns the bytes a string holds. */
|
|
33
|
+
export function textToBytes(text) {
|
|
34
|
+
if (text.isWellFormed())
|
|
35
|
+
return UTF8_ENCODER.encode(text);
|
|
36
|
+
const bytes = [];
|
|
37
|
+
// Iterating by code point keeps a surrogate pair together, so a surrogate here is lone.
|
|
38
|
+
for (const char of text) {
|
|
39
|
+
const code = char.codePointAt(0) ?? 0;
|
|
40
|
+
if (isEscape(code))
|
|
41
|
+
bytes.push(code - ESCAPE_BASE);
|
|
42
|
+
else if (isSurrogate(code))
|
|
43
|
+
bytes.push(...REPLACEMENT_CHARACTER_BYTES);
|
|
44
|
+
else
|
|
45
|
+
bytes.push(...UTF8_ENCODER.encode(char));
|
|
46
|
+
}
|
|
47
|
+
return Uint8Array.from(bytes);
|
|
48
|
+
}
|
|
49
|
+
/** Counts the bytes a string holds without encoding it. */
|
|
50
|
+
export function byteLength(text) {
|
|
51
|
+
let length = 0;
|
|
52
|
+
for (let index = 0; index < text.length; index++) {
|
|
53
|
+
const code = text.charCodeAt(index);
|
|
54
|
+
if (code < 0x80)
|
|
55
|
+
length += 1;
|
|
56
|
+
else if (code < 0x800)
|
|
57
|
+
length += 2;
|
|
58
|
+
else if (isHighSurrogate(code) && isLowSurrogate(text.charCodeAt(index + 1))) {
|
|
59
|
+
length += 4;
|
|
60
|
+
index++;
|
|
61
|
+
}
|
|
62
|
+
else
|
|
63
|
+
length += isEscape(code) ? 1 : 3;
|
|
64
|
+
}
|
|
65
|
+
return length;
|
|
66
|
+
}
|
|
67
|
+
/** Orders byte sequences as Cloudflare does, byte by byte. */
|
|
68
|
+
export function compareBytes(left, right) {
|
|
69
|
+
const length = Math.min(left.length, right.length);
|
|
70
|
+
for (let index = 0; index < length; index++) {
|
|
71
|
+
if (left[index] !== right[index])
|
|
72
|
+
return left[index] - right[index];
|
|
73
|
+
}
|
|
74
|
+
return left.length - right.length;
|
|
75
|
+
}
|
|
76
|
+
/** Whether a code point is a lone surrogate, which a string holds for a byte that is not UTF-8. */
|
|
77
|
+
export function isSurrogate(code) {
|
|
78
|
+
return code >= 0xd800 && code <= 0xdfff;
|
|
79
|
+
}
|
|
80
|
+
function decodeEscaping(bytes) {
|
|
81
|
+
const parts = [];
|
|
82
|
+
// The start of the UTF-8 run that the next escape ends.
|
|
83
|
+
let start = 0;
|
|
84
|
+
let index = 0;
|
|
85
|
+
while (index < bytes.length) {
|
|
86
|
+
const length = utf8SequenceLength(bytes, index);
|
|
87
|
+
if (length > 0) {
|
|
88
|
+
index += length;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
parts.push(UTF8_DECODER.decode(bytes.subarray(start, index)), String.fromCharCode(ESCAPE_BASE + bytes[index]));
|
|
92
|
+
start = ++index;
|
|
93
|
+
}
|
|
94
|
+
parts.push(UTF8_DECODER.decode(bytes.subarray(start)));
|
|
95
|
+
return parts.join('');
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns the length of the UTF-8 character at an index, or 0 when its bytes
|
|
99
|
+
* are not one, following the well-formed sequences of Unicode's Table 3-7. A
|
|
100
|
+
* byte that does not start a character is escaped alone, so a character after
|
|
101
|
+
* it still decodes.
|
|
102
|
+
*/
|
|
103
|
+
function utf8SequenceLength(bytes, index) {
|
|
104
|
+
const lead = bytes[index];
|
|
105
|
+
if (lead < 0x80)
|
|
106
|
+
return 1;
|
|
107
|
+
// The range of the second byte, which is narrower after some lead bytes.
|
|
108
|
+
let min = 0x80;
|
|
109
|
+
let max = 0xbf;
|
|
110
|
+
let length;
|
|
111
|
+
if (lead >= 0xc2 && lead <= 0xdf) {
|
|
112
|
+
length = 2;
|
|
113
|
+
}
|
|
114
|
+
else if (lead >= 0xe0 && lead <= 0xef) {
|
|
115
|
+
length = 3;
|
|
116
|
+
if (lead === 0xe0)
|
|
117
|
+
min = 0xa0;
|
|
118
|
+
if (lead === 0xed)
|
|
119
|
+
max = 0x9f;
|
|
120
|
+
}
|
|
121
|
+
else if (lead >= 0xf0 && lead <= 0xf4) {
|
|
122
|
+
length = 4;
|
|
123
|
+
if (lead === 0xf0)
|
|
124
|
+
min = 0x90;
|
|
125
|
+
if (lead === 0xf4)
|
|
126
|
+
max = 0x8f;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
const second = bytes[index + 1];
|
|
132
|
+
if (second === undefined || second < min || second > max)
|
|
133
|
+
return 0;
|
|
134
|
+
for (let next = index + 2; next < index + length; next++) {
|
|
135
|
+
const byte = bytes[next];
|
|
136
|
+
if (byte === undefined || byte < 0x80 || byte > 0xbf)
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
return length;
|
|
140
|
+
}
|
|
141
|
+
function isEscape(code) {
|
|
142
|
+
return code >= ESCAPE_BASE + 0x80 && code <= ESCAPE_BASE + 0xff;
|
|
143
|
+
}
|
|
144
|
+
function isHighSurrogate(code) {
|
|
145
|
+
return code >= 0xd800 && code <= 0xdbff;
|
|
146
|
+
}
|
|
147
|
+
function isLowSurrogate(code) {
|
|
148
|
+
return code >= 0xdc00 && code <= 0xdfff;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=byte-strings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"byte-strings.js","sourceRoot":"","sources":["../../src/rule-evaluator/byte-strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,YAAY,GAAG,IAAI,WAAW,EAAE,CAAC;AACvC,+EAA+E;AAC/E,uCAAuC;AACvC,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAEhF,uDAAuD;AACvD,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,iFAAiF;AACjF,MAAM,2BAA2B,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEvD,yFAAyF;AACzF,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC5C,IAAI,CAAC;QACJ,OAAO,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACF,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,aAAa,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,wCAAwC;AACxC,MAAM,UA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CAAC;IAChC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,GAAG,GAAG;QAAE,OAAO,CAAC,CAAC;IACnE,KAAK,IAAI,IAAI,GAAG,KAAK,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;QAC1D,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,IAAI;YAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC7B,OAAO,IAAI,IAAI,WAAW,GAAG,IAAI,IAAI,IAAI,IAAI,WAAW,GAAG,IAAI,CAAC;AACjE,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACpC,OAAO,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC;AACzC,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IACnC,OAAO,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC;AACzC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const RULE_EXPRESSION_OPERATORS: readonly ["eq", "ne", "lt", "le", "gt", "ge", "contains", "matches", "wildcard", "in", "and", "or", "xor", "not", "strict"];
|
|
2
|
-
export declare const RULE_EXPRESSION_FUNCTIONS: readonly ["all", "any", "bit_slice", "cidr", "cidr6", "coalesce", "concat", "decode_base64", "encode_base64", "ends_with", "has_key", "has_value", "is_jwt_present", "is_jwt_valid", "is_timed_hmac_valid_v0", "join", "len", "lookup_json_integer", "lookup_json_string", "lower", "regex_replace", "remove_bytes", "remove_query_args", "sha256", "split", "starts_with", "substring", "to_string", "upper", "url_decode", "uuidv4", "wildcard_replace"];
|
|
2
|
+
export declare const RULE_EXPRESSION_FUNCTIONS: readonly ["all", "any", "bit_slice", "cidr", "cidr6", "coalesce", "concat", "decode_base64", "encode_base64", "ends_with", "has_key", "has_value", "hash_in_range", "is_jwt_present", "is_jwt_valid", "is_timed_hmac_valid_v0", "join", "len", "lookup_json_integer", "lookup_json_string", "lower", "regex_replace", "remove_bytes", "remove_query_args", "sha256", "split", "starts_with", "substring", "to_string", "upper", "url_decode", "uuidv4", "wildcard_replace"];
|
|
3
3
|
/**
|
|
4
4
|
* The only place Cloudflare accepts `true`: as an entire expression, which
|
|
5
5
|
* matches every request. The rules language has no Boolean literals, so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/rule-evaluator/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,6HAI5B,CAAC;AAEX,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/rule-evaluator/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,6HAI5B,CAAC;AAEX,eAAO,MAAM,yBAAyB,6cAkC5B,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,SAAS,CAAC;AAE3D,MAAM,MAAM,sBAAsB,GAAG,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAC9E,MAAM,MAAM,sBAAsB,GAAG,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/rule-evaluator/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAClC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI;IACvC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ;CAC1B,CAAC;AAEX,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,KAAK;IACL,KAAK;IACL,WAAW;IACX,MAAM;IACN,OAAO;IACP,UAAU;IACV,QAAQ;IACR,eAAe;IACf,eAAe;IACf,WAAW;IACX,SAAS;IACT,WAAW;IACX,gBAAgB;IAChB,cAAc;IACd,wBAAwB;IACxB,MAAM;IACN,KAAK;IACL,qBAAqB;IACrB,oBAAoB;IACpB,OAAO;IACP,eAAe;IACf,cAAc;IACd,mBAAmB;IACnB,QAAQ;IACR,OAAO;IACP,aAAa;IACb,WAAW;IACX,WAAW;IACX,OAAO;IACP,YAAY;IACZ,QAAQ;IACR,kBAAkB;CACT,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/rule-evaluator/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAClC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI;IACvC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ;CAC1B,CAAC;AAEX,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,KAAK;IACL,KAAK;IACL,WAAW;IACX,MAAM;IACN,OAAO;IACP,UAAU;IACV,QAAQ;IACR,eAAe;IACf,eAAe;IACf,WAAW;IACX,SAAS;IACT,WAAW;IACX,eAAe;IACf,gBAAgB;IAChB,cAAc;IACd,wBAAwB;IACxB,MAAM;IACN,KAAK;IACL,qBAAqB;IACrB,oBAAoB;IACpB,OAAO;IACP,eAAe;IACf,cAAc;IACd,mBAAmB;IACnB,QAAQ;IACR,OAAO;IACP,aAAa;IACb,WAAW;IACX,WAAW;IACX,OAAO;IACP,YAAY;IACZ,QAAQ;IACR,kBAAkB;CACT,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,MAAM,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Generated by `npm run build:country-codes`. Do not edit manually.
|
|
3
3
|
*
|
|
4
|
-
* Source: @cloudflare/workers-types 5.
|
|
4
|
+
* Source: @cloudflare/workers-types 5.20261010.1, Iso3166Alpha2Code.
|
|
5
5
|
* License: MIT OR Apache-2.0.
|
|
6
6
|
*/
|
|
7
7
|
/** ISO 3166-1 alpha-2 codes exposed by the pinned Cloudflare Workers types. */
|
|
@@ -35,6 +35,15 @@ export declare function clearRuleExpressionCustomListCaches(): void;
|
|
|
35
35
|
* content cache for equivalent arrays.
|
|
36
36
|
*/
|
|
37
37
|
export declare function ipListContains(items: readonly string[], value: CfValue): boolean;
|
|
38
|
+
/** Returns an IP address as its 4 or 16 octets in network order, or null when it is not one. */
|
|
39
|
+
export declare function ipAddressOctets(value: string): Uint8Array | null;
|
|
40
|
+
/**
|
|
41
|
+
* Formats 4 or 16 octets as Cloudflare prints an IP address. IPv6 is
|
|
42
|
+
* compressed as Rust prints it: lowercase groups without leading zeros, the
|
|
43
|
+
* first longest run of two or more zero groups as `::`, and an IPv4-mapped
|
|
44
|
+
* address as `::ffff:a.b.c.d`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function formatIpAddress(octets: Uint8Array): string;
|
|
38
47
|
/** Returns an IPv6 address as a 128-bit number, or null when it is not one. */
|
|
39
48
|
export declare function ipv6ToBigInt(address: string): bigint | null;
|
|
40
49
|
//# sourceMappingURL=custom-lists.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-lists.d.ts","sourceRoot":"","sources":["../../src/rule-evaluator/custom-lists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMxC,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,IAAI,CA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