@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
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
// Canonical Node runtime + bridge custom-global inventory.
|
|
2
|
+
export const NODE_CUSTOM_GLOBAL_INVENTORY = [
|
|
3
|
+
{
|
|
4
|
+
name: "_processConfig",
|
|
5
|
+
classification: "hardened",
|
|
6
|
+
rationale: "Bridge bootstrap configuration must not be replaced by sandbox code.",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: "_osConfig",
|
|
10
|
+
classification: "hardened",
|
|
11
|
+
rationale: "Bridge bootstrap configuration must not be replaced by sandbox code.",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "bridge",
|
|
15
|
+
classification: "hardened",
|
|
16
|
+
rationale: "Bridge export object is runtime-owned control-plane state.",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "_registerHandle",
|
|
20
|
+
classification: "hardened",
|
|
21
|
+
rationale: "Active-handle lifecycle hook controls runtime completion semantics.",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "_unregisterHandle",
|
|
25
|
+
classification: "hardened",
|
|
26
|
+
rationale: "Active-handle lifecycle hook controls runtime completion semantics.",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "_waitForActiveHandles",
|
|
30
|
+
classification: "hardened",
|
|
31
|
+
rationale: "Active-handle lifecycle hook controls runtime completion semantics.",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "_getActiveHandles",
|
|
35
|
+
classification: "hardened",
|
|
36
|
+
rationale: "Bridge debug hook should not be replaced by sandbox code.",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "_childProcessDispatch",
|
|
40
|
+
classification: "hardened",
|
|
41
|
+
rationale: "Host-to-sandbox child-process callback dispatch entrypoint.",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "_childProcessModule",
|
|
45
|
+
classification: "hardened",
|
|
46
|
+
rationale: "Bridge-owned child_process module handle for require resolution.",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "_osModule",
|
|
50
|
+
classification: "hardened",
|
|
51
|
+
rationale: "Bridge-owned os module handle for require resolution.",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "_moduleModule",
|
|
55
|
+
classification: "hardened",
|
|
56
|
+
rationale: "Bridge-owned module module handle for require resolution.",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "_httpModule",
|
|
60
|
+
classification: "hardened",
|
|
61
|
+
rationale: "Bridge-owned http module handle for require resolution.",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "_httpsModule",
|
|
65
|
+
classification: "hardened",
|
|
66
|
+
rationale: "Bridge-owned https module handle for require resolution.",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "_http2Module",
|
|
70
|
+
classification: "hardened",
|
|
71
|
+
rationale: "Bridge-owned http2 module handle for require resolution.",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "_dnsModule",
|
|
75
|
+
classification: "hardened",
|
|
76
|
+
rationale: "Bridge-owned dns module handle for require resolution.",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "_httpServerDispatch",
|
|
80
|
+
classification: "hardened",
|
|
81
|
+
rationale: "Host-to-sandbox HTTP server dispatch entrypoint.",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "ProcessExitError",
|
|
85
|
+
classification: "hardened",
|
|
86
|
+
rationale: "Runtime-owned process-exit control-path error class.",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "_log",
|
|
90
|
+
classification: "hardened",
|
|
91
|
+
rationale: "Host console capture reference consumed by sandbox console shim.",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "_error",
|
|
95
|
+
classification: "hardened",
|
|
96
|
+
rationale: "Host console capture reference consumed by sandbox console shim.",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "_loadPolyfill",
|
|
100
|
+
classification: "hardened",
|
|
101
|
+
rationale: "Host module-loading bridge reference.",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "_resolveModule",
|
|
105
|
+
classification: "hardened",
|
|
106
|
+
rationale: "Host module-resolution bridge reference.",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "_loadFile",
|
|
110
|
+
classification: "hardened",
|
|
111
|
+
rationale: "Host file-loading bridge reference.",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "_scheduleTimer",
|
|
115
|
+
classification: "hardened",
|
|
116
|
+
rationale: "Host timer bridge reference used by process timers.",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "_cryptoRandomFill",
|
|
120
|
+
classification: "hardened",
|
|
121
|
+
rationale: "Host entropy bridge reference for crypto.getRandomValues.",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "_cryptoRandomUUID",
|
|
125
|
+
classification: "hardened",
|
|
126
|
+
rationale: "Host entropy bridge reference for crypto.randomUUID.",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "_fsReadFile",
|
|
130
|
+
classification: "hardened",
|
|
131
|
+
rationale: "Host filesystem bridge reference.",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "_fsWriteFile",
|
|
135
|
+
classification: "hardened",
|
|
136
|
+
rationale: "Host filesystem bridge reference.",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "_fsReadFileBinary",
|
|
140
|
+
classification: "hardened",
|
|
141
|
+
rationale: "Host filesystem bridge reference.",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "_fsWriteFileBinary",
|
|
145
|
+
classification: "hardened",
|
|
146
|
+
rationale: "Host filesystem bridge reference.",
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "_fsReadDir",
|
|
150
|
+
classification: "hardened",
|
|
151
|
+
rationale: "Host filesystem bridge reference.",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "_fsMkdir",
|
|
155
|
+
classification: "hardened",
|
|
156
|
+
rationale: "Host filesystem bridge reference.",
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: "_fsRmdir",
|
|
160
|
+
classification: "hardened",
|
|
161
|
+
rationale: "Host filesystem bridge reference.",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "_fsExists",
|
|
165
|
+
classification: "hardened",
|
|
166
|
+
rationale: "Host filesystem bridge reference.",
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "_fsStat",
|
|
170
|
+
classification: "hardened",
|
|
171
|
+
rationale: "Host filesystem bridge reference.",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: "_fsUnlink",
|
|
175
|
+
classification: "hardened",
|
|
176
|
+
rationale: "Host filesystem bridge reference.",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "_fsRename",
|
|
180
|
+
classification: "hardened",
|
|
181
|
+
rationale: "Host filesystem bridge reference.",
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: "_fsChmod",
|
|
185
|
+
classification: "hardened",
|
|
186
|
+
rationale: "Host filesystem bridge reference.",
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "_fsChown",
|
|
190
|
+
classification: "hardened",
|
|
191
|
+
rationale: "Host filesystem bridge reference.",
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: "_fsLink",
|
|
195
|
+
classification: "hardened",
|
|
196
|
+
rationale: "Host filesystem bridge reference.",
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "_fsSymlink",
|
|
200
|
+
classification: "hardened",
|
|
201
|
+
rationale: "Host filesystem bridge reference.",
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "_fsReadlink",
|
|
205
|
+
classification: "hardened",
|
|
206
|
+
rationale: "Host filesystem bridge reference.",
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "_fsLstat",
|
|
210
|
+
classification: "hardened",
|
|
211
|
+
rationale: "Host filesystem bridge reference.",
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "_fsTruncate",
|
|
215
|
+
classification: "hardened",
|
|
216
|
+
rationale: "Host filesystem bridge reference.",
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: "_fsUtimes",
|
|
220
|
+
classification: "hardened",
|
|
221
|
+
rationale: "Host filesystem bridge reference.",
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "_fs",
|
|
225
|
+
classification: "hardened",
|
|
226
|
+
rationale: "Bridge filesystem facade consumed by fs polyfill.",
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "_childProcessSpawnStart",
|
|
230
|
+
classification: "hardened",
|
|
231
|
+
rationale: "Host child_process bridge reference.",
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: "_childProcessStdinWrite",
|
|
235
|
+
classification: "hardened",
|
|
236
|
+
rationale: "Host child_process bridge reference.",
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: "_childProcessStdinClose",
|
|
240
|
+
classification: "hardened",
|
|
241
|
+
rationale: "Host child_process bridge reference.",
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: "_childProcessKill",
|
|
245
|
+
classification: "hardened",
|
|
246
|
+
rationale: "Host child_process bridge reference.",
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: "_childProcessSpawnSync",
|
|
250
|
+
classification: "hardened",
|
|
251
|
+
rationale: "Host child_process bridge reference.",
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: "_networkFetchRaw",
|
|
255
|
+
classification: "hardened",
|
|
256
|
+
rationale: "Host network bridge reference.",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "_networkDnsLookupRaw",
|
|
260
|
+
classification: "hardened",
|
|
261
|
+
rationale: "Host network bridge reference.",
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: "_networkHttpRequestRaw",
|
|
265
|
+
classification: "hardened",
|
|
266
|
+
rationale: "Host network bridge reference.",
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: "_networkHttpServerListenRaw",
|
|
270
|
+
classification: "hardened",
|
|
271
|
+
rationale: "Host network bridge reference.",
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
name: "_networkHttpServerCloseRaw",
|
|
275
|
+
classification: "hardened",
|
|
276
|
+
rationale: "Host network bridge reference.",
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: "require",
|
|
280
|
+
classification: "hardened",
|
|
281
|
+
rationale: "Runtime-owned global require shim entrypoint.",
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
name: "_requireFrom",
|
|
285
|
+
classification: "hardened",
|
|
286
|
+
rationale: "Runtime-owned internal require shim used by module polyfill.",
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: "_dynamicImport",
|
|
290
|
+
classification: "hardened",
|
|
291
|
+
rationale: "Runtime-owned host callback reference for dynamic import resolution.",
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: "__dynamicImport",
|
|
295
|
+
classification: "hardened",
|
|
296
|
+
rationale: "Runtime-owned dynamic-import shim entrypoint.",
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: "_moduleCache",
|
|
300
|
+
classification: "mutable-runtime-state",
|
|
301
|
+
rationale: "Per-execution CommonJS/require cache state.",
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
name: "_pendingModules",
|
|
305
|
+
classification: "mutable-runtime-state",
|
|
306
|
+
rationale: "Per-execution circular-load tracking state.",
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
name: "_currentModule",
|
|
310
|
+
classification: "mutable-runtime-state",
|
|
311
|
+
rationale: "Per-execution module resolution context.",
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
name: "_stdinData",
|
|
315
|
+
classification: "mutable-runtime-state",
|
|
316
|
+
rationale: "Per-execution stdin payload state.",
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: "_stdinPosition",
|
|
320
|
+
classification: "mutable-runtime-state",
|
|
321
|
+
rationale: "Per-execution stdin stream cursor state.",
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: "_stdinEnded",
|
|
325
|
+
classification: "mutable-runtime-state",
|
|
326
|
+
rationale: "Per-execution stdin completion state.",
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: "_stdinFlowMode",
|
|
330
|
+
classification: "mutable-runtime-state",
|
|
331
|
+
rationale: "Per-execution stdin flow-control state.",
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
name: "module",
|
|
335
|
+
classification: "mutable-runtime-state",
|
|
336
|
+
rationale: "Per-execution CommonJS module wrapper state.",
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: "exports",
|
|
340
|
+
classification: "mutable-runtime-state",
|
|
341
|
+
rationale: "Per-execution CommonJS module wrapper state.",
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: "__filename",
|
|
345
|
+
classification: "mutable-runtime-state",
|
|
346
|
+
rationale: "Per-execution CommonJS file context state.",
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: "__dirname",
|
|
350
|
+
classification: "mutable-runtime-state",
|
|
351
|
+
rationale: "Per-execution CommonJS file context state.",
|
|
352
|
+
},
|
|
353
|
+
];
|
|
354
|
+
export const HARDENED_NODE_CUSTOM_GLOBALS = NODE_CUSTOM_GLOBAL_INVENTORY
|
|
355
|
+
.filter((entry) => entry.classification === "hardened")
|
|
356
|
+
.map((entry) => entry.name);
|
|
357
|
+
export const MUTABLE_NODE_CUSTOM_GLOBALS = NODE_CUSTOM_GLOBAL_INVENTORY
|
|
358
|
+
.filter((entry) => entry.classification === "mutable-runtime-state")
|
|
359
|
+
.map((entry) => entry.name);
|
|
360
|
+
/**
|
|
361
|
+
* Define a property on `target` using `Object.defineProperty`.
|
|
362
|
+
* By default the property is non-writable/non-configurable (hardened).
|
|
363
|
+
*/
|
|
364
|
+
export function exposeGlobalBinding(target, name, value, options = {}) {
|
|
365
|
+
const mutable = options.mutable === true;
|
|
366
|
+
const enumerable = options.enumerable !== false;
|
|
367
|
+
Object.defineProperty(target, name, {
|
|
368
|
+
value,
|
|
369
|
+
writable: mutable,
|
|
370
|
+
configurable: mutable,
|
|
371
|
+
enumerable,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
/** Install a hardened (non-writable) global on `globalThis`. */
|
|
375
|
+
export function exposeCustomGlobal(name, value) {
|
|
376
|
+
exposeGlobalBinding(globalThis, name, value);
|
|
377
|
+
}
|
|
378
|
+
/** Install a writable global on `globalThis` for per-execution state. */
|
|
379
|
+
export function exposeMutableRuntimeStateGlobal(name, value) {
|
|
380
|
+
exposeGlobalBinding(globalThis, name, value, {
|
|
381
|
+
mutable: true,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Inline JavaScript source that provides `exposeCustomGlobal` and
|
|
386
|
+
* `exposeMutableRuntimeStateGlobal` inside the isolate's V8 context.
|
|
387
|
+
* Evaluated by the host after context creation so that bridge/runtime
|
|
388
|
+
* scripts can harden their own globals.
|
|
389
|
+
*/
|
|
390
|
+
export const ISOLATE_GLOBAL_EXPOSURE_HELPER_SOURCE = `(() => {
|
|
391
|
+
const exposeGlobalBinding = (name, value, mutable = false) => {
|
|
392
|
+
Object.defineProperty(globalThis, name, {
|
|
393
|
+
value,
|
|
394
|
+
writable: mutable,
|
|
395
|
+
configurable: mutable,
|
|
396
|
+
enumerable: true,
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
const exposeCustomGlobal = (name, value) => exposeGlobalBinding(name, value, false);
|
|
400
|
+
const exposeMutableRuntimeStateGlobal = (name, value) =>
|
|
401
|
+
exposeGlobalBinding(name, value, true);
|
|
402
|
+
return {
|
|
403
|
+
exposeCustomGlobal,
|
|
404
|
+
exposeMutableRuntimeStateGlobal,
|
|
405
|
+
};
|
|
406
|
+
})()`;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { VirtualFileSystem, VirtualStat } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A fully in-memory VirtualFileSystem backed by Maps.
|
|
4
|
+
* Used as the default filesystem for the browser sandbox and for tests.
|
|
5
|
+
* Paths are always POSIX-style (forward slashes, rooted at "/").
|
|
6
|
+
*/
|
|
7
|
+
export declare class InMemoryFileSystem implements VirtualFileSystem {
|
|
8
|
+
private files;
|
|
9
|
+
private dirs;
|
|
10
|
+
private symlinks;
|
|
11
|
+
private modes;
|
|
12
|
+
private owners;
|
|
13
|
+
private timestamps;
|
|
14
|
+
private hardLinks;
|
|
15
|
+
private listDirEntries;
|
|
16
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
17
|
+
readTextFile(path: string): Promise<string>;
|
|
18
|
+
readDir(path: string): Promise<string[]>;
|
|
19
|
+
readDirWithTypes(path: string): Promise<Array<{
|
|
20
|
+
name: string;
|
|
21
|
+
isDirectory: boolean;
|
|
22
|
+
}>>;
|
|
23
|
+
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
24
|
+
createDir(path: string): Promise<void>;
|
|
25
|
+
mkdir(path: string): Promise<void>;
|
|
26
|
+
private resolveSymlink;
|
|
27
|
+
private statEntry;
|
|
28
|
+
exists(path: string): Promise<boolean>;
|
|
29
|
+
stat(path: string): Promise<VirtualStat>;
|
|
30
|
+
removeFile(path: string): Promise<void>;
|
|
31
|
+
removeDir(path: string): Promise<void>;
|
|
32
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
33
|
+
symlink(target: string, linkPath: string): Promise<void>;
|
|
34
|
+
readlink(path: string): Promise<string>;
|
|
35
|
+
lstat(path: string): Promise<VirtualStat>;
|
|
36
|
+
link(oldPath: string, newPath: string): Promise<void>;
|
|
37
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
38
|
+
chown(path: string, uid: number, gid: number): Promise<void>;
|
|
39
|
+
utimes(path: string, atime: number, mtime: number): Promise<void>;
|
|
40
|
+
truncate(path: string, length: number): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export declare function createInMemoryFileSystem(): InMemoryFileSystem;
|