cf-workers-native 0.1.4 → 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.
- package/README.md +2 -2
- package/dist/browser/documents/page-source.js +1 -1
- package/dist/browser/fetch/host-call.js +6 -1
- package/dist/browser/fetch/native-network.d.ts +1 -1
- package/dist/browser/fetch/relay.js +2 -0
- package/dist/browser/headers/index.d.ts +2 -0
- package/dist/browser/headers/index.js +5 -0
- package/dist/browser/isolated/transport.js +3 -2
- package/dist/browser/request/index.js +3 -2
- package/dist/browser/response/index.d.ts +2 -0
- package/dist/browser/response/index.js +11 -3
- package/dist/browser/structured-clone/index.d.ts +3 -0
- package/dist/browser/structured-clone/index.js +75 -7
- package/dist/browser/websocket/attachment-size.d.ts +3 -0
- package/dist/browser/websocket/attachment-size.js +336 -0
- package/dist/browser/websocket/brand.d.ts +4 -0
- package/dist/browser/websocket/brand.js +16 -0
- package/dist/browser/websocket/close-event.d.ts +7 -0
- package/dist/browser/websocket/close-event.js +30 -0
- package/dist/browser/websocket/compression.d.ts +5 -0
- package/dist/browser/websocket/compression.js +124 -0
- package/dist/browser/websocket/conversion.d.ts +2 -0
- package/dist/browser/websocket/conversion.js +13 -0
- package/dist/browser/websocket/endpoint.d.ts +39 -0
- package/dist/browser/websocket/endpoint.js +379 -0
- package/dist/browser/websocket/frames.d.ts +21 -0
- package/dist/browser/websocket/frames.js +121 -0
- package/dist/browser/websocket/native.d.ts +14 -0
- package/dist/browser/websocket/native.js +226 -0
- package/dist/cloudflare/apis/cloudflare-node/index.js +11 -23
- package/dist/cloudflare/workers/worker-runtime.js +2 -1
- package/dist/compat/console/index.d.ts +35 -0
- package/dist/compat/console/index.js +92 -0
- package/dist/compat/crypto/LICENSE-3RD-PARTY.md +39 -0
- package/dist/compat/crypto/LICENSE-APACHE +177 -0
- package/dist/compat/crypto/LICENSE.boringssl +238 -0
- package/dist/compat/crypto/LICENSE.emscripten +102 -0
- package/dist/compat/crypto/LICENSE.musl +193 -0
- package/dist/compat/crypto/LICENSE.ncrypto +21 -0
- package/dist/compat/crypto/LICENSE.openssl +177 -0
- package/dist/compat/crypto/asymmetric.d.ts +13 -0
- package/dist/compat/crypto/asymmetric.js +312 -0
- package/dist/compat/crypto/brorand.cjs +74 -0
- package/dist/compat/crypto/brorand.d.cts +6 -0
- package/dist/compat/crypto/certificate.d.ts +14 -0
- package/dist/compat/crypto/certificate.js +66 -0
- package/dist/compat/crypto/cipher-handle.d.ts +27 -0
- package/dist/compat/crypto/cipher-handle.js +239 -0
- package/dist/compat/crypto/cipher-info.d.ts +12 -0
- package/dist/compat/crypto/cipher-info.js +324 -0
- package/dist/compat/crypto/constants.d.ts +62 -0
- package/dist/compat/crypto/constants.js +68 -0
- package/dist/compat/crypto/dh-handle.d.ts +17 -0
- package/dist/compat/crypto/dh-handle.js +180 -0
- package/dist/compat/crypto/dh.d.ts +53 -0
- package/dist/compat/crypto/dh.js +138 -0
- package/dist/compat/crypto/digest-stream.d.ts +15 -0
- package/dist/compat/crypto/digest-stream.js +213 -0
- package/dist/compat/crypto/digests.d.ts +3 -0
- package/dist/compat/crypto/digests.js +32 -0
- package/dist/compat/crypto/ecdh.d.ts +25 -0
- package/dist/compat/crypto/ecdh.js +109 -0
- package/dist/compat/crypto/hash-handle.d.ts +23 -0
- package/dist/compat/crypto/hash-handle.js +70 -0
- package/dist/compat/crypto/hash.d.ts +37 -0
- package/dist/compat/crypto/hash.js +218 -0
- package/dist/compat/crypto/hkdf.d.ts +2 -0
- package/dist/compat/crypto/hkdf.js +78 -0
- package/dist/compat/crypto/index.cjs +2 -0
- package/dist/compat/crypto/index.d.cts +169 -0
- package/dist/compat/crypto/index.d.ts +213 -0
- package/dist/compat/crypto/index.js +96 -0
- package/dist/compat/crypto/key-errors.d.ts +10 -0
- package/dist/compat/crypto/key-errors.js +17 -0
- package/dist/compat/crypto/key-export.d.ts +8 -0
- package/dist/compat/crypto/key-export.js +49 -0
- package/dist/compat/crypto/key-formats.d.ts +7 -0
- package/dist/compat/crypto/key-formats.js +251 -0
- package/dist/compat/crypto/key-options.d.ts +1 -0
- package/dist/compat/crypto/key-options.js +74 -0
- package/dist/compat/crypto/key-state.d.ts +10 -0
- package/dist/compat/crypto/key-state.js +4 -0
- package/dist/compat/crypto/keys.d.ts +58 -0
- package/dist/compat/crypto/keys.js +278 -0
- package/dist/compat/crypto/metadata.d.ts +13 -0
- package/dist/compat/crypto/metadata.js +109 -0
- package/dist/compat/crypto/native-cipher.d.ts +17 -0
- package/dist/compat/crypto/native-cipher.js +192 -0
- package/dist/compat/crypto/native-crypto.d.ts +81 -0
- package/dist/compat/crypto/native-crypto.js +681 -0
- package/dist/compat/crypto/pbkdf2-handle.d.ts +4 -0
- package/dist/compat/crypto/pbkdf2-handle.js +26 -0
- package/dist/compat/crypto/pbkdf2.d.ts +5 -0
- package/dist/compat/crypto/pbkdf2.js +60 -0
- package/dist/compat/crypto/prime.d.ts +19 -0
- package/dist/compat/crypto/prime.js +146 -0
- package/dist/compat/crypto/random.d.ts +18 -0
- package/dist/compat/crypto/random.js +203 -0
- package/dist/compat/crypto/rsa.d.ts +21 -0
- package/dist/compat/crypto/rsa.js +177 -0
- package/dist/compat/crypto/scrypt.d.ts +25 -0
- package/dist/compat/crypto/scrypt.js +152 -0
- package/dist/compat/crypto/sign-errors.d.ts +8 -0
- package/dist/compat/crypto/sign-errors.js +13 -0
- package/dist/compat/crypto/sign-handle.d.ts +22 -0
- package/dist/compat/crypto/sign-handle.js +149 -0
- package/dist/compat/crypto/signatures.d.ts +34 -0
- package/dist/compat/crypto/signatures.js +252 -0
- package/dist/compat/crypto/subtle-digest.d.ts +1 -0
- package/dist/compat/crypto/subtle-digest.js +56 -0
- package/dist/compat/crypto/symmetric.d.ts +45 -0
- package/dist/compat/crypto/symmetric.js +239 -0
- package/dist/compat/crypto/validation.d.ts +7 -0
- package/dist/compat/crypto/validation.js +46 -0
- package/dist/compat/crypto/webcrypto.d.ts +13 -0
- package/dist/compat/crypto/webcrypto.js +51 -0
- package/dist/compat/crypto/x509.d.ts +30 -0
- package/dist/compat/crypto/x509.js +407 -0
- package/dist/compat/events/errors.d.ts +8 -0
- package/dist/compat/events/errors.js +39 -0
- package/dist/compat/events/index.cjs +2 -0
- package/dist/compat/events/index.d.cts +2 -0
- package/dist/compat/events/index.d.ts +64 -0
- package/dist/compat/events/index.js +792 -0
- package/dist/compat/events/intrinsics.d.ts +1 -0
- package/dist/compat/events/intrinsics.js +2 -0
- package/dist/compat/fs/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/fs/LICENSE-APACHE +177 -0
- package/dist/compat/fs/directory-backend.d.ts +6 -0
- package/dist/compat/fs/directory-backend.js +51 -0
- package/dist/compat/fs/directory.d.ts +37 -0
- package/dist/compat/fs/directory.js +137 -0
- package/dist/compat/fs/embedded.d.ts +85 -0
- package/dist/compat/fs/embedded.js +260 -0
- package/dist/compat/fs/file-handle.d.ts +75 -0
- package/dist/compat/fs/file-handle.js +226 -0
- package/dist/compat/fs/glob-internal.d.ts +15 -0
- package/dist/compat/fs/glob-internal.js +417 -0
- package/dist/compat/fs/glob.d.ts +10 -0
- package/dist/compat/fs/glob.js +71 -0
- package/dist/compat/fs/index.d.ts +8 -82
- package/dist/compat/fs/index.js +736 -238
- package/dist/compat/fs/io-validation.d.ts +14 -0
- package/dist/compat/fs/io-validation.js +130 -0
- package/dist/compat/fs/io.d.ts +1 -0
- package/dist/compat/fs/io.js +282 -0
- package/dist/compat/fs/mode.d.ts +1 -0
- package/dist/compat/fs/mode.js +13 -0
- package/dist/compat/fs/promises/index.d.ts +3 -1
- package/dist/compat/fs/promises/index.js +1 -1
- package/dist/compat/fs/public-types.d.ts +120 -0
- package/dist/compat/fs/public-types.js +1 -0
- package/dist/compat/fs/stream-errors.d.ts +6 -0
- package/dist/compat/fs/stream-errors.js +8 -0
- package/dist/compat/fs/stream-utils.d.ts +16 -0
- package/dist/compat/fs/stream-utils.js +29 -0
- package/dist/compat/fs/streams.d.ts +104 -0
- package/dist/compat/fs/streams.js +794 -0
- package/dist/compat/fs/writable.d.ts +14 -0
- package/dist/compat/fs/writable.js +532 -0
- package/dist/compat/http/index.d.ts +11 -28
- package/dist/compat/http/index.js +81 -125
- package/dist/compat/http/server-options.d.ts +1 -0
- package/dist/compat/http/server-options.js +87 -0
- package/dist/compat/http/symbols.d.ts +5 -0
- package/dist/compat/http/symbols.js +9 -0
- package/dist/compat/http/unique-headers.d.ts +1 -0
- package/dist/compat/http/unique-headers.js +21 -0
- package/dist/compat/http-common/index.d.ts +37 -0
- package/dist/compat/http-common/index.js +43 -0
- package/dist/compat/http-outgoing/index.d.ts +14 -0
- package/dist/compat/http-outgoing/index.js +17 -0
- package/dist/compat/http-server/index.d.ts +18 -0
- package/dist/compat/http-server/index.js +26 -0
- package/dist/compat/https/index.d.ts +4 -2
- package/dist/compat/module/builtins.d.ts +1 -0
- package/dist/compat/module/builtins.js +101 -0
- package/dist/compat/module/index.d.ts +4 -2
- package/dist/compat/module/index.js +22 -17
- package/dist/compat/module/metadata.d.ts +44 -0
- package/dist/compat/module/metadata.js +127 -0
- package/dist/compat/net/internal-net.js +4 -0
- package/dist/compat/net/sockets.d.ts +5 -0
- package/dist/compat/net/sockets.js +153 -14
- package/dist/compat/net/validators.d.ts +1 -0
- package/dist/compat/net/validators.js +8 -0
- package/dist/compat/process/configuration.d.ts +113 -0
- package/dist/compat/process/configuration.js +115 -0
- package/dist/compat/process/directory.d.ts +4 -0
- package/dist/compat/process/directory.js +28 -0
- package/dist/compat/process/files.d.ts +3 -0
- package/dist/compat/process/files.js +10 -0
- package/dist/compat/process/index.cjs +2 -0
- package/dist/compat/process/index.d.cts +4 -0
- package/dist/compat/process/index.d.ts +20 -0
- package/dist/compat/process/index.js +113 -0
- package/dist/compat/process/metadata.d.ts +135 -0
- package/dist/compat/process/metadata.js +251 -0
- package/dist/compat/process/scheduling.d.ts +2 -0
- package/dist/compat/process/scheduling.js +60 -0
- package/dist/compat/process/state.d.ts +4 -0
- package/dist/compat/process/state.js +5 -0
- package/dist/compat/process/stdio.d.ts +18 -0
- package/dist/compat/process/stdio.js +66 -0
- package/dist/compat/stream/destroy.d.ts +1 -0
- package/dist/compat/stream/destroy.js +21 -1
- package/dist/compat/stream/readable.js +10 -2
- package/dist/compat/stream-web/LICENSE +22 -0
- package/dist/compat/stream-web/ponyfill.d.ts +1 -1
- package/dist/compat/stream-web/ponyfill.js +2369 -1775
- package/dist/compat/stream-web/runtime.d.ts +1 -1
- package/dist/compat/stream-web/runtime.js +3 -2
- package/dist/compat/stream-wrap/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/stream-wrap/LICENSE-APACHE +177 -0
- package/dist/compat/stream-wrap/index.d.ts +1 -0
- package/dist/compat/stream-wrap/index.js +1 -0
- package/dist/compat/tls/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/tls/LICENSE-APACHE +177 -0
- package/dist/compat/tls/constants.d.ts +7 -0
- package/dist/compat/tls/constants.js +14 -0
- package/dist/compat/tls/errors.d.ts +35 -0
- package/dist/compat/tls/errors.js +68 -0
- package/dist/compat/tls/helpers.d.ts +9 -0
- package/dist/compat/tls/helpers.js +207 -0
- package/dist/compat/tls/index.d.ts +26 -0
- package/dist/compat/tls/index.js +50 -0
- package/dist/compat/tls/jsstream.d.ts +19 -0
- package/dist/compat/tls/jsstream.js +196 -0
- package/dist/compat/tls/native-session.d.ts +3 -0
- package/dist/compat/tls/native-session.js +187 -0
- package/dist/compat/tls/wrap.d.ts +65 -0
- package/dist/compat/tls/wrap.js +541 -0
- package/dist/compat/tls-wrap/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/tls-wrap/LICENSE-APACHE +177 -0
- package/dist/compat/tls-wrap/index.d.ts +7 -0
- package/dist/compat/tls-wrap/index.js +3 -0
- package/dist/compat/util/index.js +43 -1
- package/dist/compat/util/inspect.js +5 -1
- package/dist/compat/util/types/index.d.ts +3 -0
- package/dist/compat/util/types/index.js +5 -0
- package/dist/compat/zlib/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/zlib/LICENSE-APACHE +177 -0
- package/dist/compat/zlib/LICENSE.brotli +19 -0
- package/dist/compat/zlib/LICENSE.emscripten +102 -0
- package/dist/compat/zlib/LICENSE.musl +193 -0
- package/dist/compat/zlib/LICENSE.zlib +22 -0
- package/dist/compat/zlib/LICENSE.zstd +30 -0
- package/dist/compat/zlib/classic-base.cjs +600 -0
- package/dist/compat/zlib/classic-base.d.cts +39 -0
- package/dist/compat/zlib/classic-binding.d.ts +28 -0
- package/dist/compat/zlib/classic-binding.js +105 -0
- package/dist/compat/zlib/classic.d.ts +44 -0
- package/dist/compat/zlib/classic.js +199 -0
- package/dist/compat/zlib/codec-binding.d.ts +33 -0
- package/dist/compat/zlib/codec-binding.js +141 -0
- package/dist/compat/zlib/compression.d.ts +26 -0
- package/dist/compat/zlib/compression.js +170 -0
- package/dist/compat/zlib/constants.d.ts +172 -0
- package/dist/compat/zlib/constants.js +173 -0
- package/dist/compat/zlib/errors.d.ts +21 -0
- package/dist/compat/zlib/errors.js +32 -0
- package/dist/compat/zlib/index.d.ts +544 -0
- package/dist/compat/zlib/index.js +194 -0
- package/dist/compat/zlib/input.d.ts +16 -0
- package/dist/compat/zlib/input.js +132 -0
- package/dist/compat/zlib/native-codecs.d.ts +24 -0
- package/dist/compat/zlib/native-codecs.js +180 -0
- package/dist/compat/zlib/native-zlib.d.ts +5 -0
- package/dist/compat/zlib/native-zlib.js +52 -0
- package/dist/compat/zlib/public-types.d.ts +48 -0
- package/dist/compat/zlib/public-types.js +1 -0
- package/dist/compat/zlib/validators.d.ts +3 -0
- package/dist/compat/zlib/validators.js +18 -0
- package/dist/shared/buffer-source.d.ts +5 -0
- package/dist/shared/buffer-source.js +70 -0
- package/dist/shared/globals/inject.d.ts +2 -1
- package/dist/shared/globals/inject.js +2 -1
- package/dist/shared/globals/platform.d.ts +8 -0
- package/dist/shared/globals/platform.js +1 -0
- package/dist/shared/globals/runtime.d.ts +1 -2
- package/dist/shared/globals/runtime.js +1 -2
- package/dist/shared/globals/web.js +5 -0
- package/dist/shared/request-context.d.ts +2 -0
- package/dist/shared/request-context.js +11 -0
- package/dist/shared/request-scope.d.ts +4 -0
- package/dist/shared/request-scope.js +14 -0
- package/dist/tooling/async.js +36 -14
- package/dist/tooling/shared.d.ts +1 -0
- package/dist/tooling/shared.js +26 -1
- package/dist/tooling/vite.js +8 -3
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +92 -13
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersCapacitorPlugin.java +4 -2
- package/native/ios/NetworkBridge.swift +11 -1
- package/native/ios/SocketBridge.swift +37 -2
- package/native/ios/WorkersCapacitorPlugin.swift +4 -0
- package/package.json +4 -2
package/dist/tooling/shared.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import stdlib from "node-stdlib-browser";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
3
4
|
export const configuredPath = fileURLToPath(new URL("../configured.js", import.meta.url));
|
|
4
5
|
export const transportPath = fileURLToPath(new URL("../browser/isolated/transport.js", import.meta.url));
|
|
5
6
|
export const globalsPath = fileURLToPath(new URL("../shared/globals/index.js", import.meta.url));
|
|
6
7
|
export const networkRelayPath = fileURLToPath(new URL("../browser/fetch/relay.js", import.meta.url));
|
|
7
8
|
export const globalsInstallPath = fileURLToPath(new URL("../shared/globals/install.js", import.meta.url));
|
|
8
9
|
export const nodeGlobalsInstallPath = fileURLToPath(new URL("../shared/globals/node-install.js", import.meta.url));
|
|
10
|
+
export const processStatePath = fileURLToPath(new URL("../compat/process/state.js", import.meta.url));
|
|
9
11
|
export const nodeCompatPath = (name) => fileURLToPath(new URL(`../compat/${name}/index.js`, import.meta.url));
|
|
10
12
|
const workersModulePath = (name) => fileURLToPath(new URL(`../cloudflare/apis/${name}/index.js`, import.meta.url));
|
|
11
13
|
// A compat module reusing a CommonJS polyfill imports the concrete package
|
|
@@ -15,6 +17,16 @@ const polyfill = (specifier) => fileURLToPath(import.meta.resolve(specifier));
|
|
|
15
17
|
// One entry per builtin; subpaths precede parent aliases when expanded.
|
|
16
18
|
// The optional third path is the CommonJS constructor entry.
|
|
17
19
|
const builtins = [
|
|
20
|
+
["_http_common", "http-common/index.js"],
|
|
21
|
+
["_http_outgoing", "http-outgoing/index.js"],
|
|
22
|
+
["_http_server", "http-server/index.js"],
|
|
23
|
+
["zlib", "zlib/index.js"],
|
|
24
|
+
["crypto", "crypto/index.js", "crypto/index.cjs"],
|
|
25
|
+
["console", "console/index.js"],
|
|
26
|
+
["sys", "util/index.js"],
|
|
27
|
+
["util/types", "util/types/index.js"],
|
|
28
|
+
["events", "events/index.js", "events/index.cjs"],
|
|
29
|
+
["process", "process/index.js", "process/index.cjs"],
|
|
18
30
|
["punycode", "punycode/index.js"],
|
|
19
31
|
["child_process", "child-process/index.js"],
|
|
20
32
|
["cluster", "cluster/index.js"],
|
|
@@ -46,6 +58,9 @@ const builtins = [
|
|
|
46
58
|
["tty", "tty/index.js"],
|
|
47
59
|
["url", "url/index.js"],
|
|
48
60
|
["diagnostics_channel", "diagnostics-channel/index.js"],
|
|
61
|
+
["tls", "tls/index.js"],
|
|
62
|
+
["_tls_wrap", "tls-wrap/index.js"],
|
|
63
|
+
["_stream_wrap", "stream-wrap/index.js"],
|
|
49
64
|
["_tls_common", "tls-common/index.js"],
|
|
50
65
|
["async_hooks", "async-hooks/index.js"],
|
|
51
66
|
["timers/promises", "timers/promises.js", "timers/promises.cjs"],
|
|
@@ -95,8 +110,13 @@ function builtinAliases(commonJS = false) {
|
|
|
95
110
|
}
|
|
96
111
|
export function compatibilityAliases() {
|
|
97
112
|
return {
|
|
98
|
-
"process/":
|
|
113
|
+
"process/": nodeCompatPath("process"),
|
|
114
|
+
// Preserve brorand's browser crypto:false branch across Vite aliases.
|
|
115
|
+
brorand: fileURLToPath(new URL("../compat/crypto/brorand.cjs", import.meta.url)),
|
|
116
|
+
"cf-workers-native:process-base": createRequire(import.meta.url).resolve(stdlib.process),
|
|
99
117
|
"cloudflare:node": workersModulePath("cloudflare-node"),
|
|
118
|
+
"cf-workers-native:response": fileURLToPath(new URL("../browser/response/index.js", import.meta.url)),
|
|
119
|
+
"cf-workers-native:headers": fileURLToPath(new URL("../browser/headers/index.js", import.meta.url)),
|
|
100
120
|
"cloudflare:workers": workersModulePath("cloudflare-workers"),
|
|
101
121
|
"punycode/": polyfill("punycode/punycode.js"),
|
|
102
122
|
"util/util.js": polyfill("util/util.js"),
|
|
@@ -109,6 +129,11 @@ export function commonJSCompatibilityAliases() {
|
|
|
109
129
|
}
|
|
110
130
|
export function compatibilityDependencies() {
|
|
111
131
|
return [
|
|
132
|
+
processStatePath,
|
|
133
|
+
// The HTTP bridge and runtime response checks must share Fetch brands in
|
|
134
|
+
// Vite dev, including when cloudflare:node is dependency-prebundled.
|
|
135
|
+
"cf-workers-native:response",
|
|
136
|
+
"cf-workers-native:headers",
|
|
112
137
|
"cloudflare:node",
|
|
113
138
|
"cloudflare:workers",
|
|
114
139
|
...Object.keys(builtinAliases()),
|
package/dist/tooling/vite.js
CHANGED
|
@@ -7,7 +7,7 @@ import { documentAssets, listAssets } from "./documents.js";
|
|
|
7
7
|
import { serverModules } from "./server-modules.js";
|
|
8
8
|
import { resolve, dirname, isAbsolute } from "node:path";
|
|
9
9
|
import { existsSync } from "node:fs";
|
|
10
|
-
import { configuredPath, compatibilityAliases, compatibilityDependencies, commonJSCompatibilityAliases, globalsInstallPath, nodeGlobalsInstallPath, globalsPath, globalsInjectPath, workerEntry, } from "./shared.js";
|
|
10
|
+
import { configuredPath, compatibilityAliases, compatibilityDependencies, processStatePath, commonJSCompatibilityAliases, globalsInstallPath, nodeGlobalsInstallPath, globalsPath, globalsInjectPath, workerEntry, } from "./shared.js";
|
|
11
11
|
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
12
12
|
import inject from "@rollup/plugin-inject";
|
|
13
13
|
import { normalizePath } from "vite";
|
|
@@ -78,6 +78,10 @@ function compatibilityPlugins(installGlobals = false) {
|
|
|
78
78
|
let specifier;
|
|
79
79
|
if (target === `${root}/compat/stream-web/index.js`)
|
|
80
80
|
specifier = "node:stream/web";
|
|
81
|
+
else if (target === `${root}/browser/response/index.js`)
|
|
82
|
+
specifier = "cf-workers-native:response";
|
|
83
|
+
else if (target === `${root}/browser/headers/index.js`)
|
|
84
|
+
specifier = "cf-workers-native:headers";
|
|
81
85
|
else if (owner === `${root}/browser/body/stream-body.js` ||
|
|
82
86
|
owner === `${root}/shared/globals/web.js`) {
|
|
83
87
|
if (target === `${root}/compat/buffer/blob.js`)
|
|
@@ -130,8 +134,9 @@ function compatibilityPlugins(installGlobals = false) {
|
|
|
130
134
|
...inject({
|
|
131
135
|
Buffer: [globalsInjectPath, "Buffer"],
|
|
132
136
|
// util reads process during Buffer initialization. Keep this import
|
|
133
|
-
//
|
|
134
|
-
|
|
137
|
+
// on the shared state leaf: importing the full process adapter here
|
|
138
|
+
// would cycle through events/util in optimized development chunks.
|
|
139
|
+
process: [processStatePath, "default"],
|
|
135
140
|
global: [globalsRuntimePath, "global"],
|
|
136
141
|
setImmediate: [globalsRuntimePath, "setImmediate"],
|
|
137
142
|
clearImmediate: [globalsRuntimePath, "clearImmediate"],
|
|
@@ -11,6 +11,7 @@ import io.netty.channel.socket.SocketChannel;
|
|
|
11
11
|
import io.netty.channel.socket.ChannelInputShutdownEvent;
|
|
12
12
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
|
13
13
|
import io.netty.handler.ssl.SslHandler;
|
|
14
|
+
import io.netty.handler.ssl.SslCloseCompletionEvent;
|
|
14
15
|
import java.util.ArrayDeque;
|
|
15
16
|
import java.util.Map;
|
|
16
17
|
import java.util.concurrent.ConcurrentHashMap;
|
|
@@ -33,13 +34,15 @@ final class WorkerSockets {
|
|
|
33
34
|
final Result opening;
|
|
34
35
|
final ArrayDeque<byte[]> chunks = new ArrayDeque<>();
|
|
35
36
|
SocketChannel channel;
|
|
36
|
-
Result reading, watching;
|
|
37
|
+
Result reading, watching, upgrading;
|
|
38
|
+
String host; int port;
|
|
37
39
|
int count, offset;
|
|
38
|
-
boolean ready, closed, eof, ended, writing, reset;
|
|
40
|
+
boolean ready, closed, eof, ended, writing, reset, encrypted, closeNotify, inboundEndQueued;
|
|
39
41
|
Connection(String id, Result opening) { this.id=id; this.opening=opening; }
|
|
40
42
|
void fail(String message) {
|
|
41
43
|
if (closed) return;
|
|
42
44
|
closed=true;
|
|
45
|
+
if(upgrading!=null) { Result pending=upgrading; upgrading=null; pending.reject(message); }
|
|
43
46
|
if (!ready) { ready=true; opening.reject(message); }
|
|
44
47
|
if (reading!=null) {
|
|
45
48
|
Result pending=reading; reading=null;
|
|
@@ -51,6 +54,19 @@ final class WorkerSockets {
|
|
|
51
54
|
chunks.clear();
|
|
52
55
|
if(channel!=null) channel.close();
|
|
53
56
|
}
|
|
57
|
+
void finishInbound(ChannelHandlerContext context) {
|
|
58
|
+
if(inboundEndQueued || eof || closed) return;
|
|
59
|
+
inboundEndQueued=true;
|
|
60
|
+
// SslHandler can complete its close future during a reentrant
|
|
61
|
+
// unwrap, before the enclosing decode delivers its plaintext.
|
|
62
|
+
// Publish EOF only after the current pipeline dispatch unwinds;
|
|
63
|
+
// queued data must be drained before read/watch observe the end.
|
|
64
|
+
context.executor().execute(() -> {
|
|
65
|
+
inboundEndQueued=false;
|
|
66
|
+
if(closed) return;
|
|
67
|
+
eof=true; drain(); notifyEnd();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
54
70
|
void notifyEnd() {
|
|
55
71
|
if(eof && chunks.isEmpty() && watching!=null) { Result pending=watching; watching=null; pending.resolve(null); }
|
|
56
72
|
}
|
|
@@ -74,18 +90,36 @@ final class WorkerSockets {
|
|
|
74
90
|
}
|
|
75
91
|
@Override public void channelReadComplete(ChannelHandlerContext context) { if(!ready && !closed) context.read(); else pump(); }
|
|
76
92
|
@Override public void userEventTriggered(ChannelHandlerContext context,Object event) {
|
|
77
|
-
if(event instanceof
|
|
93
|
+
if(event instanceof SslCloseCompletionEvent) {
|
|
94
|
+
SslCloseCompletionEvent tlsClose=(SslCloseCompletionEvent)event;
|
|
95
|
+
if(tlsClose.isSuccess()) { closeNotify=true; finishInbound(context); }
|
|
96
|
+
else if(ready && encrypted && !closed) { fail("TLS connection closed without close_notify"); return; }
|
|
97
|
+
context.fireUserEventTriggered(event);
|
|
98
|
+
} else if(event instanceof ChannelInputShutdownEvent) {
|
|
99
|
+
if(!ready || upgrading!=null) { fail("TLS connection closed before handshake completed"); return; }
|
|
100
|
+
if(encrypted && !closeNotify) { fail("TLS connection closed without close_notify"); return; }
|
|
101
|
+
finishInbound(context);
|
|
102
|
+
}
|
|
78
103
|
else context.fireUserEventTriggered(event);
|
|
79
104
|
}
|
|
80
105
|
@Override public void channelInactive(ChannelHandlerContext context) {
|
|
81
|
-
if(!closed) {
|
|
106
|
+
if(!closed) {
|
|
107
|
+
if(!ready || upgrading!=null) { fail("Socket closed before handshake completed"); return; }
|
|
108
|
+
if(encrypted && !closeNotify) { fail("TLS connection closed without close_notify"); return; }
|
|
109
|
+
finishInbound(context);
|
|
110
|
+
}
|
|
82
111
|
}
|
|
83
112
|
@Override public void exceptionCaught(ChannelHandlerContext context,Throwable error) {
|
|
84
|
-
|
|
85
|
-
|
|
113
|
+
boolean peerReset = error instanceof java.io.IOException && String.valueOf(error.getMessage()).toLowerCase(java.util.Locale.ROOT).contains("reset");
|
|
114
|
+
// Workers' plain TCP reset-as-EOF behavior must not turn a truncated
|
|
115
|
+
// authenticated TLS stream into a successful end.
|
|
116
|
+
if(encrypted && peerReset && closeNotify) { finishInbound(context); return; }
|
|
117
|
+
reset = !encrypted && peerReset;
|
|
118
|
+
fail(encrypted && peerReset ? "TLS connection closed without close_notify" : "Socket failed: "+error.getMessage());
|
|
86
119
|
}
|
|
87
120
|
}
|
|
88
|
-
synchronized void open(String id,String host,int port,boolean tls,Result result) {
|
|
121
|
+
synchronized void open(String id,String host,int port,boolean tls,Result result) { open(id,host,port,tls,null,result); }
|
|
122
|
+
synchronized void open(String id,String host,int port,boolean tls,String servername,Result result) {
|
|
89
123
|
if(stopped || id==null || id.isEmpty() || connections.containsKey(id) || host==null || host.isEmpty() || port<1 || port>65535) { result.reject("Invalid socket open"); return; }
|
|
90
124
|
try {
|
|
91
125
|
final SSLEngine engine;
|
|
@@ -96,11 +130,11 @@ final class WorkerSockets {
|
|
|
96
130
|
SSLContext context=SSLContext.getInstance("TLS");
|
|
97
131
|
context.init(null,null,null); tlsContext=context;
|
|
98
132
|
}
|
|
99
|
-
engine=tlsContext.createSSLEngine(host,port); engine.setUseClientMode(true);
|
|
133
|
+
engine=tlsContext.createSSLEngine(servername==null || servername.isEmpty() ? host : servername,port); engine.setUseClientMode(true);
|
|
100
134
|
SSLParameters parameters=engine.getSSLParameters(); parameters.setEndpointIdentificationAlgorithm("HTTPS"); engine.setSSLParameters(parameters);
|
|
101
135
|
} else engine=null;
|
|
102
136
|
if(group==null) group=new NioEventLoopGroup(1);
|
|
103
|
-
Connection connection=new Connection(id,result); connections.put(id,connection);
|
|
137
|
+
Connection connection=new Connection(id,result); connection.host=host; connection.port=port; connection.encrypted=tls; connections.put(id,connection);
|
|
104
138
|
ChannelFuture future=new Bootstrap().group(group).channel(NioSocketChannel.class)
|
|
105
139
|
.option(ChannelOption.AUTO_READ,false).option(ChannelOption.ALLOW_HALF_CLOSURE,true)
|
|
106
140
|
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,30000)
|
|
@@ -130,6 +164,37 @@ final class WorkerSockets {
|
|
|
130
164
|
});
|
|
131
165
|
} catch(Exception error) { Connection connection=connections.remove(id); if(connection!=null) connection.fail(error.toString()); else result.reject(error.toString()); }
|
|
132
166
|
}
|
|
167
|
+
void startTls(String id,String servername,Result result) {
|
|
168
|
+
perform(id,result,connection -> {
|
|
169
|
+
if(connection.ended || connection.eof || connection.writing || connection.upgrading!=null || connection.channel.pipeline().get(SslHandler.class)!=null) { result.reject("Socket cannot be upgraded"); return; }
|
|
170
|
+
try {
|
|
171
|
+
final SSLEngine engine;
|
|
172
|
+
synchronized(this) {
|
|
173
|
+
if(tlsContext==null) { tlsContext=SSLContext.getInstance("TLS"); tlsContext.init(null,null,null); }
|
|
174
|
+
engine=tlsContext.createSSLEngine(servername==null || servername.isEmpty()?connection.host:servername,connection.port);
|
|
175
|
+
}
|
|
176
|
+
engine.setUseClientMode(true);
|
|
177
|
+
SSLParameters parameters=engine.getSSLParameters(); parameters.setEndpointIdentificationAlgorithm("HTTPS"); engine.setSSLParameters(parameters);
|
|
178
|
+
connection.upgrading=result; connection.encrypted=true;
|
|
179
|
+
JSObject moved=new JSObject(); moved.put("upgraded",true);
|
|
180
|
+
if(connection.reading!=null) { Result pending=connection.reading; connection.reading=null; pending.resolve(moved); }
|
|
181
|
+
if(connection.watching!=null) { Result pending=connection.watching; connection.watching=null; pending.resolve(moved); }
|
|
182
|
+
ArrayDeque<byte[]> buffered=new ArrayDeque<>(connection.chunks); connection.chunks.clear();
|
|
183
|
+
int firstOffset=connection.offset; connection.offset=0;
|
|
184
|
+
SslHandler handler=new SslHandler(engine);
|
|
185
|
+
connection.channel.pipeline().addFirst(handler);
|
|
186
|
+
for(byte[] chunk:buffered) {
|
|
187
|
+
connection.channel.pipeline().fireChannelRead(Unpooled.wrappedBuffer(chunk,firstOffset,chunk.length-firstOffset)); firstOffset=0;
|
|
188
|
+
}
|
|
189
|
+
handler.handshakeFuture().addListener(handshake -> {
|
|
190
|
+
if(connection.closed) return;
|
|
191
|
+
if(!handshake.isSuccess()) { connection.fail("TLS failed: "+handshake.cause()); return; }
|
|
192
|
+
Result pending=connection.upgrading; connection.upgrading=null; pending.resolve(null); connection.pump();
|
|
193
|
+
});
|
|
194
|
+
connection.channel.read();
|
|
195
|
+
} catch(Exception error) { result.reject(error.toString()); connection.fail(error.toString()); }
|
|
196
|
+
});
|
|
197
|
+
}
|
|
133
198
|
private static String authority(java.net.InetSocketAddress address) {
|
|
134
199
|
String host=address.getAddress().getHostAddress(); return (host.contains(":")?"["+host+"]":host)+":"+address.getPort();
|
|
135
200
|
}
|
|
@@ -163,7 +228,7 @@ final class WorkerSockets {
|
|
|
163
228
|
try { chunk=Base64.decode(encoded,Base64.DEFAULT); } catch(Exception error) { result.reject("Invalid socket chunk"); return; }
|
|
164
229
|
if(chunk.length>65536) { result.reject("Socket chunk exceeds limit"); return; }
|
|
165
230
|
perform(id,result,connection -> {
|
|
166
|
-
if(connection.ended || connection.writing) { result.reject("Socket write unavailable"); return; }
|
|
231
|
+
if(connection.ended || connection.writing || connection.upgrading!=null) { result.reject("Socket write unavailable"); return; }
|
|
167
232
|
connection.writing=true;
|
|
168
233
|
connection.channel.writeAndFlush(Unpooled.wrappedBuffer(chunk)).addListener(future -> {
|
|
169
234
|
connection.writing=false;
|
|
@@ -174,11 +239,25 @@ final class WorkerSockets {
|
|
|
174
239
|
void end(String id,Result result) {
|
|
175
240
|
perform(id,result,true,connection -> {
|
|
176
241
|
if(connection.reset) { result.resolve(null); return; }
|
|
177
|
-
if(connection.writing) { result.reject("Socket write still pending"); return; }
|
|
242
|
+
if(connection.writing || connection.upgrading!=null) { result.reject("Socket write still pending"); return; }
|
|
178
243
|
if(connection.ended) { result.resolve(null); return; }
|
|
179
244
|
connection.ended=true;
|
|
180
|
-
|
|
181
|
-
if(
|
|
245
|
+
Runnable shutdownOutput=() -> {
|
|
246
|
+
if(connection.eof && !connection.channel.isActive()) { result.resolve(null); return; }
|
|
247
|
+
connection.channel.shutdownOutput().addListener(future -> {
|
|
248
|
+
if(future.isSuccess() || connection.eof) result.resolve(null);
|
|
249
|
+
else { result.reject("Socket end failed"); connection.fail("Socket end failed"); }
|
|
250
|
+
});
|
|
251
|
+
};
|
|
252
|
+
SslHandler tls=connection.channel.pipeline().get(SslHandler.class);
|
|
253
|
+
if(tls==null) shutdownOutput.run();
|
|
254
|
+
else tls.closeOutbound().addListener(future -> {
|
|
255
|
+
// TLS close_notify half-closes the TLS write side. Do not send
|
|
256
|
+
// TCP FIN here: it can close a peer's raw transport before its
|
|
257
|
+
// encrypted response has flushed. The read side owns final close.
|
|
258
|
+
if(future.isSuccess()) result.resolve(null);
|
|
259
|
+
else if(connection.eof) result.resolve(null);
|
|
260
|
+
else { result.reject("TLS end failed"); connection.fail("TLS end failed"); }
|
|
182
261
|
});
|
|
183
262
|
});
|
|
184
263
|
}
|
|
@@ -110,9 +110,10 @@ public class WorkersCapacitorPlugin extends Plugin {
|
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
@PluginMethod public void socketStartTls(PluginCall call) { network.startTls(call.getString("id"),call.getString("servername"),result(call)); }
|
|
113
114
|
@PluginMethod public void socketWatch(PluginCall call) { network.watch(call.getString("id"),result(call)); }
|
|
114
115
|
@PluginMethod public void socketOpen(PluginCall call) {
|
|
115
|
-
network.open(call.getString("id"),call.getString("host"),call.getInt("port",0),call.getBoolean("tls",false),result(call));
|
|
116
|
+
network.open(call.getString("id"),call.getString("host"),call.getInt("port",0),call.getBoolean("tls",false),call.getString("servername"),result(call));
|
|
116
117
|
}
|
|
117
118
|
@PluginMethod public void socketWrite(PluginCall call) { network.write(call.getString("id"),call.getString("chunk"),result(call)); }
|
|
118
119
|
@PluginMethod public void socketEnd(PluginCall call) { network.end(call.getString("id"),result(call)); }
|
|
@@ -246,8 +247,9 @@ public class WorkersCapacitorPlugin extends Plugin {
|
|
|
246
247
|
}
|
|
247
248
|
@JavascriptInterface public void cookiesGet(String callbackId,String url) { WorkersCapacitorPlugin.this.cookiesGet(url,hostResult(owner,callbackId)); }
|
|
248
249
|
@JavascriptInterface public void cookiesSet(String callbackId,String url,String cookies) { WorkersCapacitorPlugin.this.cookiesSet(url,cookies,hostResult(owner,callbackId)); }
|
|
250
|
+
@JavascriptInterface public void socketStartTls(String callbackId,String id,String servername) { network.startTls(id,servername,hostResult(owner,callbackId)); }
|
|
249
251
|
@JavascriptInterface public void socketWatch(String callbackId,String id) { network.watch(id,hostResult(owner,callbackId)); }
|
|
250
|
-
@JavascriptInterface public void socketOpen(String callbackId,String id,String host,int port,boolean tls) { network.open(id,host,port,tls,hostResult(owner,callbackId)); }
|
|
252
|
+
@JavascriptInterface public void socketOpen(String callbackId,String id,String host,int port,boolean tls,String servername) { network.open(id,host,port,tls,servername,hostResult(owner,callbackId)); }
|
|
251
253
|
@JavascriptInterface public void socketWrite(String callbackId,String id,String chunk) { network.write(id,chunk,hostResult(owner,callbackId)); }
|
|
252
254
|
@JavascriptInterface public void socketEnd(String callbackId,String id) { network.end(id,hostResult(owner,callbackId)); }
|
|
253
255
|
@JavascriptInterface public void socketRead(String callbackId,String id,int count) { network.read(id,count,hostResult(owner,callbackId)); }
|
|
@@ -22,13 +22,23 @@ final class NetworkBridge {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
func socketVerifyTls(_ call: CAPPluginCall) {
|
|
26
|
+
guard let id = call.getString("id"), let encoded = call.getArray("certificates", String.self), encoded.count <= 32 else { reject(call, "Invalid certificate chain"); return }
|
|
27
|
+
let certificates = encoded.compactMap { $0.utf8.count <= 1048576 ? Data(base64Encoded: $0) : nil }
|
|
28
|
+
guard certificates.count == encoded.count else { reject(call, "Invalid certificate chain"); return }
|
|
29
|
+
sockets.verifyTls(id: id, certificates: certificates, completion: socketResult(call))
|
|
30
|
+
}
|
|
31
|
+
func socketStartTls(_ call: CAPPluginCall) {
|
|
32
|
+
guard let id = call.getString("id") else { reject(call, "Missing socket"); return }
|
|
33
|
+
sockets.startTls(id: id, servername: call.getString("servername"), completion: socketResult(call))
|
|
34
|
+
}
|
|
25
35
|
func socketWatch(_ call: CAPPluginCall) {
|
|
26
36
|
guard let id = call.getString("id") else { reject(call, "Missing socket"); return }
|
|
27
37
|
sockets.watch(id: id, completion: socketResult(call))
|
|
28
38
|
}
|
|
29
39
|
func socketOpen(_ call: CAPPluginCall) {
|
|
30
40
|
guard let id = call.getString("id"), let host = call.getString("host"), let port = call.getInt("port") else { reject(call, "Invalid socket open"); return }
|
|
31
|
-
sockets.open(id: id, host: host, port: port, tls: call.getBool("tls") ?? false, completion: socketResult(call))
|
|
41
|
+
sockets.open(id: id, host: host, port: port, tls: call.getBool("tls") ?? false, servername: call.getString("servername"), completion: socketResult(call))
|
|
32
42
|
}
|
|
33
43
|
func socketWrite(_ call: CAPPluginCall) {
|
|
34
44
|
guard let id = call.getString("id"), let encoded = call.getString("chunk"), encoded.utf8.count <= 87384, let data = Data(base64Encoded: encoded) else { reject(call, "Invalid socket write"); return }
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import Network
|
|
3
|
+
import Security
|
|
3
4
|
import Capacitor
|
|
4
5
|
|
|
5
6
|
/// TCP byte transport. All state and completions belong to one serial queue.
|
|
@@ -7,6 +8,8 @@ final class SocketBridge: @unchecked Sendable {
|
|
|
7
8
|
private final class Connection: @unchecked Sendable {
|
|
8
9
|
let id: String
|
|
9
10
|
let transport: NWConnection
|
|
11
|
+
var encrypted = false
|
|
12
|
+
var host = ""
|
|
10
13
|
var opening: ((Result<PluginCallResultData, Error>) -> Void)?
|
|
11
14
|
var reading: ((Result<PluginCallResultData, Error>) -> Void)?
|
|
12
15
|
var writing: ((Result<PluginCallResultData, Error>) -> Void)?
|
|
@@ -51,12 +54,19 @@ final class SocketBridge: @unchecked Sendable {
|
|
|
51
54
|
let waiters = value.closeWaiters; value.closeWaiters.removeAll()
|
|
52
55
|
for waiter in waiters { waiter() }
|
|
53
56
|
}
|
|
54
|
-
func open(id: String, host: String, port: Int, tls: Bool, completion: @escaping Completion) {
|
|
57
|
+
func open(id: String, host: String, port: Int, tls: Bool, servername: String? = nil, completion: @escaping Completion) {
|
|
55
58
|
queue.async {
|
|
56
59
|
guard !self.stopped, !id.isEmpty, !host.isEmpty, port > 0, port <= 65535,
|
|
57
60
|
self.values[id] == nil, let endpointPort = NWEndpoint.Port(rawValue: UInt16(port)) else { completion(.failure(Failure.invalid)); return }
|
|
58
|
-
let
|
|
61
|
+
let parameters: NWParameters
|
|
62
|
+
if tls {
|
|
63
|
+
let options = NWProtocolTLS.Options()
|
|
64
|
+
sec_protocol_options_set_tls_server_name(options.securityProtocolOptions, servername ?? host)
|
|
65
|
+
parameters = NWParameters(tls: options, tcp: NWProtocolTCP.Options())
|
|
66
|
+
} else { parameters = .tcp }
|
|
67
|
+
let transport = NWConnection(host: NWEndpoint.Host(host), port: endpointPort, using: parameters)
|
|
59
68
|
let value = Connection(id, transport)
|
|
69
|
+
value.host = host; value.encrypted = tls
|
|
60
70
|
value.opening = completion
|
|
61
71
|
self.values[id] = value
|
|
62
72
|
transport.stateUpdateHandler = { [weak self, weak value] state in
|
|
@@ -89,6 +99,31 @@ final class SocketBridge: @unchecked Sendable {
|
|
|
89
99
|
transport.start(queue: self.queue)
|
|
90
100
|
}
|
|
91
101
|
}
|
|
102
|
+
func startTls(id: String, servername: String?, completion: @escaping Completion) {
|
|
103
|
+
queue.async {
|
|
104
|
+
guard let value = self.values[id], value.ready, !value.closed, !value.eof, !value.ended, !value.encrypted, value.writing == nil,
|
|
105
|
+
let hostname = servername, !hostname.isEmpty, !hostname.utf8.contains(0) else { completion(.failure(Failure.invalid)); return }
|
|
106
|
+
value.encrypted = true; value.host = hostname
|
|
107
|
+
value.reading?(.success(["upgraded": true])); value.reading = nil
|
|
108
|
+
value.watching?(.success(["upgraded": true])); value.watching = nil
|
|
109
|
+
// JS encrypts records with OpenSSL memory BIOs on this same TCP stream.
|
|
110
|
+
// The successful JS open is withheld until verifyTls authenticates it.
|
|
111
|
+
completion(.success(["tlsEngine": "openssl-wasm"]))
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
func verifyTls(id: String, certificates: [Data], completion: @escaping Completion) {
|
|
115
|
+
queue.async {
|
|
116
|
+
guard let value = self.values[id], !value.closed, value.encrypted, !certificates.isEmpty else { completion(.failure(Failure.invalid)); return }
|
|
117
|
+
let chain = certificates.compactMap { SecCertificateCreateWithData(nil, $0 as CFData) }
|
|
118
|
+
guard chain.count == certificates.count else { completion(.failure(Failure.invalid)); return }
|
|
119
|
+
var trust: SecTrust?
|
|
120
|
+
let policy = SecPolicyCreateSSL(true, value.host as CFString)
|
|
121
|
+
guard SecTrustCreateWithCertificates(chain as CFArray, policy, &trust) == errSecSuccess, let trust else { completion(.failure(Failure.invalid)); return }
|
|
122
|
+
var error: CFError?
|
|
123
|
+
guard SecTrustEvaluateWithError(trust, &error) else { completion(.failure(error as Error? ?? Failure.invalid)); return }
|
|
124
|
+
completion(.success([:]))
|
|
125
|
+
}
|
|
126
|
+
}
|
|
92
127
|
func watch(id: String, completion: @escaping Completion) {
|
|
93
128
|
queue.async {
|
|
94
129
|
if let value = self.values[id], value.reset { completion(.success(["reset": true])); return }
|
|
@@ -13,6 +13,8 @@ public final class WorkersCapacitorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
13
13
|
CAPPluginMethod(name: "start", returnType: CAPPluginReturnPromise),
|
|
14
14
|
CAPPluginMethod(name: "stop", returnType: CAPPluginReturnPromise),
|
|
15
15
|
CAPPluginMethod(name: "socketWatch", returnType: CAPPluginReturnPromise),
|
|
16
|
+
CAPPluginMethod(name: "socketVerifyTls", returnType: CAPPluginReturnPromise),
|
|
17
|
+
CAPPluginMethod(name: "socketStartTls", returnType: CAPPluginReturnPromise),
|
|
16
18
|
CAPPluginMethod(name: "socketOpen", returnType: CAPPluginReturnPromise),
|
|
17
19
|
CAPPluginMethod(name: "socketWrite", returnType: CAPPluginReturnPromise),
|
|
18
20
|
CAPPluginMethod(name: "socketEnd", returnType: CAPPluginReturnPromise),
|
|
@@ -69,6 +71,8 @@ public final class WorkersCapacitorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
69
71
|
Task { await owner.closeAll(); call.resolve() }
|
|
70
72
|
}
|
|
71
73
|
}
|
|
74
|
+
@objc func socketVerifyTls(_ call: CAPPluginCall) { network.socketVerifyTls(call) }
|
|
75
|
+
@objc func socketStartTls(_ call: CAPPluginCall) { network.socketStartTls(call) }
|
|
72
76
|
@objc func socketWatch(_ call: CAPPluginCall) { network.socketWatch(call) }
|
|
73
77
|
@objc func socketOpen(_ call: CAPPluginCall) { network.socketOpen(call) }
|
|
74
78
|
@objc func socketWrite(_ call: CAPPluginCall) { network.socketWrite(call) }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cf-workers-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Bring Cloudflare Workers apps to iOS and Android.",
|
|
6
6
|
"repository": {
|
|
@@ -111,12 +111,14 @@
|
|
|
111
111
|
"brotli-dec-wasm": "2.3.2",
|
|
112
112
|
"esbuild": "^0.28.2",
|
|
113
113
|
"jsonc-parser": "^3.3.1",
|
|
114
|
+
"memfs": "4.80.0",
|
|
114
115
|
"node-stdlib-browser": "^1.3.1",
|
|
115
116
|
"parse-srcset": "^1.0.2",
|
|
116
117
|
"parse5": "^8.0.1",
|
|
117
118
|
"punycode": "2.3.1",
|
|
118
119
|
"readable-stream": "4.8.0",
|
|
119
120
|
"rollup": "^4.64.9",
|
|
121
|
+
"scrypt-js": "3.0.1",
|
|
120
122
|
"smol-toml": "^1.9.1",
|
|
121
123
|
"string_decoder": "^1.3.0",
|
|
122
124
|
"vite-plugin-node-polyfills": "^0.28.0",
|
|
@@ -125,7 +127,7 @@
|
|
|
125
127
|
"devDependencies": {
|
|
126
128
|
"@playwright/test": "^1.64.1",
|
|
127
129
|
"@types/node": "^26.6.5",
|
|
128
|
-
"hono": "
|
|
130
|
+
"hono": "4.13.13",
|
|
129
131
|
"np": "^12.1.1",
|
|
130
132
|
"prettier": "3.8.4",
|
|
131
133
|
"typescript": "^7.0.2",
|