@secure-exec/core 0.2.1-rc.1 → 0.3.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.
Files changed (248) hide show
  1. package/README.md +5 -5
  2. package/dist/binary.d.ts +4 -0
  3. package/dist/binary.js +25 -0
  4. package/dist/bytes.d.ts +2 -0
  5. package/dist/bytes.js +6 -0
  6. package/dist/callbacks.d.ts +41 -0
  7. package/dist/callbacks.js +94 -0
  8. package/dist/cargo.d.ts +2 -0
  9. package/dist/cargo.js +142 -0
  10. package/dist/correlation.d.ts +10 -0
  11. package/dist/correlation.js +49 -0
  12. package/dist/descriptors.d.ts +34 -0
  13. package/dist/descriptors.js +37 -0
  14. package/dist/event-buffer.d.ts +90 -0
  15. package/dist/event-buffer.js +313 -0
  16. package/dist/ext.d.ts +7 -0
  17. package/dist/ext.js +13 -0
  18. package/dist/filesystem.d.ts +41 -0
  19. package/dist/filesystem.js +70 -0
  20. package/dist/frame-payload-codec.d.ts +8 -0
  21. package/dist/frame-payload-codec.js +14 -0
  22. package/dist/frame-rpc.d.ts +38 -0
  23. package/dist/frame-rpc.js +73 -0
  24. package/dist/frame-stream.d.ts +27 -0
  25. package/dist/frame-stream.js +99 -0
  26. package/dist/framing.d.ts +7 -0
  27. package/dist/framing.js +22 -0
  28. package/dist/generated/AcpLimitsConfig.d.ts +4 -0
  29. package/dist/generated/AcpLimitsConfig.js +2 -0
  30. package/dist/generated/CreateVmConfig.d.ts +19 -0
  31. package/dist/generated/FsPermissionRule.d.ts +6 -0
  32. package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
  33. package/dist/generated/FsPermissionRuleSet.js +1 -0
  34. package/dist/generated/FsPermissionScope.d.ts +3 -0
  35. package/dist/generated/FsPermissionScope.js +1 -0
  36. package/dist/generated/HttpLimitsConfig.d.ts +3 -0
  37. package/dist/generated/HttpLimitsConfig.js +2 -0
  38. package/dist/generated/JsModuleResolution.d.ts +1 -0
  39. package/dist/generated/JsModuleResolution.js +2 -0
  40. package/dist/generated/JsRuntimeConfig.d.ts +26 -0
  41. package/dist/generated/JsRuntimeConfig.js +1 -0
  42. package/dist/generated/JsRuntimeLimitsConfig.d.ts +7 -0
  43. package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
  44. package/dist/generated/JsRuntimePlatform.d.ts +1 -0
  45. package/dist/generated/JsRuntimePlatform.js +2 -0
  46. package/dist/generated/MountPluginDescriptor.d.ts +4 -0
  47. package/dist/generated/MountPluginDescriptor.js +2 -0
  48. package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
  49. package/dist/generated/NativeRootFilesystemConfig.js +1 -0
  50. package/dist/generated/PatternPermissionRule.d.ts +6 -0
  51. package/dist/generated/PatternPermissionRule.js +1 -0
  52. package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
  53. package/dist/generated/PatternPermissionRuleSet.js +1 -0
  54. package/dist/generated/PatternPermissionScope.d.ts +3 -0
  55. package/dist/generated/PatternPermissionScope.js +1 -0
  56. package/dist/generated/PermissionMode.d.ts +1 -0
  57. package/dist/generated/PermissionMode.js +2 -0
  58. package/dist/generated/PermissionsPolicy.d.ts +10 -0
  59. package/dist/generated/PermissionsPolicy.js +1 -0
  60. package/dist/generated/PluginLimitsConfig.d.ts +4 -0
  61. package/dist/generated/PluginLimitsConfig.js +2 -0
  62. package/dist/generated/PythonLimitsConfig.d.ts +5 -0
  63. package/dist/generated/PythonLimitsConfig.js +2 -0
  64. package/dist/generated/ResourceLimitsConfig.d.ts +22 -0
  65. package/dist/generated/ResourceLimitsConfig.js +2 -0
  66. package/dist/generated/RootFilesystemConfig.d.ts +9 -0
  67. package/dist/generated/RootFilesystemConfig.js +1 -0
  68. package/dist/generated/RootFilesystemEntry.d.ts +13 -0
  69. package/dist/generated/RootFilesystemEntry.js +1 -0
  70. package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
  71. package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
  72. package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
  73. package/dist/generated/RootFilesystemEntryKind.js +2 -0
  74. package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
  75. package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
  76. package/dist/generated/RootFilesystemMode.d.ts +1 -0
  77. package/dist/generated/RootFilesystemMode.js +2 -0
  78. package/dist/generated/ToolLimitsConfig.d.ts +10 -0
  79. package/dist/generated/ToolLimitsConfig.js +2 -0
  80. package/dist/generated/VmDnsConfig.d.ts +6 -0
  81. package/dist/generated/VmDnsConfig.js +2 -0
  82. package/dist/generated/VmLimitsConfig.d.ts +18 -0
  83. package/dist/generated/VmLimitsConfig.js +1 -0
  84. package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
  85. package/dist/generated/VmListenPolicyConfig.js +2 -0
  86. package/dist/generated/WasmLimitsConfig.d.ts +5 -0
  87. package/dist/generated/WasmLimitsConfig.js +2 -0
  88. package/dist/generated-protocol.d.ts +1037 -0
  89. package/dist/generated-protocol.js +2887 -0
  90. package/dist/index.d.ts +24 -62
  91. package/dist/index.js +24 -53
  92. package/dist/json.d.ts +2 -0
  93. package/dist/json.js +20 -0
  94. package/dist/kernel-proxy.d.ts +149 -0
  95. package/dist/kernel-proxy.js +1733 -0
  96. package/dist/native-client.d.ts +41 -0
  97. package/dist/native-client.js +124 -0
  98. package/dist/node-runtime.d.ts +443 -0
  99. package/dist/node-runtime.js +569 -0
  100. package/dist/numbers.d.ts +1 -0
  101. package/dist/numbers.js +8 -0
  102. package/dist/ownership.d.ts +18 -0
  103. package/dist/ownership.js +77 -0
  104. package/dist/permissions.d.ts +29 -0
  105. package/dist/permissions.js +68 -0
  106. package/dist/process.d.ts +35 -0
  107. package/dist/process.js +125 -0
  108. package/dist/protocol-client.d.ts +46 -0
  109. package/dist/protocol-client.js +180 -0
  110. package/dist/protocol-frames.d.ts +68 -0
  111. package/dist/protocol-frames.js +139 -0
  112. package/dist/protocol-maps.d.ts +28 -0
  113. package/dist/protocol-maps.js +217 -0
  114. package/dist/protocol-schema.d.ts +10 -0
  115. package/dist/protocol-schema.js +11 -0
  116. package/dist/request-payloads.d.ts +137 -0
  117. package/dist/request-payloads.js +210 -0
  118. package/dist/response-payloads.d.ts +107 -0
  119. package/dist/response-payloads.js +161 -0
  120. package/dist/sidecar-client.d.ts +242 -0
  121. package/dist/sidecar-client.js +797 -0
  122. package/dist/state.d.ts +40 -0
  123. package/dist/state.js +44 -0
  124. package/dist/test-runtime.d.ts +526 -0
  125. package/dist/test-runtime.js +2119 -0
  126. package/dist/vm-config.d.ts +31 -0
  127. package/dist/vm-config.js +1 -0
  128. package/fixtures/alpine-defaults.json +520 -0
  129. package/fixtures/base-filesystem.json +528 -0
  130. package/package.json +193 -115
  131. package/LICENSE +0 -191
  132. package/dist/bridge-setup.d.ts +0 -6
  133. package/dist/bridge-setup.js +0 -9
  134. package/dist/esm-compiler.d.ts +0 -18
  135. package/dist/esm-compiler.js +0 -72
  136. package/dist/fs-helpers.d.ts +0 -23
  137. package/dist/fs-helpers.js +0 -41
  138. package/dist/generated/isolate-runtime.d.ts +0 -19
  139. package/dist/generated/isolate-runtime.js +0 -21
  140. package/dist/generated/polyfills.d.ts +0 -82
  141. package/dist/generated/polyfills.js +0 -82
  142. package/dist/isolate-runtime/apply-custom-global-policy.js +0 -53
  143. package/dist/isolate-runtime/apply-timing-mitigation-freeze.js +0 -130
  144. package/dist/isolate-runtime/apply-timing-mitigation-off.js +0 -14
  145. package/dist/isolate-runtime/bridge-attach.js +0 -29
  146. package/dist/isolate-runtime/bridge-initial-globals.js +0 -385
  147. package/dist/isolate-runtime/eval-script-result.js +0 -8
  148. package/dist/isolate-runtime/global-exposure-helpers.js +0 -36
  149. package/dist/isolate-runtime/init-commonjs-module-globals.js +0 -28
  150. package/dist/isolate-runtime/override-process-cwd.js +0 -8
  151. package/dist/isolate-runtime/override-process-env.js +0 -8
  152. package/dist/isolate-runtime/require-setup.js +0 -4153
  153. package/dist/isolate-runtime/set-commonjs-file-globals.js +0 -36
  154. package/dist/isolate-runtime/set-stdin-data.js +0 -10
  155. package/dist/isolate-runtime/setup-dynamic-import.js +0 -123
  156. package/dist/isolate-runtime/setup-fs-facade.js +0 -87
  157. package/dist/kernel/command-registry.d.ts +0 -44
  158. package/dist/kernel/command-registry.js +0 -114
  159. package/dist/kernel/device-backend.d.ts +0 -14
  160. package/dist/kernel/device-backend.js +0 -251
  161. package/dist/kernel/device-layer.d.ts +0 -12
  162. package/dist/kernel/device-layer.js +0 -271
  163. package/dist/kernel/dns-cache.d.ts +0 -29
  164. package/dist/kernel/dns-cache.js +0 -52
  165. package/dist/kernel/fd-table.d.ts +0 -84
  166. package/dist/kernel/fd-table.js +0 -278
  167. package/dist/kernel/file-lock.d.ts +0 -34
  168. package/dist/kernel/file-lock.js +0 -122
  169. package/dist/kernel/host-adapter.d.ts +0 -50
  170. package/dist/kernel/host-adapter.js +0 -8
  171. package/dist/kernel/index.d.ts +0 -36
  172. package/dist/kernel/index.js +0 -34
  173. package/dist/kernel/kernel.d.ts +0 -9
  174. package/dist/kernel/kernel.js +0 -1415
  175. package/dist/kernel/mount-table.d.ts +0 -75
  176. package/dist/kernel/mount-table.js +0 -353
  177. package/dist/kernel/permissions.d.ts +0 -36
  178. package/dist/kernel/permissions.js +0 -150
  179. package/dist/kernel/pipe-manager.d.ts +0 -64
  180. package/dist/kernel/pipe-manager.js +0 -267
  181. package/dist/kernel/proc-backend.d.ts +0 -30
  182. package/dist/kernel/proc-backend.js +0 -428
  183. package/dist/kernel/proc-layer.d.ts +0 -11
  184. package/dist/kernel/proc-layer.js +0 -507
  185. package/dist/kernel/process-table.d.ts +0 -126
  186. package/dist/kernel/process-table.js +0 -651
  187. package/dist/kernel/pty.d.ts +0 -109
  188. package/dist/kernel/pty.js +0 -552
  189. package/dist/kernel/socket-table.d.ts +0 -312
  190. package/dist/kernel/socket-table.js +0 -1188
  191. package/dist/kernel/timer-table.d.ts +0 -54
  192. package/dist/kernel/timer-table.js +0 -108
  193. package/dist/kernel/types.d.ts +0 -541
  194. package/dist/kernel/types.js +0 -98
  195. package/dist/kernel/user.d.ts +0 -29
  196. package/dist/kernel/user.js +0 -35
  197. package/dist/kernel/vfs.d.ts +0 -82
  198. package/dist/kernel/vfs.js +0 -25
  199. package/dist/kernel/wait.d.ts +0 -45
  200. package/dist/kernel/wait.js +0 -112
  201. package/dist/kernel/wstatus.d.ts +0 -21
  202. package/dist/kernel/wstatus.js +0 -33
  203. package/dist/module-resolver.d.ts +0 -29
  204. package/dist/module-resolver.js +0 -314
  205. package/dist/package-bundler.d.ts +0 -41
  206. package/dist/package-bundler.js +0 -497
  207. package/dist/runtime-driver.d.ts +0 -66
  208. package/dist/shared/api-types.d.ts +0 -83
  209. package/dist/shared/bridge-contract.d.ts +0 -772
  210. package/dist/shared/bridge-contract.js +0 -169
  211. package/dist/shared/console-formatter.d.ts +0 -22
  212. package/dist/shared/console-formatter.js +0 -161
  213. package/dist/shared/constants.d.ts +0 -3
  214. package/dist/shared/constants.js +0 -3
  215. package/dist/shared/errors.d.ts +0 -16
  216. package/dist/shared/errors.js +0 -21
  217. package/dist/shared/esm-utils.d.ts +0 -28
  218. package/dist/shared/esm-utils.js +0 -97
  219. package/dist/shared/global-exposure.d.ts +0 -38
  220. package/dist/shared/global-exposure.js +0 -876
  221. package/dist/shared/in-memory-fs.d.ts +0 -16
  222. package/dist/shared/in-memory-fs.js +0 -115
  223. package/dist/shared/permissions.d.ts +0 -36
  224. package/dist/shared/permissions.js +0 -314
  225. package/dist/shared/require-setup.d.ts +0 -6
  226. package/dist/shared/require-setup.js +0 -9
  227. package/dist/test/block-store-conformance.d.ts +0 -34
  228. package/dist/test/block-store-conformance.js +0 -251
  229. package/dist/test/metadata-store-conformance.d.ts +0 -37
  230. package/dist/test/metadata-store-conformance.js +0 -646
  231. package/dist/test/vfs-conformance.d.ts +0 -65
  232. package/dist/test/vfs-conformance.js +0 -842
  233. package/dist/types.d.ts +0 -98
  234. package/dist/types.js +0 -6
  235. package/dist/vfs/chunked-vfs.d.ts +0 -66
  236. package/dist/vfs/chunked-vfs.js +0 -1290
  237. package/dist/vfs/host-block-store.d.ts +0 -19
  238. package/dist/vfs/host-block-store.js +0 -97
  239. package/dist/vfs/memory-block-store.d.ts +0 -16
  240. package/dist/vfs/memory-block-store.js +0 -45
  241. package/dist/vfs/memory-metadata.d.ts +0 -75
  242. package/dist/vfs/memory-metadata.js +0 -528
  243. package/dist/vfs/sqlite-metadata.d.ts +0 -91
  244. package/dist/vfs/sqlite-metadata.js +0 -582
  245. package/dist/vfs/types.d.ts +0 -210
  246. package/dist/vfs/types.js +0 -8
  247. /package/dist/{runtime-driver.js → generated/CreateVmConfig.js} +0 -0
  248. /package/dist/{shared/api-types.js → generated/FsPermissionRule.js} +0 -0
@@ -1,169 +0,0 @@
1
- /**
2
- * @deprecated Canonical source moved to @secure-exec/nodejs (US-002).
3
- * This copy is retained for backward compatibility during phased migration.
4
- * Will be removed in US-005 when kernel merges into core.
5
- *
6
- * Bridge contract: typed declarations for the globals shared between the
7
- * host (Node.js) and the isolate (sandbox V8 context).
8
- *
9
- * Two categories:
10
- * - Host bridge globals: set by the host before bridge code runs (fs refs, timers, etc.)
11
- * - Runtime bridge globals: installed by the bridge bundle itself (active handles, modules, etc.)
12
- *
13
- * The typed `Ref` aliases describe the bridge calling convention for each global.
14
- */
15
- function valuesOf(object) {
16
- return Object.values(object);
17
- }
18
- /** Globals injected by the host before the bridge bundle executes. */
19
- export const HOST_BRIDGE_GLOBAL_KEYS = {
20
- dynamicImport: "_dynamicImport",
21
- loadPolyfill: "_loadPolyfill",
22
- resolveModule: "_resolveModule",
23
- loadFile: "_loadFile",
24
- scheduleTimer: "_scheduleTimer",
25
- cryptoRandomFill: "_cryptoRandomFill",
26
- cryptoRandomUuid: "_cryptoRandomUUID",
27
- cryptoHashDigest: "_cryptoHashDigest",
28
- cryptoHmacDigest: "_cryptoHmacDigest",
29
- cryptoPbkdf2: "_cryptoPbkdf2",
30
- cryptoScrypt: "_cryptoScrypt",
31
- cryptoCipheriv: "_cryptoCipheriv",
32
- cryptoDecipheriv: "_cryptoDecipheriv",
33
- cryptoCipherivCreate: "_cryptoCipherivCreate",
34
- cryptoCipherivUpdate: "_cryptoCipherivUpdate",
35
- cryptoCipherivFinal: "_cryptoCipherivFinal",
36
- cryptoSign: "_cryptoSign",
37
- cryptoVerify: "_cryptoVerify",
38
- cryptoAsymmetricOp: "_cryptoAsymmetricOp",
39
- cryptoCreateKeyObject: "_cryptoCreateKeyObject",
40
- cryptoGenerateKeyPairSync: "_cryptoGenerateKeyPairSync",
41
- cryptoGenerateKeySync: "_cryptoGenerateKeySync",
42
- cryptoGeneratePrimeSync: "_cryptoGeneratePrimeSync",
43
- cryptoDiffieHellman: "_cryptoDiffieHellman",
44
- cryptoDiffieHellmanGroup: "_cryptoDiffieHellmanGroup",
45
- cryptoDiffieHellmanSessionCreate: "_cryptoDiffieHellmanSessionCreate",
46
- cryptoDiffieHellmanSessionCall: "_cryptoDiffieHellmanSessionCall",
47
- cryptoSubtle: "_cryptoSubtle",
48
- fsReadFile: "_fsReadFile",
49
- fsWriteFile: "_fsWriteFile",
50
- fsReadFileBinary: "_fsReadFileBinary",
51
- fsWriteFileBinary: "_fsWriteFileBinary",
52
- fsReadDir: "_fsReadDir",
53
- fsMkdir: "_fsMkdir",
54
- fsRmdir: "_fsRmdir",
55
- fsExists: "_fsExists",
56
- fsStat: "_fsStat",
57
- fsUnlink: "_fsUnlink",
58
- fsRename: "_fsRename",
59
- fsChmod: "_fsChmod",
60
- fsChown: "_fsChown",
61
- fsLink: "_fsLink",
62
- fsSymlink: "_fsSymlink",
63
- fsReadlink: "_fsReadlink",
64
- fsLstat: "_fsLstat",
65
- fsTruncate: "_fsTruncate",
66
- fsUtimes: "_fsUtimes",
67
- childProcessSpawnStart: "_childProcessSpawnStart",
68
- childProcessStdinWrite: "_childProcessStdinWrite",
69
- childProcessStdinClose: "_childProcessStdinClose",
70
- childProcessKill: "_childProcessKill",
71
- childProcessSpawnSync: "_childProcessSpawnSync",
72
- networkFetchRaw: "_networkFetchRaw",
73
- networkDnsLookupRaw: "_networkDnsLookupRaw",
74
- networkHttpRequestRaw: "_networkHttpRequestRaw",
75
- networkHttpServerListenRaw: "_networkHttpServerListenRaw",
76
- networkHttpServerCloseRaw: "_networkHttpServerCloseRaw",
77
- networkHttpServerRespondRaw: "_networkHttpServerRespondRaw",
78
- networkHttpServerWaitRaw: "_networkHttpServerWaitRaw",
79
- networkHttp2ServerListenRaw: "_networkHttp2ServerListenRaw",
80
- networkHttp2ServerCloseRaw: "_networkHttp2ServerCloseRaw",
81
- networkHttp2ServerWaitRaw: "_networkHttp2ServerWaitRaw",
82
- networkHttp2SessionConnectRaw: "_networkHttp2SessionConnectRaw",
83
- networkHttp2SessionRequestRaw: "_networkHttp2SessionRequestRaw",
84
- networkHttp2SessionSettingsRaw: "_networkHttp2SessionSettingsRaw",
85
- networkHttp2SessionSetLocalWindowSizeRaw: "_networkHttp2SessionSetLocalWindowSizeRaw",
86
- networkHttp2SessionGoawayRaw: "_networkHttp2SessionGoawayRaw",
87
- networkHttp2SessionCloseRaw: "_networkHttp2SessionCloseRaw",
88
- networkHttp2SessionDestroyRaw: "_networkHttp2SessionDestroyRaw",
89
- networkHttp2SessionWaitRaw: "_networkHttp2SessionWaitRaw",
90
- networkHttp2ServerPollRaw: "_networkHttp2ServerPollRaw",
91
- networkHttp2SessionPollRaw: "_networkHttp2SessionPollRaw",
92
- networkHttp2StreamRespondRaw: "_networkHttp2StreamRespondRaw",
93
- networkHttp2StreamPushStreamRaw: "_networkHttp2StreamPushStreamRaw",
94
- networkHttp2StreamWriteRaw: "_networkHttp2StreamWriteRaw",
95
- networkHttp2StreamEndRaw: "_networkHttp2StreamEndRaw",
96
- networkHttp2StreamCloseRaw: "_networkHttp2StreamCloseRaw",
97
- networkHttp2StreamPauseRaw: "_networkHttp2StreamPauseRaw",
98
- networkHttp2StreamResumeRaw: "_networkHttp2StreamResumeRaw",
99
- networkHttp2StreamRespondWithFileRaw: "_networkHttp2StreamRespondWithFileRaw",
100
- networkHttp2ServerRespondRaw: "_networkHttp2ServerRespondRaw",
101
- upgradeSocketWriteRaw: "_upgradeSocketWriteRaw",
102
- upgradeSocketEndRaw: "_upgradeSocketEndRaw",
103
- upgradeSocketDestroyRaw: "_upgradeSocketDestroyRaw",
104
- netSocketConnectRaw: "_netSocketConnectRaw",
105
- netSocketWaitConnectRaw: "_netSocketWaitConnectRaw",
106
- netSocketReadRaw: "_netSocketReadRaw",
107
- netSocketSetNoDelayRaw: "_netSocketSetNoDelayRaw",
108
- netSocketSetKeepAliveRaw: "_netSocketSetKeepAliveRaw",
109
- netSocketWriteRaw: "_netSocketWriteRaw",
110
- netSocketEndRaw: "_netSocketEndRaw",
111
- netSocketDestroyRaw: "_netSocketDestroyRaw",
112
- netSocketUpgradeTlsRaw: "_netSocketUpgradeTlsRaw",
113
- netSocketGetTlsClientHelloRaw: "_netSocketGetTlsClientHelloRaw",
114
- netSocketTlsQueryRaw: "_netSocketTlsQueryRaw",
115
- tlsGetCiphersRaw: "_tlsGetCiphersRaw",
116
- netServerListenRaw: "_netServerListenRaw",
117
- netServerAcceptRaw: "_netServerAcceptRaw",
118
- netServerCloseRaw: "_netServerCloseRaw",
119
- dgramSocketCreateRaw: "_dgramSocketCreateRaw",
120
- dgramSocketBindRaw: "_dgramSocketBindRaw",
121
- dgramSocketRecvRaw: "_dgramSocketRecvRaw",
122
- dgramSocketSendRaw: "_dgramSocketSendRaw",
123
- dgramSocketCloseRaw: "_dgramSocketCloseRaw",
124
- dgramSocketAddressRaw: "_dgramSocketAddressRaw",
125
- dgramSocketSetBufferSizeRaw: "_dgramSocketSetBufferSizeRaw",
126
- dgramSocketGetBufferSizeRaw: "_dgramSocketGetBufferSizeRaw",
127
- resolveModuleSync: "_resolveModuleSync",
128
- loadFileSync: "_loadFileSync",
129
- ptySetRawMode: "_ptySetRawMode",
130
- kernelStdinRead: "_kernelStdinRead",
131
- processConfig: "_processConfig",
132
- osConfig: "_osConfig",
133
- log: "_log",
134
- error: "_error",
135
- };
136
- /** Globals exposed by the bridge bundle and runtime scripts inside the isolate. */
137
- export const RUNTIME_BRIDGE_GLOBAL_KEYS = {
138
- registerHandle: "_registerHandle",
139
- unregisterHandle: "_unregisterHandle",
140
- waitForActiveHandles: "_waitForActiveHandles",
141
- getActiveHandles: "_getActiveHandles",
142
- childProcessDispatch: "_childProcessDispatch",
143
- childProcessModule: "_childProcessModule",
144
- moduleModule: "_moduleModule",
145
- osModule: "_osModule",
146
- httpModule: "_httpModule",
147
- httpsModule: "_httpsModule",
148
- http2Module: "_http2Module",
149
- dnsModule: "_dnsModule",
150
- dgramModule: "_dgramModule",
151
- httpServerDispatch: "_httpServerDispatch",
152
- httpServerUpgradeDispatch: "_httpServerUpgradeDispatch",
153
- httpServerConnectDispatch: "_httpServerConnectDispatch",
154
- http2Dispatch: "_http2Dispatch",
155
- timerDispatch: "_timerDispatch",
156
- upgradeSocketData: "_upgradeSocketData",
157
- upgradeSocketEnd: "_upgradeSocketEnd",
158
- netSocketDispatch: "_netSocketDispatch",
159
- fsFacade: "_fs",
160
- requireFrom: "_requireFrom",
161
- moduleCache: "_moduleCache",
162
- processExitError: "ProcessExitError",
163
- };
164
- export const HOST_BRIDGE_GLOBAL_KEY_LIST = valuesOf(HOST_BRIDGE_GLOBAL_KEYS);
165
- export const RUNTIME_BRIDGE_GLOBAL_KEY_LIST = valuesOf(RUNTIME_BRIDGE_GLOBAL_KEYS);
166
- export const BRIDGE_GLOBAL_KEY_LIST = [
167
- ...HOST_BRIDGE_GLOBAL_KEY_LIST,
168
- ...RUNTIME_BRIDGE_GLOBAL_KEY_LIST,
169
- ];
@@ -1,22 +0,0 @@
1
- /**
2
- * Controls how deeply and widely console.log arguments are serialized.
3
- * Prevents CPU amplification and memory buildup from deeply-nested or
4
- * massive objects being logged inside the sandbox.
5
- */
6
- export interface ConsoleSerializationBudget {
7
- maxDepth: number;
8
- maxKeys: number;
9
- maxArrayLength: number;
10
- maxOutputLength: number;
11
- }
12
- export declare const DEFAULT_CONSOLE_SERIALIZATION_BUDGET: ConsoleSerializationBudget;
13
- /** Serialize a single value with circular reference detection and budget limits. */
14
- export declare function safeStringifyConsoleValue(value: unknown, rawBudget: ConsoleSerializationBudget): string;
15
- /** Format an array of console arguments into a single space-separated string. */
16
- export declare function formatConsoleArgs(args: unknown[], rawBudget: ConsoleSerializationBudget): string;
17
- /**
18
- * Generate isolate-side JavaScript that installs a `globalThis.console` shim.
19
- * The shim serializes arguments using the budget and forwards them to host
20
- * bridge references (`_log` / `_error`) via `applySync`.
21
- */
22
- export declare function getConsoleSetupCode(budget?: ConsoleSerializationBudget): string;
@@ -1,161 +0,0 @@
1
- export const DEFAULT_CONSOLE_SERIALIZATION_BUDGET = {
2
- maxDepth: 6,
3
- maxKeys: 50,
4
- maxArrayLength: 50,
5
- maxOutputLength: 4096,
6
- };
7
- function normalizeBudget(budget) {
8
- const defaults = {
9
- maxDepth: 6,
10
- maxKeys: 50,
11
- maxArrayLength: 50,
12
- maxOutputLength: 4096,
13
- };
14
- const clamp = (value, fallback) => {
15
- if (!Number.isFinite(value))
16
- return fallback;
17
- const normalized = Math.floor(value);
18
- return normalized > 0 ? normalized : fallback;
19
- };
20
- return {
21
- maxDepth: clamp(budget.maxDepth, defaults.maxDepth),
22
- maxKeys: clamp(budget.maxKeys, defaults.maxKeys),
23
- maxArrayLength: clamp(budget.maxArrayLength, defaults.maxArrayLength),
24
- maxOutputLength: clamp(budget.maxOutputLength, defaults.maxOutputLength),
25
- };
26
- }
27
- function safeStringifyConsoleValueWithBudget(value, budget) {
28
- const suffix = "...[Truncated]";
29
- const clampOutput = (text) => {
30
- if (text.length <= budget.maxOutputLength) {
31
- return text;
32
- }
33
- if (budget.maxOutputLength <= suffix.length) {
34
- return suffix.slice(0, budget.maxOutputLength);
35
- }
36
- return (text.slice(0, budget.maxOutputLength - suffix.length) + suffix);
37
- };
38
- if (value === null)
39
- return "null";
40
- if (value === undefined)
41
- return "undefined";
42
- const valueType = typeof value;
43
- if (valueType !== "object") {
44
- if (valueType === "bigint") {
45
- return `${String(value)}n`;
46
- }
47
- return clampOutput(String(value));
48
- }
49
- const rootObject = value;
50
- const skipFastPath = (Array.isArray(rootObject) &&
51
- rootObject.length > budget.maxArrayLength) ||
52
- (!Array.isArray(rootObject) &&
53
- Object.keys(rootObject).length > budget.maxKeys);
54
- if (!skipFastPath) {
55
- try {
56
- const quickSerialized = JSON.stringify(value);
57
- if (quickSerialized !== undefined) {
58
- return clampOutput(quickSerialized);
59
- }
60
- }
61
- catch {
62
- // Fall back to circular-safe and budget-aware serialization.
63
- }
64
- }
65
- const seen = new WeakSet();
66
- const depthByObject = new WeakMap();
67
- const replacer = function (key, current) {
68
- if (typeof current === "bigint") {
69
- return `${String(current)}n`;
70
- }
71
- if (typeof current !== "object" || current === null) {
72
- return current;
73
- }
74
- const currentObject = current;
75
- if (seen.has(currentObject)) {
76
- return "[Circular]";
77
- }
78
- seen.add(currentObject);
79
- let depth = 0;
80
- if (key !== "") {
81
- const parent = this;
82
- if (typeof parent === "object" && parent !== null) {
83
- depth = (depthByObject.get(parent) ?? 0) + 1;
84
- }
85
- }
86
- depthByObject.set(currentObject, depth);
87
- if (depth > budget.maxDepth) {
88
- return "[MaxDepth]";
89
- }
90
- if (Array.isArray(currentObject)) {
91
- if (currentObject.length <= budget.maxArrayLength) {
92
- return currentObject;
93
- }
94
- const trimmed = currentObject.slice(0, budget.maxArrayLength);
95
- trimmed.push("[Truncated]");
96
- return trimmed;
97
- }
98
- const keys = Object.keys(currentObject);
99
- if (keys.length <= budget.maxKeys) {
100
- return currentObject;
101
- }
102
- const trimmed = {};
103
- for (let i = 0; i < budget.maxKeys; i += 1) {
104
- const keyName = keys[i];
105
- trimmed[keyName] = currentObject[keyName];
106
- }
107
- trimmed["[Truncated]"] = `${keys.length - budget.maxKeys} key(s)`;
108
- return trimmed;
109
- };
110
- try {
111
- const serialized = JSON.stringify(value, replacer);
112
- if (serialized === undefined) {
113
- return clampOutput(String(value));
114
- }
115
- return clampOutput(serialized);
116
- }
117
- catch {
118
- return clampOutput(String(value));
119
- }
120
- }
121
- /** Serialize a single value with circular reference detection and budget limits. */
122
- export function safeStringifyConsoleValue(value, rawBudget) {
123
- return safeStringifyConsoleValueWithBudget(value, normalizeBudget(rawBudget));
124
- }
125
- /** Format an array of console arguments into a single space-separated string. */
126
- export function formatConsoleArgs(args, rawBudget) {
127
- const budget = normalizeBudget(rawBudget);
128
- const formatted = [];
129
- for (let i = 0; i < args.length; i += 1) {
130
- formatted.push(safeStringifyConsoleValueWithBudget(args[i], budget));
131
- }
132
- return formatted.join(" ");
133
- }
134
- /**
135
- * Generate isolate-side JavaScript that installs a `globalThis.console` shim.
136
- * The shim serializes arguments using the budget and forwards them to host
137
- * bridge references (`_log` / `_error`) via `applySync`.
138
- */
139
- export function getConsoleSetupCode(budget = DEFAULT_CONSOLE_SERIALIZATION_BUDGET) {
140
- const normalizedBudget = normalizeBudget(budget);
141
- return `
142
- // tsx/esbuild may emit __name(...) wrappers inside function source strings.
143
- const __name = (value) => value;
144
- const __consoleBudget = ${JSON.stringify(normalizedBudget)};
145
- const normalizeBudget = ${normalizeBudget.toString()};
146
- const safeStringifyConsoleValueWithBudget = ${safeStringifyConsoleValueWithBudget.toString()};
147
- const safeStringifyConsoleValue = ${safeStringifyConsoleValue.toString()};
148
- const formatConsoleArgs = ${formatConsoleArgs.toString()};
149
-
150
- globalThis.console = {
151
- log: (...args) => _log(formatConsoleArgs(args, __consoleBudget) + "\\n"),
152
- error: (...args) => _error(formatConsoleArgs(args, __consoleBudget) + "\\n"),
153
- warn: (...args) => _error(formatConsoleArgs(args, __consoleBudget) + "\\n"),
154
- info: (...args) => _log(formatConsoleArgs(args, __consoleBudget) + "\\n"),
155
- debug: (...args) => _log(formatConsoleArgs(args, __consoleBudget) + "\\n"),
156
- trace: (...args) => _error(formatConsoleArgs(args, __consoleBudget) + "\\n"),
157
- dir: (...args) => _log(formatConsoleArgs(args, __consoleBudget) + "\\n"),
158
- table: (...args) => _log(formatConsoleArgs(args, __consoleBudget) + "\\n"),
159
- };
160
- `;
161
- }
@@ -1,3 +0,0 @@
1
- /** Matches GNU `timeout` convention where 124 indicates execution timed out. */
2
- export declare const TIMEOUT_EXIT_CODE = 124;
3
- export declare const TIMEOUT_ERROR_MESSAGE = "CPU time limit exceeded";
@@ -1,3 +0,0 @@
1
- /** Matches GNU `timeout` convention where 124 indicates execution timed out. */
2
- export const TIMEOUT_EXIT_CODE = 124;
3
- export const TIMEOUT_ERROR_MESSAGE = "CPU time limit exceeded";
@@ -1,16 +0,0 @@
1
- /** Node-compatible system error shape with code, errno, path, and syscall. */
2
- export interface SystemError extends Error {
3
- code?: string;
4
- errno?: number | string;
5
- path?: string;
6
- syscall?: string;
7
- }
8
- /** Build a system error with the given POSIX error code (ENOENT, EACCES, etc.). */
9
- export declare function createSystemError(code: string, message: string, details?: {
10
- path?: string;
11
- syscall?: string;
12
- }): SystemError;
13
- /** Create a permission-denied error matching Node's EACCES format. */
14
- export declare function createEaccesError(op: string, path?: string, reason?: string): SystemError;
15
- /** Create a "function not implemented" error for unsupported operations. */
16
- export declare function createEnosysError(op: string, path?: string): SystemError;
@@ -1,21 +0,0 @@
1
- /** Build a system error with the given POSIX error code (ENOENT, EACCES, etc.). */
2
- export function createSystemError(code, message, details) {
3
- const err = new Error(message);
4
- err.code = code;
5
- if (details?.path)
6
- err.path = details.path;
7
- if (details?.syscall)
8
- err.syscall = details.syscall;
9
- return err;
10
- }
11
- /** Create a permission-denied error matching Node's EACCES format. */
12
- export function createEaccesError(op, path, reason) {
13
- const suffix = path ? ` '${path}'` : "";
14
- const reasonSuffix = reason ? `: ${reason}` : "";
15
- return createSystemError("EACCES", `EACCES: permission denied, ${op}${suffix}${reasonSuffix}`, { path, syscall: op });
16
- }
17
- /** Create a "function not implemented" error for unsupported operations. */
18
- export function createEnosysError(op, path) {
19
- const suffix = path ? ` '${path}'` : "";
20
- return createSystemError("ENOSYS", `ENOSYS: function not implemented, ${op}${suffix}`, { path, syscall: op });
21
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Detect if code uses ESM syntax.
3
- */
4
- export declare function isESM(code: string, filePath?: string): boolean;
5
- /**
6
- * Transform dynamic import() calls to __dynamicImport() calls.
7
- */
8
- export declare function transformDynamicImport(code: string): string;
9
- /**
10
- * Extract static import specifiers from transformed code.
11
- */
12
- export declare function extractDynamicImportSpecifiers(code: string): string[];
13
- /**
14
- * Convert CJS module to ESM-compatible wrapper.
15
- */
16
- /**
17
- * Wrap CommonJS code in an ESM-compatible module that exports `module.exports`
18
- * as the default export plus any statically-detectable named exports.
19
- */
20
- export declare function wrapCJSForESM(code: string): string;
21
- export declare function wrapCJSForESMWithModulePath(code: string, modulePath: string): string;
22
- /**
23
- * Scan CJS code for `module.exports.X =`, `exports.X =`, and
24
- * `Object.defineProperty(exports, 'X', ...)` patterns to discover named exports
25
- * that can be re-exported from the ESM wrapper.
26
- */
27
- declare function extractCjsNamedExports(code: string): string[];
28
- export { extractCjsNamedExports };
@@ -1,97 +0,0 @@
1
- /**
2
- * Detect if code uses ESM syntax.
3
- */
4
- export function isESM(code, filePath) {
5
- if (filePath?.endsWith(".mjs"))
6
- return true;
7
- if (filePath?.endsWith(".cjs"))
8
- return false;
9
- const hasImport = /^\s*import\s*(?:[\w{},*\s]+\s*from\s*)?['"][^'"]+['"]/m.test(code) ||
10
- /^\s*import\s*\{[^}]*\}\s*from\s*['"][^'"]+['"]/m.test(code);
11
- const hasExport = /^\s*export\s+(?:default|const|let|var|function|class|{)/m.test(code) ||
12
- /^\s*export\s*\{/m.test(code);
13
- return hasImport || hasExport;
14
- }
15
- /**
16
- * Transform dynamic import() calls to __dynamicImport() calls.
17
- */
18
- export function transformDynamicImport(code) {
19
- return code.replace(/(?<![a-zA-Z_$])import\s*\(/g, "__dynamicImport(");
20
- }
21
- /**
22
- * Extract static import specifiers from transformed code.
23
- */
24
- export function extractDynamicImportSpecifiers(code) {
25
- const regex = /__dynamicImport\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
26
- const specifiers = new Set();
27
- for (const match of code.matchAll(regex)) {
28
- specifiers.add(match[1]);
29
- }
30
- return Array.from(specifiers);
31
- }
32
- /**
33
- * Convert CJS module to ESM-compatible wrapper.
34
- */
35
- /**
36
- * Wrap CommonJS code in an ESM-compatible module that exports `module.exports`
37
- * as the default export plus any statically-detectable named exports.
38
- */
39
- export function wrapCJSForESM(code) {
40
- const modulePath = "/<cjs-module>.cjs";
41
- return wrapCJSForESMWithModulePath(code, modulePath);
42
- }
43
- function getModuleDir(path) {
44
- const normalized = path.replace(/\\/g, "/");
45
- const lastSlash = normalized.lastIndexOf("/");
46
- if (lastSlash <= 0) {
47
- return "/";
48
- }
49
- return normalized.slice(0, lastSlash);
50
- }
51
- export function wrapCJSForESMWithModulePath(code, modulePath) {
52
- const moduleDir = getModuleDir(modulePath);
53
- const namedExports = extractCjsNamedExports(code)
54
- .filter((name) => name !== "default" && name !== "__esModule")
55
- .map((name) => {
56
- const localName = `__cjs_named_${name}`;
57
- return `const ${localName} = __cjs?.${name};\nexport { ${localName} as ${name} };`;
58
- })
59
- .join("\n");
60
- return `
61
- const __filename = ${JSON.stringify(modulePath)};
62
- const __dirname = ${JSON.stringify(moduleDir)};
63
- const require = (name) => globalThis._requireFrom(name, __dirname);
64
- const module = { exports: {} };
65
- const exports = module.exports;
66
- ${code}
67
- const __cjs = module.exports;
68
- export default __cjs;
69
- export const __cjsModule = true;
70
- ${namedExports}
71
- `;
72
- }
73
- /**
74
- * Scan CJS code for `module.exports.X =`, `exports.X =`, and
75
- * `Object.defineProperty(exports, 'X', ...)` patterns to discover named exports
76
- * that can be re-exported from the ESM wrapper.
77
- */
78
- function extractCjsNamedExports(code) {
79
- const names = new Set();
80
- const add = (name) => {
81
- if (!/^[A-Za-z_$][\w$]*$/.test(name)) {
82
- return;
83
- }
84
- names.add(name);
85
- };
86
- for (const match of code.matchAll(/\bmodule\.exports\.([A-Za-z_$][\w$]*)\s*=/g)) {
87
- add(match[1]);
88
- }
89
- for (const match of code.matchAll(/\bexports\.([A-Za-z_$][\w$]*)\s*=/g)) {
90
- add(match[1]);
91
- }
92
- for (const match of code.matchAll(/\bObject\.defineProperty\(\s*(?:module\.)?exports\s*,\s*["']([^"']+)["']/g)) {
93
- add(match[1]);
94
- }
95
- return Array.from(names).sort();
96
- }
97
- export { extractCjsNamedExports };
@@ -1,38 +0,0 @@
1
- /**
2
- * Classification for globals the runtime installs on the isolate's `globalThis`.
3
- *
4
- * - `hardened`: non-writable, non-configurable. Prevents sandbox code from
5
- * replacing bridge callbacks or lifecycle hooks.
6
- * - `mutable-runtime-state`: writable per-execution state (module cache,
7
- * stdin data, CJS module/exports wrappers) that must be reset between runs.
8
- */
9
- export type CustomGlobalClassification = "hardened" | "mutable-runtime-state";
10
- export interface CustomGlobalInventoryEntry {
11
- name: string;
12
- classification: CustomGlobalClassification;
13
- rationale: string;
14
- }
15
- export declare const NODE_CUSTOM_GLOBAL_INVENTORY: readonly CustomGlobalInventoryEntry[];
16
- export declare const HARDENED_NODE_CUSTOM_GLOBALS: string[];
17
- export declare const MUTABLE_NODE_CUSTOM_GLOBALS: string[];
18
- interface ExposeGlobalOptions {
19
- mutable?: boolean;
20
- enumerable?: boolean;
21
- }
22
- /**
23
- * Define a property on `target` using `Object.defineProperty`.
24
- * By default the property is non-writable/non-configurable (hardened).
25
- */
26
- export declare function exposeGlobalBinding(target: Record<string, unknown>, name: string, value: unknown, options?: ExposeGlobalOptions): void;
27
- /** Install a hardened (non-writable) global on `globalThis`. */
28
- export declare function exposeCustomGlobal(name: string, value: unknown): void;
29
- /** Install a writable global on `globalThis` for per-execution state. */
30
- export declare function exposeMutableRuntimeStateGlobal(name: string, value: unknown): void;
31
- /**
32
- * Inline JavaScript source that provides `exposeCustomGlobal` and
33
- * `exposeMutableRuntimeStateGlobal` inside the isolate's V8 context.
34
- * Evaluated by the host after context creation so that bridge/runtime
35
- * scripts can harden their own globals.
36
- */
37
- export declare const ISOLATE_GLOBAL_EXPOSURE_HELPER_SOURCE = "(() => {\n const exposeGlobalBinding = (name, value, mutable = false) => {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true,\n });\n };\n const exposeCustomGlobal = (name, value) => exposeGlobalBinding(name, value, false);\n const exposeMutableRuntimeStateGlobal = (name, value) =>\n exposeGlobalBinding(name, value, true);\n return {\n exposeCustomGlobal,\n exposeMutableRuntimeStateGlobal,\n };\n})()";
38
- export {};