cloudstructs 0.1.37 → 0.1.41

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 (396) hide show
  1. package/.jsii +3 -3
  2. package/lib/codecommit-mirror/index.js +2 -2
  3. package/lib/ecs-service-roller/index.js +2 -2
  4. package/lib/email-receiver/receiver.js +1 -1
  5. package/lib/saml-identity-provider/index.js +2 -2
  6. package/lib/slack-events/index.js +1 -1
  7. package/lib/slack-textract/index.js +1 -1
  8. package/lib/state-machine-cr-provider/index.js +1 -1
  9. package/lib/static-website/index.js +1 -1
  10. package/lib/url-shortener/index.handler.js +2 -1
  11. package/lib/url-shortener/index.js +1 -1
  12. package/node_modules/@sindresorhus/is/dist/index.d.ts +9 -4
  13. package/node_modules/@sindresorhus/is/dist/index.js +9 -0
  14. package/node_modules/@sindresorhus/is/package.json +1 -1
  15. package/node_modules/@sindresorhus/is/readme.md +26 -0
  16. package/node_modules/@slack/logger/node_modules/@types/node/README.md +3 -3
  17. package/node_modules/@slack/logger/node_modules/@types/node/assert/strict.d.ts +3 -4
  18. package/node_modules/@slack/logger/node_modules/@types/node/assert.d.ts +823 -40
  19. package/node_modules/@slack/logger/node_modules/@types/node/async_hooks.d.ts +359 -90
  20. package/node_modules/@slack/logger/node_modules/@types/node/buffer.d.ts +1895 -113
  21. package/node_modules/@slack/logger/node_modules/@types/node/child_process.d.ts +1070 -240
  22. package/node_modules/@slack/logger/node_modules/@types/node/cluster.d.ts +331 -104
  23. package/node_modules/@slack/logger/node_modules/@types/node/console.d.ts +310 -37
  24. package/node_modules/@slack/logger/node_modules/@types/node/constants.d.ts +3 -3
  25. package/node_modules/@slack/logger/node_modules/@types/node/crypto.d.ts +2406 -742
  26. package/node_modules/@slack/logger/node_modules/@types/node/dgram.d.ts +458 -58
  27. package/node_modules/@slack/logger/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
  28. package/node_modules/@slack/logger/node_modules/@types/node/dns/promises.d.ts +292 -36
  29. package/node_modules/@slack/logger/node_modules/@types/node/dns.d.ts +414 -97
  30. package/node_modules/@slack/logger/node_modules/@types/node/domain.d.ts +153 -9
  31. package/node_modules/@slack/logger/node_modules/@types/node/events.d.ts +560 -35
  32. package/node_modules/@slack/logger/node_modules/@types/node/fs/promises.d.ts +735 -279
  33. package/node_modules/@slack/logger/node_modules/@types/node/fs.d.ts +2351 -870
  34. package/node_modules/@slack/logger/node_modules/@types/node/globals.d.ts +24 -14
  35. package/node_modules/@slack/logger/node_modules/@types/node/http.d.ts +1020 -98
  36. package/node_modules/@slack/logger/node_modules/@types/node/http2.d.ts +1586 -466
  37. package/node_modules/@slack/logger/node_modules/@types/node/https.d.ts +366 -15
  38. package/node_modules/@slack/logger/node_modules/@types/node/index.d.ts +87 -13
  39. package/node_modules/@slack/logger/node_modules/@types/node/inspector.d.ts +577 -562
  40. package/node_modules/@slack/logger/node_modules/@types/node/module.d.ts +53 -12
  41. package/node_modules/@slack/logger/node_modules/@types/node/net.d.ts +558 -143
  42. package/node_modules/@slack/logger/node_modules/@types/node/os.d.ts +236 -26
  43. package/node_modules/@slack/logger/node_modules/@types/node/package.json +18 -15
  44. package/node_modules/@slack/logger/node_modules/@types/node/path.d.ts +9 -5
  45. package/node_modules/@slack/logger/node_modules/@types/node/perf_hooks.d.ts +290 -92
  46. package/node_modules/@slack/logger/node_modules/@types/node/process.d.ts +1170 -156
  47. package/node_modules/@slack/logger/node_modules/@types/node/punycode.d.ts +64 -26
  48. package/node_modules/@slack/logger/node_modules/@types/node/querystring.d.ts +107 -8
  49. package/node_modules/@slack/logger/node_modules/@types/node/readline.d.ts +426 -80
  50. package/node_modules/@slack/logger/node_modules/@types/node/repl.d.ts +138 -113
  51. package/node_modules/@slack/logger/node_modules/@types/node/stream/consumers.d.ts +24 -0
  52. package/node_modules/@slack/logger/node_modules/@types/node/stream/promises.d.ts +15 -44
  53. package/node_modules/@slack/logger/node_modules/@types/node/stream/web.d.ts +6 -0
  54. package/node_modules/@slack/logger/node_modules/@types/node/stream.d.ts +979 -226
  55. package/node_modules/@slack/logger/node_modules/@types/node/string_decoder.d.ts +57 -1
  56. package/node_modules/@slack/logger/node_modules/@types/node/timers/promises.d.ts +53 -10
  57. package/node_modules/@slack/logger/node_modules/@types/node/timers.d.ts +32 -39
  58. package/node_modules/@slack/logger/node_modules/@types/node/tls.d.ts +449 -227
  59. package/node_modules/@slack/logger/node_modules/@types/node/trace_events.d.ts +107 -11
  60. package/node_modules/@slack/logger/node_modules/@types/node/tty.d.ts +160 -24
  61. package/node_modules/@slack/logger/node_modules/@types/node/url.d.ts +703 -32
  62. package/node_modules/@slack/logger/node_modules/@types/node/util.d.ts +1375 -76
  63. package/node_modules/@slack/logger/node_modules/@types/node/v8.d.ts +255 -79
  64. package/node_modules/@slack/logger/node_modules/@types/node/vm.d.ts +384 -33
  65. package/node_modules/@slack/logger/node_modules/@types/node/wasi.d.ts +92 -24
  66. package/node_modules/@slack/logger/node_modules/@types/node/worker_threads.d.ts +501 -138
  67. package/node_modules/@slack/logger/node_modules/@types/node/zlib.d.ts +216 -64
  68. package/node_modules/@slack/web-api/node_modules/@types/node/README.md +3 -3
  69. package/node_modules/@slack/web-api/node_modules/@types/node/assert/strict.d.ts +3 -4
  70. package/node_modules/@slack/web-api/node_modules/@types/node/assert.d.ts +823 -40
  71. package/node_modules/@slack/web-api/node_modules/@types/node/async_hooks.d.ts +359 -90
  72. package/node_modules/@slack/web-api/node_modules/@types/node/buffer.d.ts +1895 -113
  73. package/node_modules/@slack/web-api/node_modules/@types/node/child_process.d.ts +1070 -240
  74. package/node_modules/@slack/web-api/node_modules/@types/node/cluster.d.ts +331 -104
  75. package/node_modules/@slack/web-api/node_modules/@types/node/console.d.ts +310 -37
  76. package/node_modules/@slack/web-api/node_modules/@types/node/constants.d.ts +3 -3
  77. package/node_modules/@slack/web-api/node_modules/@types/node/crypto.d.ts +2406 -742
  78. package/node_modules/@slack/web-api/node_modules/@types/node/dgram.d.ts +458 -58
  79. package/node_modules/@slack/web-api/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
  80. package/node_modules/@slack/web-api/node_modules/@types/node/dns/promises.d.ts +292 -36
  81. package/node_modules/@slack/web-api/node_modules/@types/node/dns.d.ts +414 -97
  82. package/node_modules/@slack/web-api/node_modules/@types/node/domain.d.ts +153 -9
  83. package/node_modules/@slack/web-api/node_modules/@types/node/events.d.ts +560 -35
  84. package/node_modules/@slack/web-api/node_modules/@types/node/fs/promises.d.ts +735 -279
  85. package/node_modules/@slack/web-api/node_modules/@types/node/fs.d.ts +2351 -870
  86. package/node_modules/@slack/web-api/node_modules/@types/node/globals.d.ts +24 -14
  87. package/node_modules/@slack/web-api/node_modules/@types/node/http.d.ts +1020 -98
  88. package/node_modules/@slack/web-api/node_modules/@types/node/http2.d.ts +1586 -466
  89. package/node_modules/@slack/web-api/node_modules/@types/node/https.d.ts +366 -15
  90. package/node_modules/@slack/web-api/node_modules/@types/node/index.d.ts +87 -13
  91. package/node_modules/@slack/web-api/node_modules/@types/node/inspector.d.ts +577 -562
  92. package/node_modules/@slack/web-api/node_modules/@types/node/module.d.ts +53 -12
  93. package/node_modules/@slack/web-api/node_modules/@types/node/net.d.ts +558 -143
  94. package/node_modules/@slack/web-api/node_modules/@types/node/os.d.ts +236 -26
  95. package/node_modules/@slack/web-api/node_modules/@types/node/package.json +18 -15
  96. package/node_modules/@slack/web-api/node_modules/@types/node/path.d.ts +9 -5
  97. package/node_modules/@slack/web-api/node_modules/@types/node/perf_hooks.d.ts +290 -92
  98. package/node_modules/@slack/web-api/node_modules/@types/node/process.d.ts +1170 -156
  99. package/node_modules/@slack/web-api/node_modules/@types/node/punycode.d.ts +64 -26
  100. package/node_modules/@slack/web-api/node_modules/@types/node/querystring.d.ts +107 -8
  101. package/node_modules/@slack/web-api/node_modules/@types/node/readline.d.ts +426 -80
  102. package/node_modules/@slack/web-api/node_modules/@types/node/repl.d.ts +138 -113
  103. package/node_modules/@slack/web-api/node_modules/@types/node/stream/consumers.d.ts +24 -0
  104. package/node_modules/@slack/web-api/node_modules/@types/node/stream/promises.d.ts +15 -44
  105. package/node_modules/@slack/web-api/node_modules/@types/node/stream/web.d.ts +6 -0
  106. package/node_modules/@slack/web-api/node_modules/@types/node/stream.d.ts +979 -226
  107. package/node_modules/@slack/web-api/node_modules/@types/node/string_decoder.d.ts +57 -1
  108. package/node_modules/@slack/web-api/node_modules/@types/node/timers/promises.d.ts +53 -10
  109. package/node_modules/@slack/web-api/node_modules/@types/node/timers.d.ts +32 -39
  110. package/node_modules/@slack/web-api/node_modules/@types/node/tls.d.ts +449 -227
  111. package/node_modules/@slack/web-api/node_modules/@types/node/trace_events.d.ts +107 -11
  112. package/node_modules/@slack/web-api/node_modules/@types/node/tty.d.ts +160 -24
  113. package/node_modules/@slack/web-api/node_modules/@types/node/url.d.ts +703 -32
  114. package/node_modules/@slack/web-api/node_modules/@types/node/util.d.ts +1375 -76
  115. package/node_modules/@slack/web-api/node_modules/@types/node/v8.d.ts +255 -79
  116. package/node_modules/@slack/web-api/node_modules/@types/node/vm.d.ts +384 -33
  117. package/node_modules/@slack/web-api/node_modules/@types/node/wasi.d.ts +92 -24
  118. package/node_modules/@slack/web-api/node_modules/@types/node/worker_threads.d.ts +501 -138
  119. package/node_modules/@slack/web-api/node_modules/@types/node/zlib.d.ts +216 -64
  120. package/node_modules/@types/cacheable-request/node_modules/@types/node/README.md +3 -3
  121. package/node_modules/@types/cacheable-request/node_modules/@types/node/assert/strict.d.ts +3 -4
  122. package/node_modules/@types/cacheable-request/node_modules/@types/node/assert.d.ts +823 -40
  123. package/node_modules/@types/cacheable-request/node_modules/@types/node/async_hooks.d.ts +359 -90
  124. package/node_modules/@types/cacheable-request/node_modules/@types/node/buffer.d.ts +1895 -113
  125. package/node_modules/@types/cacheable-request/node_modules/@types/node/child_process.d.ts +1070 -240
  126. package/node_modules/@types/cacheable-request/node_modules/@types/node/cluster.d.ts +331 -104
  127. package/node_modules/@types/cacheable-request/node_modules/@types/node/console.d.ts +310 -37
  128. package/node_modules/@types/cacheable-request/node_modules/@types/node/constants.d.ts +3 -3
  129. package/node_modules/@types/cacheable-request/node_modules/@types/node/crypto.d.ts +2406 -742
  130. package/node_modules/@types/cacheable-request/node_modules/@types/node/dgram.d.ts +458 -58
  131. package/node_modules/@types/cacheable-request/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
  132. package/node_modules/@types/cacheable-request/node_modules/@types/node/dns/promises.d.ts +292 -36
  133. package/node_modules/@types/cacheable-request/node_modules/@types/node/dns.d.ts +414 -97
  134. package/node_modules/@types/cacheable-request/node_modules/@types/node/domain.d.ts +153 -9
  135. package/node_modules/@types/cacheable-request/node_modules/@types/node/events.d.ts +560 -35
  136. package/node_modules/@types/cacheable-request/node_modules/@types/node/fs/promises.d.ts +735 -279
  137. package/node_modules/@types/cacheable-request/node_modules/@types/node/fs.d.ts +2351 -870
  138. package/node_modules/@types/cacheable-request/node_modules/@types/node/globals.d.ts +24 -14
  139. package/node_modules/@types/cacheable-request/node_modules/@types/node/http.d.ts +1020 -98
  140. package/node_modules/@types/cacheable-request/node_modules/@types/node/http2.d.ts +1586 -466
  141. package/node_modules/@types/cacheable-request/node_modules/@types/node/https.d.ts +366 -15
  142. package/node_modules/@types/cacheable-request/node_modules/@types/node/index.d.ts +87 -13
  143. package/node_modules/@types/cacheable-request/node_modules/@types/node/inspector.d.ts +577 -562
  144. package/node_modules/@types/cacheable-request/node_modules/@types/node/module.d.ts +53 -12
  145. package/node_modules/@types/cacheable-request/node_modules/@types/node/net.d.ts +558 -143
  146. package/node_modules/@types/cacheable-request/node_modules/@types/node/os.d.ts +236 -26
  147. package/node_modules/@types/cacheable-request/node_modules/@types/node/package.json +18 -15
  148. package/node_modules/@types/cacheable-request/node_modules/@types/node/path.d.ts +9 -5
  149. package/node_modules/@types/cacheable-request/node_modules/@types/node/perf_hooks.d.ts +290 -92
  150. package/node_modules/@types/cacheable-request/node_modules/@types/node/process.d.ts +1170 -156
  151. package/node_modules/@types/cacheable-request/node_modules/@types/node/punycode.d.ts +64 -26
  152. package/node_modules/@types/cacheable-request/node_modules/@types/node/querystring.d.ts +107 -8
  153. package/node_modules/@types/cacheable-request/node_modules/@types/node/readline.d.ts +426 -80
  154. package/node_modules/@types/cacheable-request/node_modules/@types/node/repl.d.ts +138 -113
  155. package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/consumers.d.ts +24 -0
  156. package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/promises.d.ts +15 -44
  157. package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/web.d.ts +6 -0
  158. package/node_modules/@types/cacheable-request/node_modules/@types/node/stream.d.ts +979 -226
  159. package/node_modules/@types/cacheable-request/node_modules/@types/node/string_decoder.d.ts +57 -1
  160. package/node_modules/@types/cacheable-request/node_modules/@types/node/timers/promises.d.ts +53 -10
  161. package/node_modules/@types/cacheable-request/node_modules/@types/node/timers.d.ts +32 -39
  162. package/node_modules/@types/cacheable-request/node_modules/@types/node/tls.d.ts +449 -227
  163. package/node_modules/@types/cacheable-request/node_modules/@types/node/trace_events.d.ts +107 -11
  164. package/node_modules/@types/cacheable-request/node_modules/@types/node/tty.d.ts +160 -24
  165. package/node_modules/@types/cacheable-request/node_modules/@types/node/url.d.ts +703 -32
  166. package/node_modules/@types/cacheable-request/node_modules/@types/node/util.d.ts +1375 -76
  167. package/node_modules/@types/cacheable-request/node_modules/@types/node/v8.d.ts +255 -79
  168. package/node_modules/@types/cacheable-request/node_modules/@types/node/vm.d.ts +384 -33
  169. package/node_modules/@types/cacheable-request/node_modules/@types/node/wasi.d.ts +92 -24
  170. package/node_modules/@types/cacheable-request/node_modules/@types/node/worker_threads.d.ts +501 -138
  171. package/node_modules/@types/cacheable-request/node_modules/@types/node/zlib.d.ts +216 -64
  172. package/node_modules/@types/is-stream/node_modules/@types/node/README.md +3 -3
  173. package/node_modules/@types/is-stream/node_modules/@types/node/assert/strict.d.ts +3 -4
  174. package/node_modules/@types/is-stream/node_modules/@types/node/assert.d.ts +823 -40
  175. package/node_modules/@types/is-stream/node_modules/@types/node/async_hooks.d.ts +359 -90
  176. package/node_modules/@types/is-stream/node_modules/@types/node/buffer.d.ts +1895 -113
  177. package/node_modules/@types/is-stream/node_modules/@types/node/child_process.d.ts +1070 -240
  178. package/node_modules/@types/is-stream/node_modules/@types/node/cluster.d.ts +331 -104
  179. package/node_modules/@types/is-stream/node_modules/@types/node/console.d.ts +310 -37
  180. package/node_modules/@types/is-stream/node_modules/@types/node/constants.d.ts +3 -3
  181. package/node_modules/@types/is-stream/node_modules/@types/node/crypto.d.ts +2406 -742
  182. package/node_modules/@types/is-stream/node_modules/@types/node/dgram.d.ts +458 -58
  183. package/node_modules/@types/is-stream/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
  184. package/node_modules/@types/is-stream/node_modules/@types/node/dns/promises.d.ts +292 -36
  185. package/node_modules/@types/is-stream/node_modules/@types/node/dns.d.ts +414 -97
  186. package/node_modules/@types/is-stream/node_modules/@types/node/domain.d.ts +153 -9
  187. package/node_modules/@types/is-stream/node_modules/@types/node/events.d.ts +560 -35
  188. package/node_modules/@types/is-stream/node_modules/@types/node/fs/promises.d.ts +735 -279
  189. package/node_modules/@types/is-stream/node_modules/@types/node/fs.d.ts +2351 -870
  190. package/node_modules/@types/is-stream/node_modules/@types/node/globals.d.ts +24 -14
  191. package/node_modules/@types/is-stream/node_modules/@types/node/http.d.ts +1020 -98
  192. package/node_modules/@types/is-stream/node_modules/@types/node/http2.d.ts +1586 -466
  193. package/node_modules/@types/is-stream/node_modules/@types/node/https.d.ts +366 -15
  194. package/node_modules/@types/is-stream/node_modules/@types/node/index.d.ts +87 -13
  195. package/node_modules/@types/is-stream/node_modules/@types/node/inspector.d.ts +577 -562
  196. package/node_modules/@types/is-stream/node_modules/@types/node/module.d.ts +53 -12
  197. package/node_modules/@types/is-stream/node_modules/@types/node/net.d.ts +558 -143
  198. package/node_modules/@types/is-stream/node_modules/@types/node/os.d.ts +236 -26
  199. package/node_modules/@types/is-stream/node_modules/@types/node/package.json +18 -15
  200. package/node_modules/@types/is-stream/node_modules/@types/node/path.d.ts +9 -5
  201. package/node_modules/@types/is-stream/node_modules/@types/node/perf_hooks.d.ts +290 -92
  202. package/node_modules/@types/is-stream/node_modules/@types/node/process.d.ts +1170 -156
  203. package/node_modules/@types/is-stream/node_modules/@types/node/punycode.d.ts +64 -26
  204. package/node_modules/@types/is-stream/node_modules/@types/node/querystring.d.ts +107 -8
  205. package/node_modules/@types/is-stream/node_modules/@types/node/readline.d.ts +426 -80
  206. package/node_modules/@types/is-stream/node_modules/@types/node/repl.d.ts +138 -113
  207. package/node_modules/@types/is-stream/node_modules/@types/node/stream/consumers.d.ts +24 -0
  208. package/node_modules/@types/is-stream/node_modules/@types/node/stream/promises.d.ts +15 -44
  209. package/node_modules/@types/is-stream/node_modules/@types/node/stream/web.d.ts +6 -0
  210. package/node_modules/@types/is-stream/node_modules/@types/node/stream.d.ts +979 -226
  211. package/node_modules/@types/is-stream/node_modules/@types/node/string_decoder.d.ts +57 -1
  212. package/node_modules/@types/is-stream/node_modules/@types/node/timers/promises.d.ts +53 -10
  213. package/node_modules/@types/is-stream/node_modules/@types/node/timers.d.ts +32 -39
  214. package/node_modules/@types/is-stream/node_modules/@types/node/tls.d.ts +449 -227
  215. package/node_modules/@types/is-stream/node_modules/@types/node/trace_events.d.ts +107 -11
  216. package/node_modules/@types/is-stream/node_modules/@types/node/tty.d.ts +160 -24
  217. package/node_modules/@types/is-stream/node_modules/@types/node/url.d.ts +703 -32
  218. package/node_modules/@types/is-stream/node_modules/@types/node/util.d.ts +1375 -76
  219. package/node_modules/@types/is-stream/node_modules/@types/node/v8.d.ts +255 -79
  220. package/node_modules/@types/is-stream/node_modules/@types/node/vm.d.ts +384 -33
  221. package/node_modules/@types/is-stream/node_modules/@types/node/wasi.d.ts +92 -24
  222. package/node_modules/@types/is-stream/node_modules/@types/node/worker_threads.d.ts +501 -138
  223. package/node_modules/@types/is-stream/node_modules/@types/node/zlib.d.ts +216 -64
  224. package/node_modules/@types/keyv/README.md +1 -1
  225. package/node_modules/@types/keyv/index.d.ts +10 -3
  226. package/node_modules/@types/keyv/node_modules/@types/node/README.md +3 -3
  227. package/node_modules/@types/keyv/node_modules/@types/node/assert/strict.d.ts +3 -4
  228. package/node_modules/@types/keyv/node_modules/@types/node/assert.d.ts +823 -40
  229. package/node_modules/@types/keyv/node_modules/@types/node/async_hooks.d.ts +359 -90
  230. package/node_modules/@types/keyv/node_modules/@types/node/buffer.d.ts +1895 -113
  231. package/node_modules/@types/keyv/node_modules/@types/node/child_process.d.ts +1070 -240
  232. package/node_modules/@types/keyv/node_modules/@types/node/cluster.d.ts +331 -104
  233. package/node_modules/@types/keyv/node_modules/@types/node/console.d.ts +310 -37
  234. package/node_modules/@types/keyv/node_modules/@types/node/constants.d.ts +3 -3
  235. package/node_modules/@types/keyv/node_modules/@types/node/crypto.d.ts +2406 -742
  236. package/node_modules/@types/keyv/node_modules/@types/node/dgram.d.ts +458 -58
  237. package/node_modules/@types/keyv/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
  238. package/node_modules/@types/keyv/node_modules/@types/node/dns/promises.d.ts +292 -36
  239. package/node_modules/@types/keyv/node_modules/@types/node/dns.d.ts +414 -97
  240. package/node_modules/@types/keyv/node_modules/@types/node/domain.d.ts +153 -9
  241. package/node_modules/@types/keyv/node_modules/@types/node/events.d.ts +560 -35
  242. package/node_modules/@types/keyv/node_modules/@types/node/fs/promises.d.ts +735 -279
  243. package/node_modules/@types/keyv/node_modules/@types/node/fs.d.ts +2351 -870
  244. package/node_modules/@types/keyv/node_modules/@types/node/globals.d.ts +24 -14
  245. package/node_modules/@types/keyv/node_modules/@types/node/http.d.ts +1020 -98
  246. package/node_modules/@types/keyv/node_modules/@types/node/http2.d.ts +1586 -466
  247. package/node_modules/@types/keyv/node_modules/@types/node/https.d.ts +366 -15
  248. package/node_modules/@types/keyv/node_modules/@types/node/index.d.ts +87 -13
  249. package/node_modules/@types/keyv/node_modules/@types/node/inspector.d.ts +577 -562
  250. package/node_modules/@types/keyv/node_modules/@types/node/module.d.ts +53 -12
  251. package/node_modules/@types/keyv/node_modules/@types/node/net.d.ts +558 -143
  252. package/node_modules/@types/keyv/node_modules/@types/node/os.d.ts +236 -26
  253. package/node_modules/@types/keyv/node_modules/@types/node/package.json +18 -15
  254. package/node_modules/@types/keyv/node_modules/@types/node/path.d.ts +9 -5
  255. package/node_modules/@types/keyv/node_modules/@types/node/perf_hooks.d.ts +290 -92
  256. package/node_modules/@types/keyv/node_modules/@types/node/process.d.ts +1170 -156
  257. package/node_modules/@types/keyv/node_modules/@types/node/punycode.d.ts +64 -26
  258. package/node_modules/@types/keyv/node_modules/@types/node/querystring.d.ts +107 -8
  259. package/node_modules/@types/keyv/node_modules/@types/node/readline.d.ts +426 -80
  260. package/node_modules/@types/keyv/node_modules/@types/node/repl.d.ts +138 -113
  261. package/node_modules/@types/keyv/node_modules/@types/node/stream/consumers.d.ts +24 -0
  262. package/node_modules/@types/keyv/node_modules/@types/node/stream/promises.d.ts +15 -44
  263. package/node_modules/@types/keyv/node_modules/@types/node/stream/web.d.ts +6 -0
  264. package/node_modules/@types/keyv/node_modules/@types/node/stream.d.ts +979 -226
  265. package/node_modules/@types/keyv/node_modules/@types/node/string_decoder.d.ts +57 -1
  266. package/node_modules/@types/keyv/node_modules/@types/node/timers/promises.d.ts +53 -10
  267. package/node_modules/@types/keyv/node_modules/@types/node/timers.d.ts +32 -39
  268. package/node_modules/@types/keyv/node_modules/@types/node/tls.d.ts +449 -227
  269. package/node_modules/@types/keyv/node_modules/@types/node/trace_events.d.ts +107 -11
  270. package/node_modules/@types/keyv/node_modules/@types/node/tty.d.ts +160 -24
  271. package/node_modules/@types/keyv/node_modules/@types/node/url.d.ts +703 -32
  272. package/node_modules/@types/keyv/node_modules/@types/node/util.d.ts +1375 -76
  273. package/node_modules/@types/keyv/node_modules/@types/node/v8.d.ts +255 -79
  274. package/node_modules/@types/keyv/node_modules/@types/node/vm.d.ts +384 -33
  275. package/node_modules/@types/keyv/node_modules/@types/node/wasi.d.ts +92 -24
  276. package/node_modules/@types/keyv/node_modules/@types/node/worker_threads.d.ts +501 -138
  277. package/node_modules/@types/keyv/node_modules/@types/node/zlib.d.ts +216 -64
  278. package/node_modules/@types/keyv/package.json +3 -3
  279. package/node_modules/@types/responselike/node_modules/@types/node/README.md +3 -3
  280. package/node_modules/@types/responselike/node_modules/@types/node/assert/strict.d.ts +3 -4
  281. package/node_modules/@types/responselike/node_modules/@types/node/assert.d.ts +823 -40
  282. package/node_modules/@types/responselike/node_modules/@types/node/async_hooks.d.ts +359 -90
  283. package/node_modules/@types/responselike/node_modules/@types/node/buffer.d.ts +1895 -113
  284. package/node_modules/@types/responselike/node_modules/@types/node/child_process.d.ts +1070 -240
  285. package/node_modules/@types/responselike/node_modules/@types/node/cluster.d.ts +331 -104
  286. package/node_modules/@types/responselike/node_modules/@types/node/console.d.ts +310 -37
  287. package/node_modules/@types/responselike/node_modules/@types/node/constants.d.ts +3 -3
  288. package/node_modules/@types/responselike/node_modules/@types/node/crypto.d.ts +2406 -742
  289. package/node_modules/@types/responselike/node_modules/@types/node/dgram.d.ts +458 -58
  290. package/node_modules/@types/responselike/node_modules/@types/node/diagnostics_channel.d.ts +128 -0
  291. package/node_modules/@types/responselike/node_modules/@types/node/dns/promises.d.ts +292 -36
  292. package/node_modules/@types/responselike/node_modules/@types/node/dns.d.ts +414 -97
  293. package/node_modules/@types/responselike/node_modules/@types/node/domain.d.ts +153 -9
  294. package/node_modules/@types/responselike/node_modules/@types/node/events.d.ts +560 -35
  295. package/node_modules/@types/responselike/node_modules/@types/node/fs/promises.d.ts +735 -279
  296. package/node_modules/@types/responselike/node_modules/@types/node/fs.d.ts +2351 -870
  297. package/node_modules/@types/responselike/node_modules/@types/node/globals.d.ts +24 -14
  298. package/node_modules/@types/responselike/node_modules/@types/node/http.d.ts +1020 -98
  299. package/node_modules/@types/responselike/node_modules/@types/node/http2.d.ts +1586 -466
  300. package/node_modules/@types/responselike/node_modules/@types/node/https.d.ts +366 -15
  301. package/node_modules/@types/responselike/node_modules/@types/node/index.d.ts +87 -13
  302. package/node_modules/@types/responselike/node_modules/@types/node/inspector.d.ts +577 -562
  303. package/node_modules/@types/responselike/node_modules/@types/node/module.d.ts +53 -12
  304. package/node_modules/@types/responselike/node_modules/@types/node/net.d.ts +558 -143
  305. package/node_modules/@types/responselike/node_modules/@types/node/os.d.ts +236 -26
  306. package/node_modules/@types/responselike/node_modules/@types/node/package.json +18 -15
  307. package/node_modules/@types/responselike/node_modules/@types/node/path.d.ts +9 -5
  308. package/node_modules/@types/responselike/node_modules/@types/node/perf_hooks.d.ts +290 -92
  309. package/node_modules/@types/responselike/node_modules/@types/node/process.d.ts +1170 -156
  310. package/node_modules/@types/responselike/node_modules/@types/node/punycode.d.ts +64 -26
  311. package/node_modules/@types/responselike/node_modules/@types/node/querystring.d.ts +107 -8
  312. package/node_modules/@types/responselike/node_modules/@types/node/readline.d.ts +426 -80
  313. package/node_modules/@types/responselike/node_modules/@types/node/repl.d.ts +138 -113
  314. package/node_modules/@types/responselike/node_modules/@types/node/stream/consumers.d.ts +24 -0
  315. package/node_modules/@types/responselike/node_modules/@types/node/stream/promises.d.ts +15 -44
  316. package/node_modules/@types/responselike/node_modules/@types/node/stream/web.d.ts +6 -0
  317. package/node_modules/@types/responselike/node_modules/@types/node/stream.d.ts +979 -226
  318. package/node_modules/@types/responselike/node_modules/@types/node/string_decoder.d.ts +57 -1
  319. package/node_modules/@types/responselike/node_modules/@types/node/timers/promises.d.ts +53 -10
  320. package/node_modules/@types/responselike/node_modules/@types/node/timers.d.ts +32 -39
  321. package/node_modules/@types/responselike/node_modules/@types/node/tls.d.ts +449 -227
  322. package/node_modules/@types/responselike/node_modules/@types/node/trace_events.d.ts +107 -11
  323. package/node_modules/@types/responselike/node_modules/@types/node/tty.d.ts +160 -24
  324. package/node_modules/@types/responselike/node_modules/@types/node/url.d.ts +703 -32
  325. package/node_modules/@types/responselike/node_modules/@types/node/util.d.ts +1375 -76
  326. package/node_modules/@types/responselike/node_modules/@types/node/v8.d.ts +255 -79
  327. package/node_modules/@types/responselike/node_modules/@types/node/vm.d.ts +384 -33
  328. package/node_modules/@types/responselike/node_modules/@types/node/wasi.d.ts +92 -24
  329. package/node_modules/@types/responselike/node_modules/@types/node/worker_threads.d.ts +501 -138
  330. package/node_modules/@types/responselike/node_modules/@types/node/zlib.d.ts +216 -64
  331. package/node_modules/axios/CHANGELOG.md +98 -8
  332. package/node_modules/axios/README.md +74 -6
  333. package/node_modules/axios/SECURITY.md +5 -0
  334. package/node_modules/axios/dist/axios.js +2028 -1591
  335. package/node_modules/axios/dist/axios.map +1 -1
  336. package/node_modules/axios/dist/axios.min.js +2 -2
  337. package/node_modules/axios/dist/axios.min.map +1 -1
  338. package/node_modules/axios/index.d.ts +8 -1
  339. package/node_modules/axios/lib/adapters/http.js +33 -5
  340. package/node_modules/axios/lib/adapters/xhr.js +35 -25
  341. package/node_modules/axios/lib/core/Axios.js +60 -7
  342. package/node_modules/axios/lib/core/InterceptorManager.js +4 -2
  343. package/node_modules/axios/lib/core/README.md +1 -0
  344. package/node_modules/axios/lib/core/dispatchRequest.js +6 -3
  345. package/node_modules/axios/lib/core/transformData.js +3 -1
  346. package/node_modules/axios/lib/defaults.js +43 -7
  347. package/node_modules/axios/lib/helpers/validator.js +105 -0
  348. package/node_modules/axios/lib/utils.js +1 -3
  349. package/node_modules/axios/package.json +19 -21
  350. package/node_modules/follow-redirects/debug.js +2 -1
  351. package/node_modules/follow-redirects/index.js +14 -7
  352. package/node_modules/follow-redirects/package.json +1 -1
  353. package/node_modules/mime-db/HISTORY.md +6 -0
  354. package/node_modules/mime-db/db.json +39 -1
  355. package/node_modules/mime-db/package.json +4 -4
  356. package/node_modules/mime-types/HISTORY.md +7 -0
  357. package/node_modules/mime-types/package.json +4 -4
  358. package/node_modules/{http2-wrapper/node_modules/quick-lru → quick-lru}/index.d.ts +0 -0
  359. package/node_modules/{http2-wrapper/node_modules/quick-lru → quick-lru}/index.js +0 -0
  360. package/node_modules/{http2-wrapper/node_modules/quick-lru → quick-lru}/license +0 -0
  361. package/node_modules/{http2-wrapper/node_modules/quick-lru → quick-lru}/package.json +0 -0
  362. package/node_modules/{http2-wrapper/node_modules/quick-lru → quick-lru}/readme.md +0 -0
  363. package/node_modules/resolve-alpn/README.md +8 -1
  364. package/node_modules/resolve-alpn/index.js +14 -4
  365. package/node_modules/resolve-alpn/package.json +1 -1
  366. package/package.json +15 -15
  367. package/node_modules/@slack/logger/node_modules/@types/node/base.d.ts +0 -19
  368. package/node_modules/@slack/logger/node_modules/@types/node/diagnostic_channel.d.ts +0 -38
  369. package/node_modules/@slack/logger/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
  370. package/node_modules/@slack/logger/node_modules/@types/node/ts3.6/base.d.ts +0 -67
  371. package/node_modules/@slack/logger/node_modules/@types/node/ts3.6/index.d.ts +0 -7
  372. package/node_modules/@slack/web-api/node_modules/@types/node/base.d.ts +0 -19
  373. package/node_modules/@slack/web-api/node_modules/@types/node/diagnostic_channel.d.ts +0 -38
  374. package/node_modules/@slack/web-api/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
  375. package/node_modules/@slack/web-api/node_modules/@types/node/ts3.6/base.d.ts +0 -67
  376. package/node_modules/@slack/web-api/node_modules/@types/node/ts3.6/index.d.ts +0 -7
  377. package/node_modules/@types/cacheable-request/node_modules/@types/node/base.d.ts +0 -19
  378. package/node_modules/@types/cacheable-request/node_modules/@types/node/diagnostic_channel.d.ts +0 -38
  379. package/node_modules/@types/cacheable-request/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
  380. package/node_modules/@types/cacheable-request/node_modules/@types/node/ts3.6/base.d.ts +0 -67
  381. package/node_modules/@types/cacheable-request/node_modules/@types/node/ts3.6/index.d.ts +0 -7
  382. package/node_modules/@types/is-stream/node_modules/@types/node/base.d.ts +0 -19
  383. package/node_modules/@types/is-stream/node_modules/@types/node/diagnostic_channel.d.ts +0 -38
  384. package/node_modules/@types/is-stream/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
  385. package/node_modules/@types/is-stream/node_modules/@types/node/ts3.6/base.d.ts +0 -67
  386. package/node_modules/@types/is-stream/node_modules/@types/node/ts3.6/index.d.ts +0 -7
  387. package/node_modules/@types/keyv/node_modules/@types/node/base.d.ts +0 -19
  388. package/node_modules/@types/keyv/node_modules/@types/node/diagnostic_channel.d.ts +0 -38
  389. package/node_modules/@types/keyv/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
  390. package/node_modules/@types/keyv/node_modules/@types/node/ts3.6/base.d.ts +0 -67
  391. package/node_modules/@types/keyv/node_modules/@types/node/ts3.6/index.d.ts +0 -7
  392. package/node_modules/@types/responselike/node_modules/@types/node/base.d.ts +0 -19
  393. package/node_modules/@types/responselike/node_modules/@types/node/diagnostic_channel.d.ts +0 -38
  394. package/node_modules/@types/responselike/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
  395. package/node_modules/@types/responselike/node_modules/@types/node/ts3.6/base.d.ts +0 -67
  396. package/node_modules/@types/responselike/node_modules/@types/node/ts3.6/index.d.ts +0 -7
@@ -1,7 +1,23 @@
1
+ /**
2
+ * The `crypto` module provides cryptographic functionality that includes a set of
3
+ * wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions.
4
+ *
5
+ * ```js
6
+ * const { createHmac } = await import('crypto');
7
+ *
8
+ * const secret = 'abcdefg';
9
+ * const hash = createHmac('sha256', secret)
10
+ * .update('I love cupcakes')
11
+ * .digest('hex');
12
+ * console.log(hash);
13
+ * // Prints:
14
+ * // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
15
+ * ```
16
+ * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/crypto.js)
17
+ */
1
18
  declare module 'crypto' {
2
- import * as stream from 'stream';
3
- import { PeerCertificate } from 'tls';
4
-
19
+ import * as stream from 'node:stream';
20
+ import { PeerCertificate } from 'node:tls';
5
21
  interface Certificate {
6
22
  /**
7
23
  * @deprecated
@@ -28,10 +44,9 @@ declare module 'crypto' {
28
44
  }
29
45
  const Certificate: Certificate & {
30
46
  /** @deprecated since v14.9.0 - Use static methods of `crypto.Certificate` instead. */
31
- new(): Certificate;
47
+ new (): Certificate;
32
48
  /** @deprecated since v14.9.0 - Use static methods of `crypto.Certificate` instead. */
33
49
  (): Certificate;
34
-
35
50
  /**
36
51
  * @param spkac
37
52
  * @returns The challenge component of the `spkac` data structure,
@@ -52,11 +67,9 @@ declare module 'crypto' {
52
67
  */
53
68
  verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
54
69
  };
55
-
56
70
  namespace constants {
57
71
  // https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants
58
72
  const OPENSSL_VERSION_NUMBER: number;
59
-
60
73
  /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
61
74
  const SSL_OP_ALL: number;
62
75
  /** 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. */
@@ -106,7 +119,6 @@ declare module 'crypto' {
106
119
  const SSL_OP_TLS_D5_BUG: number;
107
120
  /** Instructs OpenSSL to disable version rollback attack detection. */
108
121
  const SSL_OP_TLS_ROLLBACK_BUG: number;
109
-
110
122
  const ENGINE_METHOD_RSA: number;
111
123
  const ENGINE_METHOD_DSA: number;
112
124
  const ENGINE_METHOD_DH: number;
@@ -118,14 +130,11 @@ declare module 'crypto' {
118
130
  const ENGINE_METHOD_PKEY_ASN1_METHS: number;
119
131
  const ENGINE_METHOD_ALL: number;
120
132
  const ENGINE_METHOD_NONE: number;
121
-
122
133
  const DH_CHECK_P_NOT_SAFE_PRIME: number;
123
134
  const DH_CHECK_P_NOT_PRIME: number;
124
135
  const DH_UNABLE_TO_CHECK_GENERATOR: number;
125
136
  const DH_NOT_SUITABLE_GENERATOR: number;
126
-
127
137
  const ALPN_ENABLED: number;
128
-
129
138
  const RSA_PKCS1_PADDING: number;
130
139
  const RSA_SSLV23_PADDING: number;
131
140
  const RSA_NO_PADDING: number;
@@ -138,17 +147,14 @@ declare module 'crypto' {
138
147
  const RSA_PSS_SALTLEN_MAX_SIGN: number;
139
148
  /** Causes the salt length for RSA_PKCS1_PSS_PADDING to be determined automatically when verifying a signature. */
140
149
  const RSA_PSS_SALTLEN_AUTO: number;
141
-
142
150
  const POINT_CONVERSION_COMPRESSED: number;
143
151
  const POINT_CONVERSION_UNCOMPRESSED: number;
144
152
  const POINT_CONVERSION_HYBRID: number;
145
-
146
153
  /** Specifies the built-in default cipher list used by Node.js (colon-separated values). */
147
154
  const defaultCoreCipherList: string;
148
155
  /** Specifies the active default cipher list used by the current Node.js process (colon-separated values). */
149
156
  const defaultCipherList: string;
150
157
  }
151
-
152
158
  interface HashOptions extends stream.TransformOptions {
153
159
  /**
154
160
  * For XOF hash functions such as `shake256`, the
@@ -156,40 +162,318 @@ declare module 'crypto' {
156
162
  */
157
163
  outputLength?: number | undefined;
158
164
  }
159
-
160
165
  /** @deprecated since v10.0.0 */
161
166
  const fips: boolean;
162
-
167
+ /**
168
+ * Creates and returns a `Hash` object that can be used to generate hash digests
169
+ * using the given `algorithm`. Optional `options` argument controls stream
170
+ * behavior. For XOF hash functions such as `'shake256'`, the `outputLength` option
171
+ * can be used to specify the desired output length in bytes.
172
+ *
173
+ * The `algorithm` is dependent on the available algorithms supported by the
174
+ * version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
175
+ * On recent releases of OpenSSL, `openssl list -digest-algorithms`(`openssl list-message-digest-algorithms` for older versions of OpenSSL) will
176
+ * display the available digest algorithms.
177
+ *
178
+ * Example: generating the sha256 sum of a file
179
+ *
180
+ * ```js
181
+ * import {
182
+ * createReadStream
183
+ * } from 'fs';
184
+ * import { argv } from 'process';
185
+ * const {
186
+ * createHash
187
+ * } = await import('crypto');
188
+ *
189
+ * const filename = argv[2];
190
+ *
191
+ * const hash = createHash('sha256');
192
+ *
193
+ * const input = createReadStream(filename);
194
+ * input.on('readable', () => {
195
+ * // Only one element is going to be produced by the
196
+ * // hash stream.
197
+ * const data = input.read();
198
+ * if (data)
199
+ * hash.update(data);
200
+ * else {
201
+ * console.log(`${hash.digest('hex')} ${filename}`);
202
+ * }
203
+ * });
204
+ * ```
205
+ * @since v0.1.92
206
+ * @param options `stream.transform` options
207
+ */
163
208
  function createHash(algorithm: string, options?: HashOptions): Hash;
209
+ /**
210
+ * Creates and returns an `Hmac` object that uses the given `algorithm` and `key`.
211
+ * Optional `options` argument controls stream behavior.
212
+ *
213
+ * The `algorithm` is dependent on the available algorithms supported by the
214
+ * version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
215
+ * On recent releases of OpenSSL, `openssl list -digest-algorithms`(`openssl list-message-digest-algorithms` for older versions of OpenSSL) will
216
+ * display the available digest algorithms.
217
+ *
218
+ * The `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is
219
+ * a `KeyObject`, its type must be `secret`.
220
+ *
221
+ * Example: generating the sha256 HMAC of a file
222
+ *
223
+ * ```js
224
+ * import {
225
+ * createReadStream
226
+ * } from 'fs';
227
+ * import { argv } from 'process';
228
+ * const {
229
+ * createHmac
230
+ * } = await import('crypto');
231
+ *
232
+ * const filename = argv[2];
233
+ *
234
+ * const hmac = createHmac('sha256', 'a secret');
235
+ *
236
+ * const input = createReadStream(filename);
237
+ * input.on('readable', () => {
238
+ * // Only one element is going to be produced by the
239
+ * // hash stream.
240
+ * const data = input.read();
241
+ * if (data)
242
+ * hmac.update(data);
243
+ * else {
244
+ * console.log(`${hmac.digest('hex')} ${filename}`);
245
+ * }
246
+ * });
247
+ * ```
248
+ * @since v0.1.94
249
+ * @param options `stream.transform` options
250
+ */
164
251
  function createHmac(algorithm: string, key: BinaryLike | KeyObject, options?: stream.TransformOptions): Hmac;
165
-
166
252
  // https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
167
253
  type BinaryToTextEncoding = 'base64' | 'hex';
168
254
  type CharacterEncoding = 'utf8' | 'utf-8' | 'utf16le' | 'latin1';
169
255
  type LegacyCharacterEncoding = 'ascii' | 'binary' | 'ucs2' | 'ucs-2';
170
-
171
256
  type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding;
172
-
173
257
  type ECDHKeyFormat = 'compressed' | 'uncompressed' | 'hybrid';
174
-
258
+ /**
259
+ * The `Hash` class is a utility for creating hash digests of data. It can be
260
+ * used in one of two ways:
261
+ *
262
+ * * As a `stream` that is both readable and writable, where data is written
263
+ * to produce a computed hash digest on the readable side, or
264
+ * * Using the `hash.update()` and `hash.digest()` methods to produce the
265
+ * computed hash.
266
+ *
267
+ * The {@link createHash} method is used to create `Hash` instances. `Hash`objects are not to be created directly using the `new` keyword.
268
+ *
269
+ * Example: Using `Hash` objects as streams:
270
+ *
271
+ * ```js
272
+ * const {
273
+ * createHash
274
+ * } = await import('crypto');
275
+ *
276
+ * const hash = createHash('sha256');
277
+ *
278
+ * hash.on('readable', () => {
279
+ * // Only one element is going to be produced by the
280
+ * // hash stream.
281
+ * const data = hash.read();
282
+ * if (data) {
283
+ * console.log(data.toString('hex'));
284
+ * // Prints:
285
+ * // 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50
286
+ * }
287
+ * });
288
+ *
289
+ * hash.write('some data to hash');
290
+ * hash.end();
291
+ * ```
292
+ *
293
+ * Example: Using `Hash` and piped streams:
294
+ *
295
+ * ```js
296
+ * import { createReadStream } from 'fs';
297
+ * import { stdout } from 'process';
298
+ * const { createHash } = await import('crypto');
299
+ *
300
+ * const hash = createHash('sha256');
301
+ *
302
+ * const input = createReadStream('test.js');
303
+ * input.pipe(hash).setEncoding('hex').pipe(stdout);
304
+ * ```
305
+ *
306
+ * Example: Using the `hash.update()` and `hash.digest()` methods:
307
+ *
308
+ * ```js
309
+ * const {
310
+ * createHash
311
+ * } = await import('crypto');
312
+ *
313
+ * const hash = createHash('sha256');
314
+ *
315
+ * hash.update('some data to hash');
316
+ * console.log(hash.digest('hex'));
317
+ * // Prints:
318
+ * // 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50
319
+ * ```
320
+ * @since v0.1.92
321
+ */
175
322
  class Hash extends stream.Transform {
176
323
  private constructor();
177
- copy(): Hash;
324
+ /**
325
+ * Creates a new `Hash` object that contains a deep copy of the internal state
326
+ * of the current `Hash` object.
327
+ *
328
+ * The optional `options` argument controls stream behavior. For XOF hash
329
+ * functions such as `'shake256'`, the `outputLength` option can be used to
330
+ * specify the desired output length in bytes.
331
+ *
332
+ * An error is thrown when an attempt is made to copy the `Hash` object after
333
+ * its `hash.digest()` method has been called.
334
+ *
335
+ * ```js
336
+ * // Calculate a rolling hash.
337
+ * const {
338
+ * createHash
339
+ * } = await import('crypto');
340
+ *
341
+ * const hash = createHash('sha256');
342
+ *
343
+ * hash.update('one');
344
+ * console.log(hash.copy().digest('hex'));
345
+ *
346
+ * hash.update('two');
347
+ * console.log(hash.copy().digest('hex'));
348
+ *
349
+ * hash.update('three');
350
+ * console.log(hash.copy().digest('hex'));
351
+ *
352
+ * // Etc.
353
+ * ```
354
+ * @since v13.1.0
355
+ * @param options `stream.transform` options
356
+ */
357
+ copy(options?: stream.TransformOptions): Hash;
358
+ /**
359
+ * Updates the hash content with the given `data`, the encoding of which
360
+ * is given in `inputEncoding`.
361
+ * If `encoding` is not provided, and the `data` is a string, an
362
+ * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored.
363
+ *
364
+ * This can be called many times with new data as it is streamed.
365
+ * @since v0.1.92
366
+ * @param inputEncoding The `encoding` of the `data` string.
367
+ */
178
368
  update(data: BinaryLike): Hash;
179
- update(data: string, input_encoding: Encoding): Hash;
369
+ update(data: string, inputEncoding: Encoding): Hash;
370
+ /**
371
+ * Calculates the digest of all of the data passed to be hashed (using the `hash.update()` method).
372
+ * If `encoding` is provided a string will be returned; otherwise
373
+ * a `Buffer` is returned.
374
+ *
375
+ * The `Hash` object can not be used again after `hash.digest()` method has been
376
+ * called. Multiple calls will cause an error to be thrown.
377
+ * @since v0.1.92
378
+ * @param encoding The `encoding` of the return value.
379
+ */
180
380
  digest(): Buffer;
181
381
  digest(encoding: BinaryToTextEncoding): string;
182
382
  }
383
+ /**
384
+ * The `Hmac` class is a utility for creating cryptographic HMAC digests. It can
385
+ * be used in one of two ways:
386
+ *
387
+ * * As a `stream` that is both readable and writable, where data is written
388
+ * to produce a computed HMAC digest on the readable side, or
389
+ * * Using the `hmac.update()` and `hmac.digest()` methods to produce the
390
+ * computed HMAC digest.
391
+ *
392
+ * The {@link createHmac} method is used to create `Hmac` instances. `Hmac`objects are not to be created directly using the `new` keyword.
393
+ *
394
+ * Example: Using `Hmac` objects as streams:
395
+ *
396
+ * ```js
397
+ * const {
398
+ * createHmac
399
+ * } = await import('crypto');
400
+ *
401
+ * const hmac = createHmac('sha256', 'a secret');
402
+ *
403
+ * hmac.on('readable', () => {
404
+ * // Only one element is going to be produced by the
405
+ * // hash stream.
406
+ * const data = hmac.read();
407
+ * if (data) {
408
+ * console.log(data.toString('hex'));
409
+ * // Prints:
410
+ * // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
411
+ * }
412
+ * });
413
+ *
414
+ * hmac.write('some data to hash');
415
+ * hmac.end();
416
+ * ```
417
+ *
418
+ * Example: Using `Hmac` and piped streams:
419
+ *
420
+ * ```js
421
+ * import { createReadStream } from 'fs';
422
+ * import { stdout } from 'process';
423
+ * const {
424
+ * createHmac
425
+ * } = await import('crypto');
426
+ *
427
+ * const hmac = createHmac('sha256', 'a secret');
428
+ *
429
+ * const input = createReadStream('test.js');
430
+ * input.pipe(hmac).pipe(stdout);
431
+ * ```
432
+ *
433
+ * Example: Using the `hmac.update()` and `hmac.digest()` methods:
434
+ *
435
+ * ```js
436
+ * const {
437
+ * createHmac
438
+ * } = await import('crypto');
439
+ *
440
+ * const hmac = createHmac('sha256', 'a secret');
441
+ *
442
+ * hmac.update('some data to hash');
443
+ * console.log(hmac.digest('hex'));
444
+ * // Prints:
445
+ * // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
446
+ * ```
447
+ * @since v0.1.94
448
+ */
183
449
  class Hmac extends stream.Transform {
184
450
  private constructor();
451
+ /**
452
+ * Updates the `Hmac` content with the given `data`, the encoding of which
453
+ * is given in `inputEncoding`.
454
+ * If `encoding` is not provided, and the `data` is a string, an
455
+ * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored.
456
+ *
457
+ * This can be called many times with new data as it is streamed.
458
+ * @since v0.1.94
459
+ * @param inputEncoding The `encoding` of the `data` string.
460
+ */
185
461
  update(data: BinaryLike): Hmac;
186
- update(data: string, input_encoding: Encoding): Hmac;
462
+ update(data: string, inputEncoding: Encoding): Hmac;
463
+ /**
464
+ * Calculates the HMAC digest of all of the data passed using `hmac.update()`.
465
+ * If `encoding` is
466
+ * provided a string is returned; otherwise a `Buffer` is returned;
467
+ *
468
+ * The `Hmac` object can not be used again after `hmac.digest()` has been
469
+ * called. Multiple calls to `hmac.digest()` will result in an error being thrown.
470
+ * @since v0.1.94
471
+ * @param encoding The `encoding` of the return value.
472
+ */
187
473
  digest(): Buffer;
188
474
  digest(encoding: BinaryToTextEncoding): string;
189
475
  }
190
-
191
476
  type KeyObjectType = 'secret' | 'public' | 'private';
192
-
193
477
  interface KeyExportOptions<T extends KeyFormat> {
194
478
  type: 'pkcs1' | 'spki' | 'pkcs8' | 'sec1';
195
479
  format: T;
@@ -215,7 +499,6 @@ declare module 'crypto' {
215
499
  y?: string | undefined;
216
500
  [key: string]: unknown;
217
501
  }
218
-
219
502
  interface AsymmetricKeyDetails {
220
503
  /**
221
504
  * Key size in bits (RSA, DSA).
@@ -225,6 +508,18 @@ declare module 'crypto' {
225
508
  * Public exponent (RSA).
226
509
  */
227
510
  publicExponent?: bigint | undefined;
511
+ /**
512
+ * Name of the message digest (RSA-PSS).
513
+ */
514
+ hashAlgorithm?: string | undefined;
515
+ /**
516
+ * Name of the message digest used by MGF1 (RSA-PSS).
517
+ */
518
+ mgf1HashAlgorithm?: string | undefined;
519
+ /**
520
+ * Minimal salt length in bytes (RSA-PSS).
521
+ */
522
+ saltLength?: number | undefined;
228
523
  /**
229
524
  * Size of q in bits (DSA).
230
525
  */
@@ -234,13 +529,62 @@ declare module 'crypto' {
234
529
  */
235
530
  namedCurve?: string | undefined;
236
531
  }
237
-
238
532
  interface JwkKeyExportOptions {
239
533
  format: 'jwk';
240
534
  }
241
-
535
+ /**
536
+ * Node.js uses a `KeyObject` class to represent a symmetric or asymmetric key,
537
+ * and each kind of key exposes different functions. The {@link createSecretKey}, {@link createPublicKey} and {@link createPrivateKey} methods are used to create `KeyObject`instances. `KeyObject`
538
+ * objects are not to be created directly using the `new`keyword.
539
+ *
540
+ * Most applications should consider using the new `KeyObject` API instead of
541
+ * passing keys as strings or `Buffer`s due to improved security features.
542
+ *
543
+ * `KeyObject` instances can be passed to other threads via `postMessage()`.
544
+ * The receiver obtains a cloned `KeyObject`, and the `KeyObject` does not need to
545
+ * be listed in the `transferList` argument.
546
+ * @since v11.6.0
547
+ */
242
548
  class KeyObject {
243
549
  private constructor();
550
+ /**
551
+ * Example: Converting a `CryptoKey` instance to a `KeyObject`:
552
+ *
553
+ * ```js
554
+ * const { webcrypto, KeyObject } = await import('crypto');
555
+ * const { subtle } = webcrypto;
556
+ *
557
+ * const key = await subtle.generateKey({
558
+ * name: 'HMAC',
559
+ * hash: 'SHA-256',
560
+ * length: 256
561
+ * }, true, ['sign', 'verify']);
562
+ *
563
+ * const keyObject = KeyObject.from(key);
564
+ * console.log(keyObject.symmetricKeySize);
565
+ * // Prints: 32 (symmetric key size in bytes)
566
+ * ```
567
+ * @since v15.0.0
568
+ */
569
+ static from(key: webcrypto.CryptoKey): KeyObject;
570
+ /**
571
+ * For asymmetric keys, this property represents the type of the key. Supported key
572
+ * types are:
573
+ *
574
+ * * `'rsa'` (OID 1.2.840.113549.1.1.1)
575
+ * * `'rsa-pss'` (OID 1.2.840.113549.1.1.10)
576
+ * * `'dsa'` (OID 1.2.840.10040.4.1)
577
+ * * `'ec'` (OID 1.2.840.10045.2.1)
578
+ * * `'x25519'` (OID 1.3.101.110)
579
+ * * `'x448'` (OID 1.3.101.111)
580
+ * * `'ed25519'` (OID 1.3.101.112)
581
+ * * `'ed448'` (OID 1.3.101.113)
582
+ * * `'dh'` (OID 1.2.840.113549.1.3.1)
583
+ *
584
+ * This property is `undefined` for unrecognized `KeyObject` types and symmetric
585
+ * keys.
586
+ * @since v11.6.0
587
+ */
244
588
  asymmetricKeyType?: KeyType | undefined;
245
589
  /**
246
590
  * For asymmetric keys, this property represents the size of the embedded key in
@@ -250,151 +594,629 @@ declare module 'crypto' {
250
594
  /**
251
595
  * This property exists only on asymmetric keys. Depending on the type of the key,
252
596
  * this object contains information about the key. None of the information obtained
253
- * through this property can be used to uniquely identify a key or to compromise the
254
- * security of the key.
597
+ * through this property can be used to uniquely identify a key or to compromise
598
+ * the security of the key.
599
+ *
600
+ * For RSA-PSS keys, if the key material contains a `RSASSA-PSS-params` sequence,
601
+ * the `hashAlgorithm`, `mgf1HashAlgorithm`, and `saltLength` properties will be
602
+ * set.
603
+ *
604
+ * Other key details might be exposed via this API using additional attributes.
605
+ * @since v15.7.0
255
606
  */
256
607
  asymmetricKeyDetails?: AsymmetricKeyDetails | undefined;
608
+ /**
609
+ * For symmetric keys, the following encoding options can be used:
610
+ *
611
+ * For public keys, the following encoding options can be used:
612
+ *
613
+ * For private keys, the following encoding options can be used:
614
+ *
615
+ * The result type depends on the selected encoding format, when PEM the
616
+ * result is a string, when DER it will be a buffer containing the data
617
+ * encoded as DER, when [JWK](https://tools.ietf.org/html/rfc7517) it will be an object.
618
+ *
619
+ * When [JWK](https://tools.ietf.org/html/rfc7517) encoding format was selected, all other encoding options are
620
+ * ignored.
621
+ *
622
+ * PKCS#1, SEC1, and PKCS#8 type keys can be encrypted by using a combination of
623
+ * 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
624
+ * encrypted by specifying a `cipher`when the PEM `format` is used. For maximum compatibility, use PKCS#8 for
625
+ * encrypted private keys. Since PKCS#8 defines its own
626
+ * encryption mechanism, PEM-level encryption is not supported when encrypting
627
+ * 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
628
+ * PKCS#1 and SEC1 encryption.
629
+ * @since v11.6.0
630
+ */
257
631
  export(options: KeyExportOptions<'pem'>): string | Buffer;
258
632
  export(options?: KeyExportOptions<'der'>): Buffer;
259
633
  export(options?: JwkKeyExportOptions): JsonWebKey;
634
+ /**
635
+ * For secret keys, this property represents the size of the key in bytes. This
636
+ * property is `undefined` for asymmetric keys.
637
+ * @since v11.6.0
638
+ */
260
639
  symmetricKeySize?: number | undefined;
640
+ /**
641
+ * Depending on the type of this `KeyObject`, this property is either`'secret'` for secret (symmetric) keys, `'public'` for public (asymmetric) keys
642
+ * or `'private'` for private (asymmetric) keys.
643
+ * @since v11.6.0
644
+ */
261
645
  type: KeyObjectType;
262
646
  }
263
-
264
647
  type CipherCCMTypes = 'aes-128-ccm' | 'aes-192-ccm' | 'aes-256-ccm' | 'chacha20-poly1305';
265
648
  type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
266
-
267
649
  type BinaryLike = string | NodeJS.ArrayBufferView;
268
-
269
650
  type CipherKey = BinaryLike | KeyObject;
270
-
271
651
  interface CipherCCMOptions extends stream.TransformOptions {
272
652
  authTagLength: number;
273
653
  }
274
654
  interface CipherGCMOptions extends stream.TransformOptions {
275
655
  authTagLength?: number | undefined;
276
656
  }
277
- /** @deprecated since v10.0.0 use `createCipheriv()` */
657
+ /**
658
+ * Creates and returns a `Cipher` object that uses the given `algorithm` and`password`.
659
+ *
660
+ * The `options` argument controls stream behavior and is optional except when a
661
+ * cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
662
+ * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to set the length of the authentication
663
+ * tag that will be returned by `getAuthTag()` and defaults to 16 bytes.
664
+ *
665
+ * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
666
+ * recent OpenSSL releases, `openssl list -cipher-algorithms`(`openssl list-cipher-algorithms` for older versions of OpenSSL) will
667
+ * display the available cipher algorithms.
668
+ *
669
+ * The `password` is used to derive the cipher key and initialization vector (IV).
670
+ * The value must be either a `'latin1'` encoded string, a `Buffer`, a`TypedArray`, or a `DataView`.
671
+ *
672
+ * The implementation of `crypto.createCipher()` derives keys using the OpenSSL
673
+ * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
674
+ * iteration, and no salt. The lack of salt allows dictionary attacks as the same
675
+ * password always creates the same key. The low iteration count and
676
+ * non-cryptographically secure hash algorithm allow passwords to be tested very
677
+ * rapidly.
678
+ *
679
+ * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) it is recommended that
680
+ * developers derive a key and IV on
681
+ * their own using {@link scrypt} and to use {@link createCipheriv} to create the `Cipher` object. Users should not use ciphers with counter mode
682
+ * (e.g. CTR, GCM, or CCM) in `crypto.createCipher()`. A warning is emitted when
683
+ * they are used in order to avoid the risk of IV reuse that causes
684
+ * vulnerabilities. For the case when IV is reused in GCM, see [Nonce-Disrespecting Adversaries](https://github.com/nonce-disrespect/nonce-disrespect) for details.
685
+ * @since v0.1.94
686
+ * @deprecated Since v10.0.0 - Use {@link createCipheriv} instead.
687
+ * @param options `stream.transform` options
688
+ */
278
689
  function createCipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): CipherCCM;
279
690
  /** @deprecated since v10.0.0 use `createCipheriv()` */
280
691
  function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM;
281
692
  /** @deprecated since v10.0.0 use `createCipheriv()` */
282
693
  function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher;
283
-
284
- function createCipheriv(
285
- algorithm: CipherCCMTypes,
286
- key: CipherKey,
287
- iv: BinaryLike | null,
288
- options: CipherCCMOptions,
289
- ): CipherCCM;
290
- function createCipheriv(
291
- algorithm: CipherGCMTypes,
292
- key: CipherKey,
293
- iv: BinaryLike | null,
294
- options?: CipherGCMOptions,
295
- ): CipherGCM;
296
- function createCipheriv(
297
- algorithm: string,
298
- key: CipherKey,
299
- iv: BinaryLike | null,
300
- options?: stream.TransformOptions,
301
- ): Cipher;
302
-
694
+ /**
695
+ * Creates and returns a `Cipher` object, with the given `algorithm`, `key` and
696
+ * initialization vector (`iv`).
697
+ *
698
+ * The `options` argument controls stream behavior and is optional except when a
699
+ * cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
700
+ * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to set the length of the authentication
701
+ * tag that will be returned by `getAuthTag()` and defaults to 16 bytes.
702
+ *
703
+ * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
704
+ * recent OpenSSL releases, `openssl list -cipher-algorithms`(`openssl list-cipher-algorithms` for older versions of OpenSSL) will
705
+ * display the available cipher algorithms.
706
+ *
707
+ * The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded
708
+ * strings,`Buffers`, `TypedArray`, or `DataView`s. The `key` may optionally be
709
+ * a `KeyObject` of type `secret`. If the cipher does not need
710
+ * an initialization vector, `iv` may be `null`.
711
+ *
712
+ * When passing strings for `key` or `iv`, please consider `caveats when using strings as inputs to cryptographic APIs`.
713
+ *
714
+ * Initialization vectors should be unpredictable and unique; ideally, they will be
715
+ * cryptographically random. They do not have to be secret: IVs are typically just
716
+ * added to ciphertext messages unencrypted. It may sound contradictory that
717
+ * something has to be unpredictable and unique, but does not have to be secret;
718
+ * remember that an attacker must not be able to predict ahead of time what a
719
+ * given IV will be.
720
+ * @since v0.1.94
721
+ * @param options `stream.transform` options
722
+ */
723
+ function createCipheriv(algorithm: CipherCCMTypes, key: CipherKey, iv: BinaryLike | null, options: CipherCCMOptions): CipherCCM;
724
+ function createCipheriv(algorithm: CipherGCMTypes, key: CipherKey, iv: BinaryLike | null, options?: CipherGCMOptions): CipherGCM;
725
+ function createCipheriv(algorithm: string, key: CipherKey, iv: BinaryLike | null, options?: stream.TransformOptions): Cipher;
726
+ /**
727
+ * Instances of the `Cipher` class are used to encrypt data. The class can be
728
+ * used in one of two ways:
729
+ *
730
+ * * As a `stream` that is both readable and writable, where plain unencrypted
731
+ * data is written to produce encrypted data on the readable side, or
732
+ * * Using the `cipher.update()` and `cipher.final()` methods to produce
733
+ * the encrypted data.
734
+ *
735
+ * The {@link createCipher} or {@link createCipheriv} methods are
736
+ * used to create `Cipher` instances. `Cipher` objects are not to be created
737
+ * directly using the `new` keyword.
738
+ *
739
+ * Example: Using `Cipher` objects as streams:
740
+ *
741
+ * ```js
742
+ * const {
743
+ * scrypt,
744
+ * randomFill,
745
+ * createCipheriv
746
+ * } = await import('crypto');
747
+ *
748
+ * const algorithm = 'aes-192-cbc';
749
+ * const password = 'Password used to generate key';
750
+ *
751
+ * // First, we'll generate the key. The key length is dependent on the algorithm.
752
+ * // In this case for aes192, it is 24 bytes (192 bits).
753
+ * scrypt(password, 'salt', 24, (err, key) => {
754
+ * if (err) throw err;
755
+ * // Then, we'll generate a random initialization vector
756
+ * randomFill(new Uint8Array(16), (err, iv) => {
757
+ * if (err) throw err;
758
+ *
759
+ * // Once we have the key and iv, we can create and use the cipher...
760
+ * const cipher = createCipheriv(algorithm, key, iv);
761
+ *
762
+ * let encrypted = '';
763
+ * cipher.setEncoding('hex');
764
+ *
765
+ * cipher.on('data', (chunk) => encrypted += chunk);
766
+ * cipher.on('end', () => console.log(encrypted));
767
+ *
768
+ * cipher.write('some clear text data');
769
+ * cipher.end();
770
+ * });
771
+ * });
772
+ * ```
773
+ *
774
+ * Example: Using `Cipher` and piped streams:
775
+ *
776
+ * ```js
777
+ * import {
778
+ * createReadStream,
779
+ * createWriteStream,
780
+ * } from 'fs';
781
+ *
782
+ * import {
783
+ * pipeline
784
+ * } from 'stream';
785
+ *
786
+ * const {
787
+ * scrypt,
788
+ * randomFill,
789
+ * createCipheriv
790
+ * } = await import('crypto');
791
+ *
792
+ * const algorithm = 'aes-192-cbc';
793
+ * const password = 'Password used to generate key';
794
+ *
795
+ * // First, we'll generate the key. The key length is dependent on the algorithm.
796
+ * // In this case for aes192, it is 24 bytes (192 bits).
797
+ * scrypt(password, 'salt', 24, (err, key) => {
798
+ * if (err) throw err;
799
+ * // Then, we'll generate a random initialization vector
800
+ * randomFill(new Uint8Array(16), (err, iv) => {
801
+ * if (err) throw err;
802
+ *
803
+ * const cipher = createCipheriv(algorithm, key, iv);
804
+ *
805
+ * const input = createReadStream('test.js');
806
+ * const output = createWriteStream('test.enc');
807
+ *
808
+ * pipeline(input, cipher, output, (err) => {
809
+ * if (err) throw err;
810
+ * });
811
+ * });
812
+ * });
813
+ * ```
814
+ *
815
+ * Example: Using the `cipher.update()` and `cipher.final()` methods:
816
+ *
817
+ * ```js
818
+ * const {
819
+ * scrypt,
820
+ * randomFill,
821
+ * createCipheriv
822
+ * } = await import('crypto');
823
+ *
824
+ * const algorithm = 'aes-192-cbc';
825
+ * const password = 'Password used to generate key';
826
+ *
827
+ * // First, we'll generate the key. The key length is dependent on the algorithm.
828
+ * // In this case for aes192, it is 24 bytes (192 bits).
829
+ * scrypt(password, 'salt', 24, (err, key) => {
830
+ * if (err) throw err;
831
+ * // Then, we'll generate a random initialization vector
832
+ * randomFill(new Uint8Array(16), (err, iv) => {
833
+ * if (err) throw err;
834
+ *
835
+ * const cipher = createCipheriv(algorithm, key, iv);
836
+ *
837
+ * let encrypted = cipher.update('some clear text data', 'utf8', 'hex');
838
+ * encrypted += cipher.final('hex');
839
+ * console.log(encrypted);
840
+ * });
841
+ * });
842
+ * ```
843
+ * @since v0.1.94
844
+ */
303
845
  class Cipher extends stream.Transform {
304
846
  private constructor();
847
+ /**
848
+ * Updates the cipher with `data`. If the `inputEncoding` argument is given,
849
+ * the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`, `TypedArray`, or`DataView`. If `data` is a `Buffer`,
850
+ * `TypedArray`, or `DataView`, then`inputEncoding` is ignored.
851
+ *
852
+ * The `outputEncoding` specifies the output format of the enciphered
853
+ * data. If the `outputEncoding`is specified, a string using the specified encoding is returned. If no`outputEncoding` is provided, a `Buffer` is returned.
854
+ *
855
+ * The `cipher.update()` method can be called multiple times with new data until `cipher.final()` is called. Calling `cipher.update()` after `cipher.final()` will result in an error being
856
+ * thrown.
857
+ * @since v0.1.94
858
+ * @param inputEncoding The `encoding` of the data.
859
+ * @param outputEncoding The `encoding` of the return value.
860
+ */
305
861
  update(data: BinaryLike): Buffer;
306
- update(data: string, input_encoding: Encoding): Buffer;
307
- update(data: NodeJS.ArrayBufferView, input_encoding: undefined, output_encoding: Encoding): string;
308
- update(data: string, input_encoding: Encoding | undefined, output_encoding: Encoding): string;
862
+ update(data: string, inputEncoding: Encoding): Buffer;
863
+ update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
864
+ update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
865
+ /**
866
+ * Once the `cipher.final()` method has been called, the `Cipher` object can no
867
+ * longer be used to encrypt data. Attempts to call `cipher.final()` more than
868
+ * once will result in an error being thrown.
869
+ * @since v0.1.94
870
+ * @param outputEncoding The `encoding` of the return value.
871
+ * @return Any remaining enciphered contents. If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a {@link Buffer} is returned.
872
+ */
309
873
  final(): Buffer;
310
- final(output_encoding: BufferEncoding): string;
311
- setAutoPadding(auto_padding?: boolean): this;
312
- // getAuthTag(): Buffer;
313
- // setAAD(buffer: NodeJS.ArrayBufferView): this;
874
+ final(outputEncoding: BufferEncoding): string;
875
+ /**
876
+ * When using block encryption algorithms, the `Cipher` class will automatically
877
+ * add padding to the input data to the appropriate block size. To disable the
878
+ * default padding call `cipher.setAutoPadding(false)`.
879
+ *
880
+ * When `autoPadding` is `false`, the length of the entire input data must be a
881
+ * multiple of the cipher's block size or `cipher.final()` will throw an error.
882
+ * Disabling automatic padding is useful for non-standard padding, for instance
883
+ * using `0x0` instead of PKCS padding.
884
+ *
885
+ * The `cipher.setAutoPadding()` method must be called before `cipher.final()`.
886
+ * @since v0.7.1
887
+ * @param [autoPadding=true]
888
+ * @return for method chaining.
889
+ */
890
+ setAutoPadding(autoPadding?: boolean): this;
314
891
  }
315
892
  interface CipherCCM extends Cipher {
316
- setAAD(buffer: NodeJS.ArrayBufferView, options: { plaintextLength: number }): this;
893
+ setAAD(
894
+ buffer: NodeJS.ArrayBufferView,
895
+ options: {
896
+ plaintextLength: number;
897
+ }
898
+ ): this;
317
899
  getAuthTag(): Buffer;
318
900
  }
319
901
  interface CipherGCM extends Cipher {
320
- setAAD(buffer: NodeJS.ArrayBufferView, options?: { plaintextLength: number }): this;
902
+ setAAD(
903
+ buffer: NodeJS.ArrayBufferView,
904
+ options?: {
905
+ plaintextLength: number;
906
+ }
907
+ ): this;
321
908
  getAuthTag(): Buffer;
322
909
  }
323
- /** @deprecated since v10.0.0 use `createDecipheriv()` */
910
+ /**
911
+ * Creates and returns a `Decipher` object that uses the given `algorithm` and`password` (key).
912
+ *
913
+ * The `options` argument controls stream behavior and is optional except when a
914
+ * cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
915
+ * authentication tag in bytes, see `CCM mode`.
916
+ *
917
+ * The implementation of `crypto.createDecipher()` derives keys using the OpenSSL
918
+ * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
919
+ * iteration, and no salt. The lack of salt allows dictionary attacks as the same
920
+ * password always creates the same key. The low iteration count and
921
+ * non-cryptographically secure hash algorithm allow passwords to be tested very
922
+ * rapidly.
923
+ *
924
+ * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html) it is recommended that
925
+ * developers derive a key and IV on
926
+ * their own using {@link scrypt} and to use {@link createDecipheriv} to create the `Decipher` object.
927
+ * @since v0.1.94
928
+ * @deprecated Since v10.0.0 - Use {@link createDecipheriv} instead.
929
+ * @param options `stream.transform` options
930
+ */
324
931
  function createDecipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): DecipherCCM;
325
932
  /** @deprecated since v10.0.0 use `createDecipheriv()` */
326
933
  function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM;
327
934
  /** @deprecated since v10.0.0 use `createDecipheriv()` */
328
935
  function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher;
329
-
330
- function createDecipheriv(
331
- algorithm: CipherCCMTypes,
332
- key: CipherKey,
333
- iv: BinaryLike | null,
334
- options: CipherCCMOptions,
335
- ): DecipherCCM;
336
- function createDecipheriv(
337
- algorithm: CipherGCMTypes,
338
- key: CipherKey,
339
- iv: BinaryLike | null,
340
- options?: CipherGCMOptions,
341
- ): DecipherGCM;
342
- function createDecipheriv(
343
- algorithm: string,
344
- key: CipherKey,
345
- iv: BinaryLike | null,
346
- options?: stream.TransformOptions,
347
- ): Decipher;
348
-
936
+ /**
937
+ * Creates and returns a `Decipher` object that uses the given `algorithm`, `key`and initialization vector (`iv`).
938
+ *
939
+ * The `options` argument controls stream behavior and is optional except when a
940
+ * cipher in CCM or OCB mode is used (e.g. `'aes-128-ccm'`). In that case, the`authTagLength` option is required and specifies the length of the
941
+ * 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
942
+ * to those with the specified length.
943
+ *
944
+ * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
945
+ * recent OpenSSL releases, `openssl list -cipher-algorithms`(`openssl list-cipher-algorithms` for older versions of OpenSSL) will
946
+ * display the available cipher algorithms.
947
+ *
948
+ * The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector](https://en.wikipedia.org/wiki/Initialization_vector). Both arguments must be `'utf8'` encoded
949
+ * strings,`Buffers`, `TypedArray`, or `DataView`s. The `key` may optionally be
950
+ * a `KeyObject` of type `secret`. If the cipher does not need
951
+ * an initialization vector, `iv` may be `null`.
952
+ *
953
+ * When passing strings for `key` or `iv`, please consider `caveats when using strings as inputs to cryptographic APIs`.
954
+ *
955
+ * Initialization vectors should be unpredictable and unique; ideally, they will be
956
+ * cryptographically random. They do not have to be secret: IVs are typically just
957
+ * added to ciphertext messages unencrypted. It may sound contradictory that
958
+ * something has to be unpredictable and unique, but does not have to be secret;
959
+ * remember that an attacker must not be able to predict ahead of time what a given
960
+ * IV will be.
961
+ * @since v0.1.94
962
+ * @param options `stream.transform` options
963
+ */
964
+ function createDecipheriv(algorithm: CipherCCMTypes, key: CipherKey, iv: BinaryLike | null, options: CipherCCMOptions): DecipherCCM;
965
+ function createDecipheriv(algorithm: CipherGCMTypes, key: CipherKey, iv: BinaryLike | null, options?: CipherGCMOptions): DecipherGCM;
966
+ function createDecipheriv(algorithm: string, key: CipherKey, iv: BinaryLike | null, options?: stream.TransformOptions): Decipher;
967
+ /**
968
+ * Instances of the `Decipher` class are used to decrypt data. The class can be
969
+ * used in one of two ways:
970
+ *
971
+ * * As a `stream` that is both readable and writable, where plain encrypted
972
+ * data is written to produce unencrypted data on the readable side, or
973
+ * * Using the `decipher.update()` and `decipher.final()` methods to
974
+ * produce the unencrypted data.
975
+ *
976
+ * The {@link createDecipher} or {@link createDecipheriv} methods are
977
+ * used to create `Decipher` instances. `Decipher` objects are not to be created
978
+ * directly using the `new` keyword.
979
+ *
980
+ * Example: Using `Decipher` objects as streams:
981
+ *
982
+ * ```js
983
+ * import { Buffer } from 'buffer';
984
+ * const {
985
+ * scryptSync,
986
+ * createDecipheriv
987
+ * } = await import('crypto');
988
+ *
989
+ * const algorithm = 'aes-192-cbc';
990
+ * const password = 'Password used to generate key';
991
+ * // Key length is dependent on the algorithm. In this case for aes192, it is
992
+ * // 24 bytes (192 bits).
993
+ * // Use the async `crypto.scrypt()` instead.
994
+ * const key = scryptSync(password, 'salt', 24);
995
+ * // The IV is usually passed along with the ciphertext.
996
+ * const iv = Buffer.alloc(16, 0); // Initialization vector.
997
+ *
998
+ * const decipher = createDecipheriv(algorithm, key, iv);
999
+ *
1000
+ * let decrypted = '';
1001
+ * decipher.on('readable', () => {
1002
+ * while (null !== (chunk = decipher.read())) {
1003
+ * decrypted += chunk.toString('utf8');
1004
+ * }
1005
+ * });
1006
+ * decipher.on('end', () => {
1007
+ * console.log(decrypted);
1008
+ * // Prints: some clear text data
1009
+ * });
1010
+ *
1011
+ * // Encrypted with same algorithm, key and iv.
1012
+ * const encrypted =
1013
+ * 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';
1014
+ * decipher.write(encrypted, 'hex');
1015
+ * decipher.end();
1016
+ * ```
1017
+ *
1018
+ * Example: Using `Decipher` and piped streams:
1019
+ *
1020
+ * ```js
1021
+ * import {
1022
+ * createReadStream,
1023
+ * createWriteStream,
1024
+ * } from 'fs';
1025
+ * import { Buffer } from 'buffer';
1026
+ * const {
1027
+ * scryptSync,
1028
+ * createDecipheriv
1029
+ * } = await import('crypto');
1030
+ *
1031
+ * const algorithm = 'aes-192-cbc';
1032
+ * const password = 'Password used to generate key';
1033
+ * // Use the async `crypto.scrypt()` instead.
1034
+ * const key = scryptSync(password, 'salt', 24);
1035
+ * // The IV is usually passed along with the ciphertext.
1036
+ * const iv = Buffer.alloc(16, 0); // Initialization vector.
1037
+ *
1038
+ * const decipher = createDecipheriv(algorithm, key, iv);
1039
+ *
1040
+ * const input = createReadStream('test.enc');
1041
+ * const output = createWriteStream('test.js');
1042
+ *
1043
+ * input.pipe(decipher).pipe(output);
1044
+ * ```
1045
+ *
1046
+ * Example: Using the `decipher.update()` and `decipher.final()` methods:
1047
+ *
1048
+ * ```js
1049
+ * import { Buffer } from 'buffer';
1050
+ * const {
1051
+ * scryptSync,
1052
+ * createDecipheriv
1053
+ * } = await import('crypto');
1054
+ *
1055
+ * const algorithm = 'aes-192-cbc';
1056
+ * const password = 'Password used to generate key';
1057
+ * // Use the async `crypto.scrypt()` instead.
1058
+ * const key = scryptSync(password, 'salt', 24);
1059
+ * // The IV is usually passed along with the ciphertext.
1060
+ * const iv = Buffer.alloc(16, 0); // Initialization vector.
1061
+ *
1062
+ * const decipher = createDecipheriv(algorithm, key, iv);
1063
+ *
1064
+ * // Encrypted using same algorithm, key and iv.
1065
+ * const encrypted =
1066
+ * 'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';
1067
+ * let decrypted = decipher.update(encrypted, 'hex', 'utf8');
1068
+ * decrypted += decipher.final('utf8');
1069
+ * console.log(decrypted);
1070
+ * // Prints: some clear text data
1071
+ * ```
1072
+ * @since v0.1.94
1073
+ */
349
1074
  class Decipher extends stream.Transform {
350
1075
  private constructor();
1076
+ /**
1077
+ * Updates the decipher with `data`. If the `inputEncoding` argument is given,
1078
+ * the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`. If `data` is a `Buffer` then `inputEncoding` is
1079
+ * ignored.
1080
+ *
1081
+ * The `outputEncoding` specifies the output format of the enciphered
1082
+ * data. If the `outputEncoding`is specified, a string using the specified encoding is returned. If no`outputEncoding` is provided, a `Buffer` is returned.
1083
+ *
1084
+ * The `decipher.update()` method can be called multiple times with new data until `decipher.final()` is called. Calling `decipher.update()` after `decipher.final()` will result in an error
1085
+ * being thrown.
1086
+ * @since v0.1.94
1087
+ * @param inputEncoding The `encoding` of the `data` string.
1088
+ * @param outputEncoding The `encoding` of the return value.
1089
+ */
351
1090
  update(data: NodeJS.ArrayBufferView): Buffer;
352
- update(data: string, input_encoding: Encoding): Buffer;
353
- update(data: NodeJS.ArrayBufferView, input_encoding: undefined, output_encoding: Encoding): string;
354
- update(data: string, input_encoding: Encoding | undefined, output_encoding: Encoding): string;
1091
+ update(data: string, inputEncoding: Encoding): Buffer;
1092
+ update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
1093
+ update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
1094
+ /**
1095
+ * Once the `decipher.final()` method has been called, the `Decipher` object can
1096
+ * no longer be used to decrypt data. Attempts to call `decipher.final()` more
1097
+ * than once will result in an error being thrown.
1098
+ * @since v0.1.94
1099
+ * @param outputEncoding The `encoding` of the return value.
1100
+ * @return Any remaining deciphered contents. If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a {@link Buffer} is returned.
1101
+ */
355
1102
  final(): Buffer;
356
- final(output_encoding: BufferEncoding): string;
1103
+ final(outputEncoding: BufferEncoding): string;
1104
+ /**
1105
+ * When data has been encrypted without standard block padding, calling`decipher.setAutoPadding(false)` will disable automatic padding to prevent `decipher.final()` from checking for and
1106
+ * removing padding.
1107
+ *
1108
+ * Turning auto padding off will only work if the input data's length is a
1109
+ * multiple of the ciphers block size.
1110
+ *
1111
+ * The `decipher.setAutoPadding()` method must be called before `decipher.final()`.
1112
+ * @since v0.7.1
1113
+ * @param [autoPadding=true]
1114
+ * @return for method chaining.
1115
+ */
357
1116
  setAutoPadding(auto_padding?: boolean): this;
358
- // setAuthTag(tag: NodeJS.ArrayBufferView): this;
359
- // setAAD(buffer: NodeJS.ArrayBufferView): this;
360
1117
  }
361
1118
  interface DecipherCCM extends Decipher {
362
1119
  setAuthTag(buffer: NodeJS.ArrayBufferView): this;
363
- setAAD(buffer: NodeJS.ArrayBufferView, options: { plaintextLength: number }): this;
1120
+ setAAD(
1121
+ buffer: NodeJS.ArrayBufferView,
1122
+ options: {
1123
+ plaintextLength: number;
1124
+ }
1125
+ ): this;
364
1126
  }
365
1127
  interface DecipherGCM extends Decipher {
366
1128
  setAuthTag(buffer: NodeJS.ArrayBufferView): this;
367
- setAAD(buffer: NodeJS.ArrayBufferView, options?: { plaintextLength: number }): this;
1129
+ setAAD(
1130
+ buffer: NodeJS.ArrayBufferView,
1131
+ options?: {
1132
+ plaintextLength: number;
1133
+ }
1134
+ ): this;
368
1135
  }
369
-
370
1136
  interface PrivateKeyInput {
371
1137
  key: string | Buffer;
372
1138
  format?: KeyFormat | undefined;
373
1139
  type?: 'pkcs1' | 'pkcs8' | 'sec1' | undefined;
374
1140
  passphrase?: string | Buffer | undefined;
375
1141
  }
376
-
377
1142
  interface PublicKeyInput {
378
1143
  key: string | Buffer;
379
1144
  format?: KeyFormat | undefined;
380
1145
  type?: 'pkcs1' | 'spki' | undefined;
381
1146
  }
382
-
383
- function generateKey(type: 'hmac' | 'aes', options: {length: number}, callback: (err: Error | null, key: KeyObject) => void): void;
384
-
1147
+ /**
1148
+ * Asynchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`.
1149
+ *
1150
+ * ```js
1151
+ * const {
1152
+ * generateKey
1153
+ * } = await import('crypto');
1154
+ *
1155
+ * generateKey('hmac', { length: 64 }, (err, key) => {
1156
+ * if (err) throw err;
1157
+ * console.log(key.export().toString('hex')); // 46e..........620
1158
+ * });
1159
+ * ```
1160
+ * @since v15.0.0
1161
+ * @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`.
1162
+ */
1163
+ function generateKey(
1164
+ type: 'hmac' | 'aes',
1165
+ options: {
1166
+ length: number;
1167
+ },
1168
+ callback: (err: Error | null, key: KeyObject) => void
1169
+ ): void;
385
1170
  interface JsonWebKeyInput {
386
1171
  key: JsonWebKey;
387
1172
  format: 'jwk';
388
1173
  }
389
-
1174
+ /**
1175
+ * Creates and returns a new key object containing a private key. If `key` is a
1176
+ * string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key`must be an object with the properties described above.
1177
+ *
1178
+ * If the private key is encrypted, a `passphrase` must be specified. The length
1179
+ * of the passphrase is limited to 1024 bytes.
1180
+ * @since v11.6.0
1181
+ */
390
1182
  function createPrivateKey(key: PrivateKeyInput | string | Buffer | JsonWebKeyInput): KeyObject;
1183
+ /**
1184
+ * Creates and returns a new key object containing a public key. If `key` is a
1185
+ * 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;
1186
+ * otherwise, `key` must be an object with the properties described above.
1187
+ *
1188
+ * If the format is `'pem'`, the `'key'` may also be an X.509 certificate.
1189
+ *
1190
+ * Because public keys can be derived from private keys, a private key may be
1191
+ * passed instead of a public key. In that case, this function behaves as if {@link createPrivateKey} had been called, except that the type of the
1192
+ * returned `KeyObject` will be `'public'` and that the private key cannot be
1193
+ * extracted from the returned `KeyObject`. Similarly, if a `KeyObject` with type`'private'` is given, a new `KeyObject` with type `'public'` will be returned
1194
+ * and it will be impossible to extract the private key from the returned object.
1195
+ * @since v11.6.0
1196
+ */
391
1197
  function createPublicKey(key: PublicKeyInput | string | Buffer | KeyObject | JsonWebKeyInput): KeyObject;
1198
+ /**
1199
+ * Creates and returns a new key object containing a secret key for symmetric
1200
+ * encryption or `Hmac`.
1201
+ * @since v11.6.0
1202
+ * @param encoding The string encoding when `key` is a string.
1203
+ */
392
1204
  function createSecretKey(key: NodeJS.ArrayBufferView): KeyObject;
393
-
1205
+ function createSecretKey(key: string, encoding: BufferEncoding): KeyObject;
1206
+ /**
1207
+ * Creates and returns a `Sign` object that uses the given `algorithm`. Use {@link getHashes} to obtain the names of the available digest algorithms.
1208
+ * Optional `options` argument controls the `stream.Writable` behavior.
1209
+ *
1210
+ * In some cases, a `Sign` instance can be created using the name of a signature
1211
+ * algorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use
1212
+ * the corresponding digest algorithm. This does not work for all signature
1213
+ * algorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest
1214
+ * algorithm names.
1215
+ * @since v0.1.92
1216
+ * @param options `stream.Writable` options
1217
+ */
394
1218
  function createSign(algorithm: string, options?: stream.WritableOptions): Sign;
395
-
396
1219
  type DSAEncoding = 'der' | 'ieee-p1363';
397
-
398
1220
  interface SigningOptions {
399
1221
  /**
400
1222
  * @See crypto.constants.RSA_PKCS1_PADDING
@@ -403,132 +1225,670 @@ declare module 'crypto' {
403
1225
  saltLength?: number | undefined;
404
1226
  dsaEncoding?: DSAEncoding | undefined;
405
1227
  }
406
-
407
- interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions { }
1228
+ interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {}
408
1229
  interface SignKeyObjectInput extends SigningOptions {
409
1230
  key: KeyObject;
410
1231
  }
411
- interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions { }
1232
+ interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions {}
412
1233
  interface VerifyKeyObjectInput extends SigningOptions {
413
1234
  key: KeyObject;
414
1235
  }
415
-
416
1236
  type KeyLike = string | Buffer | KeyObject;
417
-
1237
+ /**
1238
+ * The `Sign` class is a utility for generating signatures. It can be used in one
1239
+ * of two ways:
1240
+ *
1241
+ * * As a writable `stream`, where data to be signed is written and the `sign.sign()` method is used to generate and return the signature, or
1242
+ * * Using the `sign.update()` and `sign.sign()` methods to produce the
1243
+ * signature.
1244
+ *
1245
+ * The {@link createSign} method is used to create `Sign` instances. The
1246
+ * argument is the string name of the hash function to use. `Sign` objects are not
1247
+ * to be created directly using the `new` keyword.
1248
+ *
1249
+ * Example: Using `Sign` and `Verify` objects as streams:
1250
+ *
1251
+ * ```js
1252
+ * const {
1253
+ * generateKeyPairSync,
1254
+ * createSign,
1255
+ * createVerify
1256
+ * } = await import('crypto');
1257
+ *
1258
+ * const { privateKey, publicKey } = generateKeyPairSync('ec', {
1259
+ * namedCurve: 'sect239k1'
1260
+ * });
1261
+ *
1262
+ * const sign = createSign('SHA256');
1263
+ * sign.write('some data to sign');
1264
+ * sign.end();
1265
+ * const signature = sign.sign(privateKey, 'hex');
1266
+ *
1267
+ * const verify = createVerify('SHA256');
1268
+ * verify.write('some data to sign');
1269
+ * verify.end();
1270
+ * console.log(verify.verify(publicKey, signature, 'hex'));
1271
+ * // Prints: true
1272
+ * ```
1273
+ *
1274
+ * Example: Using the `sign.update()` and `verify.update()` methods:
1275
+ *
1276
+ * ```js
1277
+ * const {
1278
+ * generateKeyPairSync,
1279
+ * createSign,
1280
+ * createVerify
1281
+ * } = await import('crypto');
1282
+ *
1283
+ * const { privateKey, publicKey } = generateKeyPairSync('rsa', {
1284
+ * modulusLength: 2048,
1285
+ * });
1286
+ *
1287
+ * const sign = createSign('SHA256');
1288
+ * sign.update('some data to sign');
1289
+ * sign.end();
1290
+ * const signature = sign.sign(privateKey);
1291
+ *
1292
+ * const verify = createVerify('SHA256');
1293
+ * verify.update('some data to sign');
1294
+ * verify.end();
1295
+ * console.log(verify.verify(publicKey, signature));
1296
+ * // Prints: true
1297
+ * ```
1298
+ * @since v0.1.92
1299
+ */
418
1300
  class Sign extends stream.Writable {
419
1301
  private constructor();
420
-
1302
+ /**
1303
+ * Updates the `Sign` content with the given `data`, the encoding of which
1304
+ * is given in `inputEncoding`.
1305
+ * If `encoding` is not provided, and the `data` is a string, an
1306
+ * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored.
1307
+ *
1308
+ * This can be called many times with new data as it is streamed.
1309
+ * @since v0.1.92
1310
+ * @param inputEncoding The `encoding` of the `data` string.
1311
+ */
421
1312
  update(data: BinaryLike): this;
422
- update(data: string, input_encoding: Encoding): this;
423
- sign(private_key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput): Buffer;
424
- sign(
425
- private_key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
426
- output_format: BinaryToTextEncoding,
427
- ): string;
1313
+ update(data: string, inputEncoding: Encoding): this;
1314
+ /**
1315
+ * Calculates the signature on all the data passed through using either `sign.update()` or `sign.write()`.
1316
+ *
1317
+ * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an
1318
+ * object, the following additional properties can be passed:
1319
+ *
1320
+ * If `outputEncoding` is provided a string is returned; otherwise a `Buffer` is returned.
1321
+ *
1322
+ * The `Sign` object can not be again used after `sign.sign()` method has been
1323
+ * called. Multiple calls to `sign.sign()` will result in an error being thrown.
1324
+ * @since v0.1.92
1325
+ */
1326
+ sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput): Buffer;
1327
+ sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput, outputFormat: BinaryToTextEncoding): string;
428
1328
  }
429
-
1329
+ /**
1330
+ * Creates and returns a `Verify` object that uses the given algorithm.
1331
+ * Use {@link getHashes} to obtain an array of names of the available
1332
+ * signing algorithms. Optional `options` argument controls the`stream.Writable` behavior.
1333
+ *
1334
+ * In some cases, a `Verify` instance can be created using the name of a signature
1335
+ * algorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use
1336
+ * the corresponding digest algorithm. This does not work for all signature
1337
+ * algorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest
1338
+ * algorithm names.
1339
+ * @since v0.1.92
1340
+ * @param options `stream.Writable` options
1341
+ */
430
1342
  function createVerify(algorithm: string, options?: stream.WritableOptions): Verify;
1343
+ /**
1344
+ * The `Verify` class is a utility for verifying signatures. It can be used in one
1345
+ * of two ways:
1346
+ *
1347
+ * * As a writable `stream` where written data is used to validate against the
1348
+ * supplied signature, or
1349
+ * * Using the `verify.update()` and `verify.verify()` methods to verify
1350
+ * the signature.
1351
+ *
1352
+ * The {@link createVerify} method is used to create `Verify` instances.`Verify` objects are not to be created directly using the `new` keyword.
1353
+ *
1354
+ * See `Sign` for examples.
1355
+ * @since v0.1.92
1356
+ */
431
1357
  class Verify extends stream.Writable {
432
1358
  private constructor();
433
-
1359
+ /**
1360
+ * Updates the `Verify` content with the given `data`, the encoding of which
1361
+ * is given in `inputEncoding`.
1362
+ * If `inputEncoding` is not provided, and the `data` is a string, an
1363
+ * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored.
1364
+ *
1365
+ * This can be called many times with new data as it is streamed.
1366
+ * @since v0.1.92
1367
+ * @param inputEncoding The `encoding` of the `data` string.
1368
+ */
434
1369
  update(data: BinaryLike): Verify;
435
- update(data: string, input_encoding: Encoding): Verify;
436
- verify(
437
- object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput,
438
- signature: NodeJS.ArrayBufferView,
439
- ): boolean;
440
- verify(
441
- object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput,
442
- signature: string,
443
- signature_format?: BinaryToTextEncoding,
444
- ): boolean;
445
- // https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format
446
- // The signature field accepts a TypedArray type, but it is only available starting ES2017
1370
+ update(data: string, inputEncoding: Encoding): Verify;
1371
+ /**
1372
+ * Verifies the provided data using the given `object` and `signature`.
1373
+ *
1374
+ * If `object` is not a `KeyObject`, this function behaves as if`object` had been passed to {@link createPublicKey}. If it is an
1375
+ * object, the following additional properties can be passed:
1376
+ *
1377
+ * The `signature` argument is the previously calculated signature for the data, in
1378
+ * the `signatureEncoding`.
1379
+ * If a `signatureEncoding` is specified, the `signature` is expected to be a
1380
+ * string; otherwise `signature` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
1381
+ *
1382
+ * The `verify` object can not be used again after `verify.verify()` has been
1383
+ * called. Multiple calls to `verify.verify()` will result in an error being
1384
+ * thrown.
1385
+ *
1386
+ * Because public keys can be derived from private keys, a private key may
1387
+ * be passed instead of a public key.
1388
+ * @since v0.1.92
1389
+ */
1390
+ verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean;
1391
+ verify(object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: string, signature_format?: BinaryToTextEncoding): boolean;
447
1392
  }
448
- function createDiffieHellman(prime_length: number, generator?: number | NodeJS.ArrayBufferView): DiffieHellman;
1393
+ /**
1394
+ * Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
1395
+ * optional specific `generator`.
1396
+ *
1397
+ * The `generator` argument can be a number, string, or `Buffer`. If`generator` is not specified, the value `2` is used.
1398
+ *
1399
+ * If `primeEncoding` is specified, `prime` is expected to be a string; otherwise
1400
+ * a `Buffer`, `TypedArray`, or `DataView` is expected.
1401
+ *
1402
+ * If `generatorEncoding` is specified, `generator` is expected to be a string;
1403
+ * otherwise a number, `Buffer`, `TypedArray`, or `DataView` is expected.
1404
+ * @since v0.11.12
1405
+ * @param primeEncoding The `encoding` of the `prime` string.
1406
+ * @param [generator=2]
1407
+ * @param generatorEncoding The `encoding` of the `generator` string.
1408
+ */
1409
+ function createDiffieHellman(primeLength: number, generator?: number | NodeJS.ArrayBufferView): DiffieHellman;
449
1410
  function createDiffieHellman(prime: NodeJS.ArrayBufferView): DiffieHellman;
450
- function createDiffieHellman(prime: string, prime_encoding: BinaryToTextEncoding): DiffieHellman;
451
- function createDiffieHellman(
452
- prime: string,
453
- prime_encoding: BinaryToTextEncoding,
454
- generator: number | NodeJS.ArrayBufferView,
455
- ): DiffieHellman;
456
- function createDiffieHellman(
457
- prime: string,
458
- prime_encoding: BinaryToTextEncoding,
459
- generator: string,
460
- generator_encoding: BinaryToTextEncoding,
461
- ): DiffieHellman;
1411
+ function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding): DiffieHellman;
1412
+ function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator: number | NodeJS.ArrayBufferView): DiffieHellman;
1413
+ function createDiffieHellman(prime: string, primeEncoding: BinaryToTextEncoding, generator: string, generatorEncoding: BinaryToTextEncoding): DiffieHellman;
1414
+ /**
1415
+ * The `DiffieHellman` class is a utility for creating Diffie-Hellman key
1416
+ * exchanges.
1417
+ *
1418
+ * Instances of the `DiffieHellman` class can be created using the {@link createDiffieHellman} function.
1419
+ *
1420
+ * ```js
1421
+ * import assert from 'assert';
1422
+ *
1423
+ * const {
1424
+ * createDiffieHellman
1425
+ * } = await import('crypto');
1426
+ *
1427
+ * // Generate Alice's keys...
1428
+ * const alice = createDiffieHellman(2048);
1429
+ * const aliceKey = alice.generateKeys();
1430
+ *
1431
+ * // Generate Bob's keys...
1432
+ * const bob = createDiffieHellman(alice.getPrime(), alice.getGenerator());
1433
+ * const bobKey = bob.generateKeys();
1434
+ *
1435
+ * // Exchange and generate the secret...
1436
+ * const aliceSecret = alice.computeSecret(bobKey);
1437
+ * const bobSecret = bob.computeSecret(aliceKey);
1438
+ *
1439
+ * // OK
1440
+ * assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
1441
+ * ```
1442
+ * @since v0.5.0
1443
+ */
462
1444
  class DiffieHellman {
463
1445
  private constructor();
1446
+ /**
1447
+ * Generates private and public Diffie-Hellman key values, and returns
1448
+ * the public key in the specified `encoding`. This key should be
1449
+ * transferred to the other party.
1450
+ * If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.
1451
+ * @since v0.5.0
1452
+ * @param encoding The `encoding` of the return value.
1453
+ */
464
1454
  generateKeys(): Buffer;
465
1455
  generateKeys(encoding: BinaryToTextEncoding): string;
466
- computeSecret(other_public_key: NodeJS.ArrayBufferView): Buffer;
467
- computeSecret(other_public_key: string, input_encoding: BinaryToTextEncoding): Buffer;
468
- computeSecret(other_public_key: NodeJS.ArrayBufferView, output_encoding: BinaryToTextEncoding): string;
469
- computeSecret(
470
- other_public_key: string,
471
- input_encoding: BinaryToTextEncoding,
472
- output_encoding: BinaryToTextEncoding,
473
- ): string;
1456
+ /**
1457
+ * Computes the shared secret using `otherPublicKey` as the other
1458
+ * party's public key and returns the computed shared secret. The supplied
1459
+ * key is interpreted using the specified `inputEncoding`, and secret is
1460
+ * encoded using specified `outputEncoding`.
1461
+ * If the `inputEncoding` is not
1462
+ * provided, `otherPublicKey` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
1463
+ *
1464
+ * If `outputEncoding` is given a string is returned; otherwise, a `Buffer` is returned.
1465
+ * @since v0.5.0
1466
+ * @param inputEncoding The `encoding` of an `otherPublicKey` string.
1467
+ * @param outputEncoding The `encoding` of the return value.
1468
+ */
1469
+ computeSecret(otherPublicKey: NodeJS.ArrayBufferView): Buffer;
1470
+ computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): Buffer;
1471
+ computeSecret(otherPublicKey: NodeJS.ArrayBufferView, outputEncoding: BinaryToTextEncoding): string;
1472
+ computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding, outputEncoding: BinaryToTextEncoding): string;
1473
+ /**
1474
+ * Returns the Diffie-Hellman prime in the specified `encoding`.
1475
+ * If `encoding` is provided a string is
1476
+ * returned; otherwise a `Buffer` is returned.
1477
+ * @since v0.5.0
1478
+ * @param encoding The `encoding` of the return value.
1479
+ */
474
1480
  getPrime(): Buffer;
475
1481
  getPrime(encoding: BinaryToTextEncoding): string;
1482
+ /**
1483
+ * Returns the Diffie-Hellman generator in the specified `encoding`.
1484
+ * If `encoding` is provided a string is
1485
+ * returned; otherwise a `Buffer` is returned.
1486
+ * @since v0.5.0
1487
+ * @param encoding The `encoding` of the return value.
1488
+ */
476
1489
  getGenerator(): Buffer;
477
1490
  getGenerator(encoding: BinaryToTextEncoding): string;
1491
+ /**
1492
+ * Returns the Diffie-Hellman public key in the specified `encoding`.
1493
+ * If `encoding` is provided a
1494
+ * string is returned; otherwise a `Buffer` is returned.
1495
+ * @since v0.5.0
1496
+ * @param encoding The `encoding` of the return value.
1497
+ */
478
1498
  getPublicKey(): Buffer;
479
1499
  getPublicKey(encoding: BinaryToTextEncoding): string;
1500
+ /**
1501
+ * Returns the Diffie-Hellman private key in the specified `encoding`.
1502
+ * If `encoding` is provided a
1503
+ * string is returned; otherwise a `Buffer` is returned.
1504
+ * @since v0.5.0
1505
+ * @param encoding The `encoding` of the return value.
1506
+ */
480
1507
  getPrivateKey(): Buffer;
481
1508
  getPrivateKey(encoding: BinaryToTextEncoding): string;
482
- setPublicKey(public_key: NodeJS.ArrayBufferView): void;
483
- setPublicKey(public_key: string, encoding: BufferEncoding): void;
484
- setPrivateKey(private_key: NodeJS.ArrayBufferView): void;
485
- setPrivateKey(private_key: string, encoding: BufferEncoding): void;
1509
+ /**
1510
+ * Sets the Diffie-Hellman public key. If the `encoding` argument is provided,`publicKey` is expected
1511
+ * to be a string. If no `encoding` is provided, `publicKey` is expected
1512
+ * to be a `Buffer`, `TypedArray`, or `DataView`.
1513
+ * @since v0.5.0
1514
+ * @param encoding The `encoding` of the `publicKey` string.
1515
+ */
1516
+ setPublicKey(publicKey: NodeJS.ArrayBufferView): void;
1517
+ setPublicKey(publicKey: string, encoding: BufferEncoding): void;
1518
+ /**
1519
+ * Sets the Diffie-Hellman private key. If the `encoding` argument is provided,`privateKey` is expected
1520
+ * to be a string. If no `encoding` is provided, `privateKey` is expected
1521
+ * to be a `Buffer`, `TypedArray`, or `DataView`.
1522
+ * @since v0.5.0
1523
+ * @param encoding The `encoding` of the `privateKey` string.
1524
+ */
1525
+ setPrivateKey(privateKey: NodeJS.ArrayBufferView): void;
1526
+ setPrivateKey(privateKey: string, encoding: BufferEncoding): void;
1527
+ /**
1528
+ * A bit field containing any warnings and/or errors resulting from a check
1529
+ * performed during initialization of the `DiffieHellman` object.
1530
+ *
1531
+ * The following values are valid for this property (as defined in `constants`module):
1532
+ *
1533
+ * * `DH_CHECK_P_NOT_SAFE_PRIME`
1534
+ * * `DH_CHECK_P_NOT_PRIME`
1535
+ * * `DH_UNABLE_TO_CHECK_GENERATOR`
1536
+ * * `DH_NOT_SUITABLE_GENERATOR`
1537
+ * @since v0.11.12
1538
+ */
486
1539
  verifyError: number;
487
1540
  }
488
- function getDiffieHellman(group_name: string): DiffieHellman;
489
- function pbkdf2(
490
- password: BinaryLike,
491
- salt: BinaryLike,
492
- iterations: number,
493
- keylen: number,
494
- digest: string,
495
- callback: (err: Error | null, derivedKey: Buffer) => void,
496
- ): void;
497
- function pbkdf2Sync(
498
- password: BinaryLike,
499
- salt: BinaryLike,
500
- iterations: number,
501
- keylen: number,
502
- digest: string,
503
- ): Buffer;
504
-
1541
+ /**
1542
+ * Creates a predefined `DiffieHellmanGroup` key exchange object. The
1543
+ * supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in [RFC 2412](https://www.rfc-editor.org/rfc/rfc2412.txt), but see `Caveats`) and `'modp14'`, `'modp15'`,`'modp16'`, `'modp17'`,
1544
+ * `'modp18'` (defined in [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt)). The
1545
+ * returned object mimics the interface of objects created by {@link createDiffieHellman}, but will not allow changing
1546
+ * the keys (with `diffieHellman.setPublicKey()`, for example). The
1547
+ * advantage of using this method is that the parties do not have to
1548
+ * generate nor exchange a group modulus beforehand, saving both processor
1549
+ * and communication time.
1550
+ *
1551
+ * Example (obtaining a shared secret):
1552
+ *
1553
+ * ```js
1554
+ * const {
1555
+ * getDiffieHellman
1556
+ * } = await import('crypto');
1557
+ * const alice = getDiffieHellman('modp14');
1558
+ * const bob = getDiffieHellman('modp14');
1559
+ *
1560
+ * alice.generateKeys();
1561
+ * bob.generateKeys();
1562
+ *
1563
+ * const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');
1564
+ * const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');
1565
+ *
1566
+ * // aliceSecret and bobSecret should be the same
1567
+ * console.log(aliceSecret === bobSecret);
1568
+ * ```
1569
+ * @since v0.7.5
1570
+ */
1571
+ function getDiffieHellman(groupName: string): DiffieHellman;
1572
+ /**
1573
+ * Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2)
1574
+ * implementation. A selected HMAC digest algorithm specified by `digest` is
1575
+ * applied to derive a key of the requested byte length (`keylen`) from the`password`, `salt` and `iterations`.
1576
+ *
1577
+ * The supplied `callback` function is called with two arguments: `err` and`derivedKey`. If an error occurs while deriving the key, `err` will be set;
1578
+ * otherwise `err` will be `null`. By default, the successfully generated`derivedKey` will be passed to the callback as a `Buffer`. An error will be
1579
+ * thrown if any of the input arguments specify invalid values or types.
1580
+ *
1581
+ * If `digest` is `null`, `'sha1'` will be used. This behavior is deprecated,
1582
+ * please specify a `digest` explicitly.
1583
+ *
1584
+ * The `iterations` argument must be a number set as high as possible. The
1585
+ * higher the number of iterations, the more secure the derived key will be,
1586
+ * but will take a longer amount of time to complete.
1587
+ *
1588
+ * The `salt` should be as unique as possible. It is recommended that a salt is
1589
+ * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
1590
+ *
1591
+ * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`.
1592
+ *
1593
+ * ```js
1594
+ * const {
1595
+ * pbkdf2
1596
+ * } = await import('crypto');
1597
+ *
1598
+ * pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {
1599
+ * if (err) throw err;
1600
+ * console.log(derivedKey.toString('hex')); // '3745e48...08d59ae'
1601
+ * });
1602
+ * ```
1603
+ *
1604
+ * The `crypto.DEFAULT_ENCODING` property can be used to change the way the`derivedKey` is passed to the callback. This property, however, has been
1605
+ * deprecated and use should be avoided.
1606
+ *
1607
+ * ```js
1608
+ * import crypto from 'crypto';
1609
+ * crypto.DEFAULT_ENCODING = 'hex';
1610
+ * crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, derivedKey) => {
1611
+ * if (err) throw err;
1612
+ * console.log(derivedKey); // '3745e48...aa39b34'
1613
+ * });
1614
+ * ```
1615
+ *
1616
+ * An array of supported digest functions can be retrieved using {@link getHashes}.
1617
+ *
1618
+ * This API uses libuv's threadpool, which can have surprising and
1619
+ * negative performance implications for some applications; see the `UV_THREADPOOL_SIZE` documentation for more information.
1620
+ * @since v0.5.5
1621
+ */
1622
+ function pbkdf2(password: BinaryLike, salt: BinaryLike, iterations: number, keylen: number, digest: string, callback: (err: Error | null, derivedKey: Buffer) => void): void;
1623
+ /**
1624
+ * Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2)
1625
+ * implementation. A selected HMAC digest algorithm specified by `digest` is
1626
+ * applied to derive a key of the requested byte length (`keylen`) from the`password`, `salt` and `iterations`.
1627
+ *
1628
+ * If an error occurs an `Error` will be thrown, otherwise the derived key will be
1629
+ * returned as a `Buffer`.
1630
+ *
1631
+ * If `digest` is `null`, `'sha1'` will be used. This behavior is deprecated,
1632
+ * please specify a `digest` explicitly.
1633
+ *
1634
+ * The `iterations` argument must be a number set as high as possible. The
1635
+ * higher the number of iterations, the more secure the derived key will be,
1636
+ * but will take a longer amount of time to complete.
1637
+ *
1638
+ * The `salt` should be as unique as possible. It is recommended that a salt is
1639
+ * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
1640
+ *
1641
+ * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`.
1642
+ *
1643
+ * ```js
1644
+ * const {
1645
+ * pbkdf2Sync
1646
+ * } = await import('crypto');
1647
+ *
1648
+ * const key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');
1649
+ * console.log(key.toString('hex')); // '3745e48...08d59ae'
1650
+ * ```
1651
+ *
1652
+ * The `crypto.DEFAULT_ENCODING` property may be used to change the way the`derivedKey` is returned. This property, however, is deprecated and use
1653
+ * should be avoided.
1654
+ *
1655
+ * ```js
1656
+ * import crypto from 'crypto';
1657
+ * crypto.DEFAULT_ENCODING = 'hex';
1658
+ * const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 512, 'sha512');
1659
+ * console.log(key); // '3745e48...aa39b34'
1660
+ * ```
1661
+ *
1662
+ * An array of supported digest functions can be retrieved using {@link getHashes}.
1663
+ * @since v0.9.3
1664
+ */
1665
+ function pbkdf2Sync(password: BinaryLike, salt: BinaryLike, iterations: number, keylen: number, digest: string): Buffer;
1666
+ /**
1667
+ * Generates cryptographically strong pseudorandom data. The `size` argument
1668
+ * is a number indicating the number of bytes to generate.
1669
+ *
1670
+ * If a `callback` function is provided, the bytes are generated asynchronously
1671
+ * and the `callback` function is invoked with two arguments: `err` and `buf`.
1672
+ * If an error occurs, `err` will be an `Error` object; otherwise it is `null`. The`buf` argument is a `Buffer` containing the generated bytes.
1673
+ *
1674
+ * ```js
1675
+ * // Asynchronous
1676
+ * const {
1677
+ * randomBytes
1678
+ * } = await import('crypto');
1679
+ *
1680
+ * randomBytes(256, (err, buf) => {
1681
+ * if (err) throw err;
1682
+ * console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`);
1683
+ * });
1684
+ * ```
1685
+ *
1686
+ * If the `callback` function is not provided, the random bytes are generated
1687
+ * synchronously and returned as a `Buffer`. An error will be thrown if
1688
+ * there is a problem generating the bytes.
1689
+ *
1690
+ * ```js
1691
+ * // Synchronous
1692
+ * const {
1693
+ * randomBytes
1694
+ * } = await import('crypto');
1695
+ *
1696
+ * const buf = randomBytes(256);
1697
+ * console.log(
1698
+ * `${buf.length} bytes of random data: ${buf.toString('hex')}`);
1699
+ * ```
1700
+ *
1701
+ * The `crypto.randomBytes()` method will not complete until there is
1702
+ * sufficient entropy available.
1703
+ * This should normally never take longer than a few milliseconds. The only time
1704
+ * when generating the random bytes may conceivably block for a longer period of
1705
+ * time is right after boot, when the whole system is still low on entropy.
1706
+ *
1707
+ * This API uses libuv's threadpool, which can have surprising and
1708
+ * negative performance implications for some applications; see the `UV_THREADPOOL_SIZE` documentation for more information.
1709
+ *
1710
+ * The asynchronous version of `crypto.randomBytes()` is carried out in a single
1711
+ * threadpool request. To minimize threadpool task length variation, partition
1712
+ * large `randomBytes` requests when doing so as part of fulfilling a client
1713
+ * request.
1714
+ * @since v0.5.8
1715
+ * @param size The number of bytes to generate. The `size` must not be larger than `2**31 - 1`.
1716
+ * @return if the `callback` function is not provided.
1717
+ */
505
1718
  function randomBytes(size: number): Buffer;
506
1719
  function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
507
1720
  function pseudoRandomBytes(size: number): Buffer;
508
1721
  function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
509
-
1722
+ /**
1723
+ * Return a random integer `n` such that `min <= n < max`. This
1724
+ * implementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias).
1725
+ *
1726
+ * The range (`max - min`) must be less than 248. `min` and `max` must
1727
+ * be [safe integers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
1728
+ *
1729
+ * If the `callback` function is not provided, the random integer is
1730
+ * generated synchronously.
1731
+ *
1732
+ * ```js
1733
+ * // Asynchronous
1734
+ * const {
1735
+ * randomInt
1736
+ * } = await import('crypto');
1737
+ *
1738
+ * randomInt(3, (err, n) => {
1739
+ * if (err) throw err;
1740
+ * console.log(`Random number chosen from (0, 1, 2): ${n}`);
1741
+ * });
1742
+ * ```
1743
+ *
1744
+ * ```js
1745
+ * // Synchronous
1746
+ * const {
1747
+ * randomInt
1748
+ * } = await import('crypto');
1749
+ *
1750
+ * const n = randomInt(3);
1751
+ * console.log(`Random number chosen from (0, 1, 2): ${n}`);
1752
+ * ```
1753
+ *
1754
+ * ```js
1755
+ * // With `min` argument
1756
+ * const {
1757
+ * randomInt
1758
+ * } = await import('crypto');
1759
+ *
1760
+ * const n = randomInt(1, 7);
1761
+ * console.log(`The dice rolled: ${n}`);
1762
+ * ```
1763
+ * @since v14.10.0, v12.19.0
1764
+ * @param [min=0] Start of random range (inclusive).
1765
+ * @param max End of random range (exclusive).
1766
+ * @param callback `function(err, n) {}`.
1767
+ */
510
1768
  function randomInt(max: number): number;
511
1769
  function randomInt(min: number, max: number): number;
512
1770
  function randomInt(max: number, callback: (err: Error | null, value: number) => void): void;
513
1771
  function randomInt(min: number, max: number, callback: (err: Error | null, value: number) => void): void;
514
-
1772
+ /**
1773
+ * Synchronous version of {@link randomFill}.
1774
+ *
1775
+ * ```js
1776
+ * import { Buffer } from 'buffer';
1777
+ * const { randomFillSync } = await import('crypto');
1778
+ *
1779
+ * const buf = Buffer.alloc(10);
1780
+ * console.log(randomFillSync(buf).toString('hex'));
1781
+ *
1782
+ * randomFillSync(buf, 5);
1783
+ * console.log(buf.toString('hex'));
1784
+ *
1785
+ * // The above is equivalent to the following:
1786
+ * randomFillSync(buf, 5, 5);
1787
+ * console.log(buf.toString('hex'));
1788
+ * ```
1789
+ *
1790
+ * Any `ArrayBuffer`, `TypedArray` or `DataView` instance may be passed as`buffer`.
1791
+ *
1792
+ * ```js
1793
+ * import { Buffer } from 'buffer';
1794
+ * const { randomFillSync } = await import('crypto');
1795
+ *
1796
+ * const a = new Uint32Array(10);
1797
+ * console.log(Buffer.from(randomFillSync(a).buffer,
1798
+ * a.byteOffset, a.byteLength).toString('hex'));
1799
+ *
1800
+ * const b = new DataView(new ArrayBuffer(10));
1801
+ * console.log(Buffer.from(randomFillSync(b).buffer,
1802
+ * b.byteOffset, b.byteLength).toString('hex'));
1803
+ *
1804
+ * const c = new ArrayBuffer(10);
1805
+ * console.log(Buffer.from(randomFillSync(c)).toString('hex'));
1806
+ * ```
1807
+ * @since v7.10.0, v6.13.0
1808
+ * @param buffer Must be supplied. The size of the provided `buffer` must not be larger than `2**31 - 1`.
1809
+ * @param [offset=0]
1810
+ * @param [size=buffer.length - offset]
1811
+ * @return The object passed as `buffer` argument.
1812
+ */
515
1813
  function randomFillSync<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number, size?: number): T;
516
- function randomFill<T extends NodeJS.ArrayBufferView>(
517
- buffer: T,
518
- callback: (err: Error | null, buf: T) => void,
519
- ): void;
520
- function randomFill<T extends NodeJS.ArrayBufferView>(
521
- buffer: T,
522
- offset: number,
523
- callback: (err: Error | null, buf: T) => void,
524
- ): void;
525
- function randomFill<T extends NodeJS.ArrayBufferView>(
526
- buffer: T,
527
- offset: number,
528
- size: number,
529
- callback: (err: Error | null, buf: T) => void,
530
- ): void;
531
-
1814
+ /**
1815
+ * This function is similar to {@link randomBytes} but requires the first
1816
+ * argument to be a `Buffer` that will be filled. It also
1817
+ * requires that a callback is passed in.
1818
+ *
1819
+ * If the `callback` function is not provided, an error will be thrown.
1820
+ *
1821
+ * ```js
1822
+ * import { Buffer } from 'buffer';
1823
+ * const { randomFill } = await import('crypto');
1824
+ *
1825
+ * const buf = Buffer.alloc(10);
1826
+ * randomFill(buf, (err, buf) => {
1827
+ * if (err) throw err;
1828
+ * console.log(buf.toString('hex'));
1829
+ * });
1830
+ *
1831
+ * randomFill(buf, 5, (err, buf) => {
1832
+ * if (err) throw err;
1833
+ * console.log(buf.toString('hex'));
1834
+ * });
1835
+ *
1836
+ * // The above is equivalent to the following:
1837
+ * randomFill(buf, 5, 5, (err, buf) => {
1838
+ * if (err) throw err;
1839
+ * console.log(buf.toString('hex'));
1840
+ * });
1841
+ * ```
1842
+ *
1843
+ * Any `ArrayBuffer`, `TypedArray`, or `DataView` instance may be passed as`buffer`.
1844
+ *
1845
+ * While this includes instances of `Float32Array` and `Float64Array`, this
1846
+ * function should not be used to generate random floating-point numbers. The
1847
+ * result may contain `+Infinity`, `-Infinity`, and `NaN`, and even if the array
1848
+ * contains finite numbers only, they are not drawn from a uniform random
1849
+ * distribution and have no meaningful lower or upper bounds.
1850
+ *
1851
+ * ```js
1852
+ * import { Buffer } from 'buffer';
1853
+ * const { randomFill } = await import('crypto');
1854
+ *
1855
+ * const a = new Uint32Array(10);
1856
+ * randomFill(a, (err, buf) => {
1857
+ * if (err) throw err;
1858
+ * console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
1859
+ * .toString('hex'));
1860
+ * });
1861
+ *
1862
+ * const b = new DataView(new ArrayBuffer(10));
1863
+ * randomFill(b, (err, buf) => {
1864
+ * if (err) throw err;
1865
+ * console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
1866
+ * .toString('hex'));
1867
+ * });
1868
+ *
1869
+ * const c = new ArrayBuffer(10);
1870
+ * randomFill(c, (err, buf) => {
1871
+ * if (err) throw err;
1872
+ * console.log(Buffer.from(buf).toString('hex'));
1873
+ * });
1874
+ * ```
1875
+ *
1876
+ * This API uses libuv's threadpool, which can have surprising and
1877
+ * negative performance implications for some applications; see the `UV_THREADPOOL_SIZE` documentation for more information.
1878
+ *
1879
+ * The asynchronous version of `crypto.randomFill()` is carried out in a single
1880
+ * threadpool request. To minimize threadpool task length variation, partition
1881
+ * large `randomFill` requests when doing so as part of fulfilling a client
1882
+ * request.
1883
+ * @since v7.10.0, v6.13.0
1884
+ * @param buffer Must be supplied. The size of the provided `buffer` must not be larger than `2**31 - 1`.
1885
+ * @param [offset=0]
1886
+ * @param [size=buffer.length - offset]
1887
+ * @param callback `function(err, buf) {}`.
1888
+ */
1889
+ function randomFill<T extends NodeJS.ArrayBufferView>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
1890
+ function randomFill<T extends NodeJS.ArrayBufferView>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
1891
+ function randomFill<T extends NodeJS.ArrayBufferView>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
532
1892
  interface ScryptOptions {
533
1893
  cost?: number | undefined;
534
1894
  blockSize?: number | undefined;
@@ -538,21 +1898,73 @@ declare module 'crypto' {
538
1898
  p?: number | undefined;
539
1899
  maxmem?: number | undefined;
540
1900
  }
541
- function scrypt(
542
- password: BinaryLike,
543
- salt: BinaryLike,
544
- keylen: number,
545
- callback: (err: Error | null, derivedKey: Buffer) => void,
546
- ): void;
547
- function scrypt(
548
- password: BinaryLike,
549
- salt: BinaryLike,
550
- keylen: number,
551
- options: ScryptOptions,
552
- callback: (err: Error | null, derivedKey: Buffer) => void,
553
- ): void;
1901
+ /**
1902
+ * Provides an asynchronous [scrypt](https://en.wikipedia.org/wiki/Scrypt) implementation. Scrypt is a password-based
1903
+ * key derivation function that is designed to be expensive computationally and
1904
+ * memory-wise in order to make brute-force attacks unrewarding.
1905
+ *
1906
+ * The `salt` should be as unique as possible. It is recommended that a salt is
1907
+ * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
1908
+ *
1909
+ * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`.
1910
+ *
1911
+ * The `callback` function is called with two arguments: `err` and `derivedKey`.`err` is an exception object when key derivation fails, otherwise `err` is`null`. `derivedKey` is passed to the
1912
+ * callback as a `Buffer`.
1913
+ *
1914
+ * An exception is thrown when any of the input arguments specify invalid values
1915
+ * or types.
1916
+ *
1917
+ * ```js
1918
+ * const {
1919
+ * scrypt
1920
+ * } = await import('crypto');
1921
+ *
1922
+ * // Using the factory defaults.
1923
+ * scrypt('password', 'salt', 64, (err, derivedKey) => {
1924
+ * if (err) throw err;
1925
+ * console.log(derivedKey.toString('hex')); // '3745e48...08d59ae'
1926
+ * });
1927
+ * // Using a custom N parameter. Must be a power of two.
1928
+ * scrypt('password', 'salt', 64, { N: 1024 }, (err, derivedKey) => {
1929
+ * if (err) throw err;
1930
+ * console.log(derivedKey.toString('hex')); // '3745e48...aa39b34'
1931
+ * });
1932
+ * ```
1933
+ * @since v10.5.0
1934
+ */
1935
+ function scrypt(password: BinaryLike, salt: BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void): void;
1936
+ function scrypt(password: BinaryLike, salt: BinaryLike, keylen: number, options: ScryptOptions, callback: (err: Error | null, derivedKey: Buffer) => void): void;
1937
+ /**
1938
+ * Provides a synchronous [scrypt](https://en.wikipedia.org/wiki/Scrypt) implementation. Scrypt is a password-based
1939
+ * key derivation function that is designed to be expensive computationally and
1940
+ * memory-wise in order to make brute-force attacks unrewarding.
1941
+ *
1942
+ * The `salt` should be as unique as possible. It is recommended that a salt is
1943
+ * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
1944
+ *
1945
+ * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`.
1946
+ *
1947
+ * An exception is thrown when key derivation fails, otherwise the derived key is
1948
+ * returned as a `Buffer`.
1949
+ *
1950
+ * An exception is thrown when any of the input arguments specify invalid values
1951
+ * or types.
1952
+ *
1953
+ * ```js
1954
+ * const {
1955
+ * scryptSync
1956
+ * } = await import('crypto');
1957
+ * // Using the factory defaults.
1958
+ *
1959
+ * const key1 = scryptSync('password', 'salt', 64);
1960
+ * console.log(key1.toString('hex')); // '3745e48...08d59ae'
1961
+ * // Using a custom N parameter. Must be a power of two.
1962
+ * const key2 = scryptSync('password', 'salt', 64, { N: 1024 });
1963
+ * console.log(key2.toString('hex')); // '3745e48...aa39b34'
1964
+ * ```
1965
+ * @since v10.5.0
1966
+ */
554
1967
  function scryptSync(password: BinaryLike, salt: BinaryLike, keylen: number, options?: ScryptOptions): Buffer;
555
-
556
1968
  interface RsaPublicKey {
557
1969
  key: KeyLike;
558
1970
  padding?: number | undefined;
@@ -567,114 +1979,320 @@ declare module 'crypto' {
567
1979
  oaepLabel?: NodeJS.TypedArray | undefined;
568
1980
  padding?: number | undefined;
569
1981
  }
1982
+ /**
1983
+ * Encrypts the content of `buffer` with `key` and returns a new `Buffer` with encrypted content. The returned data can be decrypted using
1984
+ * the corresponding private key, for example using {@link privateDecrypt}.
1985
+ *
1986
+ * If `key` is not a `KeyObject`, this function behaves as if`key` had been passed to {@link createPublicKey}. If it is an
1987
+ * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_OAEP_PADDING`.
1988
+ *
1989
+ * Because RSA public keys can be derived from private keys, a private key may
1990
+ * be passed instead of a public key.
1991
+ * @since v0.11.14
1992
+ */
570
1993
  function publicEncrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
1994
+ /**
1995
+ * Decrypts `buffer` with `key`.`buffer` was previously encrypted using
1996
+ * the corresponding private key, for example using {@link privateEncrypt}.
1997
+ *
1998
+ * If `key` is not a `KeyObject`, this function behaves as if`key` had been passed to {@link createPublicKey}. If it is an
1999
+ * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_PADDING`.
2000
+ *
2001
+ * Because RSA public keys can be derived from private keys, a private key may
2002
+ * be passed instead of a public key.
2003
+ * @since v1.1.0
2004
+ */
571
2005
  function publicDecrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
572
- function privateDecrypt(private_key: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
573
- function privateEncrypt(private_key: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
2006
+ /**
2007
+ * Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
2008
+ * the corresponding public key, for example using {@link publicEncrypt}.
2009
+ *
2010
+ * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an
2011
+ * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_OAEP_PADDING`.
2012
+ * @since v0.11.14
2013
+ */
2014
+ function privateDecrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
2015
+ /**
2016
+ * Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
2017
+ * the corresponding public key, for example using {@link publicDecrypt}.
2018
+ *
2019
+ * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an
2020
+ * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_PADDING`.
2021
+ * @since v1.1.0
2022
+ */
2023
+ function privateEncrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
2024
+ /**
2025
+ * ```js
2026
+ * const {
2027
+ * getCiphers
2028
+ * } = await import('crypto');
2029
+ *
2030
+ * console.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...]
2031
+ * ```
2032
+ * @since v0.9.3
2033
+ * @return An array with the names of the supported cipher algorithms.
2034
+ */
574
2035
  function getCiphers(): string[];
2036
+ /**
2037
+ * ```js
2038
+ * const {
2039
+ * getCurves
2040
+ * } = await import('crypto');
2041
+ *
2042
+ * console.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]
2043
+ * ```
2044
+ * @since v2.3.0
2045
+ * @return An array with the names of the supported elliptic curves.
2046
+ */
575
2047
  function getCurves(): string[];
2048
+ /**
2049
+ * @since v10.0.0
2050
+ * @return `1` if and only if a FIPS compliant crypto provider is currently in use, `0` otherwise. A future semver-major release may change the return type of this API to a {boolean}.
2051
+ */
576
2052
  function getFips(): 1 | 0;
2053
+ /**
2054
+ * ```js
2055
+ * const {
2056
+ * getHashes
2057
+ * } = await import('crypto');
2058
+ *
2059
+ * console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]
2060
+ * ```
2061
+ * @since v0.9.3
2062
+ * @return An array of the names of the supported hash algorithms, such as `'RSA-SHA256'`. Hash algorithms are also called "digest" algorithms.
2063
+ */
577
2064
  function getHashes(): string[];
2065
+ /**
2066
+ * The `ECDH` class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH)
2067
+ * key exchanges.
2068
+ *
2069
+ * Instances of the `ECDH` class can be created using the {@link createECDH} function.
2070
+ *
2071
+ * ```js
2072
+ * import assert from 'assert';
2073
+ *
2074
+ * const {
2075
+ * createECDH
2076
+ * } = await import('crypto');
2077
+ *
2078
+ * // Generate Alice's keys...
2079
+ * const alice = createECDH('secp521r1');
2080
+ * const aliceKey = alice.generateKeys();
2081
+ *
2082
+ * // Generate Bob's keys...
2083
+ * const bob = createECDH('secp521r1');
2084
+ * const bobKey = bob.generateKeys();
2085
+ *
2086
+ * // Exchange and generate the secret...
2087
+ * const aliceSecret = alice.computeSecret(bobKey);
2088
+ * const bobSecret = bob.computeSecret(aliceKey);
2089
+ *
2090
+ * assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
2091
+ * // OK
2092
+ * ```
2093
+ * @since v0.11.14
2094
+ */
578
2095
  class ECDH {
579
2096
  private constructor();
2097
+ /**
2098
+ * Converts the EC Diffie-Hellman public key specified by `key` and `curve` to the
2099
+ * format specified by `format`. The `format` argument specifies point encoding
2100
+ * and can be `'compressed'`, `'uncompressed'` or `'hybrid'`. The supplied key is
2101
+ * interpreted using the specified `inputEncoding`, and the returned key is encoded
2102
+ * using the specified `outputEncoding`.
2103
+ *
2104
+ * Use {@link getCurves} to obtain a list of available curve names.
2105
+ * On recent OpenSSL releases, `openssl ecparam -list_curves` will also display
2106
+ * the name and description of each available elliptic curve.
2107
+ *
2108
+ * If `format` is not specified the point will be returned in `'uncompressed'`format.
2109
+ *
2110
+ * If the `inputEncoding` is not provided, `key` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
2111
+ *
2112
+ * Example (uncompressing a key):
2113
+ *
2114
+ * ```js
2115
+ * const {
2116
+ * createECDH,
2117
+ * ECDH
2118
+ * } = await import('crypto');
2119
+ *
2120
+ * const ecdh = createECDH('secp256k1');
2121
+ * ecdh.generateKeys();
2122
+ *
2123
+ * const compressedKey = ecdh.getPublicKey('hex', 'compressed');
2124
+ *
2125
+ * const uncompressedKey = ECDH.convertKey(compressedKey,
2126
+ * 'secp256k1',
2127
+ * 'hex',
2128
+ * 'hex',
2129
+ * 'uncompressed');
2130
+ *
2131
+ * // The converted key and the uncompressed public key should be the same
2132
+ * console.log(uncompressedKey === ecdh.getPublicKey('hex'));
2133
+ * ```
2134
+ * @since v10.0.0
2135
+ * @param inputEncoding The `encoding` of the `key` string.
2136
+ * @param outputEncoding The `encoding` of the return value.
2137
+ * @param [format='uncompressed']
2138
+ */
580
2139
  static convertKey(
581
2140
  key: BinaryLike,
582
2141
  curve: string,
583
2142
  inputEncoding?: BinaryToTextEncoding,
584
2143
  outputEncoding?: 'latin1' | 'hex' | 'base64',
585
- format?: 'uncompressed' | 'compressed' | 'hybrid',
2144
+ format?: 'uncompressed' | 'compressed' | 'hybrid'
586
2145
  ): Buffer | string;
2146
+ /**
2147
+ * Generates private and public EC Diffie-Hellman key values, and returns
2148
+ * the public key in the specified `format` and `encoding`. This key should be
2149
+ * transferred to the other party.
2150
+ *
2151
+ * 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.
2152
+ *
2153
+ * If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.
2154
+ * @since v0.11.14
2155
+ * @param encoding The `encoding` of the return value.
2156
+ * @param [format='uncompressed']
2157
+ */
587
2158
  generateKeys(): Buffer;
588
2159
  generateKeys(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
589
- computeSecret(other_public_key: NodeJS.ArrayBufferView): Buffer;
590
- computeSecret(other_public_key: string, input_encoding: BinaryToTextEncoding): Buffer;
591
- computeSecret(other_public_key: NodeJS.ArrayBufferView, output_encoding: BinaryToTextEncoding): string;
592
- computeSecret(
593
- other_public_key: string,
594
- input_encoding: BinaryToTextEncoding,
595
- output_encoding: BinaryToTextEncoding,
596
- ): string;
2160
+ /**
2161
+ * Computes the shared secret using `otherPublicKey` as the other
2162
+ * party's public key and returns the computed shared secret. The supplied
2163
+ * key is interpreted using specified `inputEncoding`, and the returned secret
2164
+ * is encoded using the specified `outputEncoding`.
2165
+ * If the `inputEncoding` is not
2166
+ * provided, `otherPublicKey` is expected to be a `Buffer`, `TypedArray`, or`DataView`.
2167
+ *
2168
+ * If `outputEncoding` is given a string will be returned; otherwise a `Buffer` is returned.
2169
+ *
2170
+ * `ecdh.computeSecret` will throw an`ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY` error when `otherPublicKey`lies outside of the elliptic curve. Since `otherPublicKey` is
2171
+ * usually supplied from a remote user over an insecure network,
2172
+ * be sure to handle this exception accordingly.
2173
+ * @since v0.11.14
2174
+ * @param inputEncoding The `encoding` of the `otherPublicKey` string.
2175
+ * @param outputEncoding The `encoding` of the return value.
2176
+ */
2177
+ computeSecret(otherPublicKey: NodeJS.ArrayBufferView): Buffer;
2178
+ computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): Buffer;
2179
+ computeSecret(otherPublicKey: NodeJS.ArrayBufferView, outputEncoding: BinaryToTextEncoding): string;
2180
+ computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding, outputEncoding: BinaryToTextEncoding): string;
2181
+ /**
2182
+ * If `encoding` is specified, a string is returned; otherwise a `Buffer` is
2183
+ * returned.
2184
+ * @since v0.11.14
2185
+ * @param encoding The `encoding` of the return value.
2186
+ * @return The EC Diffie-Hellman in the specified `encoding`.
2187
+ */
597
2188
  getPrivateKey(): Buffer;
598
2189
  getPrivateKey(encoding: BinaryToTextEncoding): string;
2190
+ /**
2191
+ * 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.
2192
+ *
2193
+ * If `encoding` is specified, a string is returned; otherwise a `Buffer` is
2194
+ * returned.
2195
+ * @since v0.11.14
2196
+ * @param encoding The `encoding` of the return value.
2197
+ * @param [format='uncompressed']
2198
+ * @return The EC Diffie-Hellman public key in the specified `encoding` and `format`.
2199
+ */
599
2200
  getPublicKey(): Buffer;
600
2201
  getPublicKey(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
601
- setPrivateKey(private_key: NodeJS.ArrayBufferView): void;
602
- setPrivateKey(private_key: string, encoding: BinaryToTextEncoding): void;
2202
+ /**
2203
+ * Sets the EC Diffie-Hellman private key.
2204
+ * If `encoding` is provided, `privateKey` is expected
2205
+ * to be a string; otherwise `privateKey` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
2206
+ *
2207
+ * If `privateKey` is not valid for the curve specified when the `ECDH` object was
2208
+ * created, an error is thrown. Upon setting the private key, the associated
2209
+ * public point (key) is also generated and set in the `ECDH` object.
2210
+ * @since v0.11.14
2211
+ * @param encoding The `encoding` of the `privateKey` string.
2212
+ */
2213
+ setPrivateKey(privateKey: NodeJS.ArrayBufferView): void;
2214
+ setPrivateKey(privateKey: string, encoding: BinaryToTextEncoding): void;
603
2215
  }
604
- function createECDH(curve_name: string): ECDH;
2216
+ /**
2217
+ * Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a
2218
+ * predefined curve specified by the `curveName` string. Use {@link getCurves} to obtain a list of available curve names. On recent
2219
+ * OpenSSL releases, `openssl ecparam -list_curves` will also display the name
2220
+ * and description of each available elliptic curve.
2221
+ * @since v0.11.14
2222
+ */
2223
+ function createECDH(curveName: string): ECDH;
2224
+ /**
2225
+ * This function is based on a constant-time algorithm.
2226
+ * Returns true if `a` is equal to `b`, without leaking timing information that
2227
+ * would allow an attacker to guess one of the values. This is suitable for
2228
+ * comparing HMAC digests or secret values like authentication cookies or [capability urls](https://www.w3.org/TR/capability-urls/).
2229
+ *
2230
+ * `a` and `b` must both be `Buffer`s, `TypedArray`s, or `DataView`s, and they
2231
+ * must have the same byte length.
2232
+ *
2233
+ * If at least one of `a` and `b` is a `TypedArray` with more than one byte per
2234
+ * entry, such as `Uint16Array`, the result will be computed using the platform
2235
+ * byte order.
2236
+ *
2237
+ * Use of `crypto.timingSafeEqual` does not guarantee that the _surrounding_ code
2238
+ * is timing-safe. Care should be taken to ensure that the surrounding code does
2239
+ * not introduce timing vulnerabilities.
2240
+ * @since v6.6.0
2241
+ */
605
2242
  function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
606
2243
  /** @deprecated since v10.0.0 */
607
2244
  const DEFAULT_ENCODING: BufferEncoding;
608
-
609
- type KeyType = 'rsa' | 'dsa' | 'ec' | 'ed25519' | 'ed448' | 'x25519' | 'x448';
2245
+ type KeyType = 'rsa' | 'rsa-pss' | 'dsa' | 'ec' | 'ed25519' | 'ed448' | 'x25519' | 'x448';
610
2246
  type KeyFormat = 'pem' | 'der';
611
-
612
2247
  interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
613
2248
  format: T;
614
2249
  cipher?: string | undefined;
615
2250
  passphrase?: string | undefined;
616
2251
  }
617
-
618
2252
  interface KeyPairKeyObjectResult {
619
2253
  publicKey: KeyObject;
620
2254
  privateKey: KeyObject;
621
2255
  }
622
-
623
- interface ED25519KeyPairKeyObjectOptions {
624
- /**
625
- * No options.
626
- */
627
- }
628
-
629
- interface ED448KeyPairKeyObjectOptions {
630
- /**
631
- * No options.
632
- */
633
- }
634
-
635
- interface X25519KeyPairKeyObjectOptions {
2256
+ interface ED25519KeyPairKeyObjectOptions {}
2257
+ interface ED448KeyPairKeyObjectOptions {}
2258
+ interface X25519KeyPairKeyObjectOptions {}
2259
+ interface X448KeyPairKeyObjectOptions {}
2260
+ interface ECKeyPairKeyObjectOptions {
636
2261
  /**
637
- * No options.
2262
+ * Name of the curve to use.
638
2263
  */
2264
+ namedCurve: string;
639
2265
  }
640
-
641
- interface X448KeyPairKeyObjectOptions {
2266
+ interface RSAKeyPairKeyObjectOptions {
642
2267
  /**
643
- * No options.
2268
+ * Key size in bits
644
2269
  */
645
- }
646
-
647
- interface ECKeyPairKeyObjectOptions {
2270
+ modulusLength: number;
648
2271
  /**
649
- * Name of the curve to use.
2272
+ * @default 0x10001
650
2273
  */
651
- namedCurve: string;
2274
+ publicExponent?: number | undefined;
652
2275
  }
653
-
654
- interface RSAKeyPairKeyObjectOptions {
2276
+ interface RSAPSSKeyPairKeyObjectOptions {
655
2277
  /**
656
2278
  * Key size in bits
657
2279
  */
658
2280
  modulusLength: number;
659
-
660
2281
  /**
661
2282
  * @default 0x10001
662
2283
  */
663
2284
  publicExponent?: number | undefined;
664
2285
  }
665
-
666
2286
  interface DSAKeyPairKeyObjectOptions {
667
2287
  /**
668
2288
  * Key size in bits
669
2289
  */
670
2290
  modulusLength: number;
671
-
672
2291
  /**
673
2292
  * Size of q in bits
674
2293
  */
675
2294
  divisorLength: number;
676
2295
  }
677
-
678
2296
  interface RSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
679
2297
  /**
680
2298
  * Key size in bits
@@ -684,7 +2302,6 @@ declare module 'crypto' {
684
2302
  * @default 0x10001
685
2303
  */
686
2304
  publicExponent?: number | undefined;
687
-
688
2305
  publicKeyEncoding: {
689
2306
  type: 'pkcs1' | 'spki';
690
2307
  format: PubF;
@@ -693,7 +2310,23 @@ declare module 'crypto' {
693
2310
  type: 'pkcs1' | 'pkcs8';
694
2311
  };
695
2312
  }
696
-
2313
+ interface RSAPSSKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2314
+ /**
2315
+ * Key size in bits
2316
+ */
2317
+ modulusLength: number;
2318
+ /**
2319
+ * @default 0x10001
2320
+ */
2321
+ publicExponent?: number | undefined;
2322
+ publicKeyEncoding: {
2323
+ type: 'spki';
2324
+ format: PubF;
2325
+ };
2326
+ privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2327
+ type: 'pkcs8';
2328
+ };
2329
+ }
697
2330
  interface DSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
698
2331
  /**
699
2332
  * Key size in bits
@@ -703,7 +2336,6 @@ declare module 'crypto' {
703
2336
  * Size of q in bits
704
2337
  */
705
2338
  divisorLength: number;
706
-
707
2339
  publicKeyEncoding: {
708
2340
  type: 'spki';
709
2341
  format: PubF;
@@ -712,13 +2344,11 @@ declare module 'crypto' {
712
2344
  type: 'pkcs8';
713
2345
  };
714
2346
  }
715
-
716
2347
  interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
717
2348
  /**
718
2349
  * Name of the curve to use.
719
2350
  */
720
2351
  namedCurve: string;
721
-
722
2352
  publicKeyEncoding: {
723
2353
  type: 'pkcs1' | 'spki';
724
2354
  format: PubF;
@@ -727,7 +2357,6 @@ declare module 'crypto' {
727
2357
  type: 'sec1' | 'pkcs8';
728
2358
  };
729
2359
  }
730
-
731
2360
  interface ED25519KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
732
2361
  publicKeyEncoding: {
733
2362
  type: 'spki';
@@ -737,7 +2366,6 @@ declare module 'crypto' {
737
2366
  type: 'pkcs8';
738
2367
  };
739
2368
  }
740
-
741
2369
  interface ED448KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
742
2370
  publicKeyEncoding: {
743
2371
  type: 'spki';
@@ -747,7 +2375,6 @@ declare module 'crypto' {
747
2375
  type: 'pkcs8';
748
2376
  };
749
2377
  }
750
-
751
2378
  interface X25519KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
752
2379
  publicKeyEncoding: {
753
2380
  type: 'spki';
@@ -757,7 +2384,6 @@ declare module 'crypto' {
757
2384
  type: 'pkcs8';
758
2385
  };
759
2386
  }
760
-
761
2387
  interface X448KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
762
2388
  publicKeyEncoding: {
763
2389
  type: 'spki';
@@ -767,488 +2393,440 @@ declare module 'crypto' {
767
2393
  type: 'pkcs8';
768
2394
  };
769
2395
  }
770
-
771
2396
  interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
772
2397
  publicKey: T1;
773
2398
  privateKey: T2;
774
2399
  }
775
-
776
- function generateKeyPairSync(
777
- type: 'rsa',
778
- options: RSAKeyPairOptions<'pem', 'pem'>,
779
- ): KeyPairSyncResult<string, string>;
780
- function generateKeyPairSync(
781
- type: 'rsa',
782
- options: RSAKeyPairOptions<'pem', 'der'>,
783
- ): KeyPairSyncResult<string, Buffer>;
784
- function generateKeyPairSync(
785
- type: 'rsa',
786
- options: RSAKeyPairOptions<'der', 'pem'>,
787
- ): KeyPairSyncResult<Buffer, string>;
788
- function generateKeyPairSync(
789
- type: 'rsa',
790
- options: RSAKeyPairOptions<'der', 'der'>,
791
- ): KeyPairSyncResult<Buffer, Buffer>;
2400
+ /**
2401
+ * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
2402
+ * Ed25519, Ed448, X25519, X448, and DH are currently supported.
2403
+ *
2404
+ * If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
2405
+ * behaves as if `keyObject.export()` had been called on its result. Otherwise,
2406
+ * the respective part of the key is returned as a `KeyObject`.
2407
+ *
2408
+ * When encoding public keys, it is recommended to use `'spki'`. When encoding
2409
+ * private keys, it is recommended to use `'pkcs8'` with a strong passphrase,
2410
+ * and to keep the passphrase confidential.
2411
+ *
2412
+ * ```js
2413
+ * const {
2414
+ * generateKeyPairSync
2415
+ * } = await import('crypto');
2416
+ *
2417
+ * const {
2418
+ * publicKey,
2419
+ * privateKey,
2420
+ * } = generateKeyPairSync('rsa', {
2421
+ * modulusLength: 4096,
2422
+ * publicKeyEncoding: {
2423
+ * type: 'spki',
2424
+ * format: 'pem'
2425
+ * },
2426
+ * privateKeyEncoding: {
2427
+ * type: 'pkcs8',
2428
+ * format: 'pem',
2429
+ * cipher: 'aes-256-cbc',
2430
+ * passphrase: 'top secret'
2431
+ * }
2432
+ * });
2433
+ * ```
2434
+ *
2435
+ * The return value `{ publicKey, privateKey }` represents the generated key pair.
2436
+ * When PEM encoding was selected, the respective key will be a string, otherwise
2437
+ * it will be a buffer containing the data encoded as DER.
2438
+ * @since v10.12.0
2439
+ * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`.
2440
+ */
2441
+ function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
2442
+ function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
2443
+ function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
2444
+ function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
792
2445
  function generateKeyPairSync(type: 'rsa', options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
793
-
794
- function generateKeyPairSync(
795
- type: 'dsa',
796
- options: DSAKeyPairOptions<'pem', 'pem'>,
797
- ): KeyPairSyncResult<string, string>;
798
- function generateKeyPairSync(
799
- type: 'dsa',
800
- options: DSAKeyPairOptions<'pem', 'der'>,
801
- ): KeyPairSyncResult<string, Buffer>;
802
- function generateKeyPairSync(
803
- type: 'dsa',
804
- options: DSAKeyPairOptions<'der', 'pem'>,
805
- ): KeyPairSyncResult<Buffer, string>;
806
- function generateKeyPairSync(
807
- type: 'dsa',
808
- options: DSAKeyPairOptions<'der', 'der'>,
809
- ): KeyPairSyncResult<Buffer, Buffer>;
2446
+ function generateKeyPairSync(type: 'rsa-pss', options: RSAPSSKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
2447
+ function generateKeyPairSync(type: 'rsa-pss', options: RSAPSSKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
2448
+ function generateKeyPairSync(type: 'rsa-pss', options: RSAPSSKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
2449
+ function generateKeyPairSync(type: 'rsa-pss', options: RSAPSSKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
2450
+ function generateKeyPairSync(type: 'rsa-pss', options: RSAPSSKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2451
+ function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
2452
+ function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
2453
+ function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
2454
+ function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
810
2455
  function generateKeyPairSync(type: 'dsa', options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
811
-
812
- function generateKeyPairSync(
813
- type: 'ec',
814
- options: ECKeyPairOptions<'pem', 'pem'>,
815
- ): KeyPairSyncResult<string, string>;
816
- function generateKeyPairSync(
817
- type: 'ec',
818
- options: ECKeyPairOptions<'pem', 'der'>,
819
- ): KeyPairSyncResult<string, Buffer>;
820
- function generateKeyPairSync(
821
- type: 'ec',
822
- options: ECKeyPairOptions<'der', 'pem'>,
823
- ): KeyPairSyncResult<Buffer, string>;
824
- function generateKeyPairSync(
825
- type: 'ec',
826
- options: ECKeyPairOptions<'der', 'der'>,
827
- ): KeyPairSyncResult<Buffer, Buffer>;
2456
+ function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
2457
+ function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
2458
+ function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
2459
+ function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
828
2460
  function generateKeyPairSync(type: 'ec', options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
829
-
830
- function generateKeyPairSync(
831
- type: 'ed25519',
832
- options: ED25519KeyPairOptions<'pem', 'pem'>,
833
- ): KeyPairSyncResult<string, string>;
834
- function generateKeyPairSync(
835
- type: 'ed25519',
836
- options: ED25519KeyPairOptions<'pem', 'der'>,
837
- ): KeyPairSyncResult<string, Buffer>;
838
- function generateKeyPairSync(
839
- type: 'ed25519',
840
- options: ED25519KeyPairOptions<'der', 'pem'>,
841
- ): KeyPairSyncResult<Buffer, string>;
842
- function generateKeyPairSync(
843
- type: 'ed25519',
844
- options: ED25519KeyPairOptions<'der', 'der'>,
845
- ): KeyPairSyncResult<Buffer, Buffer>;
2461
+ function generateKeyPairSync(type: 'ed25519', options: ED25519KeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
2462
+ function generateKeyPairSync(type: 'ed25519', options: ED25519KeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
2463
+ function generateKeyPairSync(type: 'ed25519', options: ED25519KeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
2464
+ function generateKeyPairSync(type: 'ed25519', options: ED25519KeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
846
2465
  function generateKeyPairSync(type: 'ed25519', options?: ED25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
847
-
848
- function generateKeyPairSync(
849
- type: 'ed448',
850
- options: ED448KeyPairOptions<'pem', 'pem'>,
851
- ): KeyPairSyncResult<string, string>;
852
- function generateKeyPairSync(
853
- type: 'ed448',
854
- options: ED448KeyPairOptions<'pem', 'der'>,
855
- ): KeyPairSyncResult<string, Buffer>;
856
- function generateKeyPairSync(
857
- type: 'ed448',
858
- options: ED448KeyPairOptions<'der', 'pem'>,
859
- ): KeyPairSyncResult<Buffer, string>;
860
- function generateKeyPairSync(
861
- type: 'ed448',
862
- options: ED448KeyPairOptions<'der', 'der'>,
863
- ): KeyPairSyncResult<Buffer, Buffer>;
2466
+ function generateKeyPairSync(type: 'ed448', options: ED448KeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
2467
+ function generateKeyPairSync(type: 'ed448', options: ED448KeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
2468
+ function generateKeyPairSync(type: 'ed448', options: ED448KeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
2469
+ function generateKeyPairSync(type: 'ed448', options: ED448KeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
864
2470
  function generateKeyPairSync(type: 'ed448', options?: ED448KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
865
-
866
- function generateKeyPairSync(
867
- type: 'x25519',
868
- options: X25519KeyPairOptions<'pem', 'pem'>,
869
- ): KeyPairSyncResult<string, string>;
870
- function generateKeyPairSync(
871
- type: 'x25519',
872
- options: X25519KeyPairOptions<'pem', 'der'>,
873
- ): KeyPairSyncResult<string, Buffer>;
874
- function generateKeyPairSync(
875
- type: 'x25519',
876
- options: X25519KeyPairOptions<'der', 'pem'>,
877
- ): KeyPairSyncResult<Buffer, string>;
878
- function generateKeyPairSync(
879
- type: 'x25519',
880
- options: X25519KeyPairOptions<'der', 'der'>,
881
- ): KeyPairSyncResult<Buffer, Buffer>;
2471
+ function generateKeyPairSync(type: 'x25519', options: X25519KeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
2472
+ function generateKeyPairSync(type: 'x25519', options: X25519KeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
2473
+ function generateKeyPairSync(type: 'x25519', options: X25519KeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
2474
+ function generateKeyPairSync(type: 'x25519', options: X25519KeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
882
2475
  function generateKeyPairSync(type: 'x25519', options?: X25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
883
-
884
- function generateKeyPairSync(
885
- type: 'x448',
886
- options: X448KeyPairOptions<'pem', 'pem'>,
887
- ): KeyPairSyncResult<string, string>;
888
- function generateKeyPairSync(
889
- type: 'x448',
890
- options: X448KeyPairOptions<'pem', 'der'>,
891
- ): KeyPairSyncResult<string, Buffer>;
892
- function generateKeyPairSync(
893
- type: 'x448',
894
- options: X448KeyPairOptions<'der', 'pem'>,
895
- ): KeyPairSyncResult<Buffer, string>;
896
- function generateKeyPairSync(
897
- type: 'x448',
898
- options: X448KeyPairOptions<'der', 'der'>,
899
- ): KeyPairSyncResult<Buffer, Buffer>;
2476
+ function generateKeyPairSync(type: 'x448', options: X448KeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
2477
+ function generateKeyPairSync(type: 'x448', options: X448KeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
2478
+ function generateKeyPairSync(type: 'x448', options: X448KeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
2479
+ function generateKeyPairSync(type: 'x448', options: X448KeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
900
2480
  function generateKeyPairSync(type: 'x448', options?: X448KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
901
-
902
- function generateKeyPair(
903
- type: 'rsa',
904
- options: RSAKeyPairOptions<'pem', 'pem'>,
905
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
906
- ): void;
907
- function generateKeyPair(
908
- type: 'rsa',
909
- options: RSAKeyPairOptions<'pem', 'der'>,
910
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
911
- ): void;
912
- function generateKeyPair(
913
- type: 'rsa',
914
- options: RSAKeyPairOptions<'der', 'pem'>,
915
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
916
- ): void;
917
- function generateKeyPair(
918
- type: 'rsa',
919
- options: RSAKeyPairOptions<'der', 'der'>,
920
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
921
- ): void;
922
- function generateKeyPair(
923
- type: 'rsa',
924
- options: RSAKeyPairKeyObjectOptions,
925
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
926
- ): void;
927
-
928
- function generateKeyPair(
929
- type: 'dsa',
930
- options: DSAKeyPairOptions<'pem', 'pem'>,
931
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
932
- ): void;
933
- function generateKeyPair(
934
- type: 'dsa',
935
- options: DSAKeyPairOptions<'pem', 'der'>,
936
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
937
- ): void;
938
- function generateKeyPair(
939
- type: 'dsa',
940
- options: DSAKeyPairOptions<'der', 'pem'>,
941
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
942
- ): void;
943
- function generateKeyPair(
944
- type: 'dsa',
945
- options: DSAKeyPairOptions<'der', 'der'>,
946
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
947
- ): void;
948
- function generateKeyPair(
949
- type: 'dsa',
950
- options: DSAKeyPairKeyObjectOptions,
951
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
952
- ): void;
953
-
954
- function generateKeyPair(
955
- type: 'ec',
956
- options: ECKeyPairOptions<'pem', 'pem'>,
957
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
958
- ): void;
959
- function generateKeyPair(
960
- type: 'ec',
961
- options: ECKeyPairOptions<'pem', 'der'>,
962
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
963
- ): void;
964
- function generateKeyPair(
965
- type: 'ec',
966
- options: ECKeyPairOptions<'der', 'pem'>,
967
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
968
- ): void;
969
- function generateKeyPair(
970
- type: 'ec',
971
- options: ECKeyPairOptions<'der', 'der'>,
972
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
973
- ): void;
974
- function generateKeyPair(
975
- type: 'ec',
976
- options: ECKeyPairKeyObjectOptions,
977
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
978
- ): void;
979
-
980
- function generateKeyPair(
981
- type: 'ed25519',
982
- options: ED25519KeyPairOptions<'pem', 'pem'>,
983
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
984
- ): void;
985
- function generateKeyPair(
986
- type: 'ed25519',
987
- options: ED25519KeyPairOptions<'pem', 'der'>,
988
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
989
- ): void;
990
- function generateKeyPair(
991
- type: 'ed25519',
992
- options: ED25519KeyPairOptions<'der', 'pem'>,
993
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
994
- ): void;
995
- function generateKeyPair(
996
- type: 'ed25519',
997
- options: ED25519KeyPairOptions<'der', 'der'>,
998
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
999
- ): void;
1000
- function generateKeyPair(
1001
- type: 'ed25519',
1002
- options: ED25519KeyPairKeyObjectOptions | undefined,
1003
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
1004
- ): void;
1005
-
1006
- function generateKeyPair(
1007
- type: 'ed448',
1008
- options: ED448KeyPairOptions<'pem', 'pem'>,
1009
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
1010
- ): void;
1011
- function generateKeyPair(
1012
- type: 'ed448',
1013
- options: ED448KeyPairOptions<'pem', 'der'>,
1014
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
1015
- ): void;
1016
- function generateKeyPair(
1017
- type: 'ed448',
1018
- options: ED448KeyPairOptions<'der', 'pem'>,
1019
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
1020
- ): void;
1021
- function generateKeyPair(
1022
- type: 'ed448',
1023
- options: ED448KeyPairOptions<'der', 'der'>,
1024
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
1025
- ): void;
1026
- function generateKeyPair(
1027
- type: 'ed448',
1028
- options: ED448KeyPairKeyObjectOptions | undefined,
1029
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
1030
- ): void;
1031
-
1032
- function generateKeyPair(
1033
- type: 'x25519',
1034
- options: X25519KeyPairOptions<'pem', 'pem'>,
1035
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
1036
- ): void;
1037
- function generateKeyPair(
1038
- type: 'x25519',
1039
- options: X25519KeyPairOptions<'pem', 'der'>,
1040
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
1041
- ): void;
1042
- function generateKeyPair(
1043
- type: 'x25519',
1044
- options: X25519KeyPairOptions<'der', 'pem'>,
1045
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
1046
- ): void;
1047
- function generateKeyPair(
1048
- type: 'x25519',
1049
- options: X25519KeyPairOptions<'der', 'der'>,
1050
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
1051
- ): void;
1052
- function generateKeyPair(
1053
- type: 'x25519',
1054
- options: X25519KeyPairKeyObjectOptions | undefined,
1055
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
1056
- ): void;
1057
-
1058
- function generateKeyPair(
1059
- type: 'x448',
1060
- options: X448KeyPairOptions<'pem', 'pem'>,
1061
- callback: (err: Error | null, publicKey: string, privateKey: string) => void,
1062
- ): void;
1063
- function generateKeyPair(
1064
- type: 'x448',
1065
- options: X448KeyPairOptions<'pem', 'der'>,
1066
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
1067
- ): void;
1068
- function generateKeyPair(
1069
- type: 'x448',
1070
- options: X448KeyPairOptions<'der', 'pem'>,
1071
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
1072
- ): void;
1073
- function generateKeyPair(
1074
- type: 'x448',
1075
- options: X448KeyPairOptions<'der', 'der'>,
1076
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
1077
- ): void;
1078
- function generateKeyPair(
1079
- type: 'x448',
1080
- options: X448KeyPairKeyObjectOptions | undefined,
1081
- callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
1082
- ): void;
1083
-
2481
+ /**
2482
+ * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
2483
+ * Ed25519, Ed448, X25519, X448, and DH are currently supported.
2484
+ *
2485
+ * If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
2486
+ * behaves as if `keyObject.export()` had been called on its result. Otherwise,
2487
+ * the respective part of the key is returned as a `KeyObject`.
2488
+ *
2489
+ * It is recommended to encode public keys as `'spki'` and private keys as`'pkcs8'` with encryption for long-term storage:
2490
+ *
2491
+ * ```js
2492
+ * const {
2493
+ * generateKeyPair
2494
+ * } = await import('crypto');
2495
+ *
2496
+ * generateKeyPair('rsa', {
2497
+ * modulusLength: 4096,
2498
+ * publicKeyEncoding: {
2499
+ * type: 'spki',
2500
+ * format: 'pem'
2501
+ * },
2502
+ * privateKeyEncoding: {
2503
+ * type: 'pkcs8',
2504
+ * format: 'pem',
2505
+ * cipher: 'aes-256-cbc',
2506
+ * passphrase: 'top secret'
2507
+ * }
2508
+ * }, (err, publicKey, privateKey) => {
2509
+ * // Handle errors and use the generated key pair.
2510
+ * });
2511
+ * ```
2512
+ *
2513
+ * On completion, `callback` will be called with `err` set to `undefined` and`publicKey` / `privateKey` representing the generated key pair.
2514
+ *
2515
+ * If this method is invoked as its `util.promisify()` ed version, it returns
2516
+ * a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
2517
+ * @since v10.12.0
2518
+ * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`.
2519
+ */
2520
+ function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
2521
+ function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
2522
+ function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
2523
+ function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
2524
+ function generateKeyPair(type: 'rsa', options: RSAKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
2525
+ function generateKeyPair(type: 'rsa-pss', options: RSAPSSKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
2526
+ function generateKeyPair(type: 'rsa-pss', options: RSAPSSKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
2527
+ function generateKeyPair(type: 'rsa-pss', options: RSAPSSKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
2528
+ function generateKeyPair(type: 'rsa-pss', options: RSAPSSKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
2529
+ function generateKeyPair(type: 'rsa-pss', options: RSAPSSKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
2530
+ function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
2531
+ function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
2532
+ function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
2533
+ function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
2534
+ function generateKeyPair(type: 'dsa', options: DSAKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
2535
+ function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
2536
+ function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
2537
+ function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
2538
+ function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
2539
+ function generateKeyPair(type: 'ec', options: ECKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
2540
+ function generateKeyPair(type: 'ed25519', options: ED25519KeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
2541
+ function generateKeyPair(type: 'ed25519', options: ED25519KeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
2542
+ function generateKeyPair(type: 'ed25519', options: ED25519KeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
2543
+ function generateKeyPair(type: 'ed25519', options: ED25519KeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
2544
+ function generateKeyPair(type: 'ed25519', options: ED25519KeyPairKeyObjectOptions | undefined, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
2545
+ function generateKeyPair(type: 'ed448', options: ED448KeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
2546
+ function generateKeyPair(type: 'ed448', options: ED448KeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
2547
+ function generateKeyPair(type: 'ed448', options: ED448KeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
2548
+ function generateKeyPair(type: 'ed448', options: ED448KeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
2549
+ function generateKeyPair(type: 'ed448', options: ED448KeyPairKeyObjectOptions | undefined, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
2550
+ function generateKeyPair(type: 'x25519', options: X25519KeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
2551
+ function generateKeyPair(type: 'x25519', options: X25519KeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
2552
+ function generateKeyPair(type: 'x25519', options: X25519KeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
2553
+ function generateKeyPair(type: 'x25519', options: X25519KeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
2554
+ function generateKeyPair(type: 'x25519', options: X25519KeyPairKeyObjectOptions | undefined, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
2555
+ function generateKeyPair(type: 'x448', options: X448KeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
2556
+ function generateKeyPair(type: 'x448', options: X448KeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
2557
+ function generateKeyPair(type: 'x448', options: X448KeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
2558
+ function generateKeyPair(type: 'x448', options: X448KeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
2559
+ function generateKeyPair(type: 'x448', options: X448KeyPairKeyObjectOptions | undefined, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
1084
2560
  namespace generateKeyPair {
1085
2561
  function __promisify__(
1086
2562
  type: 'rsa',
1087
- options: RSAKeyPairOptions<'pem', 'pem'>,
1088
- ): Promise<{ publicKey: string; privateKey: string }>;
2563
+ options: RSAKeyPairOptions<'pem', 'pem'>
2564
+ ): Promise<{
2565
+ publicKey: string;
2566
+ privateKey: string;
2567
+ }>;
1089
2568
  function __promisify__(
1090
2569
  type: 'rsa',
1091
- options: RSAKeyPairOptions<'pem', 'der'>,
1092
- ): Promise<{ publicKey: string; privateKey: Buffer }>;
2570
+ options: RSAKeyPairOptions<'pem', 'der'>
2571
+ ): Promise<{
2572
+ publicKey: string;
2573
+ privateKey: Buffer;
2574
+ }>;
1093
2575
  function __promisify__(
1094
2576
  type: 'rsa',
1095
- options: RSAKeyPairOptions<'der', 'pem'>,
1096
- ): Promise<{ publicKey: Buffer; privateKey: string }>;
2577
+ options: RSAKeyPairOptions<'der', 'pem'>
2578
+ ): Promise<{
2579
+ publicKey: Buffer;
2580
+ privateKey: string;
2581
+ }>;
1097
2582
  function __promisify__(
1098
2583
  type: 'rsa',
1099
- options: RSAKeyPairOptions<'der', 'der'>,
1100
- ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
2584
+ options: RSAKeyPairOptions<'der', 'der'>
2585
+ ): Promise<{
2586
+ publicKey: Buffer;
2587
+ privateKey: Buffer;
2588
+ }>;
1101
2589
  function __promisify__(type: 'rsa', options: RSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1102
-
2590
+ function __promisify__(
2591
+ type: 'rsa-pss',
2592
+ options: RSAPSSKeyPairOptions<'pem', 'pem'>
2593
+ ): Promise<{
2594
+ publicKey: string;
2595
+ privateKey: string;
2596
+ }>;
2597
+ function __promisify__(
2598
+ type: 'rsa-pss',
2599
+ options: RSAPSSKeyPairOptions<'pem', 'der'>
2600
+ ): Promise<{
2601
+ publicKey: string;
2602
+ privateKey: Buffer;
2603
+ }>;
2604
+ function __promisify__(
2605
+ type: 'rsa-pss',
2606
+ options: RSAPSSKeyPairOptions<'der', 'pem'>
2607
+ ): Promise<{
2608
+ publicKey: Buffer;
2609
+ privateKey: string;
2610
+ }>;
2611
+ function __promisify__(
2612
+ type: 'rsa-pss',
2613
+ options: RSAPSSKeyPairOptions<'der', 'der'>
2614
+ ): Promise<{
2615
+ publicKey: Buffer;
2616
+ privateKey: Buffer;
2617
+ }>;
2618
+ function __promisify__(type: 'rsa-pss', options: RSAPSSKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1103
2619
  function __promisify__(
1104
2620
  type: 'dsa',
1105
- options: DSAKeyPairOptions<'pem', 'pem'>,
1106
- ): Promise<{ publicKey: string; privateKey: string }>;
2621
+ options: DSAKeyPairOptions<'pem', 'pem'>
2622
+ ): Promise<{
2623
+ publicKey: string;
2624
+ privateKey: string;
2625
+ }>;
1107
2626
  function __promisify__(
1108
2627
  type: 'dsa',
1109
- options: DSAKeyPairOptions<'pem', 'der'>,
1110
- ): Promise<{ publicKey: string; privateKey: Buffer }>;
2628
+ options: DSAKeyPairOptions<'pem', 'der'>
2629
+ ): Promise<{
2630
+ publicKey: string;
2631
+ privateKey: Buffer;
2632
+ }>;
1111
2633
  function __promisify__(
1112
2634
  type: 'dsa',
1113
- options: DSAKeyPairOptions<'der', 'pem'>,
1114
- ): Promise<{ publicKey: Buffer; privateKey: string }>;
2635
+ options: DSAKeyPairOptions<'der', 'pem'>
2636
+ ): Promise<{
2637
+ publicKey: Buffer;
2638
+ privateKey: string;
2639
+ }>;
1115
2640
  function __promisify__(
1116
2641
  type: 'dsa',
1117
- options: DSAKeyPairOptions<'der', 'der'>,
1118
- ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
2642
+ options: DSAKeyPairOptions<'der', 'der'>
2643
+ ): Promise<{
2644
+ publicKey: Buffer;
2645
+ privateKey: Buffer;
2646
+ }>;
1119
2647
  function __promisify__(type: 'dsa', options: DSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1120
-
1121
2648
  function __promisify__(
1122
2649
  type: 'ec',
1123
- options: ECKeyPairOptions<'pem', 'pem'>,
1124
- ): Promise<{ publicKey: string; privateKey: string }>;
2650
+ options: ECKeyPairOptions<'pem', 'pem'>
2651
+ ): Promise<{
2652
+ publicKey: string;
2653
+ privateKey: string;
2654
+ }>;
1125
2655
  function __promisify__(
1126
2656
  type: 'ec',
1127
- options: ECKeyPairOptions<'pem', 'der'>,
1128
- ): Promise<{ publicKey: string; privateKey: Buffer }>;
2657
+ options: ECKeyPairOptions<'pem', 'der'>
2658
+ ): Promise<{
2659
+ publicKey: string;
2660
+ privateKey: Buffer;
2661
+ }>;
1129
2662
  function __promisify__(
1130
2663
  type: 'ec',
1131
- options: ECKeyPairOptions<'der', 'pem'>,
1132
- ): Promise<{ publicKey: Buffer; privateKey: string }>;
2664
+ options: ECKeyPairOptions<'der', 'pem'>
2665
+ ): Promise<{
2666
+ publicKey: Buffer;
2667
+ privateKey: string;
2668
+ }>;
1133
2669
  function __promisify__(
1134
2670
  type: 'ec',
1135
- options: ECKeyPairOptions<'der', 'der'>,
1136
- ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
2671
+ options: ECKeyPairOptions<'der', 'der'>
2672
+ ): Promise<{
2673
+ publicKey: Buffer;
2674
+ privateKey: Buffer;
2675
+ }>;
1137
2676
  function __promisify__(type: 'ec', options: ECKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1138
-
1139
- function __promisify__(
1140
- type: 'ed25519',
1141
- options: ED25519KeyPairOptions<'pem', 'pem'>,
1142
- ): Promise<{ publicKey: string; privateKey: string }>;
1143
2677
  function __promisify__(
1144
2678
  type: 'ed25519',
1145
- options: ED25519KeyPairOptions<'pem', 'der'>,
1146
- ): Promise<{ publicKey: string; privateKey: Buffer }>;
2679
+ options: ED25519KeyPairOptions<'pem', 'pem'>
2680
+ ): Promise<{
2681
+ publicKey: string;
2682
+ privateKey: string;
2683
+ }>;
1147
2684
  function __promisify__(
1148
2685
  type: 'ed25519',
1149
- options: ED25519KeyPairOptions<'der', 'pem'>,
1150
- ): Promise<{ publicKey: Buffer; privateKey: string }>;
2686
+ options: ED25519KeyPairOptions<'pem', 'der'>
2687
+ ): Promise<{
2688
+ publicKey: string;
2689
+ privateKey: Buffer;
2690
+ }>;
1151
2691
  function __promisify__(
1152
2692
  type: 'ed25519',
1153
- options: ED25519KeyPairOptions<'der', 'der'>,
1154
- ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
2693
+ options: ED25519KeyPairOptions<'der', 'pem'>
2694
+ ): Promise<{
2695
+ publicKey: Buffer;
2696
+ privateKey: string;
2697
+ }>;
1155
2698
  function __promisify__(
1156
2699
  type: 'ed25519',
1157
- options?: ED25519KeyPairKeyObjectOptions,
1158
- ): Promise<KeyPairKeyObjectResult>;
1159
-
2700
+ options: ED25519KeyPairOptions<'der', 'der'>
2701
+ ): Promise<{
2702
+ publicKey: Buffer;
2703
+ privateKey: Buffer;
2704
+ }>;
2705
+ function __promisify__(type: 'ed25519', options?: ED25519KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1160
2706
  function __promisify__(
1161
2707
  type: 'ed448',
1162
- options: ED448KeyPairOptions<'pem', 'pem'>,
1163
- ): Promise<{ publicKey: string; privateKey: string }>;
2708
+ options: ED448KeyPairOptions<'pem', 'pem'>
2709
+ ): Promise<{
2710
+ publicKey: string;
2711
+ privateKey: string;
2712
+ }>;
1164
2713
  function __promisify__(
1165
2714
  type: 'ed448',
1166
- options: ED448KeyPairOptions<'pem', 'der'>,
1167
- ): Promise<{ publicKey: string; privateKey: Buffer }>;
2715
+ options: ED448KeyPairOptions<'pem', 'der'>
2716
+ ): Promise<{
2717
+ publicKey: string;
2718
+ privateKey: Buffer;
2719
+ }>;
1168
2720
  function __promisify__(
1169
2721
  type: 'ed448',
1170
- options: ED448KeyPairOptions<'der', 'pem'>,
1171
- ): Promise<{ publicKey: Buffer; privateKey: string }>;
2722
+ options: ED448KeyPairOptions<'der', 'pem'>
2723
+ ): Promise<{
2724
+ publicKey: Buffer;
2725
+ privateKey: string;
2726
+ }>;
1172
2727
  function __promisify__(
1173
2728
  type: 'ed448',
1174
- options: ED448KeyPairOptions<'der', 'der'>,
1175
- ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
2729
+ options: ED448KeyPairOptions<'der', 'der'>
2730
+ ): Promise<{
2731
+ publicKey: Buffer;
2732
+ privateKey: Buffer;
2733
+ }>;
1176
2734
  function __promisify__(type: 'ed448', options?: ED448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1177
-
1178
- function __promisify__(
1179
- type: 'x25519',
1180
- options: X25519KeyPairOptions<'pem', 'pem'>,
1181
- ): Promise<{ publicKey: string; privateKey: string }>;
1182
2735
  function __promisify__(
1183
2736
  type: 'x25519',
1184
- options: X25519KeyPairOptions<'pem', 'der'>,
1185
- ): Promise<{ publicKey: string; privateKey: Buffer }>;
2737
+ options: X25519KeyPairOptions<'pem', 'pem'>
2738
+ ): Promise<{
2739
+ publicKey: string;
2740
+ privateKey: string;
2741
+ }>;
1186
2742
  function __promisify__(
1187
2743
  type: 'x25519',
1188
- options: X25519KeyPairOptions<'der', 'pem'>,
1189
- ): Promise<{ publicKey: Buffer; privateKey: string }>;
2744
+ options: X25519KeyPairOptions<'pem', 'der'>
2745
+ ): Promise<{
2746
+ publicKey: string;
2747
+ privateKey: Buffer;
2748
+ }>;
1190
2749
  function __promisify__(
1191
2750
  type: 'x25519',
1192
- options: X25519KeyPairOptions<'der', 'der'>,
1193
- ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
2751
+ options: X25519KeyPairOptions<'der', 'pem'>
2752
+ ): Promise<{
2753
+ publicKey: Buffer;
2754
+ privateKey: string;
2755
+ }>;
1194
2756
  function __promisify__(
1195
2757
  type: 'x25519',
1196
- options?: X25519KeyPairKeyObjectOptions,
1197
- ): Promise<KeyPairKeyObjectResult>;
1198
-
2758
+ options: X25519KeyPairOptions<'der', 'der'>
2759
+ ): Promise<{
2760
+ publicKey: Buffer;
2761
+ privateKey: Buffer;
2762
+ }>;
2763
+ function __promisify__(type: 'x25519', options?: X25519KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1199
2764
  function __promisify__(
1200
2765
  type: 'x448',
1201
- options: X448KeyPairOptions<'pem', 'pem'>,
1202
- ): Promise<{ publicKey: string; privateKey: string }>;
2766
+ options: X448KeyPairOptions<'pem', 'pem'>
2767
+ ): Promise<{
2768
+ publicKey: string;
2769
+ privateKey: string;
2770
+ }>;
1203
2771
  function __promisify__(
1204
2772
  type: 'x448',
1205
- options: X448KeyPairOptions<'pem', 'der'>,
1206
- ): Promise<{ publicKey: string; privateKey: Buffer }>;
2773
+ options: X448KeyPairOptions<'pem', 'der'>
2774
+ ): Promise<{
2775
+ publicKey: string;
2776
+ privateKey: Buffer;
2777
+ }>;
1207
2778
  function __promisify__(
1208
2779
  type: 'x448',
1209
- options: X448KeyPairOptions<'der', 'pem'>,
1210
- ): Promise<{ publicKey: Buffer; privateKey: string }>;
2780
+ options: X448KeyPairOptions<'der', 'pem'>
2781
+ ): Promise<{
2782
+ publicKey: Buffer;
2783
+ privateKey: string;
2784
+ }>;
1211
2785
  function __promisify__(
1212
2786
  type: 'x448',
1213
- options: X448KeyPairOptions<'der', 'der'>,
1214
- ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
2787
+ options: X448KeyPairOptions<'der', 'der'>
2788
+ ): Promise<{
2789
+ publicKey: Buffer;
2790
+ privateKey: Buffer;
2791
+ }>;
1215
2792
  function __promisify__(type: 'x448', options?: X448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1216
2793
  }
1217
-
1218
2794
  /**
1219
2795
  * Calculates and returns the signature for `data` using the given private key and
1220
2796
  * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
1221
2797
  * dependent upon the key type (especially Ed25519 and Ed448).
1222
2798
  *
1223
2799
  * If `key` is not a `KeyObject`, this function behaves as if `key` had been
1224
- * passed to `crypto.createPrivateKey().
2800
+ * passed to {@link createPrivateKey}. If it is an object, the following
2801
+ * additional properties can be passed:
2802
+ *
2803
+ * If the `callback` function is provided this function uses libuv's threadpool.
2804
+ * @since v12.0.0
1225
2805
  */
1226
- function sign(
1227
- algorithm: string | null | undefined,
1228
- data: NodeJS.ArrayBufferView,
1229
- key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
1230
- ): Buffer;
2806
+ function sign(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput): Buffer;
1231
2807
  function sign(
1232
2808
  algorithm: string | null | undefined,
1233
2809
  data: NodeJS.ArrayBufferView,
1234
2810
  key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
1235
2811
  callback: (error: Error | null, data: Buffer) => void
1236
2812
  ): void;
1237
-
1238
2813
  /**
1239
- * Calculates and returns the signature for `data` using the given private key and
1240
- * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
1241
- * dependent upon the key type (especially Ed25519 and Ed448).
2814
+ * 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
2815
+ * key type (especially Ed25519 and Ed448).
1242
2816
  *
1243
2817
  * If `key` is not a `KeyObject`, this function behaves as if `key` had been
1244
- * passed to `crypto.createPublicKey()`.
2818
+ * passed to {@link createPublicKey}. If it is an object, the following
2819
+ * additional properties can be passed:
2820
+ *
2821
+ * The `signature` argument is the previously calculated signature for the `data`.
2822
+ *
2823
+ * Because public keys can be derived from private keys, a private key or a public
2824
+ * key may be passed for `key`.
2825
+ *
2826
+ * If the `callback` function is provided this function uses libuv's threadpool.
2827
+ * @since v12.0.0
1245
2828
  */
1246
- function verify(
1247
- algorithm: string | null | undefined,
1248
- data: NodeJS.ArrayBufferView,
1249
- key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput,
1250
- signature: NodeJS.ArrayBufferView,
1251
- ): boolean;
2829
+ function verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput, signature: NodeJS.ArrayBufferView): boolean;
1252
2830
  function verify(
1253
2831
  algorithm: string | null | undefined,
1254
2832
  data: NodeJS.ArrayBufferView,
@@ -1256,16 +2834,13 @@ declare module 'crypto' {
1256
2834
  signature: NodeJS.ArrayBufferView,
1257
2835
  callback: (error: Error | null, result: boolean) => void
1258
2836
  ): void;
1259
-
1260
2837
  /**
1261
- * Computes the Diffie-Hellman secret based on a privateKey and a publicKey.
1262
- * Both keys must have the same asymmetricKeyType, which must be one of
1263
- * 'dh' (for Diffie-Hellman), 'ec' (for ECDH), 'x448', or 'x25519' (for ECDH-ES).
2838
+ * Computes the Diffie-Hellman secret based on a `privateKey` and a `publicKey`.
2839
+ * 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).
2840
+ * @since v13.9.0, v12.17.0
1264
2841
  */
1265
2842
  function diffieHellman(options: { privateKey: KeyObject; publicKey: KeyObject }): Buffer;
1266
-
1267
2843
  type CipherMode = 'cbc' | 'ccm' | 'cfb' | 'ctr' | 'ecb' | 'gcm' | 'ocb' | 'ofb' | 'stream' | 'wrap' | 'xts';
1268
-
1269
2844
  interface CipherInfoOptions {
1270
2845
  /**
1271
2846
  * A test key length.
@@ -1276,7 +2851,6 @@ declare module 'crypto' {
1276
2851
  */
1277
2852
  ivLength?: number | undefined;
1278
2853
  }
1279
-
1280
2854
  interface CipherInfo {
1281
2855
  /**
1282
2856
  * The name of the cipher.
@@ -1305,64 +2879,95 @@ declare module 'crypto' {
1305
2879
  */
1306
2880
  mode: CipherMode;
1307
2881
  }
1308
-
1309
2882
  /**
1310
2883
  * Returns information about a given cipher.
1311
2884
  *
1312
- * Some ciphers accept variable length keys and initialization vectors.
1313
- * By default, the `crypto.getCipherInfo()` method will return the default
1314
- * values for these ciphers. To test if a given key length or iv length
1315
- * is acceptable for given cipher, use the `keyLenth` and `ivLenth` options.
1316
- * If the given values are unacceptable, `undefined` will be returned.
2885
+ * Some ciphers accept variable length keys and initialization vectors. By default,
2886
+ * the `crypto.getCipherInfo()` method will return the default values for these
2887
+ * ciphers. To test if a given key length or iv length is acceptable for given
2888
+ * cipher, use the `keyLength` and `ivLength` options. If the given values are
2889
+ * unacceptable, `undefined` will be returned.
2890
+ * @since v15.0.0
1317
2891
  * @param nameOrNid The name or nid of the cipher to query.
1318
2892
  */
1319
2893
  function getCipherInfo(nameOrNid: string | number, options?: CipherInfoOptions): CipherInfo | undefined;
1320
-
1321
2894
  /**
1322
- * HKDF is a simple key derivation function defined in RFC 5869.
1323
- * The given `key`, `salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
2895
+ * HKDF is a simple key derivation function defined in RFC 5869\. The given `ikm`,`salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
2896
+ *
2897
+ * The supplied `callback` function is called with two arguments: `err` and`derivedKey`. If an errors occurs while deriving the key, `err` will be set;
2898
+ * otherwise `err` will be `null`. The successfully generated `derivedKey` will
2899
+ * be passed to the callback as an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). An error will be thrown if any
2900
+ * of the input arguments specify invalid values or types.
1324
2901
  *
1325
- * The supplied `callback` function is called with two arguments: `err` and `derivedKey`.
1326
- * If an errors occurs while deriving the key, `err` will be set; otherwise `err` will be `null`.
1327
- * The successfully generated `derivedKey` will be passed to the callback as an `ArrayBuffer`.
1328
- * An error will be thrown if any of the input aguments specify invalid values or types.
2902
+ * ```js
2903
+ * import { Buffer } from 'buffer';
2904
+ * const {
2905
+ * hkdf
2906
+ * } = await import('crypto');
2907
+ *
2908
+ * hkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => {
2909
+ * if (err) throw err;
2910
+ * console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653'
2911
+ * });
2912
+ * ```
2913
+ * @since v15.0.0
2914
+ * @param digest The digest algorithm to use.
2915
+ * @param ikm The input keying material. It must be at least one byte in length.
2916
+ * @param salt The salt value. Must be provided but can be zero-length.
2917
+ * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes.
2918
+ * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512`
2919
+ * generates 64-byte hashes, making the maximum HKDF output 16320 bytes).
1329
2920
  */
1330
- function hkdf(digest: string, key: BinaryLike | KeyObject, salt: BinaryLike, info: BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: ArrayBuffer) => void): void;
1331
-
2921
+ function hkdf(digest: string, irm: BinaryLike | KeyObject, salt: BinaryLike, info: BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: ArrayBuffer) => void): void;
1332
2922
  /**
1333
- * Provides a synchronous HKDF key derivation function as defined in RFC 5869.
1334
- * The given `key`, `salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
2923
+ * Provides a synchronous HKDF key derivation function as defined in RFC 5869\. The
2924
+ * given `ikm`, `salt` and `info` are used with the `digest` to derive a key of`keylen` bytes.
2925
+ *
2926
+ * The successfully generated `derivedKey` will be returned as an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer).
1335
2927
  *
1336
- * The successfully generated `derivedKey` will be returned as an `ArrayBuffer`.
1337
- * An error will be thrown if any of the input aguments specify invalid values or types,
1338
- * or if the derived key cannot be generated.
2928
+ * An error will be thrown if any of the input arguments specify invalid values or
2929
+ * types, or if the derived key cannot be generated.
2930
+ *
2931
+ * ```js
2932
+ * import { Buffer } from 'buffer';
2933
+ * const {
2934
+ * hkdfSync
2935
+ * } = await import('crypto');
2936
+ *
2937
+ * const derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64);
2938
+ * console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653'
2939
+ * ```
2940
+ * @since v15.0.0
2941
+ * @param digest The digest algorithm to use.
2942
+ * @param ikm The input keying material. It must be at least one byte in length.
2943
+ * @param salt The salt value. Must be provided but can be zero-length.
2944
+ * @param info Additional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes.
2945
+ * @param keylen The length of the key to generate. Must be greater than 0. The maximum allowable value is `255` times the number of bytes produced by the selected digest function (e.g. `sha512`
2946
+ * generates 64-byte hashes, making the maximum HKDF output 16320 bytes).
1339
2947
  */
1340
- function hkdfSync(digest: string, key: BinaryLike | KeyObject, salt: BinaryLike, info: BinaryLike, keylen: number): ArrayBuffer;
1341
-
2948
+ function hkdfSync(digest: string, ikm: BinaryLike | KeyObject, salt: BinaryLike, info: BinaryLike, keylen: number): ArrayBuffer;
1342
2949
  interface SecureHeapUsage {
1343
2950
  /**
1344
2951
  * The total allocated secure heap size as specified using the `--secure-heap=n` command-line flag.
1345
2952
  */
1346
2953
  total: number;
1347
-
1348
2954
  /**
1349
2955
  * The minimum allocation from the secure heap as specified using the `--secure-heap-min` command-line flag.
1350
2956
  */
1351
2957
  min: number;
1352
-
1353
2958
  /**
1354
2959
  * The total number of bytes currently allocated from the secure heap.
1355
2960
  */
1356
2961
  used: number;
1357
-
1358
2962
  /**
1359
2963
  * The calculated ratio of `used` to `total` allocated bytes.
1360
2964
  */
1361
2965
  utilization: number;
1362
2966
  }
1363
-
2967
+ /**
2968
+ * @since v15.6.0
2969
+ */
1364
2970
  function secureHeapUsed(): SecureHeapUsage;
1365
-
1366
2971
  interface RandomUUIDOptions {
1367
2972
  /**
1368
2973
  * By default, to improve performance,
@@ -1374,166 +2979,175 @@ declare module 'crypto' {
1374
2979
  */
1375
2980
  disableEntropyCache?: boolean | undefined;
1376
2981
  }
1377
-
2982
+ /**
2983
+ * Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a
2984
+ * cryptographic pseudorandom number generator.
2985
+ * @since v15.6.0
2986
+ */
1378
2987
  function randomUUID(options?: RandomUUIDOptions): string;
1379
-
1380
2988
  interface X509CheckOptions {
1381
2989
  /**
1382
2990
  * @default 'always'
1383
2991
  */
1384
2992
  subject: 'always' | 'never';
1385
-
1386
2993
  /**
1387
2994
  * @default true
1388
2995
  */
1389
2996
  wildcards: boolean;
1390
-
1391
2997
  /**
1392
2998
  * @default true
1393
2999
  */
1394
3000
  partialWildcards: boolean;
1395
-
1396
3001
  /**
1397
3002
  * @default false
1398
3003
  */
1399
3004
  multiLabelWildcards: boolean;
1400
-
1401
3005
  /**
1402
3006
  * @default false
1403
3007
  */
1404
3008
  singleLabelSubdomains: boolean;
1405
3009
  }
1406
-
3010
+ /**
3011
+ * Encapsulates an X509 certificate and provides read-only access to
3012
+ * its information.
3013
+ *
3014
+ * ```js
3015
+ * const { X509Certificate } = await import('crypto');
3016
+ *
3017
+ * const x509 = new X509Certificate('{... pem encoded cert ...}');
3018
+ *
3019
+ * console.log(x509.subject);
3020
+ * ```
3021
+ * @since v15.6.0
3022
+ */
1407
3023
  class X509Certificate {
1408
3024
  /**
1409
- * Will be `true` if this is a Certificate Authority (ca) certificate.
3025
+ * Will be \`true\` if this is a Certificate Authority (ca) certificate.
3026
+ * @since v15.6.0
1410
3027
  */
1411
3028
  readonly ca: boolean;
1412
-
1413
3029
  /**
1414
3030
  * The SHA-1 fingerprint of this certificate.
3031
+ * @since v15.6.0
1415
3032
  */
1416
3033
  readonly fingerprint: string;
1417
-
1418
3034
  /**
1419
3035
  * The SHA-256 fingerprint of this certificate.
3036
+ * @since v15.6.0
1420
3037
  */
1421
3038
  readonly fingerprint256: string;
1422
-
1423
3039
  /**
1424
3040
  * The complete subject of this certificate.
3041
+ * @since v15.6.0
1425
3042
  */
1426
3043
  readonly subject: string;
1427
-
1428
3044
  /**
1429
3045
  * The subject alternative name specified for this certificate.
3046
+ * @since v15.6.0
1430
3047
  */
1431
3048
  readonly subjectAltName: string;
1432
-
1433
3049
  /**
1434
3050
  * The information access content of this certificate.
3051
+ * @since v15.6.0
1435
3052
  */
1436
3053
  readonly infoAccess: string;
1437
-
1438
3054
  /**
1439
3055
  * An array detailing the key usages for this certificate.
3056
+ * @since v15.6.0
1440
3057
  */
1441
3058
  readonly keyUsage: string[];
1442
-
1443
3059
  /**
1444
3060
  * The issuer identification included in this certificate.
3061
+ * @since v15.6.0
1445
3062
  */
1446
3063
  readonly issuer: string;
1447
-
1448
3064
  /**
1449
- * The issuer certificate or `undefined` if the issuer certificate is not available.
3065
+ * The issuer certificate or `undefined` if the issuer certificate is not
3066
+ * available.
3067
+ * @since v15.9.0
1450
3068
  */
1451
3069
  readonly issuerCertificate?: X509Certificate | undefined;
1452
-
1453
3070
  /**
1454
- * The public key for this certificate.
3071
+ * The public key `KeyObject` for this certificate.
3072
+ * @since v15.6.0
1455
3073
  */
1456
3074
  readonly publicKey: KeyObject;
1457
-
1458
3075
  /**
1459
3076
  * A `Buffer` containing the DER encoding of this certificate.
3077
+ * @since v15.6.0
1460
3078
  */
1461
3079
  readonly raw: Buffer;
1462
-
1463
3080
  /**
1464
3081
  * The serial number of this certificate.
3082
+ * @since v15.6.0
1465
3083
  */
1466
3084
  readonly serialNumber: string;
1467
-
1468
3085
  /**
1469
- * Returns the PEM-encoded certificate.
3086
+ * The date/time from which this certificate is considered valid.
3087
+ * @since v15.6.0
1470
3088
  */
1471
3089
  readonly validFrom: string;
1472
-
1473
3090
  /**
1474
- * The date/time from which this certificate is considered valid.
3091
+ * The date/time until which this certificate is considered valid.
3092
+ * @since v15.6.0
1475
3093
  */
1476
3094
  readonly validTo: string;
1477
-
1478
3095
  constructor(buffer: BinaryLike);
1479
-
1480
3096
  /**
1481
3097
  * Checks whether the certificate matches the given email address.
1482
- *
1483
- * Returns `email` if the certificate matches,`undefined` if it does not.
3098
+ * @since v15.6.0
3099
+ * @return Returns `email` if the certificate matches, `undefined` if it does not.
1484
3100
  */
1485
3101
  checkEmail(email: string, options?: X509CheckOptions): string | undefined;
1486
-
1487
3102
  /**
1488
3103
  * Checks whether the certificate matches the given host name.
1489
- *
1490
- * Returns `name` if the certificate matches, `undefined` if it does not.
3104
+ * @since v15.6.0
3105
+ * @return Returns `name` if the certificate matches, `undefined` if it does not.
1491
3106
  */
1492
3107
  checkHost(name: string, options?: X509CheckOptions): string | undefined;
1493
-
1494
3108
  /**
1495
3109
  * Checks whether the certificate matches the given IP address (IPv4 or IPv6).
1496
- *
1497
- * Returns `ip` if the certificate matches, `undefined` if it does not.
3110
+ * @since v15.6.0
3111
+ * @return Returns `ip` if the certificate matches, `undefined` if it does not.
1498
3112
  */
1499
3113
  checkIP(ip: string, options?: X509CheckOptions): string | undefined;
1500
-
1501
3114
  /**
1502
3115
  * Checks whether this certificate was issued by the given `otherCert`.
3116
+ * @since v15.6.0
1503
3117
  */
1504
3118
  checkIssued(otherCert: X509Certificate): boolean;
1505
-
1506
3119
  /**
1507
- * Checks whether this certificate was issued by the given `otherCert`.
3120
+ * Checks whether the public key for this certificate is consistent with
3121
+ * the given private key.
3122
+ * @since v15.6.0
3123
+ * @param privateKey A private key.
1508
3124
  */
1509
3125
  checkPrivateKey(privateKey: KeyObject): boolean;
1510
-
1511
3126
  /**
1512
- * There is no standard JSON encoding for X509 certificates. The
1513
- * `toJSON()` method returns a string containing the PEM encoded
3127
+ * There is no standard JSON encoding for X509 certificates. The`toJSON()` method returns a string containing the PEM encoded
1514
3128
  * certificate.
3129
+ * @since v15.6.0
1515
3130
  */
1516
3131
  toJSON(): string;
1517
-
1518
3132
  /**
1519
- * Returns information about this certificate using the legacy certificate object encoding.
3133
+ * Returns information about this certificate using the legacy `certificate object` encoding.
3134
+ * @since v15.6.0
1520
3135
  */
1521
3136
  toLegacyObject(): PeerCertificate;
1522
-
1523
3137
  /**
1524
3138
  * Returns the PEM-encoded certificate.
3139
+ * @since v15.6.0
1525
3140
  */
1526
3141
  toString(): string;
1527
-
1528
3142
  /**
1529
3143
  * Verifies that this certificate was signed by the given public key.
1530
3144
  * Does not perform any other validation checks on the certificate.
3145
+ * @since v15.6.0
3146
+ * @param publicKey A public key.
1531
3147
  */
1532
3148
  verify(publicKey: KeyObject): boolean;
1533
3149
  }
1534
-
1535
3150
  type LargeNumberLike = NodeJS.ArrayBufferView | SharedArrayBuffer | ArrayBuffer | bigint;
1536
-
1537
3151
  interface GeneratePrimeOptions {
1538
3152
  add?: LargeNumberLike | undefined;
1539
3153
  rem?: LargeNumberLike | undefined;
@@ -1543,25 +3157,74 @@ declare module 'crypto' {
1543
3157
  safe?: boolean | undefined;
1544
3158
  bigint?: boolean | undefined;
1545
3159
  }
1546
-
1547
3160
  interface GeneratePrimeOptionsBigInt extends GeneratePrimeOptions {
1548
3161
  bigint: true;
1549
3162
  }
1550
-
1551
3163
  interface GeneratePrimeOptionsArrayBuffer extends GeneratePrimeOptions {
1552
3164
  bigint?: false | undefined;
1553
3165
  }
1554
-
3166
+ /**
3167
+ * Generates a pseudorandom prime of `size` bits.
3168
+ *
3169
+ * If `options.safe` is `true`, the prime will be a safe prime -- that is,`(prime - 1) / 2` will also be a prime.
3170
+ *
3171
+ * The `options.add` and `options.rem` parameters can be used to enforce additional
3172
+ * requirements, e.g., for Diffie-Hellman:
3173
+ *
3174
+ * * If `options.add` and `options.rem` are both set, the prime will satisfy the
3175
+ * condition that `prime % add = rem`.
3176
+ * * If only `options.add` is set and `options.safe` is not `true`, the prime will
3177
+ * satisfy the condition that `prime % add = 1`.
3178
+ * * If only `options.add` is set and `options.safe` is set to `true`, the prime
3179
+ * will instead satisfy the condition that `prime % add = 3`. This is necessary
3180
+ * because `prime % add = 1` for `options.add > 2` would contradict the condition
3181
+ * enforced by `options.safe`.
3182
+ * * `options.rem` is ignored if `options.add` is not given.
3183
+ *
3184
+ * Both `options.add` and `options.rem` must be encoded as big-endian sequences
3185
+ * if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or`DataView`.
3186
+ *
3187
+ * By default, the prime is encoded as a big-endian sequence of octets
3188
+ * in an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). If the `bigint` option is `true`, then a
3189
+ * [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) is provided.
3190
+ * @since v15.8.0
3191
+ * @param size The size (in bits) of the prime to generate.
3192
+ */
1555
3193
  function generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
1556
3194
  function generatePrime(size: number, options: GeneratePrimeOptionsBigInt, callback: (err: Error | null, prime: bigint) => void): void;
1557
3195
  function generatePrime(size: number, options: GeneratePrimeOptionsArrayBuffer, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
1558
3196
  function generatePrime(size: number, options: GeneratePrimeOptions, callback: (err: Error | null, prime: ArrayBuffer | bigint) => void): void;
1559
-
3197
+ /**
3198
+ * Generates a pseudorandom prime of `size` bits.
3199
+ *
3200
+ * If `options.safe` is `true`, the prime will be a safe prime -- that is,`(prime - 1) / 2` will also be a prime.
3201
+ *
3202
+ * The `options.add` and `options.rem` parameters can be used to enforce additional
3203
+ * requirements, e.g., for Diffie-Hellman:
3204
+ *
3205
+ * * If `options.add` and `options.rem` are both set, the prime will satisfy the
3206
+ * condition that `prime % add = rem`.
3207
+ * * If only `options.add` is set and `options.safe` is not `true`, the prime will
3208
+ * satisfy the condition that `prime % add = 1`.
3209
+ * * If only `options.add` is set and `options.safe` is set to `true`, the prime
3210
+ * will instead satisfy the condition that `prime % add = 3`. This is necessary
3211
+ * because `prime % add = 1` for `options.add > 2` would contradict the condition
3212
+ * enforced by `options.safe`.
3213
+ * * `options.rem` is ignored if `options.add` is not given.
3214
+ *
3215
+ * Both `options.add` and `options.rem` must be encoded as big-endian sequences
3216
+ * if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or`DataView`.
3217
+ *
3218
+ * By default, the prime is encoded as a big-endian sequence of octets
3219
+ * in an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). If the `bigint` option is `true`, then a
3220
+ * [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) is provided.
3221
+ * @since v15.8.0
3222
+ * @param size The size (in bits) of the prime to generate.
3223
+ */
1560
3224
  function generatePrimeSync(size: number): ArrayBuffer;
1561
3225
  function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint;
1562
3226
  function generatePrimeSync(size: number, options: GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
1563
3227
  function generatePrimeSync(size: number, options: GeneratePrimeOptions): ArrayBuffer | bigint;
1564
-
1565
3228
  interface CheckPrimeOptions {
1566
3229
  /**
1567
3230
  * The number of Miller-Rabin probabilistic primality iterations to perform.
@@ -1573,23 +3236,24 @@ declare module 'crypto' {
1573
3236
  */
1574
3237
  checks?: number | undefined;
1575
3238
  }
1576
-
1577
3239
  /**
1578
- * Checks the primality of the candidate.
3240
+ * Checks the primality of the `candidate`.
3241
+ * @since v15.8.0
3242
+ * @param candidate A possible prime encoded as a sequence of big endian octets of arbitrary length.
1579
3243
  */
1580
3244
  function checkPrime(value: LargeNumberLike, callback: (err: Error | null, result: boolean) => void): void;
1581
3245
  function checkPrime(value: LargeNumberLike, options: CheckPrimeOptions, callback: (err: Error | null, result: boolean) => void): void;
1582
-
1583
3246
  /**
1584
- * Checks the primality of the candidate.
3247
+ * Checks the primality of the `candidate`.
3248
+ * @since v15.8.0
3249
+ * @param candidate A possible prime encoded as a sequence of big endian octets of arbitrary length.
3250
+ * @return `true` if the candidate is a prime with an error probability less than `0.25 ** options.checks`.
1585
3251
  */
1586
- function checkPrimeSync(value: LargeNumberLike, options?: CheckPrimeOptions): boolean;
1587
-
3252
+ function checkPrimeSync(candidate: LargeNumberLike, options?: CheckPrimeOptions): boolean;
1588
3253
  namespace webcrypto {
1589
3254
  class CryptoKey {} // placeholder
1590
3255
  }
1591
3256
  }
1592
-
1593
3257
  declare module 'node:crypto' {
1594
3258
  export * from 'crypto';
1595
3259
  }