@n8n/expression-runtime 0.3.0 → 0.5.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/README.md +3 -3
- package/dist/bundle/runtime.esm.js +17 -17
- package/dist/bundle/runtime.esm.js.map +4 -4
- package/dist/bundle/runtime.iife.js +17 -17
- package/dist/bundle/runtime.iife.js.map +4 -4
- package/dist/{bridge → cjs/bridge}/isolated-vm-bridge.d.ts +3 -2
- package/dist/cjs/bridge/isolated-vm-bridge.d.ts.map +1 -0
- package/dist/cjs/bridge/isolated-vm-bridge.js +512 -0
- package/dist/cjs/bridge/isolated-vm-bridge.js.map +1 -0
- package/dist/cjs/build.tsbuildinfo +1 -0
- package/dist/cjs/evaluator/expression-evaluator.d.ts +23 -0
- package/dist/cjs/evaluator/expression-evaluator.d.ts.map +1 -0
- package/dist/cjs/evaluator/expression-evaluator.js +89 -0
- package/dist/cjs/evaluator/expression-evaluator.js.map +1 -0
- package/dist/cjs/extensions/array-extensions.d.ts.map +1 -0
- package/dist/cjs/extensions/array-extensions.js +637 -0
- package/dist/cjs/extensions/array-extensions.js.map +1 -0
- package/dist/cjs/extensions/boolean-extensions.d.ts.map +1 -0
- package/dist/cjs/extensions/boolean-extensions.js +49 -0
- package/dist/cjs/extensions/boolean-extensions.js.map +1 -0
- package/dist/cjs/extensions/date-extensions.d.ts.map +1 -0
- package/dist/cjs/extensions/date-extensions.js +528 -0
- package/dist/cjs/extensions/date-extensions.js.map +1 -0
- package/dist/cjs/extensions/expression-extension-error.d.ts.map +1 -0
- package/dist/cjs/extensions/expression-extension-error.js +25 -0
- package/dist/cjs/extensions/expression-extension-error.js.map +1 -0
- package/dist/cjs/extensions/extend.d.ts.map +1 -0
- package/dist/cjs/extensions/extend.js +149 -0
- package/dist/cjs/extensions/extend.js.map +1 -0
- package/dist/cjs/extensions/extensions.d.ts.map +1 -0
- package/dist/cjs/extensions/extensions.js +13 -0
- package/dist/cjs/extensions/extensions.js.map +1 -0
- package/dist/cjs/extensions/function-extensions.d.ts +28 -0
- package/dist/cjs/extensions/function-extensions.d.ts.map +1 -0
- package/dist/cjs/extensions/function-extensions.js +92 -0
- package/dist/cjs/extensions/function-extensions.js.map +1 -0
- package/dist/cjs/extensions/number-extensions.d.ts.map +1 -0
- package/dist/cjs/extensions/number-extensions.js +244 -0
- package/dist/cjs/extensions/number-extensions.js.map +1 -0
- package/dist/cjs/extensions/object-extensions.d.ts.map +1 -0
- package/dist/cjs/extensions/object-extensions.js +305 -0
- package/dist/cjs/extensions/object-extensions.js.map +1 -0
- package/dist/cjs/extensions/string-extensions.d.ts.map +1 -0
- package/dist/cjs/extensions/string-extensions.js +790 -0
- package/dist/cjs/extensions/string-extensions.js.map +1 -0
- package/dist/cjs/extensions/utils.d.ts.map +1 -0
- package/dist/cjs/extensions/utils.js +42 -0
- package/dist/cjs/extensions/utils.js.map +1 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/runtime/index.d.ts +34 -0
- package/dist/cjs/runtime/index.d.ts.map +1 -0
- package/dist/cjs/runtime/index.js +39 -0
- package/dist/cjs/runtime/index.js.map +1 -0
- package/dist/{runtime → cjs/runtime}/lazy-proxy.d.ts +4 -0
- package/dist/cjs/runtime/lazy-proxy.d.ts.map +1 -0
- package/dist/cjs/runtime/lazy-proxy.js +179 -0
- package/dist/cjs/runtime/lazy-proxy.js.map +1 -0
- package/dist/{runtime → cjs/runtime}/reset.d.ts +1 -1
- package/dist/cjs/runtime/reset.d.ts.map +1 -0
- package/dist/cjs/runtime/reset.js +157 -0
- package/dist/cjs/runtime/reset.js.map +1 -0
- package/dist/cjs/runtime/safe-globals.d.ts.map +1 -0
- package/dist/cjs/runtime/safe-globals.js +125 -0
- package/dist/cjs/runtime/safe-globals.js.map +1 -0
- package/dist/cjs/runtime/serialize.d.ts +19 -0
- package/dist/cjs/runtime/serialize.d.ts.map +1 -0
- package/dist/cjs/runtime/serialize.js +67 -0
- package/dist/cjs/runtime/serialize.js.map +1 -0
- package/dist/{types → cjs/types}/bridge.d.ts +11 -1
- package/dist/cjs/types/bridge.d.ts.map +1 -0
- package/dist/cjs/types/bridge.js +26 -0
- package/dist/cjs/types/bridge.js.map +1 -0
- package/dist/{types → cjs/types}/evaluator.d.ts +6 -7
- package/dist/cjs/types/evaluator.d.ts.map +1 -0
- package/dist/cjs/types/evaluator.js +47 -0
- package/dist/cjs/types/evaluator.js.map +1 -0
- package/dist/{types → cjs/types}/index.d.ts +3 -2
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/index.js +30 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/runtime.d.ts.map +1 -0
- package/dist/cjs/types/runtime.js +39 -0
- package/dist/cjs/types/runtime.js.map +1 -0
- package/dist/esm/bridge/isolated-vm-bridge.d.ts +133 -0
- package/dist/esm/bridge/isolated-vm-bridge.d.ts.map +1 -0
- package/dist/{bridge → esm/bridge}/isolated-vm-bridge.js +62 -24
- package/dist/esm/bridge/isolated-vm-bridge.js.map +1 -0
- package/dist/esm/build.tsbuildinfo +1 -0
- package/dist/esm/evaluator/expression-evaluator.d.ts +23 -0
- package/dist/esm/evaluator/expression-evaluator.d.ts.map +1 -0
- package/dist/esm/evaluator/expression-evaluator.js +75 -0
- package/dist/esm/evaluator/expression-evaluator.js.map +1 -0
- package/dist/esm/extensions/array-extensions.d.ts +34 -0
- package/dist/esm/extensions/array-extensions.d.ts.map +1 -0
- package/dist/{extensions → esm/extensions}/array-extensions.js +6 -1
- package/dist/esm/extensions/array-extensions.js.map +1 -0
- package/dist/esm/extensions/boolean-extensions.d.ts +6 -0
- package/dist/esm/extensions/boolean-extensions.d.ts.map +1 -0
- package/dist/esm/extensions/boolean-extensions.js.map +1 -0
- package/dist/esm/extensions/date-extensions.d.ts +3 -0
- package/dist/esm/extensions/date-extensions.d.ts.map +1 -0
- package/dist/esm/extensions/date-extensions.js.map +1 -0
- package/dist/esm/extensions/expression-extension-error.d.ts +7 -0
- package/dist/esm/extensions/expression-extension-error.d.ts.map +1 -0
- package/dist/esm/extensions/expression-extension-error.js.map +1 -0
- package/dist/esm/extensions/extend.d.ts +12 -0
- package/dist/esm/extensions/extend.d.ts.map +1 -0
- package/dist/esm/extensions/extend.js.map +1 -0
- package/dist/esm/extensions/extensions.d.ts +43 -0
- package/dist/esm/extensions/extensions.d.ts.map +1 -0
- package/dist/esm/extensions/extensions.js.map +1 -0
- package/dist/esm/extensions/function-extensions.d.ts +28 -0
- package/dist/esm/extensions/function-extensions.d.ts.map +1 -0
- package/dist/esm/extensions/function-extensions.js +79 -0
- package/dist/esm/extensions/function-extensions.js.map +1 -0
- package/dist/esm/extensions/number-extensions.d.ts +27 -0
- package/dist/esm/extensions/number-extensions.d.ts.map +1 -0
- package/dist/{extensions → esm/extensions}/number-extensions.js +10 -1
- package/dist/esm/extensions/number-extensions.js.map +1 -0
- package/dist/esm/extensions/object-extensions.d.ts +46 -0
- package/dist/esm/extensions/object-extensions.d.ts.map +1 -0
- package/dist/{extensions → esm/extensions}/object-extensions.js +9 -1
- package/dist/esm/extensions/object-extensions.js.map +1 -0
- package/dist/esm/extensions/string-extensions.d.ts +38 -0
- package/dist/esm/extensions/string-extensions.d.ts.map +1 -0
- package/dist/{extensions → esm/extensions}/string-extensions.js +41 -4
- package/dist/esm/extensions/string-extensions.js.map +1 -0
- package/dist/esm/extensions/utils.d.ts +4 -0
- package/dist/esm/extensions/utils.d.ts.map +1 -0
- package/dist/esm/extensions/utils.js.map +1 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/runtime/index.d.ts +34 -0
- package/dist/esm/runtime/index.d.ts.map +1 -0
- package/dist/{runtime → esm/runtime}/index.js +5 -1
- package/dist/esm/runtime/index.js.map +1 -0
- package/dist/esm/runtime/lazy-proxy.d.ts +22 -0
- package/dist/esm/runtime/lazy-proxy.d.ts.map +1 -0
- package/dist/{runtime → esm/runtime}/lazy-proxy.js +20 -6
- package/dist/esm/runtime/lazy-proxy.js.map +1 -0
- package/dist/esm/runtime/reset.d.ts +16 -0
- package/dist/esm/runtime/reset.d.ts.map +1 -0
- package/dist/{runtime → esm/runtime}/reset.js +21 -1
- package/dist/esm/runtime/reset.js.map +1 -0
- package/dist/esm/runtime/safe-globals.d.ts +21 -0
- package/dist/esm/runtime/safe-globals.d.ts.map +1 -0
- package/dist/esm/runtime/safe-globals.js.map +1 -0
- package/dist/esm/runtime/serialize.d.ts +19 -0
- package/dist/esm/runtime/serialize.d.ts.map +1 -0
- package/dist/esm/runtime/serialize.js +54 -0
- package/dist/esm/runtime/serialize.js.map +1 -0
- package/dist/esm/types/bridge.d.ts +71 -0
- package/dist/esm/types/bridge.d.ts.map +1 -0
- package/dist/{types → esm/types}/bridge.js +6 -1
- package/dist/esm/types/bridge.js.map +1 -0
- package/dist/esm/types/evaluator.d.ts +196 -0
- package/dist/esm/types/evaluator.d.ts.map +1 -0
- package/dist/esm/types/evaluator.js.map +1 -0
- package/dist/esm/types/index.d.ts +11 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/{types → esm/types}/index.js +1 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/runtime.d.ts +20 -0
- package/dist/esm/types/runtime.d.ts.map +1 -0
- package/dist/esm/types/runtime.js.map +1 -0
- package/package.json +16 -5
- package/dist/bridge/isolated-vm-bridge.d.ts.map +0 -1
- package/dist/bridge/isolated-vm-bridge.js.map +0 -1
- package/dist/build.tsbuildinfo +0 -1
- package/dist/extensions/array-extensions.d.ts.map +0 -1
- package/dist/extensions/array-extensions.js.map +0 -1
- package/dist/extensions/boolean-extensions.d.ts.map +0 -1
- package/dist/extensions/boolean-extensions.js.map +0 -1
- package/dist/extensions/date-extensions.d.ts.map +0 -1
- package/dist/extensions/date-extensions.js.map +0 -1
- package/dist/extensions/expression-extension-error.d.ts.map +0 -1
- package/dist/extensions/expression-extension-error.js.map +0 -1
- package/dist/extensions/extend.d.ts.map +0 -1
- package/dist/extensions/extend.js.map +0 -1
- package/dist/extensions/extensions.d.ts.map +0 -1
- package/dist/extensions/extensions.js.map +0 -1
- package/dist/extensions/number-extensions.d.ts.map +0 -1
- package/dist/extensions/number-extensions.js.map +0 -1
- package/dist/extensions/object-extensions.d.ts.map +0 -1
- package/dist/extensions/object-extensions.js.map +0 -1
- package/dist/extensions/string-extensions.d.ts.map +0 -1
- package/dist/extensions/string-extensions.js.map +0 -1
- package/dist/extensions/utils.d.ts.map +0 -1
- package/dist/extensions/utils.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -17
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/lazy-proxy.d.ts.map +0 -1
- package/dist/runtime/lazy-proxy.js.map +0 -1
- package/dist/runtime/reset.d.ts.map +0 -1
- package/dist/runtime/reset.js.map +0 -1
- package/dist/runtime/safe-globals.d.ts.map +0 -1
- package/dist/runtime/safe-globals.js.map +0 -1
- package/dist/types/bridge.d.ts.map +0 -1
- package/dist/types/bridge.js.map +0 -1
- package/dist/types/evaluator.d.ts.map +0 -1
- package/dist/types/evaluator.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/runtime.d.ts.map +0 -1
- package/dist/types/runtime.js.map +0 -1
- /package/dist/{extensions → cjs/extensions}/array-extensions.d.ts +0 -0
- /package/dist/{extensions → cjs/extensions}/boolean-extensions.d.ts +0 -0
- /package/dist/{extensions → cjs/extensions}/date-extensions.d.ts +0 -0
- /package/dist/{extensions → cjs/extensions}/expression-extension-error.d.ts +0 -0
- /package/dist/{extensions → cjs/extensions}/extend.d.ts +0 -0
- /package/dist/{extensions → cjs/extensions}/extensions.d.ts +0 -0
- /package/dist/{extensions → cjs/extensions}/number-extensions.d.ts +0 -0
- /package/dist/{extensions → cjs/extensions}/object-extensions.d.ts +0 -0
- /package/dist/{extensions → cjs/extensions}/string-extensions.d.ts +0 -0
- /package/dist/{extensions → cjs/extensions}/utils.d.ts +0 -0
- /package/dist/{runtime → cjs/runtime}/safe-globals.d.ts +0 -0
- /package/dist/{types → cjs/types}/runtime.d.ts +0 -0
- /package/dist/{extensions → esm/extensions}/boolean-extensions.js +0 -0
- /package/dist/{extensions → esm/extensions}/date-extensions.js +0 -0
- /package/dist/{extensions → esm/extensions}/expression-extension-error.js +0 -0
- /package/dist/{extensions → esm/extensions}/extend.js +0 -0
- /package/dist/{extensions → esm/extensions}/extensions.js +0 -0
- /package/dist/{extensions → esm/extensions}/utils.js +0 -0
- /package/dist/{runtime → esm/runtime}/safe-globals.js +0 -0
- /package/dist/{types → esm/types}/evaluator.js +0 -0
- /package/dist/{types → esm/types}/runtime.js +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Safe Wrappers for Security-Sensitive Globals
|
|
3
|
+
// ============================================================================
|
|
4
|
+
(function (factory) {
|
|
5
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
6
|
+
var v = factory(require, exports);
|
|
7
|
+
if (v !== undefined) module.exports = v;
|
|
8
|
+
}
|
|
9
|
+
else if (typeof define === "function" && define.amd) {
|
|
10
|
+
define(["require", "exports"], factory);
|
|
11
|
+
}
|
|
12
|
+
})(function (require, exports) {
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ExpressionError = exports.SafeError = exports.SafeObject = void 0;
|
|
16
|
+
exports.__sanitize = __sanitize;
|
|
17
|
+
/**
|
|
18
|
+
* SafeObject - Blocks dangerous Object methods that could lead to RCE
|
|
19
|
+
*
|
|
20
|
+
* Blocked methods:
|
|
21
|
+
* - defineProperty, setPrototypeOf: Prevent prototype pollution
|
|
22
|
+
* - getOwnPropertyDescriptor: Prevent property descriptor manipulation
|
|
23
|
+
* - __defineGetter__, __defineSetter__: Legacy descriptor manipulation
|
|
24
|
+
*/
|
|
25
|
+
exports.SafeObject = new Proxy(Object, {
|
|
26
|
+
get(target, prop) {
|
|
27
|
+
// Block dangerous methods (return undefined)
|
|
28
|
+
const blockedMethods = [
|
|
29
|
+
'defineProperty',
|
|
30
|
+
'defineProperties',
|
|
31
|
+
'setPrototypeOf',
|
|
32
|
+
'getOwnPropertyDescriptor',
|
|
33
|
+
'getOwnPropertyDescriptors',
|
|
34
|
+
'__defineGetter__',
|
|
35
|
+
'__defineSetter__',
|
|
36
|
+
'__lookupGetter__',
|
|
37
|
+
'__lookupSetter__',
|
|
38
|
+
];
|
|
39
|
+
if (blockedMethods.includes(prop)) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
// Block getPrototypeOf by throwing (more secure than returning undefined)
|
|
43
|
+
if (prop === 'getPrototypeOf') {
|
|
44
|
+
throw new Error('Object.getPrototypeOf is not allowed');
|
|
45
|
+
}
|
|
46
|
+
// Allow other Object methods
|
|
47
|
+
const value = target[prop];
|
|
48
|
+
if (typeof value === 'function') {
|
|
49
|
+
// Use arrow function wrapper to preserve 'this' binding
|
|
50
|
+
return (...args) => value.apply(target, args);
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* SafeError - Blocks stack manipulation methods
|
|
57
|
+
*
|
|
58
|
+
* Blocked properties:
|
|
59
|
+
* - stackTraceLimit, captureStackTrace, prepareStackTrace: Prevent stack manipulation attacks
|
|
60
|
+
*/
|
|
61
|
+
exports.SafeError = new Proxy(Error, {
|
|
62
|
+
get(target, prop) {
|
|
63
|
+
// Block stack manipulation (return undefined)
|
|
64
|
+
const blockedProps = ['stackTraceLimit', 'captureStackTrace', 'prepareStackTrace'];
|
|
65
|
+
if (blockedProps.includes(prop)) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
// Block dangerous methods
|
|
69
|
+
const blockedMethods = ['__defineGetter__', '__defineSetter__'];
|
|
70
|
+
if (blockedMethods.includes(prop)) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const value = target[prop];
|
|
74
|
+
if (typeof value === 'function') {
|
|
75
|
+
return (...args) => value.apply(target, args);
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
},
|
|
79
|
+
set(target, prop, value) {
|
|
80
|
+
// Block setting prepareStackTrace
|
|
81
|
+
if (prop === 'prepareStackTrace') {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
target[prop] = value;
|
|
85
|
+
return true;
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
// ============================================================================
|
|
89
|
+
// ExpressionError - used by tournament-generated error handlers
|
|
90
|
+
// ============================================================================
|
|
91
|
+
class ExpressionError extends Error {
|
|
92
|
+
constructor(message) {
|
|
93
|
+
super(message);
|
|
94
|
+
this.name = 'ExpressionError';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.ExpressionError = ExpressionError;
|
|
98
|
+
// ============================================================================
|
|
99
|
+
// Runtime sanitizer for dynamic property access
|
|
100
|
+
// Generated by PrototypeSanitizer: obj[expr] → obj[this.__sanitize(expr)]
|
|
101
|
+
// Must match the blocklist in packages/workflow/src/expression-sandboxing.ts
|
|
102
|
+
// ============================================================================
|
|
103
|
+
const unsafeObjectProperties = new Set([
|
|
104
|
+
'__proto__',
|
|
105
|
+
'prototype',
|
|
106
|
+
'constructor',
|
|
107
|
+
'__defineGetter__',
|
|
108
|
+
'__defineSetter__',
|
|
109
|
+
'__lookupGetter__',
|
|
110
|
+
'__lookupSetter__',
|
|
111
|
+
'toString',
|
|
112
|
+
'valueOf',
|
|
113
|
+
'toLocaleString',
|
|
114
|
+
'hasOwnProperty',
|
|
115
|
+
'isPrototypeOf',
|
|
116
|
+
'propertyIsEnumerable',
|
|
117
|
+
]);
|
|
118
|
+
function __sanitize(value) {
|
|
119
|
+
if (typeof value === 'string' && unsafeObjectProperties.has(value)) {
|
|
120
|
+
throw new ExpressionError(`Cannot access "${value}" due to security concerns`);
|
|
121
|
+
}
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=safe-globals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-globals.js","sourceRoot":"","sources":["../../../src/runtime/safe-globals.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,+CAA+C;AAC/C,+EAA+E;;;;;;;;;;;;;IAiH/E,gCAKC;IApHD;;;;;;;OAOG;IACU,QAAA,UAAU,GAAG,IAAI,KAAK,CAAC,MAAM,EAAE;QAC3C,GAAG,CAAC,MAAM,EAAE,IAAI;YACf,6CAA6C;YAC7C,MAAM,cAAc,GAAG;gBACtB,gBAAgB;gBAChB,kBAAkB;gBAClB,gBAAgB;gBAChB,0BAA0B;gBAC1B,2BAA2B;gBAC3B,kBAAkB;gBAClB,kBAAkB;gBAClB,kBAAkB;gBAClB,kBAAkB;aAClB,CAAC;YAEF,IAAI,cAAc,CAAC,QAAQ,CAAC,IAAc,CAAC,EAAE,CAAC;gBAC7C,OAAO,SAAS,CAAC;YAClB,CAAC;YAED,0EAA0E;YAC1E,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;YACzD,CAAC;YAED,6BAA6B;YAC7B,MAAM,KAAK,GAAI,MAAc,CAAC,IAAI,CAAC,CAAC;YACpC,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBACjC,wDAAwD;gBACxD,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAA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KACD;IALD,0CAKC;IAED,+EAA+E;IAC/E,gDAAgD;IAChD,0EAA0E;IAC1E,6EAA6E;IAC7E,+EAA+E;IAE/E,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;QACtC,WAAW;QACX,WAAW;QACX,aAAa;QACb,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,UAAU;QACV,SAAS;QACT,gBAAgB;QAChB,gBAAgB;QAChB,eAAe;QACf,sBAAsB;KACtB,CAAC,CAAC;IAEH,SAAgB,UAAU,CAAC,KAAc;QACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACpE,MAAM,IAAI,eAAe,CAAC,kBAAkB,KAAK,4BAA4B,CAAC,CAAC;QAChF,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prepare a value for transfer across the V8 isolate boundary.
|
|
3
|
+
*
|
|
4
|
+
* isolated-vm's `copy: true` uses structured clone, which strips prototypes
|
|
5
|
+
* from non-standard types. Luxon DateTime/Duration/Interval lose their class
|
|
6
|
+
* identity and arrive on the host as plain objects.
|
|
7
|
+
*
|
|
8
|
+
* This function recursively walks a value and converts types that don't
|
|
9
|
+
* survive structured clone into their string representations. It runs
|
|
10
|
+
* inside the isolate before the result is transferred.
|
|
11
|
+
*
|
|
12
|
+
* Note: JS Date objects survive structured clone with prototype intact
|
|
13
|
+
* (Date is a standard structured-cloneable type) and are not converted.
|
|
14
|
+
*
|
|
15
|
+
* Circular references are not handled — expression results should not
|
|
16
|
+
* contain cycles.
|
|
17
|
+
*/
|
|
18
|
+
export declare function __prepareForTransfer(value: unknown): unknown;
|
|
19
|
+
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/runtime/serialize.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA2B5D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "luxon"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.__prepareForTransfer = __prepareForTransfer;
|
|
13
|
+
const luxon_1 = require("luxon");
|
|
14
|
+
/** Type guard: plain object with Object.prototype or null prototype. */
|
|
15
|
+
function isPlainObject(value) {
|
|
16
|
+
const proto = Object.getPrototypeOf(value);
|
|
17
|
+
return proto === Object.prototype || proto === null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Prepare a value for transfer across the V8 isolate boundary.
|
|
21
|
+
*
|
|
22
|
+
* isolated-vm's `copy: true` uses structured clone, which strips prototypes
|
|
23
|
+
* from non-standard types. Luxon DateTime/Duration/Interval lose their class
|
|
24
|
+
* identity and arrive on the host as plain objects.
|
|
25
|
+
*
|
|
26
|
+
* This function recursively walks a value and converts types that don't
|
|
27
|
+
* survive structured clone into their string representations. It runs
|
|
28
|
+
* inside the isolate before the result is transferred.
|
|
29
|
+
*
|
|
30
|
+
* Note: JS Date objects survive structured clone with prototype intact
|
|
31
|
+
* (Date is a standard structured-cloneable type) and are not converted.
|
|
32
|
+
*
|
|
33
|
+
* Circular references are not handled — expression results should not
|
|
34
|
+
* contain cycles.
|
|
35
|
+
*/
|
|
36
|
+
function __prepareForTransfer(value) {
|
|
37
|
+
if (value === null || value === undefined)
|
|
38
|
+
return value;
|
|
39
|
+
if (typeof value !== 'object')
|
|
40
|
+
return value;
|
|
41
|
+
// Luxon DateTime -> ISO string (toISO() returns null for invalid DateTime)
|
|
42
|
+
if (luxon_1.DateTime.isDateTime(value))
|
|
43
|
+
return value.toISO() ?? null;
|
|
44
|
+
// Luxon Duration -> ISO string (toISO() returns null for invalid Duration)
|
|
45
|
+
if (luxon_1.Duration.isDuration(value))
|
|
46
|
+
return value.toISO() ?? null;
|
|
47
|
+
// Luxon Interval -> ISO string (toISO() returns "Invalid Interval" for invalid Interval)
|
|
48
|
+
if (luxon_1.Interval.isInterval(value)) {
|
|
49
|
+
const iso = value.toISO();
|
|
50
|
+
return iso === 'Invalid Interval' ? null : iso;
|
|
51
|
+
}
|
|
52
|
+
// Array — walk elements
|
|
53
|
+
if (Array.isArray(value))
|
|
54
|
+
return value.map(__prepareForTransfer);
|
|
55
|
+
// Only walk plain objects — structured-cloneable types like Date, Map, Set,
|
|
56
|
+
// RegExp, Error, typed arrays survive copy:true with prototypes intact.
|
|
57
|
+
if (!isPlainObject(value))
|
|
58
|
+
return value;
|
|
59
|
+
// Plain object — walk values
|
|
60
|
+
const result = {};
|
|
61
|
+
for (const key of Object.keys(value)) {
|
|
62
|
+
result[key] = __prepareForTransfer(value[key]);
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=serialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../src/runtime/serialize.ts"],"names":[],"mappings":";;;;;;;;;;;IAyBA,oDA2BC;IApDD,iCAAqD;IAErD,wEAAwE;IACxE,SAAS,aAAa,CAAC,KAAa;QACnC,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAC3C,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;IACrD,CAAC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vm module (Slice 1).
|
|
25
25
|
* Will be async for isolated-vm (Slice 2).
|
|
26
26
|
*/
|
|
27
|
-
execute(code: string, data: Record<string, unknown
|
|
27
|
+
execute(code: string, data: Record<string, unknown>, options?: ExecuteOptions): unknown;
|
|
28
28
|
/**
|
|
29
29
|
* Dispose of the isolated context and free resources.
|
|
30
30
|
* After disposal, the bridge cannot be used again.
|
|
@@ -58,4 +58,14 @@ export interface BridgeConfig {
|
|
|
58
58
|
*/
|
|
59
59
|
debug?: boolean;
|
|
60
60
|
}
|
|
61
|
+
/** Default values for BridgeConfig. Bridge implementations should use this as their baseline. */
|
|
62
|
+
export declare const DEFAULT_BRIDGE_CONFIG: Required<BridgeConfig>;
|
|
63
|
+
/** Options for a single execute() call. */
|
|
64
|
+
export interface ExecuteOptions {
|
|
65
|
+
/**
|
|
66
|
+
* IANA timezone for this evaluation (e.g., 'America/New_York').
|
|
67
|
+
* Sets luxon Settings.defaultZone inside the isolate before execution.
|
|
68
|
+
*/
|
|
69
|
+
timezone?: string;
|
|
70
|
+
}
|
|
61
71
|
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../../src/types/bridge.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC7B;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC;IAExF;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,iGAAiG;AACjG,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,YAAY,CAIxD,CAAC;AAEF,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC9B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Phase 1.1: Bridge Interface (CORE - IMPLEMENT FIRST)
|
|
3
|
+
//
|
|
4
|
+
// This is the main interface all environments must implement.
|
|
5
|
+
// Start here for CLI/backend (IsolatedVmBridge) or frontend (WebWorkerBridge).
|
|
6
|
+
// ============================================================================
|
|
7
|
+
(function (factory) {
|
|
8
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
9
|
+
var v = factory(require, exports);
|
|
10
|
+
if (v !== undefined) module.exports = v;
|
|
11
|
+
}
|
|
12
|
+
else if (typeof define === "function" && define.amd) {
|
|
13
|
+
define(["require", "exports"], factory);
|
|
14
|
+
}
|
|
15
|
+
})(function (require, exports) {
|
|
16
|
+
"use strict";
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DEFAULT_BRIDGE_CONFIG = void 0;
|
|
19
|
+
/** Default values for BridgeConfig. Bridge implementations should use this as their baseline. */
|
|
20
|
+
exports.DEFAULT_BRIDGE_CONFIG = {
|
|
21
|
+
memoryLimit: 128,
|
|
22
|
+
timeout: 5000,
|
|
23
|
+
debug: false,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../src/types/bridge.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,uDAAuD;AACvD,EAAE;AACF,8DAA8D;AAC9D,+EAA+E;AAC/E,+EAA+E;;;;;;;;;;;;;IAqE/E,iGAAiG;IACpF,QAAA,qBAAqB,GAA2B;QAC5D,WAAW,EAAE,GAAG;QAChB,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,KAAK;KACZ,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
+
import type { TournamentHooks } from '@n8n/tournament';
|
|
1
2
|
import type { RuntimeBridge } from './bridge';
|
|
2
|
-
export interface TournamentHooks {
|
|
3
|
-
before?: Array<(ast: unknown) => unknown>;
|
|
4
|
-
after?: Array<(ast: unknown) => unknown>;
|
|
5
|
-
}
|
|
6
3
|
/**
|
|
7
4
|
* Configuration for ExpressionEvaluator.
|
|
8
5
|
*
|
|
@@ -64,9 +61,6 @@ export interface IExpressionEvaluator {
|
|
|
64
61
|
* Later: Will implement deep lazy proxy for field-level data fetching.
|
|
65
62
|
*/
|
|
66
63
|
export type WorkflowData = Record<string, unknown>;
|
|
67
|
-
/**
|
|
68
|
-
* Options for evaluate().
|
|
69
|
-
*/
|
|
70
64
|
/**
|
|
71
65
|
* Options for evaluate().
|
|
72
66
|
*
|
|
@@ -78,6 +72,11 @@ export interface EvaluateOptions {
|
|
|
78
72
|
* Overrides the bridge's default timeout.
|
|
79
73
|
*/
|
|
80
74
|
timeout?: number;
|
|
75
|
+
/**
|
|
76
|
+
* IANA timezone for this evaluation (e.g., 'America/New_York').
|
|
77
|
+
* Sets luxon Settings.defaultZone inside the isolate before execution.
|
|
78
|
+
*/
|
|
79
|
+
timezone?: string;
|
|
81
80
|
}
|
|
82
81
|
/**
|
|
83
82
|
* Observability provider interface.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../../src/types/evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,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,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAChE;AASD;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IAGjC,OAAO,EAAE;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB;gBAND,OAAO,EAAE,MAAM,EACR,OAAO,EAAE;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB;CAKF;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,eAAe;CAAG;AACxD,qBAAa,YAAa,SAAQ,eAAe;CAAG;AACpD,qBAAa,sBAAuB,SAAQ,eAAe;CAAG;AAC9D,qBAAa,WAAY,SAAQ,eAAe;CAAG"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SyntaxError = exports.SecurityViolationError = exports.TimeoutError = exports.MemoryLimitError = exports.ExpressionError = void 0;
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Phase 1.4: Error Handling (IMPLEMENT WITH EVALUATOR)
|
|
15
|
+
//
|
|
16
|
+
// These error types provide structured error information.
|
|
17
|
+
// Start with basic Error, add these types in Phase 1.4.
|
|
18
|
+
// ============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Expression evaluation error.
|
|
21
|
+
*/
|
|
22
|
+
class ExpressionError extends Error {
|
|
23
|
+
context;
|
|
24
|
+
constructor(message, context) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.context = context;
|
|
27
|
+
this.name = 'ExpressionError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ExpressionError = ExpressionError;
|
|
31
|
+
/**
|
|
32
|
+
* Specific error types.
|
|
33
|
+
*/
|
|
34
|
+
class MemoryLimitError extends ExpressionError {
|
|
35
|
+
}
|
|
36
|
+
exports.MemoryLimitError = MemoryLimitError;
|
|
37
|
+
class TimeoutError extends ExpressionError {
|
|
38
|
+
}
|
|
39
|
+
exports.TimeoutError = TimeoutError;
|
|
40
|
+
class SecurityViolationError extends ExpressionError {
|
|
41
|
+
}
|
|
42
|
+
exports.SecurityViolationError = SecurityViolationError;
|
|
43
|
+
class SyntaxError extends ExpressionError {
|
|
44
|
+
}
|
|
45
|
+
exports.SyntaxError = SyntaxError;
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../../src/types/evaluator.ts"],"names":[],"mappings":";;;;;;;;;;;;IAiNA,+EAA+E;IAC/E,uDAAuD;IACvD,EAAE;IACF,0DAA0D;IAC1D,wDAAwD;IACxD,+EAA+E;IAE/E;;OAEG;IACH,MAAa,eAAgB,SAAQ,KAAK;QAGjC;QAFR,YACC,OAAe,EACR,OAKN;YAED,KAAK,CAAC,OAAO,CAAC,CAAC;YAPR,YAAO,GAAP,OAAO,CAKb;YAGD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC/B,CAAC;KACD;IAbD,0CAaC;IAED;;OAEG;IACH,MAAa,gBAAiB,SAAQ,eAAe;KAAG;IAAxD,4CAAwD;IACxD,MAAa,YAAa,SAAQ,eAAe;KAAG;IAApD,oCAAoD;IACpD,MAAa,sBAAuB,SAAQ,eAAe;KAAG;IAA9D,wDAA8D;IAC9D,MAAa,WAAY,SAAQ,eAAe;KAAG;IAAnD,kCAAmD"}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This module exports all TypeScript interfaces and types for the expression runtime.
|
|
5
5
|
*/
|
|
6
|
-
export type { RuntimeBridge, BridgeConfig } from './bridge';
|
|
6
|
+
export type { RuntimeBridge, BridgeConfig, ExecuteOptions } from './bridge';
|
|
7
|
+
export { DEFAULT_BRIDGE_CONFIG } from './bridge';
|
|
7
8
|
export { RuntimeError } from './runtime';
|
|
8
|
-
export type { EvaluatorConfig, IExpressionEvaluator, WorkflowData, EvaluateOptions, ObservabilityProvider, MetricsAPI, TracesAPI, Span, LogsAPI,
|
|
9
|
+
export type { EvaluatorConfig, IExpressionEvaluator, WorkflowData, EvaluateOptions, ObservabilityProvider, MetricsAPI, TracesAPI, Span, LogsAPI, } from './evaluator';
|
|
9
10
|
export { ExpressionError, MemoryLimitError, TimeoutError, SecurityViolationError, SyntaxError, } from './evaluator';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,YAAY,EACX,eAAe,EACf,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,SAAS,EACT,IAAI,EACJ,OAAO,GACP,MAAM,aAAa,CAAC;AAErB,OAAO,EACN,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACtB,WAAW,GACX,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expression Runtime Types
|
|
3
|
+
*
|
|
4
|
+
* This module exports all TypeScript interfaces and types for the expression runtime.
|
|
5
|
+
*/
|
|
6
|
+
(function (factory) {
|
|
7
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
8
|
+
var v = factory(require, exports);
|
|
9
|
+
if (v !== undefined) module.exports = v;
|
|
10
|
+
}
|
|
11
|
+
else if (typeof define === "function" && define.amd) {
|
|
12
|
+
define(["require", "exports", "./bridge", "./runtime", "./evaluator"], factory);
|
|
13
|
+
}
|
|
14
|
+
})(function (require, exports) {
|
|
15
|
+
"use strict";
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.SyntaxError = exports.SecurityViolationError = exports.TimeoutError = exports.MemoryLimitError = exports.ExpressionError = exports.RuntimeError = exports.DEFAULT_BRIDGE_CONFIG = void 0;
|
|
18
|
+
var bridge_1 = require("./bridge");
|
|
19
|
+
Object.defineProperty(exports, "DEFAULT_BRIDGE_CONFIG", { enumerable: true, get: function () { return bridge_1.DEFAULT_BRIDGE_CONFIG; } });
|
|
20
|
+
// Runtime types
|
|
21
|
+
var runtime_1 = require("./runtime");
|
|
22
|
+
Object.defineProperty(exports, "RuntimeError", { enumerable: true, get: function () { return runtime_1.RuntimeError; } });
|
|
23
|
+
var evaluator_1 = require("./evaluator");
|
|
24
|
+
Object.defineProperty(exports, "ExpressionError", { enumerable: true, get: function () { return evaluator_1.ExpressionError; } });
|
|
25
|
+
Object.defineProperty(exports, "MemoryLimitError", { enumerable: true, get: function () { return evaluator_1.MemoryLimitError; } });
|
|
26
|
+
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return evaluator_1.TimeoutError; } });
|
|
27
|
+
Object.defineProperty(exports, "SecurityViolationError", { enumerable: true, get: function () { return evaluator_1.SecurityViolationError; } });
|
|
28
|
+
Object.defineProperty(exports, "SyntaxError", { enumerable: true, get: function () { return evaluator_1.SyntaxError; } });
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;;;;;IAIH,mCAAiD;IAAxC,+GAAA,qBAAqB,OAAA;IAE9B,gBAAgB;IAChB,qCAAyC;IAAhC,uGAAA,YAAY,OAAA;IAerB,yCAMqB;IALpB,4GAAA,eAAe,OAAA;IACf,6GAAA,gBAAgB,OAAA;IAChB,yGAAA,YAAY,OAAA;IACZ,mHAAA,sBAAsB,OAAA;IACtB,wGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/types/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAa,SAAQ,KAAK;IAG9B,IAAI,EAAE,MAAM;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAFxC,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAKzC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RuntimeError = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Runtime error thrown inside isolated context.
|
|
15
|
+
*
|
|
16
|
+
* These errors are thrown by the runtime code when something goes wrong during
|
|
17
|
+
* expression evaluation. The bridge must catch these and translate them to the
|
|
18
|
+
* appropriate ExpressionError subclass (see evaluator.ts).
|
|
19
|
+
*
|
|
20
|
+
* Translation mapping:
|
|
21
|
+
* - code: 'MEMORY_LIMIT' → MemoryLimitError
|
|
22
|
+
* - code: 'TIMEOUT' → TimeoutError
|
|
23
|
+
* - code: 'SECURITY_VIOLATION' → SecurityViolationError
|
|
24
|
+
* - code: 'SYNTAX_ERROR' → SyntaxError
|
|
25
|
+
* - other → ExpressionError
|
|
26
|
+
*/
|
|
27
|
+
class RuntimeError extends Error {
|
|
28
|
+
code;
|
|
29
|
+
details;
|
|
30
|
+
constructor(message, code, details) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.code = code;
|
|
33
|
+
this.details = details;
|
|
34
|
+
this.name = 'RuntimeError';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.RuntimeError = RuntimeError;
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/types/runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA;;;;;;;;;;;;;OAaG;IACH,MAAa,YAAa,SAAQ,KAAK;QAG9B;QACA;QAHR,YACC,OAAe,EACR,IAAY,EACZ,OAAiC;YAExC,KAAK,CAAC,OAAO,CAAC,CAAC;YAHR,SAAI,GAAJ,IAAI,CAAQ;YACZ,YAAO,GAAP,OAAO,CAA0B;YAGxC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC5B,CAAC;KACD;IATD,oCASC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { RuntimeBridge, BridgeConfig, ExecuteOptions } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* IsolatedVmBridge - Runtime bridge using isolated-vm for secure expression evaluation.
|
|
4
|
+
*
|
|
5
|
+
* This bridge creates a V8 isolate with:
|
|
6
|
+
* - Hard memory limit (128MB default)
|
|
7
|
+
* - No access to Node.js APIs
|
|
8
|
+
* - Timeout enforcement
|
|
9
|
+
* - Complete isolation from host process
|
|
10
|
+
*
|
|
11
|
+
* Context reuse pattern: Create isolate/context once, reset state between evaluations.
|
|
12
|
+
*/
|
|
13
|
+
export declare class IsolatedVmBridge implements RuntimeBridge {
|
|
14
|
+
private isolate;
|
|
15
|
+
private context?;
|
|
16
|
+
private initialized;
|
|
17
|
+
private disposed;
|
|
18
|
+
private config;
|
|
19
|
+
private scriptCache;
|
|
20
|
+
private valueAtPathRef?;
|
|
21
|
+
private arrayElementRef?;
|
|
22
|
+
private callFunctionRef?;
|
|
23
|
+
private resetDataProxiesRef?;
|
|
24
|
+
constructor(config?: BridgeConfig);
|
|
25
|
+
/**
|
|
26
|
+
* Initialize the isolate and create execution context.
|
|
27
|
+
*
|
|
28
|
+
* Steps:
|
|
29
|
+
* 1. Create context
|
|
30
|
+
* 2. Set up basic globals (global reference)
|
|
31
|
+
* 3. Load runtime bundle (DateTime, extend, proxy system)
|
|
32
|
+
* 4. Verify proxy system
|
|
33
|
+
*
|
|
34
|
+
* Must be called before execute().
|
|
35
|
+
*/
|
|
36
|
+
initialize(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Load runtime bundle into the isolate.
|
|
39
|
+
*
|
|
40
|
+
* The runtime bundle includes:
|
|
41
|
+
* - DateTime, extend, extendOptional (expression engine globals)
|
|
42
|
+
* - SafeObject and SafeError wrappers
|
|
43
|
+
* - createDeepLazyProxy function
|
|
44
|
+
* - __data object initialization
|
|
45
|
+
*
|
|
46
|
+
* @private
|
|
47
|
+
* @throws {Error} If context not initialized or bundle loading fails
|
|
48
|
+
*/
|
|
49
|
+
private loadVendorLibraries;
|
|
50
|
+
/**
|
|
51
|
+
* Verify the proxy system loaded correctly.
|
|
52
|
+
*
|
|
53
|
+
* The proxy system is loaded as part of the runtime bundle in loadVendorLibraries().
|
|
54
|
+
* This method verifies all required components are available.
|
|
55
|
+
*
|
|
56
|
+
* @private
|
|
57
|
+
* @throws {Error} If context not initialized or proxy system verification fails
|
|
58
|
+
*/
|
|
59
|
+
private verifyProxySystem;
|
|
60
|
+
/**
|
|
61
|
+
* Inject the E() error handler into the isolate context.
|
|
62
|
+
*
|
|
63
|
+
* Tournament wraps expressions with try-catch that calls E(error, this).
|
|
64
|
+
* This handler:
|
|
65
|
+
* - Re-throws security violations from __sanitize
|
|
66
|
+
* - Swallows TypeErrors (failed attack attempts return undefined)
|
|
67
|
+
* - Re-throws all other errors
|
|
68
|
+
*
|
|
69
|
+
* @private
|
|
70
|
+
* @throws {Error} If context not initialized
|
|
71
|
+
*/
|
|
72
|
+
private injectErrorHandler;
|
|
73
|
+
/**
|
|
74
|
+
* Reset data proxies in the isolate context.
|
|
75
|
+
*
|
|
76
|
+
* This method should be called before each execute() to:
|
|
77
|
+
* 1. Clear proxy caches from previous evaluations
|
|
78
|
+
* 2. Initialize fresh workflow data references
|
|
79
|
+
* 3. Expose workflow properties to globalThis
|
|
80
|
+
*
|
|
81
|
+
* The reset function runs in the isolate and calls back to the host
|
|
82
|
+
* via ivm.Reference callbacks to fetch workflow data.
|
|
83
|
+
*
|
|
84
|
+
* @private
|
|
85
|
+
* @throws {Error} If context not initialized or reset fails
|
|
86
|
+
*/
|
|
87
|
+
private resetDataProxies;
|
|
88
|
+
/**
|
|
89
|
+
* Register callback functions for cross-isolate communication.
|
|
90
|
+
*
|
|
91
|
+
* Creates three ivm.Reference callbacks that the runtime bundle uses
|
|
92
|
+
* to fetch data from the host process:
|
|
93
|
+
*
|
|
94
|
+
* - __getValueAtPath: Returns metadata or primitive for a property path
|
|
95
|
+
* - __getArrayElement: Returns individual array elements
|
|
96
|
+
* - __callFunctionAtPath: Executes functions in host context
|
|
97
|
+
*
|
|
98
|
+
* These callbacks are called synchronously from isolate proxy traps.
|
|
99
|
+
*
|
|
100
|
+
* @param data - Current workflow data to use for callback responses
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
private registerCallbacks;
|
|
104
|
+
/**
|
|
105
|
+
* Execute JavaScript code in the isolated context.
|
|
106
|
+
*
|
|
107
|
+
* Flow:
|
|
108
|
+
* 1. Register callbacks as ivm.Reference for cross-isolate communication
|
|
109
|
+
* 2. Call resetDataProxies() to initialize workflow data proxies
|
|
110
|
+
* 3. Compile script (with caching for performance)
|
|
111
|
+
* 4. Execute with timeout enforcement
|
|
112
|
+
* 5. Return result (copied from isolate)
|
|
113
|
+
*
|
|
114
|
+
* @param code - JavaScript expression to evaluate
|
|
115
|
+
* @param data - Workflow data (e.g., { $json: {...}, $runIndex: 0 })
|
|
116
|
+
* @returns Result of the expression
|
|
117
|
+
* @throws {Error} If bridge not initialized or execution fails
|
|
118
|
+
*/
|
|
119
|
+
execute(code: string, data: Record<string, unknown>, options?: ExecuteOptions): unknown;
|
|
120
|
+
/**
|
|
121
|
+
* Dispose of the isolate and free resources.
|
|
122
|
+
*
|
|
123
|
+
* After disposal, the bridge cannot be used again.
|
|
124
|
+
*/
|
|
125
|
+
dispose(): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Check if the bridge has been disposed.
|
|
128
|
+
*
|
|
129
|
+
* @returns true if disposed, false otherwise
|
|
130
|
+
*/
|
|
131
|
+
isDisposed(): boolean;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=isolated-vm-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolated-vm-bridge.d.ts","sourceRoot":"","sources":["../../../src/bridge/isolated-vm-bridge.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAwC5E;;;;;;;;;;GAUG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IACrD,OAA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