@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/types.d.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal filesystem interface for secure-exec.
|
|
3
|
+
*
|
|
4
|
+
* This interface abstracts filesystem operations needed by the sandbox.
|
|
5
|
+
*/
|
|
6
|
+
export interface VirtualDirEntry {
|
|
7
|
+
name: string;
|
|
8
|
+
isDirectory: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface VirtualStat {
|
|
11
|
+
mode: number;
|
|
12
|
+
size: number;
|
|
13
|
+
isDirectory: boolean;
|
|
14
|
+
isSymbolicLink?: boolean;
|
|
15
|
+
atimeMs: number;
|
|
16
|
+
mtimeMs: number;
|
|
17
|
+
ctimeMs: number;
|
|
18
|
+
birthtimeMs: number;
|
|
19
|
+
}
|
|
20
|
+
export interface VirtualFileSystem {
|
|
21
|
+
/**
|
|
22
|
+
* Read a file as binary data.
|
|
23
|
+
* @throws Error if file doesn't exist.
|
|
24
|
+
*/
|
|
25
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
26
|
+
/**
|
|
27
|
+
* Read a file as text (UTF-8).
|
|
28
|
+
* @throws Error if file doesn't exist.
|
|
29
|
+
*/
|
|
30
|
+
readTextFile(path: string): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Read directory entries (file/folder names).
|
|
33
|
+
* @throws Error if directory doesn't exist.
|
|
34
|
+
*/
|
|
35
|
+
readDir(path: string): Promise<string[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Read directory entries with type metadata.
|
|
38
|
+
* @throws Error if directory doesn't exist.
|
|
39
|
+
*/
|
|
40
|
+
readDirWithTypes(path: string): Promise<VirtualDirEntry[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Write a file (creates parent directories as needed).
|
|
43
|
+
* @param path - Absolute path to the file.
|
|
44
|
+
* @param content - String or binary content.
|
|
45
|
+
*/
|
|
46
|
+
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Create a single directory level.
|
|
49
|
+
* @throws Error if parent doesn't exist.
|
|
50
|
+
*/
|
|
51
|
+
createDir(path: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Create a directory recursively (creates parent directories as needed).
|
|
54
|
+
* Should not throw if directory already exists.
|
|
55
|
+
*/
|
|
56
|
+
mkdir(path: string): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Check if a path exists (file or directory).
|
|
59
|
+
*/
|
|
60
|
+
exists(path: string): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Get file or directory metadata.
|
|
63
|
+
* @throws Error if path doesn't exist.
|
|
64
|
+
*/
|
|
65
|
+
stat(path: string): Promise<VirtualStat>;
|
|
66
|
+
/**
|
|
67
|
+
* Remove a file.
|
|
68
|
+
* @throws Error if file doesn't exist.
|
|
69
|
+
*/
|
|
70
|
+
removeFile(path: string): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Remove an empty directory.
|
|
73
|
+
* @throws Error if directory doesn't exist or is not empty.
|
|
74
|
+
*/
|
|
75
|
+
removeDir(path: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Rename or move a file/directory.
|
|
78
|
+
* Behavior SHOULD be atomic when supported by the backing store.
|
|
79
|
+
*/
|
|
80
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
81
|
+
/** Create a symbolic link at linkPath pointing to target. */
|
|
82
|
+
symlink(target: string, linkPath: string): Promise<void>;
|
|
83
|
+
/** Read the target of a symbolic link. */
|
|
84
|
+
readlink(path: string): Promise<string>;
|
|
85
|
+
/** Like stat but does not follow symlinks. */
|
|
86
|
+
lstat(path: string): Promise<VirtualStat>;
|
|
87
|
+
/** Create a hard link from oldPath to newPath. */
|
|
88
|
+
link(oldPath: string, newPath: string): Promise<void>;
|
|
89
|
+
/** Change file mode bits. */
|
|
90
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
91
|
+
/** Change file owner and group. */
|
|
92
|
+
chown(path: string, uid: number, gid: number): Promise<void>;
|
|
93
|
+
/** Update access and modification timestamps. */
|
|
94
|
+
utimes(path: string, atime: number, mtime: number): Promise<void>;
|
|
95
|
+
/** Truncate a file to a specified length. */
|
|
96
|
+
truncate(path: string, length: number): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
export interface SpawnedProcess {
|
|
99
|
+
writeStdin(data: Uint8Array | string): void;
|
|
100
|
+
closeStdin(): void;
|
|
101
|
+
kill(signal?: number): void;
|
|
102
|
+
wait(): Promise<number>;
|
|
103
|
+
}
|
|
104
|
+
export interface CommandExecutor {
|
|
105
|
+
spawn(command: string, args: string[], options: {
|
|
106
|
+
cwd?: string;
|
|
107
|
+
env?: Record<string, string>;
|
|
108
|
+
onStdout?: (data: Uint8Array) => void;
|
|
109
|
+
onStderr?: (data: Uint8Array) => void;
|
|
110
|
+
}): SpawnedProcess;
|
|
111
|
+
}
|
|
112
|
+
export interface NetworkServerAddress {
|
|
113
|
+
address: string;
|
|
114
|
+
family: string;
|
|
115
|
+
port: number;
|
|
116
|
+
}
|
|
117
|
+
export interface NetworkServerRequest {
|
|
118
|
+
method: string;
|
|
119
|
+
url: string;
|
|
120
|
+
headers: Record<string, string>;
|
|
121
|
+
rawHeaders: string[];
|
|
122
|
+
bodyBase64?: string;
|
|
123
|
+
}
|
|
124
|
+
export interface NetworkServerResponse {
|
|
125
|
+
status: number;
|
|
126
|
+
headers?: Array<[string, string]>;
|
|
127
|
+
body?: string;
|
|
128
|
+
bodyEncoding?: "utf8" | "base64";
|
|
129
|
+
}
|
|
130
|
+
export interface NetworkServerListenOptions {
|
|
131
|
+
serverId: number;
|
|
132
|
+
port?: number;
|
|
133
|
+
hostname?: string;
|
|
134
|
+
onRequest(request: NetworkServerRequest): Promise<NetworkServerResponse> | NetworkServerResponse;
|
|
135
|
+
}
|
|
136
|
+
export interface NetworkAdapter {
|
|
137
|
+
httpServerListen?(options: NetworkServerListenOptions): Promise<{
|
|
138
|
+
address: NetworkServerAddress | null;
|
|
139
|
+
}>;
|
|
140
|
+
httpServerClose?(serverId: number): Promise<void>;
|
|
141
|
+
fetch(url: string, options: {
|
|
142
|
+
method?: string;
|
|
143
|
+
headers?: Record<string, string>;
|
|
144
|
+
body?: string | null;
|
|
145
|
+
}): Promise<{
|
|
146
|
+
ok: boolean;
|
|
147
|
+
status: number;
|
|
148
|
+
statusText: string;
|
|
149
|
+
headers: Record<string, string>;
|
|
150
|
+
body: string;
|
|
151
|
+
url: string;
|
|
152
|
+
redirected: boolean;
|
|
153
|
+
}>;
|
|
154
|
+
dnsLookup(hostname: string): Promise<{
|
|
155
|
+
address: string;
|
|
156
|
+
family: number;
|
|
157
|
+
} | {
|
|
158
|
+
error: string;
|
|
159
|
+
code: string;
|
|
160
|
+
}>;
|
|
161
|
+
httpRequest(url: string, options: {
|
|
162
|
+
method?: string;
|
|
163
|
+
headers?: Record<string, string>;
|
|
164
|
+
body?: string | null;
|
|
165
|
+
}): Promise<{
|
|
166
|
+
status: number;
|
|
167
|
+
statusText: string;
|
|
168
|
+
headers: Record<string, string>;
|
|
169
|
+
body: string;
|
|
170
|
+
url: string;
|
|
171
|
+
trailers?: Record<string, string>;
|
|
172
|
+
}>;
|
|
173
|
+
}
|
|
174
|
+
export interface PermissionDecision {
|
|
175
|
+
allow: boolean;
|
|
176
|
+
reason?: string;
|
|
177
|
+
}
|
|
178
|
+
export type PermissionCheck<T> = (request: T) => PermissionDecision;
|
|
179
|
+
export interface FsAccessRequest {
|
|
180
|
+
op: "read" | "write" | "mkdir" | "createDir" | "readdir" | "stat" | "rm" | "rename" | "exists" | "chmod" | "chown" | "link" | "symlink" | "readlink" | "truncate" | "utimes";
|
|
181
|
+
path: string;
|
|
182
|
+
}
|
|
183
|
+
export interface NetworkAccessRequest {
|
|
184
|
+
op: "fetch" | "http" | "dns" | "listen";
|
|
185
|
+
url?: string;
|
|
186
|
+
method?: string;
|
|
187
|
+
hostname?: string;
|
|
188
|
+
}
|
|
189
|
+
export interface ChildProcessAccessRequest {
|
|
190
|
+
command: string;
|
|
191
|
+
args: string[];
|
|
192
|
+
cwd?: string;
|
|
193
|
+
env?: Record<string, string>;
|
|
194
|
+
}
|
|
195
|
+
export interface EnvAccessRequest {
|
|
196
|
+
op: "read" | "write";
|
|
197
|
+
key: string;
|
|
198
|
+
value?: string;
|
|
199
|
+
}
|
|
200
|
+
export interface Permissions {
|
|
201
|
+
fs?: PermissionCheck<FsAccessRequest>;
|
|
202
|
+
network?: PermissionCheck<NetworkAccessRequest>;
|
|
203
|
+
childProcess?: PermissionCheck<ChildProcessAccessRequest>;
|
|
204
|
+
env?: PermissionCheck<EnvAccessRequest>;
|
|
205
|
+
}
|
|
206
|
+
export type { DriverRuntimeConfig, NodeRuntimeDriver, NodeRuntimeDriverFactory, PythonRuntimeDriver, PythonRuntimeDriverFactory, RuntimeDriver, RuntimeDriverFactory, RuntimeDriverOptions, SharedRuntimeDriver, SystemDriver, } from "./runtime-driver.js";
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@secure-exec/core",
|
|
3
|
+
"version": "0.1.0-rc.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./internal/bridge-setup": {
|
|
19
|
+
"types": "./dist/bridge-setup.d.ts",
|
|
20
|
+
"import": "./dist/bridge-setup.js",
|
|
21
|
+
"default": "./dist/bridge-setup.js"
|
|
22
|
+
},
|
|
23
|
+
"./internal/esm-compiler": {
|
|
24
|
+
"types": "./dist/esm-compiler.d.ts",
|
|
25
|
+
"import": "./dist/esm-compiler.js",
|
|
26
|
+
"default": "./dist/esm-compiler.js"
|
|
27
|
+
},
|
|
28
|
+
"./internal/fs-helpers": {
|
|
29
|
+
"types": "./dist/fs-helpers.d.ts",
|
|
30
|
+
"import": "./dist/fs-helpers.js",
|
|
31
|
+
"default": "./dist/fs-helpers.js"
|
|
32
|
+
},
|
|
33
|
+
"./internal/module-resolver": {
|
|
34
|
+
"types": "./dist/module-resolver.d.ts",
|
|
35
|
+
"import": "./dist/module-resolver.js",
|
|
36
|
+
"default": "./dist/module-resolver.js"
|
|
37
|
+
},
|
|
38
|
+
"./internal/package-bundler": {
|
|
39
|
+
"types": "./dist/package-bundler.d.ts",
|
|
40
|
+
"import": "./dist/package-bundler.js",
|
|
41
|
+
"default": "./dist/package-bundler.js"
|
|
42
|
+
},
|
|
43
|
+
"./internal/runtime": {
|
|
44
|
+
"types": "./dist/runtime.d.ts",
|
|
45
|
+
"import": "./dist/runtime.js",
|
|
46
|
+
"default": "./dist/runtime.js"
|
|
47
|
+
},
|
|
48
|
+
"./internal/python-runtime": {
|
|
49
|
+
"types": "./dist/python-runtime.d.ts",
|
|
50
|
+
"import": "./dist/python-runtime.js",
|
|
51
|
+
"default": "./dist/python-runtime.js"
|
|
52
|
+
},
|
|
53
|
+
"./internal/runtime-driver": {
|
|
54
|
+
"types": "./dist/runtime-driver.d.ts",
|
|
55
|
+
"import": "./dist/runtime-driver.js",
|
|
56
|
+
"default": "./dist/runtime-driver.js"
|
|
57
|
+
},
|
|
58
|
+
"./internal/types": {
|
|
59
|
+
"types": "./dist/types.d.ts",
|
|
60
|
+
"import": "./dist/types.js",
|
|
61
|
+
"default": "./dist/types.js"
|
|
62
|
+
},
|
|
63
|
+
"./internal/generated/isolate-runtime": {
|
|
64
|
+
"types": "./dist/generated/isolate-runtime.d.ts",
|
|
65
|
+
"import": "./dist/generated/isolate-runtime.js",
|
|
66
|
+
"default": "./dist/generated/isolate-runtime.js"
|
|
67
|
+
},
|
|
68
|
+
"./internal/generated/polyfills": {
|
|
69
|
+
"types": "./dist/generated/polyfills.d.ts",
|
|
70
|
+
"import": "./dist/generated/polyfills.js",
|
|
71
|
+
"default": "./dist/generated/polyfills.js"
|
|
72
|
+
},
|
|
73
|
+
"./internal/shared/*": {
|
|
74
|
+
"types": "./dist/shared/*.d.ts",
|
|
75
|
+
"import": "./dist/shared/*.js",
|
|
76
|
+
"default": "./dist/shared/*.js"
|
|
77
|
+
},
|
|
78
|
+
"./internal/bridge": {
|
|
79
|
+
"types": "./dist/bridge/index.d.ts",
|
|
80
|
+
"import": "./dist/bridge/index.js",
|
|
81
|
+
"default": "./dist/bridge/index.js"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"dependencies": {
|
|
85
|
+
"buffer": "^6.0.3",
|
|
86
|
+
"esbuild": "^0.27.1",
|
|
87
|
+
"node-stdlib-browser": "^1.3.1",
|
|
88
|
+
"sucrase": "^3.35.0",
|
|
89
|
+
"text-encoding-utf-8": "^1.0.2",
|
|
90
|
+
"whatwg-url": "^15.1.0"
|
|
91
|
+
},
|
|
92
|
+
"devDependencies": {
|
|
93
|
+
"@types/node": "^22.10.2",
|
|
94
|
+
"typescript": "^5.7.2"
|
|
95
|
+
},
|
|
96
|
+
"scripts": {
|
|
97
|
+
"check-types:src": "tsc --noEmit",
|
|
98
|
+
"check-types:isolate-runtime": "tsc -p tsconfig.isolate-runtime.json --noEmit",
|
|
99
|
+
"check-types": "pnpm run build:generated && pnpm run check-types:src && pnpm run check-types:isolate-runtime",
|
|
100
|
+
"build:bridge": "esbuild src/bridge/index.ts --bundle --format=iife --global-name=bridge --outfile=dist/bridge.js",
|
|
101
|
+
"build:polyfills": "node scripts/build-polyfills.mjs",
|
|
102
|
+
"build:isolate-runtime": "node scripts/build-isolate-runtime.mjs",
|
|
103
|
+
"build:generated": "pnpm run build:polyfills && pnpm run build:isolate-runtime",
|
|
104
|
+
"build": "pnpm run build:bridge && pnpm run build:generated && tsc",
|
|
105
|
+
"test": "echo 'no tests yet'"
|
|
106
|
+
}
|
|
107
|
+
}
|