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.
Files changed (296) hide show
  1. package/README.md +2 -2
  2. package/dist/browser/documents/page-source.js +1 -1
  3. package/dist/browser/fetch/host-call.js +6 -1
  4. package/dist/browser/fetch/native-network.d.ts +1 -1
  5. package/dist/browser/fetch/relay.js +2 -0
  6. package/dist/browser/headers/index.d.ts +2 -0
  7. package/dist/browser/headers/index.js +5 -0
  8. package/dist/browser/isolated/transport.js +3 -2
  9. package/dist/browser/request/index.js +3 -2
  10. package/dist/browser/response/index.d.ts +2 -0
  11. package/dist/browser/response/index.js +11 -3
  12. package/dist/browser/structured-clone/index.d.ts +3 -0
  13. package/dist/browser/structured-clone/index.js +75 -7
  14. package/dist/browser/websocket/attachment-size.d.ts +3 -0
  15. package/dist/browser/websocket/attachment-size.js +336 -0
  16. package/dist/browser/websocket/brand.d.ts +4 -0
  17. package/dist/browser/websocket/brand.js +16 -0
  18. package/dist/browser/websocket/close-event.d.ts +7 -0
  19. package/dist/browser/websocket/close-event.js +30 -0
  20. package/dist/browser/websocket/compression.d.ts +5 -0
  21. package/dist/browser/websocket/compression.js +124 -0
  22. package/dist/browser/websocket/conversion.d.ts +2 -0
  23. package/dist/browser/websocket/conversion.js +13 -0
  24. package/dist/browser/websocket/endpoint.d.ts +39 -0
  25. package/dist/browser/websocket/endpoint.js +379 -0
  26. package/dist/browser/websocket/frames.d.ts +21 -0
  27. package/dist/browser/websocket/frames.js +121 -0
  28. package/dist/browser/websocket/native.d.ts +14 -0
  29. package/dist/browser/websocket/native.js +226 -0
  30. package/dist/cloudflare/apis/cloudflare-node/index.js +11 -23
  31. package/dist/cloudflare/workers/worker-runtime.js +2 -1
  32. package/dist/compat/console/index.d.ts +35 -0
  33. package/dist/compat/console/index.js +92 -0
  34. package/dist/compat/crypto/LICENSE-3RD-PARTY.md +39 -0
  35. package/dist/compat/crypto/LICENSE-APACHE +177 -0
  36. package/dist/compat/crypto/LICENSE.boringssl +238 -0
  37. package/dist/compat/crypto/LICENSE.emscripten +102 -0
  38. package/dist/compat/crypto/LICENSE.musl +193 -0
  39. package/dist/compat/crypto/LICENSE.ncrypto +21 -0
  40. package/dist/compat/crypto/LICENSE.openssl +177 -0
  41. package/dist/compat/crypto/asymmetric.d.ts +13 -0
  42. package/dist/compat/crypto/asymmetric.js +312 -0
  43. package/dist/compat/crypto/brorand.cjs +74 -0
  44. package/dist/compat/crypto/brorand.d.cts +6 -0
  45. package/dist/compat/crypto/certificate.d.ts +14 -0
  46. package/dist/compat/crypto/certificate.js +66 -0
  47. package/dist/compat/crypto/cipher-handle.d.ts +27 -0
  48. package/dist/compat/crypto/cipher-handle.js +239 -0
  49. package/dist/compat/crypto/cipher-info.d.ts +12 -0
  50. package/dist/compat/crypto/cipher-info.js +324 -0
  51. package/dist/compat/crypto/constants.d.ts +62 -0
  52. package/dist/compat/crypto/constants.js +68 -0
  53. package/dist/compat/crypto/dh-handle.d.ts +17 -0
  54. package/dist/compat/crypto/dh-handle.js +180 -0
  55. package/dist/compat/crypto/dh.d.ts +53 -0
  56. package/dist/compat/crypto/dh.js +138 -0
  57. package/dist/compat/crypto/digest-stream.d.ts +15 -0
  58. package/dist/compat/crypto/digest-stream.js +213 -0
  59. package/dist/compat/crypto/digests.d.ts +3 -0
  60. package/dist/compat/crypto/digests.js +32 -0
  61. package/dist/compat/crypto/ecdh.d.ts +25 -0
  62. package/dist/compat/crypto/ecdh.js +109 -0
  63. package/dist/compat/crypto/hash-handle.d.ts +23 -0
  64. package/dist/compat/crypto/hash-handle.js +70 -0
  65. package/dist/compat/crypto/hash.d.ts +37 -0
  66. package/dist/compat/crypto/hash.js +218 -0
  67. package/dist/compat/crypto/hkdf.d.ts +2 -0
  68. package/dist/compat/crypto/hkdf.js +78 -0
  69. package/dist/compat/crypto/index.cjs +2 -0
  70. package/dist/compat/crypto/index.d.cts +169 -0
  71. package/dist/compat/crypto/index.d.ts +213 -0
  72. package/dist/compat/crypto/index.js +96 -0
  73. package/dist/compat/crypto/key-errors.d.ts +10 -0
  74. package/dist/compat/crypto/key-errors.js +17 -0
  75. package/dist/compat/crypto/key-export.d.ts +8 -0
  76. package/dist/compat/crypto/key-export.js +49 -0
  77. package/dist/compat/crypto/key-formats.d.ts +7 -0
  78. package/dist/compat/crypto/key-formats.js +251 -0
  79. package/dist/compat/crypto/key-options.d.ts +1 -0
  80. package/dist/compat/crypto/key-options.js +74 -0
  81. package/dist/compat/crypto/key-state.d.ts +10 -0
  82. package/dist/compat/crypto/key-state.js +4 -0
  83. package/dist/compat/crypto/keys.d.ts +58 -0
  84. package/dist/compat/crypto/keys.js +278 -0
  85. package/dist/compat/crypto/metadata.d.ts +13 -0
  86. package/dist/compat/crypto/metadata.js +109 -0
  87. package/dist/compat/crypto/native-cipher.d.ts +17 -0
  88. package/dist/compat/crypto/native-cipher.js +192 -0
  89. package/dist/compat/crypto/native-crypto.d.ts +81 -0
  90. package/dist/compat/crypto/native-crypto.js +681 -0
  91. package/dist/compat/crypto/pbkdf2-handle.d.ts +4 -0
  92. package/dist/compat/crypto/pbkdf2-handle.js +26 -0
  93. package/dist/compat/crypto/pbkdf2.d.ts +5 -0
  94. package/dist/compat/crypto/pbkdf2.js +60 -0
  95. package/dist/compat/crypto/prime.d.ts +19 -0
  96. package/dist/compat/crypto/prime.js +146 -0
  97. package/dist/compat/crypto/random.d.ts +18 -0
  98. package/dist/compat/crypto/random.js +203 -0
  99. package/dist/compat/crypto/rsa.d.ts +21 -0
  100. package/dist/compat/crypto/rsa.js +177 -0
  101. package/dist/compat/crypto/scrypt.d.ts +25 -0
  102. package/dist/compat/crypto/scrypt.js +152 -0
  103. package/dist/compat/crypto/sign-errors.d.ts +8 -0
  104. package/dist/compat/crypto/sign-errors.js +13 -0
  105. package/dist/compat/crypto/sign-handle.d.ts +22 -0
  106. package/dist/compat/crypto/sign-handle.js +149 -0
  107. package/dist/compat/crypto/signatures.d.ts +34 -0
  108. package/dist/compat/crypto/signatures.js +252 -0
  109. package/dist/compat/crypto/subtle-digest.d.ts +1 -0
  110. package/dist/compat/crypto/subtle-digest.js +56 -0
  111. package/dist/compat/crypto/symmetric.d.ts +45 -0
  112. package/dist/compat/crypto/symmetric.js +239 -0
  113. package/dist/compat/crypto/validation.d.ts +7 -0
  114. package/dist/compat/crypto/validation.js +46 -0
  115. package/dist/compat/crypto/webcrypto.d.ts +13 -0
  116. package/dist/compat/crypto/webcrypto.js +51 -0
  117. package/dist/compat/crypto/x509.d.ts +30 -0
  118. package/dist/compat/crypto/x509.js +407 -0
  119. package/dist/compat/events/errors.d.ts +8 -0
  120. package/dist/compat/events/errors.js +39 -0
  121. package/dist/compat/events/index.cjs +2 -0
  122. package/dist/compat/events/index.d.cts +2 -0
  123. package/dist/compat/events/index.d.ts +64 -0
  124. package/dist/compat/events/index.js +792 -0
  125. package/dist/compat/events/intrinsics.d.ts +1 -0
  126. package/dist/compat/events/intrinsics.js +2 -0
  127. package/dist/compat/fs/LICENSE-3RD-PARTY.md +11 -0
  128. package/dist/compat/fs/LICENSE-APACHE +177 -0
  129. package/dist/compat/fs/directory-backend.d.ts +6 -0
  130. package/dist/compat/fs/directory-backend.js +51 -0
  131. package/dist/compat/fs/directory.d.ts +37 -0
  132. package/dist/compat/fs/directory.js +137 -0
  133. package/dist/compat/fs/embedded.d.ts +85 -0
  134. package/dist/compat/fs/embedded.js +260 -0
  135. package/dist/compat/fs/file-handle.d.ts +75 -0
  136. package/dist/compat/fs/file-handle.js +226 -0
  137. package/dist/compat/fs/glob-internal.d.ts +15 -0
  138. package/dist/compat/fs/glob-internal.js +417 -0
  139. package/dist/compat/fs/glob.d.ts +10 -0
  140. package/dist/compat/fs/glob.js +71 -0
  141. package/dist/compat/fs/index.d.ts +8 -82
  142. package/dist/compat/fs/index.js +736 -238
  143. package/dist/compat/fs/io-validation.d.ts +14 -0
  144. package/dist/compat/fs/io-validation.js +130 -0
  145. package/dist/compat/fs/io.d.ts +1 -0
  146. package/dist/compat/fs/io.js +282 -0
  147. package/dist/compat/fs/mode.d.ts +1 -0
  148. package/dist/compat/fs/mode.js +13 -0
  149. package/dist/compat/fs/promises/index.d.ts +3 -1
  150. package/dist/compat/fs/promises/index.js +1 -1
  151. package/dist/compat/fs/public-types.d.ts +120 -0
  152. package/dist/compat/fs/public-types.js +1 -0
  153. package/dist/compat/fs/stream-errors.d.ts +6 -0
  154. package/dist/compat/fs/stream-errors.js +8 -0
  155. package/dist/compat/fs/stream-utils.d.ts +16 -0
  156. package/dist/compat/fs/stream-utils.js +29 -0
  157. package/dist/compat/fs/streams.d.ts +104 -0
  158. package/dist/compat/fs/streams.js +794 -0
  159. package/dist/compat/fs/writable.d.ts +14 -0
  160. package/dist/compat/fs/writable.js +532 -0
  161. package/dist/compat/http/index.d.ts +11 -28
  162. package/dist/compat/http/index.js +81 -125
  163. package/dist/compat/http/server-options.d.ts +1 -0
  164. package/dist/compat/http/server-options.js +87 -0
  165. package/dist/compat/http/symbols.d.ts +5 -0
  166. package/dist/compat/http/symbols.js +9 -0
  167. package/dist/compat/http/unique-headers.d.ts +1 -0
  168. package/dist/compat/http/unique-headers.js +21 -0
  169. package/dist/compat/http-common/index.d.ts +37 -0
  170. package/dist/compat/http-common/index.js +43 -0
  171. package/dist/compat/http-outgoing/index.d.ts +14 -0
  172. package/dist/compat/http-outgoing/index.js +17 -0
  173. package/dist/compat/http-server/index.d.ts +18 -0
  174. package/dist/compat/http-server/index.js +26 -0
  175. package/dist/compat/https/index.d.ts +4 -2
  176. package/dist/compat/module/builtins.d.ts +1 -0
  177. package/dist/compat/module/builtins.js +101 -0
  178. package/dist/compat/module/index.d.ts +4 -2
  179. package/dist/compat/module/index.js +22 -17
  180. package/dist/compat/module/metadata.d.ts +44 -0
  181. package/dist/compat/module/metadata.js +127 -0
  182. package/dist/compat/net/internal-net.js +4 -0
  183. package/dist/compat/net/sockets.d.ts +5 -0
  184. package/dist/compat/net/sockets.js +153 -14
  185. package/dist/compat/net/validators.d.ts +1 -0
  186. package/dist/compat/net/validators.js +8 -0
  187. package/dist/compat/process/configuration.d.ts +113 -0
  188. package/dist/compat/process/configuration.js +115 -0
  189. package/dist/compat/process/directory.d.ts +4 -0
  190. package/dist/compat/process/directory.js +28 -0
  191. package/dist/compat/process/files.d.ts +3 -0
  192. package/dist/compat/process/files.js +10 -0
  193. package/dist/compat/process/index.cjs +2 -0
  194. package/dist/compat/process/index.d.cts +4 -0
  195. package/dist/compat/process/index.d.ts +20 -0
  196. package/dist/compat/process/index.js +113 -0
  197. package/dist/compat/process/metadata.d.ts +135 -0
  198. package/dist/compat/process/metadata.js +251 -0
  199. package/dist/compat/process/scheduling.d.ts +2 -0
  200. package/dist/compat/process/scheduling.js +60 -0
  201. package/dist/compat/process/state.d.ts +4 -0
  202. package/dist/compat/process/state.js +5 -0
  203. package/dist/compat/process/stdio.d.ts +18 -0
  204. package/dist/compat/process/stdio.js +66 -0
  205. package/dist/compat/stream/destroy.d.ts +1 -0
  206. package/dist/compat/stream/destroy.js +21 -1
  207. package/dist/compat/stream/readable.js +10 -2
  208. package/dist/compat/stream-web/LICENSE +22 -0
  209. package/dist/compat/stream-web/ponyfill.d.ts +1 -1
  210. package/dist/compat/stream-web/ponyfill.js +2369 -1775
  211. package/dist/compat/stream-web/runtime.d.ts +1 -1
  212. package/dist/compat/stream-web/runtime.js +3 -2
  213. package/dist/compat/stream-wrap/LICENSE-3RD-PARTY.md +11 -0
  214. package/dist/compat/stream-wrap/LICENSE-APACHE +177 -0
  215. package/dist/compat/stream-wrap/index.d.ts +1 -0
  216. package/dist/compat/stream-wrap/index.js +1 -0
  217. package/dist/compat/tls/LICENSE-3RD-PARTY.md +11 -0
  218. package/dist/compat/tls/LICENSE-APACHE +177 -0
  219. package/dist/compat/tls/constants.d.ts +7 -0
  220. package/dist/compat/tls/constants.js +14 -0
  221. package/dist/compat/tls/errors.d.ts +35 -0
  222. package/dist/compat/tls/errors.js +68 -0
  223. package/dist/compat/tls/helpers.d.ts +9 -0
  224. package/dist/compat/tls/helpers.js +207 -0
  225. package/dist/compat/tls/index.d.ts +26 -0
  226. package/dist/compat/tls/index.js +50 -0
  227. package/dist/compat/tls/jsstream.d.ts +19 -0
  228. package/dist/compat/tls/jsstream.js +196 -0
  229. package/dist/compat/tls/native-session.d.ts +3 -0
  230. package/dist/compat/tls/native-session.js +187 -0
  231. package/dist/compat/tls/wrap.d.ts +65 -0
  232. package/dist/compat/tls/wrap.js +541 -0
  233. package/dist/compat/tls-wrap/LICENSE-3RD-PARTY.md +11 -0
  234. package/dist/compat/tls-wrap/LICENSE-APACHE +177 -0
  235. package/dist/compat/tls-wrap/index.d.ts +7 -0
  236. package/dist/compat/tls-wrap/index.js +3 -0
  237. package/dist/compat/util/index.js +43 -1
  238. package/dist/compat/util/inspect.js +5 -1
  239. package/dist/compat/util/types/index.d.ts +3 -0
  240. package/dist/compat/util/types/index.js +5 -0
  241. package/dist/compat/zlib/LICENSE-3RD-PARTY.md +11 -0
  242. package/dist/compat/zlib/LICENSE-APACHE +177 -0
  243. package/dist/compat/zlib/LICENSE.brotli +19 -0
  244. package/dist/compat/zlib/LICENSE.emscripten +102 -0
  245. package/dist/compat/zlib/LICENSE.musl +193 -0
  246. package/dist/compat/zlib/LICENSE.zlib +22 -0
  247. package/dist/compat/zlib/LICENSE.zstd +30 -0
  248. package/dist/compat/zlib/classic-base.cjs +600 -0
  249. package/dist/compat/zlib/classic-base.d.cts +39 -0
  250. package/dist/compat/zlib/classic-binding.d.ts +28 -0
  251. package/dist/compat/zlib/classic-binding.js +105 -0
  252. package/dist/compat/zlib/classic.d.ts +44 -0
  253. package/dist/compat/zlib/classic.js +199 -0
  254. package/dist/compat/zlib/codec-binding.d.ts +33 -0
  255. package/dist/compat/zlib/codec-binding.js +141 -0
  256. package/dist/compat/zlib/compression.d.ts +26 -0
  257. package/dist/compat/zlib/compression.js +170 -0
  258. package/dist/compat/zlib/constants.d.ts +172 -0
  259. package/dist/compat/zlib/constants.js +173 -0
  260. package/dist/compat/zlib/errors.d.ts +21 -0
  261. package/dist/compat/zlib/errors.js +32 -0
  262. package/dist/compat/zlib/index.d.ts +544 -0
  263. package/dist/compat/zlib/index.js +194 -0
  264. package/dist/compat/zlib/input.d.ts +16 -0
  265. package/dist/compat/zlib/input.js +132 -0
  266. package/dist/compat/zlib/native-codecs.d.ts +24 -0
  267. package/dist/compat/zlib/native-codecs.js +180 -0
  268. package/dist/compat/zlib/native-zlib.d.ts +5 -0
  269. package/dist/compat/zlib/native-zlib.js +52 -0
  270. package/dist/compat/zlib/public-types.d.ts +48 -0
  271. package/dist/compat/zlib/public-types.js +1 -0
  272. package/dist/compat/zlib/validators.d.ts +3 -0
  273. package/dist/compat/zlib/validators.js +18 -0
  274. package/dist/shared/buffer-source.d.ts +5 -0
  275. package/dist/shared/buffer-source.js +70 -0
  276. package/dist/shared/globals/inject.d.ts +2 -1
  277. package/dist/shared/globals/inject.js +2 -1
  278. package/dist/shared/globals/platform.d.ts +8 -0
  279. package/dist/shared/globals/platform.js +1 -0
  280. package/dist/shared/globals/runtime.d.ts +1 -2
  281. package/dist/shared/globals/runtime.js +1 -2
  282. package/dist/shared/globals/web.js +5 -0
  283. package/dist/shared/request-context.d.ts +2 -0
  284. package/dist/shared/request-context.js +11 -0
  285. package/dist/shared/request-scope.d.ts +4 -0
  286. package/dist/shared/request-scope.js +14 -0
  287. package/dist/tooling/async.js +36 -14
  288. package/dist/tooling/shared.d.ts +1 -0
  289. package/dist/tooling/shared.js +26 -1
  290. package/dist/tooling/vite.js +8 -3
  291. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +92 -13
  292. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersCapacitorPlugin.java +4 -2
  293. package/native/ios/NetworkBridge.swift +11 -1
  294. package/native/ios/SocketBridge.swift +37 -2
  295. package/native/ios/WorkersCapacitorPlugin.swift +4 -0
  296. package/package.json +4 -2
@@ -0,0 +1,207 @@
1
+ // @ts-nocheck
2
+ import { Buffer } from "node:buffer";
3
+ import { isIP } from "../net/internal-net.js";
4
+ const urlUtil = {
5
+ canonicalizeIp(ip) {
6
+ // URL's IPv6 serializer expands equivalent spellings to one canonical form.
7
+ if (isIP(ip) === 6)
8
+ return new URL(`http://[${ip}]/`).hostname.slice(1, -1);
9
+ return ip;
10
+ },
11
+ };
12
+ import { ERR_TLS_CERT_ALTNAME_INVALID, ERR_TLS_CERT_ALTNAME_FORMAT, ERR_OUT_OF_RANGE, } from "./errors.js";
13
+ import { isUint8Array, isArrayBufferView } from "../util/types/index.js";
14
+ // String#toLowerCase() is locale-sensitive so we use
15
+ // a conservative version that only lowercases A-Z.
16
+ function toLowerCase(c) {
17
+ return String.fromCharCode(32 + c.charCodeAt(0));
18
+ }
19
+ function unfqdn(host) {
20
+ return host.replace(/[.]$/, "");
21
+ }
22
+ function splitHost(host) {
23
+ return unfqdn(host).replace(/[A-Z]/g, toLowerCase).split(".");
24
+ }
25
+ function check(hostParts, pattern, wildcards) {
26
+ // Empty strings, null, undefined, etc. never match.
27
+ if (!pattern)
28
+ return false;
29
+ const patternParts = splitHost(pattern);
30
+ if (hostParts.length !== patternParts.length)
31
+ return false;
32
+ // Pattern has empty components, e.g. "bad..example.com".
33
+ if (patternParts.includes(""))
34
+ return false;
35
+ // RFC 6125 allows IDNA U-labels (Unicode) in names but we have no
36
+ // good way to detect their encoding or normalize them so we simply
37
+ // reject them. Control characters and blanks are rejected as well
38
+ // because nothing good can come from accepting them.
39
+ const isBad = (s) => /[^\u0021-\u007F]/u.test(s);
40
+ if (patternParts.some(isBad))
41
+ return false;
42
+ // Check host parts from right to left first.
43
+ for (let i = hostParts.length - 1; i > 0; i -= 1) {
44
+ if (hostParts[i] !== patternParts[i])
45
+ return false;
46
+ }
47
+ const hostSubdomain = hostParts[0];
48
+ const patternSubdomain = patternParts[0];
49
+ const patternSubdomainParts = patternSubdomain.split("*", 3);
50
+ // Short-circuit when the subdomain does not contain a wildcard.
51
+ // RFC 6125 does not allow wildcard substitution for components
52
+ // containing IDNA A-labels (Punycode) so match those verbatim.
53
+ if (patternSubdomainParts.length === 1 || patternSubdomain.includes("xn--"))
54
+ return hostSubdomain === patternSubdomain;
55
+ if (!wildcards)
56
+ return false;
57
+ // More than one wildcard is always wrong.
58
+ if (patternSubdomainParts.length > 2)
59
+ return false;
60
+ // *.tld wildcards are not allowed.
61
+ if (patternParts.length <= 2)
62
+ return false;
63
+ const { 0: prefix, 1: suffix } = patternSubdomainParts;
64
+ if (prefix.length + suffix.length > hostSubdomain.length)
65
+ return false;
66
+ if (!hostSubdomain.startsWith(prefix))
67
+ return false;
68
+ if (!hostSubdomain.endsWith(suffix))
69
+ return false;
70
+ return true;
71
+ }
72
+ // This pattern is used to determine the length of escaped sequences within
73
+ // the subject alt names string. It allows any valid JSON string literal.
74
+ // This MUST match the JSON specification (ECMA-404 / RFC8259) exactly.
75
+ const jsonStringPattern =
76
+ // eslint-disable-next-line no-control-regex
77
+ /^"(?:[^"\\\u0000-\u001f]|\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4}))*"/;
78
+ function splitEscapedAltNames(altNames) {
79
+ const result = [];
80
+ let currentToken = "";
81
+ let offset = 0;
82
+ while (offset !== altNames.length) {
83
+ const nextSep = altNames.indexOf(",", offset);
84
+ const nextQuote = altNames.indexOf('"', offset);
85
+ if (nextQuote !== -1 && (nextSep === -1 || nextQuote < nextSep)) {
86
+ // There is a quote character and there is no separator before the quote.
87
+ currentToken += altNames.substring(offset, nextQuote);
88
+ const match = jsonStringPattern.exec(altNames.substring(nextQuote));
89
+ if (!match) {
90
+ throw new ERR_TLS_CERT_ALTNAME_FORMAT();
91
+ }
92
+ currentToken += JSON.parse(match[0]);
93
+ offset = nextQuote + match[0].length;
94
+ }
95
+ else if (nextSep !== -1) {
96
+ // There is a separator and no quote before it.
97
+ currentToken += altNames.substring(offset, nextSep);
98
+ result.push(currentToken);
99
+ currentToken = "";
100
+ offset = nextSep + 2;
101
+ }
102
+ else {
103
+ currentToken += altNames.substring(offset);
104
+ offset = altNames.length;
105
+ }
106
+ }
107
+ result.push(currentToken);
108
+ return result;
109
+ }
110
+ export function checkServerIdentity(hostname, cert) {
111
+ const subject = cert.subject;
112
+ const altNames = cert.subjectaltname;
113
+ const dnsNames = [];
114
+ const ips = [];
115
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion
116
+ hostname = "" + hostname;
117
+ if (altNames) {
118
+ const splitAltNames = altNames.includes('"')
119
+ ? splitEscapedAltNames(altNames)
120
+ : altNames.split(", ");
121
+ splitAltNames.forEach((name) => {
122
+ if (name.startsWith("DNS:")) {
123
+ dnsNames.push(name.slice(4));
124
+ }
125
+ else if (name.startsWith("IP Address:")) {
126
+ ips.push(urlUtil.canonicalizeIp(name.slice(11)));
127
+ }
128
+ });
129
+ }
130
+ let valid = false;
131
+ let reason = "Unknown reason";
132
+ hostname = unfqdn(hostname); // Remove trailing dot for error messages.
133
+ if (isIP(hostname)) {
134
+ valid = ips.includes(urlUtil.canonicalizeIp(hostname));
135
+ if (!valid)
136
+ reason = `IP: ${hostname} is not in the cert's list: ` + ips.join(", ");
137
+ }
138
+ else if (dnsNames.length > 0 || subject?.CN) {
139
+ const hostParts = splitHost(hostname);
140
+ const wildcard = (pattern) => check(hostParts, pattern, true);
141
+ if (dnsNames.length > 0) {
142
+ valid = dnsNames.some(wildcard);
143
+ if (!valid)
144
+ reason = `Host: ${hostname}. is not in the cert's altnames: ${altNames}`;
145
+ }
146
+ else {
147
+ // Match against Common Name only if no supported identifiers exist.
148
+ const cn = subject?.CN;
149
+ if (Array.isArray(cn))
150
+ valid = cn.some(wildcard);
151
+ else if (cn)
152
+ valid = wildcard(cn);
153
+ if (!valid)
154
+ reason = `Host: ${hostname}. is not cert's CN: ${cn}`;
155
+ }
156
+ }
157
+ else {
158
+ reason = "Cert does not contain a DNS name";
159
+ }
160
+ if (!valid) {
161
+ return new ERR_TLS_CERT_ALTNAME_INVALID(reason, hostname, cert);
162
+ }
163
+ return undefined;
164
+ }
165
+ // Convert protocols array into valid OpenSSL protocols list
166
+ // ("\x06spdy/2\x08http/1.1\x08http/1.0")
167
+ function convertProtocols(protocols) {
168
+ const lens = Array.from({ length: protocols.length }, () => 0);
169
+ const buff = Buffer.allocUnsafe(protocols.reduce((p, c, i) => {
170
+ const len = Buffer.byteLength(c);
171
+ if (len > 255) {
172
+ throw new ERR_OUT_OF_RANGE("The byte length of the protocol at index " +
173
+ `${i} exceeds the maximum length.`, "<= 255", len, true);
174
+ }
175
+ lens[i] = len;
176
+ return p + 1 + len;
177
+ }, 0));
178
+ let offset = 0;
179
+ for (let i = 0, c = protocols.length; i < c; i++) {
180
+ buff[offset++] = lens[i];
181
+ buff.write(protocols[i], offset);
182
+ offset += lens[i];
183
+ }
184
+ return buff;
185
+ }
186
+ export function convertALPNProtocols(protocols, out) {
187
+ // If protocols is Array - translate it into buffer
188
+ if (Array.isArray(protocols)) {
189
+ out.ALPNProtocols = convertProtocols(protocols);
190
+ }
191
+ else if (isUint8Array(protocols)) {
192
+ // Copy new buffer not to be modified by user.
193
+ out.ALPNProtocols = Buffer.from(protocols);
194
+ }
195
+ else if (isArrayBufferView(protocols)) {
196
+ out.ALPNProtocols = Buffer.from(protocols.buffer.slice(protocols.byteOffset, protocols.byteOffset + protocols.byteLength));
197
+ }
198
+ }
199
+ export function createServer() {
200
+ throw new Error("Not implemented");
201
+ }
202
+ export function Server() {
203
+ throw new Error("Not implemented");
204
+ }
205
+ export function getCiphers() {
206
+ throw new Error("Not implemented");
207
+ }
@@ -0,0 +1,26 @@
1
+ import { checkServerIdentity, convertALPNProtocols, createServer, Server, getCiphers } from "./helpers.js";
2
+ import { createSecureContext, SecureContext } from "../tls-common/index.js";
3
+ import { TLSSocket, connect } from "./wrap.js";
4
+ declare let createSecurePair: any;
5
+ export * from "./constants.js";
6
+ export { TLSSocket, connect, createSecureContext, createServer, checkServerIdentity, SecureContext, Server, convertALPNProtocols, getCiphers, createSecurePair, };
7
+ declare const _default: {
8
+ CLIENT_RENEG_LIMIT: 3;
9
+ CLIENT_RENEG_WINDOW: 600;
10
+ DEFAULT_CIPHERS: "";
11
+ DEFAULT_ECDH_CURVE: "auto";
12
+ DEFAULT_MIN_VERSION: "TLSv1.2";
13
+ DEFAULT_MAX_VERSION: "TLSv1.3";
14
+ rootCertificates: never[];
15
+ SecureContext: typeof SecureContext;
16
+ Server: typeof Server;
17
+ TLSSocket: typeof TLSSocket;
18
+ connect: typeof connect;
19
+ createSecureContext: typeof createSecureContext;
20
+ createServer: typeof createServer;
21
+ checkServerIdentity: typeof checkServerIdentity;
22
+ convertALPNProtocols: typeof convertALPNProtocols;
23
+ getCiphers: typeof getCiphers;
24
+ createSecurePair: () => void;
25
+ };
26
+ export default _default;
@@ -0,0 +1,50 @@
1
+ // Copyright (c) 2017-2022 Cloudflare, Inc.
2
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
3
+ // https://opensource.org/licenses/Apache-2.0
4
+ //
5
+ // Copyright Joyent, Inc. and other Node contributors.
6
+ //
7
+ // Permission is hereby granted, free of charge, to any person obtaining a
8
+ // copy of this software and associated documentation files (the
9
+ // "Software"), to deal in the Software without restriction, including
10
+ // without limitation the rights to use, copy, modify, merge, publish,
11
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
12
+ // persons to whom the Software is furnished to do so, subject to the
13
+ // following conditions:
14
+ //
15
+ // The above copyright notice and this permission notice shall be included
16
+ // in all copies or substantial portions of the Software.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
21
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+ import { checkServerIdentity, convertALPNProtocols, createServer, Server, getCiphers, } from "./helpers.js";
26
+ import { createSecureContext, SecureContext } from "../tls-common/index.js";
27
+ import * as constants from "./constants.js";
28
+ import { TLSSocket, connect } from "./wrap.js";
29
+ import { ERR_METHOD_NOT_IMPLEMENTED } from "./errors.js";
30
+ let createSecurePair = undefined;
31
+ if (true) {
32
+ createSecurePair = function createSecurePair() {
33
+ throw new ERR_METHOD_NOT_IMPLEMENTED("createSecurePair");
34
+ };
35
+ }
36
+ export * from "./constants.js";
37
+ export { TLSSocket, connect, createSecureContext, createServer, checkServerIdentity, SecureContext, Server, convertALPNProtocols, getCiphers, createSecurePair, };
38
+ export default {
39
+ SecureContext,
40
+ Server,
41
+ TLSSocket,
42
+ connect,
43
+ createSecureContext,
44
+ createServer,
45
+ checkServerIdentity,
46
+ convertALPNProtocols,
47
+ getCiphers,
48
+ createSecurePair,
49
+ ...constants,
50
+ };
@@ -0,0 +1,19 @@
1
+ import { Socket } from "../net/internal-net.js";
2
+ declare const kCurrentWriteRequest: unique symbol;
3
+ declare const kCurrentShutdownRequest: unique symbol;
4
+ declare const kPendingShutdownRequest: unique symbol;
5
+ declare const kPendingClose: unique symbol;
6
+ export declare class JSStreamSocket extends Socket {
7
+ stream: Duplex;
8
+ [kCurrentWriteRequest]: null | unknown;
9
+ [kCurrentShutdownRequest]: null | unknown;
10
+ [kPendingShutdownRequest]: null | unknown;
11
+ [kPendingClose]: boolean;
12
+ constructor(stream: Duplex);
13
+ isClosing(): boolean;
14
+ readStart(): number;
15
+ readStop(): number;
16
+ doShutdown(req: unknown): number;
17
+ doClose(): void;
18
+ }
19
+ export {};
@@ -0,0 +1,196 @@
1
+ // Copyright (c) 2017-2022 Cloudflare, Inc.
2
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
3
+ // https://opensource.org/licenses/Apache-2.0
4
+ //
5
+ // Copyright Joyent, Inc. and other Node contributors.
6
+ //
7
+ // Permission is hereby granted, free of charge, to any person obtaining a
8
+ // copy of this software and associated documentation files (the
9
+ // "Software"), to deal in the Software without restriction, including
10
+ // without limitation the rights to use, copy, modify, merge, publish,
11
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
12
+ // persons to whom the Software is furnished to do so, subject to the
13
+ // following conditions:
14
+ //
15
+ // The above copyright notice and this permission notice shall be included
16
+ // in all copies or substantial portions of the Software.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
21
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
26
+ import { markInternalErrorInterruption } from "../stream/destroy.js";
27
+ import { notStrictEqual } from "../assert/index.js";
28
+ import { Socket } from "../net/internal-net.js";
29
+ import { ERR_STREAM_WRAP } from "./errors.js";
30
+ import { toBYOBWeb } from "../stream/duplex.js";
31
+ const kCurrentWriteRequest = Symbol("kCurrentWriteRequest");
32
+ const kCurrentShutdownRequest = Symbol("kCurrentShutdownRequest");
33
+ const kPendingShutdownRequest = Symbol("kPendingShutdownRequest");
34
+ const kPendingClose = Symbol("kPendingClose");
35
+ /* This class serves as a wrapper for when the C++ side of Node wants access
36
+ * to a standard JS stream. For example, TLS or HTTP do not operate on network
37
+ * resources conceptually, although that is the common case and what we are
38
+ * optimizing for; in theory, they are completely composable and can work with
39
+ * any stream resource they see.
40
+ *
41
+ * For the common case, i.e. a TLS socket wrapping around a net.Socket, we
42
+ * can skip going through the JS layer and let TLS access the raw C++ handle
43
+ * of a net.Socket. The flipside of this is that, to maintain composability,
44
+ * we need a way to create "fake" net.Socket instances that call back into a
45
+ * "real" JavaScript stream. JSStreamSocket is exactly this.
46
+ */
47
+ export class JSStreamSocket extends Socket {
48
+ stream;
49
+ [kCurrentWriteRequest];
50
+ [kCurrentShutdownRequest];
51
+ [kPendingShutdownRequest];
52
+ [kPendingClose];
53
+ constructor(stream) {
54
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
55
+ const closePromise = Promise.withResolvers();
56
+ const openPromise = Promise.withResolvers();
57
+ const webStream = toBYOBWeb(stream);
58
+ Object.assign(webStream.writable, {
59
+ // eslint-disable-next-line @typescript-eslint/require-await
60
+ write: async (data) => {
61
+ stream.write(data);
62
+ },
63
+ closed: closePromise.promise,
64
+ releaseLock: async () => { },
65
+ });
66
+ const handle = {
67
+ reading: true,
68
+ bytesRead: 0,
69
+ bytesWritten: 0,
70
+ socket: {
71
+ startTls() {
72
+ throw new Error("startTls() should not be called for a duplex stream");
73
+ },
74
+ upgraded: false,
75
+ secureTransport: "off",
76
+ closed: closePromise.promise,
77
+ close: async () => {
78
+ queueMicrotask(() => {
79
+ closePromise.resolve();
80
+ });
81
+ return closePromise.promise;
82
+ },
83
+ opened: openPromise.promise,
84
+ readable: webStream.readable,
85
+ writable: webStream.writable,
86
+ },
87
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
88
+ reader: webStream.readable.getReader({ mode: "byob" }),
89
+ writer: webStream.writable.getWriter(),
90
+ options: {
91
+ host: "0.0.0.0",
92
+ port: 0,
93
+ addressType: 4,
94
+ },
95
+ };
96
+ stream.pause();
97
+ stream.on("error", (err) => {
98
+ const unobserved = this.listenerCount("error") === 0;
99
+ try {
100
+ this.emit("error", err);
101
+ }
102
+ catch (error) {
103
+ if (unobserved)
104
+ markInternalErrorInterruption(stream, error);
105
+ throw error;
106
+ }
107
+ });
108
+ const ondata = (chunk) => {
109
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare
110
+ if (typeof chunk === "string" || stream.readableObjectMode === true) {
111
+ // Make sure that no further `data` events will happen.
112
+ stream.pause();
113
+ stream.removeListener("data", ondata);
114
+ throw new ERR_STREAM_WRAP();
115
+ }
116
+ // TODO(soon): We need to trigger read() result for _handle.reader.read(buf) call
117
+ // in node:net.
118
+ };
119
+ stream.prependListener("data", ondata);
120
+ stream.once("end", () => {
121
+ closePromise.resolve();
122
+ });
123
+ // Some `Stream` don't pass `hasError` parameters when closed.
124
+ stream.once("close", () => {
125
+ // Errors emitted from `stream` have also been emitted to this instance
126
+ // so that we don't pass errors to `destroy()` again.
127
+ this.destroy();
128
+ });
129
+ super({ handle });
130
+ this.stream = stream;
131
+ this[kCurrentWriteRequest] = null;
132
+ this[kCurrentShutdownRequest] = null;
133
+ this[kPendingShutdownRequest] = null;
134
+ this[kPendingClose] = false;
135
+ this.readable = stream.readable;
136
+ this.writable = stream.writable;
137
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
138
+ handle.socket.closed.then(this.doClose.bind(this));
139
+ openPromise.resolve({});
140
+ // Start reading.
141
+ this.read(0);
142
+ }
143
+ isClosing() {
144
+ return !this.readable || !this.writable;
145
+ }
146
+ readStart() {
147
+ this.stream.resume();
148
+ return 0;
149
+ }
150
+ readStop() {
151
+ this.stream.pause();
152
+ return 0;
153
+ }
154
+ doShutdown(req) {
155
+ // TODO(addaleax): It might be nice if we could get into a state where
156
+ // DoShutdown() is not called on streams while a write is still pending.
157
+ //
158
+ // Currently, the only part of the code base where that happens is the
159
+ // TLS implementation, which calls both DoWrite() and DoShutdown() on the
160
+ // underlying network stream inside of its own DoShutdown() method.
161
+ // Working around that on the native side is not quite trivial (yet?),
162
+ // so for now that is supported here.
163
+ if (this[kCurrentWriteRequest] !== null) {
164
+ this[kPendingShutdownRequest] = req;
165
+ return 0;
166
+ }
167
+ this[kCurrentShutdownRequest] = req;
168
+ if (this[kPendingClose]) {
169
+ // If doClose is pending, the stream & this._handle are gone. We can't do
170
+ // anything. doClose will call finishShutdown with ECANCELED for us shortly.
171
+ return 0;
172
+ }
173
+ const handle = this._handle;
174
+ notStrictEqual(handle, null);
175
+ queueMicrotask(() => {
176
+ // Ensure that write is dispatched asynchronously.
177
+ this.stream.end();
178
+ });
179
+ return 0;
180
+ }
181
+ doClose() {
182
+ this[kPendingClose] = true;
183
+ const handle = this._handle;
184
+ // When sockets of the "net" module destroyed, they will call
185
+ // `this._handle.close()` which will also emit EOF if not emitted before.
186
+ // This feature makes sockets on the other side emit "end" and "close"
187
+ // even though we haven't called `end()`. As `stream` are likely to be
188
+ // instances of `net.Socket`, calling `stream.destroy()` manually will
189
+ // avoid issues that don't properly close wrapped connections.
190
+ this.stream.destroy();
191
+ queueMicrotask(() => {
192
+ notStrictEqual(handle, null);
193
+ this[kPendingClose] = false;
194
+ });
195
+ }
196
+ }
@@ -0,0 +1,3 @@
1
+ import type { NativeCall } from "../../browser/fetch/native-network.js";
2
+ /** Memory-BIO encryption on the original TCP stream, with mandatory OS trust. */
3
+ export declare function nativeTlsSession(call: NativeCall, id: string, hostname: string): Promise<NativeCall>;
@@ -0,0 +1,187 @@
1
+ import { NativeTLS } from "../crypto/native-crypto.js";
2
+ function decode(value) {
3
+ return Uint8Array.from(atob(value), (character) => character.charCodeAt(0));
4
+ }
5
+ function encode(value) {
6
+ let text = "";
7
+ for (let i = 0; i < value.length; i += 8192)
8
+ text += String.fromCharCode(...value.subarray(i, i + 8192));
9
+ return btoa(text);
10
+ }
11
+ /** Memory-BIO encryption on the original TCP stream, with mandatory OS trust. */
12
+ export async function nativeTlsSession(call, id, hostname) {
13
+ const tls = new NativeTLS(hostname);
14
+ let stopped = false, eof = false, pumping = false;
15
+ let buffered;
16
+ let incoming;
17
+ let outgoing = Promise.resolve();
18
+ let reading;
19
+ let resolveWatch, rejectWatch;
20
+ const watched = new Promise((resolve, reject) => {
21
+ resolveWatch = resolve;
22
+ rejectWatch = reject;
23
+ });
24
+ void watched.catch(() => { });
25
+ const stop = (error) => {
26
+ if (stopped)
27
+ return;
28
+ stopped = true;
29
+ tls.dispose();
30
+ buffered = undefined;
31
+ reading?.reject(error ?? new Error("TLS session closed"));
32
+ reading = undefined;
33
+ if (error)
34
+ rejectWatch(error);
35
+ else
36
+ resolveWatch({});
37
+ };
38
+ const flush = () => {
39
+ for (const data of tls.drain()) {
40
+ outgoing = outgoing.then(async () => {
41
+ if (stopped)
42
+ throw new Error("TLS session closed");
43
+ await call("WorkersCapacitor", "socketWrite", {
44
+ id,
45
+ chunk: encode(data),
46
+ });
47
+ });
48
+ }
49
+ return outgoing;
50
+ };
51
+ const receive = () => (incoming ??= (async () => {
52
+ const value = (await call("WorkersCapacitor", "socketRead", {
53
+ id,
54
+ maxBytes: 65536,
55
+ }));
56
+ if (stopped)
57
+ throw new Error("TLS session closed");
58
+ if (value.eof)
59
+ throw new Error("TLS connection closed without close_notify");
60
+ if (typeof value.chunk !== "string")
61
+ throw new Error("Invalid TLS transport response");
62
+ tls.feed(decode(value.chunk));
63
+ })().finally(() => {
64
+ incoming = undefined;
65
+ }));
66
+ const retry = async (status) => {
67
+ await flush();
68
+ if (status === -2)
69
+ await receive();
70
+ else if (status !== -3)
71
+ throw new Error(`TLS operation failed (${status})`);
72
+ };
73
+ const deliver = () => {
74
+ if (buffered && reading) {
75
+ const pending = reading;
76
+ reading = undefined;
77
+ const data = buffered.subarray(0, pending.count);
78
+ buffered =
79
+ buffered.byteLength > data.byteLength
80
+ ? buffered.subarray(data.byteLength)
81
+ : undefined;
82
+ pending.resolve({ chunk: encode(data) });
83
+ }
84
+ if (eof && !buffered) {
85
+ reading?.resolve({ eof: true });
86
+ reading = undefined;
87
+ resolveWatch({});
88
+ }
89
+ };
90
+ const pump = async () => {
91
+ if (pumping || stopped)
92
+ return;
93
+ pumping = true;
94
+ try {
95
+ while (!stopped && !eof && !buffered) {
96
+ const result = tls.read();
97
+ if (result instanceof Uint8Array) {
98
+ buffered = result;
99
+ deliver();
100
+ }
101
+ else if (result === -6) {
102
+ eof = true;
103
+ deliver();
104
+ }
105
+ else
106
+ await retry(result);
107
+ }
108
+ }
109
+ catch (error) {
110
+ stop(error);
111
+ }
112
+ finally {
113
+ pumping = false;
114
+ }
115
+ };
116
+ try {
117
+ for (;;) {
118
+ const status = tls.handshake();
119
+ if (status === 1)
120
+ break;
121
+ await retry(status);
122
+ }
123
+ await flush();
124
+ const certificates = tls.certificates();
125
+ if (!certificates.length)
126
+ throw new Error("TLS peer did not present a certificate");
127
+ // No application reads/writes or successful open are exposed before this.
128
+ await call("WorkersCapacitor", "socketVerifyTls", {
129
+ id,
130
+ servername: hostname,
131
+ certificates: certificates.map(encode),
132
+ });
133
+ }
134
+ catch (error) {
135
+ stop(error);
136
+ throw error;
137
+ }
138
+ void pump();
139
+ return async (plugin, method, args) => {
140
+ if (method === "socketClose") {
141
+ stop();
142
+ return call(plugin, method, args);
143
+ }
144
+ if (method === "socketWatch")
145
+ return watched;
146
+ if (stopped)
147
+ throw new Error("TLS session closed");
148
+ if (method === "socketRead") {
149
+ if (reading)
150
+ throw new Error("TLS read already pending");
151
+ return new Promise((resolve, reject) => {
152
+ reading = { count: Number(args.maxBytes ?? 65536), resolve, reject };
153
+ deliver();
154
+ void pump();
155
+ });
156
+ }
157
+ try {
158
+ if (method === "socketWrite") {
159
+ const data = decode(String(args.chunk));
160
+ for (let offset = 0; offset < data.length;) {
161
+ const status = tls.write(data.subarray(offset));
162
+ if (status > 0)
163
+ offset += status;
164
+ else
165
+ await retry(status);
166
+ }
167
+ await flush();
168
+ return {};
169
+ }
170
+ if (method === "socketEnd") {
171
+ for (;;) {
172
+ const status = tls.shutdown();
173
+ if (status >= 0)
174
+ break;
175
+ await retry(status);
176
+ }
177
+ await flush();
178
+ return {};
179
+ }
180
+ return await call(plugin, method, args);
181
+ }
182
+ catch (error) {
183
+ stop(error);
184
+ throw error;
185
+ }
186
+ };
187
+ }