cf-workers-native 0.1.5 → 0.1.6

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 (197) hide show
  1. package/README.md +2 -2
  2. package/dist/browser/documents/page-source.js +1 -1
  3. package/dist/browser/headers/index.d.ts +2 -0
  4. package/dist/browser/headers/index.js +5 -0
  5. package/dist/browser/response/index.d.ts +2 -0
  6. package/dist/browser/response/index.js +11 -3
  7. package/dist/browser/structured-clone/index.d.ts +3 -0
  8. package/dist/browser/structured-clone/index.js +75 -7
  9. package/dist/browser/websocket/attachment-size.d.ts +3 -0
  10. package/dist/browser/websocket/attachment-size.js +336 -0
  11. package/dist/browser/websocket/brand.d.ts +4 -0
  12. package/dist/browser/websocket/brand.js +16 -0
  13. package/dist/browser/websocket/close-event.d.ts +7 -0
  14. package/dist/browser/websocket/close-event.js +30 -0
  15. package/dist/browser/websocket/compression.d.ts +5 -0
  16. package/dist/browser/websocket/compression.js +124 -0
  17. package/dist/browser/websocket/conversion.d.ts +2 -0
  18. package/dist/browser/websocket/conversion.js +13 -0
  19. package/dist/browser/websocket/endpoint.d.ts +39 -0
  20. package/dist/browser/websocket/endpoint.js +379 -0
  21. package/dist/browser/websocket/frames.d.ts +21 -0
  22. package/dist/browser/websocket/frames.js +121 -0
  23. package/dist/browser/websocket/native.d.ts +14 -0
  24. package/dist/browser/websocket/native.js +226 -0
  25. package/dist/cloudflare/apis/cloudflare-node/index.js +11 -23
  26. package/dist/compat/crypto/LICENSE-3RD-PARTY.md +20 -0
  27. package/dist/compat/crypto/LICENSE.boringssl +238 -0
  28. package/dist/compat/crypto/LICENSE.ncrypto +21 -0
  29. package/dist/compat/crypto/asymmetric.js +141 -68
  30. package/dist/compat/crypto/cipher-handle.d.ts +27 -0
  31. package/dist/compat/crypto/cipher-handle.js +239 -0
  32. package/dist/compat/crypto/cipher-info.d.ts +12 -0
  33. package/dist/compat/crypto/cipher-info.js +324 -0
  34. package/dist/compat/crypto/constants.d.ts +62 -0
  35. package/dist/compat/crypto/constants.js +68 -0
  36. package/dist/compat/crypto/dh-handle.d.ts +17 -0
  37. package/dist/compat/crypto/dh-handle.js +180 -0
  38. package/dist/compat/crypto/dh.d.ts +53 -0
  39. package/dist/compat/crypto/dh.js +138 -0
  40. package/dist/compat/crypto/digest-stream.d.ts +15 -0
  41. package/dist/compat/crypto/digest-stream.js +213 -0
  42. package/dist/compat/crypto/digests.d.ts +3 -0
  43. package/dist/compat/crypto/digests.js +32 -0
  44. package/dist/compat/crypto/ecdh.d.ts +16 -6
  45. package/dist/compat/crypto/hash-handle.d.ts +23 -0
  46. package/dist/compat/crypto/hash-handle.js +70 -0
  47. package/dist/compat/crypto/hash.d.ts +37 -0
  48. package/dist/compat/crypto/hash.js +218 -0
  49. package/dist/compat/crypto/hkdf.js +40 -14
  50. package/dist/compat/crypto/index.d.cts +168 -1
  51. package/dist/compat/crypto/index.d.ts +191 -8
  52. package/dist/compat/crypto/index.js +36 -23
  53. package/dist/compat/crypto/key-errors.d.ts +10 -0
  54. package/dist/compat/crypto/key-errors.js +17 -0
  55. package/dist/compat/crypto/key-export.d.ts +8 -0
  56. package/dist/compat/crypto/key-export.js +49 -0
  57. package/dist/compat/crypto/key-formats.d.ts +2 -1
  58. package/dist/compat/crypto/key-formats.js +162 -31
  59. package/dist/compat/crypto/key-options.d.ts +1 -0
  60. package/dist/compat/crypto/key-options.js +74 -0
  61. package/dist/compat/crypto/key-state.d.ts +1 -0
  62. package/dist/compat/crypto/keys.d.ts +20 -12
  63. package/dist/compat/crypto/keys.js +125 -56
  64. package/dist/compat/crypto/metadata.d.ts +9 -0
  65. package/dist/compat/crypto/metadata.js +89 -2
  66. package/dist/compat/crypto/native-cipher.d.ts +17 -0
  67. package/dist/compat/crypto/native-cipher.js +192 -0
  68. package/dist/compat/crypto/native-crypto.d.ts +14 -1
  69. package/dist/compat/crypto/native-crypto.js +118 -6
  70. package/dist/compat/crypto/pbkdf2-handle.d.ts +4 -0
  71. package/dist/compat/crypto/pbkdf2-handle.js +26 -0
  72. package/dist/compat/crypto/pbkdf2.d.ts +5 -0
  73. package/dist/compat/crypto/pbkdf2.js +60 -0
  74. package/dist/compat/crypto/prime.js +4 -4
  75. package/dist/compat/crypto/random.d.ts +11 -0
  76. package/dist/compat/crypto/random.js +86 -6
  77. package/dist/compat/crypto/rsa.d.ts +17 -1
  78. package/dist/compat/crypto/rsa.js +8 -4
  79. package/dist/compat/crypto/scrypt.d.ts +3 -3
  80. package/dist/compat/crypto/scrypt.js +25 -23
  81. package/dist/compat/crypto/sign-handle.d.ts +3 -3
  82. package/dist/compat/crypto/sign-handle.js +55 -11
  83. package/dist/compat/crypto/signatures.d.ts +17 -11
  84. package/dist/compat/crypto/subtle-digest.d.ts +1 -0
  85. package/dist/compat/crypto/subtle-digest.js +56 -0
  86. package/dist/compat/crypto/symmetric.d.ts +40 -24
  87. package/dist/compat/crypto/symmetric.js +229 -94
  88. package/dist/compat/crypto/validation.d.ts +4 -0
  89. package/dist/compat/crypto/validation.js +29 -2
  90. package/dist/compat/crypto/webcrypto.d.ts +13 -0
  91. package/dist/compat/crypto/webcrypto.js +51 -0
  92. package/dist/compat/crypto/x509.js +2 -1
  93. package/dist/compat/events/index.js +1 -1
  94. package/dist/compat/fs/LICENSE-3RD-PARTY.md +11 -0
  95. package/dist/compat/fs/LICENSE-APACHE +177 -0
  96. package/dist/compat/fs/directory-backend.d.ts +6 -0
  97. package/dist/compat/fs/directory-backend.js +51 -0
  98. package/dist/compat/fs/directory.d.ts +37 -0
  99. package/dist/compat/fs/directory.js +137 -0
  100. package/dist/compat/fs/embedded.d.ts +1 -1
  101. package/dist/compat/fs/embedded.js +7 -2
  102. package/dist/compat/fs/file-handle.d.ts +75 -0
  103. package/dist/compat/fs/file-handle.js +226 -0
  104. package/dist/compat/fs/glob-internal.d.ts +15 -0
  105. package/dist/compat/fs/glob-internal.js +417 -0
  106. package/dist/compat/fs/glob.d.ts +10 -0
  107. package/dist/compat/fs/glob.js +71 -0
  108. package/dist/compat/fs/index.d.ts +6 -3
  109. package/dist/compat/fs/index.js +582 -50
  110. package/dist/compat/fs/io-validation.d.ts +14 -0
  111. package/dist/compat/fs/io-validation.js +130 -0
  112. package/dist/compat/fs/io.d.ts +1 -0
  113. package/dist/compat/fs/io.js +282 -0
  114. package/dist/compat/fs/promises/index.d.ts +3 -1
  115. package/dist/compat/fs/public-types.d.ts +120 -0
  116. package/dist/compat/fs/public-types.js +1 -0
  117. package/dist/compat/fs/stream-errors.d.ts +6 -0
  118. package/dist/compat/fs/stream-errors.js +8 -0
  119. package/dist/compat/fs/stream-utils.d.ts +16 -0
  120. package/dist/compat/fs/stream-utils.js +29 -0
  121. package/dist/compat/fs/streams.d.ts +104 -0
  122. package/dist/compat/fs/streams.js +794 -0
  123. package/dist/compat/fs/writable.d.ts +8 -0
  124. package/dist/compat/fs/writable.js +412 -22
  125. package/dist/compat/http/index.d.ts +11 -28
  126. package/dist/compat/http/index.js +81 -125
  127. package/dist/compat/http/server-options.d.ts +1 -0
  128. package/dist/compat/http/server-options.js +87 -0
  129. package/dist/compat/http/unique-headers.d.ts +1 -0
  130. package/dist/compat/http/unique-headers.js +21 -0
  131. package/dist/compat/http-outgoing/index.d.ts +2 -1
  132. package/dist/compat/http-outgoing/index.js +2 -17
  133. package/dist/compat/http-server/index.d.ts +2 -2
  134. package/dist/compat/http-server/index.js +4 -85
  135. package/dist/compat/https/index.d.ts +4 -2
  136. package/dist/compat/net/sockets.js +98 -20
  137. package/dist/compat/net/validators.d.ts +1 -0
  138. package/dist/compat/net/validators.js +8 -0
  139. package/dist/compat/process/configuration.d.ts +113 -0
  140. package/dist/compat/process/configuration.js +115 -0
  141. package/dist/compat/process/directory.d.ts +4 -0
  142. package/dist/compat/process/directory.js +28 -0
  143. package/dist/compat/process/files.d.ts +3 -0
  144. package/dist/compat/process/files.js +10 -0
  145. package/dist/compat/process/index.d.ts +15 -13
  146. package/dist/compat/process/index.js +47 -74
  147. package/dist/compat/process/scheduling.d.ts +2 -0
  148. package/dist/compat/process/scheduling.js +60 -0
  149. package/dist/compat/process/state.js +1 -0
  150. package/dist/compat/process/stdio.d.ts +18 -0
  151. package/dist/compat/process/stdio.js +66 -0
  152. package/dist/compat/stream/destroy.d.ts +1 -0
  153. package/dist/compat/stream/destroy.js +21 -1
  154. package/dist/compat/stream/readable.js +10 -2
  155. package/dist/compat/tls/jsstream.js +16 -6
  156. package/dist/compat/tls/wrap.d.ts +1 -1
  157. package/dist/compat/tls/wrap.js +0 -3
  158. package/dist/compat/util/inspect.js +5 -1
  159. package/dist/compat/zlib/LICENSE-3RD-PARTY.md +11 -0
  160. package/dist/compat/zlib/LICENSE-APACHE +177 -0
  161. package/dist/compat/zlib/LICENSE.zlib +22 -0
  162. package/dist/compat/zlib/classic-base.cjs +600 -0
  163. package/dist/compat/zlib/classic-base.d.cts +39 -0
  164. package/dist/compat/zlib/classic-binding.d.ts +28 -0
  165. package/dist/compat/zlib/classic-binding.js +105 -0
  166. package/dist/compat/zlib/classic.d.ts +44 -0
  167. package/dist/compat/zlib/classic.js +199 -0
  168. package/dist/compat/zlib/codec-binding.d.ts +33 -0
  169. package/dist/compat/zlib/codec-binding.js +141 -0
  170. package/dist/compat/zlib/compression.d.ts +22 -51
  171. package/dist/compat/zlib/compression.js +129 -218
  172. package/dist/compat/zlib/errors.d.ts +21 -0
  173. package/dist/compat/zlib/errors.js +32 -0
  174. package/dist/compat/zlib/index.d.ts +367 -3
  175. package/dist/compat/zlib/index.js +28 -11
  176. package/dist/compat/zlib/input.d.ts +16 -0
  177. package/dist/compat/zlib/input.js +132 -0
  178. package/dist/compat/zlib/native-codecs.d.ts +7 -0
  179. package/dist/compat/zlib/native-codecs.js +22 -10
  180. package/dist/compat/zlib/native-zlib.d.ts +5 -0
  181. package/dist/compat/zlib/native-zlib.js +52 -0
  182. package/dist/compat/zlib/public-types.d.ts +48 -0
  183. package/dist/compat/zlib/public-types.js +1 -0
  184. package/dist/compat/zlib/validators.d.ts +3 -0
  185. package/dist/compat/zlib/validators.js +18 -0
  186. package/dist/shared/buffer-source.d.ts +5 -0
  187. package/dist/shared/buffer-source.js +70 -0
  188. package/dist/shared/globals/platform.d.ts +8 -0
  189. package/dist/shared/globals/platform.js +1 -0
  190. package/dist/shared/globals/web.js +5 -0
  191. package/dist/shared/request-context.d.ts +2 -0
  192. package/dist/shared/request-context.js +11 -0
  193. package/dist/shared/request-scope.js +4 -1
  194. package/dist/tooling/shared.js +6 -0
  195. package/dist/tooling/vite.js +4 -0
  196. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +38 -7
  197. package/package.json +2 -2
@@ -2,12 +2,14 @@ declare const ClientRequest: typeof import("../http/index.js").ClientRequest;
2
2
  type ClientRequest = InstanceType<typeof ClientRequest>;
3
3
  import { Agent, globalAgent } from "./agent.js";
4
4
  import { Server } from "./server.js";
5
- import type { IncomingMessageCallback } from "node-internal:internal_http_util";
5
+ import type { IncomingMessage } from "node:http";
6
+ type IncomingMessageCallback = (message: IncomingMessage) => void;
6
7
  import type { RequestOptions, RequestListener } from "node:http";
7
8
  import type { ServerOptions } from "node:https";
8
9
  export declare function request(url: string | URL | RequestOptions, options?: RequestOptions | IncomingMessageCallback, cb?: IncomingMessageCallback): ClientRequest;
9
10
  export declare function get(input: string | URL | RequestOptions, options?: RequestOptions | IncomingMessageCallback, cb?: IncomingMessageCallback): ClientRequest;
10
- export declare function createServer(options: ServerOptions, handler: RequestListener): Server;
11
+ export declare function createServer(handler?: RequestListener): Server;
12
+ export declare function createServer(options: ServerOptions, handler?: RequestListener): Server;
11
13
  export { Agent, globalAgent, Server };
12
14
  declare const _default: {
13
15
  get: typeof get;
@@ -30,17 +30,47 @@ export function connect(address, options = {}) {
30
30
  throw new TypeError("Invalid TCP address");
31
31
  const id = crypto.randomUUID();
32
32
  const host = url.hostname.replace(/^\[|\]$/g, "");
33
- return transport(call, id, host, options.secureTransport ?? "off", () => call("WorkersCapacitor", "socketOpen", {
34
- id,
35
- host,
36
- port,
37
- tls: options.secureTransport === "on",
38
- ...(options.expectedServerHostname
39
- ? { servername: options.expectedServerHostname }
40
- : {}),
41
- }));
33
+ const directTls = options.secureTransport === "on";
34
+ let secureCall = call;
35
+ return transport((...args) => {
36
+ const operation = secureCall(...args);
37
+ return directTls
38
+ ? operation.catch((error) => {
39
+ if (error instanceof Error &&
40
+ error.message.includes("TLS connection closed without close_notify"))
41
+ throw new Error("Network connection lost.");
42
+ throw error;
43
+ })
44
+ : operation;
45
+ }, id, host, options.secureTransport ?? "off", async () => {
46
+ try {
47
+ const info = await call("WorkersCapacitor", "socketOpen", {
48
+ id,
49
+ host,
50
+ port,
51
+ tls: false,
52
+ });
53
+ if (options.secureTransport === "on") {
54
+ const servername = options.expectedServerHostname ?? host;
55
+ const result = (await call("WorkersCapacitor", "socketStartTls", {
56
+ id,
57
+ servername,
58
+ }));
59
+ // Direct TLS and STARTTLS share the authenticated record engine. On iOS
60
+ // this also preserves TLS close_notify information that NW TLS hides.
61
+ if (result?.tlsEngine === "openssl-wasm")
62
+ secureCall = await nativeTlsSession(call, id, servername);
63
+ }
64
+ return info;
65
+ }
66
+ catch (error) {
67
+ if (directTls)
68
+ throw new Error("proxy request failed, cannot connect to the specified address");
69
+ throw error;
70
+ }
71
+ });
42
72
  }
43
- function transport(call, id, host, secureTransport, open) {
73
+ function transport(call, id, host, secureTransport, open, connectionInfo) {
44
74
  let upgraded = false;
45
75
  let activeWrite;
46
76
  let readableController;
@@ -63,12 +93,21 @@ function transport(call, id, host, secureTransport, open) {
63
93
  resolveClosed();
64
94
  };
65
95
  let closing;
96
+ let openingStarted = false;
66
97
  const close = () => {
67
98
  if (upgraded)
68
99
  return Promise.resolve();
69
100
  if (!closing) {
70
101
  stopped = true;
71
- closing = call("WorkersCapacitor", "socketClose", { id }).then(() => {
102
+ // workerd Socket::close waits for the direct TLS connection result. A
103
+ // STARTTLS socket exposes TCP establishment separately, so its close can
104
+ // interrupt authentication. Do not synthesize this ordering with timers.
105
+ const pendingConnection = secureTransport === "on" && !connectionInfo && openingStarted
106
+ ? opened.catch(() => { })
107
+ : Promise.resolve();
108
+ closing = pendingConnection
109
+ .then(() => call("WorkersCapacitor", "socketClose", { id }))
110
+ .then(() => {
72
111
  if (!readEnded) {
73
112
  readEnded = true;
74
113
  readableController.error(new Error("Socket closed"));
@@ -101,6 +140,7 @@ function transport(call, id, host, secureTransport, open) {
101
140
  .then(() => {
102
141
  if (stopped)
103
142
  throw new Error("Socket closed before connection");
143
+ openingStarted = true;
104
144
  return open();
105
145
  })
106
146
  .then(async (value) => {
@@ -217,7 +257,10 @@ function transport(call, id, host, secureTransport, open) {
217
257
  notifyTerminal();
218
258
  });
219
259
  const socket = {
220
- opened,
260
+ // Workers STARTTLS inherits the established TCP connection's opened
261
+ // notification. Reads, writes and the terminal watcher still await the
262
+ // private authenticated `opened` promise above.
263
+ opened: connectionInfo ?? opened,
221
264
  closed,
222
265
  readable,
223
266
  writable,
@@ -237,18 +280,53 @@ function transport(call, id, host, secureTransport, open) {
237
280
  writableController.error(error);
238
281
  resolveClosed();
239
282
  let secureCall = call;
240
- return transport((...args) => secureCall(...args), id, host, "on", async () => {
283
+ let tlsFailed = false;
284
+ const failedOperation = (method) => {
285
+ if (method === "socketRead")
286
+ return { eof: true };
287
+ if (method === "socketWatch" || method === "socketEnd")
288
+ return {};
289
+ throw new Error("Network connection lost.");
290
+ };
291
+ return transport(async (...args) => {
292
+ const method = args[1];
293
+ const io = [
294
+ "socketRead",
295
+ "socketWatch",
296
+ "socketWrite",
297
+ "socketEnd",
298
+ ].includes(method);
299
+ if (tlsFailed && io)
300
+ return failedOperation(method);
301
+ try {
302
+ return await secureCall(...args);
303
+ }
304
+ catch (error) {
305
+ if (!io)
306
+ throw error;
307
+ // Workers STARTTLS exposes transport/TLS failure as readable EOF,
308
+ // while writes fail. Never forward application bytes after a
309
+ // failed handshake; close still reaches the native resource.
310
+ tlsFailed = true;
311
+ return failedOperation(method);
312
+ }
313
+ }, id, host, "on", async () => {
241
314
  const info = await opened;
242
315
  await activeWrite;
243
316
  const hostname = options.expectedServerHostname ?? host;
244
- const result = (await call("WorkersCapacitor", "socketStartTls", {
245
- id,
246
- servername: hostname,
247
- }));
248
- if (result?.tlsEngine === "openssl-wasm")
249
- secureCall = await nativeTlsSession(call, id, hostname);
317
+ try {
318
+ const result = (await call("WorkersCapacitor", "socketStartTls", {
319
+ id,
320
+ servername: hostname,
321
+ }));
322
+ if (result?.tlsEngine === "openssl-wasm")
323
+ secureCall = await nativeTlsSession(call, id, hostname);
324
+ }
325
+ catch {
326
+ tlsFailed = true;
327
+ }
250
328
  return info;
251
- });
329
+ }, opened);
252
330
  },
253
331
  };
254
332
  return socket;
@@ -2,6 +2,7 @@ export declare function isInt32(value: unknown): value is number;
2
2
  export declare function isUint32(value: unknown): value is number;
3
3
  export declare function validateObject<T extends object>(value: T | null | undefined, name: string, options?: number): asserts value is T;
4
4
  export declare function validateObject(value: unknown, name: string, options?: number): asserts value is Record<string, unknown>;
5
+ export declare function validateInteger(value: unknown, name: string, min?: number, max?: number): asserts value is number;
5
6
  export declare function validateInt32(value: unknown, name: string, min?: number, max?: number): asserts value is number;
6
7
  export declare function validateUint32(value: unknown, name: string, positive?: boolean): asserts value is number;
7
8
  export declare function validateString(value: unknown, name: string): asserts value is string;
@@ -61,6 +61,14 @@ export function validateObject(value, name, options = kValidateObjectNone) {
61
61
  }
62
62
  }
63
63
  }
64
+ export function validateInteger(value, name, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
65
+ if (typeof value !== "number")
66
+ throw new ERR_INVALID_ARG_TYPE(name, "number", value);
67
+ if (!Number.isInteger(value))
68
+ throw new ERR_OUT_OF_RANGE(name, "an integer", value);
69
+ if (value < min || value > max)
70
+ throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
71
+ }
64
72
  export function validateInt32(value, name, min = -2147483648, max = 2147483647) {
65
73
  if (!isInt32(value)) {
66
74
  if (typeof value !== "number") {
@@ -0,0 +1,113 @@
1
+ export declare const config: Readonly<{
2
+ target_defaults: Readonly<{
3
+ default_configuration: "Release";
4
+ }>;
5
+ variables: Readonly<{
6
+ asan: 0;
7
+ clang: 1;
8
+ control_flow_guard: false;
9
+ coverage: false;
10
+ dcheck_always_on: 0;
11
+ debug_nghttp2: false;
12
+ debug_node: false;
13
+ enable_lto: false;
14
+ enable_pgo_generate: false;
15
+ enable_pgo_use: false;
16
+ error_on_warn: false;
17
+ force_dynamic_crt: 0;
18
+ gas_version: "";
19
+ host_arch: "x64";
20
+ icu_data_in: "";
21
+ icu_endianness: "l";
22
+ icu_gyp_path: "";
23
+ icu_path: "";
24
+ icu_small: false;
25
+ icu_ver_major: "";
26
+ is_debug: 0;
27
+ libdir: "lib";
28
+ llvm_version: "";
29
+ napi_build_version: "9";
30
+ node_byteorder: "little";
31
+ node_debug_lib: false;
32
+ node_enable_d8: false;
33
+ node_enable_v8_vtunejit: false;
34
+ node_enable_v8windbg: false;
35
+ node_fipsinstall: false;
36
+ node_install_corepack: false;
37
+ node_install_npm: false;
38
+ node_module_version: 127;
39
+ node_no_browser_globals: false;
40
+ node_prefix: "/usr/local";
41
+ node_quic: false;
42
+ node_release_urlbase: "";
43
+ node_section_ordering_info: "";
44
+ node_shared: false;
45
+ node_shared_ada: false;
46
+ node_shared_brotli: false;
47
+ node_shared_cares: false;
48
+ node_shared_gtest: false;
49
+ node_shared_hdr_histogram: false;
50
+ node_shared_http_parser: false;
51
+ node_shared_libuv: false;
52
+ node_shared_merve: false;
53
+ node_shared_nbytes: false;
54
+ node_shared_nghttp2: false;
55
+ node_shared_nghttp3: false;
56
+ node_shared_ngtcp2: false;
57
+ node_shared_openssl: false;
58
+ node_shared_simdjson: false;
59
+ node_shared_simdutf: false;
60
+ node_shared_sqlite: false;
61
+ node_shared_uvwasi: false;
62
+ node_shared_zlib: false;
63
+ node_shared_zstd: false;
64
+ node_tag: "";
65
+ node_target_type: "executable";
66
+ node_use_amaro: false;
67
+ node_use_bundled_v8: true;
68
+ node_use_node_code_cache: false;
69
+ node_use_node_snapshot: false;
70
+ node_use_openssl: true;
71
+ node_use_sqlite: false;
72
+ node_use_v8_platform: false;
73
+ node_with_ltcg: false;
74
+ node_without_node_options: true;
75
+ node_write_snapshot_as_array_literals: false;
76
+ openssl_is_fips: false;
77
+ openssl_quic: false;
78
+ ossfuzz: false;
79
+ shlib_suffix: "so";
80
+ single_executable_application: false;
81
+ suppress_all_error_on_warn: false;
82
+ target_arch: "x64";
83
+ ubsan: 0;
84
+ use_ccache_win: 0;
85
+ use_prefix_to_find_headers: false;
86
+ v8_enable_31bit_smis_on_64bit_arch: 0;
87
+ v8_enable_extensible_ro_snapshot: 0;
88
+ v8_enable_external_code_space: 0;
89
+ v8_enable_gdbjit: 0;
90
+ v8_enable_hugepage: 0;
91
+ v8_enable_i18n_support: 1;
92
+ v8_enable_inspector: 0;
93
+ v8_enable_javascript_promise_hooks: 0;
94
+ v8_enable_lite_mode: 0;
95
+ v8_enable_maglev: 1;
96
+ v8_enable_object_print: 0;
97
+ v8_enable_pointer_compression: 1;
98
+ v8_enable_pointer_compression_shared_cage: 1;
99
+ v8_enable_sandbox: 0;
100
+ v8_enable_shared_ro_heap: 1;
101
+ v8_enable_short_builtin_calls: 1;
102
+ v8_enable_v8_checks: 0;
103
+ v8_enable_wasm_simd256_revec: 0;
104
+ v8_enable_webassembly: 1;
105
+ v8_no_strict_aliasing: 1;
106
+ v8_optimized_debug: 1;
107
+ v8_promise_internal_field_count: 1;
108
+ v8_random_seed: 0;
109
+ v8_trace_maps: 0;
110
+ v8_use_siphash: 1;
111
+ want_separate_host_toolset: 0;
112
+ }>;
113
+ }>;
@@ -0,0 +1,115 @@
1
+ // Copyright (c) 2017-2026 Cloudflare, Inc. Apache-2.0.
2
+ // From workerd 5358e3d337336eaf696a48bc1563d808b10feba5 internal_process.ts.
3
+ export const config = Object.freeze({
4
+ target_defaults: Object.freeze({
5
+ default_configuration: "Release",
6
+ }),
7
+ variables: Object.freeze({
8
+ asan: 0,
9
+ clang: 1,
10
+ control_flow_guard: false,
11
+ coverage: false,
12
+ dcheck_always_on: 0,
13
+ debug_nghttp2: false,
14
+ debug_node: false,
15
+ enable_lto: false,
16
+ enable_pgo_generate: false,
17
+ enable_pgo_use: false,
18
+ error_on_warn: false,
19
+ force_dynamic_crt: 0,
20
+ gas_version: "",
21
+ host_arch: "x64",
22
+ icu_data_in: "",
23
+ icu_endianness: "l",
24
+ icu_gyp_path: "",
25
+ icu_path: "",
26
+ icu_small: false,
27
+ icu_ver_major: "",
28
+ is_debug: 0,
29
+ libdir: "lib",
30
+ llvm_version: "",
31
+ napi_build_version: "9",
32
+ node_byteorder: "little",
33
+ node_debug_lib: false,
34
+ node_enable_d8: false,
35
+ node_enable_v8_vtunejit: false,
36
+ node_enable_v8windbg: false,
37
+ node_fipsinstall: false,
38
+ node_install_corepack: false,
39
+ node_install_npm: false,
40
+ node_module_version: 127,
41
+ node_no_browser_globals: false,
42
+ node_prefix: "/usr/local",
43
+ node_quic: false,
44
+ node_release_urlbase: "",
45
+ node_section_ordering_info: "",
46
+ node_shared: false,
47
+ node_shared_ada: false,
48
+ node_shared_brotli: false,
49
+ node_shared_cares: false,
50
+ node_shared_gtest: false,
51
+ node_shared_hdr_histogram: false,
52
+ node_shared_http_parser: false,
53
+ node_shared_libuv: false,
54
+ node_shared_merve: false,
55
+ node_shared_nbytes: false,
56
+ node_shared_nghttp2: false,
57
+ node_shared_nghttp3: false,
58
+ node_shared_ngtcp2: false,
59
+ node_shared_openssl: false,
60
+ node_shared_simdjson: false,
61
+ node_shared_simdutf: false,
62
+ node_shared_sqlite: false,
63
+ node_shared_uvwasi: false,
64
+ node_shared_zlib: false,
65
+ node_shared_zstd: false,
66
+ node_tag: "",
67
+ node_target_type: "executable",
68
+ node_use_amaro: false,
69
+ node_use_bundled_v8: true,
70
+ node_use_node_code_cache: false,
71
+ node_use_node_snapshot: false,
72
+ node_use_openssl: true,
73
+ node_use_sqlite: false,
74
+ node_use_v8_platform: false,
75
+ node_with_ltcg: false,
76
+ node_without_node_options: true,
77
+ node_write_snapshot_as_array_literals: false,
78
+ openssl_is_fips: false,
79
+ openssl_quic: false,
80
+ ossfuzz: false,
81
+ shlib_suffix: "so",
82
+ single_executable_application: false,
83
+ suppress_all_error_on_warn: false,
84
+ target_arch: "x64",
85
+ ubsan: 0,
86
+ use_ccache_win: 0,
87
+ use_prefix_to_find_headers: false,
88
+ v8_enable_31bit_smis_on_64bit_arch: 0,
89
+ v8_enable_extensible_ro_snapshot: 0,
90
+ v8_enable_external_code_space: 0,
91
+ v8_enable_gdbjit: 0,
92
+ v8_enable_hugepage: 0,
93
+ v8_enable_i18n_support: 1,
94
+ v8_enable_inspector: 0,
95
+ v8_enable_javascript_promise_hooks: 0,
96
+ v8_enable_lite_mode: 0,
97
+ v8_enable_maglev: 1,
98
+ v8_enable_object_print: 0,
99
+ v8_enable_pointer_compression: 1,
100
+ v8_enable_pointer_compression_shared_cage: 1,
101
+ v8_enable_sandbox: 0,
102
+ v8_enable_shared_ro_heap: 1,
103
+ v8_enable_short_builtin_calls: 1,
104
+ v8_enable_v8_checks: 0,
105
+ v8_enable_wasm_simd256_revec: 0,
106
+ v8_enable_webassembly: 1,
107
+ v8_no_strict_aliasing: 1,
108
+ v8_optimized_debug: 1,
109
+ v8_promise_internal_field_count: 1,
110
+ v8_random_seed: 0,
111
+ v8_trace_maps: 0,
112
+ v8_use_siphash: 1,
113
+ want_separate_host_toolset: 0,
114
+ }),
115
+ });
@@ -0,0 +1,4 @@
1
+ export declare const currentDirectory: () => string;
2
+ export declare function registerDirectoryValidator(validate: (path: string) => string): void;
3
+ export declare function changeDirectory(path: unknown): void;
4
+ export declare function runWithDirectory<T>(callback: () => T): T;
@@ -0,0 +1,28 @@
1
+ import { AsyncLocalStorage } from "../async-hooks/index.js";
2
+ import { registerRequestScope } from "../../shared/request-scope.js";
3
+ const contexts = new AsyncLocalStorage();
4
+ const fallback = { path: "/bundle" };
5
+ const active = () => contexts.getStore() ?? fallback;
6
+ export const currentDirectory = () => active().path;
7
+ let validateDirectory = (path) => {
8
+ const normalized = new URL(path, "file://" + currentDirectory() + "/").pathname.replace(/\/$/, "") || "/";
9
+ if (!["/", "/tmp", "/bundle", "/dev"].includes(normalized))
10
+ throw Object.assign(new Error("no such file or directory"), {
11
+ code: "ENOENT",
12
+ syscall: "chdir",
13
+ path: normalized,
14
+ });
15
+ return normalized;
16
+ };
17
+ export function registerDirectoryValidator(validate) {
18
+ validateDirectory = validate;
19
+ }
20
+ export function changeDirectory(path) {
21
+ if (typeof path !== "string")
22
+ throw Object.assign(new TypeError('The "directory" argument must be of type string.'), { code: "ERR_INVALID_ARG_TYPE" });
23
+ active().path = validateDirectory(path);
24
+ }
25
+ export function runWithDirectory(callback) {
26
+ return contexts.run({ path: "/bundle" }, callback);
27
+ }
28
+ registerRequestScope(runWithDirectory);
@@ -0,0 +1,3 @@
1
+ import type { Buffer } from "node:buffer";
2
+ /** Workers loads into its own environment object; host OS files are inaccessible. */
3
+ export declare function loadEnvFile(path?: string | URL | Buffer): void;
@@ -0,0 +1,10 @@
1
+ import { readFileSync } from "../fs/index.js";
2
+ import { parseEnv } from "../util/core.js";
3
+ import process from "./state.js";
4
+ /** Workers loads into its own environment object; host OS files are inaccessible. */
5
+ export function loadEnvFile(path = ".env") {
6
+ if (path === null)
7
+ throw new TypeError("Cannot read properties of null (reading 'toString')");
8
+ const parsed = parseEnv(readFileSync(path instanceof URL ? path : path.toString(), "utf8"));
9
+ Object.assign(process.env, parsed);
10
+ }
@@ -1,18 +1,20 @@
1
+ import { currentDirectory as cwd, changeDirectory as chdir } from "./directory.js";
2
+ export { cwd, chdir };
1
3
  export { arch, pid, ppid, allowedNodeEnvironmentFlags, setSourceMapsEnabled, getSourceMapsSupport, ref, unref, setUncaughtExceptionCaptureCallback, hasUncaughtExceptionCaptureCallback, kill, binding, dlopen, exitCode, getActiveResourcesInfo, memoryUsage, resourceUsage, threadCpuUsage, cpuUsage, channel, connected, debugPort, noDeprecation, traceDeprecation, throwDeprecation, sourceMapsEnabled, execPath, permission, release, report, finalization, _rawDebug, moduleLoadList, _preload_modules, _linkedBinding, domain, _exiting, _getActiveRequests, _getActiveHandles, _kill, constrainedMemory, availableMemory, execve, _fatalException, _tickCallback, _debugProcess, _debugEnd, _startProfilerIdleNotifier, _stopProfilerIdleNotifier, send, uptime, getegid, getgid, getgroups, geteuid, getuid, setegid, setgid, seteuid, setuid, setgroups, initgroups, } from "./metadata.js";
2
- export * from "cf-workers-native:process-base";
4
+ export { argv, env, execArgv, exit, features, platform, title, umask, version, versions, } from "cf-workers-native:process-base";
3
5
  export { default } from "./state.js";
4
- export declare const on: (...args: any[]) => any;
5
- export declare const addListener: typeof on;
6
- export declare const once: (...args: any[]) => any;
7
- export declare const prependListener: (...args: any[]) => any;
8
- export declare const prependOnceListener: (...args: any[]) => any;
9
- export declare const off: (...args: any[]) => any;
10
- export declare const removeListener: typeof off;
11
- export declare const removeAllListeners: (...args: any[]) => any;
12
- export declare const emit: (...args: any[]) => any;
13
- export declare const listeners: (...args: any[]) => any;
14
- export declare function nextTick(callback: (...args: any[]) => void, ...args: any[]): void;
15
- export declare function emitWarning(warning: string | Error, options?: any, codeOrCtor?: any, maybeCtor?: any): void;
6
+ export declare const _events: any;
7
+ export declare const _eventsCount: any;
8
+ export declare const _maxListeners: any;
9
+ export declare const _channel: undefined, _disconnect: undefined, _handleQueue: undefined, _pendingMessage: undefined, _send: undefined;
10
+ export declare const argv0 = "workerd";
11
+ export declare const assert: (actual: unknown, message?: string | Error) => asserts actual;
12
+ import { config } from "./configuration.js";
13
+ import { loadEnvFile } from "./files.js";
14
+ export { config, loadEnvFile };
15
+ export { stdin, stdout, stderr, openStdin } from "./stdio.js";
16
+ import { nextTick, emitWarning } from "./scheduling.js";
17
+ export { nextTick, emitWarning };
16
18
  export declare const hrtime: ((time?: [number, number]) => [number, number]) & {
17
19
  bigint: () => bigint;
18
20
  };