@n8n/expression-runtime 0.14.0 → 0.14.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.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * In-isolate `$jmespath` / `$jmesPath` implementation.
3
+ *
4
+ * Mirrors the host-side wrapper in `packages/workflow/src/workflow-data-proxy.ts`
5
+ * so that expressions resolve `$jmespath` from the in-isolate runtime via
6
+ * Tournament's polyfill, instead of falling through to the bridge's
7
+ * `callFunctionAtPath` channel. This shrinks the host-callable surface
8
+ * exposed by the data object.
9
+ *
10
+ * Behavioural parity with the host wrapper:
11
+ * - Throws `ExpressionError` (same name) when args are wrong.
12
+ * - Rejects queries that contain unsafe property tokens.
13
+ * - Spreads non-array, non-null objects to drop proxies at the top level.
14
+ *
15
+ * Note on lazy proxies: when `data` is a lazy proxy (e.g. `$json`), each
16
+ * property access during `jmespath.search` triggers a synchronous host
17
+ * roundtrip via `getValueAtPath`. Functional but slow for deep traversals.
18
+ * Performance optimisation (e.g. bulk pre-fetch of the queried subtree) is
19
+ * a follow-up.
20
+ */
21
+ export declare function jmesPath(data: unknown, query: string): unknown;
22
+ //# sourceMappingURL=jmespath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jmespath.d.ts","sourceRoot":"","sources":["../../../src/runtime/jmespath.ts"],"names":[],"mappings":"AAmCA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAoB9D"}
@@ -0,0 +1,66 @@
1
+ import * as jmespath from 'jmespath';
2
+ import { ExpressionError } from './safe-globals';
3
+ const unsafeJmespathProperties = [
4
+ '__proto__',
5
+ 'prototype',
6
+ 'constructor',
7
+ 'getPrototypeOf',
8
+ 'setPrototypeOf',
9
+ 'getOwnPropertyDescriptor',
10
+ 'getOwnPropertyDescriptors',
11
+ 'defineProperty',
12
+ 'defineProperties',
13
+ 'mainModule',
14
+ 'binding',
15
+ '_linkedBinding',
16
+ '_load',
17
+ 'prepareStackTrace',
18
+ '__lookupGetter__',
19
+ '__lookupSetter__',
20
+ '__defineGetter__',
21
+ '__defineSetter__',
22
+ 'caller',
23
+ 'arguments',
24
+ 'getBuiltinModule',
25
+ 'dlopen',
26
+ 'execve',
27
+ 'loadEnvFile',
28
+ ];
29
+ const unsafeJmespathPropertyPattern = new RegExp(`\\b(?:${unsafeJmespathProperties.map((p) => p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')})\\b`);
30
+ /**
31
+ * In-isolate `$jmespath` / `$jmesPath` implementation.
32
+ *
33
+ * Mirrors the host-side wrapper in `packages/workflow/src/workflow-data-proxy.ts`
34
+ * so that expressions resolve `$jmespath` from the in-isolate runtime via
35
+ * Tournament's polyfill, instead of falling through to the bridge's
36
+ * `callFunctionAtPath` channel. This shrinks the host-callable surface
37
+ * exposed by the data object.
38
+ *
39
+ * Behavioural parity with the host wrapper:
40
+ * - Throws `ExpressionError` (same name) when args are wrong.
41
+ * - Rejects queries that contain unsafe property tokens.
42
+ * - Spreads non-array, non-null objects to drop proxies at the top level.
43
+ *
44
+ * Note on lazy proxies: when `data` is a lazy proxy (e.g. `$json`), each
45
+ * property access during `jmespath.search` triggers a synchronous host
46
+ * roundtrip via `getValueAtPath`. Functional but slow for deep traversals.
47
+ * Performance optimisation (e.g. bulk pre-fetch of the queried subtree) is
48
+ * a follow-up.
49
+ */
50
+ export function jmesPath(data, query) {
51
+ if (typeof data !== 'object' || typeof query !== 'string') {
52
+ throw new ExpressionError('expected two arguments (Object, string) for this function');
53
+ }
54
+ // jmespath decodes escape sequences inside quoted identifiers, so the
55
+ // token check must run against an unescaped query. Reject any backslash
56
+ // up front to keep the property-name match meaningful.
57
+ if (query.includes('\\') || unsafeJmespathPropertyPattern.test(query)) {
58
+ throw new ExpressionError('Cannot access this property in a jmespath query due to security concerns');
59
+ }
60
+ if (data !== null && !Array.isArray(data) && typeof data === 'object') {
61
+ return jmespath.search({ ...data }, query);
62
+ }
63
+ // Array or null — pass through to jmespath which accepts both
64
+ return jmespath.search(data, query);
65
+ }
66
+ //# sourceMappingURL=jmespath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jmespath.js","sourceRoot":"","sources":["../../../src/runtime/jmespath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,wBAAwB,GAAG;IAChC,WAAW;IACX,WAAW;IACX,aAAa;IACb,gBAAgB;IAChB,gBAAgB;IAChB,0BAA0B;IAC1B,2BAA2B;IAC3B,gBAAgB;IAChB,kBAAkB;IAClB,YAAY;IACZ,SAAS;IACT,gBAAgB;IAChB,OAAO;IACP,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,QAAQ;IACR,WAAW;IACX,kBAAkB;IAClB,QAAQ;IACR,QAAQ;IACR,aAAa;CACb,CAAC;AAEF,MAAM,6BAA6B,GAAG,IAAI,MAAM,CAC/C,SAAS,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CACtG,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAa,EAAE,KAAa;IACpD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3D,MAAM,IAAI,eAAe,CAAC,2DAA2D,CAAC,CAAC;IACxF,CAAC;IAED,sEAAsE;IACtE,wEAAwE;IACxE,uDAAuD;IACvD,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,6BAA6B,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACvE,MAAM,IAAI,eAAe,CACxB,0EAA0E,CAC1E,CAAC;IACH,CAAC;IAED,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACvE,OAAO,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAI,IAAgC,EAAE,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;IAED,8DAA8D;IAC9D,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAa,EAAE,KAAK,CAAC,CAAC;AAC9C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n8n/expression-runtime",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "Secure, isolated expression evaluation runtime for n8n",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -31,8 +31,8 @@
31
31
  "md5": "2.3.0",
32
32
  "title-case": "3.0.3",
33
33
  "transliteration": "2.3.5",
34
- "@n8n/errors": "0.8.0",
35
- "@n8n/tournament": "1.2.0"
34
+ "@n8n/tournament": "1.2.0",
35
+ "@n8n/errors": "0.8.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/lodash": "4.17.17",