@psnext/slingcli 3.3.20260911-1 → 3.3.20260914-1

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 (420) hide show
  1. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-VDBOM5UG.js → chunk-BRL3MDQL.js} +1 -1
  2. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/cli.js +1 -1
  3. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/index.js +1 -1
  4. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/rpc-entry.js +1 -1
  5. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.js +79 -32
  6. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +2 -0
  7. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +25 -8
  8. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +2 -0
  9. package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/getAwsChunkedEncodingStream.browser.js +2 -0
  10. package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/getAwsChunkedEncodingStream.js +23 -8
  11. package/node_modules/@smithy/core/package.json +1 -1
  12. package/node_modules/@types/node/README.md +2 -2
  13. package/node_modules/@types/node/assert/strict.d.ts +13 -56
  14. package/node_modules/@types/node/assert.d.ts +189 -190
  15. package/node_modules/@types/node/async_hooks.d.ts +151 -43
  16. package/node_modules/@types/node/buffer.buffer.d.ts +12 -13
  17. package/node_modules/@types/node/buffer.d.ts +103 -237
  18. package/node_modules/@types/node/child_process.d.ts +39 -154
  19. package/node_modules/@types/node/cluster.d.ts +238 -384
  20. package/node_modules/@types/node/console.d.ts +45 -404
  21. package/node_modules/@types/node/constants.d.ts +3 -10
  22. package/node_modules/@types/node/crypto.d.ts +1000 -1593
  23. package/node_modules/@types/node/dgram.d.ts +133 -81
  24. package/node_modules/@types/node/diagnostics_channel.d.ts +277 -59
  25. package/node_modules/@types/node/dns/promises.d.ts +9 -15
  26. package/node_modules/@types/node/dns.d.ts +136 -183
  27. package/node_modules/@types/node/domain.d.ts +12 -32
  28. package/node_modules/@types/node/events.d.ts +872 -840
  29. package/node_modules/@types/node/ffi.d.ts +486 -0
  30. package/node_modules/@types/node/fs/promises.d.ts +256 -85
  31. package/node_modules/@types/node/fs.d.ts +865 -525
  32. package/node_modules/@types/node/globals.d.ts +12 -34
  33. package/node_modules/@types/node/globals.typedarray.d.ts +63 -0
  34. package/node_modules/@types/node/http.d.ts +433 -312
  35. package/node_modules/@types/node/http2.d.ts +545 -891
  36. package/node_modules/@types/node/https.d.ts +64 -243
  37. package/node_modules/@types/node/index.d.ts +25 -7
  38. package/node_modules/@types/node/inspector/promises.d.ts +35 -0
  39. package/node_modules/@types/node/inspector.d.ts +70 -58
  40. package/node_modules/@types/node/inspector.generated.d.ts +764 -410
  41. package/node_modules/@types/node/module.d.ts +54 -219
  42. package/node_modules/@types/node/net.d.ts +208 -222
  43. package/node_modules/@types/node/os.d.ts +41 -49
  44. package/node_modules/@types/node/package.json +13 -3
  45. package/node_modules/@types/node/path/posix.d.ts +8 -0
  46. package/node_modules/@types/node/path/win32.d.ts +8 -0
  47. package/node_modules/@types/node/path.d.ts +119 -141
  48. package/node_modules/@types/node/perf_hooks.d.ts +339 -690
  49. package/node_modules/@types/node/process.d.ts +389 -205
  50. package/node_modules/@types/node/punycode.d.ts +3 -31
  51. package/node_modules/@types/node/querystring.d.ts +3 -16
  52. package/node_modules/@types/node/quic.d.ts +2153 -0
  53. package/node_modules/@types/node/readline/promises.d.ts +3 -6
  54. package/node_modules/@types/node/readline.d.ts +66 -152
  55. package/node_modules/@types/node/repl.d.ts +101 -109
  56. package/node_modules/@types/node/sea.d.ts +1 -116
  57. package/node_modules/@types/node/sqlite.d.ts +486 -68
  58. package/node_modules/@types/node/stream/consumers.d.ts +91 -15
  59. package/node_modules/@types/node/stream/iter.d.ts +452 -0
  60. package/node_modules/@types/node/stream/promises.d.ts +136 -15
  61. package/node_modules/@types/node/stream/web.d.ts +197 -454
  62. package/node_modules/@types/node/stream.d.ts +603 -491
  63. package/node_modules/@types/node/string_decoder.d.ts +3 -43
  64. package/node_modules/@types/node/test/reporters.d.ts +59 -0
  65. package/node_modules/@types/node/test.d.ts +513 -292
  66. package/node_modules/@types/node/timers/promises.d.ts +3 -18
  67. package/node_modules/@types/node/timers.d.ts +3 -141
  68. package/node_modules/@types/node/tls.d.ts +166 -257
  69. package/node_modules/@types/node/trace_events.d.ts +3 -97
  70. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +7 -8
  71. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  72. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +2 -0
  73. package/node_modules/@types/node/ts5.6/index.d.ts +26 -6
  74. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  75. package/node_modules/@types/node/ts5.7/index.d.ts +118 -0
  76. package/node_modules/@types/node/tty.d.ts +61 -43
  77. package/node_modules/@types/node/url.d.ts +156 -584
  78. package/node_modules/@types/node/util/types.d.ts +558 -0
  79. package/node_modules/@types/node/util.d.ts +170 -1099
  80. package/node_modules/@types/node/v8.d.ts +175 -36
  81. package/node_modules/@types/node/vfs.d.ts +211 -0
  82. package/node_modules/@types/node/vm.d.ts +292 -209
  83. package/node_modules/@types/node/wasi.d.ts +24 -74
  84. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +27 -2
  85. package/node_modules/@types/node/web-globals/blob.d.ts +23 -0
  86. package/node_modules/@types/node/web-globals/console.d.ts +9 -0
  87. package/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
  88. package/node_modules/@types/node/web-globals/domexception.d.ts +15 -0
  89. package/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
  90. package/node_modules/@types/node/web-globals/events.d.ts +9 -0
  91. package/node_modules/@types/node/web-globals/fetch.d.ts +14 -0
  92. package/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
  93. package/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
  94. package/node_modules/@types/node/web-globals/navigator.d.ts +3 -0
  95. package/node_modules/@types/node/web-globals/performance.d.ts +45 -0
  96. package/node_modules/@types/node/web-globals/streams.d.ts +97 -0
  97. package/node_modules/@types/node/web-globals/timers.d.ts +44 -0
  98. package/node_modules/@types/node/web-globals/url.d.ts +24 -0
  99. package/node_modules/@types/node/worker_threads.d.ts +257 -407
  100. package/node_modules/@types/node/zlib/iter.d.ts +131 -0
  101. package/node_modules/@types/node/zlib.d.ts +24 -165
  102. package/node_modules/undici-types/agent.d.ts +12 -13
  103. package/node_modules/undici-types/api.d.ts +26 -26
  104. package/node_modules/undici-types/balanced-pool.d.ts +13 -12
  105. package/node_modules/undici-types/cache-interceptor.d.ts +179 -0
  106. package/node_modules/undici-types/client-stats.d.ts +15 -0
  107. package/node_modules/undici-types/client.d.ts +63 -37
  108. package/node_modules/undici-types/connector.d.ts +5 -2
  109. package/node_modules/undici-types/cookies.d.ts +3 -1
  110. package/node_modules/undici-types/diagnostics-channel.d.ts +18 -10
  111. package/node_modules/undici-types/dispatcher.d.ts +136 -139
  112. package/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
  113. package/node_modules/undici-types/env-http-proxy-agent.d.ts +4 -3
  114. package/node_modules/undici-types/errors.d.ts +92 -54
  115. package/node_modules/undici-types/eventsource.d.ts +9 -4
  116. package/node_modules/undici-types/fetch.d.ts +51 -25
  117. package/node_modules/undici-types/formdata.d.ts +7 -7
  118. package/node_modules/undici-types/global-dispatcher.d.ts +4 -4
  119. package/node_modules/undici-types/global-origin.d.ts +5 -5
  120. package/node_modules/undici-types/h2c-client.d.ts +73 -0
  121. package/node_modules/undici-types/handlers.d.ts +10 -9
  122. package/node_modules/undici-types/header.d.ts +162 -1
  123. package/node_modules/undici-types/index.d.ts +69 -47
  124. package/node_modules/undici-types/interceptors.d.ts +72 -9
  125. package/node_modules/undici-types/mock-agent.d.ts +36 -18
  126. package/node_modules/undici-types/mock-call-history.d.ts +111 -0
  127. package/node_modules/undici-types/mock-client.d.ts +6 -4
  128. package/node_modules/undici-types/mock-errors.d.ts +3 -3
  129. package/node_modules/undici-types/mock-interceptor.d.ts +26 -21
  130. package/node_modules/undici-types/mock-pool.d.ts +6 -4
  131. package/node_modules/undici-types/package.json +1 -1
  132. package/node_modules/undici-types/patch.d.ts +0 -4
  133. package/node_modules/undici-types/pool-stats.d.ts +8 -8
  134. package/node_modules/undici-types/pool.d.ts +14 -14
  135. package/node_modules/undici-types/proxy-agent.d.ts +14 -6
  136. package/node_modules/undici-types/readable.d.ts +19 -16
  137. package/node_modules/undici-types/retry-agent.d.ts +1 -1
  138. package/node_modules/undici-types/retry-handler.d.ts +19 -10
  139. package/node_modules/undici-types/round-robin-pool.d.ts +39 -0
  140. package/node_modules/undici-types/snapshot-agent.d.ts +113 -0
  141. package/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  142. package/node_modules/undici-types/util.d.ts +3 -3
  143. package/node_modules/undici-types/utility.d.ts +7 -0
  144. package/node_modules/undici-types/webidl.d.ts +148 -30
  145. package/node_modules/undici-types/websocket.d.ts +48 -10
  146. package/node_modules/zod/README.md +2 -2
  147. package/node_modules/zod/package.json +1 -1
  148. package/node_modules/zod/src/v4/classic/checks.ts +1 -0
  149. package/node_modules/zod/src/v4/classic/schemas.ts +14 -30
  150. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +1 -0
  151. package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +2 -11
  152. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -4
  153. package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +22 -0
  154. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +1 -1
  155. package/node_modules/zod/src/v4/classic/tests/number.test.ts +39 -0
  156. package/node_modules/zod/src/v4/classic/tests/properties.test.ts +53 -137
  157. package/node_modules/zod/src/v4/classic/tests/string.test.ts +70 -1
  158. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +87 -35
  159. package/node_modules/zod/src/v4/core/api.ts +21 -29
  160. package/node_modules/zod/src/v4/core/checks.ts +61 -1
  161. package/node_modules/zod/src/v4/core/compile.ts +35 -24
  162. package/node_modules/zod/src/v4/core/core.ts +1 -3
  163. package/node_modules/zod/src/v4/core/json-schema-processors.ts +9 -63
  164. package/node_modules/zod/src/v4/core/memoizer.ts +2 -5
  165. package/node_modules/zod/src/v4/core/regexes.ts +4 -0
  166. package/node_modules/zod/src/v4/core/schemas.ts +36 -109
  167. package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +35 -0
  168. package/node_modules/zod/src/v4/core/tests/compile.test.ts +177 -0
  169. package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +118 -16
  170. package/node_modules/zod/src/v4/core/to-json-schema.ts +1 -1
  171. package/node_modules/zod/src/v4/core/util.ts +0 -4
  172. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  173. package/node_modules/zod/src/v4/core/visit.ts +0 -11
  174. package/node_modules/zod/src/v4/locales/ar.ts +1 -0
  175. package/node_modules/zod/src/v4/locales/az.ts +1 -0
  176. package/node_modules/zod/src/v4/locales/be.ts +1 -0
  177. package/node_modules/zod/src/v4/locales/bg.ts +1 -0
  178. package/node_modules/zod/src/v4/locales/bn.ts +1 -0
  179. package/node_modules/zod/src/v4/locales/ca.ts +1 -0
  180. package/node_modules/zod/src/v4/locales/ckb.ts +1 -0
  181. package/node_modules/zod/src/v4/locales/cs.ts +1 -0
  182. package/node_modules/zod/src/v4/locales/da.ts +1 -0
  183. package/node_modules/zod/src/v4/locales/de.ts +1 -0
  184. package/node_modules/zod/src/v4/locales/el.ts +1 -0
  185. package/node_modules/zod/src/v4/locales/en.ts +1 -0
  186. package/node_modules/zod/src/v4/locales/eo.ts +1 -0
  187. package/node_modules/zod/src/v4/locales/es.ts +1 -0
  188. package/node_modules/zod/src/v4/locales/fa.ts +1 -0
  189. package/node_modules/zod/src/v4/locales/fi.ts +1 -0
  190. package/node_modules/zod/src/v4/locales/fr-CA.ts +1 -0
  191. package/node_modules/zod/src/v4/locales/fr.ts +1 -0
  192. package/node_modules/zod/src/v4/locales/gu.ts +1 -0
  193. package/node_modules/zod/src/v4/locales/he.ts +1 -0
  194. package/node_modules/zod/src/v4/locales/hi.ts +1 -0
  195. package/node_modules/zod/src/v4/locales/hr.ts +1 -0
  196. package/node_modules/zod/src/v4/locales/hu.ts +1 -0
  197. package/node_modules/zod/src/v4/locales/hy.ts +1 -0
  198. package/node_modules/zod/src/v4/locales/id.ts +1 -0
  199. package/node_modules/zod/src/v4/locales/is.ts +1 -0
  200. package/node_modules/zod/src/v4/locales/it.ts +1 -0
  201. package/node_modules/zod/src/v4/locales/ja.ts +1 -0
  202. package/node_modules/zod/src/v4/locales/ka.ts +1 -0
  203. package/node_modules/zod/src/v4/locales/km.ts +1 -0
  204. package/node_modules/zod/src/v4/locales/kn.ts +1 -0
  205. package/node_modules/zod/src/v4/locales/ko.ts +1 -0
  206. package/node_modules/zod/src/v4/locales/lt.ts +1 -0
  207. package/node_modules/zod/src/v4/locales/mk.ts +1 -0
  208. package/node_modules/zod/src/v4/locales/ms.ts +1 -0
  209. package/node_modules/zod/src/v4/locales/ne.ts +1 -0
  210. package/node_modules/zod/src/v4/locales/nl.ts +1 -0
  211. package/node_modules/zod/src/v4/locales/nn.ts +1 -0
  212. package/node_modules/zod/src/v4/locales/no.ts +1 -0
  213. package/node_modules/zod/src/v4/locales/ota.ts +1 -0
  214. package/node_modules/zod/src/v4/locales/pl.ts +1 -0
  215. package/node_modules/zod/src/v4/locales/ps.ts +1 -0
  216. package/node_modules/zod/src/v4/locales/pt-BR.ts +1 -0
  217. package/node_modules/zod/src/v4/locales/pt.ts +1 -0
  218. package/node_modules/zod/src/v4/locales/ro.ts +1 -0
  219. package/node_modules/zod/src/v4/locales/ru.ts +1 -0
  220. package/node_modules/zod/src/v4/locales/sk.ts +1 -0
  221. package/node_modules/zod/src/v4/locales/sl.ts +1 -0
  222. package/node_modules/zod/src/v4/locales/sv.ts +1 -0
  223. package/node_modules/zod/src/v4/locales/ta.ts +1 -0
  224. package/node_modules/zod/src/v4/locales/tg.ts +1 -0
  225. package/node_modules/zod/src/v4/locales/th.ts +1 -0
  226. package/node_modules/zod/src/v4/locales/tk.ts +1 -0
  227. package/node_modules/zod/src/v4/locales/tr.ts +1 -0
  228. package/node_modules/zod/src/v4/locales/uk.ts +1 -0
  229. package/node_modules/zod/src/v4/locales/ur.ts +1 -0
  230. package/node_modules/zod/src/v4/locales/uz.ts +1 -0
  231. package/node_modules/zod/src/v4/locales/vi.ts +1 -0
  232. package/node_modules/zod/src/v4/locales/yo.ts +1 -0
  233. package/node_modules/zod/src/v4/locales/zh-CN.ts +1 -0
  234. package/node_modules/zod/src/v4/locales/zh-TW.ts +1 -0
  235. package/node_modules/zod/src/v4/mini/checks.ts +1 -0
  236. package/node_modules/zod/src/v4/mini/schemas.ts +12 -23
  237. package/node_modules/zod/src/v4/mini/tests/index.test.ts +56 -0
  238. package/node_modules/zod/src/v4/mini/tests/string.test.ts +7 -0
  239. package/node_modules/zod/v4/classic/checks.cjs +2 -1
  240. package/node_modules/zod/v4/classic/checks.d.cts +1 -1
  241. package/node_modules/zod/v4/classic/checks.d.ts +1 -1
  242. package/node_modules/zod/v4/classic/checks.js +1 -1
  243. package/node_modules/zod/v4/classic/schemas.cjs +11 -15
  244. package/node_modules/zod/v4/classic/schemas.d.cts +4 -6
  245. package/node_modules/zod/v4/classic/schemas.d.ts +4 -6
  246. package/node_modules/zod/v4/classic/schemas.js +9 -13
  247. package/node_modules/zod/v4/core/api.cjs +11 -23
  248. package/node_modules/zod/v4/core/api.d.cts +8 -4
  249. package/node_modules/zod/v4/core/api.d.ts +8 -4
  250. package/node_modules/zod/v4/core/api.js +11 -23
  251. package/node_modules/zod/v4/core/checks.cjs +32 -1
  252. package/node_modules/zod/v4/core/checks.d.cts +16 -0
  253. package/node_modules/zod/v4/core/checks.d.ts +16 -0
  254. package/node_modules/zod/v4/core/checks.js +31 -0
  255. package/node_modules/zod/v4/core/compile.cjs +12 -17
  256. package/node_modules/zod/v4/core/compile.js +13 -18
  257. package/node_modules/zod/v4/core/core.cjs +1 -1
  258. package/node_modules/zod/v4/core/core.js +1 -1
  259. package/node_modules/zod/v4/core/json-schema-processors.cjs +8 -44
  260. package/node_modules/zod/v4/core/json-schema-processors.d.cts +0 -1
  261. package/node_modules/zod/v4/core/json-schema-processors.d.ts +0 -1
  262. package/node_modules/zod/v4/core/json-schema-processors.js +8 -43
  263. package/node_modules/zod/v4/core/memoizer.cjs +2 -5
  264. package/node_modules/zod/v4/core/memoizer.js +2 -5
  265. package/node_modules/zod/v4/core/regexes.cjs +4 -2
  266. package/node_modules/zod/v4/core/regexes.d.cts +1 -0
  267. package/node_modules/zod/v4/core/regexes.d.ts +1 -0
  268. package/node_modules/zod/v4/core/regexes.js +2 -0
  269. package/node_modules/zod/v4/core/schemas.cjs +33 -73
  270. package/node_modules/zod/v4/core/schemas.d.cts +7 -22
  271. package/node_modules/zod/v4/core/schemas.d.ts +7 -22
  272. package/node_modules/zod/v4/core/schemas.js +30 -72
  273. package/node_modules/zod/v4/core/to-json-schema.cjs +0 -1
  274. package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -3
  275. package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -3
  276. package/node_modules/zod/v4/core/to-json-schema.js +1 -1
  277. package/node_modules/zod/v4/core/util.cjs +0 -4
  278. package/node_modules/zod/v4/core/util.js +0 -4
  279. package/node_modules/zod/v4/core/versions.cjs +1 -1
  280. package/node_modules/zod/v4/core/versions.js +1 -1
  281. package/node_modules/zod/v4/core/visit.cjs +0 -12
  282. package/node_modules/zod/v4/core/visit.js +0 -12
  283. package/node_modules/zod/v4/locales/ar.cjs +1 -0
  284. package/node_modules/zod/v4/locales/ar.js +1 -0
  285. package/node_modules/zod/v4/locales/az.cjs +1 -0
  286. package/node_modules/zod/v4/locales/az.js +1 -0
  287. package/node_modules/zod/v4/locales/be.cjs +1 -0
  288. package/node_modules/zod/v4/locales/be.js +1 -0
  289. package/node_modules/zod/v4/locales/bg.cjs +1 -0
  290. package/node_modules/zod/v4/locales/bg.js +1 -0
  291. package/node_modules/zod/v4/locales/bn.cjs +1 -0
  292. package/node_modules/zod/v4/locales/bn.js +1 -0
  293. package/node_modules/zod/v4/locales/ca.cjs +1 -0
  294. package/node_modules/zod/v4/locales/ca.js +1 -0
  295. package/node_modules/zod/v4/locales/ckb.cjs +1 -0
  296. package/node_modules/zod/v4/locales/ckb.js +1 -0
  297. package/node_modules/zod/v4/locales/cs.cjs +1 -0
  298. package/node_modules/zod/v4/locales/cs.js +1 -0
  299. package/node_modules/zod/v4/locales/da.cjs +1 -0
  300. package/node_modules/zod/v4/locales/da.js +1 -0
  301. package/node_modules/zod/v4/locales/de.cjs +1 -0
  302. package/node_modules/zod/v4/locales/de.js +1 -0
  303. package/node_modules/zod/v4/locales/el.cjs +1 -0
  304. package/node_modules/zod/v4/locales/el.js +1 -0
  305. package/node_modules/zod/v4/locales/en.cjs +1 -0
  306. package/node_modules/zod/v4/locales/en.js +1 -0
  307. package/node_modules/zod/v4/locales/eo.cjs +1 -0
  308. package/node_modules/zod/v4/locales/eo.js +1 -0
  309. package/node_modules/zod/v4/locales/es.cjs +1 -0
  310. package/node_modules/zod/v4/locales/es.js +1 -0
  311. package/node_modules/zod/v4/locales/fa.cjs +1 -0
  312. package/node_modules/zod/v4/locales/fa.js +1 -0
  313. package/node_modules/zod/v4/locales/fi.cjs +1 -0
  314. package/node_modules/zod/v4/locales/fi.js +1 -0
  315. package/node_modules/zod/v4/locales/fr-CA.cjs +1 -0
  316. package/node_modules/zod/v4/locales/fr-CA.js +1 -0
  317. package/node_modules/zod/v4/locales/fr.cjs +1 -0
  318. package/node_modules/zod/v4/locales/fr.js +1 -0
  319. package/node_modules/zod/v4/locales/gu.cjs +1 -0
  320. package/node_modules/zod/v4/locales/gu.js +1 -0
  321. package/node_modules/zod/v4/locales/he.cjs +1 -0
  322. package/node_modules/zod/v4/locales/he.js +1 -0
  323. package/node_modules/zod/v4/locales/hi.cjs +1 -0
  324. package/node_modules/zod/v4/locales/hi.js +1 -0
  325. package/node_modules/zod/v4/locales/hr.cjs +1 -0
  326. package/node_modules/zod/v4/locales/hr.js +1 -0
  327. package/node_modules/zod/v4/locales/hu.cjs +1 -0
  328. package/node_modules/zod/v4/locales/hu.js +1 -0
  329. package/node_modules/zod/v4/locales/hy.cjs +1 -0
  330. package/node_modules/zod/v4/locales/hy.js +1 -0
  331. package/node_modules/zod/v4/locales/id.cjs +1 -0
  332. package/node_modules/zod/v4/locales/id.js +1 -0
  333. package/node_modules/zod/v4/locales/is.cjs +1 -0
  334. package/node_modules/zod/v4/locales/is.js +1 -0
  335. package/node_modules/zod/v4/locales/it.cjs +1 -0
  336. package/node_modules/zod/v4/locales/it.js +1 -0
  337. package/node_modules/zod/v4/locales/ja.cjs +1 -0
  338. package/node_modules/zod/v4/locales/ja.js +1 -0
  339. package/node_modules/zod/v4/locales/ka.cjs +1 -0
  340. package/node_modules/zod/v4/locales/ka.js +1 -0
  341. package/node_modules/zod/v4/locales/km.cjs +1 -0
  342. package/node_modules/zod/v4/locales/km.js +1 -0
  343. package/node_modules/zod/v4/locales/kn.cjs +1 -0
  344. package/node_modules/zod/v4/locales/kn.js +1 -0
  345. package/node_modules/zod/v4/locales/ko.cjs +1 -0
  346. package/node_modules/zod/v4/locales/ko.js +1 -0
  347. package/node_modules/zod/v4/locales/lt.cjs +1 -0
  348. package/node_modules/zod/v4/locales/lt.js +1 -0
  349. package/node_modules/zod/v4/locales/mk.cjs +1 -0
  350. package/node_modules/zod/v4/locales/mk.js +1 -0
  351. package/node_modules/zod/v4/locales/ms.cjs +1 -0
  352. package/node_modules/zod/v4/locales/ms.js +1 -0
  353. package/node_modules/zod/v4/locales/ne.cjs +1 -0
  354. package/node_modules/zod/v4/locales/ne.js +1 -0
  355. package/node_modules/zod/v4/locales/nl.cjs +1 -0
  356. package/node_modules/zod/v4/locales/nl.js +1 -0
  357. package/node_modules/zod/v4/locales/nn.cjs +1 -0
  358. package/node_modules/zod/v4/locales/nn.js +1 -0
  359. package/node_modules/zod/v4/locales/no.cjs +1 -0
  360. package/node_modules/zod/v4/locales/no.js +1 -0
  361. package/node_modules/zod/v4/locales/ota.cjs +1 -0
  362. package/node_modules/zod/v4/locales/ota.js +1 -0
  363. package/node_modules/zod/v4/locales/pl.cjs +1 -0
  364. package/node_modules/zod/v4/locales/pl.js +1 -0
  365. package/node_modules/zod/v4/locales/ps.cjs +1 -0
  366. package/node_modules/zod/v4/locales/ps.js +1 -0
  367. package/node_modules/zod/v4/locales/pt-BR.cjs +1 -0
  368. package/node_modules/zod/v4/locales/pt-BR.js +1 -0
  369. package/node_modules/zod/v4/locales/pt.cjs +1 -0
  370. package/node_modules/zod/v4/locales/pt.js +1 -0
  371. package/node_modules/zod/v4/locales/ro.cjs +1 -0
  372. package/node_modules/zod/v4/locales/ro.js +1 -0
  373. package/node_modules/zod/v4/locales/ru.cjs +1 -0
  374. package/node_modules/zod/v4/locales/ru.js +1 -0
  375. package/node_modules/zod/v4/locales/sk.cjs +1 -0
  376. package/node_modules/zod/v4/locales/sk.js +1 -0
  377. package/node_modules/zod/v4/locales/sl.cjs +1 -0
  378. package/node_modules/zod/v4/locales/sl.js +1 -0
  379. package/node_modules/zod/v4/locales/sv.cjs +1 -0
  380. package/node_modules/zod/v4/locales/sv.js +1 -0
  381. package/node_modules/zod/v4/locales/ta.cjs +1 -0
  382. package/node_modules/zod/v4/locales/ta.js +1 -0
  383. package/node_modules/zod/v4/locales/tg.cjs +1 -0
  384. package/node_modules/zod/v4/locales/tg.js +1 -0
  385. package/node_modules/zod/v4/locales/th.cjs +1 -0
  386. package/node_modules/zod/v4/locales/th.js +1 -0
  387. package/node_modules/zod/v4/locales/tk.cjs +1 -0
  388. package/node_modules/zod/v4/locales/tk.js +1 -0
  389. package/node_modules/zod/v4/locales/tr.cjs +1 -0
  390. package/node_modules/zod/v4/locales/tr.js +1 -0
  391. package/node_modules/zod/v4/locales/uk.cjs +1 -0
  392. package/node_modules/zod/v4/locales/uk.js +1 -0
  393. package/node_modules/zod/v4/locales/ur.cjs +1 -0
  394. package/node_modules/zod/v4/locales/ur.js +1 -0
  395. package/node_modules/zod/v4/locales/uz.cjs +1 -0
  396. package/node_modules/zod/v4/locales/uz.js +1 -0
  397. package/node_modules/zod/v4/locales/vi.cjs +1 -0
  398. package/node_modules/zod/v4/locales/vi.js +1 -0
  399. package/node_modules/zod/v4/locales/yo.cjs +1 -0
  400. package/node_modules/zod/v4/locales/yo.js +1 -0
  401. package/node_modules/zod/v4/locales/zh-CN.cjs +1 -0
  402. package/node_modules/zod/v4/locales/zh-CN.js +1 -0
  403. package/node_modules/zod/v4/locales/zh-TW.cjs +1 -0
  404. package/node_modules/zod/v4/locales/zh-TW.js +1 -0
  405. package/node_modules/zod/v4/mini/checks.cjs +2 -1
  406. package/node_modules/zod/v4/mini/checks.d.cts +1 -1
  407. package/node_modules/zod/v4/mini/checks.d.ts +1 -1
  408. package/node_modules/zod/v4/mini/checks.js +1 -1
  409. package/node_modules/zod/v4/mini/schemas.cjs +11 -13
  410. package/node_modules/zod/v4/mini/schemas.d.cts +1 -4
  411. package/node_modules/zod/v4/mini/schemas.d.ts +1 -4
  412. package/node_modules/zod/v4/mini/schemas.js +9 -11
  413. package/package.json +2 -2
  414. package/slingshot/index.js +183 -182
  415. package/node_modules/@types/node/compatibility/disposable.d.ts +0 -14
  416. package/node_modules/@types/node/compatibility/index.d.ts +0 -9
  417. package/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
  418. package/node_modules/@types/node/compatibility/iterators.d.ts +0 -20
  419. package/node_modules/undici-types/file.d.ts +0 -39
  420. package/node_modules/undici-types/filereader.d.ts +0 -54
@@ -1,24 +1,6 @@
1
- /**
2
- * The `node:crypto` module provides cryptographic functionality that includes a
3
- * set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify
4
- * functions.
5
- *
6
- * ```js
7
- * const { createHmac } = await import('node:crypto');
8
- *
9
- * const secret = 'abcdefg';
10
- * const hash = createHmac('sha256', secret)
11
- * .update('I love cupcakes')
12
- * .digest('hex');
13
- * console.log(hash);
14
- * // Prints:
15
- * // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
16
- * ```
17
- * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/crypto.js)
18
- */
19
- declare module "crypto" {
1
+ declare module "node:crypto" {
20
2
  import { NonSharedBuffer } from "node:buffer";
21
- import * as stream from "node:stream";
3
+ import { Transform, TransformOptions, Writable, WritableOptions } from "node:stream";
22
4
  import { PeerCertificate } from "node:tls";
23
5
  /**
24
6
  * SPKAC is a Certificate Signing Request mechanism originally implemented by
@@ -45,7 +27,7 @@ declare module "crypto" {
45
27
  * @param encoding The `encoding` of the `spkac` string.
46
28
  * @return The challenge component of the `spkac` data structure, which includes a public key and a challenge.
47
29
  */
48
- static exportChallenge(spkac: BinaryLike): NonSharedBuffer;
30
+ static exportChallenge(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
49
31
  /**
50
32
  * ```js
51
33
  * const { Certificate } = await import('node:crypto');
@@ -58,7 +40,7 @@ declare module "crypto" {
58
40
  * @param encoding The `encoding` of the `spkac` string.
59
41
  * @return The public key component of the `spkac` data structure, which includes a public key and a challenge.
60
42
  */
61
- static exportPublicKey(spkac: BinaryLike, encoding?: string): NonSharedBuffer;
43
+ static exportPublicKey(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
62
44
  /**
63
45
  * ```js
64
46
  * import { Buffer } from 'node:buffer';
@@ -72,122 +54,34 @@ declare module "crypto" {
72
54
  * @param encoding The `encoding` of the `spkac` string.
73
55
  * @return `true` if the given `spkac` data structure is valid, `false` otherwise.
74
56
  */
75
- static verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
57
+ static verifySpkac(spkac: BinaryLike, encoding?: BufferEncoding): boolean;
76
58
  /**
77
59
  * @deprecated
78
- * @param spkac
60
+ * @param encoding The `encoding` of the `spkac` string.
79
61
  * @returns The challenge component of the `spkac` data structure,
80
62
  * which includes a public key and a challenge.
81
63
  */
82
- exportChallenge(spkac: BinaryLike): NonSharedBuffer;
64
+ exportChallenge(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
83
65
  /**
84
66
  * @deprecated
85
- * @param spkac
86
67
  * @param encoding The encoding of the spkac string.
87
68
  * @returns The public key component of the `spkac` data structure,
88
69
  * which includes a public key and a challenge.
89
70
  */
90
- exportPublicKey(spkac: BinaryLike, encoding?: string): NonSharedBuffer;
71
+ exportPublicKey(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
91
72
  /**
92
73
  * @deprecated
93
- * @param spkac
74
+ * @param encoding The `encoding` of the `spkac` string.
94
75
  * @returns `true` if the given `spkac` data structure is valid,
95
76
  * `false` otherwise.
96
77
  */
97
- verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
98
- }
99
- namespace constants {
100
- // https://nodejs.org/dist/latest-v22.x/docs/api/crypto.html#crypto-constants
101
- const OPENSSL_VERSION_NUMBER: number;
102
- /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
103
- const SSL_OP_ALL: number;
104
- /** Instructs OpenSSL to allow a non-[EC]DHE-based key exchange mode for TLS v1.3 */
105
- const SSL_OP_ALLOW_NO_DHE_KEX: number;
106
- /** Allows legacy insecure renegotiation between OpenSSL and unpatched clients or servers. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */
107
- const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
108
- /** Attempts to use the server's preferences instead of the client's when selecting a cipher. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */
109
- const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
110
- /** Instructs OpenSSL to use Cisco's version identifier of DTLS_BAD_VER. */
111
- const SSL_OP_CISCO_ANYCONNECT: number;
112
- /** Instructs OpenSSL to turn on cookie exchange. */
113
- const SSL_OP_COOKIE_EXCHANGE: number;
114
- /** Instructs OpenSSL to add server-hello extension from an early version of the cryptopro draft. */
115
- const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
116
- /** Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. */
117
- const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
118
- /** Allows initial connection to servers that do not support RI. */
119
- const SSL_OP_LEGACY_SERVER_CONNECT: number;
120
- /** Instructs OpenSSL to disable support for SSL/TLS compression. */
121
- const SSL_OP_NO_COMPRESSION: number;
122
- /** Instructs OpenSSL to disable encrypt-then-MAC. */
123
- const SSL_OP_NO_ENCRYPT_THEN_MAC: number;
124
- const SSL_OP_NO_QUERY_MTU: number;
125
- /** Instructs OpenSSL to disable renegotiation. */
126
- const SSL_OP_NO_RENEGOTIATION: number;
127
- /** Instructs OpenSSL to always start a new session when performing renegotiation. */
128
- const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
129
- /** Instructs OpenSSL to turn off SSL v2 */
130
- const SSL_OP_NO_SSLv2: number;
131
- /** Instructs OpenSSL to turn off SSL v3 */
132
- const SSL_OP_NO_SSLv3: number;
133
- /** Instructs OpenSSL to disable use of RFC4507bis tickets. */
134
- const SSL_OP_NO_TICKET: number;
135
- /** Instructs OpenSSL to turn off TLS v1 */
136
- const SSL_OP_NO_TLSv1: number;
137
- /** Instructs OpenSSL to turn off TLS v1.1 */
138
- const SSL_OP_NO_TLSv1_1: number;
139
- /** Instructs OpenSSL to turn off TLS v1.2 */
140
- const SSL_OP_NO_TLSv1_2: number;
141
- /** Instructs OpenSSL to turn off TLS v1.3 */
142
- const SSL_OP_NO_TLSv1_3: number;
143
- /** Instructs OpenSSL server to prioritize ChaCha20-Poly1305 when the client does. This option has no effect if `SSL_OP_CIPHER_SERVER_PREFERENCE` is not enabled. */
144
- const SSL_OP_PRIORITIZE_CHACHA: number;
145
- /** Instructs OpenSSL to disable version rollback attack detection. */
146
- const SSL_OP_TLS_ROLLBACK_BUG: number;
147
- const ENGINE_METHOD_RSA: number;
148
- const ENGINE_METHOD_DSA: number;
149
- const ENGINE_METHOD_DH: number;
150
- const ENGINE_METHOD_RAND: number;
151
- const ENGINE_METHOD_EC: number;
152
- const ENGINE_METHOD_CIPHERS: number;
153
- const ENGINE_METHOD_DIGESTS: number;
154
- const ENGINE_METHOD_PKEY_METHS: number;
155
- const ENGINE_METHOD_PKEY_ASN1_METHS: number;
156
- const ENGINE_METHOD_ALL: number;
157
- const ENGINE_METHOD_NONE: number;
158
- const DH_CHECK_P_NOT_SAFE_PRIME: number;
159
- const DH_CHECK_P_NOT_PRIME: number;
160
- const DH_UNABLE_TO_CHECK_GENERATOR: number;
161
- const DH_NOT_SUITABLE_GENERATOR: number;
162
- const RSA_PKCS1_PADDING: number;
163
- const RSA_SSLV23_PADDING: number;
164
- const RSA_NO_PADDING: number;
165
- const RSA_PKCS1_OAEP_PADDING: number;
166
- const RSA_X931_PADDING: number;
167
- const RSA_PKCS1_PSS_PADDING: number;
168
- /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the digest size when signing or verifying. */
169
- const RSA_PSS_SALTLEN_DIGEST: number;
170
- /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the maximum permissible value when signing data. */
171
- const RSA_PSS_SALTLEN_MAX_SIGN: number;
172
- /** Causes the salt length for RSA_PKCS1_PSS_PADDING to be determined automatically when verifying a signature. */
173
- const RSA_PSS_SALTLEN_AUTO: number;
174
- const POINT_CONVERSION_COMPRESSED: number;
175
- const POINT_CONVERSION_UNCOMPRESSED: number;
176
- const POINT_CONVERSION_HYBRID: number;
177
- /** Specifies the built-in default cipher list used by Node.js (colon-separated values). */
178
- const defaultCoreCipherList: string;
179
- /** Specifies the active default cipher list used by the current Node.js process (colon-separated values). */
180
- const defaultCipherList: string;
78
+ verifySpkac(spkac: BinaryLike, encoding?: BufferEncoding): boolean;
181
79
  }
182
- interface HashOptions extends stream.TransformOptions {
183
- /**
184
- * For XOF hash functions such as `shake256`, the
185
- * outputLength option can be used to specify the desired output length in bytes.
186
- */
80
+ /** @deprecated This property is deprecated. Please use `crypto.setFips()` and `crypto.getFips()` instead. */
81
+ var fips: boolean;
82
+ interface HashOptions extends TransformOptions {
187
83
  outputLength?: number | undefined;
188
84
  }
189
- /** @deprecated since v10.0.0 */
190
- const fips: boolean;
191
85
  /**
192
86
  * Creates and returns a `Hash` object that can be used to generate hash digests
193
87
  * using the given `algorithm`. Optional `options` argument controls stream
@@ -230,6 +124,9 @@ declare module "crypto" {
230
124
  * @param options `stream.transform` options
231
125
  */
232
126
  function createHash(algorithm: string, options?: HashOptions): Hash;
127
+ interface HmacOptions extends TransformOptions {
128
+ encoding?: BufferEncoding | undefined;
129
+ }
233
130
  /**
234
131
  * Creates and returns an `Hmac` object that uses the given `algorithm` and `key`.
235
132
  * Optional `options` argument controls stream behavior.
@@ -274,13 +171,7 @@ declare module "crypto" {
274
171
  * @since v0.1.94
275
172
  * @param options `stream.transform` options
276
173
  */
277
- function createHmac(algorithm: string, key: BinaryLike | KeyObject, options?: stream.TransformOptions): Hmac;
278
- // https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
279
- type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary";
280
- type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1";
281
- type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2";
282
- type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding;
283
- type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
174
+ function createHmac(algorithm: string, key: KeyLike, options?: HmacOptions): Hmac;
284
175
  /**
285
176
  * The `Hash` class is a utility for creating hash digests of data. It can be
286
177
  * used in one of two ways:
@@ -345,7 +236,7 @@ declare module "crypto" {
345
236
  * ```
346
237
  * @since v0.1.92
347
238
  */
348
- class Hash extends stream.Transform {
239
+ class Hash extends Transform {
349
240
  private constructor();
350
241
  /**
351
242
  * Creates a new `Hash` object that contains a deep copy of the internal state
@@ -391,8 +282,7 @@ declare module "crypto" {
391
282
  * @since v0.1.92
392
283
  * @param inputEncoding The `encoding` of the `data` string.
393
284
  */
394
- update(data: BinaryLike): Hash;
395
- update(data: string, inputEncoding: Encoding): Hash;
285
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): Hash;
396
286
  /**
397
287
  * Calculates the digest of all of the data passed to be hashed (using the `hash.update()` method).
398
288
  * If `encoding` is provided a string will be returned; otherwise
@@ -404,7 +294,7 @@ declare module "crypto" {
404
294
  * @param encoding The `encoding` of the return value.
405
295
  */
406
296
  digest(): NonSharedBuffer;
407
- digest(encoding: BinaryToTextEncoding): string;
297
+ digest(encoding: BufferEncoding): string;
408
298
  }
409
299
  /**
410
300
  * The `Hmac` class is a utility for creating cryptographic HMAC digests. It can
@@ -471,9 +361,8 @@ declare module "crypto" {
471
361
  * // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
472
362
  * ```
473
363
  * @since v0.1.94
474
- * @deprecated Since v20.13.0 Calling `Hmac` class directly with `Hmac()` or `new Hmac()` is deprecated due to being internals, not intended for public use. Please use the {@link createHmac} method to create Hmac instances.
475
364
  */
476
- class Hmac extends stream.Transform {
365
+ class Hmac extends Transform {
477
366
  private constructor();
478
367
  /**
479
368
  * Updates the `Hmac` content with the given `data`, the encoding of which
@@ -485,8 +374,7 @@ declare module "crypto" {
485
374
  * @since v0.1.94
486
375
  * @param inputEncoding The `encoding` of the `data` string.
487
376
  */
488
- update(data: BinaryLike): Hmac;
489
- update(data: string, inputEncoding: Encoding): Hmac;
377
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): Hmac;
490
378
  /**
491
379
  * Calculates the HMAC digest of all of the data passed using `hmac.update()`.
492
380
  * If `encoding` is
@@ -498,62 +386,97 @@ declare module "crypto" {
498
386
  * @param encoding The `encoding` of the return value.
499
387
  */
500
388
  digest(): NonSharedBuffer;
501
- digest(encoding: BinaryToTextEncoding): string;
389
+ digest(encoding: BufferEncoding): string;
502
390
  }
391
+ type KeyFormat = "pem" | "der" | "jwk" | "raw-public" | "raw-private" | "raw-seed";
503
392
  type KeyObjectType = "secret" | "public" | "private";
504
- interface KeyExportOptions<T extends KeyFormat> {
505
- type: "pkcs1" | "spki" | "pkcs8" | "sec1";
506
- format: T;
393
+ type PublicKeyExportType = "pkcs1" | "spki";
394
+ type PrivateKeyExportType = "pkcs1" | "pkcs8" | "sec1";
395
+ type KeyExportOptions =
396
+ | SymmetricKeyExportOptions
397
+ | PublicKeyExportOptions
398
+ | PrivateKeyExportOptions
399
+ | JwkKeyExportOptions
400
+ | RawPublicKeyExportOptions
401
+ | RawPrivateKeyExportOptions;
402
+ interface SymmetricKeyExportOptions {
403
+ format?: "buffer" | undefined;
404
+ }
405
+ interface PublicKeyExportOptions<T extends PublicKeyExportType = PublicKeyExportType> {
406
+ type: T;
407
+ format: "pem" | "der";
408
+ }
409
+ interface PrivateKeyExportOptions<T extends PrivateKeyExportType = PrivateKeyExportType> {
410
+ type: T;
411
+ format: "pem" | "der";
507
412
  cipher?: string | undefined;
508
- passphrase?: string | Buffer | undefined;
413
+ passphrase?: BinaryLike | undefined;
509
414
  }
510
415
  interface JwkKeyExportOptions {
511
416
  format: "jwk";
512
417
  }
513
- interface JsonWebKey {
514
- crv?: string;
515
- d?: string;
516
- dp?: string;
517
- dq?: string;
518
- e?: string;
519
- k?: string;
520
- kty?: string;
521
- n?: string;
522
- p?: string;
523
- q?: string;
524
- qi?: string;
525
- x?: string;
526
- y?: string;
527
- [key: string]: unknown;
528
- }
418
+ interface RawPublicKeyExportOptions {
419
+ format: "raw-public";
420
+ }
421
+ interface RawPrivateKeyExportOptions {
422
+ format: "raw-private" | "raw-seed";
423
+ }
424
+ interface KeyPairExportOptions<
425
+ TPublic extends PublicKeyExportType = PublicKeyExportType,
426
+ TPrivate extends PrivateKeyExportType = PrivateKeyExportType,
427
+ > {
428
+ publicKeyEncoding?:
429
+ | PublicKeyExportOptions<TPublic>
430
+ | RawPublicKeyExportOptions
431
+ | JwkKeyExportOptions
432
+ | undefined;
433
+ privateKeyEncoding?:
434
+ | PrivateKeyExportOptions<TPrivate>
435
+ | RawPrivateKeyExportOptions
436
+ | JwkKeyExportOptions
437
+ | undefined;
438
+ }
439
+ type KeyExportResult<T, Default> = T extends { format: infer F extends KeyFormat } ? {
440
+ "der": NonSharedBuffer;
441
+ "jwk": webcrypto.JsonWebKey;
442
+ "pem": string;
443
+ "raw-public": NonSharedBuffer;
444
+ "raw-private": NonSharedBuffer;
445
+ "raw-seed": NonSharedBuffer;
446
+ }[F]
447
+ : Default;
448
+ interface KeyPairExportResult<T extends KeyPairExportOptions> {
449
+ publicKey: KeyExportResult<T["publicKeyEncoding"], KeyObject>;
450
+ privateKey: KeyExportResult<T["privateKeyEncoding"], KeyObject>;
451
+ }
452
+ type KeyPairExportCallback<T extends KeyPairExportOptions = {}> = (
453
+ err: Error | null,
454
+ publicKey: KeyExportResult<T["publicKeyEncoding"], KeyObject>,
455
+ privateKey: KeyExportResult<T["privateKeyEncoding"], KeyObject>,
456
+ ) => void;
457
+ type MLDSAKeyType = `ml-dsa-${44 | 65 | 87}`;
458
+ type MLKEMKeyType = `ml-kem-${1024 | 512 | 768}`;
459
+ type SLHDSAKeyType = `slh-dsa-${"sha2" | "shake"}-${128 | 192 | 256}${"f" | "s"}`;
460
+ type AsymmetricKeyType =
461
+ | "dh"
462
+ | "dsa"
463
+ | "ec"
464
+ | "ed25519"
465
+ | "ed448"
466
+ | MLDSAKeyType
467
+ | MLKEMKeyType
468
+ | "rsa-pss"
469
+ | "rsa"
470
+ | SLHDSAKeyType
471
+ | "x25519"
472
+ | "x448";
529
473
  interface AsymmetricKeyDetails {
530
- /**
531
- * Key size in bits (RSA, DSA).
532
- */
533
474
  modulusLength?: number;
534
- /**
535
- * Public exponent (RSA).
536
- */
537
475
  publicExponent?: bigint;
538
- /**
539
- * Name of the message digest (RSA-PSS).
540
- */
541
476
  hashAlgorithm?: string;
542
- /**
543
- * Name of the message digest used by MGF1 (RSA-PSS).
544
- */
545
477
  mgf1HashAlgorithm?: string;
546
- /**
547
- * Minimal salt length in bytes (RSA-PSS).
548
- */
549
478
  saltLength?: number;
550
- /**
551
- * Size of q in bits (DSA).
552
- */
553
479
  divisorLength?: number;
554
- /**
555
- * Name of the curve (EC).
556
- */
557
480
  namedCurve?: string;
558
481
  }
559
482
  /**
@@ -572,7 +495,11 @@ declare module "crypto" {
572
495
  class KeyObject {
573
496
  private constructor();
574
497
  /**
575
- * Example: Converting a `CryptoKey` instance to a `KeyObject`:
498
+ * Returns the underlying `KeyObject` of a `CryptoKey`. The returned `KeyObject`
499
+ * does not retain any of the restrictions imposed by the Web Crypto API on the
500
+ * original `CryptoKey`, such as the allowed key usages, the algorithm or hash
501
+ * algorithm bindings, and the extractability flag. In particular, the underlying
502
+ * key material of the returned `KeyObject` can always be exported.
576
503
  *
577
504
  * ```js
578
505
  * const { KeyObject } = await import('node:crypto');
@@ -592,24 +519,14 @@ declare module "crypto" {
592
519
  */
593
520
  static from(key: webcrypto.CryptoKey): KeyObject;
594
521
  /**
595
- * For asymmetric keys, this property represents the type of the key. Supported key
596
- * types are:
597
- *
598
- * * `'rsa'` (OID 1.2.840.113549.1.1.1)
599
- * * `'rsa-pss'` (OID 1.2.840.113549.1.1.10)
600
- * * `'dsa'` (OID 1.2.840.10040.4.1)
601
- * * `'ec'` (OID 1.2.840.10045.2.1)
602
- * * `'x25519'` (OID 1.3.101.110)
603
- * * `'x448'` (OID 1.3.101.111)
604
- * * `'ed25519'` (OID 1.3.101.112)
605
- * * `'ed448'` (OID 1.3.101.113)
606
- * * `'dh'` (OID 1.2.840.113549.1.3.1)
522
+ * For asymmetric keys, this property represents the type of the key. See the
523
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
607
524
  *
608
525
  * This property is `undefined` for unrecognized `KeyObject` types and symmetric
609
526
  * keys.
610
527
  * @since v11.6.0
611
528
  */
612
- asymmetricKeyType?: KeyType;
529
+ asymmetricKeyType?: AsymmetricKeyType;
613
530
  /**
614
531
  * This property exists only on asymmetric keys. Depending on the type of the key,
615
532
  * this object contains information about the key. None of the information obtained
@@ -625,31 +542,21 @@ declare module "crypto" {
625
542
  */
626
543
  asymmetricKeyDetails?: AsymmetricKeyDetails;
627
544
  /**
628
- * For symmetric keys, the following encoding options can be used:
629
- *
630
- * For public keys, the following encoding options can be used:
631
- *
632
- * For private keys, the following encoding options can be used:
633
- *
634
545
  * The result type depends on the selected encoding format, when PEM the
635
546
  * result is a string, when DER it will be a buffer containing the data
636
- * encoded as DER, when [JWK](https://tools.ietf.org/html/rfc7517) it will be an object.
637
- *
638
- * When [JWK](https://tools.ietf.org/html/rfc7517) encoding format was selected, all other encoding options are
639
- * ignored.
640
- *
641
- * PKCS#1, SEC1, and PKCS#8 type keys can be encrypted by using a combination of
642
- * the `cipher` and `format` options. The PKCS#8 `type` can be used with any`format` to encrypt any key algorithm (RSA, EC, or DH) by specifying a`cipher`. PKCS#1 and SEC1 can only be
643
- * encrypted by specifying a `cipher`when the PEM `format` is used. For maximum compatibility, use PKCS#8 for
644
- * encrypted private keys. Since PKCS#8 defines its own
645
- * encryption mechanism, PEM-level encryption is not supported when encrypting
646
- * a PKCS#8 key. See [RFC 5208](https://www.rfc-editor.org/rfc/rfc5208.txt) for PKCS#8 encryption and [RFC 1421](https://www.rfc-editor.org/rfc/rfc1421.txt) for
647
- * PKCS#1 and SEC1 encryption.
547
+ * encoded as DER, when [JWK](https://tools.ietf.org/html/rfc7517) it will be an object. Raw formats return a
548
+ * `Buffer` containing the raw key material.
549
+ *
550
+ * Private keys can be encrypted by specifying a `cipher` and `passphrase`.
551
+ * The PKCS#8 `type` supports encryption with both PEM and DER `format` for any
552
+ * key algorithm. PKCS#1 and SEC1 can only be encrypted when the PEM `format` is
553
+ * used. For maximum compatibility, use PKCS#8 for encrypted private keys. Since
554
+ * PKCS#8 defines its own encryption mechanism, PEM-level encryption is not
555
+ * supported when encrypting a PKCS#8 key. See [RFC 5208](https://www.rfc-editor.org/rfc/rfc5208.txt) for PKCS#8 encryption
556
+ * and [RFC 1421](https://www.rfc-editor.org/rfc/rfc1421.txt) for PKCS#1 and SEC1 encryption.
648
557
  * @since v11.6.0
649
558
  */
650
- export(options: KeyExportOptions<"pem">): string | NonSharedBuffer;
651
- export(options?: KeyExportOptions<"der">): NonSharedBuffer;
652
- export(options?: JwkKeyExportOptions): JsonWebKey;
559
+ export<T extends KeyExportOptions = {}>(options?: T): KeyExportResult<T, NonSharedBuffer>;
653
560
  /**
654
561
  * Returns `true` or `false` depending on whether the keys have exactly the same
655
562
  * type, value, and parameters. This method is not [constant time](https://en.wikipedia.org/wiki/Timing_attack).
@@ -687,19 +594,18 @@ declare module "crypto" {
687
594
  type CipherGCMTypes = "aes-128-gcm" | "aes-192-gcm" | "aes-256-gcm";
688
595
  type CipherOCBTypes = "aes-128-ocb" | "aes-192-ocb" | "aes-256-ocb";
689
596
  type CipherChaCha20Poly1305Types = "chacha20-poly1305";
690
- type BinaryLike = string | NodeJS.ArrayBufferView;
691
- type CipherKey = BinaryLike | KeyObject;
692
- interface CipherCCMOptions extends stream.TransformOptions {
597
+ type BinaryLike = string | ArrayBufferLike | NodeJS.ArrayBufferView;
598
+ type KeyLike = BinaryLike | KeyObject;
599
+ interface CipherCCMOptions extends TransformOptions {
693
600
  authTagLength: number;
694
601
  }
695
- interface CipherGCMOptions extends stream.TransformOptions {
602
+ interface CipherGCMOptions extends TransformOptions {
696
603
  authTagLength?: number | undefined;
697
604
  }
698
- interface CipherOCBOptions extends stream.TransformOptions {
605
+ interface CipherOCBOptions extends TransformOptions {
699
606
  authTagLength: number;
700
607
  }
701
- interface CipherChaCha20Poly1305Options extends stream.TransformOptions {
702
- /** @default 16 */
608
+ interface CipherChaCha20Poly1305Options extends TransformOptions {
703
609
  authTagLength?: number | undefined;
704
610
  }
705
611
  /**
@@ -734,36 +640,36 @@ declare module "crypto" {
734
640
  */
735
641
  function createCipheriv(
736
642
  algorithm: CipherCCMTypes,
737
- key: CipherKey,
643
+ key: KeyLike,
738
644
  iv: BinaryLike,
739
645
  options: CipherCCMOptions,
740
646
  ): CipherCCM;
741
647
  function createCipheriv(
742
648
  algorithm: CipherOCBTypes,
743
- key: CipherKey,
649
+ key: KeyLike,
744
650
  iv: BinaryLike,
745
651
  options: CipherOCBOptions,
746
652
  ): CipherOCB;
747
653
  function createCipheriv(
748
654
  algorithm: CipherGCMTypes,
749
- key: CipherKey,
655
+ key: KeyLike,
750
656
  iv: BinaryLike,
751
657
  options?: CipherGCMOptions,
752
658
  ): CipherGCM;
753
659
  function createCipheriv(
754
660
  algorithm: CipherChaCha20Poly1305Types,
755
- key: CipherKey,
661
+ key: KeyLike,
756
662
  iv: BinaryLike,
757
663
  options?: CipherChaCha20Poly1305Options,
758
664
  ): CipherChaCha20Poly1305;
759
665
  function createCipheriv(
760
666
  algorithm: string,
761
- key: CipherKey,
667
+ key: KeyLike,
762
668
  iv: BinaryLike | null,
763
- options?: stream.TransformOptions,
764
- ): Cipher;
669
+ options?: TransformOptions,
670
+ ): Cipheriv;
765
671
  /**
766
- * Instances of the `Cipher` class are used to encrypt data. The class can be
672
+ * Instances of the `Cipheriv` class are used to encrypt data. The class can be
767
673
  * used in one of two ways:
768
674
  *
769
675
  * * As a `stream` that is both readable and writable, where plain unencrypted
@@ -772,10 +678,10 @@ declare module "crypto" {
772
678
  * the encrypted data.
773
679
  *
774
680
  * The {@link createCipheriv} method is
775
- * used to create `Cipher` instances. `Cipher` objects are not to be created
681
+ * used to create `Cipheriv` instances. `Cipheriv` objects are not to be created
776
682
  * directly using the `new` keyword.
777
683
  *
778
- * Example: Using `Cipher` objects as streams:
684
+ * Example: Using `Cipheriv` objects as streams:
779
685
  *
780
686
  * ```js
781
687
  * const {
@@ -810,7 +716,7 @@ declare module "crypto" {
810
716
  * });
811
717
  * ```
812
718
  *
813
- * Example: Using `Cipher` and piped streams:
719
+ * Example: Using `Cipheriv` and piped streams:
814
720
  *
815
721
  * ```js
816
722
  * import {
@@ -881,7 +787,7 @@ declare module "crypto" {
881
787
  * ```
882
788
  * @since v0.1.94
883
789
  */
884
- class Cipher extends stream.Transform {
790
+ class Cipheriv extends Transform {
885
791
  private constructor();
886
792
  /**
887
793
  * Updates the cipher with `data`. If the `inputEncoding` argument is given,
@@ -897,12 +803,14 @@ declare module "crypto" {
897
803
  * @param inputEncoding The `encoding` of the data.
898
804
  * @param outputEncoding The `encoding` of the return value.
899
805
  */
900
- update(data: BinaryLike): NonSharedBuffer;
901
- update(data: string, inputEncoding: Encoding): NonSharedBuffer;
902
- update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
903
- update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
806
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): NonSharedBuffer;
807
+ update(
808
+ data: string | NodeJS.ArrayBufferView,
809
+ inputEncoding: BufferEncoding | null | undefined,
810
+ outputEncoding: BufferEncoding,
811
+ ): string;
904
812
  /**
905
- * Once the `cipher.final()` method has been called, the `Cipher` object can no
813
+ * Once the `cipher.final()` method has been called, the `Cipheriv` object can no
906
814
  * longer be used to encrypt data. Attempts to call `cipher.final()` more than
907
815
  * once will result in an error being thrown.
908
816
  * @since v0.1.94
@@ -912,7 +820,7 @@ declare module "crypto" {
912
820
  final(): NonSharedBuffer;
913
821
  final(outputEncoding: BufferEncoding): string;
914
822
  /**
915
- * When using block encryption algorithms, the `Cipher` class will automatically
823
+ * When using block encryption algorithms, the `Cipheriv` class will automatically
916
824
  * add padding to the input data to the appropriate block size. To disable the
917
825
  * default padding call `cipher.setAutoPadding(false)`.
918
826
  *
@@ -928,50 +836,31 @@ declare module "crypto" {
928
836
  */
929
837
  setAutoPadding(autoPadding?: boolean): this;
930
838
  }
931
- interface CipherCCM extends Cipher {
932
- setAAD(
933
- buffer: NodeJS.ArrayBufferView,
934
- options: {
935
- plaintextLength: number;
936
- },
937
- ): this;
938
- getAuthTag(): NonSharedBuffer;
939
- }
940
- interface CipherGCM extends Cipher {
941
- setAAD(
942
- buffer: NodeJS.ArrayBufferView,
943
- options?: {
944
- plaintextLength: number;
945
- },
946
- ): this;
947
- getAuthTag(): NonSharedBuffer;
948
- }
949
- interface CipherOCB extends Cipher {
950
- setAAD(
951
- buffer: NodeJS.ArrayBufferView,
952
- options?: {
953
- plaintextLength: number;
954
- },
955
- ): this;
839
+ interface CipherAEADMethods {
956
840
  getAuthTag(): NonSharedBuffer;
841
+ setAAD(buffer: BinaryLike, options?: {
842
+ plaintextLength?: number | undefined;
843
+ encoding?: BufferEncoding | undefined;
844
+ }): this;
957
845
  }
958
- interface CipherChaCha20Poly1305 extends Cipher {
959
- setAAD(
960
- buffer: NodeJS.ArrayBufferView,
961
- options: {
962
- plaintextLength: number;
963
- },
964
- ): this;
965
- getAuthTag(): NonSharedBuffer;
846
+ interface CipherCCM extends Cipheriv, CipherAEADMethods {
847
+ setAAD(buffer: BinaryLike, options: {
848
+ plaintextLength: number;
849
+ encoding?: BufferEncoding | undefined;
850
+ }): this;
966
851
  }
852
+ interface CipherGCM extends Cipheriv, CipherAEADMethods {}
853
+ interface CipherOCB extends Cipheriv, CipherAEADMethods {}
854
+ interface CipherChaCha20Poly1305 extends Cipheriv, CipherAEADMethods {}
967
855
  /**
968
- * Creates and returns a `Decipher` object that uses the given `algorithm`, `key` and initialization vector (`iv`).
856
+ * Creates and returns a `Decipheriv` object that uses the given `algorithm`, `key` and initialization vector (`iv`).
969
857
  *
970
858
  * The `options` argument controls stream behavior and is optional except when a
971
- * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the `authTagLength` option is required and specifies the length of the
972
- * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength` option is not required but can be used to restrict accepted authentication tags
973
- * to those with the specified length.
974
- * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
859
+ * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the
860
+ * `authTagLength` option is required and specifies the length of the
861
+ * authentication tag in bytes, see [CCM mode](https://nodejs.org/docs/latest-v26.x/api/crypto.html#ccm-mode).
862
+ * For AES-GCM and `chacha20-poly1305`, the `authTagLength` option defaults to 16
863
+ * bytes and must be set to a different value if a different length is used.
975
864
  *
976
865
  * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
977
866
  * recent OpenSSL releases, `openssl list -cipher-algorithms` will
@@ -995,36 +884,36 @@ declare module "crypto" {
995
884
  */
996
885
  function createDecipheriv(
997
886
  algorithm: CipherCCMTypes,
998
- key: CipherKey,
887
+ key: KeyLike,
999
888
  iv: BinaryLike,
1000
889
  options: CipherCCMOptions,
1001
890
  ): DecipherCCM;
1002
891
  function createDecipheriv(
1003
892
  algorithm: CipherOCBTypes,
1004
- key: CipherKey,
893
+ key: KeyLike,
1005
894
  iv: BinaryLike,
1006
895
  options: CipherOCBOptions,
1007
896
  ): DecipherOCB;
1008
897
  function createDecipheriv(
1009
898
  algorithm: CipherGCMTypes,
1010
- key: CipherKey,
899
+ key: KeyLike,
1011
900
  iv: BinaryLike,
1012
901
  options?: CipherGCMOptions,
1013
902
  ): DecipherGCM;
1014
903
  function createDecipheriv(
1015
904
  algorithm: CipherChaCha20Poly1305Types,
1016
- key: CipherKey,
905
+ key: KeyLike,
1017
906
  iv: BinaryLike,
1018
907
  options?: CipherChaCha20Poly1305Options,
1019
908
  ): DecipherChaCha20Poly1305;
1020
909
  function createDecipheriv(
1021
910
  algorithm: string,
1022
- key: CipherKey,
911
+ key: KeyLike,
1023
912
  iv: BinaryLike | null,
1024
- options?: stream.TransformOptions,
1025
- ): Decipher;
913
+ options?: TransformOptions,
914
+ ): Decipheriv;
1026
915
  /**
1027
- * Instances of the `Decipher` class are used to decrypt data. The class can be
916
+ * Instances of the `Decipheriv` class are used to decrypt data. The class can be
1028
917
  * used in one of two ways:
1029
918
  *
1030
919
  * * As a `stream` that is both readable and writable, where plain encrypted
@@ -1033,10 +922,10 @@ declare module "crypto" {
1033
922
  * produce the unencrypted data.
1034
923
  *
1035
924
  * The {@link createDecipheriv} method is
1036
- * used to create `Decipher` instances. `Decipher` objects are not to be created
925
+ * used to create `Decipheriv` instances. `Decipheriv` objects are not to be created
1037
926
  * directly using the `new` keyword.
1038
927
  *
1039
- * Example: Using `Decipher` objects as streams:
928
+ * Example: Using `Decipheriv` objects as streams:
1040
929
  *
1041
930
  * ```js
1042
931
  * import { Buffer } from 'node:buffer';
@@ -1075,7 +964,7 @@ declare module "crypto" {
1075
964
  * decipher.end();
1076
965
  * ```
1077
966
  *
1078
- * Example: Using `Decipher` and piped streams:
967
+ * Example: Using `Decipheriv` and piped streams:
1079
968
  *
1080
969
  * ```js
1081
970
  * import {
@@ -1131,7 +1020,7 @@ declare module "crypto" {
1131
1020
  * ```
1132
1021
  * @since v0.1.94
1133
1022
  */
1134
- class Decipher extends stream.Transform {
1023
+ class Decipheriv extends Transform {
1135
1024
  private constructor();
1136
1025
  /**
1137
1026
  * Updates the decipher with `data`. If the `inputEncoding` argument is given,
@@ -1147,12 +1036,14 @@ declare module "crypto" {
1147
1036
  * @param inputEncoding The `encoding` of the `data` string.
1148
1037
  * @param outputEncoding The `encoding` of the return value.
1149
1038
  */
1150
- update(data: NodeJS.ArrayBufferView): NonSharedBuffer;
1151
- update(data: string, inputEncoding: Encoding): NonSharedBuffer;
1152
- update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
1153
- update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
1039
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): NonSharedBuffer;
1040
+ update(
1041
+ data: string | NodeJS.ArrayBufferView,
1042
+ inputEncoding: BufferEncoding | null | undefined,
1043
+ outputEncoding: BufferEncoding,
1044
+ ): string;
1154
1045
  /**
1155
- * Once the `decipher.final()` method has been called, the `Decipher` object can
1046
+ * Once the `decipher.final()` method has been called, the `Decipheriv` object can
1156
1047
  * no longer be used to decrypt data. Attempts to call `decipher.final()` more
1157
1048
  * than once will result in an error being thrown.
1158
1049
  * @since v0.1.94
@@ -1175,54 +1066,59 @@ declare module "crypto" {
1175
1066
  */
1176
1067
  setAutoPadding(auto_padding?: boolean): this;
1177
1068
  }
1178
- interface DecipherCCM extends Decipher {
1179
- setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1180
- setAAD(
1181
- buffer: NodeJS.ArrayBufferView,
1182
- options: {
1183
- plaintextLength: number;
1184
- },
1185
- ): this;
1186
- }
1187
- interface DecipherGCM extends Decipher {
1188
- setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1189
- setAAD(
1190
- buffer: NodeJS.ArrayBufferView,
1191
- options?: {
1192
- plaintextLength: number;
1193
- },
1194
- ): this;
1195
- }
1196
- interface DecipherOCB extends Decipher {
1197
- setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1069
+ interface DecipherAEADMethods {
1198
1070
  setAAD(
1199
- buffer: NodeJS.ArrayBufferView,
1071
+ buffer: BinaryLike,
1200
1072
  options?: {
1201
- plaintextLength: number;
1073
+ plaintextLength?: number | undefined;
1074
+ encoding?: BufferEncoding | undefined;
1202
1075
  },
1203
1076
  ): this;
1077
+ setAuthTag(buffer: BinaryLike, encoding?: BufferEncoding): this;
1204
1078
  }
1205
- interface DecipherChaCha20Poly1305 extends Decipher {
1206
- setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1079
+ interface DecipherCCM extends Decipheriv, DecipherAEADMethods {
1207
1080
  setAAD(
1208
- buffer: NodeJS.ArrayBufferView,
1081
+ buffer: BinaryLike,
1209
1082
  options: {
1210
1083
  plaintextLength: number;
1084
+ encoding?: BufferEncoding | undefined;
1211
1085
  },
1212
1086
  ): this;
1213
1087
  }
1088
+ interface DecipherGCM extends Decipheriv, DecipherAEADMethods {}
1089
+ interface DecipherOCB extends Decipheriv, DecipherAEADMethods {}
1090
+ interface DecipherChaCha20Poly1305 extends Decipheriv, DecipherAEADMethods {}
1214
1091
  interface PrivateKeyInput {
1215
- key: string | Buffer;
1216
- format?: KeyFormat | undefined;
1217
- type?: "pkcs1" | "pkcs8" | "sec1" | undefined;
1218
- passphrase?: string | Buffer | undefined;
1219
- encoding?: string | undefined;
1092
+ key: BinaryLike;
1093
+ format?: "pem" | "der" | undefined;
1094
+ type?: PrivateKeyExportType | undefined;
1095
+ passphrase?: BinaryLike | undefined;
1096
+ encoding?: BufferEncoding | undefined;
1220
1097
  }
1221
1098
  interface PublicKeyInput {
1222
- key: string | Buffer;
1223
- format?: KeyFormat | undefined;
1224
- type?: "pkcs1" | "spki" | undefined;
1225
- encoding?: string | undefined;
1099
+ key: BinaryLike;
1100
+ format?: "pem" | "der" | undefined;
1101
+ type?: PublicKeyExportType | undefined;
1102
+ encoding?: BufferEncoding | undefined;
1103
+ }
1104
+ interface RawPrivateKeyInput {
1105
+ key: ArrayBufferLike | NodeJS.ArrayBufferView;
1106
+ format: "raw-private" | "raw-seed";
1107
+ asymmetricKeyType: AsymmetricKeyType;
1108
+ namedCurve?: string | undefined;
1109
+ }
1110
+ interface RawPublicKeyInput {
1111
+ key: ArrayBufferLike | NodeJS.ArrayBufferView;
1112
+ format: "raw-public";
1113
+ asymmetricKeyType: AsymmetricKeyType;
1114
+ namedCurve?: string | undefined;
1115
+ }
1116
+ interface JsonWebKeyInput {
1117
+ key: webcrypto.JsonWebKey;
1118
+ format: "jwk";
1119
+ }
1120
+ interface SecretKeyOptions {
1121
+ length: number;
1226
1122
  }
1227
1123
  /**
1228
1124
  * Asynchronously generates a new random secret key of the given `length`. The `type` will determine which validations will be performed on the `length`.
@@ -1245,9 +1141,7 @@ declare module "crypto" {
1245
1141
  */
1246
1142
  function generateKey(
1247
1143
  type: "hmac" | "aes",
1248
- options: {
1249
- length: number;
1250
- },
1144
+ options: SecretKeyOptions,
1251
1145
  callback: (err: Error | null, key: KeyObject) => void,
1252
1146
  ): void;
1253
1147
  /**
@@ -1267,16 +1161,7 @@ declare module "crypto" {
1267
1161
  * @since v15.0.0
1268
1162
  * @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`.
1269
1163
  */
1270
- function generateKeySync(
1271
- type: "hmac" | "aes",
1272
- options: {
1273
- length: number;
1274
- },
1275
- ): KeyObject;
1276
- interface JsonWebKeyInput {
1277
- key: JsonWebKey;
1278
- format: "jwk";
1279
- }
1164
+ function generateKeySync(type: "hmac" | "aes", options: SecretKeyOptions): KeyObject;
1280
1165
  /**
1281
1166
  * Creates and returns a new key object containing a private key. If `key` is a
1282
1167
  * string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key` must be an object with the properties described above.
@@ -1285,7 +1170,7 @@ declare module "crypto" {
1285
1170
  * of the passphrase is limited to 1024 bytes.
1286
1171
  * @since v11.6.0
1287
1172
  */
1288
- function createPrivateKey(key: PrivateKeyInput | string | Buffer | JsonWebKeyInput): KeyObject;
1173
+ function createPrivateKey(key: PrivateKeyInput | RawPrivateKeyInput | JsonWebKeyInput | BinaryLike): KeyObject;
1289
1174
  /**
1290
1175
  * Creates and returns a new key object containing a public key. If `key` is a
1291
1176
  * string or `Buffer`, `format` is assumed to be `'pem'`; if `key` is a `KeyObject` with type `'private'`, the public key is derived from the given private key;
@@ -1300,15 +1185,14 @@ declare module "crypto" {
1300
1185
  * and it will be impossible to extract the private key from the returned object.
1301
1186
  * @since v11.6.0
1302
1187
  */
1303
- function createPublicKey(key: PublicKeyInput | string | Buffer | KeyObject | JsonWebKeyInput): KeyObject;
1188
+ function createPublicKey(key: PublicKeyInput | RawPublicKeyInput | JsonWebKeyInput | KeyLike): KeyObject;
1304
1189
  /**
1305
1190
  * Creates and returns a new key object containing a secret key for symmetric
1306
1191
  * encryption or `Hmac`.
1307
1192
  * @since v11.6.0
1308
1193
  * @param encoding The string encoding when `key` is a string.
1309
1194
  */
1310
- function createSecretKey(key: NodeJS.ArrayBufferView): KeyObject;
1311
- function createSecretKey(key: string, encoding: BufferEncoding): KeyObject;
1195
+ function createSecretKey(key: BinaryLike, encoding?: BufferEncoding): KeyObject;
1312
1196
  /**
1313
1197
  * Creates and returns a `Sign` object that uses the given `algorithm`. Use {@link getHashes} to obtain the names of the available digest algorithms.
1314
1198
  * Optional `options` argument controls the `stream.Writable` behavior.
@@ -1321,27 +1205,26 @@ declare module "crypto" {
1321
1205
  * @since v0.1.92
1322
1206
  * @param options `stream.Writable` options
1323
1207
  */
1324
- function createSign(algorithm: string, options?: stream.WritableOptions): Sign;
1208
+ function createSign(algorithm: string, options?: WritableOptions): Sign;
1325
1209
  type DSAEncoding = "der" | "ieee-p1363";
1326
1210
  interface SigningOptions {
1327
- /**
1328
- * @see crypto.constants.RSA_PKCS1_PADDING
1329
- */
1330
1211
  padding?: number | undefined;
1331
1212
  saltLength?: number | undefined;
1332
1213
  dsaEncoding?: DSAEncoding | undefined;
1214
+ context?: NodeJS.ArrayBufferView | undefined;
1333
1215
  }
1334
1216
  interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {}
1217
+ interface SignRawPrivateKeyInput extends RawPrivateKeyInput, SigningOptions {}
1218
+ interface SignJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
1335
1219
  interface SignKeyObjectInput extends SigningOptions {
1336
1220
  key: KeyObject;
1337
1221
  }
1338
- interface SignJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
1339
1222
  interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions {}
1223
+ interface VerifyRawPublicKeyInput extends RawPublicKeyInput, SigningOptions {}
1224
+ interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
1340
1225
  interface VerifyKeyObjectInput extends SigningOptions {
1341
1226
  key: KeyObject;
1342
1227
  }
1343
- interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
1344
- type KeyLike = string | Buffer | KeyObject;
1345
1228
  /**
1346
1229
  * The `Sign` class is a utility for generating signatures. It can be used in one
1347
1230
  * of two ways:
@@ -1405,7 +1288,7 @@ declare module "crypto" {
1405
1288
  * ```
1406
1289
  * @since v0.1.92
1407
1290
  */
1408
- class Sign extends stream.Writable {
1291
+ class Sign extends Writable {
1409
1292
  private constructor();
1410
1293
  /**
1411
1294
  * Updates the `Sign` content with the given `data`, the encoding of which
@@ -1417,8 +1300,7 @@ declare module "crypto" {
1417
1300
  * @since v0.1.92
1418
1301
  * @param inputEncoding The `encoding` of the `data` string.
1419
1302
  */
1420
- update(data: BinaryLike): this;
1421
- update(data: string, inputEncoding: Encoding): this;
1303
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): this;
1422
1304
  /**
1423
1305
  * Calculates the signature on all the data passed through using either `sign.update()` or `sign.write()`.
1424
1306
  *
@@ -1431,10 +1313,22 @@ declare module "crypto" {
1431
1313
  * called. Multiple calls to `sign.sign()` will result in an error being thrown.
1432
1314
  * @since v0.1.92
1433
1315
  */
1434
- sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput): NonSharedBuffer;
1435
1316
  sign(
1436
- privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
1437
- outputFormat: BinaryToTextEncoding,
1317
+ privateKey:
1318
+ | KeyLike
1319
+ | SignKeyObjectInput
1320
+ | SignPrivateKeyInput
1321
+ | SignRawPrivateKeyInput
1322
+ | SignJsonWebKeyInput,
1323
+ ): NonSharedBuffer;
1324
+ sign(
1325
+ privateKey:
1326
+ | KeyLike
1327
+ | SignKeyObjectInput
1328
+ | SignPrivateKeyInput
1329
+ | SignRawPrivateKeyInput
1330
+ | SignJsonWebKeyInput,
1331
+ outputFormat: BufferEncoding,
1438
1332
  ): string;
1439
1333
  }
1440
1334
  /**
@@ -1450,7 +1344,7 @@ declare module "crypto" {
1450
1344
  * @since v0.1.92
1451
1345
  * @param options `stream.Writable` options
1452
1346
  */
1453
- function createVerify(algorithm: string, options?: stream.WritableOptions): Verify;
1347
+ function createVerify(algorithm: string, options?: WritableOptions): Verify;
1454
1348
  /**
1455
1349
  * The `Verify` class is a utility for verifying signatures. It can be used in one
1456
1350
  * of two ways:
@@ -1465,7 +1359,7 @@ declare module "crypto" {
1465
1359
  * See `Sign` for examples.
1466
1360
  * @since v0.1.92
1467
1361
  */
1468
- class Verify extends stream.Writable {
1362
+ class Verify extends Writable {
1469
1363
  private constructor();
1470
1364
  /**
1471
1365
  * Updates the `Verify` content with the given `data`, the encoding of which
@@ -1477,12 +1371,11 @@ declare module "crypto" {
1477
1371
  * @since v0.1.92
1478
1372
  * @param inputEncoding The `encoding` of the `data` string.
1479
1373
  */
1480
- update(data: BinaryLike): Verify;
1481
- update(data: string, inputEncoding: Encoding): Verify;
1374
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): Verify;
1482
1375
  /**
1483
- * Verifies the provided data using the given `object` and `signature`.
1376
+ * Verifies the provided data using the given `key` and `signature`.
1484
1377
  *
1485
- * If `object` is not a `KeyObject`, this function behaves as if `object` had been passed to {@link createPublicKey}. If it is an
1378
+ * If `key` is not a `KeyObject`, this function behaves as if `key` had been passed to {@link createPublicKey}. If it is an
1486
1379
  * object, the following additional properties can be passed:
1487
1380
  *
1488
1381
  * The `signature` argument is the previously calculated signature for the data, in
@@ -1499,13 +1392,14 @@ declare module "crypto" {
1499
1392
  * @since v0.1.92
1500
1393
  */
1501
1394
  verify(
1502
- object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
1503
- signature: NodeJS.ArrayBufferView,
1504
- ): boolean;
1505
- verify(
1506
- object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
1507
- signature: string,
1508
- signature_format?: BinaryToTextEncoding,
1395
+ key:
1396
+ | KeyLike
1397
+ | VerifyKeyObjectInput
1398
+ | VerifyPublicKeyInput
1399
+ | VerifyRawPublicKeyInput
1400
+ | VerifyJsonWebKeyInput,
1401
+ signature: BinaryLike,
1402
+ signatureEncoding?: BufferEncoding,
1509
1403
  ): boolean;
1510
1404
  }
1511
1405
  /**
@@ -1526,24 +1420,15 @@ declare module "crypto" {
1526
1420
  */
1527
1421
  function createDiffieHellman(primeLength: number, generator?: number): DiffieHellman;
1528
1422
  function createDiffieHellman(
1529
- prime: ArrayBuffer | NodeJS.ArrayBufferView,
1530
- generator?: number | ArrayBuffer | NodeJS.ArrayBufferView,
1531
- ): DiffieHellman;
1532
- function createDiffieHellman(
1533
- prime: ArrayBuffer | NodeJS.ArrayBufferView,
1534
- generator: string,
1535
- generatorEncoding: BinaryToTextEncoding,
1536
- ): DiffieHellman;
1537
- function createDiffieHellman(
1538
- prime: string,
1539
- primeEncoding: BinaryToTextEncoding,
1540
- generator?: number | ArrayBuffer | NodeJS.ArrayBufferView,
1423
+ prime: BinaryLike,
1424
+ primeEncoding?: BufferEncoding,
1425
+ generator?: number | BinaryLike,
1426
+ generatorEncoding?: BufferEncoding,
1541
1427
  ): DiffieHellman;
1542
1428
  function createDiffieHellman(
1543
- prime: string,
1544
- primeEncoding: BinaryToTextEncoding,
1545
- generator: string,
1546
- generatorEncoding: BinaryToTextEncoding,
1429
+ prime: BinaryLike,
1430
+ generator: number | BinaryLike,
1431
+ generatorEncoding?: BufferEncoding,
1547
1432
  ): DiffieHellman;
1548
1433
  /**
1549
1434
  * The `DiffieHellman` class is a utility for creating Diffie-Hellman key
@@ -1585,13 +1470,15 @@ declare module "crypto" {
1585
1470
  * If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.
1586
1471
  *
1587
1472
  * This function is a thin wrapper around [`DH_generate_key()`](https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html). In particular,
1588
- * once a private key has been generated or set, calling this function only updates
1589
- * the public key but does not generate a new private key.
1473
+ * once a private key has been generated or set, calling this function only
1474
+ * recomputes the public key from the existing private key. Since the public key is
1475
+ * determined by the private key, the result will be the same unless the private key
1476
+ * has been changed via `diffieHellman.setPrivateKey()`.
1590
1477
  * @since v0.5.0
1591
1478
  * @param encoding The `encoding` of the return value.
1592
1479
  */
1593
1480
  generateKeys(): NonSharedBuffer;
1594
- generateKeys(encoding: BinaryToTextEncoding): string;
1481
+ generateKeys(encoding: BufferEncoding): string;
1595
1482
  /**
1596
1483
  * Computes the shared secret using `otherPublicKey` as the other
1597
1484
  * party's public key and returns the computed shared secret. The supplied
@@ -1606,24 +1493,13 @@ declare module "crypto" {
1606
1493
  * @param outputEncoding The `encoding` of the return value.
1607
1494
  */
1608
1495
  computeSecret(
1609
- otherPublicKey: NodeJS.ArrayBufferView,
1610
- inputEncoding?: null,
1611
- outputEncoding?: null,
1612
- ): NonSharedBuffer;
1613
- computeSecret(
1614
- otherPublicKey: string,
1615
- inputEncoding: BinaryToTextEncoding,
1616
- outputEncoding?: null,
1496
+ otherPublicKey: BinaryLike,
1497
+ inputEncoding?: BufferEncoding,
1617
1498
  ): NonSharedBuffer;
1618
1499
  computeSecret(
1619
- otherPublicKey: NodeJS.ArrayBufferView,
1620
- inputEncoding: null,
1621
- outputEncoding: BinaryToTextEncoding,
1622
- ): string;
1623
- computeSecret(
1624
- otherPublicKey: string,
1625
- inputEncoding: BinaryToTextEncoding,
1626
- outputEncoding: BinaryToTextEncoding,
1500
+ otherPublicKey: BinaryLike,
1501
+ inputEncoding: BufferEncoding | null | undefined,
1502
+ outputEncoding: BufferEncoding,
1627
1503
  ): string;
1628
1504
  /**
1629
1505
  * Returns the Diffie-Hellman prime in the specified `encoding`.
@@ -1633,7 +1509,7 @@ declare module "crypto" {
1633
1509
  * @param encoding The `encoding` of the return value.
1634
1510
  */
1635
1511
  getPrime(): NonSharedBuffer;
1636
- getPrime(encoding: BinaryToTextEncoding): string;
1512
+ getPrime(encoding: BufferEncoding): string;
1637
1513
  /**
1638
1514
  * Returns the Diffie-Hellman generator in the specified `encoding`.
1639
1515
  * If `encoding` is provided a string is
@@ -1642,7 +1518,7 @@ declare module "crypto" {
1642
1518
  * @param encoding The `encoding` of the return value.
1643
1519
  */
1644
1520
  getGenerator(): NonSharedBuffer;
1645
- getGenerator(encoding: BinaryToTextEncoding): string;
1521
+ getGenerator(encoding: BufferEncoding): string;
1646
1522
  /**
1647
1523
  * Returns the Diffie-Hellman public key in the specified `encoding`.
1648
1524
  * If `encoding` is provided a
@@ -1651,7 +1527,7 @@ declare module "crypto" {
1651
1527
  * @param encoding The `encoding` of the return value.
1652
1528
  */
1653
1529
  getPublicKey(): NonSharedBuffer;
1654
- getPublicKey(encoding: BinaryToTextEncoding): string;
1530
+ getPublicKey(encoding: BufferEncoding): string;
1655
1531
  /**
1656
1532
  * Returns the Diffie-Hellman private key in the specified `encoding`.
1657
1533
  * If `encoding` is provided a
@@ -1660,7 +1536,7 @@ declare module "crypto" {
1660
1536
  * @param encoding The `encoding` of the return value.
1661
1537
  */
1662
1538
  getPrivateKey(): NonSharedBuffer;
1663
- getPrivateKey(encoding: BinaryToTextEncoding): string;
1539
+ getPrivateKey(encoding: BufferEncoding): string;
1664
1540
  /**
1665
1541
  * Sets the Diffie-Hellman public key. If the `encoding` argument is provided, `publicKey` is expected
1666
1542
  * to be a string. If no `encoding` is provided, `publicKey` is expected
@@ -1668,8 +1544,7 @@ declare module "crypto" {
1668
1544
  * @since v0.5.0
1669
1545
  * @param encoding The `encoding` of the `publicKey` string.
1670
1546
  */
1671
- setPublicKey(publicKey: NodeJS.ArrayBufferView): void;
1672
- setPublicKey(publicKey: string, encoding: BufferEncoding): void;
1547
+ setPublicKey(publicKey: BinaryLike, encoding?: BufferEncoding): void;
1673
1548
  /**
1674
1549
  * Sets the Diffie-Hellman private key. If the `encoding` argument is provided,`privateKey` is expected
1675
1550
  * to be a string. If no `encoding` is provided, `privateKey` is expected
@@ -1680,8 +1555,7 @@ declare module "crypto" {
1680
1555
  * @since v0.5.0
1681
1556
  * @param encoding The `encoding` of the `privateKey` string.
1682
1557
  */
1683
- setPrivateKey(privateKey: NodeJS.ArrayBufferView): void;
1684
- setPrivateKey(privateKey: string, encoding: BufferEncoding): void;
1558
+ setPrivateKey(privateKey: BinaryLike, encoding?: BufferEncoding): void;
1685
1559
  /**
1686
1560
  * A bit field containing any warnings and/or errors resulting from a check
1687
1561
  * performed during initialization of the `DiffieHellman` object.
@@ -1719,13 +1593,10 @@ declare module "crypto" {
1719
1593
  * ```
1720
1594
  * @since v0.7.5
1721
1595
  */
1722
- const DiffieHellmanGroup: DiffieHellmanGroupConstructor;
1723
- interface DiffieHellmanGroupConstructor {
1724
- new(name: string): DiffieHellmanGroup;
1725
- (name: string): DiffieHellmanGroup;
1726
- readonly prototype: DiffieHellmanGroup;
1596
+ class DiffieHellmanGroup {
1597
+ private constructor();
1727
1598
  }
1728
- type DiffieHellmanGroup = Omit<DiffieHellman, "setPublicKey" | "setPrivateKey">;
1599
+ interface DiffieHellmanGroup extends Omit<DiffieHellman, "setPublicKey" | "setPrivateKey"> {}
1729
1600
  /**
1730
1601
  * Creates a predefined `DiffieHellmanGroup` key exchange object. The
1731
1602
  * supported groups are listed in the documentation for `DiffieHellmanGroup`.
@@ -1939,9 +1810,8 @@ declare module "crypto" {
1939
1810
  * console.log(`The dice rolled: ${n}`);
1940
1811
  * ```
1941
1812
  * @since v14.10.0, v12.19.0
1942
- * @param [min=0] Start of random range (inclusive).
1813
+ * @param min Start of random range (inclusive).
1943
1814
  * @param max End of random range (exclusive).
1944
- * @param callback `function(err, n) {}`.
1945
1815
  */
1946
1816
  function randomInt(max: number): number;
1947
1817
  function randomInt(min: number, max: number): number;
@@ -1988,7 +1858,11 @@ declare module "crypto" {
1988
1858
  * @param [size=buffer.length - offset]
1989
1859
  * @return The object passed as `buffer` argument.
1990
1860
  */
1991
- function randomFillSync<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number, size?: number): T;
1861
+ function randomFillSync<T extends ArrayBufferLike | NodeJS.ArrayBufferView>(
1862
+ buffer: T,
1863
+ offset?: number,
1864
+ size?: number,
1865
+ ): T;
1992
1866
  /**
1993
1867
  * This function is similar to {@link randomBytes} but requires the first
1994
1868
  * argument to be a `Buffer` that will be filled. It also
@@ -2064,16 +1938,16 @@ declare module "crypto" {
2064
1938
  * @param [size=buffer.length - offset]
2065
1939
  * @param callback `function(err, buf) {}`.
2066
1940
  */
2067
- function randomFill<T extends NodeJS.ArrayBufferView>(
1941
+ function randomFill<T extends ArrayBufferLike | NodeJS.ArrayBufferView>(
2068
1942
  buffer: T,
2069
1943
  callback: (err: Error | null, buf: T) => void,
2070
1944
  ): void;
2071
- function randomFill<T extends NodeJS.ArrayBufferView>(
1945
+ function randomFill<T extends ArrayBufferLike | NodeJS.ArrayBufferView>(
2072
1946
  buffer: T,
2073
1947
  offset: number,
2074
1948
  callback: (err: Error | null, buf: T) => void,
2075
1949
  ): void;
2076
- function randomFill<T extends NodeJS.ArrayBufferView>(
1950
+ function randomFill<T extends ArrayBufferLike | NodeJS.ArrayBufferView>(
2077
1951
  buffer: T,
2078
1952
  offset: number,
2079
1953
  size: number,
@@ -2171,19 +2045,25 @@ declare module "crypto" {
2171
2045
  keylen: number,
2172
2046
  options?: ScryptOptions,
2173
2047
  ): NonSharedBuffer;
2174
- interface RsaPublicKey {
2175
- key: KeyLike;
2048
+ interface PublicDecryptOptions {
2176
2049
  padding?: number | undefined;
2050
+ encoding?: BufferEncoding | undefined;
2177
2051
  }
2178
- interface RsaPrivateKey {
2179
- key: KeyLike;
2180
- passphrase?: string | undefined;
2181
- /**
2182
- * @default 'sha1'
2183
- */
2052
+ interface PublicDecryptPrivateKeyInput extends PrivateKeyInput, PublicDecryptOptions {}
2053
+ interface PublicDecryptPublicKeyInput extends PublicKeyInput, PublicDecryptOptions {}
2054
+ interface PublicDecryptJsonWebKeyInput extends JsonWebKeyInput, PublicDecryptOptions {}
2055
+ interface PublicDecryptKeyObjectInput extends PublicDecryptOptions {
2056
+ key: KeyObject;
2057
+ }
2058
+ interface PublicEncryptOptions extends PublicDecryptOptions {
2184
2059
  oaepHash?: string | undefined;
2185
- oaepLabel?: NodeJS.TypedArray | undefined;
2186
- padding?: number | undefined;
2060
+ oaepLabel?: BinaryLike | undefined;
2061
+ }
2062
+ interface PublicEncryptPrivateKeyInput extends PrivateKeyInput, PublicEncryptOptions {}
2063
+ interface PublicEncryptPublicKeyInput extends PublicKeyInput, PublicEncryptOptions {}
2064
+ interface PublicEncryptJsonWebKeyInput extends JsonWebKeyInput, PublicEncryptOptions {}
2065
+ interface PublicEncryptKeyObjectInput extends PublicEncryptOptions {
2066
+ key: KeyObject;
2187
2067
  }
2188
2068
  /**
2189
2069
  * Encrypts the content of `buffer` with `key` and returns a new `Buffer` with encrypted content. The returned data can be decrypted using
@@ -2197,8 +2077,13 @@ declare module "crypto" {
2197
2077
  * @since v0.11.14
2198
2078
  */
2199
2079
  function publicEncrypt(
2200
- key: RsaPublicKey | RsaPrivateKey | KeyLike,
2201
- buffer: NodeJS.ArrayBufferView | string,
2080
+ key:
2081
+ | KeyLike
2082
+ | PublicEncryptKeyObjectInput
2083
+ | PublicEncryptPrivateKeyInput
2084
+ | PublicEncryptPublicKeyInput
2085
+ | PublicEncryptJsonWebKeyInput,
2086
+ buffer: BinaryLike,
2202
2087
  ): NonSharedBuffer;
2203
2088
  /**
2204
2089
  * Decrypts `buffer` with `key`.`buffer` was previously encrypted using
@@ -2212,8 +2097,13 @@ declare module "crypto" {
2212
2097
  * @since v1.1.0
2213
2098
  */
2214
2099
  function publicDecrypt(
2215
- key: RsaPublicKey | RsaPrivateKey | KeyLike,
2216
- buffer: NodeJS.ArrayBufferView | string,
2100
+ key:
2101
+ | KeyLike
2102
+ | PublicDecryptKeyObjectInput
2103
+ | PublicDecryptPrivateKeyInput
2104
+ | PublicDecryptPublicKeyInput
2105
+ | PublicDecryptJsonWebKeyInput,
2106
+ buffer: BinaryLike,
2217
2107
  ): NonSharedBuffer;
2218
2108
  /**
2219
2109
  * Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
@@ -2224,8 +2114,12 @@ declare module "crypto" {
2224
2114
  * @since v0.11.14
2225
2115
  */
2226
2116
  function privateDecrypt(
2227
- privateKey: RsaPrivateKey | KeyLike,
2228
- buffer: NodeJS.ArrayBufferView | string,
2117
+ privateKey:
2118
+ | KeyLike
2119
+ | PublicEncryptKeyObjectInput
2120
+ | PublicEncryptPrivateKeyInput
2121
+ | PublicEncryptJsonWebKeyInput,
2122
+ buffer: BinaryLike,
2229
2123
  ): NonSharedBuffer;
2230
2124
  /**
2231
2125
  * Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
@@ -2236,8 +2130,12 @@ declare module "crypto" {
2236
2130
  * @since v1.1.0
2237
2131
  */
2238
2132
  function privateEncrypt(
2239
- privateKey: RsaPrivateKey | KeyLike,
2240
- buffer: NodeJS.ArrayBufferView | string,
2133
+ privateKey:
2134
+ | KeyLike
2135
+ | PublicDecryptKeyObjectInput
2136
+ | PublicDecryptPrivateKeyInput
2137
+ | PublicDecryptJsonWebKeyInput,
2138
+ buffer: BinaryLike,
2241
2139
  ): NonSharedBuffer;
2242
2140
  /**
2243
2141
  * ```js
@@ -2287,6 +2185,7 @@ declare module "crypto" {
2287
2185
  * @return An array of the names of the supported hash algorithms, such as `'RSA-SHA256'`. Hash algorithms are also called "digest" algorithms.
2288
2186
  */
2289
2187
  function getHashes(): string[];
2188
+ type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
2290
2189
  /**
2291
2190
  * The `ECDH` class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH)
2292
2191
  * key exchanges.
@@ -2359,15 +2258,21 @@ declare module "crypto" {
2359
2258
  * @since v10.0.0
2360
2259
  * @param inputEncoding The `encoding` of the `key` string.
2361
2260
  * @param outputEncoding The `encoding` of the return value.
2362
- * @param [format='uncompressed']
2363
2261
  */
2364
2262
  static convertKey(
2365
2263
  key: BinaryLike,
2366
2264
  curve: string,
2367
- inputEncoding?: BinaryToTextEncoding,
2368
- outputEncoding?: "latin1" | "hex" | "base64" | "base64url",
2265
+ inputEncoding?: BufferEncoding,
2266
+ outputEncoding?: null,
2267
+ format?: "uncompressed" | "compressed" | "hybrid",
2268
+ ): NonSharedBuffer;
2269
+ static convertKey(
2270
+ key: BinaryLike,
2271
+ curve: string,
2272
+ inputEncoding: BufferEncoding | null | undefined,
2273
+ outputEncoding: BufferEncoding,
2369
2274
  format?: "uncompressed" | "compressed" | "hybrid",
2370
- ): NonSharedBuffer | string;
2275
+ ): string;
2371
2276
  /**
2372
2277
  * Generates private and public EC Diffie-Hellman key values, and returns
2373
2278
  * the public key in the specified `format` and `encoding`. This key should be
@@ -2380,8 +2285,8 @@ declare module "crypto" {
2380
2285
  * @param encoding The `encoding` of the return value.
2381
2286
  * @param [format='uncompressed']
2382
2287
  */
2383
- generateKeys(): NonSharedBuffer;
2384
- generateKeys(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
2288
+ generateKeys(encoding?: null, format?: ECDHKeyFormat): NonSharedBuffer;
2289
+ generateKeys(encoding: BufferEncoding, format?: ECDHKeyFormat): string;
2385
2290
  /**
2386
2291
  * Computes the shared secret using `otherPublicKey` as the other
2387
2292
  * party's public key and returns the computed shared secret. The supplied
@@ -2399,13 +2304,11 @@ declare module "crypto" {
2399
2304
  * @param inputEncoding The `encoding` of the `otherPublicKey` string.
2400
2305
  * @param outputEncoding The `encoding` of the return value.
2401
2306
  */
2402
- computeSecret(otherPublicKey: NodeJS.ArrayBufferView): NonSharedBuffer;
2403
- computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): NonSharedBuffer;
2404
- computeSecret(otherPublicKey: NodeJS.ArrayBufferView, outputEncoding: BinaryToTextEncoding): string;
2307
+ computeSecret(otherPublicKey: BinaryLike, inputEncoding?: BufferEncoding): NonSharedBuffer;
2405
2308
  computeSecret(
2406
- otherPublicKey: string,
2407
- inputEncoding: BinaryToTextEncoding,
2408
- outputEncoding: BinaryToTextEncoding,
2309
+ otherPublicKey: BinaryLike,
2310
+ inputEncoding: BufferEncoding | null | undefined,
2311
+ outputEncoding: BufferEncoding,
2409
2312
  ): string;
2410
2313
  /**
2411
2314
  * If `encoding` is specified, a string is returned; otherwise a `Buffer` is
@@ -2415,7 +2318,7 @@ declare module "crypto" {
2415
2318
  * @return The EC Diffie-Hellman in the specified `encoding`.
2416
2319
  */
2417
2320
  getPrivateKey(): NonSharedBuffer;
2418
- getPrivateKey(encoding: BinaryToTextEncoding): string;
2321
+ getPrivateKey(encoding: BufferEncoding): string;
2419
2322
  /**
2420
2323
  * The `format` argument specifies point encoding and can be `'compressed'` or `'uncompressed'`. If `format` is not specified the point will be returned in`'uncompressed'` format.
2421
2324
  *
@@ -2427,7 +2330,7 @@ declare module "crypto" {
2427
2330
  * @return The EC Diffie-Hellman public key in the specified `encoding` and `format`.
2428
2331
  */
2429
2332
  getPublicKey(encoding?: null, format?: ECDHKeyFormat): NonSharedBuffer;
2430
- getPublicKey(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
2333
+ getPublicKey(encoding: BufferEncoding, format?: ECDHKeyFormat): string;
2431
2334
  /**
2432
2335
  * Sets the EC Diffie-Hellman private key.
2433
2336
  * If `encoding` is provided, `privateKey` is expected
@@ -2439,8 +2342,7 @@ declare module "crypto" {
2439
2342
  * @since v0.11.14
2440
2343
  * @param encoding The `encoding` of the `privateKey` string.
2441
2344
  */
2442
- setPrivateKey(privateKey: NodeJS.ArrayBufferView): void;
2443
- setPrivateKey(privateKey: string, encoding: BinaryToTextEncoding): void;
2345
+ setPrivateKey(privateKey: BinaryLike, encoding?: BufferEncoding): void;
2444
2346
  }
2445
2347
  /**
2446
2348
  * Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a
@@ -2475,193 +2377,45 @@ declare module "crypto" {
2475
2377
  * not introduce timing vulnerabilities.
2476
2378
  * @since v6.6.0
2477
2379
  */
2478
- function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
2479
- type KeyType = "rsa" | "rsa-pss" | "dsa" | "ec" | "ed25519" | "ed448" | "x25519" | "x448";
2480
- type KeyFormat = "pem" | "der" | "jwk";
2481
- interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
2482
- format: T;
2483
- cipher?: string | undefined;
2484
- passphrase?: string | undefined;
2380
+ function timingSafeEqual(
2381
+ a: ArrayBufferLike | NodeJS.ArrayBufferView,
2382
+ b: ArrayBufferLike | NodeJS.ArrayBufferView,
2383
+ ): boolean;
2384
+ interface DHKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
2385
+ prime?: NodeJS.ArrayBufferView | undefined;
2386
+ primeLength?: number | undefined;
2387
+ generator?: number | undefined;
2388
+ groupName?: string | undefined;
2485
2389
  }
2486
- interface KeyPairKeyObjectResult {
2487
- publicKey: KeyObject;
2488
- privateKey: KeyObject;
2390
+ interface DSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
2391
+ modulusLength: number;
2392
+ divisorLength?: number | undefined;
2489
2393
  }
2490
- interface ED25519KeyPairKeyObjectOptions {}
2491
- interface ED448KeyPairKeyObjectOptions {}
2492
- interface X25519KeyPairKeyObjectOptions {}
2493
- interface X448KeyPairKeyObjectOptions {}
2494
- interface ECKeyPairKeyObjectOptions {
2495
- /**
2496
- * Name of the curve to use
2497
- */
2394
+ interface ECKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8" | "sec1"> {
2498
2395
  namedCurve: string;
2499
- /**
2500
- * Must be `'named'` or `'explicit'`. Default: `'named'`.
2501
- */
2502
2396
  paramEncoding?: "explicit" | "named" | undefined;
2503
2397
  }
2504
- interface RSAKeyPairKeyObjectOptions {
2505
- /**
2506
- * Key size in bits
2507
- */
2508
- modulusLength: number;
2509
- /**
2510
- * Public exponent
2511
- * @default 0x10001
2512
- */
2513
- publicExponent?: number | undefined;
2514
- }
2515
- interface RSAPSSKeyPairKeyObjectOptions {
2516
- /**
2517
- * Key size in bits
2518
- */
2398
+ interface ED25519KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
2399
+ interface ED448KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
2400
+ interface MLDSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
2401
+ interface MLKEMKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
2402
+ interface RSAPSSKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
2519
2403
  modulusLength: number;
2520
- /**
2521
- * Public exponent
2522
- * @default 0x10001
2523
- */
2524
2404
  publicExponent?: number | undefined;
2525
- /**
2526
- * Name of the message digest
2527
- */
2528
2405
  hashAlgorithm?: string | undefined;
2529
- /**
2530
- * Name of the message digest used by MGF1
2531
- */
2532
2406
  mgf1HashAlgorithm?: string | undefined;
2533
- /**
2534
- * Minimal salt length in bytes
2535
- */
2536
2407
  saltLength?: string | undefined;
2537
2408
  }
2538
- interface DSAKeyPairKeyObjectOptions {
2539
- /**
2540
- * Key size in bits
2541
- */
2542
- modulusLength: number;
2543
- /**
2544
- * Size of q in bits
2545
- */
2546
- divisorLength: number;
2547
- }
2548
- interface RSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2549
- /**
2550
- * Key size in bits
2551
- */
2409
+ interface RSAKeyPairOptions extends KeyPairExportOptions<"pkcs1" | "spki", "pkcs1" | "pkcs8"> {
2552
2410
  modulusLength: number;
2553
- /**
2554
- * Public exponent
2555
- * @default 0x10001
2556
- */
2557
- publicExponent?: number | undefined;
2558
- publicKeyEncoding: {
2559
- type: "pkcs1" | "spki";
2560
- format: PubF;
2561
- };
2562
- privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2563
- type: "pkcs1" | "pkcs8";
2564
- };
2565
- }
2566
- interface RSAPSSKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2567
- /**
2568
- * Key size in bits
2569
- */
2570
- modulusLength: number;
2571
- /**
2572
- * Public exponent
2573
- * @default 0x10001
2574
- */
2575
2411
  publicExponent?: number | undefined;
2576
- /**
2577
- * Name of the message digest
2578
- */
2579
- hashAlgorithm?: string | undefined;
2580
- /**
2581
- * Name of the message digest used by MGF1
2582
- */
2583
- mgf1HashAlgorithm?: string | undefined;
2584
- /**
2585
- * Minimal salt length in bytes
2586
- */
2587
- saltLength?: string | undefined;
2588
- publicKeyEncoding: {
2589
- type: "spki";
2590
- format: PubF;
2591
- };
2592
- privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2593
- type: "pkcs8";
2594
- };
2595
- }
2596
- interface DSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2597
- /**
2598
- * Key size in bits
2599
- */
2600
- modulusLength: number;
2601
- /**
2602
- * Size of q in bits
2603
- */
2604
- divisorLength: number;
2605
- publicKeyEncoding: {
2606
- type: "spki";
2607
- format: PubF;
2608
- };
2609
- privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2610
- type: "pkcs8";
2611
- };
2612
- }
2613
- interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> extends ECKeyPairKeyObjectOptions {
2614
- publicKeyEncoding: {
2615
- type: "pkcs1" | "spki";
2616
- format: PubF;
2617
- };
2618
- privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2619
- type: "sec1" | "pkcs8";
2620
- };
2621
- }
2622
- interface ED25519KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2623
- publicKeyEncoding: {
2624
- type: "spki";
2625
- format: PubF;
2626
- };
2627
- privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2628
- type: "pkcs8";
2629
- };
2630
- }
2631
- interface ED448KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2632
- publicKeyEncoding: {
2633
- type: "spki";
2634
- format: PubF;
2635
- };
2636
- privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2637
- type: "pkcs8";
2638
- };
2639
- }
2640
- interface X25519KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2641
- publicKeyEncoding: {
2642
- type: "spki";
2643
- format: PubF;
2644
- };
2645
- privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2646
- type: "pkcs8";
2647
- };
2648
- }
2649
- interface X448KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2650
- publicKeyEncoding: {
2651
- type: "spki";
2652
- format: PubF;
2653
- };
2654
- privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2655
- type: "pkcs8";
2656
- };
2657
- }
2658
- interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
2659
- publicKey: T1;
2660
- privateKey: T2;
2661
2412
  }
2413
+ interface SLHDSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
2414
+ interface X25519KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
2415
+ interface X448KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
2662
2416
  /**
2663
- * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
2664
- * Ed25519, Ed448, X25519, X448, and DH are currently supported.
2417
+ * Generates a new asymmetric key pair of the given `type`. See the
2418
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
2665
2419
  *
2666
2420
  * If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
2667
2421
  * behaves as if `keyObject.export()` had been called on its result. Otherwise,
@@ -2698,147 +2452,60 @@ declare module "crypto" {
2698
2452
  * When PEM encoding was selected, the respective key will be a string, otherwise
2699
2453
  * it will be a buffer containing the data encoded as DER.
2700
2454
  * @since v10.12.0
2701
- * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`.
2702
- */
2703
- function generateKeyPairSync(
2704
- type: "rsa",
2705
- options: RSAKeyPairOptions<"pem", "pem">,
2706
- ): KeyPairSyncResult<string, string>;
2707
- function generateKeyPairSync(
2708
- type: "rsa",
2709
- options: RSAKeyPairOptions<"pem", "der">,
2710
- ): KeyPairSyncResult<string, NonSharedBuffer>;
2711
- function generateKeyPairSync(
2712
- type: "rsa",
2713
- options: RSAKeyPairOptions<"der", "pem">,
2714
- ): KeyPairSyncResult<NonSharedBuffer, string>;
2715
- function generateKeyPairSync(
2716
- type: "rsa",
2717
- options: RSAKeyPairOptions<"der", "der">,
2718
- ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2719
- function generateKeyPairSync(type: "rsa", options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2720
- function generateKeyPairSync(
2721
- type: "rsa-pss",
2722
- options: RSAPSSKeyPairOptions<"pem", "pem">,
2723
- ): KeyPairSyncResult<string, string>;
2724
- function generateKeyPairSync(
2725
- type: "rsa-pss",
2726
- options: RSAPSSKeyPairOptions<"pem", "der">,
2727
- ): KeyPairSyncResult<string, NonSharedBuffer>;
2728
- function generateKeyPairSync(
2729
- type: "rsa-pss",
2730
- options: RSAPSSKeyPairOptions<"der", "pem">,
2731
- ): KeyPairSyncResult<NonSharedBuffer, string>;
2732
- function generateKeyPairSync(
2733
- type: "rsa-pss",
2734
- options: RSAPSSKeyPairOptions<"der", "der">,
2735
- ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2736
- function generateKeyPairSync(type: "rsa-pss", options: RSAPSSKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2737
- function generateKeyPairSync(
2738
- type: "dsa",
2739
- options: DSAKeyPairOptions<"pem", "pem">,
2740
- ): KeyPairSyncResult<string, string>;
2741
- function generateKeyPairSync(
2455
+ * @param type The asymmetric key type to generate. See the
2456
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
2457
+ */
2458
+ function generateKeyPairSync<T extends DHKeyPairOptions>(
2459
+ type: "dh",
2460
+ options: T,
2461
+ ): KeyPairExportResult<T>;
2462
+ function generateKeyPairSync<T extends DSAKeyPairOptions>(
2742
2463
  type: "dsa",
2743
- options: DSAKeyPairOptions<"pem", "der">,
2744
- ): KeyPairSyncResult<string, NonSharedBuffer>;
2745
- function generateKeyPairSync(
2746
- type: "dsa",
2747
- options: DSAKeyPairOptions<"der", "pem">,
2748
- ): KeyPairSyncResult<NonSharedBuffer, string>;
2749
- function generateKeyPairSync(
2750
- type: "dsa",
2751
- options: DSAKeyPairOptions<"der", "der">,
2752
- ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2753
- function generateKeyPairSync(type: "dsa", options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2754
- function generateKeyPairSync(
2755
- type: "ec",
2756
- options: ECKeyPairOptions<"pem", "pem">,
2757
- ): KeyPairSyncResult<string, string>;
2758
- function generateKeyPairSync(
2759
- type: "ec",
2760
- options: ECKeyPairOptions<"pem", "der">,
2761
- ): KeyPairSyncResult<string, NonSharedBuffer>;
2762
- function generateKeyPairSync(
2464
+ options: T,
2465
+ ): KeyPairExportResult<T>;
2466
+ function generateKeyPairSync<T extends ECKeyPairOptions>(
2763
2467
  type: "ec",
2764
- options: ECKeyPairOptions<"der", "pem">,
2765
- ): KeyPairSyncResult<NonSharedBuffer, string>;
2766
- function generateKeyPairSync(
2767
- type: "ec",
2768
- options: ECKeyPairOptions<"der", "der">,
2769
- ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2770
- function generateKeyPairSync(type: "ec", options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2771
- function generateKeyPairSync(
2772
- type: "ed25519",
2773
- options: ED25519KeyPairOptions<"pem", "pem">,
2774
- ): KeyPairSyncResult<string, string>;
2775
- function generateKeyPairSync(
2776
- type: "ed25519",
2777
- options: ED25519KeyPairOptions<"pem", "der">,
2778
- ): KeyPairSyncResult<string, NonSharedBuffer>;
2779
- function generateKeyPairSync(
2468
+ options: T,
2469
+ ): KeyPairExportResult<T>;
2470
+ function generateKeyPairSync<T extends ED25519KeyPairOptions = {}>(
2780
2471
  type: "ed25519",
2781
- options: ED25519KeyPairOptions<"der", "pem">,
2782
- ): KeyPairSyncResult<NonSharedBuffer, string>;
2783
- function generateKeyPairSync(
2784
- type: "ed25519",
2785
- options: ED25519KeyPairOptions<"der", "der">,
2786
- ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2787
- function generateKeyPairSync(type: "ed25519", options?: ED25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2788
- function generateKeyPairSync(
2789
- type: "ed448",
2790
- options: ED448KeyPairOptions<"pem", "pem">,
2791
- ): KeyPairSyncResult<string, string>;
2792
- function generateKeyPairSync(
2793
- type: "ed448",
2794
- options: ED448KeyPairOptions<"pem", "der">,
2795
- ): KeyPairSyncResult<string, NonSharedBuffer>;
2796
- function generateKeyPairSync(
2472
+ options?: T,
2473
+ ): KeyPairExportResult<T>;
2474
+ function generateKeyPairSync<T extends ED448KeyPairOptions = {}>(
2797
2475
  type: "ed448",
2798
- options: ED448KeyPairOptions<"der", "pem">,
2799
- ): KeyPairSyncResult<NonSharedBuffer, string>;
2800
- function generateKeyPairSync(
2801
- type: "ed448",
2802
- options: ED448KeyPairOptions<"der", "der">,
2803
- ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2804
- function generateKeyPairSync(type: "ed448", options?: ED448KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2805
- function generateKeyPairSync(
2806
- type: "x25519",
2807
- options: X25519KeyPairOptions<"pem", "pem">,
2808
- ): KeyPairSyncResult<string, string>;
2809
- function generateKeyPairSync(
2810
- type: "x25519",
2811
- options: X25519KeyPairOptions<"pem", "der">,
2812
- ): KeyPairSyncResult<string, NonSharedBuffer>;
2813
- function generateKeyPairSync(
2814
- type: "x25519",
2815
- options: X25519KeyPairOptions<"der", "pem">,
2816
- ): KeyPairSyncResult<NonSharedBuffer, string>;
2817
- function generateKeyPairSync(
2476
+ options?: T,
2477
+ ): KeyPairExportResult<T>;
2478
+ function generateKeyPairSync<T extends MLDSAKeyPairOptions = {}>(
2479
+ type: MLDSAKeyType,
2480
+ options?: T,
2481
+ ): KeyPairExportResult<T>;
2482
+ function generateKeyPairSync<T extends MLKEMKeyPairOptions = {}>(
2483
+ type: MLKEMKeyType,
2484
+ options?: T,
2485
+ ): KeyPairExportResult<T>;
2486
+ function generateKeyPairSync<T extends RSAPSSKeyPairOptions>(
2487
+ type: "rsa-pss",
2488
+ options: T,
2489
+ ): KeyPairExportResult<T>;
2490
+ function generateKeyPairSync<T extends RSAKeyPairOptions>(
2491
+ type: "rsa",
2492
+ options: T,
2493
+ ): KeyPairExportResult<T>;
2494
+ function generateKeyPairSync<T extends SLHDSAKeyPairOptions = {}>(
2495
+ type: SLHDSAKeyType,
2496
+ options?: T,
2497
+ ): KeyPairExportResult<T>;
2498
+ function generateKeyPairSync<T extends X25519KeyPairOptions = {}>(
2818
2499
  type: "x25519",
2819
- options: X25519KeyPairOptions<"der", "der">,
2820
- ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2821
- function generateKeyPairSync(type: "x25519", options?: X25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2822
- function generateKeyPairSync(
2823
- type: "x448",
2824
- options: X448KeyPairOptions<"pem", "pem">,
2825
- ): KeyPairSyncResult<string, string>;
2826
- function generateKeyPairSync(
2827
- type: "x448",
2828
- options: X448KeyPairOptions<"pem", "der">,
2829
- ): KeyPairSyncResult<string, NonSharedBuffer>;
2830
- function generateKeyPairSync(
2831
- type: "x448",
2832
- options: X448KeyPairOptions<"der", "pem">,
2833
- ): KeyPairSyncResult<NonSharedBuffer, string>;
2834
- function generateKeyPairSync(
2500
+ options?: T,
2501
+ ): KeyPairExportResult<T>;
2502
+ function generateKeyPairSync<T extends X448KeyPairOptions = {}>(
2835
2503
  type: "x448",
2836
- options: X448KeyPairOptions<"der", "der">,
2837
- ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2838
- function generateKeyPairSync(type: "x448", options?: X448KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2504
+ options?: T,
2505
+ ): KeyPairExportResult<T>;
2839
2506
  /**
2840
- * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
2841
- * Ed25519, Ed448, X25519, X448, and DH are currently supported.
2507
+ * Generates a new asymmetric key pair of the given `type`. See the
2508
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
2842
2509
  *
2843
2510
  * If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
2844
2511
  * behaves as if `keyObject.export()` had been called on its result. Otherwise,
@@ -2873,455 +2540,154 @@ declare module "crypto" {
2873
2540
  * If this method is invoked as its `util.promisify()` ed version, it returns
2874
2541
  * a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
2875
2542
  * @since v10.12.0
2876
- * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`.
2543
+ * @param type The asymmetric key type to generate. See the
2544
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
2877
2545
  */
2878
- function generateKeyPair(
2879
- type: "rsa",
2880
- options: RSAKeyPairOptions<"pem", "pem">,
2881
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
2882
- ): void;
2883
- function generateKeyPair(
2884
- type: "rsa",
2885
- options: RSAKeyPairOptions<"pem", "der">,
2886
- callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2887
- ): void;
2888
- function generateKeyPair(
2889
- type: "rsa",
2890
- options: RSAKeyPairOptions<"der", "pem">,
2891
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2892
- ): void;
2893
- function generateKeyPair(
2894
- type: "rsa",
2895
- options: RSAKeyPairOptions<"der", "der">,
2896
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2897
- ): void;
2898
- function generateKeyPair(
2899
- type: "rsa",
2900
- options: RSAKeyPairKeyObjectOptions,
2901
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
2902
- ): void;
2903
- function generateKeyPair(
2904
- type: "rsa-pss",
2905
- options: RSAPSSKeyPairOptions<"pem", "pem">,
2906
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
2907
- ): void;
2908
- function generateKeyPair(
2909
- type: "rsa-pss",
2910
- options: RSAPSSKeyPairOptions<"pem", "der">,
2911
- callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2912
- ): void;
2913
- function generateKeyPair(
2914
- type: "rsa-pss",
2915
- options: RSAPSSKeyPairOptions<"der", "pem">,
2916
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2917
- ): void;
2918
- function generateKeyPair(
2919
- type: "rsa-pss",
2920
- options: RSAPSSKeyPairOptions<"der", "der">,
2921
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2922
- ): void;
2923
- function generateKeyPair(
2924
- type: "rsa-pss",
2925
- options: RSAPSSKeyPairKeyObjectOptions,
2926
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
2927
- ): void;
2928
- function generateKeyPair(
2929
- type: "dsa",
2930
- options: DSAKeyPairOptions<"pem", "pem">,
2931
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
2546
+ function generateKeyPair<T extends DHKeyPairOptions>(
2547
+ type: "dh",
2548
+ options: T,
2549
+ callback: KeyPairExportCallback<T>,
2932
2550
  ): void;
2933
- function generateKeyPair(
2551
+ function generateKeyPair<T extends DSAKeyPairOptions>(
2934
2552
  type: "dsa",
2935
- options: DSAKeyPairOptions<"pem", "der">,
2936
- callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2553
+ options: T,
2554
+ callback: KeyPairExportCallback<T>,
2937
2555
  ): void;
2938
- function generateKeyPair(
2939
- type: "dsa",
2940
- options: DSAKeyPairOptions<"der", "pem">,
2941
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2942
- ): void;
2943
- function generateKeyPair(
2944
- type: "dsa",
2945
- options: DSAKeyPairOptions<"der", "der">,
2946
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2947
- ): void;
2948
- function generateKeyPair(
2949
- type: "dsa",
2950
- options: DSAKeyPairKeyObjectOptions,
2951
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
2952
- ): void;
2953
- function generateKeyPair(
2954
- type: "ec",
2955
- options: ECKeyPairOptions<"pem", "pem">,
2956
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
2957
- ): void;
2958
- function generateKeyPair(
2959
- type: "ec",
2960
- options: ECKeyPairOptions<"pem", "der">,
2961
- callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2962
- ): void;
2963
- function generateKeyPair(
2964
- type: "ec",
2965
- options: ECKeyPairOptions<"der", "pem">,
2966
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2967
- ): void;
2968
- function generateKeyPair(
2969
- type: "ec",
2970
- options: ECKeyPairOptions<"der", "der">,
2971
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2972
- ): void;
2973
- function generateKeyPair(
2556
+ function generateKeyPair<T extends ECKeyPairOptions>(
2974
2557
  type: "ec",
2975
- options: ECKeyPairKeyObjectOptions,
2976
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
2558
+ options: T,
2559
+ callback: KeyPairExportCallback<T>,
2977
2560
  ): void;
2978
2561
  function generateKeyPair(
2979
2562
  type: "ed25519",
2980
- options: ED25519KeyPairOptions<"pem", "pem">,
2981
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
2563
+ callback: KeyPairExportCallback,
2982
2564
  ): void;
2983
- function generateKeyPair(
2984
- type: "ed25519",
2985
- options: ED25519KeyPairOptions<"pem", "der">,
2986
- callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2987
- ): void;
2988
- function generateKeyPair(
2989
- type: "ed25519",
2990
- options: ED25519KeyPairOptions<"der", "pem">,
2991
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2992
- ): void;
2993
- function generateKeyPair(
2994
- type: "ed25519",
2995
- options: ED25519KeyPairOptions<"der", "der">,
2996
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2997
- ): void;
2998
- function generateKeyPair(
2565
+ function generateKeyPair<T extends ED25519KeyPairOptions = {}>(
2999
2566
  type: "ed25519",
3000
- options: ED25519KeyPairKeyObjectOptions | undefined,
3001
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
3002
- ): void;
3003
- function generateKeyPair(
3004
- type: "ed448",
3005
- options: ED448KeyPairOptions<"pem", "pem">,
3006
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
2567
+ options: T | undefined,
2568
+ callback: KeyPairExportCallback<T>,
3007
2569
  ): void;
3008
2570
  function generateKeyPair(
3009
2571
  type: "ed448",
3010
- options: ED448KeyPairOptions<"pem", "der">,
3011
- callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2572
+ callback: KeyPairExportCallback,
3012
2573
  ): void;
3013
- function generateKeyPair(
2574
+ function generateKeyPair<T extends ED448KeyPairOptions = {}>(
3014
2575
  type: "ed448",
3015
- options: ED448KeyPairOptions<"der", "pem">,
3016
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2576
+ options: T | undefined,
2577
+ callback: KeyPairExportCallback<T>,
3017
2578
  ): void;
3018
2579
  function generateKeyPair(
3019
- type: "ed448",
3020
- options: ED448KeyPairOptions<"der", "der">,
3021
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2580
+ type: MLDSAKeyType,
2581
+ callback: KeyPairExportCallback,
3022
2582
  ): void;
3023
- function generateKeyPair(
3024
- type: "ed448",
3025
- options: ED448KeyPairKeyObjectOptions | undefined,
3026
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
2583
+ function generateKeyPair<T extends MLDSAKeyPairOptions = {}>(
2584
+ type: MLDSAKeyType,
2585
+ options: T | undefined,
2586
+ callback: KeyPairExportCallback<T>,
3027
2587
  ): void;
3028
2588
  function generateKeyPair(
3029
- type: "x25519",
3030
- options: X25519KeyPairOptions<"pem", "pem">,
3031
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
2589
+ type: MLKEMKeyType,
2590
+ callback: KeyPairExportCallback,
3032
2591
  ): void;
3033
- function generateKeyPair(
3034
- type: "x25519",
3035
- options: X25519KeyPairOptions<"pem", "der">,
3036
- callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2592
+ function generateKeyPair<T extends MLKEMKeyPairOptions = {}>(
2593
+ type: MLKEMKeyType,
2594
+ options: T | undefined,
2595
+ callback: KeyPairExportCallback<T>,
3037
2596
  ): void;
3038
- function generateKeyPair(
3039
- type: "x25519",
3040
- options: X25519KeyPairOptions<"der", "pem">,
3041
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2597
+ function generateKeyPair<T extends RSAPSSKeyPairOptions>(
2598
+ type: "rsa-pss",
2599
+ options: T,
2600
+ callback: KeyPairExportCallback<T>,
3042
2601
  ): void;
3043
- function generateKeyPair(
3044
- type: "x25519",
3045
- options: X25519KeyPairOptions<"der", "der">,
3046
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2602
+ function generateKeyPair<T extends RSAKeyPairOptions>(
2603
+ type: "rsa",
2604
+ options: T,
2605
+ callback: KeyPairExportCallback<T>,
3047
2606
  ): void;
3048
2607
  function generateKeyPair(
3049
- type: "x25519",
3050
- options: X25519KeyPairKeyObjectOptions | undefined,
3051
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
2608
+ type: SLHDSAKeyType,
2609
+ callback: KeyPairExportCallback,
3052
2610
  ): void;
3053
- function generateKeyPair(
3054
- type: "x448",
3055
- options: X448KeyPairOptions<"pem", "pem">,
3056
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
2611
+ function generateKeyPair<T extends SLHDSAKeyPairOptions = {}>(
2612
+ type: SLHDSAKeyType,
2613
+ options: T | undefined,
2614
+ callback: KeyPairExportCallback<T>,
3057
2615
  ): void;
3058
2616
  function generateKeyPair(
3059
- type: "x448",
3060
- options: X448KeyPairOptions<"pem", "der">,
3061
- callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2617
+ type: "x25519",
2618
+ callback: KeyPairExportCallback,
3062
2619
  ): void;
3063
- function generateKeyPair(
3064
- type: "x448",
3065
- options: X448KeyPairOptions<"der", "pem">,
3066
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2620
+ function generateKeyPair<T extends X25519KeyPairOptions = {}>(
2621
+ type: "x25519",
2622
+ options: T | undefined,
2623
+ callback: KeyPairExportCallback<T>,
3067
2624
  ): void;
3068
2625
  function generateKeyPair(
3069
2626
  type: "x448",
3070
- options: X448KeyPairOptions<"der", "der">,
3071
- callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2627
+ callback: KeyPairExportCallback,
3072
2628
  ): void;
3073
- function generateKeyPair(
2629
+ function generateKeyPair<T extends X448KeyPairOptions = {}>(
3074
2630
  type: "x448",
3075
- options: X448KeyPairKeyObjectOptions | undefined,
3076
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
2631
+ options: T | undefined,
2632
+ callback: KeyPairExportCallback<T>,
3077
2633
  ): void;
3078
2634
  namespace generateKeyPair {
3079
- function __promisify__(
3080
- type: "rsa",
3081
- options: RSAKeyPairOptions<"pem", "pem">,
3082
- ): Promise<{
3083
- publicKey: string;
3084
- privateKey: string;
3085
- }>;
3086
- function __promisify__(
3087
- type: "rsa",
3088
- options: RSAKeyPairOptions<"pem", "der">,
3089
- ): Promise<{
3090
- publicKey: string;
3091
- privateKey: NonSharedBuffer;
3092
- }>;
3093
- function __promisify__(
3094
- type: "rsa",
3095
- options: RSAKeyPairOptions<"der", "pem">,
3096
- ): Promise<{
3097
- publicKey: NonSharedBuffer;
3098
- privateKey: string;
3099
- }>;
3100
- function __promisify__(
3101
- type: "rsa",
3102
- options: RSAKeyPairOptions<"der", "der">,
3103
- ): Promise<{
3104
- publicKey: NonSharedBuffer;
3105
- privateKey: NonSharedBuffer;
3106
- }>;
3107
- function __promisify__(type: "rsa", options: RSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
3108
- function __promisify__(
3109
- type: "rsa-pss",
3110
- options: RSAPSSKeyPairOptions<"pem", "pem">,
3111
- ): Promise<{
3112
- publicKey: string;
3113
- privateKey: string;
3114
- }>;
3115
- function __promisify__(
3116
- type: "rsa-pss",
3117
- options: RSAPSSKeyPairOptions<"pem", "der">,
3118
- ): Promise<{
3119
- publicKey: string;
3120
- privateKey: NonSharedBuffer;
3121
- }>;
3122
- function __promisify__(
3123
- type: "rsa-pss",
3124
- options: RSAPSSKeyPairOptions<"der", "pem">,
3125
- ): Promise<{
3126
- publicKey: NonSharedBuffer;
3127
- privateKey: string;
3128
- }>;
3129
- function __promisify__(
3130
- type: "rsa-pss",
3131
- options: RSAPSSKeyPairOptions<"der", "der">,
3132
- ): Promise<{
3133
- publicKey: NonSharedBuffer;
3134
- privateKey: NonSharedBuffer;
3135
- }>;
3136
- function __promisify__(
3137
- type: "rsa-pss",
3138
- options: RSAPSSKeyPairKeyObjectOptions,
3139
- ): Promise<KeyPairKeyObjectResult>;
3140
- function __promisify__(
3141
- type: "dsa",
3142
- options: DSAKeyPairOptions<"pem", "pem">,
3143
- ): Promise<{
3144
- publicKey: string;
3145
- privateKey: string;
3146
- }>;
3147
- function __promisify__(
3148
- type: "dsa",
3149
- options: DSAKeyPairOptions<"pem", "der">,
3150
- ): Promise<{
3151
- publicKey: string;
3152
- privateKey: NonSharedBuffer;
3153
- }>;
3154
- function __promisify__(
2635
+ function __promisify__<T extends DHKeyPairOptions>(
2636
+ type: "dh",
2637
+ options: T,
2638
+ ): Promise<KeyPairExportResult<T>>;
2639
+ function __promisify__<T extends DSAKeyPairOptions>(
3155
2640
  type: "dsa",
3156
- options: DSAKeyPairOptions<"der", "pem">,
3157
- ): Promise<{
3158
- publicKey: NonSharedBuffer;
3159
- privateKey: string;
3160
- }>;
3161
- function __promisify__(
3162
- type: "dsa",
3163
- options: DSAKeyPairOptions<"der", "der">,
3164
- ): Promise<{
3165
- publicKey: NonSharedBuffer;
3166
- privateKey: NonSharedBuffer;
3167
- }>;
3168
- function __promisify__(type: "dsa", options: DSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
3169
- function __promisify__(
3170
- type: "ec",
3171
- options: ECKeyPairOptions<"pem", "pem">,
3172
- ): Promise<{
3173
- publicKey: string;
3174
- privateKey: string;
3175
- }>;
3176
- function __promisify__(
3177
- type: "ec",
3178
- options: ECKeyPairOptions<"pem", "der">,
3179
- ): Promise<{
3180
- publicKey: string;
3181
- privateKey: NonSharedBuffer;
3182
- }>;
3183
- function __promisify__(
2641
+ options: T,
2642
+ ): Promise<KeyPairExportResult<T>>;
2643
+ function __promisify__<T extends ECKeyPairOptions>(
3184
2644
  type: "ec",
3185
- options: ECKeyPairOptions<"der", "pem">,
3186
- ): Promise<{
3187
- publicKey: NonSharedBuffer;
3188
- privateKey: string;
3189
- }>;
3190
- function __promisify__(
3191
- type: "ec",
3192
- options: ECKeyPairOptions<"der", "der">,
3193
- ): Promise<{
3194
- publicKey: NonSharedBuffer;
3195
- privateKey: NonSharedBuffer;
3196
- }>;
3197
- function __promisify__(type: "ec", options: ECKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
3198
- function __promisify__(
3199
- type: "ed25519",
3200
- options: ED25519KeyPairOptions<"pem", "pem">,
3201
- ): Promise<{
3202
- publicKey: string;
3203
- privateKey: string;
3204
- }>;
3205
- function __promisify__(
3206
- type: "ed25519",
3207
- options: ED25519KeyPairOptions<"pem", "der">,
3208
- ): Promise<{
3209
- publicKey: string;
3210
- privateKey: NonSharedBuffer;
3211
- }>;
3212
- function __promisify__(
2645
+ options: T,
2646
+ ): Promise<KeyPairExportResult<T>>;
2647
+ function __promisify__<T extends ED25519KeyPairOptions = {}>(
3213
2648
  type: "ed25519",
3214
- options: ED25519KeyPairOptions<"der", "pem">,
3215
- ): Promise<{
3216
- publicKey: NonSharedBuffer;
3217
- privateKey: string;
3218
- }>;
3219
- function __promisify__(
3220
- type: "ed25519",
3221
- options: ED25519KeyPairOptions<"der", "der">,
3222
- ): Promise<{
3223
- publicKey: NonSharedBuffer;
3224
- privateKey: NonSharedBuffer;
3225
- }>;
3226
- function __promisify__(
3227
- type: "ed25519",
3228
- options?: ED25519KeyPairKeyObjectOptions,
3229
- ): Promise<KeyPairKeyObjectResult>;
3230
- function __promisify__(
3231
- type: "ed448",
3232
- options: ED448KeyPairOptions<"pem", "pem">,
3233
- ): Promise<{
3234
- publicKey: string;
3235
- privateKey: string;
3236
- }>;
3237
- function __promisify__(
2649
+ options?: T,
2650
+ ): Promise<KeyPairExportResult<T>>;
2651
+ function __promisify__<T extends ED448KeyPairOptions = {}>(
3238
2652
  type: "ed448",
3239
- options: ED448KeyPairOptions<"pem", "der">,
3240
- ): Promise<{
3241
- publicKey: string;
3242
- privateKey: NonSharedBuffer;
3243
- }>;
3244
- function __promisify__(
3245
- type: "ed448",
3246
- options: ED448KeyPairOptions<"der", "pem">,
3247
- ): Promise<{
3248
- publicKey: NonSharedBuffer;
3249
- privateKey: string;
3250
- }>;
3251
- function __promisify__(
3252
- type: "ed448",
3253
- options: ED448KeyPairOptions<"der", "der">,
3254
- ): Promise<{
3255
- publicKey: NonSharedBuffer;
3256
- privateKey: NonSharedBuffer;
3257
- }>;
3258
- function __promisify__(type: "ed448", options?: ED448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
3259
- function __promisify__(
3260
- type: "x25519",
3261
- options: X25519KeyPairOptions<"pem", "pem">,
3262
- ): Promise<{
3263
- publicKey: string;
3264
- privateKey: string;
3265
- }>;
3266
- function __promisify__(
3267
- type: "x25519",
3268
- options: X25519KeyPairOptions<"pem", "der">,
3269
- ): Promise<{
3270
- publicKey: string;
3271
- privateKey: NonSharedBuffer;
3272
- }>;
3273
- function __promisify__(
3274
- type: "x25519",
3275
- options: X25519KeyPairOptions<"der", "pem">,
3276
- ): Promise<{
3277
- publicKey: NonSharedBuffer;
3278
- privateKey: string;
3279
- }>;
3280
- function __promisify__(
3281
- type: "x25519",
3282
- options: X25519KeyPairOptions<"der", "der">,
3283
- ): Promise<{
3284
- publicKey: NonSharedBuffer;
3285
- privateKey: NonSharedBuffer;
3286
- }>;
3287
- function __promisify__(
2653
+ options?: T,
2654
+ ): Promise<KeyPairExportResult<T>>;
2655
+ function __promisify__<T extends MLDSAKeyPairOptions = {}>(
2656
+ type: MLDSAKeyType,
2657
+ options?: T,
2658
+ ): Promise<KeyPairExportResult<T>>;
2659
+ function __promisify__<T extends MLKEMKeyPairOptions = {}>(
2660
+ type: MLKEMKeyType,
2661
+ options?: T,
2662
+ ): Promise<KeyPairExportResult<T>>;
2663
+ function __promisify__<T extends RSAPSSKeyPairOptions>(
2664
+ type: "rsa-pss",
2665
+ options: T,
2666
+ ): Promise<KeyPairExportResult<T>>;
2667
+ function __promisify__<T extends RSAKeyPairOptions>(
2668
+ type: "rsa",
2669
+ options: T,
2670
+ ): Promise<KeyPairExportResult<T>>;
2671
+ function __promisify__<T extends SLHDSAKeyPairOptions = {}>(
2672
+ type: SLHDSAKeyType,
2673
+ options?: T,
2674
+ ): Promise<KeyPairExportResult<T>>;
2675
+ function __promisify__<T extends X25519KeyPairOptions = {}>(
3288
2676
  type: "x25519",
3289
- options?: X25519KeyPairKeyObjectOptions,
3290
- ): Promise<KeyPairKeyObjectResult>;
3291
- function __promisify__(
3292
- type: "x448",
3293
- options: X448KeyPairOptions<"pem", "pem">,
3294
- ): Promise<{
3295
- publicKey: string;
3296
- privateKey: string;
3297
- }>;
3298
- function __promisify__(
2677
+ options?: T,
2678
+ ): Promise<KeyPairExportResult<T>>;
2679
+ function __promisify__<T extends X448KeyPairOptions = {}>(
3299
2680
  type: "x448",
3300
- options: X448KeyPairOptions<"pem", "der">,
3301
- ): Promise<{
3302
- publicKey: string;
3303
- privateKey: NonSharedBuffer;
3304
- }>;
3305
- function __promisify__(
3306
- type: "x448",
3307
- options: X448KeyPairOptions<"der", "pem">,
3308
- ): Promise<{
3309
- publicKey: NonSharedBuffer;
3310
- privateKey: string;
3311
- }>;
3312
- function __promisify__(
3313
- type: "x448",
3314
- options: X448KeyPairOptions<"der", "der">,
3315
- ): Promise<{
3316
- publicKey: NonSharedBuffer;
3317
- privateKey: NonSharedBuffer;
3318
- }>;
3319
- function __promisify__(type: "x448", options?: X448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
2681
+ options?: T,
2682
+ ): Promise<KeyPairExportResult<T>>;
3320
2683
  }
3321
2684
  /**
3322
2685
  * Calculates and returns the signature for `data` using the given private key and
3323
2686
  * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
3324
- * dependent upon the key type (especially Ed25519 and Ed448).
2687
+ * dependent upon the key type.
2688
+ *
2689
+ * `algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and
2690
+ * ML-DSA.
3325
2691
  *
3326
2692
  * If `key` is not a `KeyObject`, this function behaves as if `key` had been
3327
2693
  * passed to {@link createPrivateKey}. If it is an object, the following
@@ -3332,18 +2698,22 @@ declare module "crypto" {
3332
2698
  */
3333
2699
  function sign(
3334
2700
  algorithm: string | null | undefined,
3335
- data: NodeJS.ArrayBufferView,
2701
+ data: BinaryLike,
3336
2702
  key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
3337
2703
  ): NonSharedBuffer;
3338
2704
  function sign(
3339
2705
  algorithm: string | null | undefined,
3340
- data: NodeJS.ArrayBufferView,
2706
+ data: BinaryLike,
3341
2707
  key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
3342
2708
  callback: (error: Error | null, data: NonSharedBuffer) => void,
3343
2709
  ): void;
3344
2710
  /**
3345
- * Verifies the given signature for `data` using the given key and algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is dependent upon the
3346
- * key type (especially Ed25519 and Ed448).
2711
+ * Verifies the given signature for `data` using the given key and algorithm. If
2712
+ * `algorithm` is `null` or `undefined`, then the algorithm is dependent upon the
2713
+ * key type.
2714
+ *
2715
+ * `algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and
2716
+ * ML-DSA.
3347
2717
  *
3348
2718
  * If `key` is not a `KeyObject`, this function behaves as if `key` had been
3349
2719
  * passed to {@link createPublicKey}. If it is an object, the following
@@ -3359,28 +2729,118 @@ declare module "crypto" {
3359
2729
  */
3360
2730
  function verify(
3361
2731
  algorithm: string | null | undefined,
3362
- data: NodeJS.ArrayBufferView,
2732
+ data: BinaryLike,
3363
2733
  key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
3364
- signature: NodeJS.ArrayBufferView,
2734
+ signature: BinaryLike,
3365
2735
  ): boolean;
3366
2736
  function verify(
3367
2737
  algorithm: string | null | undefined,
3368
- data: NodeJS.ArrayBufferView,
2738
+ data: BinaryLike,
3369
2739
  key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
3370
- signature: NodeJS.ArrayBufferView,
2740
+ signature: BinaryLike,
3371
2741
  callback: (error: Error | null, result: boolean) => void,
3372
2742
  ): void;
3373
2743
  /**
3374
- * Computes the Diffie-Hellman secret based on a `privateKey` and a `publicKey`.
3375
- * Both keys must have the same `asymmetricKeyType`, which must be one of `'dh'` (for Diffie-Hellman), `'ec'` (for ECDH), `'x448'`, or `'x25519'` (for ECDH-ES).
2744
+ * Key decapsulation using a KEM algorithm with a private key.
2745
+ *
2746
+ * Supported key types and their KEM algorithms are:
2747
+ *
2748
+ * * `'rsa'` RSA Secret Value Encapsulation
2749
+ * * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
2750
+ * * `'x25519'` DHKEM(X25519, HKDF-SHA256)
2751
+ * * `'x448'` DHKEM(X448, HKDF-SHA512)
2752
+ * * `'ml-kem-512'` ML-KEM
2753
+ * * `'ml-kem-768'` ML-KEM
2754
+ * * `'ml-kem-1024'` ML-KEM
2755
+ *
2756
+ * If `key` is not a {@link KeyObject}, this function behaves as if `key` had been
2757
+ * passed to `crypto.createPrivateKey()`.
2758
+ *
2759
+ * If the `callback` function is provided this function uses libuv's threadpool.
2760
+ * @since v24.7.0
2761
+ */
2762
+ function decapsulate(
2763
+ key: KeyLike | PrivateKeyInput | RawPrivateKeyInput | JsonWebKeyInput,
2764
+ ciphertext: ArrayBufferLike | NodeJS.ArrayBufferView,
2765
+ ): NonSharedBuffer;
2766
+ function decapsulate(
2767
+ key: KeyLike | PrivateKeyInput | RawPrivateKeyInput | JsonWebKeyInput,
2768
+ ciphertext: ArrayBufferLike | NodeJS.ArrayBufferView,
2769
+ callback: (err: Error, sharedKey: NonSharedBuffer) => void,
2770
+ ): void;
2771
+ interface DiffieHellmanOptions {
2772
+ privateKey: KeyLike | PrivateKeyInput;
2773
+ publicKey: KeyLike | PublicKeyInput;
2774
+ }
2775
+ /**
2776
+ * Computes the Diffie-Hellman shared secret based on a `privateKey` and a `publicKey`.
2777
+ * Both keys must have the same `asymmetricKeyType` and must support either the DH or
2778
+ * ECDH operation.
2779
+ *
2780
+ * If the `callback` function is provided this function uses libuv's threadpool.
3376
2781
  * @since v13.9.0, v12.17.0
3377
2782
  */
3378
- function diffieHellman(options: { privateKey: KeyObject; publicKey: KeyObject }): NonSharedBuffer;
2783
+ function diffieHellman(options: DiffieHellmanOptions): NonSharedBuffer;
2784
+ function diffieHellman(
2785
+ options: DiffieHellmanOptions,
2786
+ callback: (err: Error | null, secret: NonSharedBuffer) => void,
2787
+ ): void;
3379
2788
  /**
3380
- * A utility for creating one-shot hash digests of data. It can be faster than the object-based `crypto.createHash()` when hashing a smaller amount of data
3381
- * (<= 5MB) that's readily available. If the data can be big or if it is streamed, it's still recommended to use `crypto.createHash()` instead. The `algorithm`
3382
- * is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc. On recent releases
3383
- * of OpenSSL, `openssl list -digest-algorithms` will display the available digest algorithms.
2789
+ * Key encapsulation using a KEM algorithm with a public key.
2790
+ *
2791
+ * Supported key types and their KEM algorithms are:
2792
+ *
2793
+ * * `'rsa'` RSA Secret Value Encapsulation
2794
+ * * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
2795
+ * * `'x25519'` DHKEM(X25519, HKDF-SHA256)
2796
+ * * `'x448'` DHKEM(X448, HKDF-SHA512)
2797
+ * * `'ml-kem-512'` ML-KEM
2798
+ * * `'ml-kem-768'` ML-KEM
2799
+ * * `'ml-kem-1024'` ML-KEM
2800
+ *
2801
+ * If `key` is not a {@link KeyObject}, this function behaves as if `key` had been
2802
+ * passed to `crypto.createPublicKey()`.
2803
+ *
2804
+ * If the `callback` function is provided this function uses libuv's threadpool.
2805
+ * @since v24.7.0
2806
+ */
2807
+ function encapsulate(
2808
+ key: KeyLike | PublicKeyInput | RawPublicKeyInput | JsonWebKeyInput,
2809
+ ): { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer };
2810
+ function encapsulate(
2811
+ key: KeyLike | PublicKeyInput | RawPublicKeyInput | JsonWebKeyInput,
2812
+ callback: (err: Error, result: { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer }) => void,
2813
+ ): void;
2814
+ interface OneShotDigestOptions {
2815
+ /**
2816
+ * Encoding used to encode the returned digest.
2817
+ * @default 'hex'
2818
+ */
2819
+ outputEncoding?: BufferEncoding | "buffer" | undefined;
2820
+ /**
2821
+ * For XOF hash functions such as 'shake256', the outputLength option
2822
+ * can be used to specify the desired output length in bytes.
2823
+ */
2824
+ outputLength?: number | undefined;
2825
+ }
2826
+ interface OneShotDigestOptionsWithStringEncoding extends OneShotDigestOptions {
2827
+ outputEncoding?: BufferEncoding | undefined;
2828
+ }
2829
+ interface OneShotDigestOptionsWithBufferEncoding extends OneShotDigestOptions {
2830
+ outputEncoding: "buffer";
2831
+ }
2832
+ /**
2833
+ * A utility for creating one-shot hash digests of data. It can be faster than
2834
+ * the object-based `crypto.createHash()` when hashing a smaller amount of data
2835
+ * (<= 5MB) that's readily available. If the data can be big or if it is streamed,
2836
+ * it's still recommended to use `crypto.createHash()` instead.
2837
+ *
2838
+ * The `algorithm` is dependent on the available algorithms supported by the
2839
+ * version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
2840
+ * On recent releases of OpenSSL, `openssl list -digest-algorithms` will
2841
+ * display the available digest algorithms.
2842
+ *
2843
+ * If `options` is a string, then it specifies the `outputEncoding`.
3384
2844
  *
3385
2845
  * Example:
3386
2846
  *
@@ -3400,16 +2860,25 @@ declare module "crypto" {
3400
2860
  * console.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));
3401
2861
  * ```
3402
2862
  * @since v21.7.0, v20.12.0
3403
- * @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different input encoding is desired for a string input, user
3404
- * could encode the string into a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing the encoded `TypedArray` into this API instead.
3405
- * @param [outputEncoding='hex'] [Encoding](https://nodejs.org/docs/latest-v22.x/api/buffer.html#buffers-and-character-encodings) used to encode the returned digest.
2863
+ * @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different
2864
+ * input encoding is desired for a string input, user could encode the string
2865
+ * into a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing
2866
+ * the encoded `TypedArray` into this API instead.
3406
2867
  */
3407
- function hash(algorithm: string, data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
3408
- function hash(algorithm: string, data: BinaryLike, outputEncoding: "buffer"): NonSharedBuffer;
3409
2868
  function hash(
3410
2869
  algorithm: string,
3411
2870
  data: BinaryLike,
3412
- outputEncoding?: BinaryToTextEncoding | "buffer",
2871
+ options?: OneShotDigestOptionsWithStringEncoding | BufferEncoding,
2872
+ ): string;
2873
+ function hash(
2874
+ algorithm: string,
2875
+ data: BinaryLike,
2876
+ options: OneShotDigestOptionsWithBufferEncoding | "buffer",
2877
+ ): NonSharedBuffer;
2878
+ function hash(
2879
+ algorithm: string,
2880
+ data: BinaryLike,
2881
+ options: OneShotDigestOptions | BufferEncoding | "buffer",
3413
2882
  ): string | NonSharedBuffer;
3414
2883
  type CipherMode = "cbc" | "ccm" | "cfb" | "ctr" | "ecb" | "gcm" | "ocb" | "ofb" | "stream" | "wrap" | "xts";
3415
2884
  interface CipherInfoOptions {
@@ -3423,31 +2892,11 @@ declare module "crypto" {
3423
2892
  ivLength?: number | undefined;
3424
2893
  }
3425
2894
  interface CipherInfo {
3426
- /**
3427
- * The name of the cipher.
3428
- */
3429
2895
  name: string;
3430
- /**
3431
- * The nid of the cipher.
3432
- */
3433
2896
  nid: number;
3434
- /**
3435
- * The block size of the cipher in bytes.
3436
- * This property is omitted when mode is 'stream'.
3437
- */
3438
- blockSize?: number | undefined;
3439
- /**
3440
- * The expected or default initialization vector length in bytes.
3441
- * This property is omitted if the cipher does not use an initialization vector.
3442
- */
3443
- ivLength?: number | undefined;
3444
- /**
3445
- * The expected or default key length in bytes.
3446
- */
2897
+ blockSize?: number;
2898
+ ivLength?: number;
3447
2899
  keyLength: number;
3448
- /**
3449
- * The cipher mode.
3450
- */
3451
2900
  mode: CipherMode;
3452
2901
  }
3453
2902
  /**
@@ -3491,7 +2940,7 @@ declare module "crypto" {
3491
2940
  */
3492
2941
  function hkdf(
3493
2942
  digest: string,
3494
- irm: BinaryLike | KeyObject,
2943
+ ikm: KeyLike,
3495
2944
  salt: BinaryLike,
3496
2945
  info: BinaryLike,
3497
2946
  keylen: number,
@@ -3525,27 +2974,15 @@ declare module "crypto" {
3525
2974
  */
3526
2975
  function hkdfSync(
3527
2976
  digest: string,
3528
- ikm: BinaryLike | KeyObject,
2977
+ ikm: KeyLike,
3529
2978
  salt: BinaryLike,
3530
2979
  info: BinaryLike,
3531
2980
  keylen: number,
3532
2981
  ): ArrayBuffer;
3533
2982
  interface SecureHeapUsage {
3534
- /**
3535
- * The total allocated secure heap size as specified using the `--secure-heap=n` command-line flag.
3536
- */
3537
2983
  total: number;
3538
- /**
3539
- * The minimum allocation from the secure heap as specified using the `--secure-heap-min` command-line flag.
3540
- */
3541
2984
  min: number;
3542
- /**
3543
- * The total number of bytes currently allocated from the secure heap.
3544
- */
3545
2985
  used: number;
3546
- /**
3547
- * The calculated ratio of `used` to `total` allocated bytes.
3548
- */
3549
2986
  utilization: number;
3550
2987
  }
3551
2988
  /**
@@ -3558,11 +2995,11 @@ declare module "crypto" {
3558
2995
  * Node.js will pre-emptively generate and persistently cache enough
3559
2996
  * random data to generate up to 128 random UUIDs. To generate a UUID
3560
2997
  * without using the cache, set `disableEntropyCache` to `true`.
3561
- *
3562
2998
  * @default `false`
3563
2999
  */
3564
3000
  disableEntropyCache?: boolean | undefined;
3565
3001
  }
3002
+ interface RandomUUIDV7Options extends RandomUUIDOptions {}
3566
3003
  type UUID = `${string}-${string}-${string}-${string}-${string}`;
3567
3004
  /**
3568
3005
  * Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a
@@ -3570,26 +3007,21 @@ declare module "crypto" {
3570
3007
  * @since v15.6.0, v14.17.0
3571
3008
  */
3572
3009
  function randomUUID(options?: RandomUUIDOptions): UUID;
3010
+ /**
3011
+ * Generates a random [RFC 9562](https://www.rfc-editor.org/rfc/rfc9562.txt) version 7 UUID. The UUID contains a millisecond
3012
+ * precision Unix timestamp in the most significant 48 bits, followed by
3013
+ * cryptographically secure random bits for the remaining fields, making it
3014
+ * suitable for use as a database key with time-based sorting. The embedded
3015
+ * timestamp relies on a non-monotonic clock and is not guaranteed to be strictly
3016
+ * increasing.
3017
+ * @since v26.1.0
3018
+ */
3019
+ function randomUUIDv7(options?: RandomUUIDV7Options): UUID;
3573
3020
  interface X509CheckOptions {
3574
- /**
3575
- * @default 'always'
3576
- */
3577
3021
  subject?: "always" | "default" | "never" | undefined;
3578
- /**
3579
- * @default true
3580
- */
3581
3022
  wildcards?: boolean | undefined;
3582
- /**
3583
- * @default true
3584
- */
3585
3023
  partialWildcards?: boolean | undefined;
3586
- /**
3587
- * @default false
3588
- */
3589
3024
  multiLabelWildcards?: boolean | undefined;
3590
- /**
3591
- * @default false
3592
- */
3593
3025
  singleLabelSubdomains?: boolean | undefined;
3594
3026
  }
3595
3027
  /**
@@ -3712,6 +3144,16 @@ declare module "crypto" {
3712
3144
  * @since v15.6.0
3713
3145
  */
3714
3146
  readonly serialNumber: string;
3147
+ /**
3148
+ * The algorithm used to sign the certificate or `undefined` if the signature algorithm is unknown by OpenSSL.
3149
+ * @since v24.9.0
3150
+ */
3151
+ readonly signatureAlgorithm: string | undefined;
3152
+ /**
3153
+ * The OID of the algorithm used to sign the certificate.
3154
+ * @since v24.9.0
3155
+ */
3156
+ readonly signatureAlgorithmOid: string;
3715
3157
  /**
3716
3158
  * The date/time from which this certificate is considered valid.
3717
3159
  * @since v15.6.0
@@ -3732,7 +3174,7 @@ declare module "crypto" {
3732
3174
  * @since v22.10.0
3733
3175
  */
3734
3176
  readonly validToDate: Date;
3735
- constructor(buffer: BinaryLike);
3177
+ constructor(buffer: string | NodeJS.ArrayBufferView);
3736
3178
  /**
3737
3179
  * Checks whether the certificate matches the given email address.
3738
3180
  *
@@ -3835,13 +3277,10 @@ declare module "crypto" {
3835
3277
  */
3836
3278
  verify(publicKey: KeyObject): boolean;
3837
3279
  }
3838
- type LargeNumberLike = NodeJS.ArrayBufferView | SharedArrayBuffer | ArrayBuffer | bigint;
3280
+ type LargeNumberLike = ArrayBufferLike | NodeJS.ArrayBufferView | bigint;
3839
3281
  interface GeneratePrimeOptions {
3840
3282
  add?: LargeNumberLike | undefined;
3841
3283
  rem?: LargeNumberLike | undefined;
3842
- /**
3843
- * @default false
3844
- */
3845
3284
  safe?: boolean | undefined;
3846
3285
  bigint?: boolean | undefined;
3847
3286
  }
@@ -3881,13 +3320,13 @@ declare module "crypto" {
3881
3320
  function generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
3882
3321
  function generatePrime(
3883
3322
  size: number,
3884
- options: GeneratePrimeOptionsBigInt,
3885
- callback: (err: Error | null, prime: bigint) => void,
3323
+ options: GeneratePrimeOptionsArrayBuffer,
3324
+ callback: (err: Error | null, prime: ArrayBuffer) => void,
3886
3325
  ): void;
3887
3326
  function generatePrime(
3888
3327
  size: number,
3889
- options: GeneratePrimeOptionsArrayBuffer,
3890
- callback: (err: Error | null, prime: ArrayBuffer) => void,
3328
+ options: GeneratePrimeOptionsBigInt,
3329
+ callback: (err: Error | null, prime: bigint) => void,
3891
3330
  ): void;
3892
3331
  function generatePrime(
3893
3332
  size: number,
@@ -3922,8 +3361,8 @@ declare module "crypto" {
3922
3361
  * @param size The size (in bits) of the prime to generate.
3923
3362
  */
3924
3363
  function generatePrimeSync(size: number): ArrayBuffer;
3925
- function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint;
3926
3364
  function generatePrimeSync(size: number, options: GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
3365
+ function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint;
3927
3366
  function generatePrimeSync(size: number, options: GeneratePrimeOptions): ArrayBuffer | bigint;
3928
3367
  interface CheckPrimeOptions {
3929
3368
  /**
@@ -3931,7 +3370,6 @@ declare module "crypto" {
3931
3370
  * When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most `2**-64` for random input.
3932
3371
  * Care must be used when selecting a number of checks.
3933
3372
  * Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details.
3934
- *
3935
3373
  * @default 0
3936
3374
  */
3937
3375
  checks?: number | undefined;
@@ -3983,7 +3421,101 @@ declare module "crypto" {
3983
3421
  * @since v17.4.0
3984
3422
  * @return Returns `typedArray`.
3985
3423
  */
3986
- function getRandomValues<T extends webcrypto.BufferSource>(typedArray: T): T;
3424
+ function getRandomValues<
3425
+ T extends Exclude<
3426
+ NodeJS.NonSharedTypedArray,
3427
+ NodeJS.NonSharedFloat16Array | NodeJS.NonSharedFloat32Array | NodeJS.NonSharedFloat64Array
3428
+ >,
3429
+ >(typedArray: T): T;
3430
+ type Argon2Algorithm = "argon2d" | "argon2i" | "argon2id";
3431
+ interface Argon2Parameters {
3432
+ message: BinaryLike;
3433
+ nonce: BinaryLike;
3434
+ parallelism: number;
3435
+ tagLength: number;
3436
+ memory: number;
3437
+ passes: number;
3438
+ secret?: BinaryLike | undefined;
3439
+ associatedData?: BinaryLike | undefined;
3440
+ }
3441
+ /**
3442
+ * Provides an asynchronous [Argon2](https://www.rfc-editor.org/rfc/rfc9106.html) implementation. Argon2 is a password-based
3443
+ * key derivation function that is designed to be expensive computationally and
3444
+ * memory-wise in order to make brute-force attacks unrewarding.
3445
+ *
3446
+ * The `nonce` should be as unique as possible. It is recommended that a nonce is
3447
+ * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
3448
+ *
3449
+ * When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
3450
+ * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v26.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
3451
+ *
3452
+ * The `callback` function is called with two arguments: `err` and `derivedKey`.
3453
+ * `err` is an exception object when key derivation fails, otherwise `err` is
3454
+ * `null`. `derivedKey` is passed to the callback as a `Buffer`.
3455
+ *
3456
+ * An exception is thrown when any of the input arguments specify invalid values
3457
+ * or types.
3458
+ *
3459
+ * ```js
3460
+ * const { argon2, randomBytes } = await import('node:crypto');
3461
+ *
3462
+ * const parameters = {
3463
+ * message: 'password',
3464
+ * nonce: randomBytes(16),
3465
+ * parallelism: 4,
3466
+ * tagLength: 64,
3467
+ * memory: 65536,
3468
+ * passes: 3,
3469
+ * };
3470
+ *
3471
+ * argon2('argon2id', parameters, (err, derivedKey) => {
3472
+ * if (err) throw err;
3473
+ * console.log(derivedKey.toString('hex')); // 'af91dad...9520f15'
3474
+ * });
3475
+ * ```
3476
+ * @since v24.7.0
3477
+ * @param algorithm Variant of Argon2, one of `"argon2d"`, `"argon2i"` or `"argon2id"`.
3478
+ */
3479
+ function argon2(
3480
+ algorithm: Argon2Algorithm,
3481
+ parameters: Argon2Parameters,
3482
+ callback: (err: Error | null, derivedKey: NonSharedBuffer) => void,
3483
+ ): void;
3484
+ /**
3485
+ * Provides a synchronous [Argon2][] implementation. Argon2 is a password-based
3486
+ * key derivation function that is designed to be expensive computationally and
3487
+ * memory-wise in order to make brute-force attacks unrewarding.
3488
+ *
3489
+ * The `nonce` should be as unique as possible. It is recommended that a nonce is
3490
+ * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
3491
+ *
3492
+ * When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
3493
+ * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v26.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
3494
+ *
3495
+ * An exception is thrown when key derivation fails, otherwise the derived key is
3496
+ * returned as a `Buffer`.
3497
+ *
3498
+ * An exception is thrown when any of the input arguments specify invalid values
3499
+ * or types.
3500
+ *
3501
+ * ```js
3502
+ * const { argon2Sync, randomBytes } = await import('node:crypto');
3503
+ *
3504
+ * const parameters = {
3505
+ * message: 'password',
3506
+ * nonce: randomBytes(16),
3507
+ * parallelism: 4,
3508
+ * tagLength: 64,
3509
+ * memory: 65536,
3510
+ * passes: 3,
3511
+ * };
3512
+ *
3513
+ * const derivedKey = argon2Sync('argon2id', parameters);
3514
+ * console.log(derivedKey.toString('hex')); // 'af91dad...9520f15'
3515
+ * ```
3516
+ * @since v24.7.0
3517
+ */
3518
+ function argon2Sync(algorithm: Argon2Algorithm, parameters: Argon2Parameters): NonSharedBuffer;
3987
3519
  /**
3988
3520
  * A convenient alias for `crypto.webcrypto.subtle`.
3989
3521
  * @since v17.4.0
@@ -3997,37 +3529,40 @@ declare module "crypto" {
3997
3529
  */
3998
3530
  const webcrypto: webcrypto.Crypto;
3999
3531
  namespace webcrypto {
4000
- type BufferSource = ArrayBufferView | ArrayBuffer;
4001
- type KeyFormat = "jwk" | "pkcs8" | "raw" | "spki";
3532
+ type AlgorithmIdentifier = Algorithm | string;
3533
+ type BigInteger = NodeJS.NonSharedUint8Array;
3534
+ type KeyFormat = "jwk" | "pkcs8" | "raw" | "raw-public" | "raw-secret" | "raw-seed" | "spki";
4002
3535
  type KeyType = "private" | "public" | "secret";
4003
3536
  type KeyUsage =
3537
+ | "decapsulateBits"
3538
+ | "decapsulateKey"
4004
3539
  | "decrypt"
4005
3540
  | "deriveBits"
4006
3541
  | "deriveKey"
3542
+ | "encapsulateBits"
3543
+ | "encapsulateKey"
4007
3544
  | "encrypt"
4008
3545
  | "sign"
4009
3546
  | "unwrapKey"
4010
3547
  | "verify"
4011
3548
  | "wrapKey";
4012
- type AlgorithmIdentifier = Algorithm | string;
4013
3549
  type HashAlgorithmIdentifier = AlgorithmIdentifier;
4014
3550
  type NamedCurve = string;
4015
- type BigInteger = Uint8Array;
3551
+ interface AeadParams extends Algorithm {
3552
+ additionalData?: NodeJS.BufferSource;
3553
+ iv: NodeJS.BufferSource;
3554
+ tagLength: number;
3555
+ }
4016
3556
  interface AesCbcParams extends Algorithm {
4017
- iv: BufferSource;
3557
+ iv: NodeJS.BufferSource;
4018
3558
  }
4019
3559
  interface AesCtrParams extends Algorithm {
4020
- counter: BufferSource;
3560
+ counter: NodeJS.BufferSource;
4021
3561
  length: number;
4022
3562
  }
4023
3563
  interface AesDerivedKeyParams extends Algorithm {
4024
3564
  length: number;
4025
3565
  }
4026
- interface AesGcmParams extends Algorithm {
4027
- additionalData?: BufferSource;
4028
- iv: BufferSource;
4029
- tagLength?: number;
4030
- }
4031
3566
  interface AesKeyAlgorithm extends KeyAlgorithm {
4032
3567
  length: number;
4033
3568
  }
@@ -4037,6 +3572,23 @@ declare module "crypto" {
4037
3572
  interface Algorithm {
4038
3573
  name: string;
4039
3574
  }
3575
+ interface Argon2Params extends Algorithm {
3576
+ associatedData?: NodeJS.BufferSource;
3577
+ memory: number;
3578
+ nonce: NodeJS.BufferSource;
3579
+ parallelism: number;
3580
+ passes: number;
3581
+ secretValue?: NodeJS.BufferSource;
3582
+ version?: number;
3583
+ }
3584
+ interface CShakeParams extends Algorithm {
3585
+ customization?: NodeJS.BufferSource;
3586
+ functionName?: NodeJS.BufferSource;
3587
+ outputLength: number;
3588
+ }
3589
+ interface ContextParams extends Algorithm {
3590
+ context?: NodeJS.BufferSource;
3591
+ }
4040
3592
  interface EcKeyAlgorithm extends KeyAlgorithm {
4041
3593
  namedCurve: NamedCurve;
4042
3594
  }
@@ -4052,13 +3604,10 @@ declare module "crypto" {
4052
3604
  interface EcdsaParams extends Algorithm {
4053
3605
  hash: HashAlgorithmIdentifier;
4054
3606
  }
4055
- interface Ed448Params extends Algorithm {
4056
- context?: BufferSource;
4057
- }
4058
3607
  interface HkdfParams extends Algorithm {
4059
3608
  hash: HashAlgorithmIdentifier;
4060
- info: BufferSource;
4061
- salt: BufferSource;
3609
+ info: NodeJS.BufferSource;
3610
+ salt: NodeJS.BufferSource;
4062
3611
  }
4063
3612
  interface HmacImportParams extends Algorithm {
4064
3613
  hash: HashAlgorithmIdentifier;
@@ -4072,6 +3621,10 @@ declare module "crypto" {
4072
3621
  hash: HashAlgorithmIdentifier;
4073
3622
  length?: number;
4074
3623
  }
3624
+ interface KangarooTwelveParams {
3625
+ customization?: NodeJS.BufferSource;
3626
+ outputLength: number;
3627
+ }
4075
3628
  interface JsonWebKey {
4076
3629
  alg?: string;
4077
3630
  crv?: string;
@@ -4095,10 +3648,23 @@ declare module "crypto" {
4095
3648
  interface KeyAlgorithm {
4096
3649
  name: string;
4097
3650
  }
3651
+ interface KmacImportParams extends Algorithm {
3652
+ length?: number;
3653
+ }
3654
+ interface KmacKeyAlgorithm extends KeyAlgorithm {
3655
+ length: number;
3656
+ }
3657
+ interface KmacKeyGenParams extends Algorithm {
3658
+ length?: number;
3659
+ }
3660
+ interface KmacParams extends Algorithm {
3661
+ customization?: NodeJS.BufferSource;
3662
+ outputLength: number;
3663
+ }
4098
3664
  interface Pbkdf2Params extends Algorithm {
4099
3665
  hash: HashAlgorithmIdentifier;
4100
3666
  iterations: number;
4101
- salt: BufferSource;
3667
+ salt: NodeJS.BufferSource;
4102
3668
  }
4103
3669
  interface RsaHashedImportParams extends Algorithm {
4104
3670
  hash: HashAlgorithmIdentifier;
@@ -4118,7 +3684,7 @@ declare module "crypto" {
4118
3684
  publicExponent: BigInteger;
4119
3685
  }
4120
3686
  interface RsaOaepParams extends Algorithm {
4121
- label?: BufferSource;
3687
+ label?: NodeJS.BufferSource;
4122
3688
  }
4123
3689
  interface RsaOtherPrimesInfo {
4124
3690
  d?: string;
@@ -4128,269 +3694,110 @@ declare module "crypto" {
4128
3694
  interface RsaPssParams extends Algorithm {
4129
3695
  saltLength: number;
4130
3696
  }
4131
- /**
4132
- * Importing the `webcrypto` object (`import { webcrypto } from 'node:crypto'`) gives an instance of the `Crypto` class.
4133
- * `Crypto` is a singleton that provides access to the remainder of the crypto API.
4134
- * @since v15.0.0
4135
- */
3697
+ interface TurboShakeParams {
3698
+ domainSeparation?: number;
3699
+ outputLength: number;
3700
+ }
4136
3701
  interface Crypto {
4137
- /**
4138
- * Provides access to the `SubtleCrypto` API.
4139
- * @since v15.0.0
4140
- */
4141
3702
  readonly subtle: SubtleCrypto;
4142
- /**
4143
- * Generates cryptographically strong random values.
4144
- * The given `typedArray` is filled with random values, and a reference to `typedArray` is returned.
4145
- *
4146
- * The given `typedArray` must be an integer-based instance of {@link NodeJS.TypedArray}, i.e. `Float32Array` and `Float64Array` are not accepted.
4147
- *
4148
- * An error will be thrown if the given `typedArray` is larger than 65,536 bytes.
4149
- * @since v15.0.0
4150
- */
4151
- getRandomValues<T extends Exclude<NodeJS.TypedArray, Float32Array | Float64Array>>(typedArray: T): T;
4152
- /**
4153
- * Generates a random {@link https://www.rfc-editor.org/rfc/rfc4122.txt RFC 4122} version 4 UUID.
4154
- * The UUID is generated using a cryptographic pseudorandom number generator.
4155
- * @since v16.7.0
4156
- */
3703
+ getRandomValues<
3704
+ T extends Exclude<
3705
+ NodeJS.NonSharedTypedArray,
3706
+ NodeJS.NonSharedFloat16Array | NodeJS.NonSharedFloat32Array | NodeJS.NonSharedFloat64Array
3707
+ >,
3708
+ >(
3709
+ typedArray: T,
3710
+ ): T;
4157
3711
  randomUUID(): UUID;
4158
- CryptoKey: CryptoKeyConstructor;
4159
- }
4160
- // This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable.
4161
- interface CryptoKeyConstructor {
4162
- /** Illegal constructor */
4163
- (_: { readonly _: unique symbol }): never; // Allows instanceof to work but not be callable by the user.
4164
- readonly length: 0;
4165
- readonly name: "CryptoKey";
4166
- readonly prototype: CryptoKey;
4167
3712
  }
4168
- /**
4169
- * @since v15.0.0
4170
- */
4171
3713
  interface CryptoKey {
4172
- /**
4173
- * An object detailing the algorithm for which the key can be used along with additional algorithm-specific parameters.
4174
- * @since v15.0.0
4175
- */
4176
3714
  readonly algorithm: KeyAlgorithm;
4177
- /**
4178
- * When `true`, the {@link CryptoKey} can be extracted using either `subtleCrypto.exportKey()` or `subtleCrypto.wrapKey()`.
4179
- * @since v15.0.0
4180
- */
4181
3715
  readonly extractable: boolean;
4182
- /**
4183
- * A string identifying whether the key is a symmetric (`'secret'`) or asymmetric (`'private'` or `'public'`) key.
4184
- * @since v15.0.0
4185
- */
4186
3716
  readonly type: KeyType;
4187
- /**
4188
- * An array of strings identifying the operations for which the key may be used.
4189
- *
4190
- * The possible usages are:
4191
- * - `'encrypt'` - The key may be used to encrypt data.
4192
- * - `'decrypt'` - The key may be used to decrypt data.
4193
- * - `'sign'` - The key may be used to generate digital signatures.
4194
- * - `'verify'` - The key may be used to verify digital signatures.
4195
- * - `'deriveKey'` - The key may be used to derive a new key.
4196
- * - `'deriveBits'` - The key may be used to derive bits.
4197
- * - `'wrapKey'` - The key may be used to wrap another key.
4198
- * - `'unwrapKey'` - The key may be used to unwrap another key.
4199
- *
4200
- * Valid key usages depend on the key algorithm (identified by `cryptokey.algorithm.name`).
4201
- * @since v15.0.0
4202
- */
4203
3717
  readonly usages: KeyUsage[];
4204
3718
  }
4205
- /**
4206
- * The `CryptoKeyPair` is a simple dictionary object with `publicKey` and `privateKey` properties, representing an asymmetric key pair.
4207
- * @since v15.0.0
4208
- */
4209
3719
  interface CryptoKeyPair {
4210
- /**
4211
- * A {@link CryptoKey} whose type will be `'private'`.
4212
- * @since v15.0.0
4213
- */
4214
3720
  privateKey: CryptoKey;
4215
- /**
4216
- * A {@link CryptoKey} whose type will be `'public'`.
4217
- * @since v15.0.0
4218
- */
4219
3721
  publicKey: CryptoKey;
4220
3722
  }
4221
- /**
4222
- * @since v15.0.0
4223
- */
3723
+ interface EncapsulatedBits {
3724
+ sharedKey: ArrayBuffer;
3725
+ ciphertext: ArrayBuffer;
3726
+ }
3727
+ interface EncapsulatedKey {
3728
+ sharedKey: CryptoKey;
3729
+ ciphertext: ArrayBuffer;
3730
+ }
4224
3731
  interface SubtleCrypto {
4225
- /**
4226
- * Using the method and parameters specified in `algorithm` and the keying material provided by `key`,
4227
- * `subtle.decrypt()` attempts to decipher the provided `data`. If successful,
4228
- * the returned promise will be resolved with an `<ArrayBuffer>` containing the plaintext result.
4229
- *
4230
- * The algorithms currently supported include:
4231
- *
4232
- * - `'RSA-OAEP'`
4233
- * - `'AES-CTR'`
4234
- * - `'AES-CBC'`
4235
- * - `'AES-GCM'`
4236
- * @since v15.0.0
4237
- */
3732
+ decapsulateBits(
3733
+ decapsulationAlgorithm: AlgorithmIdentifier,
3734
+ decapsulationKey: CryptoKey,
3735
+ ciphertext: NodeJS.BufferSource,
3736
+ ): Promise<ArrayBuffer>;
3737
+ decapsulateKey(
3738
+ decapsulationAlgorithm: AlgorithmIdentifier,
3739
+ decapsulationKey: CryptoKey,
3740
+ ciphertext: NodeJS.BufferSource,
3741
+ sharedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams | KmacImportParams,
3742
+ extractable: boolean,
3743
+ keyUsages: KeyUsage[],
3744
+ ): Promise<CryptoKey>;
4238
3745
  decrypt(
4239
- algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
3746
+ algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4240
3747
  key: CryptoKey,
4241
- data: BufferSource,
3748
+ data: NodeJS.BufferSource,
4242
3749
  ): Promise<ArrayBuffer>;
4243
- /**
4244
- * Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`,
4245
- * `subtle.deriveBits()` attempts to generate `length` bits.
4246
- * The Node.js implementation requires that when `length` is a number it must be multiple of `8`.
4247
- * When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed
4248
- * for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms.
4249
- * If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the generated data.
4250
- *
4251
- * The algorithms currently supported include:
4252
- *
4253
- * - `'ECDH'`
4254
- * - `'X25519'`
4255
- * - `'X448'`
4256
- * - `'HKDF'`
4257
- * - `'PBKDF2'`
4258
- * @since v15.0.0
4259
- */
4260
3750
  deriveBits(
4261
- algorithm: EcdhKeyDeriveParams,
3751
+ algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params | Argon2Params,
4262
3752
  baseKey: CryptoKey,
4263
3753
  length?: number | null,
4264
3754
  ): Promise<ArrayBuffer>;
4265
- deriveBits(
4266
- algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
4267
- baseKey: CryptoKey,
4268
- length: number,
4269
- ): Promise<ArrayBuffer>;
4270
- /**
4271
- * Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`,
4272
- * `subtle.deriveKey()` attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
4273
- *
4274
- * Calling `subtle.deriveKey()` is equivalent to calling `subtle.deriveBits()` to generate raw keying material,
4275
- * then passing the result into the `subtle.importKey()` method using the `deriveKeyAlgorithm`, `extractable`, and `keyUsages` parameters as input.
4276
- *
4277
- * The algorithms currently supported include:
4278
- *
4279
- * - `'ECDH'`
4280
- * - `'X25519'`
4281
- * - `'X448'`
4282
- * - `'HKDF'`
4283
- * - `'PBKDF2'`
4284
- * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4285
- * @since v15.0.0
4286
- */
4287
3755
  deriveKey(
4288
- algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
3756
+ algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params | Argon2Params,
4289
3757
  baseKey: CryptoKey,
4290
- derivedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams,
3758
+ derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | KmacImportParams,
4291
3759
  extractable: boolean,
4292
3760
  keyUsages: readonly KeyUsage[],
4293
3761
  ): Promise<CryptoKey>;
4294
- /**
4295
- * Using the method identified by `algorithm`, `subtle.digest()` attempts to generate a digest of `data`.
4296
- * If successful, the returned promise is resolved with an `<ArrayBuffer>` containing the computed digest.
4297
- *
4298
- * If `algorithm` is provided as a `<string>`, it must be one of:
4299
- *
4300
- * - `'SHA-1'`
4301
- * - `'SHA-256'`
4302
- * - `'SHA-384'`
4303
- * - `'SHA-512'`
4304
- *
4305
- * If `algorithm` is provided as an `<Object>`, it must have a `name` property whose value is one of the above.
4306
- * @since v15.0.0
4307
- */
4308
- digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
4309
- /**
4310
- * Using the method and parameters specified by `algorithm` and the keying material provided by `key`,
4311
- * `subtle.encrypt()` attempts to encipher `data`. If successful,
4312
- * the returned promise is resolved with an `<ArrayBuffer>` containing the encrypted result.
4313
- *
4314
- * The algorithms currently supported include:
4315
- *
4316
- * - `'RSA-OAEP'`
4317
- * - `'AES-CTR'`
4318
- * - `'AES-CBC'`
4319
- * - `'AES-GCM'`
4320
- * @since v15.0.0
4321
- */
3762
+ digest(
3763
+ algorithm: AlgorithmIdentifier | CShakeParams | TurboShakeParams | KangarooTwelveParams,
3764
+ data: NodeJS.BufferSource,
3765
+ ): Promise<ArrayBuffer>;
3766
+ encapsulateBits(
3767
+ encapsulationAlgorithm: AlgorithmIdentifier,
3768
+ encapsulationKey: CryptoKey,
3769
+ ): Promise<EncapsulatedBits>;
3770
+ encapsulateKey(
3771
+ encapsulationAlgorithm: AlgorithmIdentifier,
3772
+ encapsulationKey: CryptoKey,
3773
+ sharedKeyAlgorithm: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | KmacImportParams,
3774
+ extractable: boolean,
3775
+ keyUsages: KeyUsage[],
3776
+ ): Promise<EncapsulatedKey>;
4322
3777
  encrypt(
4323
- algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
3778
+ algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4324
3779
  key: CryptoKey,
4325
- data: BufferSource,
3780
+ data: NodeJS.BufferSource,
4326
3781
  ): Promise<ArrayBuffer>;
4327
- /**
4328
- * Exports the given key into the specified format, if supported.
4329
- *
4330
- * If the `<CryptoKey>` is not extractable, the returned promise will reject.
4331
- *
4332
- * When `format` is either `'pkcs8'` or `'spki'` and the export is successful,
4333
- * the returned promise will be resolved with an `<ArrayBuffer>` containing the exported key data.
4334
- *
4335
- * When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a
4336
- * JavaScript object conforming to the {@link https://tools.ietf.org/html/rfc7517 JSON Web Key} specification.
4337
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
4338
- * @returns `<Promise>` containing `<ArrayBuffer>`.
4339
- * @since v15.0.0
4340
- */
4341
3782
  exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
4342
3783
  exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
4343
- /**
4344
- * Using the method and parameters provided in `algorithm`,
4345
- * `subtle.generateKey()` attempts to generate new keying material.
4346
- * Depending the method used, the method may generate either a single `<CryptoKey>` or a `<CryptoKeyPair>`.
4347
- *
4348
- * The `<CryptoKeyPair>` (public and private key) generating algorithms supported include:
4349
- *
4350
- * - `'RSASSA-PKCS1-v1_5'`
4351
- * - `'RSA-PSS'`
4352
- * - `'RSA-OAEP'`
4353
- * - `'ECDSA'`
4354
- * - `'Ed25519'`
4355
- * - `'Ed448'`
4356
- * - `'ECDH'`
4357
- * - `'X25519'`
4358
- * - `'X448'`
4359
- * The `<CryptoKey>` (secret key) generating algorithms supported include:
4360
- *
4361
- * - `'HMAC'`
4362
- * - `'AES-CTR'`
4363
- * - `'AES-CBC'`
4364
- * - `'AES-GCM'`
4365
- * - `'AES-KW'`
4366
- * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4367
- * @since v15.0.0
4368
- */
3784
+ exportKey(format: KeyFormat, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
4369
3785
  generateKey(
4370
3786
  algorithm: RsaHashedKeyGenParams | EcKeyGenParams,
4371
3787
  extractable: boolean,
4372
- keyUsages: readonly KeyUsage[],
3788
+ keyUsages: KeyUsage[],
4373
3789
  ): Promise<CryptoKeyPair>;
4374
3790
  generateKey(
4375
- algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params,
3791
+ algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params | KmacKeyGenParams,
4376
3792
  extractable: boolean,
4377
- keyUsages: readonly KeyUsage[],
3793
+ keyUsages: KeyUsage[],
4378
3794
  ): Promise<CryptoKey>;
4379
3795
  generateKey(
4380
3796
  algorithm: AlgorithmIdentifier,
4381
3797
  extractable: boolean,
4382
3798
  keyUsages: KeyUsage[],
4383
3799
  ): Promise<CryptoKeyPair | CryptoKey>;
4384
- /**
4385
- * The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format`
4386
- * to create a `<CryptoKey>` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments.
4387
- * If the import is successful, the returned promise will be resolved with the created `<CryptoKey>`.
4388
- *
4389
- * If importing a `'PBKDF2'` key, `extractable` must be `false`.
4390
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
4391
- * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4392
- * @since v15.0.0
4393
- */
3800
+ getPublicKey(key: CryptoKey, keyUsages: KeyUsage[]): Promise<CryptoKey>;
4394
3801
  importKey(
4395
3802
  format: "jwk",
4396
3803
  keyData: JsonWebKey,
@@ -4399,147 +3806,147 @@ declare module "crypto" {
4399
3806
  | RsaHashedImportParams
4400
3807
  | EcKeyImportParams
4401
3808
  | HmacImportParams
4402
- | AesKeyAlgorithm,
3809
+ | AesKeyAlgorithm
3810
+ | KmacImportParams,
4403
3811
  extractable: boolean,
4404
- keyUsages: readonly KeyUsage[],
3812
+ keyUsages: KeyUsage[],
4405
3813
  ): Promise<CryptoKey>;
4406
3814
  importKey(
4407
3815
  format: Exclude<KeyFormat, "jwk">,
4408
- keyData: BufferSource,
3816
+ keyData: NodeJS.BufferSource,
4409
3817
  algorithm:
4410
3818
  | AlgorithmIdentifier
4411
3819
  | RsaHashedImportParams
4412
3820
  | EcKeyImportParams
4413
3821
  | HmacImportParams
4414
- | AesKeyAlgorithm,
3822
+ | AesKeyAlgorithm
3823
+ | KmacImportParams,
4415
3824
  extractable: boolean,
4416
3825
  keyUsages: KeyUsage[],
4417
3826
  ): Promise<CryptoKey>;
4418
- /**
4419
- * Using the method and parameters given by `algorithm` and the keying material provided by `key`,
4420
- * `subtle.sign()` attempts to generate a cryptographic signature of `data`. If successful,
4421
- * the returned promise is resolved with an `<ArrayBuffer>` containing the generated signature.
4422
- *
4423
- * The algorithms currently supported include:
4424
- *
4425
- * - `'RSASSA-PKCS1-v1_5'`
4426
- * - `'RSA-PSS'`
4427
- * - `'ECDSA'`
4428
- * - `'Ed25519'`
4429
- * - `'Ed448'`
4430
- * - `'HMAC'`
4431
- * @since v15.0.0
4432
- */
4433
3827
  sign(
4434
- algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params,
3828
+ algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | ContextParams | KmacParams,
4435
3829
  key: CryptoKey,
4436
- data: BufferSource,
3830
+ data: NodeJS.BufferSource,
4437
3831
  ): Promise<ArrayBuffer>;
4438
- /**
4439
- * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
4440
- * The `subtle.unwrapKey()` method attempts to decrypt a wrapped key and create a `<CryptoKey>` instance.
4441
- * It is equivalent to calling `subtle.decrypt()` first on the encrypted key data (using the `wrappedKey`, `unwrapAlgo`, and `unwrappingKey` arguments as input)
4442
- * then passing the results in to the `subtle.importKey()` method using the `unwrappedKeyAlgo`, `extractable`, and `keyUsages` arguments as inputs.
4443
- * If successful, the returned promise is resolved with a `<CryptoKey>` object.
4444
- *
4445
- * The wrapping algorithms currently supported include:
4446
- *
4447
- * - `'RSA-OAEP'`
4448
- * - `'AES-CTR'`
4449
- * - `'AES-CBC'`
4450
- * - `'AES-GCM'`
4451
- * - `'AES-KW'`
4452
- *
4453
- * The unwrapped key algorithms supported include:
4454
- *
4455
- * - `'RSASSA-PKCS1-v1_5'`
4456
- * - `'RSA-PSS'`
4457
- * - `'RSA-OAEP'`
4458
- * - `'ECDSA'`
4459
- * - `'Ed25519'`
4460
- * - `'Ed448'`
4461
- * - `'ECDH'`
4462
- * - `'X25519'`
4463
- * - `'X448'`
4464
- * - `'HMAC'`
4465
- * - `'AES-CTR'`
4466
- * - `'AES-CBC'`
4467
- * - `'AES-GCM'`
4468
- * - `'AES-KW'`
4469
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
4470
- * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4471
- * @since v15.0.0
4472
- */
4473
3832
  unwrapKey(
4474
3833
  format: KeyFormat,
4475
- wrappedKey: BufferSource,
3834
+ wrappedKey: NodeJS.BufferSource,
4476
3835
  unwrappingKey: CryptoKey,
4477
- unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
3836
+ unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4478
3837
  unwrappedKeyAlgorithm:
4479
3838
  | AlgorithmIdentifier
4480
3839
  | RsaHashedImportParams
4481
3840
  | EcKeyImportParams
4482
3841
  | HmacImportParams
4483
- | AesKeyAlgorithm,
3842
+ | AesKeyAlgorithm
3843
+ | KmacImportParams,
4484
3844
  extractable: boolean,
4485
3845
  keyUsages: KeyUsage[],
4486
3846
  ): Promise<CryptoKey>;
4487
- /**
4488
- * Using the method and parameters given in `algorithm` and the keying material provided by `key`,
4489
- * `subtle.verify()` attempts to verify that `signature` is a valid cryptographic signature of `data`.
4490
- * The returned promise is resolved with either `true` or `false`.
4491
- *
4492
- * The algorithms currently supported include:
4493
- *
4494
- * - `'RSASSA-PKCS1-v1_5'`
4495
- * - `'RSA-PSS'`
4496
- * - `'ECDSA'`
4497
- * - `'Ed25519'`
4498
- * - `'Ed448'`
4499
- * - `'HMAC'`
4500
- * @since v15.0.0
4501
- */
4502
3847
  verify(
4503
- algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params,
3848
+ algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | ContextParams | KmacParams,
4504
3849
  key: CryptoKey,
4505
- signature: BufferSource,
4506
- data: BufferSource,
3850
+ signature: NodeJS.BufferSource,
3851
+ data: NodeJS.BufferSource,
4507
3852
  ): Promise<boolean>;
4508
- /**
4509
- * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
4510
- * The `subtle.wrapKey()` method exports the keying material into the format identified by `format`,
4511
- * then encrypts it using the method and parameters specified by `wrapAlgo` and the keying material provided by `wrappingKey`.
4512
- * It is the equivalent to calling `subtle.exportKey()` using `format` and `key` as the arguments,
4513
- * then passing the result to the `subtle.encrypt()` method using `wrappingKey` and `wrapAlgo` as inputs.
4514
- * If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the encrypted key data.
4515
- *
4516
- * The wrapping algorithms currently supported include:
4517
- *
4518
- * - `'RSA-OAEP'`
4519
- * - `'AES-CTR'`
4520
- * - `'AES-CBC'`
4521
- * - `'AES-GCM'`
4522
- * - `'AES-KW'`
4523
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
4524
- * @since v15.0.0
4525
- */
4526
3853
  wrapKey(
4527
3854
  format: KeyFormat,
4528
3855
  key: CryptoKey,
4529
3856
  wrappingKey: CryptoKey,
4530
- wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
3857
+ wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4531
3858
  ): Promise<ArrayBuffer>;
4532
3859
  }
4533
3860
  }
4534
-
4535
- global {
4536
- var crypto: typeof globalThis extends {
4537
- crypto: infer T;
4538
- onmessage: any;
4539
- } ? T
4540
- : webcrypto.Crypto;
3861
+ /**
3862
+ * An object containing commonly used constants for crypto and security related
3863
+ * operations. The specific constants currently defined are described in
3864
+ * [Crypto constants](https://nodejs.org/docs/latest-v26.x/api/crypto.html#crypto-constants).
3865
+ * @since v6.3.0
3866
+ */
3867
+ namespace constants {
3868
+ const OPENSSL_VERSION_NUMBER: number;
3869
+ const SSL_OP_ALL: number;
3870
+ const SSL_OP_ALLOW_NO_DHE_KEX: number;
3871
+ const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
3872
+ const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
3873
+ const SSL_OP_CISCO_ANYCONNECT: number;
3874
+ const SSL_OP_COOKIE_EXCHANGE: number;
3875
+ const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
3876
+ const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
3877
+ const SSL_OP_LEGACY_SERVER_CONNECT: number;
3878
+ const SSL_OP_NO_COMPRESSION: number;
3879
+ const SSL_OP_NO_ENCRYPT_THEN_MAC: number;
3880
+ const SSL_OP_NO_QUERY_MTU: number;
3881
+ const SSL_OP_NO_RENEGOTIATION: number;
3882
+ const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
3883
+ const SSL_OP_NO_SSLv2: number;
3884
+ const SSL_OP_NO_SSLv3: number;
3885
+ const SSL_OP_NO_TICKET: number;
3886
+ const SSL_OP_NO_TLSv1: number;
3887
+ const SSL_OP_NO_TLSv1_1: number;
3888
+ const SSL_OP_NO_TLSv1_2: number;
3889
+ const SSL_OP_NO_TLSv1_3: number;
3890
+ const SSL_OP_PRIORITIZE_CHACHA: number;
3891
+ const SSL_OP_TLS_ROLLBACK_BUG: number;
3892
+ const ENGINE_METHOD_RSA: number;
3893
+ const ENGINE_METHOD_DSA: number;
3894
+ const ENGINE_METHOD_DH: number;
3895
+ const ENGINE_METHOD_RAND: number;
3896
+ const ENGINE_METHOD_EC: number;
3897
+ const ENGINE_METHOD_CIPHERS: number;
3898
+ const ENGINE_METHOD_DIGESTS: number;
3899
+ const ENGINE_METHOD_PKEY_METHS: number;
3900
+ const ENGINE_METHOD_PKEY_ASN1_METHS: number;
3901
+ const ENGINE_METHOD_ALL: number;
3902
+ const ENGINE_METHOD_NONE: number;
3903
+ const DH_CHECK_P_NOT_SAFE_PRIME: number;
3904
+ const DH_CHECK_P_NOT_PRIME: number;
3905
+ const DH_UNABLE_TO_CHECK_GENERATOR: number;
3906
+ const DH_NOT_SUITABLE_GENERATOR: number;
3907
+ const RSA_PKCS1_PADDING: number;
3908
+ const RSA_NO_PADDING: number;
3909
+ const RSA_PKCS1_OAEP_PADDING: number;
3910
+ const RSA_X931_PADDING: number;
3911
+ const RSA_PKCS1_PSS_PADDING: number;
3912
+ const RSA_PSS_SALTLEN_DIGEST: number;
3913
+ const RSA_PSS_SALTLEN_MAX_SIGN: number;
3914
+ const RSA_PSS_SALTLEN_AUTO: number;
3915
+ const TLS1_VERSION: number;
3916
+ const TLS1_1_VERSION: number;
3917
+ const TLS1_2_VERSION: number;
3918
+ const TLS1_3_VERSION: number;
3919
+ const POINT_CONVERSION_COMPRESSED: number;
3920
+ const POINT_CONVERSION_UNCOMPRESSED: number;
3921
+ const POINT_CONVERSION_HYBRID: number;
3922
+ const defaultCipherList: string;
3923
+ const defaultCoreCipherList: string;
3924
+ }
3925
+ // TODO: remove in future major version
3926
+ /** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
3927
+ type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary";
3928
+ /** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
3929
+ type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1";
3930
+ /** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
3931
+ type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2";
3932
+ /** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
3933
+ type Encoding = BufferEncoding;
3934
+ /** @deprecated This type will be removed in a future version. Use `KeyLike` instead. */
3935
+ type CipherKey = KeyLike;
3936
+ /** @deprecated This type will be removed in a future version. */
3937
+ interface RsaPrivateKey {
3938
+ key: KeyLike;
3939
+ passphrase?: string | undefined;
3940
+ oaepHash?: string | undefined;
3941
+ oaepLabel?: NodeJS.TypedArray | undefined;
3942
+ padding?: number | undefined;
3943
+ }
3944
+ /** @deprecated This type will be removed in a future version. */
3945
+ interface RsaPublicKey {
3946
+ key: KeyLike;
3947
+ padding?: number | undefined;
4541
3948
  }
4542
3949
  }
4543
- declare module "node:crypto" {
4544
- export * from "crypto";
3950
+ declare module "crypto" {
3951
+ export * from "node:crypto";
4545
3952
  }