@memberjunction/global 6.2.0-edge.5 → 6.2.0-edge.7
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 +8 -4
- package/dist/ClassFactory.d.ts +30 -0
- package/dist/ClassFactory.d.ts.map +1 -1
- package/dist/ClassFactory.js +69 -5
- package/dist/ClassFactory.js.map +1 -1
- package/dist/KeyedSerialTaskQueue.d.ts +18 -1
- package/dist/KeyedSerialTaskQueue.d.ts.map +1 -1
- package/dist/KeyedSerialTaskQueue.js +24 -3
- package/dist/KeyedSerialTaskQueue.js.map +1 -1
- package/dist/SQLExpressionValidator.d.ts +34 -9
- package/dist/SQLExpressionValidator.d.ts.map +1 -1
- package/dist/SQLExpressionValidator.js +58 -17
- package/dist/SQLExpressionValidator.js.map +1 -1
- package/dist/SQLScreeningScanner.d.ts +28 -2
- package/dist/SQLScreeningScanner.d.ts.map +1 -1
- package/dist/SQLScreeningScanner.js +166 -23
- package/dist/SQLScreeningScanner.js.map +1 -1
- package/dist/SafeExpressionEvaluator.d.ts +93 -109
- package/dist/SafeExpressionEvaluator.d.ts.map +1 -1
- package/dist/SafeExpressionEvaluator.js +494 -346
- package/dist/SafeExpressionEvaluator.js.map +1 -1
- package/dist/__tests__/ClassFactory.collision.test.js +110 -0
- package/dist/__tests__/ClassFactory.collision.test.js.map +1 -1
- package/dist/__tests__/ClassFactory.test.js +21 -0
- package/dist/__tests__/ClassFactory.test.js.map +1 -1
- package/dist/__tests__/FieldSecurityEgressCompliance.test.d.ts +2 -0
- package/dist/__tests__/FieldSecurityEgressCompliance.test.d.ts.map +1 -0
- package/dist/__tests__/FieldSecurityEgressCompliance.test.js +228 -0
- package/dist/__tests__/FieldSecurityEgressCompliance.test.js.map +1 -0
- package/dist/__tests__/FieldTransformEngine.screen.test.d.ts +2 -0
- package/dist/__tests__/FieldTransformEngine.screen.test.d.ts.map +1 -0
- package/dist/__tests__/FieldTransformEngine.screen.test.js +41 -0
- package/dist/__tests__/FieldTransformEngine.screen.test.js.map +1 -0
- package/dist/__tests__/FieldTransformEngine.security.test.d.ts +2 -0
- package/dist/__tests__/FieldTransformEngine.security.test.d.ts.map +1 -0
- package/dist/__tests__/FieldTransformEngine.security.test.js +74 -0
- package/dist/__tests__/FieldTransformEngine.security.test.js.map +1 -0
- package/dist/__tests__/KeyedSerialTaskQueue.test.js +92 -0
- package/dist/__tests__/KeyedSerialTaskQueue.test.js.map +1 -1
- package/dist/__tests__/PlatformStringCompliance.baseline.d.ts +10 -0
- package/dist/__tests__/PlatformStringCompliance.baseline.d.ts.map +1 -0
- package/dist/__tests__/PlatformStringCompliance.baseline.js +12 -0
- package/dist/__tests__/PlatformStringCompliance.baseline.js.map +1 -0
- package/dist/__tests__/PlatformStringCompliance.test.d.ts +8 -0
- package/dist/__tests__/PlatformStringCompliance.test.d.ts.map +1 -0
- package/dist/__tests__/PlatformStringCompliance.test.js +152 -0
- package/dist/__tests__/PlatformStringCompliance.test.js.map +1 -0
- package/dist/__tests__/ProofOfPossession.test.d.ts +2 -0
- package/dist/__tests__/ProofOfPossession.test.d.ts.map +1 -0
- package/dist/__tests__/ProofOfPossession.test.js +123 -0
- package/dist/__tests__/ProofOfPossession.test.js.map +1 -0
- package/dist/__tests__/SQLExpressionValidator.dialect.test.d.ts +2 -0
- package/dist/__tests__/SQLExpressionValidator.dialect.test.d.ts.map +1 -0
- package/dist/__tests__/SQLExpressionValidator.dialect.test.js +183 -0
- package/dist/__tests__/SQLExpressionValidator.dialect.test.js.map +1 -0
- package/dist/__tests__/SQLScreeningScanner.tokens.test.d.ts +2 -0
- package/dist/__tests__/SQLScreeningScanner.tokens.test.d.ts.map +1 -0
- package/dist/__tests__/SQLScreeningScanner.tokens.test.js +82 -0
- package/dist/__tests__/SQLScreeningScanner.tokens.test.js.map +1 -0
- package/dist/__tests__/SafeExpressionEvaluator.allowlist.test.d.ts +2 -0
- package/dist/__tests__/SafeExpressionEvaluator.allowlist.test.d.ts.map +1 -0
- package/dist/__tests__/SafeExpressionEvaluator.allowlist.test.js +200 -0
- package/dist/__tests__/SafeExpressionEvaluator.allowlist.test.js.map +1 -0
- package/dist/__tests__/SafeExpressionEvaluator.security.test.js +11 -0
- package/dist/__tests__/SafeExpressionEvaluator.security.test.js.map +1 -1
- package/dist/__tests__/SafeExpressionEvaluator.test.js +4 -2
- package/dist/__tests__/SafeExpressionEvaluator.test.js.map +1 -1
- package/dist/__tests__/UUIDCompliance.test.js +3 -4
- package/dist/__tests__/UUIDCompliance.test.js.map +1 -1
- package/dist/__tests__/UserScopedCacheKey.test.d.ts +2 -0
- package/dist/__tests__/UserScopedCacheKey.test.d.ts.map +1 -0
- package/dist/__tests__/UserScopedCacheKey.test.js +25 -0
- package/dist/__tests__/UserScopedCacheKey.test.js.map +1 -0
- package/dist/fieldRules/FieldTransformEngine.d.ts +12 -1
- package/dist/fieldRules/FieldTransformEngine.d.ts.map +1 -1
- package/dist/fieldRules/FieldTransformEngine.js +21 -8
- package/dist/fieldRules/FieldTransformEngine.js.map +1 -1
- package/dist/fieldRules/SafeTransformAstEvaluator.d.ts +16 -0
- package/dist/fieldRules/SafeTransformAstEvaluator.d.ts.map +1 -0
- package/dist/fieldRules/SafeTransformAstEvaluator.js +797 -0
- package/dist/fieldRules/SafeTransformAstEvaluator.js.map +1 -0
- package/dist/fieldRules/index.d.ts +1 -0
- package/dist/fieldRules/index.d.ts.map +1 -1
- package/dist/fieldRules/index.js +1 -0
- package/dist/fieldRules/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/util/BinaryEncoding.d.ts +2 -0
- package/dist/util/BinaryEncoding.d.ts.map +1 -1
- package/dist/util/BinaryEncoding.js +3 -5
- package/dist/util/BinaryEncoding.js.map +1 -1
- package/dist/util/ProofOfPossession.d.ts +68 -0
- package/dist/util/ProofOfPossession.d.ts.map +1 -0
- package/dist/util/ProofOfPossession.js +163 -0
- package/dist/util/ProofOfPossession.js.map +1 -0
- package/dist/util/UserScopedCacheKey.d.ts +42 -0
- package/dist/util/UserScopedCacheKey.d.ts.map +1 -0
- package/dist/util/UserScopedCacheKey.js +49 -0
- package/dist/util/UserScopedCacheKey.js.map +1 -0
- package/package.json +1 -1
|
@@ -9,31 +9,54 @@
|
|
|
9
9
|
* @author MemberJunction.com
|
|
10
10
|
* @since 2.76.0
|
|
11
11
|
*/
|
|
12
|
+
/** One approved global: whether it may be called by bare name, and which of its methods may be called. */
|
|
13
|
+
export interface ApprovedExpressionGlobal {
|
|
14
|
+
/** `true` when the global itself may be called: `Number(x)`, `parseInt(x)`. */
|
|
15
|
+
readonly Callable: boolean;
|
|
16
|
+
/** Methods that may be called on the global by dotted name: `Math.max(a, b)`. */
|
|
17
|
+
readonly Methods: ReadonlySet<string>;
|
|
18
|
+
}
|
|
12
19
|
/**
|
|
13
|
-
*
|
|
20
|
+
* **The approved globals — the only host globals an expression can reach.**
|
|
14
21
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
22
|
+
* This is the single list reviewers should check. Every other free identifier in an expression must
|
|
23
|
+
* be an evaluation-context key or an arrow-function parameter in scope; anything else is refused
|
|
24
|
+
* before compilation (see {@link SafeExpressionEvaluator.ScreenExpression}).
|
|
25
|
+
*
|
|
26
|
+
* An approved global is usable ONLY in call position — `Math.max(a, b)`, `Number(x)` — never as a
|
|
27
|
+
* bare value, a property read (`Math.PI`), or a callback (`items.map(Number)`). That rule is what
|
|
28
|
+
* stops a function being handed to code that calls it with attacker-chosen arguments: two confirmed
|
|
29
|
+
* bypasses of the earlier denylist did exactly that (`a.reduce(fetch)` and
|
|
30
|
+
* `p.reduce(Object.assign)`).
|
|
19
31
|
*
|
|
20
|
-
* Every
|
|
21
|
-
*
|
|
22
|
-
* `
|
|
32
|
+
* Every listed member is a pure function of its arguments. Deliberately absent: `Object.assign`,
|
|
33
|
+
* `Object.defineProperty`, `Object.getPrototypeOf`/`setPrototypeOf` (mutate or open the prototype
|
|
34
|
+
* chain), `Math.random` (a guard that changes per run is not a guard), `String.fromCharCode`, and
|
|
35
|
+
* every host API (`fetch`, `setTimeout`, `require`, `process`, ...).
|
|
36
|
+
*
|
|
37
|
+
* Both halves of `Math.abs(x)` are fixed identifiers in the AST, so admitting them adds no dynamic
|
|
38
|
+
* lookup.
|
|
39
|
+
*/
|
|
40
|
+
export declare const APPROVED_EXPRESSION_GLOBALS: ReadonlyMap<string, ApprovedExpressionGlobal>;
|
|
41
|
+
/**
|
|
42
|
+
* Global names that are VALUES, not functions, and may appear anywhere a value can: `x === undefined`.
|
|
43
|
+
* Each is a non-writable primitive, so referencing one cannot reach host code.
|
|
44
|
+
*/
|
|
45
|
+
export declare const APPROVED_VALUE_GLOBALS: ReadonlySet<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Namespace globals whose listed methods an expression may CALL, keyed by namespace name.
|
|
48
|
+
* Derived from {@link APPROVED_EXPRESSION_GLOBALS}.
|
|
23
49
|
*/
|
|
24
50
|
export declare const SAFE_GLOBAL_NAMESPACE_METHODS: ReadonlyMap<string, ReadonlySet<string>>;
|
|
25
51
|
/**
|
|
26
|
-
* Global functions
|
|
27
|
-
*
|
|
52
|
+
* Global functions an expression may call by bare name (`Number(payload.count) > 3`).
|
|
53
|
+
* Derived from {@link APPROVED_EXPRESSION_GLOBALS}.
|
|
28
54
|
*/
|
|
29
55
|
export declare const SAFE_GLOBAL_CALLABLES: ReadonlySet<string>;
|
|
30
56
|
/**
|
|
31
|
-
* Every global name
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* beside the policy screen that enforces it so a caller validating conditions ahead of evaluation
|
|
35
|
-
* (`ai-core-plus`'s task-graph door) cannot bless a name the runtime would refuse — the failure mode
|
|
36
|
-
* that shipped once already, where the door's own list and the evaluator disagreed silently.
|
|
57
|
+
* Every global name an expression may reference (in call position), as a namespace or as a bare
|
|
58
|
+
* callable. Derived from {@link APPROVED_EXPRESSION_GLOBALS}, so a caller validating conditions ahead
|
|
59
|
+
* of evaluation (`ai-core-plus`'s task-graph door) cannot bless a name the runtime would refuse.
|
|
37
60
|
*/
|
|
38
61
|
export declare const SAFE_EXPRESSION_GLOBALS: ReadonlySet<string>;
|
|
39
62
|
/**
|
|
@@ -58,17 +81,19 @@ export interface ExpressionEvaluationResult {
|
|
|
58
81
|
* - Logical: &&, ||, !
|
|
59
82
|
* - Property access: dot notation (e.g., payload.customer.name), including optional chaining (`?.`)
|
|
60
83
|
* - Array access: bracket notation with a literal index/key (e.g., items[0])
|
|
61
|
-
* - Safe methods: .length, .includes(), .startsWith(), .endsWith()
|
|
62
|
-
* - Array methods: .some(), .every(), .find(), .filter()
|
|
63
|
-
*
|
|
84
|
+
* - Safe methods: .length, .includes(), .startsWith(), .endsWith(), .split(), .slice(), ...
|
|
85
|
+
* - Array methods: .some(), .every(), .find(), .filter(), .map(), .reduce() — the callback must be
|
|
86
|
+
* an inline arrow function (`items.some(i => i.price > 100)`, never `items.some(fn)`)
|
|
87
|
+
* - Approved globals, in call position only: {@link APPROVED_EXPRESSION_GLOBALS}
|
|
64
88
|
* (e.g. `Math.abs(output.delta) < 5`, `Number(payload.count) > 3`, `Object.keys(payload).length`)
|
|
65
89
|
* - Type checking: typeof
|
|
66
90
|
*
|
|
67
91
|
* Safety is enforced by parsing the expression to an AST and walking it against
|
|
68
|
-
* an ALLOWLIST
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
92
|
+
* an ALLOWLIST before it is compiled. Node types, operators, methods and free identifiers are
|
|
93
|
+
* all allowlisted: a free identifier must be a context key, an arrow parameter in scope, or an
|
|
94
|
+
* approved global used as a call. An unlisted construct (computed member access with a non-literal
|
|
95
|
+
* key, `.constructor`/`__proto__` access, any call outside the safe-method and approved-global
|
|
96
|
+
* lists, any other identifier, etc.) is rejected at validation time and never reaches the compiler. A structural
|
|
72
97
|
* allowlist cannot be defeated by string concatenation the way a textual
|
|
73
98
|
* denylist can, and it does not over-reject data that merely mentions a reserved
|
|
74
99
|
* word (e.g. `name == 'constructor'` is a legal comparison).
|
|
@@ -99,96 +124,47 @@ export interface ExpressionEvaluationResult {
|
|
|
99
124
|
* ```
|
|
100
125
|
*/
|
|
101
126
|
export declare class SafeExpressionEvaluator {
|
|
102
|
-
/**
|
|
103
|
-
* Identifiers that must never resolve to a host global. Because the compiled
|
|
104
|
-
* function runs in global scope, a bare `process`/`Function`/`globalThis`/…
|
|
105
|
-
* would reach the real global object; identifiers are atomic AST tokens, so a
|
|
106
|
-
* name that is split with string concatenation parses as separate identifiers
|
|
107
|
-
* or an operator and is caught by the structural rules instead.
|
|
108
|
-
* @private
|
|
109
|
-
*/
|
|
110
|
-
private static readonly DANGEROUS_IDENTIFIERS;
|
|
111
|
-
/**
|
|
112
|
-
* Property names that open the prototype chain / constructor climb. Denied on
|
|
113
|
-
* both dotted (`x.constructor`) and literal-bracket (`x["constructor"]`) access.
|
|
114
|
-
* @private
|
|
115
|
-
*/
|
|
116
|
-
private static readonly DANGEROUS_PROPERTY_NAMES;
|
|
117
|
-
/** Binary operators the evaluator permits. `instanceof`/`in`/bitwise are excluded. @private */
|
|
118
|
-
private static readonly ALLOWED_BINARY_OPERATORS;
|
|
119
|
-
/** Unary operators the evaluator permits. `delete`/`void` are excluded. @private */
|
|
120
|
-
private static readonly ALLOWED_UNARY_OPERATORS;
|
|
121
127
|
/**
|
|
122
128
|
* Cache for compiled expressions to improve performance on repeated evaluations
|
|
123
129
|
* @private
|
|
124
130
|
*/
|
|
125
131
|
private readonly _compiledExpressionCache;
|
|
126
|
-
/**
|
|
127
|
-
* Safe methods that can be called on objects
|
|
128
|
-
* @private
|
|
129
|
-
*/
|
|
130
|
-
private static readonly SAFE_METHODS;
|
|
131
132
|
/**
|
|
132
133
|
* Evaluates a boolean expression against a context object
|
|
133
134
|
*
|
|
134
135
|
* @param {string} expression - The boolean expression to evaluate
|
|
135
|
-
* @param {Record<string, any>} context - The context object containing variables
|
|
136
|
+
* @param {Record<string, any>} [context={}] - The context object containing variables. Its keys
|
|
137
|
+
* are the only free names the expression may use; a key named like an approved global
|
|
138
|
+
* shadows it (see {@link ScreenExpression}).
|
|
136
139
|
* @param {boolean} [enableDiagnostics=false] - Whether to include diagnostic information
|
|
137
140
|
*
|
|
138
141
|
* @returns {ExpressionEvaluationResult} The evaluation result
|
|
139
142
|
*/
|
|
140
|
-
Evaluate(expression: string, context
|
|
143
|
+
Evaluate(expression: string, context?: Record<string, any>, enableDiagnostics?: boolean): ExpressionEvaluationResult;
|
|
141
144
|
/** @deprecated Use {@link Evaluate}. */
|
|
142
|
-
evaluate(expression: string, context
|
|
145
|
+
evaluate(expression: string, context?: Record<string, any>, enableDiagnostics?: boolean): ExpressionEvaluationResult;
|
|
143
146
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
147
|
+
* Screens an expression against the allowlist WITHOUT compiling or running it. Returns the
|
|
148
|
+
* rejection message, or `null` when every construct is permitted.
|
|
146
149
|
*
|
|
147
|
-
*
|
|
150
|
+
* This is the single policy gate for every place MemberJunction compiles a user- or LLM-authored
|
|
151
|
+
* expression: {@link Evaluate}, {@link ValidateSyntax}, and the field-rule / integration formula
|
|
152
|
+
* engine (`FieldTransformEngine`), which passes `['value', 'fields']`.
|
|
148
153
|
*
|
|
149
|
-
*
|
|
154
|
+
* A context key or arrow parameter named like an approved global (`Math`, `JSON`, ...) shadows
|
|
155
|
+
* it and is screened as data, so `Math.abs(x)` with a `Math` context key is refused because
|
|
156
|
+
* `abs` is not a safe instance method. Do not pass approved-global names as context keys.
|
|
150
157
|
*
|
|
151
|
-
* @
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
* Walks an AST node against the allowlist. Returns an error message on the first
|
|
158
|
-
* disallowed construct, or null if the entire subtree is permitted.
|
|
159
|
-
* @private
|
|
160
|
-
*/
|
|
161
|
-
private checkNode;
|
|
162
|
-
/**
|
|
163
|
-
* Member access is allowed for dotted property reads and literal-key bracket
|
|
164
|
-
* reads, but never for a computed key built at runtime (the string-concat
|
|
165
|
-
* escape route) or a prototype-chain property.
|
|
166
|
-
* @private
|
|
167
|
-
*/
|
|
168
|
-
private checkMemberExpression;
|
|
169
|
-
/**
|
|
170
|
-
* A call is admitted only when its callee is a FIXED name on one of two allowlists: a bare
|
|
171
|
-
* safe global (`parseInt(...)`) or a dotted method that is either a safe instance method or a
|
|
172
|
-
* method of a safe global namespace (`Math.abs(...)`). Everything else — a computed callee, an
|
|
173
|
-
* unlisted bare identifier (`eval(...)`, `Function(...)`), a call on a call's result that is
|
|
174
|
-
* not itself a safe method — is rejected.
|
|
175
|
-
* @private
|
|
176
|
-
*/
|
|
177
|
-
private checkCallExpression;
|
|
178
|
-
/**
|
|
179
|
-
* Whether `<receiver>.<method>()` names a permitted call: a safe instance method on any value,
|
|
180
|
-
* or a method of a safe global namespace when the receiver is that namespace by bare name.
|
|
181
|
-
* @private
|
|
158
|
+
* @param expression the expression to screen
|
|
159
|
+
* @param allowedIdentifiers the names the expression may reference as values — the evaluation
|
|
160
|
+
* context keys. Pass `null` only when they are not yet known (authoring-time syntax
|
|
161
|
+
* checks); free identifiers are then left for evaluation time to decide, while approved
|
|
162
|
+
* globals used as values, callbacks that are not inline arrows, and every structural rule
|
|
163
|
+
* are still enforced.
|
|
182
164
|
*/
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
private
|
|
186
|
-
/**
|
|
187
|
-
* Arrow functions are permitted only as callback arguments to the safe array
|
|
188
|
-
* methods; parameters must be simple identifiers and the body an expression.
|
|
189
|
-
* @private
|
|
190
|
-
*/
|
|
191
|
-
private checkArrowFunction;
|
|
165
|
+
static ScreenExpression(expression: string, allowedIdentifiers: Iterable<string> | null): string | null;
|
|
166
|
+
/** Counts parentheses textually; used only to word the error for an expression that failed to parse. @private */
|
|
167
|
+
private static hasUnbalancedParentheses;
|
|
192
168
|
/**
|
|
193
169
|
* Creates a safe context object with only allowed properties
|
|
194
170
|
*
|
|
@@ -212,6 +188,11 @@ export declare class SafeExpressionEvaluator {
|
|
|
212
188
|
/**
|
|
213
189
|
* Safely clones a value for use in evaluation context
|
|
214
190
|
*
|
|
191
|
+
* Functions are never carried into the context: a context should hold data, and a function
|
|
192
|
+
* reachable from an expression is one more thing that could be invoked. A function value
|
|
193
|
+
* becomes `undefined`, and function-valued properties are dropped from plain objects and
|
|
194
|
+
* class instances alike.
|
|
195
|
+
*
|
|
215
196
|
* @param {any} value - The value to clone
|
|
216
197
|
*
|
|
217
198
|
* @returns {any} The cloned value
|
|
@@ -229,32 +210,35 @@ export declare class SafeExpressionEvaluator {
|
|
|
229
210
|
* is a perfectly good condition that simply has no data yet. A submit-time check built on
|
|
230
211
|
* `evaluate` therefore refuses every legitimate condition.
|
|
231
212
|
*
|
|
232
|
-
* So this
|
|
233
|
-
* `evaluate` applies (the AST allowlist), then the same function body
|
|
234
|
-
* never invoked. Values are never consulted, which is precisely the property wanted: unknown
|
|
213
|
+
* So this parses and never runs. The expression goes through the same policy screen
|
|
214
|
+
* `evaluate` applies (the AST allowlist), then the same function body `evaluate` compiles is
|
|
215
|
+
* parsed in strict mode — never compiled, never invoked. Values are never consulted, which is precisely the property wanted: unknown
|
|
235
216
|
* identifiers, absent properties and undefined chains all PASS, because none of them is a syntax
|
|
236
|
-
* error and whether they resolve is a question about a run that has not happened yet.
|
|
217
|
+
* error and whether they resolve is a question about a run that has not happened yet. Pass
|
|
218
|
+
* `contextKeys` when the evaluation context's keys ARE known, and unknown identifiers are refused
|
|
219
|
+
* here exactly as {@link Evaluate} would refuse them.
|
|
237
220
|
*
|
|
238
|
-
* **
|
|
239
|
-
*
|
|
240
|
-
* first, so the constructs `evaluate` refuses are refused here too — those produce a
|
|
241
|
-
* runtime refusal, and an author is better told now.
|
|
221
|
+
* **Parsing is not evaluation**, and the distinction is load-bearing for safety: no code is
|
|
222
|
+
* constructed from the expression here, so nothing in it can execute. The policy screen still
|
|
223
|
+
* runs first, so the constructs `evaluate` refuses are refused here too — those produce a
|
|
224
|
+
* permanent runtime refusal, and an author is better told now.
|
|
242
225
|
*
|
|
243
|
-
*
|
|
244
|
-
* CSP without `unsafe-eval`)
|
|
245
|
-
*
|
|
226
|
+
* Because nothing is compiled, the answer does not depend on the host allowing dynamic code (a
|
|
227
|
+
* strict CSP without `unsafe-eval`). `Undecidable` is kept in the result type for callers that
|
|
228
|
+
* check it, and is no longer returned.
|
|
246
229
|
*
|
|
247
230
|
* @param expression the expression to check
|
|
248
|
-
* @
|
|
249
|
-
*
|
|
231
|
+
* @param contextKeys the names the expression may reference, when known; omitted, free
|
|
232
|
+
* identifiers are left for evaluation time (see {@link ScreenExpression})
|
|
233
|
+
* @returns `Valid: true` when it parses; `Valid: false` with `Error` when it does not
|
|
250
234
|
*/
|
|
251
|
-
ValidateSyntax(expression: string): {
|
|
235
|
+
ValidateSyntax(expression: string, contextKeys?: Iterable<string>): {
|
|
252
236
|
Valid: boolean;
|
|
253
237
|
Error?: string;
|
|
254
238
|
Undecidable?: boolean;
|
|
255
239
|
};
|
|
256
240
|
/** @deprecated Use {@link ValidateSyntax}. */
|
|
257
|
-
validateSyntax(expression: string): {
|
|
241
|
+
validateSyntax(expression: string, contextKeys?: Iterable<string>): {
|
|
258
242
|
Valid: boolean;
|
|
259
243
|
Error?: string;
|
|
260
244
|
Undecidable?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SafeExpressionEvaluator.d.ts","sourceRoot":"","sources":["../src/SafeExpressionEvaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAuBH
|
|
1
|
+
{"version":3,"file":"SafeExpressionEvaluator.d.ts","sourceRoot":"","sources":["../src/SafeExpressionEvaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAuBH,0GAA0G;AAC1G,MAAM,WAAW,wBAAwB;IACrC,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAA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