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,239 @@
1
+ // Workers CipherHandle/AeadHandle lifecycle, pinned to workerd
2
+ // 5358e3d337336eaf696a48bc1563d808b10feba5 (crypto.c++), Apache-2.0.
3
+ import { library, inputs, output, size } from "./native-cipher.js";
4
+ import { secretMaterial } from "./keys.js";
5
+ import { bufferBytes, viewBytes } from "../../shared/buffer-source.js";
6
+ import { isAnyBuffer } from "./validation.js";
7
+ const aeadNames = new Set([
8
+ "aes-128-gcm",
9
+ "aes-192-gcm",
10
+ "aes-256-gcm",
11
+ "aes-128-eax",
12
+ "aes-256-eax",
13
+ "aes-128-ccm-matter",
14
+ "aes-128-ccm-bluetooth",
15
+ "aes-128-ccm-bluetooth-8",
16
+ "aes-128-gcm-randnonce",
17
+ "aes-256-gcm-randnonce",
18
+ "aes-128-gcm-siv",
19
+ "aes-256-gcm-siv",
20
+ "aes-128-ctr-hmac-sha256",
21
+ "aes-256-ctr-hmac-sha256",
22
+ "xchacha20-poly1305",
23
+ "chacha20-poly1305",
24
+ ]);
25
+ const finalized = "Cipher/decipher context has already been finalized";
26
+ function requireValue(value, message) {
27
+ if (!value)
28
+ throw new Error(message);
29
+ }
30
+ function bytes(value) {
31
+ if (isAnyBuffer(value))
32
+ return bufferBytes(value);
33
+ if (ArrayBuffer.isView(value))
34
+ return viewBytes(value);
35
+ throw new TypeError("Expected an ArrayBuffer or ArrayBufferView");
36
+ }
37
+ const released = new FinalizationRegistry(({ pointer, aead }) => library()[aead ? "cipher_aead_free" : "cipher_free"](pointer));
38
+ const validTag = (n) => n === 4 || n === 8 || (n >= 12 && n <= 16);
39
+ export class CipherHandle {
40
+ pointer = 0;
41
+ aead = false;
42
+ auth = false;
43
+ mode = 0;
44
+ block = 1;
45
+ iv;
46
+ aad;
47
+ tag;
48
+ tagLength;
49
+ tagPassed = false;
50
+ updated = false;
51
+ decrypt;
52
+ constructor(direction, algorithm, key, iv, tagLength) {
53
+ this.decrypt = direction === 1;
54
+ this.iv = bytes(iv).slice();
55
+ this.tagLength = tagLength;
56
+ const material = secretMaterial(key), raw = bytes(material);
57
+ try {
58
+ inputs([algorithm, algorithm.toLowerCase().replaceAll("-", "_"), raw, this.iv], (api, [name, aeadName, k, v]) => {
59
+ const cipher = api.cipher_lookup(name);
60
+ if (cipher) {
61
+ this.mode = api.cipher_info(cipher, 3);
62
+ this.auth = this.mode === 6;
63
+ this.block = api.cipher_info(cipher, 2);
64
+ const expected = api.cipher_info(cipher, 1);
65
+ requireValue(!(expected && !this.iv.length) &&
66
+ !(!this.auth && this.iv.length && this.iv.length !== expected), "Invalid initialization vector");
67
+ this.pointer = api.cipher_new();
68
+ requireValue(this.pointer, "Failed to create cipher/decipher context");
69
+ requireValue(api.cipher_init(this.pointer, cipher, 0, 0, +!this.decrypt), "Failed to initialize cipher/decipher context");
70
+ if (this.auth) {
71
+ requireValue(api.cipher_iv_size(this.pointer, this.iv.length), "Invalid initialization vector");
72
+ requireValue(tagLength === undefined || validTag(tagLength), "Invalid authentication tag length");
73
+ }
74
+ requireValue(api.cipher_key_size(this.pointer, raw.length), "Invalid key length");
75
+ requireValue(api.cipher_init(this.pointer, 0, k, v, +!this.decrypt), "Failed to initialize cipher/cipher context");
76
+ }
77
+ else {
78
+ const aead = aeadNames.has(algorithm.toLowerCase())
79
+ ? api.cipher_aead(aeadName)
80
+ : 0;
81
+ requireValue(aead, "Unknown or unsupported cipher: " + algorithm);
82
+ this.aead = true;
83
+ this.auth = true;
84
+ this.mode = algorithm.toLowerCase().includes("gcm")
85
+ ? 6
86
+ : algorithm.toLowerCase().includes("ccm")
87
+ ? 7
88
+ : 0;
89
+ requireValue(this.iv.length === api.cipher_aead_info(aead, 1), "Invalid initialization vector");
90
+ this.pointer = api.cipher_aead_new(aead, k, raw.length, tagLength ?? 0);
91
+ requireValue(this.pointer, "Failed to initialize AEAD cipher/decipher context");
92
+ if (this.mode === 6)
93
+ requireValue(tagLength === undefined || validTag(tagLength), "Invalid authentication tag length");
94
+ else if (tagLength === undefined) {
95
+ requireValue(algorithm.toLowerCase() === "chacha20-poly1305", "The auth tag length is required for cipher " + algorithm);
96
+ this.tagLength = 16;
97
+ }
98
+ }
99
+ });
100
+ released.register(this, { pointer: this.pointer, aead: this.aead }, this);
101
+ }
102
+ catch (error) {
103
+ this.dispose();
104
+ throw error;
105
+ }
106
+ }
107
+ dispose() {
108
+ if (this.pointer) {
109
+ library()[this.aead ? "cipher_aead_free" : "cipher_free"](this.pointer);
110
+ this.pointer = 0;
111
+ released.unregister(this);
112
+ }
113
+ this.iv.fill(0);
114
+ this.aad?.fill(0);
115
+ }
116
+ passTag() {
117
+ if (this.decrypt && this.auth && !this.tagPassed) {
118
+ this.tagPassed = true;
119
+ requireValue(this.tag, "No auth tag provided");
120
+ inputs([this.tag], (api, [p]) => requireValue(api.cipher_tag(this.pointer, 0, this.tag.length, p), "Failed to set auth tag"));
121
+ }
122
+ }
123
+ update(value) {
124
+ if (this.aead)
125
+ requireValue(!this.updated, "update() can only be invoked once on an AEAD");
126
+ requireValue(this.pointer, finalized);
127
+ const data = bytes(value);
128
+ requireValue(data.length <= 0x7fffffff, "Data too large");
129
+ if (this.mode === 7)
130
+ requireValue(data.length <= 65535, "Invalid message length");
131
+ requireValue(data.length + this.block <= 0x7fffffff, "Data too large");
132
+ if (this.aead) {
133
+ if (this.decrypt)
134
+ requireValue(this.tag, "No auth tag provided");
135
+ else
136
+ this.tagLength ??= 16;
137
+ const tagLength = this.decrypt ? this.tag.length : this.tagLength;
138
+ const result = inputs([
139
+ data,
140
+ this.iv,
141
+ this.aad ?? new Uint8Array(),
142
+ this.tag ?? tagLength,
143
+ data.length,
144
+ 4,
145
+ ], (api, [d, v, a, t, o, n]) => {
146
+ const ok = this.decrypt
147
+ ? api.cipher_aead_open(this.pointer, o, v, this.iv.length, d, data.length, t, tagLength, a, this.aad?.length ?? 0)
148
+ : api.cipher_aead_seal(this.pointer, o, t, n, tagLength, v, this.iv.length, d, data.length, a, this.aad?.length ?? 0);
149
+ // Workers exposes this backend failure as an internal Error with a per-run reference.
150
+ if (!ok && api.cipher_bad_decrypt())
151
+ throw new DOMException("Decryption failed: Incorrect key/IV or corrupted ciphertext/authentication tag provided.", "OperationError");
152
+ requireValue(ok, "internal error");
153
+ if (!this.decrypt)
154
+ this.tag = output(api, t, size(api, n));
155
+ return output(api, o, data.length);
156
+ });
157
+ this.updated = true;
158
+ return result;
159
+ }
160
+ this.passTag();
161
+ return inputs([data, data.length + this.block, 4], (api, [d, o, n]) => {
162
+ api.cipher_update(this.pointer, o, n, d, data.length);
163
+ const length = size(api, n);
164
+ requireValue(length <= data.length + this.block, "Invalid buffer length");
165
+ return output(api, o, length);
166
+ });
167
+ }
168
+ final() {
169
+ requireValue(this.pointer, finalized);
170
+ if (this.aead) {
171
+ this.dispose();
172
+ return new Uint8Array();
173
+ }
174
+ this.passTag();
175
+ const result = inputs([this.block, 4], (api, [o, n]) => {
176
+ requireValue(api.cipher_final(this.pointer, o, n), "Authentication failed");
177
+ const length = size(api, n);
178
+ requireValue(length <= this.block, "Invalid buffer length");
179
+ if (!this.decrypt && this.auth) {
180
+ this.tagLength ??= 16;
181
+ this.tag = inputs([this.tagLength], (api, [t]) => {
182
+ requireValue(api.cipher_tag(this.pointer, 1, this.tagLength, t), "Authentication failed");
183
+ return output(api, t, this.tagLength);
184
+ });
185
+ }
186
+ return output(api, o, length);
187
+ });
188
+ this.dispose();
189
+ return result;
190
+ }
191
+ setAAD(value, plaintextLength) {
192
+ requireValue(this.pointer, finalized);
193
+ requireValue(this.auth, "Cipher does not support authenticated mode");
194
+ const data = bytes(value);
195
+ if (this.aead) {
196
+ if (this.mode === 7) {
197
+ requireValue(plaintextLength !== undefined, "options.plaintextLength is required for CCM mode with AAD");
198
+ requireValue(plaintextLength <= 65535, "Data too large");
199
+ if (this.decrypt)
200
+ requireValue(this.tag, "No auth tag provided");
201
+ }
202
+ this.aad?.fill(0);
203
+ this.aad = data.slice();
204
+ }
205
+ else
206
+ inputs([data, 4], (api, [p, n]) => requireValue(api.cipher_update(this.pointer, 0, n, p, data.length), "Failed to set AAD"));
207
+ }
208
+ setAutoPadding(value) {
209
+ requireValue(this.pointer, finalized);
210
+ requireValue(!this.aead, "Setting autopadding is not supported on AEADs");
211
+ requireValue(library().cipher_padding(this.pointer, +value), "Failed to set autopadding");
212
+ }
213
+ setAuthTag(value) {
214
+ if (!isAnyBuffer(value) && !ArrayBuffer.isView(value))
215
+ throw new TypeError(`Failed to execute 'setAuthTag' on '${this.aead ? "AeadHandle" : "CipherHandle"}': parameter 1 is not of type 'BufferSource'.`);
216
+ requireValue(this.pointer, finalized);
217
+ requireValue(this.auth, "Cipher does not support authenticated mode");
218
+ requireValue(this.decrypt, "Setting auth tag only support in decipher mode");
219
+ requireValue(!this.tag, "Auth tag is already set");
220
+ const data = bytes(value);
221
+ requireValue(data.length <= 0x7fffffff, "Auth tag is too big");
222
+ requireValue(this.mode === 6
223
+ ? (this.tagLength === undefined || this.tagLength === data.length) &&
224
+ validTag(data.length)
225
+ : this.tagLength === data.length, "Invalid authentication tag length");
226
+ this.tagLength = data.length;
227
+ this.tag = data.slice();
228
+ }
229
+ getAuthTag() {
230
+ requireValue(!this.pointer, "Auth tag is only available once cipher context has been finalized");
231
+ requireValue(!this.decrypt, "Getting the auth tag is only support for cipher");
232
+ const tag = this.tag ?? new Uint8Array();
233
+ this.tag = undefined;
234
+ return tag;
235
+ }
236
+ }
237
+ export default {
238
+ newHandle: (...args) => new CipherHandle(...args),
239
+ };
@@ -0,0 +1,12 @@
1
+ export interface CipherInfo {
2
+ name: string;
3
+ nid: number;
4
+ blockSize: number;
5
+ ivLength: number;
6
+ keyLength: number;
7
+ mode: string;
8
+ }
9
+ export declare function getCipherInfo(nameOrId: string | number, options?: {
10
+ keyLength?: number;
11
+ ivLength?: number;
12
+ }): CipherInfo | undefined;
@@ -0,0 +1,324 @@
1
+ // Cipher metadata from workerd@5358e3d337336eaf696a48bc1563d808b10feba5.
2
+ // Metadata lookup does not imply that the local backend implements the cipher.
3
+ import { validateObject } from "../net/validators.js";
4
+ import { ERR_INVALID_ARG_TYPE } from "../net/errors.js";
5
+ const ciphers = {
6
+ "aes-128-cbc": {
7
+ name: "AES-128-CBC",
8
+ nid: 419,
9
+ blockSize: 16,
10
+ ivLength: 16,
11
+ keyLength: 16,
12
+ mode: "cbc",
13
+ },
14
+ "aes-192-cbc": {
15
+ name: "AES-192-CBC",
16
+ nid: 423,
17
+ blockSize: 16,
18
+ ivLength: 16,
19
+ keyLength: 24,
20
+ mode: "cbc",
21
+ },
22
+ "aes-256-cbc": {
23
+ name: "AES-256-CBC",
24
+ nid: 427,
25
+ blockSize: 16,
26
+ ivLength: 16,
27
+ keyLength: 32,
28
+ mode: "cbc",
29
+ },
30
+ "aes-128-ctr": {
31
+ name: "AES-128-CTR",
32
+ nid: 904,
33
+ blockSize: 1,
34
+ ivLength: 16,
35
+ keyLength: 16,
36
+ mode: "ctr",
37
+ },
38
+ "aes-192-ctr": {
39
+ name: "AES-192-CTR",
40
+ nid: 905,
41
+ blockSize: 1,
42
+ ivLength: 16,
43
+ keyLength: 24,
44
+ mode: "ctr",
45
+ },
46
+ "aes-256-ctr": {
47
+ name: "AES-256-CTR",
48
+ nid: 906,
49
+ blockSize: 1,
50
+ ivLength: 16,
51
+ keyLength: 32,
52
+ mode: "ctr",
53
+ },
54
+ "aes-128-ecb": {
55
+ name: "AES-128-ECB",
56
+ nid: 418,
57
+ blockSize: 16,
58
+ ivLength: 0,
59
+ keyLength: 16,
60
+ mode: "ecb",
61
+ },
62
+ "aes-192-ecb": {
63
+ name: "AES-192-ECB",
64
+ nid: 422,
65
+ blockSize: 16,
66
+ ivLength: 0,
67
+ keyLength: 24,
68
+ mode: "ecb",
69
+ },
70
+ "aes-256-ecb": {
71
+ name: "AES-256-ECB",
72
+ nid: 426,
73
+ blockSize: 16,
74
+ ivLength: 0,
75
+ keyLength: 32,
76
+ mode: "ecb",
77
+ },
78
+ "aes-128-ofb": {
79
+ name: "AES-128-OFB",
80
+ nid: 420,
81
+ blockSize: 1,
82
+ ivLength: 16,
83
+ keyLength: 16,
84
+ mode: "ofb",
85
+ },
86
+ "aes-192-ofb": {
87
+ name: "AES-192-OFB",
88
+ nid: 424,
89
+ blockSize: 1,
90
+ ivLength: 16,
91
+ keyLength: 24,
92
+ mode: "ofb",
93
+ },
94
+ "aes-256-ofb": {
95
+ name: "AES-256-OFB",
96
+ nid: 428,
97
+ blockSize: 1,
98
+ ivLength: 16,
99
+ keyLength: 32,
100
+ mode: "ofb",
101
+ },
102
+ "aes-128-gcm": {
103
+ name: "id-aes128-GCM",
104
+ nid: 895,
105
+ blockSize: 1,
106
+ ivLength: 12,
107
+ keyLength: 16,
108
+ mode: "gcm",
109
+ },
110
+ "aes-192-gcm": {
111
+ name: "id-aes192-GCM",
112
+ nid: 898,
113
+ blockSize: 1,
114
+ ivLength: 12,
115
+ keyLength: 24,
116
+ mode: "gcm",
117
+ },
118
+ "aes-256-gcm": {
119
+ name: "id-aes256-GCM",
120
+ nid: 901,
121
+ blockSize: 1,
122
+ ivLength: 12,
123
+ keyLength: 32,
124
+ mode: "gcm",
125
+ },
126
+ "des-cbc": {
127
+ name: "DES-CBC",
128
+ nid: 31,
129
+ blockSize: 8,
130
+ ivLength: 8,
131
+ keyLength: 8,
132
+ mode: "cbc",
133
+ },
134
+ "des-ecb": {
135
+ name: "DES-ECB",
136
+ nid: 29,
137
+ blockSize: 8,
138
+ ivLength: 0,
139
+ keyLength: 8,
140
+ mode: "ecb",
141
+ },
142
+ "des-ede": {
143
+ name: "DES-EDE",
144
+ nid: 32,
145
+ blockSize: 8,
146
+ ivLength: 0,
147
+ keyLength: 16,
148
+ mode: "ecb",
149
+ },
150
+ "des-ede-cbc": {
151
+ name: "DES-EDE-CBC",
152
+ nid: 43,
153
+ blockSize: 8,
154
+ ivLength: 8,
155
+ keyLength: 16,
156
+ mode: "cbc",
157
+ },
158
+ "des-ede3-cbc": {
159
+ name: "DES-EDE3-CBC",
160
+ nid: 44,
161
+ blockSize: 8,
162
+ ivLength: 8,
163
+ keyLength: 24,
164
+ mode: "cbc",
165
+ },
166
+ "rc2-cbc": {
167
+ name: "RC2-CBC",
168
+ nid: 37,
169
+ blockSize: 8,
170
+ ivLength: 8,
171
+ keyLength: 16,
172
+ mode: "cbc",
173
+ },
174
+ rc4: {
175
+ name: "RC4",
176
+ nid: 5,
177
+ blockSize: 1,
178
+ ivLength: 0,
179
+ keyLength: 16,
180
+ mode: "stream",
181
+ },
182
+ "aes-256-eax": {
183
+ name: "aes-256-eax",
184
+ nid: 0,
185
+ blockSize: 1,
186
+ ivLength: 16,
187
+ keyLength: 32,
188
+ mode: "stream",
189
+ },
190
+ "aes-128-ccm-matter": {
191
+ name: "aes-128-ccm-matter",
192
+ nid: 0,
193
+ blockSize: 1,
194
+ ivLength: 13,
195
+ keyLength: 16,
196
+ mode: "ccm",
197
+ },
198
+ "aes-128-ccm-bluetooth-8": {
199
+ name: "aes-128-ccm-bluetooth-8",
200
+ nid: 0,
201
+ blockSize: 1,
202
+ ivLength: 13,
203
+ keyLength: 16,
204
+ mode: "ccm",
205
+ },
206
+ "aes-128-gcm-randnonce": {
207
+ name: "aes-128-gcm-randnonce",
208
+ nid: 0,
209
+ blockSize: 1,
210
+ ivLength: 0,
211
+ keyLength: 16,
212
+ mode: "gcm",
213
+ },
214
+ "aes-256-gcm-randnonce": {
215
+ name: "aes-256-gcm-randnonce",
216
+ nid: 0,
217
+ blockSize: 1,
218
+ ivLength: 0,
219
+ keyLength: 32,
220
+ mode: "gcm",
221
+ },
222
+ "aes-128-gcm-siv": {
223
+ name: "aes-128-gcm-siv",
224
+ nid: 0,
225
+ blockSize: 1,
226
+ ivLength: 12,
227
+ keyLength: 16,
228
+ mode: "gcm",
229
+ },
230
+ "aes-128-ccm-bluetooth": {
231
+ name: "aes-128-ccm-bluetooth",
232
+ nid: 0,
233
+ blockSize: 1,
234
+ ivLength: 13,
235
+ keyLength: 16,
236
+ mode: "ccm",
237
+ },
238
+ "aes-256-ctr-hmac-sha256": {
239
+ name: "aes-256-ctr-hmac-sha256",
240
+ nid: 0,
241
+ blockSize: 1,
242
+ ivLength: 12,
243
+ keyLength: 64,
244
+ mode: "ctr",
245
+ },
246
+ "aes-128-ctr-hmac-sha256": {
247
+ name: "aes-128-ctr-hmac-sha256",
248
+ nid: 0,
249
+ blockSize: 1,
250
+ ivLength: 12,
251
+ keyLength: 48,
252
+ mode: "ctr",
253
+ },
254
+ "xchacha20-poly1305": {
255
+ name: "xchacha20-poly1305",
256
+ nid: 0,
257
+ blockSize: 1,
258
+ ivLength: 24,
259
+ keyLength: 32,
260
+ mode: "stream",
261
+ },
262
+ "aes-256-gcm-siv": {
263
+ name: "aes-256-gcm-siv",
264
+ nid: 0,
265
+ blockSize: 1,
266
+ ivLength: 12,
267
+ keyLength: 32,
268
+ mode: "gcm",
269
+ },
270
+ "aes-128-eax": {
271
+ name: "aes-128-eax",
272
+ nid: 0,
273
+ blockSize: 1,
274
+ ivLength: 16,
275
+ keyLength: 16,
276
+ mode: "stream",
277
+ },
278
+ "chacha20-poly1305": {
279
+ name: "chacha20-poly1305",
280
+ nid: 950,
281
+ blockSize: 1,
282
+ ivLength: 12,
283
+ keyLength: 32,
284
+ mode: "stream",
285
+ },
286
+ };
287
+ export function getCipherInfo(nameOrId, options = {}) {
288
+ if (typeof nameOrId !== "string" && typeof nameOrId !== "number")
289
+ throw new ERR_INVALID_ARG_TYPE("nameOrId", ["string", "number"], nameOrId);
290
+ validateObject(options, "options");
291
+ // The native binding converts both optional lengths before looking up a cipher.
292
+ const keyLength = options.keyLength === undefined ? undefined : Number(options.keyLength) | 0;
293
+ const ivLength = options.ivLength === undefined ? undefined : Number(options.ivLength) | 0;
294
+ const found = typeof nameOrId === "string"
295
+ ? ciphers[nameOrId.toLowerCase()]
296
+ : Object.values(ciphers).find((c) => c.nid !== 0 && c.nid !== 950 && c.nid === (nameOrId | 0));
297
+ if (!found)
298
+ return;
299
+ const result = { ...found };
300
+ // BoringSSL AEAD metadata uses a separate lookup, without length overrides.
301
+ if (found.nid === 0 || found.nid === 950) {
302
+ result.name = String(nameOrId);
303
+ return result;
304
+ }
305
+ if (keyLength !== undefined) {
306
+ if (found.nid === 5 || found.nid === 37) {
307
+ if (keyLength <= 0)
308
+ return;
309
+ }
310
+ else if (keyLength !== found.keyLength)
311
+ return;
312
+ result.keyLength = keyLength;
313
+ }
314
+ if (ivLength !== undefined) {
315
+ if (found.mode === "gcm") {
316
+ if (ivLength <= 0)
317
+ return;
318
+ }
319
+ else if (ivLength !== found.ivLength)
320
+ return;
321
+ result.ivLength = ivLength;
322
+ }
323
+ return result;
324
+ }
@@ -0,0 +1,62 @@
1
+ declare const values: {
2
+ readonly DH_CHECK_P_NOT_SAFE_PRIME: 2;
3
+ readonly DH_CHECK_P_NOT_PRIME: 1;
4
+ readonly DH_UNABLE_TO_CHECK_GENERATOR: 4;
5
+ readonly DH_NOT_SUITABLE_GENERATOR: 8;
6
+ readonly RSA_PKCS1_PADDING: 1;
7
+ readonly RSA_NO_PADDING: 3;
8
+ readonly RSA_PKCS1_OAEP_PADDING: 4;
9
+ readonly RSA_X931_PADDING: 5;
10
+ readonly RSA_PKCS1_PSS_PADDING: 6;
11
+ readonly RSA_PSS_SALTLEN_DIGEST: -1;
12
+ readonly RSA_PSS_SALTLEN_MAX_SIGN: -2;
13
+ readonly RSA_PSS_SALTLEN_AUTO: -2;
14
+ readonly POINT_CONVERSION_COMPRESSED: 2;
15
+ readonly POINT_CONVERSION_UNCOMPRESSED: 4;
16
+ readonly POINT_CONVERSION_HYBRID: 6;
17
+ readonly OPENSSL_VERSION_NUMBER: 0;
18
+ readonly SSL_OP_ALL: 2147485776;
19
+ readonly SSL_OP_ALLOW_NO_DHE_KEX: 1024;
20
+ readonly SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: 262144;
21
+ readonly SSL_OP_CIPHER_SERVER_PREFERENCE: 4194304;
22
+ readonly SSL_OP_CISCO_ANYCONNECT: 32768;
23
+ readonly SSL_OP_COOKIE_EXCHANGE: 8192;
24
+ readonly SSL_OP_CRYPTOPRO_TLSEXT_BUG: 2147483648;
25
+ readonly SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: 2048;
26
+ readonly SSL_OP_LEGACY_SERVER_CONNECT: 4;
27
+ readonly SSL_OP_NO_COMPRESSION: 131072;
28
+ readonly SSL_OP_NO_ENCRYPT_THEN_MAC: 524288;
29
+ readonly SSL_OP_NO_QUERY_MTU: 4096;
30
+ readonly SSL_OP_NO_RENEGOTIATION: 1073741824;
31
+ readonly SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: 65536;
32
+ readonly SSL_OP_NO_SSLv2: 0;
33
+ readonly SSL_OP_NO_SSLv3: 33554432;
34
+ readonly SSL_OP_NO_TICKET: 16384;
35
+ readonly SSL_OP_NO_TLSv1: 67108864;
36
+ readonly SSL_OP_NO_TLSv1_1: 268435456;
37
+ readonly SSL_OP_NO_TLSv1_2: 134217728;
38
+ readonly SSL_OP_NO_TLSv1_3: 536870912;
39
+ readonly SSL_OP_PRIORITIZE_CHACHA: 2097152;
40
+ readonly SSL_OP_TLS_ROLLBACK_BUG: 8388608;
41
+ readonly ENGINE_METHOD_RSA: 1;
42
+ readonly ENGINE_METHOD_DSA: 2;
43
+ readonly ENGINE_METHOD_DH: 4;
44
+ readonly ENGINE_METHOD_RAND: 8;
45
+ readonly ENGINE_METHOD_EC: 2048;
46
+ readonly ENGINE_METHOD_CIPHERS: 64;
47
+ readonly ENGINE_METHOD_DIGESTS: 128;
48
+ readonly ENGINE_METHOD_PKEY_METHS: 512;
49
+ readonly ENGINE_METHOD_PKEY_ASN1_METHS: 1024;
50
+ readonly ENGINE_METHOD_ALL: 65535;
51
+ readonly ENGINE_METHOD_NONE: 0;
52
+ readonly defaultCoreCipherList: "";
53
+ readonly TLS1_VERSION: 769;
54
+ readonly TLS1_1_VERSION: 770;
55
+ readonly TLS1_2_VERSION: 771;
56
+ readonly TLS1_3_VERSION: 772;
57
+ readonly defaultCipherList: "";
58
+ };
59
+ export declare const constants: Omit<{ readonly [K in keyof typeof values]: (typeof values)[K] extends number ? number : string; }, "defaultCipherList"> & {
60
+ defaultCipherList: string;
61
+ };
62
+ export {};
@@ -0,0 +1,68 @@
1
+ // Pinned workerd 1.20261012.1 / compatibility date 2026-10-17.
2
+ // Descriptor snapshot from the shared Workers acceptance probe.
3
+ const values = {
4
+ DH_CHECK_P_NOT_SAFE_PRIME: 2,
5
+ DH_CHECK_P_NOT_PRIME: 1,
6
+ DH_UNABLE_TO_CHECK_GENERATOR: 4,
7
+ DH_NOT_SUITABLE_GENERATOR: 8,
8
+ RSA_PKCS1_PADDING: 1,
9
+ RSA_NO_PADDING: 3,
10
+ RSA_PKCS1_OAEP_PADDING: 4,
11
+ RSA_X931_PADDING: 5,
12
+ RSA_PKCS1_PSS_PADDING: 6,
13
+ RSA_PSS_SALTLEN_DIGEST: -1,
14
+ RSA_PSS_SALTLEN_MAX_SIGN: -2,
15
+ RSA_PSS_SALTLEN_AUTO: -2,
16
+ POINT_CONVERSION_COMPRESSED: 2,
17
+ POINT_CONVERSION_UNCOMPRESSED: 4,
18
+ POINT_CONVERSION_HYBRID: 6,
19
+ OPENSSL_VERSION_NUMBER: 0,
20
+ SSL_OP_ALL: 2147485776,
21
+ SSL_OP_ALLOW_NO_DHE_KEX: 1024,
22
+ SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: 262144,
23
+ SSL_OP_CIPHER_SERVER_PREFERENCE: 4194304,
24
+ SSL_OP_CISCO_ANYCONNECT: 32768,
25
+ SSL_OP_COOKIE_EXCHANGE: 8192,
26
+ SSL_OP_CRYPTOPRO_TLSEXT_BUG: 2147483648,
27
+ SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: 2048,
28
+ SSL_OP_LEGACY_SERVER_CONNECT: 4,
29
+ SSL_OP_NO_COMPRESSION: 131072,
30
+ SSL_OP_NO_ENCRYPT_THEN_MAC: 524288,
31
+ SSL_OP_NO_QUERY_MTU: 4096,
32
+ SSL_OP_NO_RENEGOTIATION: 1073741824,
33
+ SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: 65536,
34
+ SSL_OP_NO_SSLv2: 0,
35
+ SSL_OP_NO_SSLv3: 33554432,
36
+ SSL_OP_NO_TICKET: 16384,
37
+ SSL_OP_NO_TLSv1: 67108864,
38
+ SSL_OP_NO_TLSv1_1: 268435456,
39
+ SSL_OP_NO_TLSv1_2: 134217728,
40
+ SSL_OP_NO_TLSv1_3: 536870912,
41
+ SSL_OP_PRIORITIZE_CHACHA: 2097152,
42
+ SSL_OP_TLS_ROLLBACK_BUG: 8388608,
43
+ ENGINE_METHOD_RSA: 1,
44
+ ENGINE_METHOD_DSA: 2,
45
+ ENGINE_METHOD_DH: 4,
46
+ ENGINE_METHOD_RAND: 8,
47
+ ENGINE_METHOD_EC: 2048,
48
+ ENGINE_METHOD_CIPHERS: 64,
49
+ ENGINE_METHOD_DIGESTS: 128,
50
+ ENGINE_METHOD_PKEY_METHS: 512,
51
+ ENGINE_METHOD_PKEY_ASN1_METHS: 1024,
52
+ ENGINE_METHOD_ALL: 65535,
53
+ ENGINE_METHOD_NONE: 0,
54
+ defaultCoreCipherList: "",
55
+ TLS1_VERSION: 769,
56
+ TLS1_1_VERSION: 770,
57
+ TLS1_2_VERSION: 771,
58
+ TLS1_3_VERSION: 772,
59
+ defaultCipherList: "",
60
+ };
61
+ export const constants = Object.create(null);
62
+ for (const [name, value] of Object.entries(values))
63
+ Object.defineProperty(constants, name, {
64
+ value,
65
+ writable: name === "defaultCipherList",
66
+ configurable: name === "defaultCipherList",
67
+ enumerable: false,
68
+ });