@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.
- package/.jsii +184 -45
- package/API.md +153 -37
- package/CHANGELOG.md +13 -0
- package/README.md +10 -3
- package/docs/D9-plumbing.md +189 -0
- package/lib/cli/atlas.d.ts +10 -0
- package/lib/cli/atlas.js +65 -0
- package/lib/cli/commands/cedar/cedar-format.d.ts +7 -0
- package/lib/cli/commands/cedar/cedar-format.js +75 -0
- package/lib/cli/commands/cedar/cedar-to-d9-translations.d.ts +12 -0
- package/lib/cli/commands/cedar/cedar-to-d9-translations.js +130 -0
- package/lib/cli/commands/cedar/cedar-to-d9.d.ts +57 -0
- package/lib/cli/commands/cedar/cedar-to-d9.js +221 -0
- package/lib/cli/commands/cedar/cedar-translations.d.ts +9 -0
- package/lib/cli/commands/cedar/cedar-translations.js +213 -0
- package/lib/cli/commands/cedar/d9-permission.d.ts +27 -0
- package/lib/cli/commands/cedar/d9-permission.js +45 -0
- package/lib/cli/commands/cedar/d9-to-cedar.d.ts +33 -0
- package/lib/cli/commands/cedar/d9-to-cedar.js +157 -0
- package/lib/cli/commands/cedar/roles-table.d.ts +14 -0
- package/lib/cli/commands/cedar/roles-table.js +29 -0
- package/lib/cli/commands/save/apply-snapshot.js +39 -30
- package/lib/cli/commands/save/check-unsaved.d.ts +9 -0
- package/lib/cli/commands/save/check-unsaved.js +81 -0
- package/lib/cli/commands/save/env.d.ts +33 -0
- package/lib/cli/commands/save/env.js +109 -0
- package/lib/cli/commands/save/save-snapshot.d.ts +9 -0
- package/lib/cli/commands/save/save-snapshot.js +232 -0
- package/lib/cli/commands/save/sync-files.d.ts +5 -0
- package/lib/cli/commands/save/sync-files.js +46 -0
- package/lib/cli/commands/save/transfer.d.ts +18 -0
- package/lib/cli/commands/save/transfer.js +96 -0
- package/lib/cli/commands/save/utils.d.ts +5 -0
- package/lib/cli/commands/save/utils.js +33 -3
- package/lib/cli/commands/sync.js +4 -3
- package/lib/cli/index.js +65 -25
- package/lib/cli/logger.d.ts +2 -0
- package/lib/cli/logger.js +10 -0
- package/lib/cli/plumbing-config.d.ts +11 -0
- package/lib/cli/plumbing-config.js +13 -0
- package/lib/index.d.ts +44 -5
- package/lib/index.js +54 -41
- package/node_modules/@cedar-policy/cedar-wasm/README.md +181 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/README.md +181 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm.d.ts +427 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm.js +9 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.js +434 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.wasm +0 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.wasm.d.ts +34 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/package.json +23 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/README.md +181 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm.d.ts +427 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm.js +463 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm_bg.wasm +0 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm_bg.wasm.d.ts +34 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/package.json +18 -0
- package/node_modules/@cedar-policy/cedar-wasm/package.json +53 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/README.md +181 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm.d.ts +486 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm.js +534 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm_bg.wasm +0 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm_bg.wasm.d.ts +34 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/package.json +21 -0
- package/node_modules/@types/node/README.md +5 -6
- package/node_modules/@types/node/assert/strict.d.ts +111 -0
- package/node_modules/@types/node/assert.d.ts +1040 -79
- package/node_modules/@types/node/async_hooks.d.ts +476 -119
- package/node_modules/@types/node/buffer.buffer.d.ts +472 -0
- package/node_modules/@types/node/buffer.d.ts +1925 -13
- package/node_modules/@types/node/child_process.d.ts +1204 -235
- package/node_modules/@types/node/cluster.d.ts +455 -137
- package/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
- package/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
- package/node_modules/@types/node/compatibility/iterators.d.ts +20 -0
- package/node_modules/@types/node/console.d.ts +450 -1
- package/node_modules/@types/node/constants.d.ts +20 -447
- package/node_modules/@types/node/crypto.d.ts +3962 -600
- package/node_modules/@types/node/dgram.d.ts +515 -33
- package/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
- package/node_modules/@types/node/dns/promises.d.ts +503 -0
- package/node_modules/@types/node/dns.d.ts +798 -247
- package/node_modules/@types/node/domain.d.ts +164 -10
- package/node_modules/@types/node/events.d.ts +954 -25
- package/node_modules/@types/node/fs/promises.d.ts +1295 -0
- package/node_modules/@types/node/fs.d.ts +3463 -1569
- package/node_modules/@types/node/globals.d.ts +98 -1277
- package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
- package/node_modules/@types/node/http.d.ts +1933 -300
- package/node_modules/@types/node/http2.d.ts +1946 -254
- package/node_modules/@types/node/https.d.ts +557 -134
- package/node_modules/@types/node/index.d.ts +54 -48
- package/node_modules/@types/node/inspector.d.ts +227 -3014
- package/node_modules/@types/node/inspector.generated.d.ts +4052 -0
- package/node_modules/@types/node/module.d.ts +890 -2
- package/node_modules/@types/node/net.d.ts +872 -105
- package/node_modules/@types/node/os.d.ts +452 -209
- package/node_modules/@types/node/package.json +78 -128
- package/node_modules/@types/node/path.d.ts +196 -155
- package/node_modules/@types/node/perf_hooks.d.ts +829 -120
- package/node_modules/@types/node/process.d.ts +2072 -3
- package/node_modules/@types/node/punycode.d.ts +69 -27
- package/node_modules/@types/node/querystring.d.ts +132 -9
- package/node_modules/@types/node/readline/promises.d.ts +161 -0
- package/node_modules/@types/node/readline.d.ts +485 -49
- package/node_modules/@types/node/repl.d.ts +121 -83
- package/node_modules/@types/node/sea.d.ts +153 -0
- package/node_modules/@types/node/sqlite.d.ts +721 -0
- package/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/node_modules/@types/node/stream/web.d.ts +622 -0
- package/node_modules/@types/node/stream.d.ts +1470 -140
- package/node_modules/@types/node/string_decoder.d.ts +64 -4
- package/node_modules/@types/node/test.d.ts +2163 -0
- package/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/node_modules/@types/node/timers.d.ts +284 -13
- package/node_modules/@types/node/tls.d.ts +850 -244
- package/node_modules/@types/node/trace_events.d.ts +147 -11
- package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
- package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
- package/node_modules/@types/node/ts5.6/index.d.ts +97 -0
- package/node_modules/@types/node/tty.d.ts +160 -18
- package/node_modules/@types/node/url.d.ts +890 -53
- package/node_modules/@types/node/util.d.ts +2566 -160
- package/node_modules/@types/node/v8.d.ts +806 -83
- package/node_modules/@types/node/vm.d.ts +932 -44
- package/node_modules/@types/node/wasi.d.ts +148 -22
- package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
- package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/node_modules/@types/node/web-globals/events.d.ts +97 -0
- package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
- package/node_modules/@types/node/web-globals/navigator.d.ts +22 -0
- package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/node_modules/@types/node/worker_threads.d.ts +657 -80
- package/node_modules/@types/node/zlib.d.ts +510 -119
- package/node_modules/pino/.nojekyll +0 -0
- package/node_modules/pino/.prettierignore +1 -0
- package/node_modules/pino/CNAME +1 -0
- package/node_modules/pino/CONTRIBUTING.md +34 -0
- package/node_modules/pino/LICENSE +21 -0
- package/node_modules/pino/README.md +177 -0
- package/node_modules/pino/SECURITY.md +103 -0
- package/node_modules/pino/benchmarks/basic.bench.js +95 -0
- package/node_modules/pino/benchmarks/child-child.bench.js +52 -0
- package/node_modules/pino/benchmarks/child-creation.bench.js +73 -0
- package/node_modules/pino/benchmarks/child.bench.js +62 -0
- package/node_modules/pino/benchmarks/deep-object.bench.js +88 -0
- package/node_modules/pino/benchmarks/formatters.bench.js +50 -0
- package/node_modules/pino/benchmarks/internal/custom-levels.js +67 -0
- package/node_modules/pino/benchmarks/internal/just-pino-heavy.bench.js +76 -0
- package/node_modules/pino/benchmarks/internal/just-pino.bench.js +182 -0
- package/node_modules/pino/benchmarks/internal/parent-vs-child.bench.js +75 -0
- package/node_modules/pino/benchmarks/internal/redact.bench.js +86 -0
- package/node_modules/pino/benchmarks/long-string.bench.js +81 -0
- package/node_modules/pino/benchmarks/multi-arg.bench.js +193 -0
- package/node_modules/pino/benchmarks/multistream.js +98 -0
- package/node_modules/pino/benchmarks/object.bench.js +82 -0
- package/node_modules/pino/benchmarks/utils/generate-benchmark-doc.js +36 -0
- package/node_modules/pino/benchmarks/utils/runbench.js +138 -0
- package/node_modules/pino/benchmarks/utils/wrap-log-level.js +55 -0
- package/node_modules/pino/bin.js +6 -0
- package/node_modules/pino/browser.js +607 -0
- package/node_modules/pino/build/sync-version.js +25 -0
- package/node_modules/pino/docs/api.md +1664 -0
- package/node_modules/pino/docs/asynchronous.md +55 -0
- package/node_modules/pino/docs/benchmarks.md +55 -0
- package/node_modules/pino/docs/browser.md +341 -0
- package/node_modules/pino/docs/bundling.md +40 -0
- package/node_modules/pino/docs/child-loggers.md +116 -0
- package/node_modules/pino/docs/diagnostics.md +16 -0
- package/node_modules/pino/docs/ecosystem.md +87 -0
- package/node_modules/pino/docs/help.md +353 -0
- package/node_modules/pino/docs/lts.md +93 -0
- package/node_modules/pino/docs/pretty.md +38 -0
- package/node_modules/pino/docs/redaction.md +130 -0
- package/node_modules/pino/docs/transports.md +1447 -0
- package/node_modules/pino/docs/web.md +306 -0
- package/node_modules/pino/eslint.config.js +36 -0
- package/node_modules/pino/examples/basic.js +43 -0
- package/node_modules/pino/examples/transport.js +68 -0
- package/node_modules/pino/favicon.ico +0 -0
- package/node_modules/pino/file.js +12 -0
- package/node_modules/pino/inc-version.sh +42 -0
- package/node_modules/pino/index.html +55 -0
- package/node_modules/pino/lib/caller.js +40 -0
- package/node_modules/pino/lib/constants.js +28 -0
- package/node_modules/pino/lib/deprecations.js +8 -0
- package/node_modules/pino/lib/levels.js +241 -0
- package/node_modules/pino/lib/meta.js +3 -0
- package/node_modules/pino/lib/multistream.js +211 -0
- package/node_modules/pino/lib/proto.js +256 -0
- package/node_modules/pino/lib/redaction.js +119 -0
- package/node_modules/pino/lib/symbols.js +76 -0
- package/node_modules/pino/lib/time.js +39 -0
- package/node_modules/pino/lib/tools.js +427 -0
- package/node_modules/pino/lib/transport-stream.js +56 -0
- package/node_modules/pino/lib/transport.js +302 -0
- package/node_modules/pino/lib/worker.js +197 -0
- package/node_modules/pino/package.json +112 -0
- package/node_modules/pino/pino.d.ts +881 -0
- package/node_modules/pino/pino.js +259 -0
- package/node_modules/pino/test/basic.test.js +952 -0
- package/node_modules/pino/test/broken-pipe.test.js +59 -0
- package/node_modules/pino/test/browser-bindings.test.js +114 -0
- package/node_modules/pino/test/browser-child.test.js +132 -0
- package/node_modules/pino/test/browser-disabled.test.js +87 -0
- package/node_modules/pino/test/browser-early-console-freeze.test.js +12 -0
- package/node_modules/pino/test/browser-is-level-enabled.test.js +101 -0
- package/node_modules/pino/test/browser-levels.test.js +241 -0
- package/node_modules/pino/test/browser-redaction.test.js +264 -0
- package/node_modules/pino/test/browser-serializers.test.js +352 -0
- package/node_modules/pino/test/browser-set-bindings.test.js +99 -0
- package/node_modules/pino/test/browser-timestamp.test.js +88 -0
- package/node_modules/pino/test/browser-transmit.test.js +417 -0
- package/node_modules/pino/test/browser.test.js +698 -0
- package/node_modules/pino/test/caller.test.js +20 -0
- package/node_modules/pino/test/complex-objects.test.js +36 -0
- package/node_modules/pino/test/crlf.test.js +34 -0
- package/node_modules/pino/test/custom-levels.test.js +267 -0
- package/node_modules/pino/test/diagnostics.test.js +107 -0
- package/node_modules/pino/test/error-key.test.js +37 -0
- package/node_modules/pino/test/error.test.js +403 -0
- package/node_modules/pino/test/escaping.test.js +110 -0
- package/node_modules/pino/test/esm/esm.mjs +14 -0
- package/node_modules/pino/test/esm/index.test.js +21 -0
- package/node_modules/pino/test/esm/named-exports.mjs +29 -0
- package/node_modules/pino/test/exit.test.js +79 -0
- package/node_modules/pino/test/fixtures/broken-pipe/basic.js +9 -0
- package/node_modules/pino/test/fixtures/broken-pipe/destination.js +10 -0
- package/node_modules/pino/test/fixtures/broken-pipe/syncfalse.js +12 -0
- package/node_modules/pino/test/fixtures/caller-loop.js +6 -0
- package/node_modules/pino/test/fixtures/console-transport.js +13 -0
- package/node_modules/pino/test/fixtures/crashing-transport.js +13 -0
- package/node_modules/pino/test/fixtures/default-exit.js +8 -0
- package/node_modules/pino/test/fixtures/destination-exit.js +8 -0
- package/node_modules/pino/test/fixtures/eval/index.js +13 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/14-files.js +3 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/2-files.js +3 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file1.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file10.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file11.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file12.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file13.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file14.js +11 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file2.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file3.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file4.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file5.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file6.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file7.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file8.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file9.js +5 -0
- package/node_modules/pino/test/fixtures/noop-transport.js +10 -0
- package/node_modules/pino/test/fixtures/pretty/null-prototype.js +8 -0
- package/node_modules/pino/test/fixtures/stdout-hack-protection.js +11 -0
- package/node_modules/pino/test/fixtures/syncfalse-child.js +6 -0
- package/node_modules/pino/test/fixtures/syncfalse-exit.js +9 -0
- package/node_modules/pino/test/fixtures/syncfalse-flush-exit.js +10 -0
- package/node_modules/pino/test/fixtures/syncfalse.js +6 -0
- package/node_modules/pino/test/fixtures/syntax-error-esm.mjs +2 -0
- package/node_modules/pino/test/fixtures/to-file-transport-with-transform.js +20 -0
- package/node_modules/pino/test/fixtures/to-file-transport.js +13 -0
- package/node_modules/pino/test/fixtures/to-file-transport.mjs +8 -0
- package/node_modules/pino/test/fixtures/transport/index.js +12 -0
- package/node_modules/pino/test/fixtures/transport/package.json +5 -0
- package/node_modules/pino/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
- package/node_modules/pino/test/fixtures/transport-exit-immediately.js +11 -0
- package/node_modules/pino/test/fixtures/transport-exit-on-ready.js +12 -0
- package/node_modules/pino/test/fixtures/transport-invalid-node-options.js +26 -0
- package/node_modules/pino/test/fixtures/transport-main.js +9 -0
- package/node_modules/pino/test/fixtures/transport-many-lines.js +29 -0
- package/node_modules/pino/test/fixtures/transport-preload-main.mjs +13 -0
- package/node_modules/pino/test/fixtures/transport-preload.mjs +13 -0
- package/node_modules/pino/test/fixtures/transport-string-stdout.js +9 -0
- package/node_modules/pino/test/fixtures/transport-transform.js +21 -0
- package/node_modules/pino/test/fixtures/transport-uses-pino-config.js +33 -0
- package/node_modules/pino/test/fixtures/transport-with-on-exit.js +12 -0
- package/node_modules/pino/test/fixtures/transport-worker-data.js +19 -0
- package/node_modules/pino/test/fixtures/transport-worker-name.js +24 -0
- package/node_modules/pino/test/fixtures/transport-worker.js +15 -0
- package/node_modules/pino/test/fixtures/transport-wrong-export-type.js +3 -0
- package/node_modules/pino/test/fixtures/ts/to-file-transport-native.mts +15 -0
- package/node_modules/pino/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
- package/node_modules/pino/test/fixtures/ts/to-file-transport.ts +11 -0
- package/node_modules/pino/test/fixtures/ts/transpile.cjs +36 -0
- package/node_modules/pino/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
- package/node_modules/pino/test/fixtures/ts/transport-exit-immediately.ts +10 -0
- package/node_modules/pino/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
- package/node_modules/pino/test/fixtures/ts/transport-main.ts +8 -0
- package/node_modules/pino/test/fixtures/ts/transport-string-stdout.ts +8 -0
- package/node_modules/pino/test/fixtures/ts/transport-worker.ts +14 -0
- package/node_modules/pino/test/formatters.test.js +364 -0
- package/node_modules/pino/test/helper.d.ts +4 -0
- package/node_modules/pino/test/helper.js +159 -0
- package/node_modules/pino/test/hooks.test.js +114 -0
- package/node_modules/pino/test/http.test.js +214 -0
- package/node_modules/pino/test/internals/version.test.js +17 -0
- package/node_modules/pino/test/is-level-enabled.test.js +179 -0
- package/node_modules/pino/test/jest/basic.spec.js +10 -0
- package/node_modules/pino/test/levels.test.js +810 -0
- package/node_modules/pino/test/metadata.test.js +120 -0
- package/node_modules/pino/test/mixin-merge-strategy.test.js +57 -0
- package/node_modules/pino/test/mixin.test.js +241 -0
- package/node_modules/pino/test/multistream.test.js +793 -0
- package/node_modules/pino/test/redact.test.js +923 -0
- package/node_modules/pino/test/serializers.test.js +257 -0
- package/node_modules/pino/test/smoke.js +59 -0
- package/node_modules/pino/test/stdout-protection.test.js +41 -0
- package/node_modules/pino/test/syncfalse.test.js +186 -0
- package/node_modules/pino/test/timestamp-nano.test.js +37 -0
- package/node_modules/pino/test/timestamp.test.js +124 -0
- package/node_modules/pino/test/transport/big.test.js +42 -0
- package/node_modules/pino/test/transport/bundlers-support.test.js +99 -0
- package/node_modules/pino/test/transport/caller.test.js +24 -0
- package/node_modules/pino/test/transport/core.test.js +818 -0
- package/node_modules/pino/test/transport/core.transpiled.test.ts +114 -0
- package/node_modules/pino/test/transport/crash.test.js +36 -0
- package/node_modules/pino/test/transport/module-link.test.js +241 -0
- package/node_modules/pino/test/transport/native-type-stripping.test.mjs +151 -0
- package/node_modules/pino/test/transport/node-options.test.js +116 -0
- package/node_modules/pino/test/transport/pipeline.test.js +137 -0
- package/node_modules/pino/test/transport/preload.test.js +54 -0
- package/node_modules/pino/test/transport/repl.test.js +15 -0
- package/node_modules/pino/test/transport/sync-false.test.js +79 -0
- package/node_modules/pino/test/transport/sync-true.test.js +57 -0
- package/node_modules/pino/test/transport/targets.test.js +48 -0
- package/node_modules/pino/test/transport/uses-pino-config.test.js +166 -0
- package/node_modules/pino/test/transport-stream.test.js +40 -0
- package/node_modules/pino/test/types/pino-import.tst.cts +30 -0
- package/node_modules/pino/test/types/pino-import.tst.js +73 -0
- package/node_modules/pino/test/types/pino-multistream.tst.ts +49 -0
- package/node_modules/pino/test/types/pino-top-export.tst.ts +32 -0
- package/node_modules/pino/test/types/pino-transport.tst.ts +171 -0
- package/node_modules/pino/test/types/pino-type-only.tst.ts +77 -0
- package/node_modules/pino/test/types/pino.ts +98 -0
- package/node_modules/pino/test/types/pino.tst.ts +681 -0
- package/node_modules/pino/test/types/tsconfig.json +10 -0
- package/node_modules/pino/tsconfig.json +14 -0
- package/node_modules/pino-pretty/.borp.yaml +6 -0
- package/node_modules/pino-pretty/.editorconfig +13 -0
- package/node_modules/pino-pretty/.github/dependabot.yml +13 -0
- package/node_modules/pino-pretty/.github/workflows/ci.yml +83 -0
- package/node_modules/pino-pretty/LICENSE +21 -0
- package/node_modules/pino-pretty/Readme.md +425 -0
- package/node_modules/pino-pretty/SECURITY.md +146 -0
- package/node_modules/pino-pretty/benchmark.js +105 -0
- package/node_modules/pino-pretty/bin.js +113 -0
- package/node_modules/pino-pretty/demo.png +0 -0
- package/node_modules/pino-pretty/docs/help.md +24 -0
- package/node_modules/pino-pretty/eslint.config.js +5 -0
- package/node_modules/pino-pretty/help/help.txt +68 -0
- package/node_modules/pino-pretty/index.d.ts +227 -0
- package/node_modules/pino-pretty/index.js +234 -0
- package/node_modules/pino-pretty/lib/colors.js +134 -0
- package/node_modules/pino-pretty/lib/colors.test.js +132 -0
- package/node_modules/pino-pretty/lib/constants.js +55 -0
- package/node_modules/pino-pretty/lib/pretty.js +171 -0
- package/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.js +69 -0
- package/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.test.js +84 -0
- package/node_modules/pino-pretty/lib/utils/create-date.js +26 -0
- package/node_modules/pino-pretty/lib/utils/create-date.test.js +20 -0
- package/node_modules/pino-pretty/lib/utils/delete-log-property.js +28 -0
- package/node_modules/pino-pretty/lib/utils/delete-log-property.test.js +31 -0
- package/node_modules/pino-pretty/lib/utils/filter-log.js +99 -0
- package/node_modules/pino-pretty/lib/utils/filter-log.test.js +265 -0
- package/node_modules/pino-pretty/lib/utils/format-time.js +66 -0
- package/node_modules/pino-pretty/lib/utils/format-time.test.js +71 -0
- package/node_modules/pino-pretty/lib/utils/get-level-label-data.js +29 -0
- package/node_modules/pino-pretty/lib/utils/get-property-value.js +30 -0
- package/node_modules/pino-pretty/lib/utils/get-property-value.test.js +31 -0
- package/node_modules/pino-pretty/lib/utils/handle-custom-levels-names-opts.js +38 -0
- package/node_modules/pino-pretty/lib/utils/handle-custom-levels-names-opts.test.js +45 -0
- package/node_modules/pino-pretty/lib/utils/handle-custom-levels-opts.js +39 -0
- package/node_modules/pino-pretty/lib/utils/handle-custom-levels-opts.test.js +47 -0
- package/node_modules/pino-pretty/lib/utils/index.js +108 -0
- package/node_modules/pino-pretty/lib/utils/index.test.js +37 -0
- package/node_modules/pino-pretty/lib/utils/interpret-conditionals.js +41 -0
- package/node_modules/pino-pretty/lib/utils/interpret-conditionals.test.js +84 -0
- package/node_modules/pino-pretty/lib/utils/is-object.js +7 -0
- package/node_modules/pino-pretty/lib/utils/is-object.test.js +10 -0
- package/node_modules/pino-pretty/lib/utils/is-valid-date.js +14 -0
- package/node_modules/pino-pretty/lib/utils/is-valid-date.test.js +16 -0
- package/node_modules/pino-pretty/lib/utils/join-lines-with-indentation.js +29 -0
- package/node_modules/pino-pretty/lib/utils/join-lines-with-indentation.test.js +16 -0
- package/node_modules/pino-pretty/lib/utils/noop.js +3 -0
- package/node_modules/pino-pretty/lib/utils/noop.test.js +12 -0
- package/node_modules/pino-pretty/lib/utils/parse-factory-options.js +171 -0
- package/node_modules/pino-pretty/lib/utils/prettify-error-log.js +76 -0
- package/node_modules/pino-pretty/lib/utils/prettify-error-log.test.js +143 -0
- package/node_modules/pino-pretty/lib/utils/prettify-error.js +54 -0
- package/node_modules/pino-pretty/lib/utils/prettify-error.test.js +25 -0
- package/node_modules/pino-pretty/lib/utils/prettify-level.js +41 -0
- package/node_modules/pino-pretty/lib/utils/prettify-level.test.js +70 -0
- package/node_modules/pino-pretty/lib/utils/prettify-message.js +65 -0
- package/node_modules/pino-pretty/lib/utils/prettify-message.test.js +287 -0
- package/node_modules/pino-pretty/lib/utils/prettify-metadata.js +75 -0
- package/node_modules/pino-pretty/lib/utils/prettify-metadata.test.js +170 -0
- package/node_modules/pino-pretty/lib/utils/prettify-object.js +115 -0
- package/node_modules/pino-pretty/lib/utils/prettify-object.test.js +217 -0
- package/node_modules/pino-pretty/lib/utils/prettify-time.js +43 -0
- package/node_modules/pino-pretty/lib/utils/prettify-time.test.js +264 -0
- package/node_modules/pino-pretty/lib/utils/split-property-key.js +49 -0
- package/node_modules/pino-pretty/lib/utils/split-property-key.test.js +29 -0
- package/node_modules/pino-pretty/lib/utils/strip-unsafe-control-chars.js +18 -0
- package/node_modules/pino-pretty/lib/utils/strip-unsafe-control-chars.test.js +9 -0
- package/node_modules/pino-pretty/package.json +64 -0
- package/node_modules/pino-pretty/test/basic.test.js +1305 -0
- package/node_modules/pino-pretty/test/boolean-options.test.js +228 -0
- package/node_modules/pino-pretty/test/cli-rc.test.js +275 -0
- package/node_modules/pino-pretty/test/cli.test.js +360 -0
- package/node_modules/pino-pretty/test/crlf.test.js +33 -0
- package/node_modules/pino-pretty/test/error-objects.test.js +494 -0
- package/node_modules/pino-pretty/test/example/example.js +33 -0
- package/node_modules/pino-pretty/test/helper.js +19 -0
- package/node_modules/pino-pretty/test/types/exports.tst.ts +15 -0
- package/node_modules/pino-pretty/test/types/pino-pretty.tst.ts +140 -0
- package/node_modules/pino-pretty/test/types/tsconfig.json +9 -0
- package/package.json +12 -5
- package/lib/cli/commands/init.d.ts +0 -1
- package/lib/cli/commands/init.js +0 -8
- package/node_modules/@types/node/globals.global.d.ts +0 -1
|
@@ -1,57 +1,143 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
22
|
+
C?: string | string[];
|
|
13
23
|
/**
|
|
14
24
|
* Street.
|
|
15
25
|
*/
|
|
16
|
-
ST
|
|
26
|
+
ST?: string | string[];
|
|
17
27
|
/**
|
|
18
28
|
* Locality.
|
|
19
29
|
*/
|
|
20
|
-
L
|
|
30
|
+
L?: string | string[];
|
|
21
31
|
/**
|
|
22
32
|
* Organization.
|
|
23
33
|
*/
|
|
24
|
-
O
|
|
34
|
+
O?: string | string[];
|
|
25
35
|
/**
|
|
26
36
|
* Organizational unit.
|
|
27
37
|
*/
|
|
28
|
-
OU
|
|
38
|
+
OU?: string | string[];
|
|
29
39
|
/**
|
|
30
40
|
* Common name.
|
|
31
41
|
*/
|
|
32
|
-
CN
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
138
|
-
*
|
|
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
|
-
*
|
|
143
|
-
*
|
|
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
|
-
*
|
|
156
|
-
|
|
157
|
-
|
|
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
|
|
160
|
-
*
|
|
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
|
-
*
|
|
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
|
|
168
|
-
*
|
|
169
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
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
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* the
|
|
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():
|
|
303
|
+
getFinished(): NonSharedBuffer | undefined;
|
|
198
304
|
/**
|
|
199
|
-
* Returns an object representing the peer's certificate.
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* If the
|
|
204
|
-
*
|
|
205
|
-
* @
|
|
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
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
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
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* the
|
|
219
|
-
*
|
|
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
|
-
*
|
|
222
|
-
*
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* See https://www.openssl.org/docs/man1.
|
|
230
|
-
* @
|
|
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
|
-
*
|
|
235
|
-
*
|
|
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():
|
|
360
|
+
getSession(): NonSharedBuffer | undefined;
|
|
238
361
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
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
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
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():
|
|
375
|
+
getTLSTicket(): NonSharedBuffer | undefined;
|
|
249
376
|
/**
|
|
250
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* is
|
|
262
|
-
*
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
*
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
*
|
|
280
|
-
*
|
|
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
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
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:
|
|
488
|
+
addListener(event: "OCSPResponse", listener: (response: NonSharedBuffer) => void): this;
|
|
297
489
|
addListener(event: "secureConnect", listener: () => void): this;
|
|
298
|
-
addListener(event: "session", listener: (session:
|
|
299
|
-
addListener(event: "keylog", listener: (line:
|
|
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:
|
|
493
|
+
emit(event: "OCSPResponse", response: NonSharedBuffer): boolean;
|
|
303
494
|
emit(event: "secureConnect"): boolean;
|
|
304
|
-
emit(event: "session", session:
|
|
305
|
-
emit(event: "keylog", line:
|
|
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:
|
|
498
|
+
on(event: "OCSPResponse", listener: (response: NonSharedBuffer) => void): this;
|
|
309
499
|
on(event: "secureConnect", listener: () => void): this;
|
|
310
|
-
on(event: "session", listener: (session:
|
|
311
|
-
on(event: "keylog", listener: (line:
|
|
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:
|
|
503
|
+
once(event: "OCSPResponse", listener: (response: NonSharedBuffer) => void): this;
|
|
315
504
|
once(event: "secureConnect", listener: () => void): this;
|
|
316
|
-
once(event: "session", listener: (session:
|
|
317
|
-
once(event: "keylog", listener: (line:
|
|
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:
|
|
508
|
+
prependListener(event: "OCSPResponse", listener: (response: NonSharedBuffer) => void): this;
|
|
321
509
|
prependListener(event: "secureConnect", listener: () => void): this;
|
|
322
|
-
prependListener(event: "session", listener: (session:
|
|
323
|
-
prependListener(event: "keylog", listener: (line:
|
|
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:
|
|
513
|
+
prependOnceListener(event: "OCSPResponse", listener: (response: NonSharedBuffer) => void): this;
|
|
327
514
|
prependOnceListener(event: "secureConnect", listener: () => void): this;
|
|
328
|
-
prependOnceListener(event: "session", listener: (session:
|
|
329
|
-
prependOnceListener(event: "keylog", listener: (line:
|
|
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[] |
|
|
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
|
|
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
|
-
*
|
|
411
|
-
*
|
|
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(
|
|
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():
|
|
663
|
+
getTicketKeys(): NonSharedBuffer;
|
|
418
664
|
/**
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
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(
|
|
670
|
+
setSecureContext(options: SecureContextOptions): void;
|
|
425
671
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
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(
|
|
444
|
-
|
|
445
|
-
|
|
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:
|
|
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(
|
|
452
|
-
|
|
453
|
-
|
|
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:
|
|
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(
|
|
460
|
-
|
|
461
|
-
|
|
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:
|
|
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(
|
|
468
|
-
|
|
469
|
-
|
|
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:
|
|
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(
|
|
476
|
-
|
|
477
|
-
|
|
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:
|
|
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(
|
|
484
|
-
|
|
485
|
-
|
|
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:
|
|
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
|
|
540
|
-
*
|
|
541
|
-
*
|
|
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
|
-
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
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
|
-
*
|
|
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(
|
|
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
|
-
*
|
|
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'
|
|
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
|
-
*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
* the default to 'TLSv1.
|
|
692
|
-
*
|
|
693
|
-
*
|
|
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
|
|
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'
|
|
700
|
-
* changed using CLI options. Using
|
|
701
|
-
* 'TLSv1'
|
|
702
|
-
*
|
|
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
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
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
|
-
|
|
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
|
}
|