cf-workers-native 0.1.4 → 0.1.5

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 (161) hide show
  1. package/dist/browser/documents/page-source.js +1 -1
  2. package/dist/browser/fetch/host-call.js +6 -1
  3. package/dist/browser/fetch/native-network.d.ts +1 -1
  4. package/dist/browser/fetch/relay.js +2 -0
  5. package/dist/browser/isolated/transport.js +3 -2
  6. package/dist/browser/request/index.js +3 -2
  7. package/dist/cloudflare/workers/worker-runtime.js +2 -1
  8. package/dist/compat/console/index.d.ts +35 -0
  9. package/dist/compat/console/index.js +92 -0
  10. package/dist/compat/crypto/LICENSE-3RD-PARTY.md +19 -0
  11. package/dist/compat/crypto/LICENSE-APACHE +177 -0
  12. package/dist/compat/crypto/LICENSE.emscripten +102 -0
  13. package/dist/compat/crypto/LICENSE.musl +193 -0
  14. package/dist/compat/crypto/LICENSE.openssl +177 -0
  15. package/dist/compat/crypto/asymmetric.d.ts +13 -0
  16. package/dist/compat/crypto/asymmetric.js +239 -0
  17. package/dist/compat/crypto/brorand.cjs +74 -0
  18. package/dist/compat/crypto/brorand.d.cts +6 -0
  19. package/dist/compat/crypto/certificate.d.ts +14 -0
  20. package/dist/compat/crypto/certificate.js +66 -0
  21. package/dist/compat/crypto/ecdh.d.ts +15 -0
  22. package/dist/compat/crypto/ecdh.js +109 -0
  23. package/dist/compat/crypto/hkdf.d.ts +2 -0
  24. package/dist/compat/crypto/hkdf.js +52 -0
  25. package/dist/compat/crypto/index.cjs +2 -0
  26. package/dist/compat/crypto/index.d.cts +2 -0
  27. package/dist/compat/crypto/index.d.ts +30 -0
  28. package/dist/compat/crypto/index.js +83 -0
  29. package/dist/compat/crypto/key-formats.d.ts +6 -0
  30. package/dist/compat/crypto/key-formats.js +120 -0
  31. package/dist/compat/crypto/key-state.d.ts +9 -0
  32. package/dist/compat/crypto/key-state.js +4 -0
  33. package/dist/compat/crypto/keys.d.ts +50 -0
  34. package/dist/compat/crypto/keys.js +209 -0
  35. package/dist/compat/crypto/metadata.d.ts +4 -0
  36. package/dist/compat/crypto/metadata.js +22 -0
  37. package/dist/compat/crypto/native-crypto.d.ts +68 -0
  38. package/dist/compat/crypto/native-crypto.js +569 -0
  39. package/dist/compat/crypto/prime.d.ts +19 -0
  40. package/dist/compat/crypto/prime.js +146 -0
  41. package/dist/compat/crypto/random.d.ts +7 -0
  42. package/dist/compat/crypto/random.js +123 -0
  43. package/dist/compat/crypto/rsa.d.ts +5 -0
  44. package/dist/compat/crypto/rsa.js +173 -0
  45. package/dist/compat/crypto/scrypt.d.ts +25 -0
  46. package/dist/compat/crypto/scrypt.js +150 -0
  47. package/dist/compat/crypto/sign-errors.d.ts +8 -0
  48. package/dist/compat/crypto/sign-errors.js +13 -0
  49. package/dist/compat/crypto/sign-handle.d.ts +22 -0
  50. package/dist/compat/crypto/sign-handle.js +105 -0
  51. package/dist/compat/crypto/signatures.d.ts +28 -0
  52. package/dist/compat/crypto/signatures.js +252 -0
  53. package/dist/compat/crypto/symmetric.d.ts +29 -0
  54. package/dist/compat/crypto/symmetric.js +104 -0
  55. package/dist/compat/crypto/validation.d.ts +3 -0
  56. package/dist/compat/crypto/validation.js +19 -0
  57. package/dist/compat/crypto/x509.d.ts +30 -0
  58. package/dist/compat/crypto/x509.js +406 -0
  59. package/dist/compat/events/errors.d.ts +8 -0
  60. package/dist/compat/events/errors.js +39 -0
  61. package/dist/compat/events/index.cjs +2 -0
  62. package/dist/compat/events/index.d.cts +2 -0
  63. package/dist/compat/events/index.d.ts +64 -0
  64. package/dist/compat/events/index.js +792 -0
  65. package/dist/compat/events/intrinsics.d.ts +1 -0
  66. package/dist/compat/events/intrinsics.js +2 -0
  67. package/dist/compat/fs/embedded.d.ts +85 -0
  68. package/dist/compat/fs/embedded.js +255 -0
  69. package/dist/compat/fs/index.d.ts +7 -84
  70. package/dist/compat/fs/index.js +218 -252
  71. package/dist/compat/fs/mode.d.ts +1 -0
  72. package/dist/compat/fs/mode.js +13 -0
  73. package/dist/compat/fs/promises/index.d.ts +1 -1
  74. package/dist/compat/fs/promises/index.js +1 -1
  75. package/dist/compat/fs/writable.d.ts +6 -0
  76. package/dist/compat/fs/writable.js +142 -0
  77. package/dist/compat/http/symbols.d.ts +5 -0
  78. package/dist/compat/http/symbols.js +9 -0
  79. package/dist/compat/http-common/index.d.ts +37 -0
  80. package/dist/compat/http-common/index.js +43 -0
  81. package/dist/compat/http-outgoing/index.d.ts +13 -0
  82. package/dist/compat/http-outgoing/index.js +32 -0
  83. package/dist/compat/http-server/index.d.ts +18 -0
  84. package/dist/compat/http-server/index.js +107 -0
  85. package/dist/compat/module/builtins.d.ts +1 -0
  86. package/dist/compat/module/builtins.js +101 -0
  87. package/dist/compat/module/index.d.ts +4 -2
  88. package/dist/compat/module/index.js +22 -17
  89. package/dist/compat/module/metadata.d.ts +44 -0
  90. package/dist/compat/module/metadata.js +127 -0
  91. package/dist/compat/net/internal-net.js +4 -0
  92. package/dist/compat/net/sockets.d.ts +5 -0
  93. package/dist/compat/net/sockets.js +74 -13
  94. package/dist/compat/process/index.cjs +2 -0
  95. package/dist/compat/process/index.d.cts +4 -0
  96. package/dist/compat/process/index.d.ts +18 -0
  97. package/dist/compat/process/index.js +140 -0
  98. package/dist/compat/process/metadata.d.ts +135 -0
  99. package/dist/compat/process/metadata.js +251 -0
  100. package/dist/compat/process/state.d.ts +4 -0
  101. package/dist/compat/process/state.js +4 -0
  102. package/dist/compat/stream-web/LICENSE +22 -0
  103. package/dist/compat/stream-web/ponyfill.d.ts +1 -1
  104. package/dist/compat/stream-web/ponyfill.js +2369 -1775
  105. package/dist/compat/stream-web/runtime.d.ts +1 -1
  106. package/dist/compat/stream-web/runtime.js +3 -2
  107. package/dist/compat/stream-wrap/LICENSE-3RD-PARTY.md +11 -0
  108. package/dist/compat/stream-wrap/LICENSE-APACHE +177 -0
  109. package/dist/compat/stream-wrap/index.d.ts +1 -0
  110. package/dist/compat/stream-wrap/index.js +1 -0
  111. package/dist/compat/tls/LICENSE-3RD-PARTY.md +11 -0
  112. package/dist/compat/tls/LICENSE-APACHE +177 -0
  113. package/dist/compat/tls/constants.d.ts +7 -0
  114. package/dist/compat/tls/constants.js +14 -0
  115. package/dist/compat/tls/errors.d.ts +35 -0
  116. package/dist/compat/tls/errors.js +68 -0
  117. package/dist/compat/tls/helpers.d.ts +9 -0
  118. package/dist/compat/tls/helpers.js +207 -0
  119. package/dist/compat/tls/index.d.ts +26 -0
  120. package/dist/compat/tls/index.js +50 -0
  121. package/dist/compat/tls/jsstream.d.ts +19 -0
  122. package/dist/compat/tls/jsstream.js +186 -0
  123. package/dist/compat/tls/native-session.d.ts +3 -0
  124. package/dist/compat/tls/native-session.js +187 -0
  125. package/dist/compat/tls/wrap.d.ts +65 -0
  126. package/dist/compat/tls/wrap.js +544 -0
  127. package/dist/compat/tls-wrap/LICENSE-3RD-PARTY.md +11 -0
  128. package/dist/compat/tls-wrap/LICENSE-APACHE +177 -0
  129. package/dist/compat/tls-wrap/index.d.ts +7 -0
  130. package/dist/compat/tls-wrap/index.js +3 -0
  131. package/dist/compat/util/index.js +43 -1
  132. package/dist/compat/util/types/index.d.ts +3 -0
  133. package/dist/compat/util/types/index.js +5 -0
  134. package/dist/compat/zlib/LICENSE.brotli +19 -0
  135. package/dist/compat/zlib/LICENSE.emscripten +102 -0
  136. package/dist/compat/zlib/LICENSE.musl +193 -0
  137. package/dist/compat/zlib/LICENSE.zstd +30 -0
  138. package/dist/compat/zlib/compression.d.ts +55 -0
  139. package/dist/compat/zlib/compression.js +259 -0
  140. package/dist/compat/zlib/constants.d.ts +172 -0
  141. package/dist/compat/zlib/constants.js +173 -0
  142. package/dist/compat/zlib/index.d.ts +180 -0
  143. package/dist/compat/zlib/index.js +177 -0
  144. package/dist/compat/zlib/native-codecs.d.ts +17 -0
  145. package/dist/compat/zlib/native-codecs.js +168 -0
  146. package/dist/shared/globals/inject.d.ts +2 -1
  147. package/dist/shared/globals/inject.js +2 -1
  148. package/dist/shared/globals/runtime.d.ts +1 -2
  149. package/dist/shared/globals/runtime.js +1 -2
  150. package/dist/shared/request-scope.d.ts +4 -0
  151. package/dist/shared/request-scope.js +11 -0
  152. package/dist/tooling/async.js +36 -14
  153. package/dist/tooling/shared.d.ts +1 -0
  154. package/dist/tooling/shared.js +20 -1
  155. package/dist/tooling/vite.js +4 -3
  156. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +56 -8
  157. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersCapacitorPlugin.java +4 -2
  158. package/native/ios/NetworkBridge.swift +11 -1
  159. package/native/ios/SocketBridge.swift +37 -2
  160. package/native/ios/WorkersCapacitorPlugin.swift +4 -0
  161. package/package.json +3 -1
@@ -0,0 +1,251 @@
1
+ // Copyright (c) 2017-2022 Cloudflare, Inc. Apache-2.0.
2
+ // Adapted from pinned workerd public_process.ts; these are Workers stubs, not host OS introspection.
3
+ import { NodeError } from "../net/error-base.js";
4
+ class ERR_METHOD_NOT_IMPLEMENTED extends NodeError {
5
+ constructor(name) {
6
+ super("ERR_METHOD_NOT_IMPLEMENTED", `The ${name} method is not implemented`);
7
+ }
8
+ }
9
+ export class ERR_EPERM extends NodeError {
10
+ path;
11
+ syscall;
12
+ errno;
13
+ constructor(options) {
14
+ const message = options.path
15
+ ? `operation not permitted, ${options.syscall} '${options.path}'`
16
+ : "operation not permitted";
17
+ super("EPERM", message);
18
+ this.syscall = options.syscall;
19
+ if (options.path !== undefined) {
20
+ this.path = options.path;
21
+ }
22
+ this.errno = options.errno ?? 1; // EPERM
23
+ }
24
+ }
25
+ export const arch = "x64";
26
+ // For simplicity and polyfill expectations, we assign pid 1 to the process and pid 0 to the "parent".
27
+ export const pid = 1;
28
+ export const ppid = 0;
29
+ export const allowedNodeEnvironmentFlags = new Set();
30
+ export function setSourceMapsEnabled(_enabled, _options) {
31
+ // no-op since we do not support disabling source maps
32
+ }
33
+ export function getSourceMapsSupport() {
34
+ return {
35
+ enabled: false,
36
+ nodeModules: false,
37
+ generatedCode: false,
38
+ };
39
+ }
40
+ export function ref() {
41
+ // no-op
42
+ }
43
+ export function unref() {
44
+ // no-op
45
+ }
46
+ export function setUncaughtExceptionCaptureCallback(_fn) {
47
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.setUncaughtExceptionCaptureCallback");
48
+ }
49
+ export function hasUncaughtExceptionCaptureCallback() {
50
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.hasUncaughtExceptionCaptureCallback");
51
+ }
52
+ export function kill(_pid, _signal) {
53
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.kill");
54
+ }
55
+ export function binding(_name) {
56
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.binding");
57
+ }
58
+ export function dlopen(_module, _filename, _flags) {
59
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.dlopen");
60
+ }
61
+ export const exitCode = undefined;
62
+ export function getActiveResourcesInfo() {
63
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.getActiveResourcesInfo");
64
+ }
65
+ export function memoryUsage() {
66
+ return {
67
+ rss: 0,
68
+ heapTotal: 0,
69
+ heapUsed: 0,
70
+ external: 0,
71
+ arrayBuffers: 0,
72
+ };
73
+ }
74
+ export function resourceUsage() {
75
+ return {
76
+ userCPUTime: 0,
77
+ systemCPUTime: 0,
78
+ maxRSS: 0,
79
+ sharedMemorySize: 0,
80
+ unsharedDataSize: 0,
81
+ unsharedStackSize: 0,
82
+ minorPageFault: 0,
83
+ majorPageFault: 0,
84
+ swappedOut: 0,
85
+ fsRead: 0,
86
+ fsWrite: 0,
87
+ ipcSent: 0,
88
+ ipcReceived: 0,
89
+ signalsCount: 0,
90
+ voluntaryContextSwitches: 0,
91
+ involuntaryContextSwitches: 0,
92
+ };
93
+ }
94
+ export function threadCpuUsage() {
95
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.threadCpuUsage");
96
+ }
97
+ export function cpuUsage(_previousValue) {
98
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.cpuUsage");
99
+ }
100
+ // Properties and constants
101
+ export const channel = null;
102
+ export const connected = false;
103
+ export const debugPort = 0; // may be implemented to align with inspector in future
104
+ export const noDeprecation = false;
105
+ export const traceDeprecation = false;
106
+ export const throwDeprecation = false;
107
+ export const sourceMapsEnabled = false;
108
+ export const execPath = "";
109
+ export const permission = {
110
+ has: () => {
111
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.permission.has");
112
+ },
113
+ };
114
+ export const release = {
115
+ name: "node",
116
+ lts: true,
117
+ sourceUrl: "",
118
+ headersUrl: "",
119
+ };
120
+ export const report = {
121
+ compact: false,
122
+ directory: "",
123
+ filename: "",
124
+ getReport: () => {
125
+ // We do not intend to implement process.report in workerd, but there
126
+ // are some modules in the ecosystem that call it expecting it to exist and
127
+ // not throw. Returning an empty object for now to satisfy that use case.
128
+ return {};
129
+ },
130
+ reportOnFatalError: false,
131
+ reportOnSignal: false,
132
+ reportOnUncaughtException: false,
133
+ excludeNetwork: false,
134
+ excludeEnv: false,
135
+ signal: "SIGUSR2",
136
+ writeReport: () => {
137
+ // In this case, there's an expectation that the function will produce
138
+ // a report on disk and return the filename. Since we do not intend
139
+ // to implement this API in workerd, we throw to indicate that.
140
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.report.writeReport");
141
+ },
142
+ };
143
+ export const finalization = {
144
+ register: () => {
145
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.finalization.register");
146
+ },
147
+ registerBeforeExit: () => {
148
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.finalization.registerBeforeExit");
149
+ },
150
+ unregister: () => {
151
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.finalization.unregister");
152
+ },
153
+ };
154
+ // Additional undocumented APIs
155
+ export function _rawDebug(...args) {
156
+ console.log(...args);
157
+ }
158
+ export const moduleLoadList = [];
159
+ export const _preload_modules = [];
160
+ export function _linkedBinding(_name) {
161
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process._linkedBinding");
162
+ }
163
+ export const domain = null;
164
+ export const _exiting = false;
165
+ export function _getActiveRequests() {
166
+ return [];
167
+ }
168
+ export function _getActiveHandles() {
169
+ return [];
170
+ }
171
+ export function _kill(_pid, _signal) {
172
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process._kill");
173
+ }
174
+ export function constrainedMemory() {
175
+ return 0;
176
+ }
177
+ export function availableMemory() {
178
+ // This may be implemented in future, for now this matches unenv
179
+ return 0;
180
+ }
181
+ export function execve(_file, _args, _env) {
182
+ throw new ERR_METHOD_NOT_IMPLEMENTED("process.execve");
183
+ }
184
+ export function _fatalException(_err) {
185
+ return false;
186
+ }
187
+ export function _tickCallback() {
188
+ // no-op
189
+ }
190
+ export function _debugProcess(_pid) {
191
+ // no-op
192
+ }
193
+ export function _debugEnd() {
194
+ // no-op
195
+ }
196
+ export function _startProfilerIdleNotifier() {
197
+ // no-op
198
+ }
199
+ export function _stopProfilerIdleNotifier() {
200
+ // no-op
201
+ }
202
+ export function send(_message, _sendHandle) {
203
+ return false;
204
+ }
205
+ export function uptime() {
206
+ return 0;
207
+ }
208
+ // On the virtual filesystem, we only support group 0
209
+ export function getegid() {
210
+ return 0;
211
+ }
212
+ export function getgid() {
213
+ return 0;
214
+ }
215
+ export function getgroups() {
216
+ return [0];
217
+ }
218
+ // On the virtual filesystem, we only support user 0
219
+ export function geteuid() {
220
+ return 0;
221
+ }
222
+ export function getuid() {
223
+ return 0;
224
+ }
225
+ // We support group 0 but no others, with the virtual filesystem.
226
+ export function setegid(id) {
227
+ if (id !== 0)
228
+ throw new ERR_EPERM({ syscall: "setegid" });
229
+ }
230
+ // We support group 0 but no others, with the virtual filesystem.
231
+ export function setgid(id) {
232
+ if (id !== 0)
233
+ throw new ERR_EPERM({ syscall: "setgid" });
234
+ }
235
+ // We support group 0 but no others, with the virtual filesystem.
236
+ export function seteuid(id) {
237
+ if (id !== 0)
238
+ throw new ERR_EPERM({ syscall: "seteuid" });
239
+ }
240
+ // We support group 0 but no others, with the virtual filesystem.
241
+ export function setuid(id) {
242
+ if (id !== 0)
243
+ throw new ERR_EPERM({ syscall: "setuid" });
244
+ }
245
+ // We don't support setting or initializing arbitrary groups on the virtual filesystem.
246
+ export function setgroups(_groups) {
247
+ throw new ERR_EPERM({ syscall: "setgroups" });
248
+ }
249
+ export function initgroups(_user, _extractGroup) {
250
+ throw new ERR_EPERM({ syscall: "initgroups" });
251
+ }
@@ -0,0 +1,4 @@
1
+ declare const process: {
2
+ [x: string]: any;
3
+ };
4
+ export default process;
@@ -0,0 +1,4 @@
1
+ import original from "cf-workers-native:process-base";
2
+ // A dependency leaf keeps process.env available during events/util cycles.
3
+ const process = { ...original };
4
+ export default process;
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Mattias Buelens
4
+ Copyright (c) 2016 Diwank Singh Tomer
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -1 +1 @@
1
- export * from "web-streams-polyfill";
1
+ export * from "./workers-ponyfill.js";