@wbce/projen-d9 0.0.28 → 0.1.0

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 (421) hide show
  1. package/.jsii +184 -45
  2. package/API.md +153 -37
  3. package/CHANGELOG.md +13 -0
  4. package/README.md +10 -3
  5. package/docs/D9-plumbing.md +189 -0
  6. package/lib/cli/atlas.d.ts +10 -0
  7. package/lib/cli/atlas.js +65 -0
  8. package/lib/cli/commands/cedar/cedar-format.d.ts +7 -0
  9. package/lib/cli/commands/cedar/cedar-format.js +75 -0
  10. package/lib/cli/commands/cedar/cedar-to-d9-translations.d.ts +12 -0
  11. package/lib/cli/commands/cedar/cedar-to-d9-translations.js +130 -0
  12. package/lib/cli/commands/cedar/cedar-to-d9.d.ts +57 -0
  13. package/lib/cli/commands/cedar/cedar-to-d9.js +221 -0
  14. package/lib/cli/commands/cedar/cedar-translations.d.ts +9 -0
  15. package/lib/cli/commands/cedar/cedar-translations.js +213 -0
  16. package/lib/cli/commands/cedar/d9-permission.d.ts +27 -0
  17. package/lib/cli/commands/cedar/d9-permission.js +45 -0
  18. package/lib/cli/commands/cedar/d9-to-cedar.d.ts +33 -0
  19. package/lib/cli/commands/cedar/d9-to-cedar.js +157 -0
  20. package/lib/cli/commands/cedar/roles-table.d.ts +14 -0
  21. package/lib/cli/commands/cedar/roles-table.js +29 -0
  22. package/lib/cli/commands/save/apply-snapshot.js +39 -30
  23. package/lib/cli/commands/save/check-unsaved.d.ts +9 -0
  24. package/lib/cli/commands/save/check-unsaved.js +81 -0
  25. package/lib/cli/commands/save/env.d.ts +33 -0
  26. package/lib/cli/commands/save/env.js +109 -0
  27. package/lib/cli/commands/save/save-snapshot.d.ts +9 -0
  28. package/lib/cli/commands/save/save-snapshot.js +232 -0
  29. package/lib/cli/commands/save/sync-files.d.ts +5 -0
  30. package/lib/cli/commands/save/sync-files.js +46 -0
  31. package/lib/cli/commands/save/transfer.d.ts +18 -0
  32. package/lib/cli/commands/save/transfer.js +96 -0
  33. package/lib/cli/commands/save/utils.d.ts +5 -0
  34. package/lib/cli/commands/save/utils.js +33 -3
  35. package/lib/cli/commands/sync.js +4 -3
  36. package/lib/cli/index.js +65 -25
  37. package/lib/cli/logger.d.ts +2 -0
  38. package/lib/cli/logger.js +10 -0
  39. package/lib/cli/plumbing-config.d.ts +11 -0
  40. package/lib/cli/plumbing-config.js +13 -0
  41. package/lib/index.d.ts +44 -5
  42. package/lib/index.js +54 -41
  43. package/node_modules/@cedar-policy/cedar-wasm/README.md +181 -0
  44. package/node_modules/@cedar-policy/cedar-wasm/esm/README.md +181 -0
  45. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm.d.ts +427 -0
  46. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm.js +9 -0
  47. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.js +434 -0
  48. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.wasm +0 -0
  49. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.wasm.d.ts +34 -0
  50. package/node_modules/@cedar-policy/cedar-wasm/esm/package.json +23 -0
  51. package/node_modules/@cedar-policy/cedar-wasm/nodejs/README.md +181 -0
  52. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm.d.ts +427 -0
  53. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm.js +463 -0
  54. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm_bg.wasm +0 -0
  55. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm_bg.wasm.d.ts +34 -0
  56. package/node_modules/@cedar-policy/cedar-wasm/nodejs/package.json +18 -0
  57. package/node_modules/@cedar-policy/cedar-wasm/package.json +53 -0
  58. package/node_modules/@cedar-policy/cedar-wasm/web/README.md +181 -0
  59. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm.d.ts +486 -0
  60. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm.js +534 -0
  61. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm_bg.wasm +0 -0
  62. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm_bg.wasm.d.ts +34 -0
  63. package/node_modules/@cedar-policy/cedar-wasm/web/package.json +21 -0
  64. package/node_modules/@types/node/README.md +5 -6
  65. package/node_modules/@types/node/assert/strict.d.ts +111 -0
  66. package/node_modules/@types/node/assert.d.ts +1040 -79
  67. package/node_modules/@types/node/async_hooks.d.ts +476 -119
  68. package/node_modules/@types/node/buffer.buffer.d.ts +472 -0
  69. package/node_modules/@types/node/buffer.d.ts +1925 -13
  70. package/node_modules/@types/node/child_process.d.ts +1204 -235
  71. package/node_modules/@types/node/cluster.d.ts +455 -137
  72. package/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
  73. package/node_modules/@types/node/compatibility/index.d.ts +9 -0
  74. package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
  75. package/node_modules/@types/node/compatibility/iterators.d.ts +20 -0
  76. package/node_modules/@types/node/console.d.ts +450 -1
  77. package/node_modules/@types/node/constants.d.ts +20 -447
  78. package/node_modules/@types/node/crypto.d.ts +3962 -600
  79. package/node_modules/@types/node/dgram.d.ts +515 -33
  80. package/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
  81. package/node_modules/@types/node/dns/promises.d.ts +503 -0
  82. package/node_modules/@types/node/dns.d.ts +798 -247
  83. package/node_modules/@types/node/domain.d.ts +164 -10
  84. package/node_modules/@types/node/events.d.ts +954 -25
  85. package/node_modules/@types/node/fs/promises.d.ts +1295 -0
  86. package/node_modules/@types/node/fs.d.ts +3463 -1569
  87. package/node_modules/@types/node/globals.d.ts +98 -1277
  88. package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
  89. package/node_modules/@types/node/http.d.ts +1933 -300
  90. package/node_modules/@types/node/http2.d.ts +1946 -254
  91. package/node_modules/@types/node/https.d.ts +557 -134
  92. package/node_modules/@types/node/index.d.ts +54 -48
  93. package/node_modules/@types/node/inspector.d.ts +227 -3014
  94. package/node_modules/@types/node/inspector.generated.d.ts +4052 -0
  95. package/node_modules/@types/node/module.d.ts +890 -2
  96. package/node_modules/@types/node/net.d.ts +872 -105
  97. package/node_modules/@types/node/os.d.ts +452 -209
  98. package/node_modules/@types/node/package.json +78 -128
  99. package/node_modules/@types/node/path.d.ts +196 -155
  100. package/node_modules/@types/node/perf_hooks.d.ts +829 -120
  101. package/node_modules/@types/node/process.d.ts +2072 -3
  102. package/node_modules/@types/node/punycode.d.ts +69 -27
  103. package/node_modules/@types/node/querystring.d.ts +132 -9
  104. package/node_modules/@types/node/readline/promises.d.ts +161 -0
  105. package/node_modules/@types/node/readline.d.ts +485 -49
  106. package/node_modules/@types/node/repl.d.ts +121 -83
  107. package/node_modules/@types/node/sea.d.ts +153 -0
  108. package/node_modules/@types/node/sqlite.d.ts +721 -0
  109. package/node_modules/@types/node/stream/consumers.d.ts +38 -0
  110. package/node_modules/@types/node/stream/promises.d.ts +90 -0
  111. package/node_modules/@types/node/stream/web.d.ts +622 -0
  112. package/node_modules/@types/node/stream.d.ts +1470 -140
  113. package/node_modules/@types/node/string_decoder.d.ts +64 -4
  114. package/node_modules/@types/node/test.d.ts +2163 -0
  115. package/node_modules/@types/node/timers/promises.d.ts +108 -0
  116. package/node_modules/@types/node/timers.d.ts +284 -13
  117. package/node_modules/@types/node/tls.d.ts +850 -244
  118. package/node_modules/@types/node/trace_events.d.ts +147 -11
  119. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
  120. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
  121. package/node_modules/@types/node/ts5.6/index.d.ts +97 -0
  122. package/node_modules/@types/node/tty.d.ts +160 -18
  123. package/node_modules/@types/node/url.d.ts +890 -53
  124. package/node_modules/@types/node/util.d.ts +2566 -160
  125. package/node_modules/@types/node/v8.d.ts +806 -83
  126. package/node_modules/@types/node/vm.d.ts +932 -44
  127. package/node_modules/@types/node/wasi.d.ts +148 -22
  128. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  129. package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  130. package/node_modules/@types/node/web-globals/events.d.ts +97 -0
  131. package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
  132. package/node_modules/@types/node/web-globals/navigator.d.ts +22 -0
  133. package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  134. package/node_modules/@types/node/worker_threads.d.ts +657 -80
  135. package/node_modules/@types/node/zlib.d.ts +510 -119
  136. package/node_modules/pino/.nojekyll +0 -0
  137. package/node_modules/pino/.prettierignore +1 -0
  138. package/node_modules/pino/CNAME +1 -0
  139. package/node_modules/pino/CONTRIBUTING.md +34 -0
  140. package/node_modules/pino/LICENSE +21 -0
  141. package/node_modules/pino/README.md +177 -0
  142. package/node_modules/pino/SECURITY.md +103 -0
  143. package/node_modules/pino/benchmarks/basic.bench.js +95 -0
  144. package/node_modules/pino/benchmarks/child-child.bench.js +52 -0
  145. package/node_modules/pino/benchmarks/child-creation.bench.js +73 -0
  146. package/node_modules/pino/benchmarks/child.bench.js +62 -0
  147. package/node_modules/pino/benchmarks/deep-object.bench.js +88 -0
  148. package/node_modules/pino/benchmarks/formatters.bench.js +50 -0
  149. package/node_modules/pino/benchmarks/internal/custom-levels.js +67 -0
  150. package/node_modules/pino/benchmarks/internal/just-pino-heavy.bench.js +76 -0
  151. package/node_modules/pino/benchmarks/internal/just-pino.bench.js +182 -0
  152. package/node_modules/pino/benchmarks/internal/parent-vs-child.bench.js +75 -0
  153. package/node_modules/pino/benchmarks/internal/redact.bench.js +86 -0
  154. package/node_modules/pino/benchmarks/long-string.bench.js +81 -0
  155. package/node_modules/pino/benchmarks/multi-arg.bench.js +193 -0
  156. package/node_modules/pino/benchmarks/multistream.js +98 -0
  157. package/node_modules/pino/benchmarks/object.bench.js +82 -0
  158. package/node_modules/pino/benchmarks/utils/generate-benchmark-doc.js +36 -0
  159. package/node_modules/pino/benchmarks/utils/runbench.js +138 -0
  160. package/node_modules/pino/benchmarks/utils/wrap-log-level.js +55 -0
  161. package/node_modules/pino/bin.js +6 -0
  162. package/node_modules/pino/browser.js +607 -0
  163. package/node_modules/pino/build/sync-version.js +25 -0
  164. package/node_modules/pino/docs/api.md +1664 -0
  165. package/node_modules/pino/docs/asynchronous.md +55 -0
  166. package/node_modules/pino/docs/benchmarks.md +55 -0
  167. package/node_modules/pino/docs/browser.md +341 -0
  168. package/node_modules/pino/docs/bundling.md +40 -0
  169. package/node_modules/pino/docs/child-loggers.md +116 -0
  170. package/node_modules/pino/docs/diagnostics.md +16 -0
  171. package/node_modules/pino/docs/ecosystem.md +87 -0
  172. package/node_modules/pino/docs/help.md +353 -0
  173. package/node_modules/pino/docs/lts.md +93 -0
  174. package/node_modules/pino/docs/pretty.md +38 -0
  175. package/node_modules/pino/docs/redaction.md +130 -0
  176. package/node_modules/pino/docs/transports.md +1447 -0
  177. package/node_modules/pino/docs/web.md +306 -0
  178. package/node_modules/pino/eslint.config.js +36 -0
  179. package/node_modules/pino/examples/basic.js +43 -0
  180. package/node_modules/pino/examples/transport.js +68 -0
  181. package/node_modules/pino/favicon.ico +0 -0
  182. package/node_modules/pino/file.js +12 -0
  183. package/node_modules/pino/inc-version.sh +42 -0
  184. package/node_modules/pino/index.html +55 -0
  185. package/node_modules/pino/lib/caller.js +40 -0
  186. package/node_modules/pino/lib/constants.js +28 -0
  187. package/node_modules/pino/lib/deprecations.js +8 -0
  188. package/node_modules/pino/lib/levels.js +241 -0
  189. package/node_modules/pino/lib/meta.js +3 -0
  190. package/node_modules/pino/lib/multistream.js +211 -0
  191. package/node_modules/pino/lib/proto.js +256 -0
  192. package/node_modules/pino/lib/redaction.js +119 -0
  193. package/node_modules/pino/lib/symbols.js +76 -0
  194. package/node_modules/pino/lib/time.js +39 -0
  195. package/node_modules/pino/lib/tools.js +427 -0
  196. package/node_modules/pino/lib/transport-stream.js +56 -0
  197. package/node_modules/pino/lib/transport.js +302 -0
  198. package/node_modules/pino/lib/worker.js +197 -0
  199. package/node_modules/pino/package.json +112 -0
  200. package/node_modules/pino/pino.d.ts +881 -0
  201. package/node_modules/pino/pino.js +259 -0
  202. package/node_modules/pino/test/basic.test.js +952 -0
  203. package/node_modules/pino/test/broken-pipe.test.js +59 -0
  204. package/node_modules/pino/test/browser-bindings.test.js +114 -0
  205. package/node_modules/pino/test/browser-child.test.js +132 -0
  206. package/node_modules/pino/test/browser-disabled.test.js +87 -0
  207. package/node_modules/pino/test/browser-early-console-freeze.test.js +12 -0
  208. package/node_modules/pino/test/browser-is-level-enabled.test.js +101 -0
  209. package/node_modules/pino/test/browser-levels.test.js +241 -0
  210. package/node_modules/pino/test/browser-redaction.test.js +264 -0
  211. package/node_modules/pino/test/browser-serializers.test.js +352 -0
  212. package/node_modules/pino/test/browser-set-bindings.test.js +99 -0
  213. package/node_modules/pino/test/browser-timestamp.test.js +88 -0
  214. package/node_modules/pino/test/browser-transmit.test.js +417 -0
  215. package/node_modules/pino/test/browser.test.js +698 -0
  216. package/node_modules/pino/test/caller.test.js +20 -0
  217. package/node_modules/pino/test/complex-objects.test.js +36 -0
  218. package/node_modules/pino/test/crlf.test.js +34 -0
  219. package/node_modules/pino/test/custom-levels.test.js +267 -0
  220. package/node_modules/pino/test/diagnostics.test.js +107 -0
  221. package/node_modules/pino/test/error-key.test.js +37 -0
  222. package/node_modules/pino/test/error.test.js +403 -0
  223. package/node_modules/pino/test/escaping.test.js +110 -0
  224. package/node_modules/pino/test/esm/esm.mjs +14 -0
  225. package/node_modules/pino/test/esm/index.test.js +21 -0
  226. package/node_modules/pino/test/esm/named-exports.mjs +29 -0
  227. package/node_modules/pino/test/exit.test.js +79 -0
  228. package/node_modules/pino/test/fixtures/broken-pipe/basic.js +9 -0
  229. package/node_modules/pino/test/fixtures/broken-pipe/destination.js +10 -0
  230. package/node_modules/pino/test/fixtures/broken-pipe/syncfalse.js +12 -0
  231. package/node_modules/pino/test/fixtures/caller-loop.js +6 -0
  232. package/node_modules/pino/test/fixtures/console-transport.js +13 -0
  233. package/node_modules/pino/test/fixtures/crashing-transport.js +13 -0
  234. package/node_modules/pino/test/fixtures/default-exit.js +8 -0
  235. package/node_modules/pino/test/fixtures/destination-exit.js +8 -0
  236. package/node_modules/pino/test/fixtures/eval/index.js +13 -0
  237. package/node_modules/pino/test/fixtures/eval/node_modules/14-files.js +3 -0
  238. package/node_modules/pino/test/fixtures/eval/node_modules/2-files.js +3 -0
  239. package/node_modules/pino/test/fixtures/eval/node_modules/file1.js +5 -0
  240. package/node_modules/pino/test/fixtures/eval/node_modules/file10.js +5 -0
  241. package/node_modules/pino/test/fixtures/eval/node_modules/file11.js +5 -0
  242. package/node_modules/pino/test/fixtures/eval/node_modules/file12.js +5 -0
  243. package/node_modules/pino/test/fixtures/eval/node_modules/file13.js +5 -0
  244. package/node_modules/pino/test/fixtures/eval/node_modules/file14.js +11 -0
  245. package/node_modules/pino/test/fixtures/eval/node_modules/file2.js +5 -0
  246. package/node_modules/pino/test/fixtures/eval/node_modules/file3.js +5 -0
  247. package/node_modules/pino/test/fixtures/eval/node_modules/file4.js +5 -0
  248. package/node_modules/pino/test/fixtures/eval/node_modules/file5.js +5 -0
  249. package/node_modules/pino/test/fixtures/eval/node_modules/file6.js +5 -0
  250. package/node_modules/pino/test/fixtures/eval/node_modules/file7.js +5 -0
  251. package/node_modules/pino/test/fixtures/eval/node_modules/file8.js +5 -0
  252. package/node_modules/pino/test/fixtures/eval/node_modules/file9.js +5 -0
  253. package/node_modules/pino/test/fixtures/noop-transport.js +10 -0
  254. package/node_modules/pino/test/fixtures/pretty/null-prototype.js +8 -0
  255. package/node_modules/pino/test/fixtures/stdout-hack-protection.js +11 -0
  256. package/node_modules/pino/test/fixtures/syncfalse-child.js +6 -0
  257. package/node_modules/pino/test/fixtures/syncfalse-exit.js +9 -0
  258. package/node_modules/pino/test/fixtures/syncfalse-flush-exit.js +10 -0
  259. package/node_modules/pino/test/fixtures/syncfalse.js +6 -0
  260. package/node_modules/pino/test/fixtures/syntax-error-esm.mjs +2 -0
  261. package/node_modules/pino/test/fixtures/to-file-transport-with-transform.js +20 -0
  262. package/node_modules/pino/test/fixtures/to-file-transport.js +13 -0
  263. package/node_modules/pino/test/fixtures/to-file-transport.mjs +8 -0
  264. package/node_modules/pino/test/fixtures/transport/index.js +12 -0
  265. package/node_modules/pino/test/fixtures/transport/package.json +5 -0
  266. package/node_modules/pino/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
  267. package/node_modules/pino/test/fixtures/transport-exit-immediately.js +11 -0
  268. package/node_modules/pino/test/fixtures/transport-exit-on-ready.js +12 -0
  269. package/node_modules/pino/test/fixtures/transport-invalid-node-options.js +26 -0
  270. package/node_modules/pino/test/fixtures/transport-main.js +9 -0
  271. package/node_modules/pino/test/fixtures/transport-many-lines.js +29 -0
  272. package/node_modules/pino/test/fixtures/transport-preload-main.mjs +13 -0
  273. package/node_modules/pino/test/fixtures/transport-preload.mjs +13 -0
  274. package/node_modules/pino/test/fixtures/transport-string-stdout.js +9 -0
  275. package/node_modules/pino/test/fixtures/transport-transform.js +21 -0
  276. package/node_modules/pino/test/fixtures/transport-uses-pino-config.js +33 -0
  277. package/node_modules/pino/test/fixtures/transport-with-on-exit.js +12 -0
  278. package/node_modules/pino/test/fixtures/transport-worker-data.js +19 -0
  279. package/node_modules/pino/test/fixtures/transport-worker-name.js +24 -0
  280. package/node_modules/pino/test/fixtures/transport-worker.js +15 -0
  281. package/node_modules/pino/test/fixtures/transport-wrong-export-type.js +3 -0
  282. package/node_modules/pino/test/fixtures/ts/to-file-transport-native.mts +15 -0
  283. package/node_modules/pino/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
  284. package/node_modules/pino/test/fixtures/ts/to-file-transport.ts +11 -0
  285. package/node_modules/pino/test/fixtures/ts/transpile.cjs +36 -0
  286. package/node_modules/pino/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
  287. package/node_modules/pino/test/fixtures/ts/transport-exit-immediately.ts +10 -0
  288. package/node_modules/pino/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
  289. package/node_modules/pino/test/fixtures/ts/transport-main.ts +8 -0
  290. package/node_modules/pino/test/fixtures/ts/transport-string-stdout.ts +8 -0
  291. package/node_modules/pino/test/fixtures/ts/transport-worker.ts +14 -0
  292. package/node_modules/pino/test/formatters.test.js +364 -0
  293. package/node_modules/pino/test/helper.d.ts +4 -0
  294. package/node_modules/pino/test/helper.js +159 -0
  295. package/node_modules/pino/test/hooks.test.js +114 -0
  296. package/node_modules/pino/test/http.test.js +214 -0
  297. package/node_modules/pino/test/internals/version.test.js +17 -0
  298. package/node_modules/pino/test/is-level-enabled.test.js +179 -0
  299. package/node_modules/pino/test/jest/basic.spec.js +10 -0
  300. package/node_modules/pino/test/levels.test.js +810 -0
  301. package/node_modules/pino/test/metadata.test.js +120 -0
  302. package/node_modules/pino/test/mixin-merge-strategy.test.js +57 -0
  303. package/node_modules/pino/test/mixin.test.js +241 -0
  304. package/node_modules/pino/test/multistream.test.js +793 -0
  305. package/node_modules/pino/test/redact.test.js +923 -0
  306. package/node_modules/pino/test/serializers.test.js +257 -0
  307. package/node_modules/pino/test/smoke.js +59 -0
  308. package/node_modules/pino/test/stdout-protection.test.js +41 -0
  309. package/node_modules/pino/test/syncfalse.test.js +186 -0
  310. package/node_modules/pino/test/timestamp-nano.test.js +37 -0
  311. package/node_modules/pino/test/timestamp.test.js +124 -0
  312. package/node_modules/pino/test/transport/big.test.js +42 -0
  313. package/node_modules/pino/test/transport/bundlers-support.test.js +99 -0
  314. package/node_modules/pino/test/transport/caller.test.js +24 -0
  315. package/node_modules/pino/test/transport/core.test.js +818 -0
  316. package/node_modules/pino/test/transport/core.transpiled.test.ts +114 -0
  317. package/node_modules/pino/test/transport/crash.test.js +36 -0
  318. package/node_modules/pino/test/transport/module-link.test.js +241 -0
  319. package/node_modules/pino/test/transport/native-type-stripping.test.mjs +151 -0
  320. package/node_modules/pino/test/transport/node-options.test.js +116 -0
  321. package/node_modules/pino/test/transport/pipeline.test.js +137 -0
  322. package/node_modules/pino/test/transport/preload.test.js +54 -0
  323. package/node_modules/pino/test/transport/repl.test.js +15 -0
  324. package/node_modules/pino/test/transport/sync-false.test.js +79 -0
  325. package/node_modules/pino/test/transport/sync-true.test.js +57 -0
  326. package/node_modules/pino/test/transport/targets.test.js +48 -0
  327. package/node_modules/pino/test/transport/uses-pino-config.test.js +166 -0
  328. package/node_modules/pino/test/transport-stream.test.js +40 -0
  329. package/node_modules/pino/test/types/pino-import.tst.cts +30 -0
  330. package/node_modules/pino/test/types/pino-import.tst.js +73 -0
  331. package/node_modules/pino/test/types/pino-multistream.tst.ts +49 -0
  332. package/node_modules/pino/test/types/pino-top-export.tst.ts +32 -0
  333. package/node_modules/pino/test/types/pino-transport.tst.ts +171 -0
  334. package/node_modules/pino/test/types/pino-type-only.tst.ts +77 -0
  335. package/node_modules/pino/test/types/pino.ts +98 -0
  336. package/node_modules/pino/test/types/pino.tst.ts +681 -0
  337. package/node_modules/pino/test/types/tsconfig.json +10 -0
  338. package/node_modules/pino/tsconfig.json +14 -0
  339. package/node_modules/pino-pretty/.borp.yaml +6 -0
  340. package/node_modules/pino-pretty/.editorconfig +13 -0
  341. package/node_modules/pino-pretty/.github/dependabot.yml +13 -0
  342. package/node_modules/pino-pretty/.github/workflows/ci.yml +83 -0
  343. package/node_modules/pino-pretty/LICENSE +21 -0
  344. package/node_modules/pino-pretty/Readme.md +425 -0
  345. package/node_modules/pino-pretty/SECURITY.md +146 -0
  346. package/node_modules/pino-pretty/benchmark.js +105 -0
  347. package/node_modules/pino-pretty/bin.js +113 -0
  348. package/node_modules/pino-pretty/demo.png +0 -0
  349. package/node_modules/pino-pretty/docs/help.md +24 -0
  350. package/node_modules/pino-pretty/eslint.config.js +5 -0
  351. package/node_modules/pino-pretty/help/help.txt +68 -0
  352. package/node_modules/pino-pretty/index.d.ts +227 -0
  353. package/node_modules/pino-pretty/index.js +234 -0
  354. package/node_modules/pino-pretty/lib/colors.js +134 -0
  355. package/node_modules/pino-pretty/lib/colors.test.js +132 -0
  356. package/node_modules/pino-pretty/lib/constants.js +55 -0
  357. package/node_modules/pino-pretty/lib/pretty.js +171 -0
  358. package/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.js +69 -0
  359. package/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.test.js +84 -0
  360. package/node_modules/pino-pretty/lib/utils/create-date.js +26 -0
  361. package/node_modules/pino-pretty/lib/utils/create-date.test.js +20 -0
  362. package/node_modules/pino-pretty/lib/utils/delete-log-property.js +28 -0
  363. package/node_modules/pino-pretty/lib/utils/delete-log-property.test.js +31 -0
  364. package/node_modules/pino-pretty/lib/utils/filter-log.js +99 -0
  365. package/node_modules/pino-pretty/lib/utils/filter-log.test.js +265 -0
  366. package/node_modules/pino-pretty/lib/utils/format-time.js +66 -0
  367. package/node_modules/pino-pretty/lib/utils/format-time.test.js +71 -0
  368. package/node_modules/pino-pretty/lib/utils/get-level-label-data.js +29 -0
  369. package/node_modules/pino-pretty/lib/utils/get-property-value.js +30 -0
  370. package/node_modules/pino-pretty/lib/utils/get-property-value.test.js +31 -0
  371. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-names-opts.js +38 -0
  372. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-names-opts.test.js +45 -0
  373. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-opts.js +39 -0
  374. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-opts.test.js +47 -0
  375. package/node_modules/pino-pretty/lib/utils/index.js +108 -0
  376. package/node_modules/pino-pretty/lib/utils/index.test.js +37 -0
  377. package/node_modules/pino-pretty/lib/utils/interpret-conditionals.js +41 -0
  378. package/node_modules/pino-pretty/lib/utils/interpret-conditionals.test.js +84 -0
  379. package/node_modules/pino-pretty/lib/utils/is-object.js +7 -0
  380. package/node_modules/pino-pretty/lib/utils/is-object.test.js +10 -0
  381. package/node_modules/pino-pretty/lib/utils/is-valid-date.js +14 -0
  382. package/node_modules/pino-pretty/lib/utils/is-valid-date.test.js +16 -0
  383. package/node_modules/pino-pretty/lib/utils/join-lines-with-indentation.js +29 -0
  384. package/node_modules/pino-pretty/lib/utils/join-lines-with-indentation.test.js +16 -0
  385. package/node_modules/pino-pretty/lib/utils/noop.js +3 -0
  386. package/node_modules/pino-pretty/lib/utils/noop.test.js +12 -0
  387. package/node_modules/pino-pretty/lib/utils/parse-factory-options.js +171 -0
  388. package/node_modules/pino-pretty/lib/utils/prettify-error-log.js +76 -0
  389. package/node_modules/pino-pretty/lib/utils/prettify-error-log.test.js +143 -0
  390. package/node_modules/pino-pretty/lib/utils/prettify-error.js +54 -0
  391. package/node_modules/pino-pretty/lib/utils/prettify-error.test.js +25 -0
  392. package/node_modules/pino-pretty/lib/utils/prettify-level.js +41 -0
  393. package/node_modules/pino-pretty/lib/utils/prettify-level.test.js +70 -0
  394. package/node_modules/pino-pretty/lib/utils/prettify-message.js +65 -0
  395. package/node_modules/pino-pretty/lib/utils/prettify-message.test.js +287 -0
  396. package/node_modules/pino-pretty/lib/utils/prettify-metadata.js +75 -0
  397. package/node_modules/pino-pretty/lib/utils/prettify-metadata.test.js +170 -0
  398. package/node_modules/pino-pretty/lib/utils/prettify-object.js +115 -0
  399. package/node_modules/pino-pretty/lib/utils/prettify-object.test.js +217 -0
  400. package/node_modules/pino-pretty/lib/utils/prettify-time.js +43 -0
  401. package/node_modules/pino-pretty/lib/utils/prettify-time.test.js +264 -0
  402. package/node_modules/pino-pretty/lib/utils/split-property-key.js +49 -0
  403. package/node_modules/pino-pretty/lib/utils/split-property-key.test.js +29 -0
  404. package/node_modules/pino-pretty/lib/utils/strip-unsafe-control-chars.js +18 -0
  405. package/node_modules/pino-pretty/lib/utils/strip-unsafe-control-chars.test.js +9 -0
  406. package/node_modules/pino-pretty/package.json +64 -0
  407. package/node_modules/pino-pretty/test/basic.test.js +1305 -0
  408. package/node_modules/pino-pretty/test/boolean-options.test.js +228 -0
  409. package/node_modules/pino-pretty/test/cli-rc.test.js +275 -0
  410. package/node_modules/pino-pretty/test/cli.test.js +360 -0
  411. package/node_modules/pino-pretty/test/crlf.test.js +33 -0
  412. package/node_modules/pino-pretty/test/error-objects.test.js +494 -0
  413. package/node_modules/pino-pretty/test/example/example.js +33 -0
  414. package/node_modules/pino-pretty/test/helper.js +19 -0
  415. package/node_modules/pino-pretty/test/types/exports.tst.ts +15 -0
  416. package/node_modules/pino-pretty/test/types/pino-pretty.tst.ts +140 -0
  417. package/node_modules/pino-pretty/test/types/tsconfig.json +9 -0
  418. package/package.json +12 -5
  419. package/lib/cli/commands/init.d.ts +0 -1
  420. package/lib/cli/commands/init.js +0 -8
  421. package/node_modules/@types/node/globals.global.d.ts +0 -1
@@ -1,57 +1,143 @@
1
- declare module 'tls' {
2
- import * as net from 'net';
3
- import * as stream from 'stream';
4
-
1
+ /**
2
+ * The `node:tls` module provides an implementation of the Transport Layer Security
3
+ * (TLS) and Secure Socket Layer (SSL) protocols that is built on top of OpenSSL.
4
+ * The module can be accessed using:
5
+ *
6
+ * ```js
7
+ * import tls from 'node:tls';
8
+ * ```
9
+ * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/tls.js)
10
+ */
11
+ declare module "tls" {
12
+ import { NonSharedBuffer } from "node:buffer";
13
+ import { X509Certificate } from "node:crypto";
14
+ import * as net from "node:net";
15
+ import * as stream from "stream";
5
16
  const CLIENT_RENEG_LIMIT: number;
6
17
  const CLIENT_RENEG_WINDOW: number;
7
-
8
- interface Certificate {
18
+ interface Certificate extends NodeJS.Dict<string | string[]> {
9
19
  /**
10
20
  * Country code.
11
21
  */
12
- C: string;
22
+ C?: string | string[];
13
23
  /**
14
24
  * Street.
15
25
  */
16
- ST: string;
26
+ ST?: string | string[];
17
27
  /**
18
28
  * Locality.
19
29
  */
20
- L: string;
30
+ L?: string | string[];
21
31
  /**
22
32
  * Organization.
23
33
  */
24
- O: string;
34
+ O?: string | string[];
25
35
  /**
26
36
  * Organizational unit.
27
37
  */
28
- OU: string;
38
+ OU?: string | string[];
29
39
  /**
30
40
  * Common name.
31
41
  */
32
- CN: string;
42
+ CN?: string | string[];
33
43
  }
34
-
35
44
  interface PeerCertificate {
45
+ /**
46
+ * `true` if a Certificate Authority (CA), `false` otherwise.
47
+ * @since v18.13.0
48
+ */
49
+ ca: boolean;
50
+ /**
51
+ * The DER encoded X.509 certificate data.
52
+ */
53
+ raw: NonSharedBuffer;
54
+ /**
55
+ * The certificate subject.
56
+ */
36
57
  subject: Certificate;
58
+ /**
59
+ * The certificate issuer, described in the same terms as the `subject`.
60
+ */
37
61
  issuer: Certificate;
38
- subjectaltname: string;
39
- infoAccess: { [index: string]: string[] | undefined };
40
- modulus: string;
41
- exponent: string;
62
+ /**
63
+ * The date-time the certificate is valid from.
64
+ */
42
65
  valid_from: string;
66
+ /**
67
+ * The date-time the certificate is valid to.
68
+ */
43
69
  valid_to: string;
70
+ /**
71
+ * The certificate serial number, as a hex string.
72
+ */
73
+ serialNumber: string;
74
+ /**
75
+ * The SHA-1 digest of the DER encoded certificate.
76
+ * It is returned as a `:` separated hexadecimal string.
77
+ */
44
78
  fingerprint: string;
79
+ /**
80
+ * The SHA-256 digest of the DER encoded certificate.
81
+ * It is returned as a `:` separated hexadecimal string.
82
+ */
45
83
  fingerprint256: string;
46
- ext_key_usage: string[];
47
- serialNumber: string;
48
- raw: Buffer;
84
+ /**
85
+ * The SHA-512 digest of the DER encoded certificate.
86
+ * It is returned as a `:` separated hexadecimal string.
87
+ */
88
+ fingerprint512: string;
89
+ /**
90
+ * The extended key usage, a set of OIDs.
91
+ */
92
+ ext_key_usage?: string[];
93
+ /**
94
+ * A string containing concatenated names for the subject,
95
+ * an alternative to the `subject` names.
96
+ */
97
+ subjectaltname?: string;
98
+ /**
99
+ * An array describing the AuthorityInfoAccess, used with OCSP.
100
+ */
101
+ infoAccess?: NodeJS.Dict<string[]>;
102
+ /**
103
+ * For RSA keys: The RSA bit size.
104
+ *
105
+ * For EC keys: The key size in bits.
106
+ */
107
+ bits?: number;
108
+ /**
109
+ * The RSA exponent, as a string in hexadecimal number notation.
110
+ */
111
+ exponent?: string;
112
+ /**
113
+ * The RSA modulus, as a hexadecimal string.
114
+ */
115
+ modulus?: string;
116
+ /**
117
+ * The public key.
118
+ */
119
+ pubkey?: NonSharedBuffer;
120
+ /**
121
+ * The ASN.1 name of the OID of the elliptic curve.
122
+ * Well-known curves are identified by an OID.
123
+ * While it is unusual, it is possible that the curve
124
+ * is identified by its mathematical properties,
125
+ * in which case it will not have an OID.
126
+ */
127
+ asn1Curve?: string;
128
+ /**
129
+ * The NIST name for the elliptic curve, if it has one
130
+ * (not all well-known curves have been assigned names by NIST).
131
+ */
132
+ nistCurve?: string;
49
133
  }
50
-
51
134
  interface DetailedPeerCertificate extends PeerCertificate {
135
+ /**
136
+ * The issuer certificate object.
137
+ * For self-signed certificates, this may be a circular reference.
138
+ */
52
139
  issuerCertificate: DetailedPeerCertificate;
53
140
  }
54
-
55
141
  interface CipherNameAndProtocol {
56
142
  /**
57
143
  * The cipher name.
@@ -61,8 +147,11 @@ declare module 'tls' {
61
147
  * SSL/TLS protocol version.
62
148
  */
63
149
  version: string;
150
+ /**
151
+ * IETF name for the cipher suite.
152
+ */
153
+ standardName: string;
64
154
  }
65
-
66
155
  interface EphemeralKeyInfo {
67
156
  /**
68
157
  * The supported types are 'DH' and 'ECDH'.
@@ -77,7 +166,6 @@ declare module 'tls' {
77
166
  */
78
167
  size: number;
79
168
  }
80
-
81
169
  interface KeyObject {
82
170
  /**
83
171
  * Private keys in PEM format.
@@ -88,7 +176,6 @@ declare module 'tls' {
88
176
  */
89
177
  passphrase?: string | undefined;
90
178
  }
91
-
92
179
  interface PxfObject {
93
180
  /**
94
181
  * PFX or PKCS12 encoded private key and certificate chain.
@@ -99,7 +186,6 @@ declare module 'tls' {
99
186
  */
100
187
  passphrase?: string | undefined;
101
188
  }
102
-
103
189
  interface TLSSocketOptions extends SecureContextOptions, CommonConnectionOptions {
104
190
  /**
105
191
  * If true the TLS socket will be instantiated in server-mode.
@@ -110,7 +196,6 @@ declare module 'tls' {
110
196
  * An optional net.Server instance.
111
197
  */
112
198
  server?: net.Server | undefined;
113
-
114
199
  /**
115
200
  * An optional Buffer instance containing a TLS session.
116
201
  */
@@ -122,219 +207,319 @@ declare module 'tls' {
122
207
  */
123
208
  requestOCSP?: boolean | undefined;
124
209
  }
125
-
210
+ /**
211
+ * Performs transparent encryption of written data and all required TLS
212
+ * negotiation.
213
+ *
214
+ * Instances of `tls.TLSSocket` implement the duplex `Stream` interface.
215
+ *
216
+ * Methods that return TLS connection metadata (e.g.{@link TLSSocket.getPeerCertificate}) will only return data while the
217
+ * connection is open.
218
+ * @since v0.11.4
219
+ */
126
220
  class TLSSocket extends net.Socket {
127
221
  /**
128
222
  * Construct a new tls.TLSSocket object from an existing TCP socket.
129
223
  */
130
- constructor(socket: net.Socket, options?: TLSSocketOptions);
131
-
224
+ constructor(socket: net.Socket | stream.Duplex, options?: TLSSocketOptions);
132
225
  /**
133
- * A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false.
226
+ * This property is `true` if the peer certificate was signed by one of the CAs
227
+ * specified when creating the `tls.TLSSocket` instance, otherwise `false`.
228
+ * @since v0.11.4
134
229
  */
135
230
  authorized: boolean;
136
231
  /**
137
- * The reason why the peer's certificate has not been verified.
138
- * This property becomes available only when tlsSocket.authorized === false.
232
+ * Returns the reason why the peer's certificate was not been verified. This
233
+ * property is set only when `tlsSocket.authorized === false`.
234
+ * @since v0.11.4
139
235
  */
140
236
  authorizationError: Error;
141
237
  /**
142
- * Static boolean value, always true.
143
- * May be used to distinguish TLS sockets from regular ones.
238
+ * Always returns `true`. This may be used to distinguish TLS sockets from regular`net.Socket` instances.
239
+ * @since v0.11.4
144
240
  */
145
241
  encrypted: true;
146
-
147
242
  /**
148
243
  * String containing the selected ALPN protocol.
149
244
  * Before a handshake has completed, this value is always null.
150
245
  * When a handshake is completed but not ALPN protocol was selected, tlsSocket.alpnProtocol equals false.
151
246
  */
152
247
  alpnProtocol: string | false | null;
153
-
154
248
  /**
155
- * Returns an object representing the local certificate. The returned
156
- * object has some properties corresponding to the fields of the
157
- * certificate.
249
+ * String containing the server name requested via SNI (Server Name Indication) TLS extension.
250
+ */
251
+ servername: string | false | null;
252
+ /**
253
+ * Returns an object representing the local certificate. The returned object has
254
+ * some properties corresponding to the fields of the certificate.
158
255
  *
159
- * See tls.TLSSocket.getPeerCertificate() for an example of the
160
- * certificate structure.
256
+ * See {@link TLSSocket.getPeerCertificate} for an example of the certificate
257
+ * structure.
161
258
  *
162
- * If there is no local certificate, an empty object will be returned.
163
- * If the socket has been destroyed, null will be returned.
259
+ * If there is no local certificate, an empty object will be returned. If the
260
+ * socket has been destroyed, `null` will be returned.
261
+ * @since v11.2.0
164
262
  */
165
263
  getCertificate(): PeerCertificate | object | null;
166
264
  /**
167
- * Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.
168
- * @returns Returns an object representing the cipher name
169
- * and the SSL/TLS protocol version of the current connection.
265
+ * Returns an object containing information on the negotiated cipher suite.
266
+ *
267
+ * For example, a TLSv1.2 protocol with AES256-SHA cipher:
268
+ *
269
+ * ```json
270
+ * {
271
+ * "name": "AES256-SHA",
272
+ * "standardName": "TLS_RSA_WITH_AES_256_CBC_SHA",
273
+ * "version": "SSLv3"
274
+ * }
275
+ * ```
276
+ *
277
+ * See [SSL\_CIPHER\_get\_name](https://www.openssl.org/docs/man1.1.1/man3/SSL_CIPHER_get_name.html) for more information.
278
+ * @since v0.11.4
170
279
  */
171
280
  getCipher(): CipherNameAndProtocol;
172
281
  /**
173
- * Returns an object representing the type, name, and size of parameter
174
- * of an ephemeral key exchange in Perfect Forward Secrecy on a client
282
+ * Returns an object representing the type, name, and size of parameter of
283
+ * an ephemeral key exchange in `perfect forward secrecy` on a client
175
284
  * connection. It returns an empty object when the key exchange is not
176
- * ephemeral. As this is only supported on a client socket; null is
177
- * returned if called on a server socket. The supported types are 'DH'
178
- * and 'ECDH'. The name property is available only when type is 'ECDH'.
285
+ * ephemeral. As this is only supported on a client socket; `null` is returned
286
+ * if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The `name` property is available only when type is `'ECDH'`.
179
287
  *
180
- * For example: { type: 'ECDH', name: 'prime256v1', size: 256 }.
288
+ * For example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }`.
289
+ * @since v5.0.0
181
290
  */
182
291
  getEphemeralKeyInfo(): EphemeralKeyInfo | object | null;
183
292
  /**
184
- * Returns the latest Finished message that has
185
- * been sent to the socket as part of a SSL/TLS handshake, or undefined
186
- * if no Finished message has been sent yet.
293
+ * As the `Finished` messages are message digests of the complete handshake
294
+ * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can
295
+ * be used for external authentication procedures when the authentication
296
+ * provided by SSL/TLS is not desired or is not enough.
187
297
  *
188
- * As the Finished messages are message digests of the complete
189
- * handshake (with a total of 192 bits for TLS 1.0 and more for SSL
190
- * 3.0), they can be used for external authentication procedures when
191
- * the authentication provided by SSL/TLS is not desired or is not
192
- * enough.
193
- *
194
- * Corresponds to the SSL_get_finished routine in OpenSSL and may be
195
- * used to implement the tls-unique channel binding from RFC 5929.
298
+ * Corresponds to the `SSL_get_finished` routine in OpenSSL and may be used
299
+ * to implement the `tls-unique` channel binding from [RFC 5929](https://tools.ietf.org/html/rfc5929).
300
+ * @since v9.9.0
301
+ * @return The latest `Finished` message that has been sent to the socket as part of a SSL/TLS handshake, or `undefined` if no `Finished` message has been sent yet.
196
302
  */
197
- getFinished(): Buffer | undefined;
303
+ getFinished(): NonSharedBuffer | undefined;
198
304
  /**
199
- * Returns an object representing the peer's certificate.
200
- * The returned object has some properties corresponding to the field of the certificate.
201
- * If detailed argument is true the full chain with issuer property will be returned,
202
- * if false only the top certificate without issuer property.
203
- * If the peer does not provide a certificate, it returns null or an empty object.
204
- * @param detailed - If true; the full chain with issuer property will be returned.
205
- * @returns An object representing the peer's certificate.
305
+ * Returns an object representing the peer's certificate. If the peer does not
306
+ * provide a certificate, an empty object will be returned. If the socket has been
307
+ * destroyed, `null` will be returned.
308
+ *
309
+ * If the full certificate chain was requested, each certificate will include an`issuerCertificate` property containing an object representing its issuer's
310
+ * certificate.
311
+ * @since v0.11.4
312
+ * @param detailed Include the full certificate chain if `true`, otherwise include just the peer's certificate.
313
+ * @return A certificate object.
206
314
  */
207
315
  getPeerCertificate(detailed: true): DetailedPeerCertificate;
208
316
  getPeerCertificate(detailed?: false): PeerCertificate;
209
317
  getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate;
210
318
  /**
211
- * Returns the latest Finished message that is expected or has actually
212
- * been received from the socket as part of a SSL/TLS handshake, or
213
- * undefined if there is no Finished message so far.
319
+ * As the `Finished` messages are message digests of the complete handshake
320
+ * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can
321
+ * be used for external authentication procedures when the authentication
322
+ * provided by SSL/TLS is not desired or is not enough.
214
323
  *
215
- * As the Finished messages are message digests of the complete
216
- * handshake (with a total of 192 bits for TLS 1.0 and more for SSL
217
- * 3.0), they can be used for external authentication procedures when
218
- * the authentication provided by SSL/TLS is not desired or is not
219
- * enough.
324
+ * Corresponds to the `SSL_get_peer_finished` routine in OpenSSL and may be used
325
+ * to implement the `tls-unique` channel binding from [RFC 5929](https://tools.ietf.org/html/rfc5929).
326
+ * @since v9.9.0
327
+ * @return The latest `Finished` message that is expected or has actually been received from the socket as part of a SSL/TLS handshake, or `undefined` if there is no `Finished` message so
328
+ * far.
329
+ */
330
+ getPeerFinished(): NonSharedBuffer | undefined;
331
+ /**
332
+ * Returns a string containing the negotiated SSL/TLS protocol version of the
333
+ * current connection. The value `'unknown'` will be returned for connected
334
+ * sockets that have not completed the handshaking process. The value `null` will
335
+ * be returned for server sockets or disconnected client sockets.
220
336
  *
221
- * Corresponds to the SSL_get_peer_finished routine in OpenSSL and may
222
- * be used to implement the tls-unique channel binding from RFC 5929.
223
- */
224
- getPeerFinished(): Buffer | undefined;
225
- /**
226
- * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
227
- * The value `'unknown'` will be returned for connected sockets that have not completed the handshaking process.
228
- * The value `null` will be returned for server sockets or disconnected client sockets.
229
- * See https://www.openssl.org/docs/man1.0.2/ssl/SSL_get_version.html for more information.
230
- * @returns negotiated SSL/TLS protocol version of the current connection
337
+ * Protocol versions are:
338
+ *
339
+ * * `'SSLv3'`
340
+ * * `'TLSv1'`
341
+ * * `'TLSv1.1'`
342
+ * * `'TLSv1.2'`
343
+ * * `'TLSv1.3'`
344
+ *
345
+ * See the OpenSSL [`SSL_get_version`](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_version.html) documentation for more information.
346
+ * @since v5.7.0
231
347
  */
232
348
  getProtocol(): string | null;
233
349
  /**
234
- * Could be used to speed up handshake establishment when reconnecting to the server.
235
- * @returns ASN.1 encoded TLS session or undefined if none was negotiated.
350
+ * Returns the TLS session data or `undefined` if no session was
351
+ * negotiated. On the client, the data can be provided to the `session` option of {@link connect} to resume the connection. On the server, it may be useful
352
+ * for debugging.
353
+ *
354
+ * See `Session Resumption` for more information.
355
+ *
356
+ * Note: `getSession()` works only for TLSv1.2 and below. For TLSv1.3, applications
357
+ * must use the `'session'` event (it also works for TLSv1.2 and below).
358
+ * @since v0.11.4
236
359
  */
237
- getSession(): Buffer | undefined;
360
+ getSession(): NonSharedBuffer | undefined;
238
361
  /**
239
- * Returns a list of signature algorithms shared between the server and
240
- * the client in the order of decreasing preference.
362
+ * See [SSL\_get\_shared\_sigalgs](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html) for more information.
363
+ * @since v12.11.0
364
+ * @return List of signature algorithms shared between the server and the client in the order of decreasing preference.
241
365
  */
242
366
  getSharedSigalgs(): string[];
243
367
  /**
244
- * NOTE: Works only with client TLS sockets.
245
- * Useful only for debugging, for session reuse provide session option to tls.connect().
246
- * @returns TLS session ticket or undefined if none was negotiated.
368
+ * For a client, returns the TLS session ticket if one is available, or`undefined`. For a server, always returns `undefined`.
369
+ *
370
+ * It may be useful for debugging.
371
+ *
372
+ * See `Session Resumption` for more information.
373
+ * @since v0.11.4
247
374
  */
248
- getTLSTicket(): Buffer | undefined;
375
+ getTLSTicket(): NonSharedBuffer | undefined;
249
376
  /**
250
- * Returns true if the session was reused, false otherwise.
377
+ * See `Session Resumption` for more information.
378
+ * @since v0.5.6
379
+ * @return `true` if the session was reused, `false` otherwise.
251
380
  */
252
381
  isSessionReused(): boolean;
253
382
  /**
254
- * Initiate TLS renegotiation process.
383
+ * The `tlsSocket.renegotiate()` method initiates a TLS renegotiation process.
384
+ * Upon completion, the `callback` function will be passed a single argument
385
+ * that is either an `Error` (if the request failed) or `null`.
255
386
  *
256
- * NOTE: Can be used to request peer's certificate after the secure connection has been established.
257
- * ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout.
258
- * @param options - The options may contain the following fields: rejectUnauthorized,
259
- * requestCert (See tls.createServer() for details).
260
- * @param callback - callback(err) will be executed with null as err, once the renegotiation
261
- * is successfully completed.
262
- * @return `undefined` when socket is destroy, `false` if negotiaion can't be initiated.
263
- */
264
- renegotiate(options: { rejectUnauthorized?: boolean | undefined, requestCert?: boolean | undefined }, callback: (err: Error | null) => void): undefined | boolean;
265
- /**
266
- * Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512).
267
- * Smaller fragment size decreases buffering latency on the client: large fragments are buffered by
268
- * the TLS layer until the entire fragment is received and its integrity is verified;
269
- * large fragments can span multiple roundtrips, and their processing can be delayed due to packet
270
- * loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead,
271
- * which may decrease overall server throughput.
272
- * @param size - TLS fragment size (default and maximum value is: 16384, minimum is: 512).
273
- * @returns Returns true on success, false otherwise.
387
+ * This method can be used to request a peer's certificate after the secure
388
+ * connection has been established.
389
+ *
390
+ * When running as the server, the socket will be destroyed with an error after `handshakeTimeout` timeout.
391
+ *
392
+ * For TLSv1.3, renegotiation cannot be initiated, it is not supported by the
393
+ * protocol.
394
+ * @since v0.11.8
395
+ * @param callback If `renegotiate()` returned `true`, callback is attached once to the `'secure'` event. If `renegotiate()` returned `false`, `callback` will be called in the next tick with
396
+ * an error, unless the `tlsSocket` has been destroyed, in which case `callback` will not be called at all.
397
+ * @return `true` if renegotiation was initiated, `false` otherwise.
398
+ */
399
+ renegotiate(
400
+ options: {
401
+ rejectUnauthorized?: boolean | undefined;
402
+ requestCert?: boolean | undefined;
403
+ },
404
+ callback: (err: Error | null) => void,
405
+ ): undefined | boolean;
406
+ /**
407
+ * The `tlsSocket.setKeyCert()` method sets the private key and certificate to use for the socket.
408
+ * This is mainly useful if you wish to select a server certificate from a TLS server's `ALPNCallback`.
409
+ * @since v22.5.0, v20.17.0
410
+ * @param context An object containing at least `key` and `cert` properties from the {@link createSecureContext()} `options`,
411
+ * or a TLS context object created with {@link createSecureContext()} itself.
412
+ */
413
+ setKeyCert(context: SecureContextOptions | SecureContext): void;
414
+ /**
415
+ * The `tlsSocket.setMaxSendFragment()` method sets the maximum TLS fragment size.
416
+ * Returns `true` if setting the limit succeeded; `false` otherwise.
417
+ *
418
+ * Smaller fragment sizes decrease the buffering latency on the client: larger
419
+ * fragments are buffered by the TLS layer until the entire fragment is received
420
+ * and its integrity is verified; large fragments can span multiple roundtrips
421
+ * and their processing can be delayed due to packet loss or reordering. However,
422
+ * smaller fragments add extra TLS framing bytes and CPU overhead, which may
423
+ * decrease overall server throughput.
424
+ * @since v0.11.11
425
+ * @param [size=16384] The maximum TLS fragment size. The maximum value is `16384`.
274
426
  */
275
427
  setMaxSendFragment(size: number): boolean;
276
-
277
428
  /**
278
- * Disables TLS renegotiation for this TLSSocket instance. Once called,
279
- * attempts to renegotiate will trigger an 'error' event on the
280
- * TLSSocket.
429
+ * Disables TLS renegotiation for this `TLSSocket` instance. Once called, attempts
430
+ * to renegotiate will trigger an `'error'` event on the `TLSSocket`.
431
+ * @since v8.4.0
281
432
  */
282
433
  disableRenegotiation(): void;
283
-
284
434
  /**
285
435
  * When enabled, TLS packet trace information is written to `stderr`. This can be
286
436
  * used to debug TLS connection problems.
287
437
  *
288
- * Note: The format of the output is identical to the output of `openssl s_client
289
- * -trace` or `openssl s_server -trace`. While it is produced by OpenSSL's
290
- * `SSL_trace()` function, the format is undocumented, can change without notice,
291
- * and should not be relied on.
438
+ * The format of the output is identical to the output of`openssl s_client -trace` or `openssl s_server -trace`. While it is produced by
439
+ * OpenSSL's `SSL_trace()` function, the format is undocumented, can change
440
+ * without notice, and should not be relied on.
441
+ * @since v12.2.0
292
442
  */
293
443
  enableTrace(): void;
294
-
444
+ /**
445
+ * Returns the peer certificate as an `X509Certificate` object.
446
+ *
447
+ * If there is no peer certificate, or the socket has been destroyed,`undefined` will be returned.
448
+ * @since v15.9.0
449
+ */
450
+ getPeerX509Certificate(): X509Certificate | undefined;
451
+ /**
452
+ * Returns the local certificate as an `X509Certificate` object.
453
+ *
454
+ * If there is no local certificate, or the socket has been destroyed,`undefined` will be returned.
455
+ * @since v15.9.0
456
+ */
457
+ getX509Certificate(): X509Certificate | undefined;
458
+ /**
459
+ * Keying material is used for validations to prevent different kind of attacks in
460
+ * network protocols, for example in the specifications of IEEE 802.1X.
461
+ *
462
+ * Example
463
+ *
464
+ * ```js
465
+ * const keyingMaterial = tlsSocket.exportKeyingMaterial(
466
+ * 128,
467
+ * 'client finished');
468
+ *
469
+ * /*
470
+ * Example return value of keyingMaterial:
471
+ * <Buffer 76 26 af 99 c5 56 8e 42 09 91 ef 9f 93 cb ad 6c 7b 65 f8 53 f1 d8 d9
472
+ * 12 5a 33 b8 b5 25 df 7b 37 9f e0 e2 4f b8 67 83 a3 2f cd 5d 41 42 4c 91
473
+ * 74 ef 2c ... 78 more bytes>
474
+ *
475
+ * ```
476
+ *
477
+ * See the OpenSSL [`SSL_export_keying_material`](https://www.openssl.org/docs/man1.1.1/man3/SSL_export_keying_material.html) documentation for more
478
+ * information.
479
+ * @since v13.10.0, v12.17.0
480
+ * @param length number of bytes to retrieve from keying material
481
+ * @param label an application specific label, typically this will be a value from the [IANA Exporter Label
482
+ * Registry](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels).
483
+ * @param context Optionally provide a context.
484
+ * @return requested bytes of the keying material
485
+ */
486
+ exportKeyingMaterial(length: number, label: string, context: Buffer): NonSharedBuffer;
295
487
  addListener(event: string, listener: (...args: any[]) => void): this;
296
- addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
488
+ addListener(event: "OCSPResponse", listener: (response: NonSharedBuffer) => void): this;
297
489
  addListener(event: "secureConnect", listener: () => void): this;
298
- addListener(event: "session", listener: (session: Buffer) => void): this;
299
- addListener(event: "keylog", listener: (line: Buffer) => void): this;
300
-
490
+ addListener(event: "session", listener: (session: NonSharedBuffer) => void): this;
491
+ addListener(event: "keylog", listener: (line: NonSharedBuffer) => void): this;
301
492
  emit(event: string | symbol, ...args: any[]): boolean;
302
- emit(event: "OCSPResponse", response: Buffer): boolean;
493
+ emit(event: "OCSPResponse", response: NonSharedBuffer): boolean;
303
494
  emit(event: "secureConnect"): boolean;
304
- emit(event: "session", session: Buffer): boolean;
305
- emit(event: "keylog", line: Buffer): boolean;
306
-
495
+ emit(event: "session", session: NonSharedBuffer): boolean;
496
+ emit(event: "keylog", line: NonSharedBuffer): boolean;
307
497
  on(event: string, listener: (...args: any[]) => void): this;
308
- on(event: "OCSPResponse", listener: (response: Buffer) => void): this;
498
+ on(event: "OCSPResponse", listener: (response: NonSharedBuffer) => void): this;
309
499
  on(event: "secureConnect", listener: () => void): this;
310
- on(event: "session", listener: (session: Buffer) => void): this;
311
- on(event: "keylog", listener: (line: Buffer) => void): this;
312
-
500
+ on(event: "session", listener: (session: NonSharedBuffer) => void): this;
501
+ on(event: "keylog", listener: (line: NonSharedBuffer) => void): this;
313
502
  once(event: string, listener: (...args: any[]) => void): this;
314
- once(event: "OCSPResponse", listener: (response: Buffer) => void): this;
503
+ once(event: "OCSPResponse", listener: (response: NonSharedBuffer) => void): this;
315
504
  once(event: "secureConnect", listener: () => void): this;
316
- once(event: "session", listener: (session: Buffer) => void): this;
317
- once(event: "keylog", listener: (line: Buffer) => void): this;
318
-
505
+ once(event: "session", listener: (session: NonSharedBuffer) => void): this;
506
+ once(event: "keylog", listener: (line: NonSharedBuffer) => void): this;
319
507
  prependListener(event: string, listener: (...args: any[]) => void): this;
320
- prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
508
+ prependListener(event: "OCSPResponse", listener: (response: NonSharedBuffer) => void): this;
321
509
  prependListener(event: "secureConnect", listener: () => void): this;
322
- prependListener(event: "session", listener: (session: Buffer) => void): this;
323
- prependListener(event: "keylog", listener: (line: Buffer) => void): this;
324
-
510
+ prependListener(event: "session", listener: (session: NonSharedBuffer) => void): this;
511
+ prependListener(event: "keylog", listener: (line: NonSharedBuffer) => void): this;
325
512
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
326
- prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
513
+ prependOnceListener(event: "OCSPResponse", listener: (response: NonSharedBuffer) => void): this;
327
514
  prependOnceListener(event: "secureConnect", listener: () => void): this;
328
- prependOnceListener(event: "session", listener: (session: Buffer) => void): this;
329
- prependOnceListener(event: "keylog", listener: (line: Buffer) => void): this;
515
+ prependOnceListener(event: "session", listener: (session: NonSharedBuffer) => void): this;
516
+ prependOnceListener(event: "keylog", listener: (line: NonSharedBuffer) => void): this;
330
517
  }
331
-
332
518
  interface CommonConnectionOptions {
333
519
  /**
334
520
  * An optional TLS context object from tls.createSecureContext()
335
521
  */
336
522
  secureContext?: SecureContext | undefined;
337
-
338
523
  /**
339
524
  * When enabled, TLS packet trace information is written to `stderr`. This can be
340
525
  * used to debug TLS connection problems.
@@ -351,7 +536,7 @@ declare module 'tls' {
351
536
  * An array of strings or a Buffer naming possible ALPN protocols.
352
537
  * (Protocols should be ordered by their priority.)
353
538
  */
354
- ALPNProtocols?: string[] | Uint8Array[] | Uint8Array | undefined;
539
+ ALPNProtocols?: readonly string[] | NodeJS.ArrayBufferView | undefined;
355
540
  /**
356
541
  * SNICallback(servername, cb) <Function> A function that will be
357
542
  * called if the client supports SNI TLS extension. Two arguments
@@ -361,7 +546,7 @@ declare module 'tls' {
361
546
  * SecureContext.) If SNICallback wasn't provided the default callback
362
547
  * with high-level API will be used (see below).
363
548
  */
364
- SNICallback?: ((servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void) | undefined;
549
+ SNICallback?: ((servername: string, cb: (err: Error | null, ctx?: SecureContext) => void) => void) | undefined;
365
550
  /**
366
551
  * If true the server will reject any connection which is not
367
552
  * authorized with the list of supplied CAs. This option only has an
@@ -370,8 +555,7 @@ declare module 'tls' {
370
555
  */
371
556
  rejectUnauthorized?: boolean | undefined;
372
557
  }
373
-
374
- interface TlsOptions extends SecureContextOptions, CommonConnectionOptions {
558
+ interface TlsOptions extends SecureContextOptions, CommonConnectionOptions, net.ServerOpts {
375
559
  /**
376
560
  * Abort the connection if the SSL/TLS handshake does not finish in the
377
561
  * specified number of milliseconds. A 'tlsClientError' is emitted on
@@ -389,8 +573,37 @@ declare module 'tls' {
389
573
  * 48-bytes of cryptographically strong pseudo-random data.
390
574
  */
391
575
  ticketKeys?: Buffer | undefined;
576
+ /**
577
+ * @param socket
578
+ * @param identity identity parameter sent from the client.
579
+ * @return pre-shared key that must either be
580
+ * a buffer or `null` to stop the negotiation process. Returned PSK must be
581
+ * compatible with the selected cipher's digest.
582
+ *
583
+ * When negotiating TLS-PSK (pre-shared keys), this function is called
584
+ * with the identity provided by the client.
585
+ * If the return value is `null` the negotiation process will stop and an
586
+ * "unknown_psk_identity" alert message will be sent to the other party.
587
+ * If the server wishes to hide the fact that the PSK identity was not known,
588
+ * the callback must provide some random data as `psk` to make the connection
589
+ * fail with "decrypt_error" before negotiation is finished.
590
+ * PSK ciphers are disabled by default, and using TLS-PSK thus
591
+ * requires explicitly specifying a cipher suite with the `ciphers` option.
592
+ * More information can be found in the RFC 4279.
593
+ */
594
+ pskCallback?: ((socket: TLSSocket, identity: string) => NodeJS.ArrayBufferView | null) | undefined;
595
+ /**
596
+ * hint to send to a client to help
597
+ * with selecting the identity during TLS-PSK negotiation. Will be ignored
598
+ * in TLS 1.3. Upon failing to set pskIdentityHint `tlsClientError` will be
599
+ * emitted with `ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED` code.
600
+ */
601
+ pskIdentityHint?: string | undefined;
602
+ }
603
+ interface PSKCallbackNegotation {
604
+ psk: NodeJS.ArrayBufferView;
605
+ identity: string;
392
606
  }
393
-
394
607
  interface ConnectionOptions extends SecureContextOptions, CommonConnectionOptions {
395
608
  host?: string | undefined;
396
609
  port?: number | undefined;
@@ -402,33 +615,70 @@ declare module 'tls' {
402
615
  minDHSize?: number | undefined;
403
616
  lookup?: net.LookupFunction | undefined;
404
617
  timeout?: number | undefined;
618
+ /**
619
+ * When negotiating TLS-PSK (pre-shared keys), this function is called
620
+ * with optional identity `hint` provided by the server or `null`
621
+ * in case of TLS 1.3 where `hint` was removed.
622
+ * It will be necessary to provide a custom `tls.checkServerIdentity()`
623
+ * for the connection as the default one will try to check hostname/IP
624
+ * of the server against the certificate but that's not applicable for PSK
625
+ * because there won't be a certificate present.
626
+ * More information can be found in the RFC 4279.
627
+ *
628
+ * @param hint message sent from the server to help client
629
+ * decide which identity to use during negotiation.
630
+ * Always `null` if TLS 1.3 is used.
631
+ * @returns Return `null` to stop the negotiation process. `psk` must be
632
+ * compatible with the selected cipher's digest.
633
+ * `identity` must use UTF-8 encoding.
634
+ */
635
+ pskCallback?: ((hint: string | null) => PSKCallbackNegotation | null) | undefined;
405
636
  }
406
-
637
+ /**
638
+ * Accepts encrypted connections using TLS or SSL.
639
+ * @since v0.3.2
640
+ */
407
641
  class Server extends net.Server {
642
+ constructor(secureConnectionListener?: (socket: TLSSocket) => void);
643
+ constructor(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void);
408
644
  /**
409
- * The server.addContext() method adds a secure context that will be
410
- * used if the client request's SNI name matches the supplied hostname
411
- * (or wildcard).
645
+ * The `server.addContext()` method adds a secure context that will be used if
646
+ * the client request's SNI name matches the supplied `hostname` (or wildcard).
647
+ *
648
+ * When there are multiple matching contexts, the most recently added one is
649
+ * used.
650
+ * @since v0.5.3
651
+ * @param hostname A SNI host name or wildcard (e.g. `'*'`)
652
+ * @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc), or a TLS context object created
653
+ * with {@link createSecureContext} itself.
412
654
  */
413
- addContext(hostName: string, credentials: SecureContextOptions): void;
655
+ addContext(hostname: string, context: SecureContextOptions | SecureContext): void;
414
656
  /**
415
657
  * Returns the session ticket keys.
658
+ *
659
+ * See `Session Resumption` for more information.
660
+ * @since v3.0.0
661
+ * @return A 48-byte buffer containing the session ticket keys.
416
662
  */
417
- getTicketKeys(): Buffer;
663
+ getTicketKeys(): NonSharedBuffer;
418
664
  /**
419
- *
420
- * The server.setSecureContext() method replaces the
421
- * secure context of an existing server. Existing connections to the
422
- * server are not interrupted.
665
+ * The `server.setSecureContext()` method replaces the secure context of an
666
+ * existing server. Existing connections to the server are not interrupted.
667
+ * @since v11.0.0
668
+ * @param options An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc).
423
669
  */
424
- setSecureContext(details: SecureContextOptions): void;
670
+ setSecureContext(options: SecureContextOptions): void;
425
671
  /**
426
- * The server.setSecureContext() method replaces the secure context of
427
- * an existing server. Existing connections to the server are not
428
- * interrupted.
672
+ * Sets the session ticket keys.
673
+ *
674
+ * Changes to the ticket keys are effective only for future server connections.
675
+ * Existing or currently pending server connections will use the previous keys.
676
+ *
677
+ * See `Session Resumption` for more information.
678
+ * @since v3.0.0
679
+ * @param keys A 48-byte buffer containing the session ticket keys.
429
680
  */
430
681
  setTicketKeys(keys: Buffer): void;
431
-
432
682
  /**
433
683
  * events.EventEmitter
434
684
  * 1. tlsClientError
@@ -440,61 +690,167 @@ declare module 'tls' {
440
690
  */
441
691
  addListener(event: string, listener: (...args: any[]) => void): this;
442
692
  addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
443
- addListener(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
444
- addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
445
- addListener(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
693
+ addListener(
694
+ event: "newSession",
695
+ listener: (sessionId: NonSharedBuffer, sessionData: NonSharedBuffer, callback: () => void) => void,
696
+ ): this;
697
+ addListener(
698
+ event: "OCSPRequest",
699
+ listener: (
700
+ certificate: NonSharedBuffer,
701
+ issuer: NonSharedBuffer,
702
+ callback: (err: Error | null, resp: Buffer | null) => void,
703
+ ) => void,
704
+ ): this;
705
+ addListener(
706
+ event: "resumeSession",
707
+ listener: (
708
+ sessionId: NonSharedBuffer,
709
+ callback: (err: Error | null, sessionData: Buffer | null) => void,
710
+ ) => void,
711
+ ): this;
446
712
  addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
447
- addListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
448
-
713
+ addListener(event: "keylog", listener: (line: NonSharedBuffer, tlsSocket: TLSSocket) => void): this;
449
714
  emit(event: string | symbol, ...args: any[]): boolean;
450
715
  emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean;
451
- emit(event: "newSession", sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void): boolean;
452
- emit(event: "OCSPRequest", certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void): boolean;
453
- emit(event: "resumeSession", sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean;
716
+ emit(
717
+ event: "newSession",
718
+ sessionId: NonSharedBuffer,
719
+ sessionData: NonSharedBuffer,
720
+ callback: () => void,
721
+ ): boolean;
722
+ emit(
723
+ event: "OCSPRequest",
724
+ certificate: NonSharedBuffer,
725
+ issuer: NonSharedBuffer,
726
+ callback: (err: Error | null, resp: Buffer | null) => void,
727
+ ): boolean;
728
+ emit(
729
+ event: "resumeSession",
730
+ sessionId: NonSharedBuffer,
731
+ callback: (err: Error | null, sessionData: Buffer | null) => void,
732
+ ): boolean;
454
733
  emit(event: "secureConnection", tlsSocket: TLSSocket): boolean;
455
- emit(event: "keylog", line: Buffer, tlsSocket: TLSSocket): boolean;
456
-
734
+ emit(event: "keylog", line: NonSharedBuffer, tlsSocket: TLSSocket): boolean;
457
735
  on(event: string, listener: (...args: any[]) => void): this;
458
736
  on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
459
- on(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
460
- on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
461
- on(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
737
+ on(
738
+ event: "newSession",
739
+ listener: (sessionId: NonSharedBuffer, sessionData: NonSharedBuffer, callback: () => void) => void,
740
+ ): this;
741
+ on(
742
+ event: "OCSPRequest",
743
+ listener: (
744
+ certificate: NonSharedBuffer,
745
+ issuer: NonSharedBuffer,
746
+ callback: (err: Error | null, resp: Buffer | null) => void,
747
+ ) => void,
748
+ ): this;
749
+ on(
750
+ event: "resumeSession",
751
+ listener: (
752
+ sessionId: NonSharedBuffer,
753
+ callback: (err: Error | null, sessionData: Buffer | null) => void,
754
+ ) => void,
755
+ ): this;
462
756
  on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
463
- on(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
464
-
757
+ on(event: "keylog", listener: (line: NonSharedBuffer, tlsSocket: TLSSocket) => void): this;
465
758
  once(event: string, listener: (...args: any[]) => void): this;
466
759
  once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
467
- once(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
468
- once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
469
- once(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
760
+ once(
761
+ event: "newSession",
762
+ listener: (sessionId: NonSharedBuffer, sessionData: NonSharedBuffer, callback: () => void) => void,
763
+ ): this;
764
+ once(
765
+ event: "OCSPRequest",
766
+ listener: (
767
+ certificate: NonSharedBuffer,
768
+ issuer: NonSharedBuffer,
769
+ callback: (err: Error | null, resp: Buffer | null) => void,
770
+ ) => void,
771
+ ): this;
772
+ once(
773
+ event: "resumeSession",
774
+ listener: (
775
+ sessionId: NonSharedBuffer,
776
+ callback: (err: Error | null, sessionData: Buffer | null) => void,
777
+ ) => void,
778
+ ): this;
470
779
  once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
471
- once(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
472
-
780
+ once(event: "keylog", listener: (line: NonSharedBuffer, tlsSocket: TLSSocket) => void): this;
473
781
  prependListener(event: string, listener: (...args: any[]) => void): this;
474
782
  prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
475
- prependListener(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
476
- prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
477
- prependListener(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
783
+ prependListener(
784
+ event: "newSession",
785
+ listener: (sessionId: NonSharedBuffer, sessionData: NonSharedBuffer, callback: () => void) => void,
786
+ ): this;
787
+ prependListener(
788
+ event: "OCSPRequest",
789
+ listener: (
790
+ certificate: NonSharedBuffer,
791
+ issuer: NonSharedBuffer,
792
+ callback: (err: Error | null, resp: Buffer | null) => void,
793
+ ) => void,
794
+ ): this;
795
+ prependListener(
796
+ event: "resumeSession",
797
+ listener: (
798
+ sessionId: NonSharedBuffer,
799
+ callback: (err: Error | null, sessionData: Buffer | null) => void,
800
+ ) => void,
801
+ ): this;
478
802
  prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
479
- prependListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
480
-
803
+ prependListener(event: "keylog", listener: (line: NonSharedBuffer, tlsSocket: TLSSocket) => void): this;
481
804
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
482
805
  prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
483
- prependOnceListener(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
484
- prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
485
- prependOnceListener(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
806
+ prependOnceListener(
807
+ event: "newSession",
808
+ listener: (sessionId: NonSharedBuffer, sessionData: NonSharedBuffer, callback: () => void) => void,
809
+ ): this;
810
+ prependOnceListener(
811
+ event: "OCSPRequest",
812
+ listener: (
813
+ certificate: NonSharedBuffer,
814
+ issuer: NonSharedBuffer,
815
+ callback: (err: Error | null, resp: Buffer | null) => void,
816
+ ) => void,
817
+ ): this;
818
+ prependOnceListener(
819
+ event: "resumeSession",
820
+ listener: (
821
+ sessionId: NonSharedBuffer,
822
+ callback: (err: Error | null, sessionData: Buffer | null) => void,
823
+ ) => void,
824
+ ): this;
486
825
  prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
487
- prependOnceListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
826
+ prependOnceListener(event: "keylog", listener: (line: NonSharedBuffer, tlsSocket: TLSSocket) => void): this;
488
827
  }
489
-
828
+ /**
829
+ * @deprecated since v0.11.3 Use `tls.TLSSocket` instead.
830
+ */
490
831
  interface SecurePair {
491
832
  encrypted: TLSSocket;
492
833
  cleartext: TLSSocket;
493
834
  }
494
-
495
- type SecureVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
496
-
835
+ type SecureVersion = "TLSv1.3" | "TLSv1.2" | "TLSv1.1" | "TLSv1";
497
836
  interface SecureContextOptions {
837
+ /**
838
+ * If set, this will be called when a client opens a connection using the ALPN extension.
839
+ * One argument will be passed to the callback: an object containing `servername` and `protocols` fields,
840
+ * respectively containing the server name from the SNI extension (if any) and an array of
841
+ * ALPN protocol name strings. The callback must return either one of the strings listed in `protocols`,
842
+ * which will be returned to the client as the selected ALPN protocol, or `undefined`,
843
+ * to reject the connection with a fatal alert. If a string is returned that does not match one of
844
+ * the client's ALPN protocols, an error will be thrown.
845
+ * This option cannot be used with the `ALPNProtocols` option, and setting both options will throw an error.
846
+ */
847
+ ALPNCallback?: ((arg: { servername: string; protocols: string[] }) => string | undefined) | undefined;
848
+ /**
849
+ * Treat intermediate (non-self-signed)
850
+ * certificates in the trust CA certificate list as trusted.
851
+ * @since v22.9.0, v20.18.0
852
+ */
853
+ allowPartialTrustChain?: boolean | undefined;
498
854
  /**
499
855
  * Optionally override the trusted CA certificates. Default is to trust
500
856
  * the well-known CAs curated by Mozilla. Mozilla's CAs are completely
@@ -529,6 +885,7 @@ declare module 'tls' {
529
885
  ciphers?: string | undefined;
530
886
  /**
531
887
  * Name of an OpenSSL engine which can provide the client certificate.
888
+ * @deprecated
532
889
  */
533
890
  clientCertEngine?: string | undefined;
534
891
  /**
@@ -536,12 +893,9 @@ declare module 'tls' {
536
893
  */
537
894
  crl?: string | Buffer | Array<string | Buffer> | undefined;
538
895
  /**
539
- * Diffie Hellman parameters, required for Perfect Forward Secrecy. Use
540
- * openssl dhparam to create the parameters. The key length must be
541
- * greater than or equal to 1024 bits or else an error will be thrown.
542
- * Although 1024 bits is permissible, use 2048 bits or larger for
543
- * stronger security. If omitted or invalid, the parameters are
544
- * silently discarded and DHE ciphers will not be available.
896
+ * `'auto'` or custom Diffie-Hellman parameters, required for non-ECDHE perfect forward secrecy.
897
+ * If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available.
898
+ * ECDHE-based perfect forward secrecy will still be available.
545
899
  */
546
900
  dhparam?: string | Buffer | undefined;
547
901
  /**
@@ -570,16 +924,18 @@ declare module 'tls' {
570
924
  * object.passphrase is optional. Encrypted keys will be decrypted with
571
925
  * object.passphrase if provided, or options.passphrase if it is not.
572
926
  */
573
- key?: string | Buffer | Array<Buffer | KeyObject> | undefined;
927
+ key?: string | Buffer | Array<string | Buffer | KeyObject> | undefined;
574
928
  /**
575
929
  * Name of an OpenSSL engine to get private key from. Should be used
576
930
  * together with privateKeyIdentifier.
931
+ * @deprecated
577
932
  */
578
933
  privateKeyEngine?: string | undefined;
579
934
  /**
580
935
  * Identifier of a private key managed by an OpenSSL engine. Should be
581
936
  * used together with privateKeyEngine. Should not be set together with
582
937
  * key, because both options define a private key in different ways.
938
+ * @deprecated
583
939
  */
584
940
  privateKeyIdentifier?: string | undefined;
585
941
  /**
@@ -652,62 +1008,312 @@ declare module 'tls' {
652
1008
  */
653
1009
  sessionTimeout?: number | undefined;
654
1010
  }
655
-
656
1011
  interface SecureContext {
657
1012
  context: any;
658
1013
  }
659
-
660
- /*
661
- * Verifies the certificate `cert` is issued to host `host`.
662
- * @host The hostname to verify the certificate against
663
- * @cert PeerCertificate representing the peer's certificate
1014
+ /**
1015
+ * Verifies the certificate `cert` is issued to `hostname`.
1016
+ *
1017
+ * Returns [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, populating it with `reason`, `host`, and `cert` on
1018
+ * failure. On success, returns [undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type).
1019
+ *
1020
+ * This function is intended to be used in combination with the`checkServerIdentity` option that can be passed to {@link connect} and as
1021
+ * such operates on a `certificate object`. For other purposes, consider using `x509.checkHost()` instead.
1022
+ *
1023
+ * This function can be overwritten by providing an alternative function as the `options.checkServerIdentity` option that is passed to `tls.connect()`. The
1024
+ * overwriting function can call `tls.checkServerIdentity()` of course, to augment
1025
+ * the checks done with additional verification.
1026
+ *
1027
+ * This function is only called if the certificate passed all other checks, such as
1028
+ * being issued by trusted CA (`options.ca`).
1029
+ *
1030
+ * Earlier versions of Node.js incorrectly accepted certificates for a given`hostname` if a matching `uniformResourceIdentifier` subject alternative name
1031
+ * was present (see [CVE-2021-44531](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44531)). Applications that wish to accept`uniformResourceIdentifier` subject alternative names can use
1032
+ * a custom `options.checkServerIdentity` function that implements the desired behavior.
1033
+ * @since v0.8.4
1034
+ * @param hostname The host name or IP address to verify the certificate against.
1035
+ * @param cert A `certificate object` representing the peer's certificate.
1036
+ */
1037
+ function checkServerIdentity(hostname: string, cert: PeerCertificate): Error | undefined;
1038
+ /**
1039
+ * Creates a new {@link Server}. The `secureConnectionListener`, if provided, is
1040
+ * automatically set as a listener for the `'secureConnection'` event.
1041
+ *
1042
+ * The `ticketKeys` options is automatically shared between `node:cluster` module
1043
+ * workers.
664
1044
  *
665
- * Returns Error object, populating it with the reason, host and cert on failure. On success, returns undefined.
1045
+ * The following illustrates a simple echo server:
1046
+ *
1047
+ * ```js
1048
+ * import tls from 'node:tls';
1049
+ * import fs from 'node:fs';
1050
+ *
1051
+ * const options = {
1052
+ * key: fs.readFileSync('server-key.pem'),
1053
+ * cert: fs.readFileSync('server-cert.pem'),
1054
+ *
1055
+ * // This is necessary only if using client certificate authentication.
1056
+ * requestCert: true,
1057
+ *
1058
+ * // This is necessary only if the client uses a self-signed certificate.
1059
+ * ca: [ fs.readFileSync('client-cert.pem') ],
1060
+ * };
1061
+ *
1062
+ * const server = tls.createServer(options, (socket) => {
1063
+ * console.log('server connected',
1064
+ * socket.authorized ? 'authorized' : 'unauthorized');
1065
+ * socket.write('welcome!\n');
1066
+ * socket.setEncoding('utf8');
1067
+ * socket.pipe(socket);
1068
+ * });
1069
+ * server.listen(8000, () => {
1070
+ * console.log('server bound');
1071
+ * });
1072
+ * ```
1073
+ *
1074
+ * The server can be tested by connecting to it using the example client from {@link connect}.
1075
+ * @since v0.3.2
666
1076
  */
667
- function checkServerIdentity(host: string, cert: PeerCertificate): Error | undefined;
668
1077
  function createServer(secureConnectionListener?: (socket: TLSSocket) => void): Server;
669
1078
  function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server;
1079
+ /**
1080
+ * The `callback` function, if specified, will be added as a listener for the `'secureConnect'` event.
1081
+ *
1082
+ * `tls.connect()` returns a {@link TLSSocket} object.
1083
+ *
1084
+ * Unlike the `https` API, `tls.connect()` does not enable the
1085
+ * SNI (Server Name Indication) extension by default, which may cause some
1086
+ * servers to return an incorrect certificate or reject the connection
1087
+ * altogether. To enable SNI, set the `servername` option in addition
1088
+ * to `host`.
1089
+ *
1090
+ * The following illustrates a client for the echo server example from {@link createServer}:
1091
+ *
1092
+ * ```js
1093
+ * // Assumes an echo server that is listening on port 8000.
1094
+ * import tls from 'node:tls';
1095
+ * import fs from 'node:fs';
1096
+ *
1097
+ * const options = {
1098
+ * // Necessary only if the server requires client certificate authentication.
1099
+ * key: fs.readFileSync('client-key.pem'),
1100
+ * cert: fs.readFileSync('client-cert.pem'),
1101
+ *
1102
+ * // Necessary only if the server uses a self-signed certificate.
1103
+ * ca: [ fs.readFileSync('server-cert.pem') ],
1104
+ *
1105
+ * // Necessary only if the server's cert isn't for "localhost".
1106
+ * checkServerIdentity: () => { return null; },
1107
+ * };
1108
+ *
1109
+ * const socket = tls.connect(8000, options, () => {
1110
+ * console.log('client connected',
1111
+ * socket.authorized ? 'authorized' : 'unauthorized');
1112
+ * process.stdin.pipe(socket);
1113
+ * process.stdin.resume();
1114
+ * });
1115
+ * socket.setEncoding('utf8');
1116
+ * socket.on('data', (data) => {
1117
+ * console.log(data);
1118
+ * });
1119
+ * socket.on('end', () => {
1120
+ * console.log('server ends connection');
1121
+ * });
1122
+ * ```
1123
+ * @since v0.11.3
1124
+ */
670
1125
  function connect(options: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
671
- function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
1126
+ function connect(
1127
+ port: number,
1128
+ host?: string,
1129
+ options?: ConnectionOptions,
1130
+ secureConnectListener?: () => void,
1131
+ ): TLSSocket;
672
1132
  function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
673
1133
  /**
674
- * @deprecated
1134
+ * Creates a new secure pair object with two streams, one of which reads and writes
1135
+ * the encrypted data and the other of which reads and writes the cleartext data.
1136
+ * Generally, the encrypted stream is piped to/from an incoming encrypted data
1137
+ * stream and the cleartext one is used as a replacement for the initial encrypted
1138
+ * stream.
1139
+ *
1140
+ * `tls.createSecurePair()` returns a `tls.SecurePair` object with `cleartext` and `encrypted` stream properties.
1141
+ *
1142
+ * Using `cleartext` has the same API as {@link TLSSocket}.
1143
+ *
1144
+ * The `tls.createSecurePair()` method is now deprecated in favor of`tls.TLSSocket()`. For example, the code:
1145
+ *
1146
+ * ```js
1147
+ * pair = tls.createSecurePair(// ... );
1148
+ * pair.encrypted.pipe(socket);
1149
+ * socket.pipe(pair.encrypted);
1150
+ * ```
1151
+ *
1152
+ * can be replaced by:
1153
+ *
1154
+ * ```js
1155
+ * secureSocket = tls.TLSSocket(socket, options);
1156
+ * ```
1157
+ *
1158
+ * where `secureSocket` has the same API as `pair.cleartext`.
1159
+ * @since v0.3.2
1160
+ * @deprecated Since v0.11.3 - Use {@link TLSSocket} instead.
1161
+ * @param context A secure context object as returned by `tls.createSecureContext()`
1162
+ * @param isServer `true` to specify that this TLS connection should be opened as a server.
1163
+ * @param requestCert `true` to specify whether a server should request a certificate from a connecting client. Only applies when `isServer` is `true`.
1164
+ * @param rejectUnauthorized If not `false` a server automatically reject clients with invalid certificates. Only applies when `isServer` is `true`.
1165
+ */
1166
+ function createSecurePair(
1167
+ context?: SecureContext,
1168
+ isServer?: boolean,
1169
+ requestCert?: boolean,
1170
+ rejectUnauthorized?: boolean,
1171
+ ): SecurePair;
1172
+ /**
1173
+ * `{@link createServer}` sets the default value of the `honorCipherOrder` option
1174
+ * to `true`, other APIs that create secure contexts leave it unset.
1175
+ *
1176
+ * `{@link createServer}` uses a 128 bit truncated SHA1 hash value generated
1177
+ * from `process.argv` as the default value of the `sessionIdContext` option, other
1178
+ * APIs that create secure contexts have no default value.
1179
+ *
1180
+ * The `tls.createSecureContext()` method creates a `SecureContext` object. It is
1181
+ * usable as an argument to several `tls` APIs, such as `server.addContext()`,
1182
+ * but has no public methods. The {@link Server} constructor and the {@link createServer} method do not support the `secureContext` option.
1183
+ *
1184
+ * A key is _required_ for ciphers that use certificates. Either `key` or `pfx` can be used to provide it.
1185
+ *
1186
+ * If the `ca` option is not given, then Node.js will default to using [Mozilla's publicly trusted list of
1187
+ * CAs](https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt).
1188
+ *
1189
+ * Custom DHE parameters are discouraged in favor of the new `dhparam: 'auto' `option. When set to `'auto'`, well-known DHE parameters of sufficient strength
1190
+ * will be selected automatically. Otherwise, if necessary, `openssl dhparam` can
1191
+ * be used to create custom parameters. The key length must be greater than or
1192
+ * equal to 1024 bits or else an error will be thrown. Although 1024 bits is
1193
+ * permissible, use 2048 bits or larger for stronger security.
1194
+ * @since v0.11.13
675
1195
  */
676
- function createSecurePair(credentials?: SecureContext, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
677
1196
  function createSecureContext(options?: SecureContextOptions): SecureContext;
1197
+ /**
1198
+ * Returns an array containing the CA certificates from various sources, depending on `type`:
1199
+ *
1200
+ * * `"default"`: return the CA certificates that will be used by the Node.js TLS clients by default.
1201
+ * * When `--use-bundled-ca` is enabled (default), or `--use-openssl-ca` is not enabled,
1202
+ * this would include CA certificates from the bundled Mozilla CA store.
1203
+ * * When `--use-system-ca` is enabled, this would also include certificates from the system's
1204
+ * trusted store.
1205
+ * * When `NODE_EXTRA_CA_CERTS` is used, this would also include certificates loaded from the specified
1206
+ * file.
1207
+ * * `"system"`: return the CA certificates that are loaded from the system's trusted store, according
1208
+ * to rules set by `--use-system-ca`. This can be used to get the certificates from the system
1209
+ * when `--use-system-ca` is not enabled.
1210
+ * * `"bundled"`: return the CA certificates from the bundled Mozilla CA store. This would be the same
1211
+ * as `tls.rootCertificates`.
1212
+ * * `"extra"`: return the CA certificates loaded from `NODE_EXTRA_CA_CERTS`. It's an empty array if
1213
+ * `NODE_EXTRA_CA_CERTS` is not set.
1214
+ * @since v22.15.0
1215
+ * @param type The type of CA certificates that will be returned. Valid values
1216
+ * are `"default"`, `"system"`, `"bundled"` and `"extra"`.
1217
+ * **Default:** `"default"`.
1218
+ * @returns An array of PEM-encoded certificates. The array may contain duplicates
1219
+ * if the same certificate is repeatedly stored in multiple sources.
1220
+ */
1221
+ function getCACertificates(type?: "default" | "system" | "bundled" | "extra"): string[];
1222
+ /**
1223
+ * Returns an array with the names of the supported TLS ciphers. The names are
1224
+ * lower-case for historical reasons, but must be uppercased to be used in
1225
+ * the `ciphers` option of `{@link createSecureContext}`.
1226
+ *
1227
+ * Not all supported ciphers are enabled by default. See
1228
+ * [Modifying the default TLS cipher suite](https://nodejs.org/docs/latest-v22.x/api/tls.html#modifying-the-default-tls-cipher-suite).
1229
+ *
1230
+ * Cipher names that start with `'tls_'` are for TLSv1.3, all the others are for
1231
+ * TLSv1.2 and below.
1232
+ *
1233
+ * ```js
1234
+ * console.log(tls.getCiphers()); // ['aes128-gcm-sha256', 'aes128-sha', ...]
1235
+ * ```
1236
+ * @since v0.10.2
1237
+ */
678
1238
  function getCiphers(): string[];
679
-
1239
+ /**
1240
+ * Sets the default CA certificates used by Node.js TLS clients. If the provided
1241
+ * certificates are parsed successfully, they will become the default CA
1242
+ * certificate list returned by {@link getCACertificates} and used
1243
+ * by subsequent TLS connections that don't specify their own CA certificates.
1244
+ * The certificates will be deduplicated before being set as the default.
1245
+ *
1246
+ * This function only affects the current Node.js thread. Previous
1247
+ * sessions cached by the HTTPS agent won't be affected by this change, so
1248
+ * this method should be called before any unwanted cachable TLS connections are
1249
+ * made.
1250
+ *
1251
+ * To use system CA certificates as the default:
1252
+ *
1253
+ * ```js
1254
+ * import tls from 'node:tls';
1255
+ * tls.setDefaultCACertificates(tls.getCACertificates('system'));
1256
+ * ```
1257
+ *
1258
+ * This function completely replaces the default CA certificate list. To add additional
1259
+ * certificates to the existing defaults, get the current certificates and append to them:
1260
+ *
1261
+ * ```js
1262
+ * import tls from 'node:tls';
1263
+ * const currentCerts = tls.getCACertificates('default');
1264
+ * const additionalCerts = ['-----BEGIN CERTIFICATE-----\n...'];
1265
+ * tls.setDefaultCACertificates([...currentCerts, ...additionalCerts]);
1266
+ * ```
1267
+ * @since v22.19.0
1268
+ * @param certs An array of CA certificates in PEM format.
1269
+ */
1270
+ function setDefaultCACertificates(certs: ReadonlyArray<string | NodeJS.ArrayBufferView>): void;
680
1271
  /**
681
1272
  * The default curve name to use for ECDH key agreement in a tls server.
682
- * The default value is 'auto'. See tls.createSecureContext() for further
1273
+ * The default value is `'auto'`. See `{@link createSecureContext()}` for further
683
1274
  * information.
1275
+ * @since v0.11.13
684
1276
  */
685
1277
  let DEFAULT_ECDH_CURVE: string;
686
1278
  /**
687
- * The default value of the maxVersion option of
688
- * tls.createSecureContext(). It can be assigned any of the supported TLS
689
- * protocol versions, 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default:
690
- * 'TLSv1.3', unless changed using CLI options. Using --tls-max-v1.2 sets
691
- * the default to 'TLSv1.2'. Using --tls-max-v1.3 sets the default to
692
- * 'TLSv1.3'. If multiple of the options are provided, the highest maximum
693
- * is used.
1279
+ * The default value of the `maxVersion` option of `{@link createSecureContext()}`.
1280
+ * It can be assigned any of the supported TLS protocol versions,
1281
+ * `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. **Default:** `'TLSv1.3'`, unless
1282
+ * changed using CLI options. Using `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using
1283
+ * `--tls-max-v1.3` sets the default to `'TLSv1.3'`. If multiple of the options
1284
+ * are provided, the highest maximum is used.
1285
+ * @since v11.4.0
694
1286
  */
695
1287
  let DEFAULT_MAX_VERSION: SecureVersion;
696
1288
  /**
697
- * The default value of the minVersion option of tls.createSecureContext().
1289
+ * The default value of the `minVersion` option of `{@link createSecureContext()}`.
698
1290
  * It can be assigned any of the supported TLS protocol versions,
699
- * 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default: 'TLSv1.2', unless
700
- * changed using CLI options. Using --tls-min-v1.0 sets the default to
701
- * 'TLSv1'. Using --tls-min-v1.1 sets the default to 'TLSv1.1'. Using
702
- * --tls-min-v1.3 sets the default to 'TLSv1.3'. If multiple of the options
1291
+ * `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. **Default:** `'TLSv1.2'`, unless
1292
+ * changed using CLI options. Using `--tls-min-v1.0` sets the default to
1293
+ * `'TLSv1'`. Using `--tls-min-v1.1` sets the default to `'TLSv1.1'`. Using
1294
+ * `--tls-min-v1.3` sets the default to `'TLSv1.3'`. If multiple of the options
703
1295
  * are provided, the lowest minimum is used.
1296
+ * @since v11.4.0
704
1297
  */
705
1298
  let DEFAULT_MIN_VERSION: SecureVersion;
706
-
707
1299
  /**
708
- * An immutable array of strings representing the root certificates (in PEM
709
- * format) used for verifying peer certificates. This is the default value
710
- * of the ca option to tls.createSecureContext().
1300
+ * The default value of the `ciphers` option of `{@link createSecureContext()}`.
1301
+ * It can be assigned any of the supported OpenSSL ciphers.
1302
+ * Defaults to the content of `crypto.constants.defaultCoreCipherList`, unless
1303
+ * changed using CLI options using `--tls-default-ciphers`.
1304
+ * @since v19.8.0
711
1305
  */
712
- const rootCertificates: ReadonlyArray<string>;
1306
+ let DEFAULT_CIPHERS: string;
1307
+ /**
1308
+ * An immutable array of strings representing the root certificates (in PEM format)
1309
+ * from the bundled Mozilla CA store as supplied by the current Node.js version.
1310
+ *
1311
+ * The bundled CA store, as supplied by Node.js, is a snapshot of Mozilla CA store
1312
+ * that is fixed at release time. It is identical on all supported platforms.
1313
+ * @since v12.3.0
1314
+ */
1315
+ const rootCertificates: readonly string[];
1316
+ }
1317
+ declare module "node:tls" {
1318
+ export * from "tls";
713
1319
  }