@secure-exec/core 0.1.0-rc.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/LICENSE +191 -0
- package/README.md +7 -0
- package/dist/bridge/active-handles.d.ts +21 -0
- package/dist/bridge/active-handles.js +60 -0
- package/dist/bridge/child-process.d.ts +90 -0
- package/dist/bridge/child-process.js +606 -0
- package/dist/bridge/fs.d.ts +281 -0
- package/dist/bridge/fs.js +2151 -0
- package/dist/bridge/index.d.ts +10 -0
- package/dist/bridge/index.js +41 -0
- package/dist/bridge/module.d.ts +75 -0
- package/dist/bridge/module.js +308 -0
- package/dist/bridge/network.d.ts +249 -0
- package/dist/bridge/network.js +1416 -0
- package/dist/bridge/os.d.ts +13 -0
- package/dist/bridge/os.js +256 -0
- package/dist/bridge/polyfills.d.ts +2 -0
- package/dist/bridge/polyfills.js +11 -0
- package/dist/bridge/process.d.ts +86 -0
- package/dist/bridge/process.js +938 -0
- package/dist/bridge-setup.d.ts +6 -0
- package/dist/bridge-setup.js +9 -0
- package/dist/bridge.js +11538 -0
- package/dist/esm-compiler.d.ts +14 -0
- package/dist/esm-compiler.js +68 -0
- package/dist/fs-helpers.d.ts +23 -0
- package/dist/fs-helpers.js +41 -0
- package/dist/generated/isolate-runtime.d.ts +19 -0
- package/dist/generated/isolate-runtime.js +21 -0
- package/dist/generated/polyfills.d.ts +82 -0
- package/dist/generated/polyfills.js +82 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +25 -0
- package/dist/isolate-runtime/apply-custom-global-policy.js +54 -0
- package/dist/isolate-runtime/apply-timing-mitigation-freeze.js +44 -0
- package/dist/isolate-runtime/apply-timing-mitigation-off.js +14 -0
- package/dist/isolate-runtime/bridge-attach.js +29 -0
- package/dist/isolate-runtime/bridge-initial-globals.js +246 -0
- package/dist/isolate-runtime/eval-script-result.js +8 -0
- package/dist/isolate-runtime/global-exposure-helpers.js +36 -0
- package/dist/isolate-runtime/init-commonjs-module-globals.js +28 -0
- package/dist/isolate-runtime/override-process-cwd.js +8 -0
- package/dist/isolate-runtime/override-process-env.js +8 -0
- package/dist/isolate-runtime/require-setup.js +650 -0
- package/dist/isolate-runtime/set-commonjs-file-globals.js +36 -0
- package/dist/isolate-runtime/set-stdin-data.js +10 -0
- package/dist/isolate-runtime/setup-dynamic-import.js +64 -0
- package/dist/isolate-runtime/setup-fs-facade.js +48 -0
- package/dist/module-resolver.d.ts +25 -0
- package/dist/module-resolver.js +264 -0
- package/dist/package-bundler.d.ts +36 -0
- package/dist/package-bundler.js +497 -0
- package/dist/python-runtime.d.ts +16 -0
- package/dist/python-runtime.js +45 -0
- package/dist/runtime-driver.d.ts +62 -0
- package/dist/runtime-driver.js +1 -0
- package/dist/runtime.d.ts +31 -0
- package/dist/runtime.js +69 -0
- package/dist/shared/api-types.d.ts +71 -0
- package/dist/shared/api-types.js +1 -0
- package/dist/shared/bridge-contract.d.ts +302 -0
- package/dist/shared/bridge-contract.js +82 -0
- package/dist/shared/console-formatter.d.ts +22 -0
- package/dist/shared/console-formatter.js +157 -0
- package/dist/shared/constants.d.ts +3 -0
- package/dist/shared/constants.js +3 -0
- package/dist/shared/errors.d.ts +16 -0
- package/dist/shared/errors.js +21 -0
- package/dist/shared/esm-utils.d.ts +28 -0
- package/dist/shared/esm-utils.js +97 -0
- package/dist/shared/global-exposure.d.ts +38 -0
- package/dist/shared/global-exposure.js +406 -0
- package/dist/shared/in-memory-fs.d.ts +42 -0
- package/dist/shared/in-memory-fs.js +341 -0
- package/dist/shared/permissions.d.ts +38 -0
- package/dist/shared/permissions.js +283 -0
- package/dist/shared/require-setup.d.ts +6 -0
- package/dist/shared/require-setup.js +9 -0
- package/dist/types.d.ts +206 -0
- package/dist/types.js +1 -0
- package/package.json +107 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type { ChildProcessAccessRequest, CommandExecutor, EnvAccessRequest, FsAccessRequest, NetworkAccessRequest, NetworkAdapter, NetworkServerAddress, NetworkServerListenOptions, NetworkServerRequest, NetworkServerResponse, PermissionCheck, PermissionDecision, Permissions, SpawnedProcess, VirtualDirEntry, VirtualFileSystem, VirtualStat, } from "./types.js";
|
|
2
|
+
export type { DriverRuntimeConfig, NodeRuntimeDriver, NodeRuntimeDriverFactory, PythonRuntimeDriver, PythonRuntimeDriverFactory, ResourceBudgets, RuntimeDriver, RuntimeDriverFactory, RuntimeDriverOptions, SharedRuntimeDriver, SystemDriver, } from "./runtime-driver.js";
|
|
3
|
+
export type { ExecOptions, ExecResult, ExecutionStatus, OSConfig, ProcessConfig, PythonRunOptions, PythonRunResult, RunResult, StdioChannel, StdioEvent, StdioHook, TimingMitigation, } from "./shared/api-types.js";
|
|
4
|
+
export { TIMEOUT_EXIT_CODE, TIMEOUT_ERROR_MESSAGE, } from "./shared/constants.js";
|
|
5
|
+
export { createInMemoryFileSystem, InMemoryFileSystem, } from "./shared/in-memory-fs.js";
|
|
6
|
+
export { allowAll, allowAllChildProcess, allowAllEnv, allowAllFs, allowAllNetwork, createCommandExecutorStub, createFsStub, createNetworkStub, envAccessAllowed, filterEnv, wrapCommandExecutor, wrapFileSystem, wrapNetworkAdapter, } from "./shared/permissions.js";
|
|
7
|
+
export type { SystemError } from "./shared/errors.js";
|
|
8
|
+
export { createEaccesError, createEnosysError, createSystemError, } from "./shared/errors.js";
|
|
9
|
+
export { extractCjsNamedExports, extractDynamicImportSpecifiers, isESM, transformDynamicImport, wrapCJSForESM, wrapCJSForESMWithModulePath, } from "./shared/esm-utils.js";
|
|
10
|
+
export { getRequireSetupCode } from "./shared/require-setup.js";
|
|
11
|
+
export type { ConsoleSerializationBudget } from "./shared/console-formatter.js";
|
|
12
|
+
export { DEFAULT_CONSOLE_SERIALIZATION_BUDGET, formatConsoleArgs, getConsoleSetupCode, safeStringifyConsoleValue, } from "./shared/console-formatter.js";
|
|
13
|
+
export type { BridgeApplyRef, BridgeApplySyncPromiseRef, BridgeApplySyncRef, BridgeGlobalKey, ChildProcessKillBridgeRef, ChildProcessSpawnStartBridgeRef, ChildProcessSpawnSyncBridgeRef, ChildProcessStdinCloseBridgeRef, ChildProcessStdinWriteBridgeRef, CryptoRandomFillBridgeRef, CryptoRandomUuidBridgeRef, DynamicImportBridgeRef, FsChmodBridgeRef, FsChownBridgeRef, FsExistsBridgeRef, FsFacadeBridge, FsLinkBridgeRef, FsLstatBridgeRef, FsMkdirBridgeRef, FsReadDirBridgeRef, FsReadFileBinaryBridgeRef, FsReadFileBridgeRef, FsReadlinkBridgeRef, FsRenameBridgeRef, FsRmdirBridgeRef, FsStatBridgeRef, FsSymlinkBridgeRef, FsTruncateBridgeRef, FsUnlinkBridgeRef, FsUtimesBridgeRef, FsWriteFileBinaryBridgeRef, FsWriteFileBridgeRef, HostBridgeGlobalKey, LoadFileBridgeRef, LoadPolyfillBridgeRef, ModuleCacheBridgeRecord, NetworkDnsLookupRawBridgeRef, NetworkFetchRawBridgeRef, NetworkHttpRequestRawBridgeRef, NetworkHttpServerCloseRawBridgeRef, NetworkHttpServerListenRawBridgeRef, ProcessErrorBridgeRef, ProcessLogBridgeRef, RegisterHandleBridgeFn, RequireFromBridgeFn, ResolveModuleBridgeRef, RuntimeBridgeGlobalKey, ScheduleTimerBridgeRef, UnregisterHandleBridgeFn, ValueOf, } from "./shared/bridge-contract.js";
|
|
14
|
+
export { BRIDGE_GLOBAL_KEY_LIST, HOST_BRIDGE_GLOBAL_KEY_LIST, HOST_BRIDGE_GLOBAL_KEYS, RUNTIME_BRIDGE_GLOBAL_KEY_LIST, RUNTIME_BRIDGE_GLOBAL_KEYS, } from "./shared/bridge-contract.js";
|
|
15
|
+
export type { CustomGlobalClassification, CustomGlobalInventoryEntry, } from "./shared/global-exposure.js";
|
|
16
|
+
export { exposeCustomGlobal, exposeGlobalBinding, exposeMutableRuntimeStateGlobal, HARDENED_NODE_CUSTOM_GLOBALS, ISOLATE_GLOBAL_EXPOSURE_HELPER_SOURCE, MUTABLE_NODE_CUSTOM_GLOBALS, NODE_CUSTOM_GLOBAL_INVENTORY, } from "./shared/global-exposure.js";
|
|
17
|
+
export type { IsolateRuntimeSourceId } from "./generated/isolate-runtime.js";
|
|
18
|
+
export { getIsolateRuntimeSource, ISOLATE_RUNTIME_SOURCES, } from "./generated/isolate-runtime.js";
|
|
19
|
+
export { POLYFILL_CODE_MAP } from "./generated/polyfills.js";
|
|
20
|
+
export { NodeRuntime } from "./runtime.js";
|
|
21
|
+
export type { NodeRuntimeOptions } from "./runtime.js";
|
|
22
|
+
export { PythonRuntime } from "./python-runtime.js";
|
|
23
|
+
export type { PythonRuntimeOptions } from "./python-runtime.js";
|
|
24
|
+
export type { DirEntry, StatInfo } from "./fs-helpers.js";
|
|
25
|
+
export { exists, stat, rename, readDirWithTypes, mkdir } from "./fs-helpers.js";
|
|
26
|
+
export { BUILTIN_NAMED_EXPORTS, normalizeBuiltinSpecifier, getPathDir, } from "./module-resolver.js";
|
|
27
|
+
export { getStaticBuiltinWrapperSource, createBuiltinESMWrapper, getEmptyBuiltinESMWrapper, } from "./esm-compiler.js";
|
|
28
|
+
export type { ResolutionCache } from "./package-bundler.js";
|
|
29
|
+
export { createResolutionCache, resolveModule, loadFile, bundlePackage, } from "./package-bundler.js";
|
|
30
|
+
export { getInitialBridgeGlobalsSetupCode } from "./bridge-setup.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Shared constants.
|
|
2
|
+
export { TIMEOUT_EXIT_CODE, TIMEOUT_ERROR_MESSAGE, } from "./shared/constants.js";
|
|
3
|
+
// Shared utilities.
|
|
4
|
+
export { createInMemoryFileSystem, InMemoryFileSystem, } from "./shared/in-memory-fs.js";
|
|
5
|
+
export { allowAll, allowAllChildProcess, allowAllEnv, allowAllFs, allowAllNetwork, createCommandExecutorStub, createFsStub, createNetworkStub, envAccessAllowed, filterEnv, wrapCommandExecutor, wrapFileSystem, wrapNetworkAdapter, } from "./shared/permissions.js";
|
|
6
|
+
export { createEaccesError, createEnosysError, createSystemError, } from "./shared/errors.js";
|
|
7
|
+
export { extractCjsNamedExports, extractDynamicImportSpecifiers, isESM, transformDynamicImport, wrapCJSForESM, wrapCJSForESMWithModulePath, } from "./shared/esm-utils.js";
|
|
8
|
+
export { getRequireSetupCode } from "./shared/require-setup.js";
|
|
9
|
+
export { DEFAULT_CONSOLE_SERIALIZATION_BUDGET, formatConsoleArgs, getConsoleSetupCode, safeStringifyConsoleValue, } from "./shared/console-formatter.js";
|
|
10
|
+
export { BRIDGE_GLOBAL_KEY_LIST, HOST_BRIDGE_GLOBAL_KEY_LIST, HOST_BRIDGE_GLOBAL_KEYS, RUNTIME_BRIDGE_GLOBAL_KEY_LIST, RUNTIME_BRIDGE_GLOBAL_KEYS, } from "./shared/bridge-contract.js";
|
|
11
|
+
export { exposeCustomGlobal, exposeGlobalBinding, exposeMutableRuntimeStateGlobal, HARDENED_NODE_CUSTOM_GLOBALS, ISOLATE_GLOBAL_EXPOSURE_HELPER_SOURCE, MUTABLE_NODE_CUSTOM_GLOBALS, NODE_CUSTOM_GLOBAL_INVENTORY, } from "./shared/global-exposure.js";
|
|
12
|
+
export { getIsolateRuntimeSource, ISOLATE_RUNTIME_SOURCES, } from "./generated/isolate-runtime.js";
|
|
13
|
+
// Generated polyfills.
|
|
14
|
+
export { POLYFILL_CODE_MAP } from "./generated/polyfills.js";
|
|
15
|
+
// Runtime facades.
|
|
16
|
+
export { NodeRuntime } from "./runtime.js";
|
|
17
|
+
export { PythonRuntime } from "./python-runtime.js";
|
|
18
|
+
export { exists, stat, rename, readDirWithTypes, mkdir } from "./fs-helpers.js";
|
|
19
|
+
// Module resolution.
|
|
20
|
+
export { BUILTIN_NAMED_EXPORTS, normalizeBuiltinSpecifier, getPathDir, } from "./module-resolver.js";
|
|
21
|
+
// ESM compiler.
|
|
22
|
+
export { getStaticBuiltinWrapperSource, createBuiltinESMWrapper, getEmptyBuiltinESMWrapper, } from "./esm-compiler.js";
|
|
23
|
+
export { createResolutionCache, resolveModule, loadFile, bundlePackage, } from "./package-bundler.js";
|
|
24
|
+
// Bridge setup.
|
|
25
|
+
export { getInitialBridgeGlobalsSetupCode } from "./bridge-setup.js";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
// isolate-runtime/src/common/global-access.ts
|
|
4
|
+
function hasOwnGlobal(name) {
|
|
5
|
+
return Object.prototype.hasOwnProperty.call(globalThis, name);
|
|
6
|
+
}
|
|
7
|
+
function getGlobalValue(name) {
|
|
8
|
+
return Reflect.get(globalThis, name);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// isolate-runtime/src/common/global-exposure.ts
|
|
12
|
+
function defineRuntimeGlobalBinding(name, value, mutable) {
|
|
13
|
+
Object.defineProperty(globalThis, name, {
|
|
14
|
+
value,
|
|
15
|
+
writable: mutable,
|
|
16
|
+
configurable: mutable,
|
|
17
|
+
enumerable: true
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function createRuntimeGlobalExposer(mutable) {
|
|
21
|
+
return (name, value) => {
|
|
22
|
+
defineRuntimeGlobalBinding(name, value, mutable);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function getRuntimeExposeCustomGlobal() {
|
|
26
|
+
if (typeof globalThis.__runtimeExposeCustomGlobal === "function") {
|
|
27
|
+
return globalThis.__runtimeExposeCustomGlobal;
|
|
28
|
+
}
|
|
29
|
+
return createRuntimeGlobalExposer(false);
|
|
30
|
+
}
|
|
31
|
+
function getRuntimeExposeMutableGlobal() {
|
|
32
|
+
if (typeof globalThis.__runtimeExposeMutableGlobal === "function") {
|
|
33
|
+
return globalThis.__runtimeExposeMutableGlobal;
|
|
34
|
+
}
|
|
35
|
+
return createRuntimeGlobalExposer(true);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// isolate-runtime/src/inject/apply-custom-global-policy.ts
|
|
39
|
+
var __runtimeExposeCustomGlobal = getRuntimeExposeCustomGlobal();
|
|
40
|
+
var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();
|
|
41
|
+
var __globalPolicy = globalThis.__runtimeCustomGlobalPolicy ?? {};
|
|
42
|
+
var __hardenedGlobals = Array.isArray(__globalPolicy.hardenedGlobals) ? __globalPolicy.hardenedGlobals : [];
|
|
43
|
+
var __mutableGlobals = Array.isArray(__globalPolicy.mutableGlobals) ? __globalPolicy.mutableGlobals : [];
|
|
44
|
+
for (const globalName of __hardenedGlobals) {
|
|
45
|
+
if (hasOwnGlobal(globalName)) {
|
|
46
|
+
__runtimeExposeCustomGlobal(globalName, getGlobalValue(globalName));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
for (const globalName of __mutableGlobals) {
|
|
50
|
+
if (hasOwnGlobal(globalName)) {
|
|
51
|
+
__runtimeExposeMutableGlobal(globalName, getGlobalValue(globalName));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
// isolate-runtime/src/common/global-access.ts
|
|
4
|
+
function setGlobalValue(name, value) {
|
|
5
|
+
Reflect.set(globalThis, name, value);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// isolate-runtime/src/inject/apply-timing-mitigation-freeze.ts
|
|
9
|
+
var __timingConfig = globalThis.__runtimeTimingMitigationConfig ?? {};
|
|
10
|
+
var __frozenTimeMs = typeof __timingConfig.frozenTimeMs === "number" && Number.isFinite(__timingConfig.frozenTimeMs) ? __timingConfig.frozenTimeMs : Date.now();
|
|
11
|
+
var __frozenDateNow = () => __frozenTimeMs;
|
|
12
|
+
try {
|
|
13
|
+
Object.defineProperty(Date, "now", {
|
|
14
|
+
value: __frozenDateNow,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true
|
|
17
|
+
});
|
|
18
|
+
} catch {
|
|
19
|
+
Date.now = __frozenDateNow;
|
|
20
|
+
}
|
|
21
|
+
var __frozenPerformanceNow = () => 0;
|
|
22
|
+
var __performance = globalThis.performance;
|
|
23
|
+
if (typeof __performance !== "undefined" && __performance !== null) {
|
|
24
|
+
try {
|
|
25
|
+
Object.defineProperty(__performance, "now", {
|
|
26
|
+
value: __frozenPerformanceNow,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true
|
|
29
|
+
});
|
|
30
|
+
} catch {
|
|
31
|
+
try {
|
|
32
|
+
Object.assign(__performance, { now: __frozenPerformanceNow });
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
setGlobalValue("performance", {
|
|
38
|
+
now: __frozenPerformanceNow
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (!Reflect.deleteProperty(globalThis, "SharedArrayBuffer")) {
|
|
42
|
+
setGlobalValue("SharedArrayBuffer", void 0);
|
|
43
|
+
}
|
|
44
|
+
})();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
// isolate-runtime/src/common/global-access.ts
|
|
4
|
+
function setGlobalValue(name, value) {
|
|
5
|
+
Reflect.set(globalThis, name, value);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// isolate-runtime/src/inject/apply-timing-mitigation-off.ts
|
|
9
|
+
if (typeof globalThis.performance === "undefined" || globalThis.performance === null) {
|
|
10
|
+
setGlobalValue("performance", {
|
|
11
|
+
now: () => Date.now()
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
})();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
// isolate-runtime/src/common/global-exposure.ts
|
|
4
|
+
function defineRuntimeGlobalBinding(name, value, mutable) {
|
|
5
|
+
Object.defineProperty(globalThis, name, {
|
|
6
|
+
value,
|
|
7
|
+
writable: mutable,
|
|
8
|
+
configurable: mutable,
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function createRuntimeGlobalExposer(mutable) {
|
|
13
|
+
return (name, value) => {
|
|
14
|
+
defineRuntimeGlobalBinding(name, value, mutable);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function getRuntimeExposeCustomGlobal() {
|
|
18
|
+
if (typeof globalThis.__runtimeExposeCustomGlobal === "function") {
|
|
19
|
+
return globalThis.__runtimeExposeCustomGlobal;
|
|
20
|
+
}
|
|
21
|
+
return createRuntimeGlobalExposer(false);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// isolate-runtime/src/inject/bridge-attach.ts
|
|
25
|
+
var __runtimeExposeCustomGlobal = getRuntimeExposeCustomGlobal();
|
|
26
|
+
if (typeof globalThis.bridge !== "undefined") {
|
|
27
|
+
__runtimeExposeCustomGlobal("bridge", globalThis.bridge);
|
|
28
|
+
}
|
|
29
|
+
})();
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
// isolate-runtime/src/common/global-exposure.ts
|
|
4
|
+
function defineRuntimeGlobalBinding(name, value, mutable) {
|
|
5
|
+
Object.defineProperty(globalThis, name, {
|
|
6
|
+
value,
|
|
7
|
+
writable: mutable,
|
|
8
|
+
configurable: mutable,
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function createRuntimeGlobalExposer(mutable) {
|
|
13
|
+
return (name, value) => {
|
|
14
|
+
defineRuntimeGlobalBinding(name, value, mutable);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function getRuntimeExposeMutableGlobal() {
|
|
18
|
+
if (typeof globalThis.__runtimeExposeMutableGlobal === "function") {
|
|
19
|
+
return globalThis.__runtimeExposeMutableGlobal;
|
|
20
|
+
}
|
|
21
|
+
return createRuntimeGlobalExposer(true);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// isolate-runtime/src/inject/bridge-initial-globals.ts
|
|
25
|
+
var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();
|
|
26
|
+
var __bridgeSetupConfig = globalThis.__runtimeBridgeSetupConfig ?? {};
|
|
27
|
+
var __initialCwd = typeof __bridgeSetupConfig.initialCwd === "string" ? __bridgeSetupConfig.initialCwd : "/";
|
|
28
|
+
var __jsonPayloadLimitBytes = typeof __bridgeSetupConfig.jsonPayloadLimitBytes === "number" && Number.isFinite(__bridgeSetupConfig.jsonPayloadLimitBytes) ? Math.max(0, Math.floor(__bridgeSetupConfig.jsonPayloadLimitBytes)) : 4 * 1024 * 1024;
|
|
29
|
+
var __payloadLimitErrorCode = typeof __bridgeSetupConfig.payloadLimitErrorCode === "string" && __bridgeSetupConfig.payloadLimitErrorCode.length > 0 ? __bridgeSetupConfig.payloadLimitErrorCode : "ERR_SANDBOX_PAYLOAD_TOO_LARGE";
|
|
30
|
+
function __scEncode(value, seen) {
|
|
31
|
+
if (value === null) return null;
|
|
32
|
+
if (value === void 0) return { t: "undef" };
|
|
33
|
+
if (typeof value === "boolean") return value;
|
|
34
|
+
if (typeof value === "string") return value;
|
|
35
|
+
if (typeof value === "bigint") return { t: "bigint", v: String(value) };
|
|
36
|
+
if (typeof value === "number") {
|
|
37
|
+
if (Object.is(value, -0)) return { t: "-0" };
|
|
38
|
+
if (Number.isNaN(value)) return { t: "nan" };
|
|
39
|
+
if (value === Infinity) return { t: "inf" };
|
|
40
|
+
if (value === -Infinity) return { t: "-inf" };
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
const obj = value;
|
|
44
|
+
if (seen.has(obj)) return { t: "ref", i: seen.get(obj) };
|
|
45
|
+
const idx = seen.size;
|
|
46
|
+
seen.set(obj, idx);
|
|
47
|
+
if (value instanceof Date)
|
|
48
|
+
return { t: "date", v: value.getTime() };
|
|
49
|
+
if (value instanceof RegExp)
|
|
50
|
+
return { t: "regexp", p: value.source, f: value.flags };
|
|
51
|
+
if (value instanceof Map) {
|
|
52
|
+
const entries = [];
|
|
53
|
+
value.forEach((v, k) => {
|
|
54
|
+
entries.push([__scEncode(k, seen), __scEncode(v, seen)]);
|
|
55
|
+
});
|
|
56
|
+
return { t: "map", v: entries };
|
|
57
|
+
}
|
|
58
|
+
if (value instanceof Set) {
|
|
59
|
+
const elems = [];
|
|
60
|
+
value.forEach((v) => {
|
|
61
|
+
elems.push(__scEncode(v, seen));
|
|
62
|
+
});
|
|
63
|
+
return { t: "set", v: elems };
|
|
64
|
+
}
|
|
65
|
+
if (value instanceof ArrayBuffer) {
|
|
66
|
+
return { t: "ab", v: Array.from(new Uint8Array(value)) };
|
|
67
|
+
}
|
|
68
|
+
if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {
|
|
69
|
+
return {
|
|
70
|
+
t: "ta",
|
|
71
|
+
k: value.constructor.name,
|
|
72
|
+
v: Array.from(
|
|
73
|
+
new Uint8Array(value.buffer, value.byteOffset, value.byteLength)
|
|
74
|
+
)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (Array.isArray(value)) {
|
|
78
|
+
return {
|
|
79
|
+
t: "arr",
|
|
80
|
+
v: value.map((v) => __scEncode(v, seen))
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const result = {};
|
|
84
|
+
for (const key of Object.keys(value)) {
|
|
85
|
+
result[key] = __scEncode(
|
|
86
|
+
value[key],
|
|
87
|
+
seen
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
return { t: "obj", v: result };
|
|
91
|
+
}
|
|
92
|
+
function __scDecode(tagged, refs) {
|
|
93
|
+
if (tagged === null) return null;
|
|
94
|
+
if (typeof tagged === "boolean" || typeof tagged === "string" || typeof tagged === "number")
|
|
95
|
+
return tagged;
|
|
96
|
+
const tag = tagged.t;
|
|
97
|
+
if (tag === void 0) return tagged;
|
|
98
|
+
switch (tag) {
|
|
99
|
+
case "undef":
|
|
100
|
+
return void 0;
|
|
101
|
+
case "nan":
|
|
102
|
+
return NaN;
|
|
103
|
+
case "inf":
|
|
104
|
+
return Infinity;
|
|
105
|
+
case "-inf":
|
|
106
|
+
return -Infinity;
|
|
107
|
+
case "-0":
|
|
108
|
+
return -0;
|
|
109
|
+
case "bigint":
|
|
110
|
+
return BigInt(tagged.v);
|
|
111
|
+
case "ref":
|
|
112
|
+
return refs[tagged.i];
|
|
113
|
+
case "date": {
|
|
114
|
+
const d = new Date(tagged.v);
|
|
115
|
+
refs.push(d);
|
|
116
|
+
return d;
|
|
117
|
+
}
|
|
118
|
+
case "regexp": {
|
|
119
|
+
const r = new RegExp(
|
|
120
|
+
tagged.p,
|
|
121
|
+
tagged.f
|
|
122
|
+
);
|
|
123
|
+
refs.push(r);
|
|
124
|
+
return r;
|
|
125
|
+
}
|
|
126
|
+
case "map": {
|
|
127
|
+
const m = /* @__PURE__ */ new Map();
|
|
128
|
+
refs.push(m);
|
|
129
|
+
for (const [k, v] of tagged.v) {
|
|
130
|
+
m.set(__scDecode(k, refs), __scDecode(v, refs));
|
|
131
|
+
}
|
|
132
|
+
return m;
|
|
133
|
+
}
|
|
134
|
+
case "set": {
|
|
135
|
+
const s = /* @__PURE__ */ new Set();
|
|
136
|
+
refs.push(s);
|
|
137
|
+
for (const v of tagged.v) {
|
|
138
|
+
s.add(__scDecode(v, refs));
|
|
139
|
+
}
|
|
140
|
+
return s;
|
|
141
|
+
}
|
|
142
|
+
case "ab": {
|
|
143
|
+
const bytes = tagged.v;
|
|
144
|
+
const ab = new ArrayBuffer(bytes.length);
|
|
145
|
+
const u8 = new Uint8Array(ab);
|
|
146
|
+
for (let i = 0; i < bytes.length; i++) u8[i] = bytes[i];
|
|
147
|
+
refs.push(ab);
|
|
148
|
+
return ab;
|
|
149
|
+
}
|
|
150
|
+
case "ta": {
|
|
151
|
+
const { k, v: bytes } = tagged;
|
|
152
|
+
const ctors = {
|
|
153
|
+
Int8Array,
|
|
154
|
+
Uint8Array,
|
|
155
|
+
Uint8ClampedArray,
|
|
156
|
+
Int16Array,
|
|
157
|
+
Uint16Array,
|
|
158
|
+
Int32Array,
|
|
159
|
+
Uint32Array,
|
|
160
|
+
Float32Array,
|
|
161
|
+
Float64Array
|
|
162
|
+
};
|
|
163
|
+
const Ctor = ctors[k] ?? Uint8Array;
|
|
164
|
+
const ab = new ArrayBuffer(bytes.length);
|
|
165
|
+
const u8 = new Uint8Array(ab);
|
|
166
|
+
for (let i = 0; i < bytes.length; i++) u8[i] = bytes[i];
|
|
167
|
+
const ta = new Ctor(ab);
|
|
168
|
+
refs.push(ta);
|
|
169
|
+
return ta;
|
|
170
|
+
}
|
|
171
|
+
case "arr": {
|
|
172
|
+
const arr = [];
|
|
173
|
+
refs.push(arr);
|
|
174
|
+
for (const v of tagged.v) {
|
|
175
|
+
arr.push(__scDecode(v, refs));
|
|
176
|
+
}
|
|
177
|
+
return arr;
|
|
178
|
+
}
|
|
179
|
+
case "obj": {
|
|
180
|
+
const obj = {};
|
|
181
|
+
refs.push(obj);
|
|
182
|
+
const entries = tagged.v;
|
|
183
|
+
for (const key of Object.keys(entries)) {
|
|
184
|
+
obj[key] = __scDecode(entries[key], refs);
|
|
185
|
+
}
|
|
186
|
+
return obj;
|
|
187
|
+
}
|
|
188
|
+
default:
|
|
189
|
+
return tagged;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
__runtimeExposeMutableGlobal("_moduleCache", {});
|
|
193
|
+
globalThis._moduleCache = globalThis._moduleCache ?? {};
|
|
194
|
+
var __moduleCache = globalThis._moduleCache;
|
|
195
|
+
if (__moduleCache) {
|
|
196
|
+
__moduleCache["v8"] = {
|
|
197
|
+
getHeapStatistics: function() {
|
|
198
|
+
return {
|
|
199
|
+
total_heap_size: 67108864,
|
|
200
|
+
total_heap_size_executable: 1048576,
|
|
201
|
+
total_physical_size: 67108864,
|
|
202
|
+
total_available_size: 67108864,
|
|
203
|
+
used_heap_size: 52428800,
|
|
204
|
+
heap_size_limit: 134217728,
|
|
205
|
+
malloced_memory: 8192,
|
|
206
|
+
peak_malloced_memory: 16384,
|
|
207
|
+
does_zap_garbage: 0,
|
|
208
|
+
number_of_native_contexts: 1,
|
|
209
|
+
number_of_detached_contexts: 0,
|
|
210
|
+
external_memory: 0
|
|
211
|
+
};
|
|
212
|
+
},
|
|
213
|
+
getHeapSpaceStatistics: function() {
|
|
214
|
+
return [];
|
|
215
|
+
},
|
|
216
|
+
getHeapCodeStatistics: function() {
|
|
217
|
+
return {};
|
|
218
|
+
},
|
|
219
|
+
setFlagsFromString: function() {
|
|
220
|
+
},
|
|
221
|
+
serialize: function(value) {
|
|
222
|
+
return Buffer.from(
|
|
223
|
+
JSON.stringify({ $v8sc: 1, d: __scEncode(value, /* @__PURE__ */ new Map()) })
|
|
224
|
+
);
|
|
225
|
+
},
|
|
226
|
+
deserialize: function(buffer) {
|
|
227
|
+
const text = buffer.toString();
|
|
228
|
+
if (Buffer.byteLength(text, "utf8") > __jsonPayloadLimitBytes) {
|
|
229
|
+
throw new Error(
|
|
230
|
+
__payloadLimitErrorCode + ": v8.deserialize exceeds " + String(__jsonPayloadLimitBytes) + " bytes"
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
const envelope = JSON.parse(text);
|
|
234
|
+
if (envelope !== null && typeof envelope === "object" && envelope.$v8sc === 1) {
|
|
235
|
+
return __scDecode(envelope.d, []);
|
|
236
|
+
}
|
|
237
|
+
return envelope;
|
|
238
|
+
},
|
|
239
|
+
cachedDataVersionTag: function() {
|
|
240
|
+
return 0;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
__runtimeExposeMutableGlobal("_pendingModules", {});
|
|
245
|
+
__runtimeExposeMutableGlobal("_currentModule", { dirname: __initialCwd });
|
|
246
|
+
})();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
// isolate-runtime/src/common/global-exposure.ts
|
|
4
|
+
function defineRuntimeGlobalBinding(name, value, mutable) {
|
|
5
|
+
Object.defineProperty(globalThis, name, {
|
|
6
|
+
value,
|
|
7
|
+
writable: mutable,
|
|
8
|
+
configurable: mutable,
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function createRuntimeGlobalExposer(mutable) {
|
|
13
|
+
return (name, value) => {
|
|
14
|
+
defineRuntimeGlobalBinding(name, value, mutable);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function ensureRuntimeExposureHelpers() {
|
|
18
|
+
if (typeof globalThis.__runtimeExposeCustomGlobal !== "function") {
|
|
19
|
+
defineRuntimeGlobalBinding(
|
|
20
|
+
"__runtimeExposeCustomGlobal",
|
|
21
|
+
createRuntimeGlobalExposer(false),
|
|
22
|
+
false
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
if (typeof globalThis.__runtimeExposeMutableGlobal !== "function") {
|
|
26
|
+
defineRuntimeGlobalBinding(
|
|
27
|
+
"__runtimeExposeMutableGlobal",
|
|
28
|
+
createRuntimeGlobalExposer(true),
|
|
29
|
+
false
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// isolate-runtime/src/inject/global-exposure-helpers.ts
|
|
35
|
+
ensureRuntimeExposureHelpers();
|
|
36
|
+
})();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
// isolate-runtime/src/common/global-exposure.ts
|
|
4
|
+
function defineRuntimeGlobalBinding(name, value, mutable) {
|
|
5
|
+
Object.defineProperty(globalThis, name, {
|
|
6
|
+
value,
|
|
7
|
+
writable: mutable,
|
|
8
|
+
configurable: mutable,
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function createRuntimeGlobalExposer(mutable) {
|
|
13
|
+
return (name, value) => {
|
|
14
|
+
defineRuntimeGlobalBinding(name, value, mutable);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function getRuntimeExposeMutableGlobal() {
|
|
18
|
+
if (typeof globalThis.__runtimeExposeMutableGlobal === "function") {
|
|
19
|
+
return globalThis.__runtimeExposeMutableGlobal;
|
|
20
|
+
}
|
|
21
|
+
return createRuntimeGlobalExposer(true);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// isolate-runtime/src/inject/init-commonjs-module-globals.ts
|
|
25
|
+
var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();
|
|
26
|
+
__runtimeExposeMutableGlobal("module", { exports: {} });
|
|
27
|
+
__runtimeExposeMutableGlobal("exports", globalThis.module.exports);
|
|
28
|
+
})();
|