@node-red/editor-client 3.1.8 → 4.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/locales/de/editor.json +2 -0
  2. package/locales/en-US/editor.json +10 -1
  3. package/locales/fr/editor.json +8 -1
  4. package/locales/ja/editor.json +10 -3
  5. package/package.json +1 -1
  6. package/public/red/about +52 -0
  7. package/public/red/red.js +1433 -263
  8. package/public/red/red.min.js +3 -3
  9. package/public/red/style.min.css +2 -2
  10. package/public/red/tours/3.1/welcome.js +231 -0
  11. package/public/red/tours/images/nr4-auto-complete.png +0 -0
  12. package/public/red/tours/images/nr4-config-select.png +0 -0
  13. package/public/red/tours/images/nr4-multiplayer.png +0 -0
  14. package/public/red/tours/images/nr4-plugins.png +0 -0
  15. package/public/red/tours/images/nr4-sf-config.png +0 -0
  16. package/public/red/tours/images/nr4-timestamp-formatting.png +0 -0
  17. package/public/red/tours/welcome.js +105 -161
  18. package/public/types/node/assert/strict.d.ts +1 -1
  19. package/public/types/node/assert.d.ts +8 -9
  20. package/public/types/node/async_hooks.d.ts +9 -5
  21. package/public/types/node/buffer.d.ts +43 -18
  22. package/public/types/node/child_process.d.ts +8 -5
  23. package/public/types/node/cluster.d.ts +15 -19
  24. package/public/types/node/console.d.ts +2 -2
  25. package/public/types/node/crypto.d.ts +165 -70
  26. package/public/types/node/dgram.d.ts +4 -4
  27. package/public/types/node/diagnostics_channel.d.ts +8 -7
  28. package/public/types/node/dns/promises.d.ts +11 -9
  29. package/public/types/node/dns.d.ts +18 -13
  30. package/public/types/node/dom-events.d.ts +129 -0
  31. package/public/types/node/domain.d.ts +2 -2
  32. package/public/types/node/events.d.ts +49 -12
  33. package/public/types/node/fs/promises.d.ts +68 -24
  34. package/public/types/node/fs.d.ts +132 -59
  35. package/public/types/node/globals.d.ts +31 -17
  36. package/public/types/node/http.d.ts +138 -27
  37. package/public/types/node/http2.d.ts +38 -5
  38. package/public/types/node/https.d.ts +12 -3
  39. package/public/types/node/module.d.ts +1 -2
  40. package/public/types/node/net.d.ts +69 -28
  41. package/public/types/node/os.d.ts +16 -5
  42. package/public/types/node/path.d.ts +5 -5
  43. package/public/types/node/perf_hooks.d.ts +48 -9
  44. package/public/types/node/process.d.ts +18 -17
  45. package/public/types/node/querystring.d.ts +2 -2
  46. package/public/types/node/readline/promises.d.ts +146 -0
  47. package/public/types/node/readline.d.ts +141 -31
  48. package/public/types/node/stream/consumers.d.ts +2 -2
  49. package/public/types/node/stream/promises.d.ts +1 -1
  50. package/public/types/node/stream/web.d.ts +4 -66
  51. package/public/types/node/stream.d.ts +96 -118
  52. package/public/types/node/string_decoder.d.ts +2 -2
  53. package/public/types/node/test.d.ts +200 -16
  54. package/public/types/node/timers/promises.d.ts +1 -26
  55. package/public/types/node/timers.d.ts +2 -2
  56. package/public/types/node/tls.d.ts +21 -12
  57. package/public/types/node/trace_events.d.ts +12 -2
  58. package/public/types/node/ts4.8/assert/strict.d.ts +11 -0
  59. package/public/types/node/ts4.8/assert.d.ts +964 -0
  60. package/public/types/node/ts4.8/async_hooks.d.ts +504 -0
  61. package/public/types/node/ts4.8/buffer.d.ts +2262 -0
  62. package/public/types/node/ts4.8/child_process.d.ts +1372 -0
  63. package/public/types/node/ts4.8/cluster.d.ts +413 -0
  64. package/public/types/node/ts4.8/console.d.ts +415 -0
  65. package/public/types/node/ts4.8/crypto.d.ts +3967 -0
  66. package/public/types/node/ts4.8/dgram.d.ts +548 -0
  67. package/public/types/node/ts4.8/diagnostics_channel.d.ts +156 -0
  68. package/public/types/node/ts4.8/dns/promises.d.ts +373 -0
  69. package/public/types/node/ts4.8/dns.d.ts +662 -0
  70. package/public/types/node/ts4.8/dom-events.d.ts +129 -0
  71. package/public/types/node/ts4.8/domain.d.ts +173 -0
  72. package/public/types/node/ts4.8/events.d.ts +681 -0
  73. package/public/types/node/ts4.8/fs/promises.d.ts +1141 -0
  74. package/public/types/node/ts4.8/fs.d.ts +3875 -0
  75. package/public/types/node/ts4.8/globals.d.ts +297 -0
  76. package/public/types/node/ts4.8/http.d.ts +1617 -0
  77. package/public/types/node/ts4.8/http2.d.ts +2137 -0
  78. package/public/types/node/ts4.8/https.d.ts +544 -0
  79. package/public/types/node/ts4.8/module.d.ts +117 -0
  80. package/public/types/node/ts4.8/net.d.ts +872 -0
  81. package/public/types/node/ts4.8/os.d.ts +469 -0
  82. package/public/types/node/ts4.8/path.d.ts +194 -0
  83. package/public/types/node/ts4.8/perf_hooks.d.ts +628 -0
  84. package/public/types/node/ts4.8/process.d.ts +1485 -0
  85. package/public/types/node/ts4.8/querystring.d.ts +134 -0
  86. package/public/types/node/ts4.8/readline/promises.d.ts +146 -0
  87. package/public/types/node/ts4.8/readline.d.ts +656 -0
  88. package/public/types/node/ts4.8/stream/consumers.d.ts +15 -0
  89. package/public/types/node/ts4.8/stream/promises.d.ts +45 -0
  90. package/public/types/node/ts4.8/stream/web.d.ts +333 -0
  91. package/public/types/node/ts4.8/stream.d.ts +1343 -0
  92. package/public/types/node/ts4.8/string_decoder.d.ts +70 -0
  93. package/public/types/node/ts4.8/test.d.ts +377 -0
  94. package/public/types/node/ts4.8/timers/promises.d.ts +71 -0
  95. package/public/types/node/ts4.8/timers.d.ts +97 -0
  96. package/public/types/node/ts4.8/tls.d.ts +1031 -0
  97. package/public/types/node/ts4.8/trace_events.d.ts +174 -0
  98. package/public/types/node/ts4.8/tty.d.ts +209 -0
  99. package/public/types/node/ts4.8/url.d.ts +900 -0
  100. package/public/types/node/ts4.8/util.d.ts +1853 -0
  101. package/public/types/node/ts4.8/v8.d.ts +399 -0
  102. package/public/types/node/ts4.8/vm.d.ts +512 -0
  103. package/public/types/node/ts4.8/wasi.d.ts +161 -0
  104. package/public/types/node/ts4.8/worker_threads.d.ts +692 -0
  105. package/public/types/node/ts4.8/zlib.d.ts +520 -0
  106. package/public/types/node/tty.d.ts +5 -3
  107. package/public/types/node/url.d.ts +81 -39
  108. package/public/types/node/util.d.ts +269 -13
  109. package/public/types/node/v8.d.ts +22 -4
  110. package/public/types/node/vm.d.ts +7 -5
  111. package/public/types/node/wasi.d.ts +2 -2
  112. package/public/types/node/worker_threads.d.ts +51 -11
  113. package/public/types/node/zlib.d.ts +2 -2
  114. package/public/types/node-red/func.d.ts +26 -17
  115. package/public/vendor/ace/worker-jsonata.js +1 -1
  116. package/public/vendor/monaco/dist/{fa2cc0ab9f0bec2b3365.ttf → 0c718f5b7d2bce997c5f.ttf} +0 -0
  117. package/public/vendor/monaco/dist/css.worker.js +1 -1
  118. package/public/vendor/monaco/dist/css.worker.js.LICENSE.txt +1 -1
  119. package/public/vendor/monaco/dist/editor.js +1 -29
  120. package/public/vendor/monaco/dist/editor.js.LICENSE.txt +2 -2
  121. package/public/vendor/monaco/dist/editor.worker.js +1 -1
  122. package/public/vendor/monaco/dist/html.worker.js +1 -1
  123. package/public/vendor/monaco/dist/html.worker.js.LICENSE.txt +1 -1
  124. package/public/vendor/monaco/dist/json.worker.js +1 -1
  125. package/public/vendor/monaco/dist/json.worker.js.LICENSE.txt +1 -1
  126. package/public/vendor/monaco/dist/locale/cs.js +324 -106
  127. package/public/vendor/monaco/dist/locale/de.js +336 -118
  128. package/public/vendor/monaco/dist/locale/es.js +329 -111
  129. package/public/vendor/monaco/dist/locale/fr.js +334 -116
  130. package/public/vendor/monaco/dist/locale/it.js +327 -109
  131. package/public/vendor/monaco/dist/locale/ja.js +329 -111
  132. package/public/vendor/monaco/dist/locale/ko.js +330 -112
  133. package/public/vendor/monaco/dist/locale/pl.js +329 -111
  134. package/public/vendor/monaco/dist/locale/pt-br.js +329 -111
  135. package/public/vendor/monaco/dist/locale/qps-ploc.js +330 -112
  136. package/public/vendor/monaco/dist/locale/ru.js +331 -113
  137. package/public/vendor/monaco/dist/locale/tr.js +329 -111
  138. package/public/vendor/monaco/dist/locale/zh-hans.js +331 -113
  139. package/public/vendor/monaco/dist/locale/zh-hant.js +331 -113
  140. package/public/vendor/monaco/dist/ts.worker.js +2 -2
  141. package/public/vendor/vendor.js +1 -1
  142. package/public/vendor/monaco/dist/7064e66c3890a12c47b4.ttf +0 -0
  143. /package/public/red/tours/{images → 3.1/images}/context-menu.png +0 -0
  144. /package/public/red/tours/{images → 3.1/images}/global-env-vars.png +0 -0
  145. /package/public/red/tours/{images → 3.1/images}/hiding-flows.png +0 -0
  146. /package/public/red/tours/{images → 3.1/images}/locking-flows.png +0 -0
  147. /package/public/red/tours/{images → 3.1/images}/mermaid.png +0 -0
  148. /package/public/red/tours/{images → 3.1/images}/node-help.png +0 -0
  149. /package/public/red/tours/{images → 3.1/images}/tab-changes.png +0 -0
@@ -0,0 +1,1031 @@
1
+
2
+ /* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
3
+
4
+ /**
5
+ * The `tls` module provides an implementation of the Transport Layer Security
6
+ * (TLS) and Secure Socket Layer (SSL) protocols that is built on top of OpenSSL.
7
+ * The module can be accessed using:
8
+ *
9
+ * ```js
10
+ * const tls = require('tls');
11
+ * ```
12
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/tls.js)
13
+ */
14
+ declare module 'tls' {
15
+ import { X509Certificate } from 'node:crypto';
16
+ import * as net from 'node:net';
17
+ import * as stream from 'stream';
18
+ const CLIENT_RENEG_LIMIT: number;
19
+ const CLIENT_RENEG_WINDOW: number;
20
+ interface Certificate {
21
+ /**
22
+ * Country code.
23
+ */
24
+ C: string;
25
+ /**
26
+ * Street.
27
+ */
28
+ ST: string;
29
+ /**
30
+ * Locality.
31
+ */
32
+ L: string;
33
+ /**
34
+ * Organization.
35
+ */
36
+ O: string;
37
+ /**
38
+ * Organizational unit.
39
+ */
40
+ OU: string;
41
+ /**
42
+ * Common name.
43
+ */
44
+ CN: string;
45
+ }
46
+ interface PeerCertificate {
47
+ subject: Certificate;
48
+ issuer: Certificate;
49
+ subjectaltname: string;
50
+ infoAccess: NodeJS.Dict<string[]>;
51
+ modulus: string;
52
+ exponent: string;
53
+ valid_from: string;
54
+ valid_to: string;
55
+ fingerprint: string;
56
+ fingerprint256: string;
57
+ ext_key_usage: string[];
58
+ serialNumber: string;
59
+ raw: Buffer;
60
+ }
61
+ interface DetailedPeerCertificate extends PeerCertificate {
62
+ issuerCertificate: DetailedPeerCertificate;
63
+ }
64
+ interface CipherNameAndProtocol {
65
+ /**
66
+ * The cipher name.
67
+ */
68
+ name: string;
69
+ /**
70
+ * SSL/TLS protocol version.
71
+ */
72
+ version: string;
73
+ /**
74
+ * IETF name for the cipher suite.
75
+ */
76
+ standardName: string;
77
+ }
78
+ interface EphemeralKeyInfo {
79
+ /**
80
+ * The supported types are 'DH' and 'ECDH'.
81
+ */
82
+ type: string;
83
+ /**
84
+ * The name property is available only when type is 'ECDH'.
85
+ */
86
+ name?: string | undefined;
87
+ /**
88
+ * The size of parameter of an ephemeral key exchange.
89
+ */
90
+ size: number;
91
+ }
92
+ interface KeyObject {
93
+ /**
94
+ * Private keys in PEM format.
95
+ */
96
+ pem: string | Buffer;
97
+ /**
98
+ * Optional passphrase.
99
+ */
100
+ passphrase?: string | undefined;
101
+ }
102
+ interface PxfObject {
103
+ /**
104
+ * PFX or PKCS12 encoded private key and certificate chain.
105
+ */
106
+ buf: string | Buffer;
107
+ /**
108
+ * Optional passphrase.
109
+ */
110
+ passphrase?: string | undefined;
111
+ }
112
+ interface TLSSocketOptions extends SecureContextOptions, CommonConnectionOptions {
113
+ /**
114
+ * If true the TLS socket will be instantiated in server-mode.
115
+ * Defaults to false.
116
+ */
117
+ isServer?: boolean | undefined;
118
+ /**
119
+ * An optional net.Server instance.
120
+ */
121
+ server?: net.Server | undefined;
122
+ /**
123
+ * An optional Buffer instance containing a TLS session.
124
+ */
125
+ session?: Buffer | undefined;
126
+ /**
127
+ * If true, specifies that the OCSP status request extension will be
128
+ * added to the client hello and an 'OCSPResponse' event will be
129
+ * emitted on the socket before establishing a secure communication
130
+ */
131
+ requestOCSP?: boolean | undefined;
132
+ }
133
+ /**
134
+ * Performs transparent encryption of written data and all required TLS
135
+ * negotiation.
136
+ *
137
+ * Instances of `tls.TLSSocket` implement the duplex `Stream` interface.
138
+ *
139
+ * Methods that return TLS connection metadata (e.g.{@link TLSSocket.getPeerCertificate} will only return data while the
140
+ * connection is open.
141
+ * @since v0.11.4
142
+ */
143
+ class TLSSocket extends net.Socket {
144
+ /**
145
+ * Construct a new tls.TLSSocket object from an existing TCP socket.
146
+ */
147
+ constructor(socket: net.Socket, options?: TLSSocketOptions);
148
+ /**
149
+ * This property is `true` if the peer certificate was signed by one of the CAs
150
+ * specified when creating the `tls.TLSSocket` instance, otherwise `false`.
151
+ * @since v0.11.4
152
+ */
153
+ authorized: boolean;
154
+ /**
155
+ * Returns the reason why the peer's certificate was not been verified. This
156
+ * property is set only when `tlsSocket.authorized === false`.
157
+ * @since v0.11.4
158
+ */
159
+ authorizationError: Error;
160
+ /**
161
+ * Always returns `true`. This may be used to distinguish TLS sockets from regular`net.Socket` instances.
162
+ * @since v0.11.4
163
+ */
164
+ encrypted: true;
165
+ /**
166
+ * String containing the selected ALPN protocol.
167
+ * Before a handshake has completed, this value is always null.
168
+ * When a handshake is completed but not ALPN protocol was selected, tlsSocket.alpnProtocol equals false.
169
+ */
170
+ alpnProtocol: string | false | null;
171
+ /**
172
+ * Returns an object representing the local certificate. The returned object has
173
+ * some properties corresponding to the fields of the certificate.
174
+ *
175
+ * See {@link TLSSocket.getPeerCertificate} for an example of the certificate
176
+ * structure.
177
+ *
178
+ * If there is no local certificate, an empty object will be returned. If the
179
+ * socket has been destroyed, `null` will be returned.
180
+ * @since v11.2.0
181
+ */
182
+ getCertificate(): PeerCertificate | object | null;
183
+ /**
184
+ * Returns an object containing information on the negotiated cipher suite.
185
+ *
186
+ * For example:
187
+ *
188
+ * ```json
189
+ * {
190
+ * "name": "AES128-SHA256",
191
+ * "standardName": "TLS_RSA_WITH_AES_128_CBC_SHA256",
192
+ * "version": "TLSv1.2"
193
+ * }
194
+ * ```
195
+ *
196
+ * See [SSL\_CIPHER\_get\_name](https://www.openssl.org/docs/man1.1.1/man3/SSL_CIPHER_get_name.html) for more information.
197
+ * @since v0.11.4
198
+ */
199
+ getCipher(): CipherNameAndProtocol;
200
+ /**
201
+ * Returns an object representing the type, name, and size of parameter of
202
+ * an ephemeral key exchange in `perfect forward secrecy` on a client
203
+ * connection. It returns an empty object when the key exchange is not
204
+ * ephemeral. As this is only supported on a client socket; `null` is returned
205
+ * if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The`name` property is available only when type is `'ECDH'`.
206
+ *
207
+ * For example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }`.
208
+ * @since v5.0.0
209
+ */
210
+ getEphemeralKeyInfo(): EphemeralKeyInfo | object | null;
211
+ /**
212
+ * As the `Finished` messages are message digests of the complete handshake
213
+ * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can
214
+ * be used for external authentication procedures when the authentication
215
+ * provided by SSL/TLS is not desired or is not enough.
216
+ *
217
+ * Corresponds to the `SSL_get_finished` routine in OpenSSL and may be used
218
+ * to implement the `tls-unique` channel binding from [RFC 5929](https://tools.ietf.org/html/rfc5929).
219
+ * @since v9.9.0
220
+ * @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.
221
+ */
222
+ getFinished(): Buffer | undefined;
223
+ /**
224
+ * Returns an object representing the peer's certificate. If the peer does not
225
+ * provide a certificate, an empty object will be returned. If the socket has been
226
+ * destroyed, `null` will be returned.
227
+ *
228
+ * If the full certificate chain was requested, each certificate will include an`issuerCertificate` property containing an object representing its issuer's
229
+ * certificate.
230
+ * @since v0.11.4
231
+ * @param detailed Include the full certificate chain if `true`, otherwise include just the peer's certificate.
232
+ * @return A certificate object.
233
+ */
234
+ getPeerCertificate(detailed: true): DetailedPeerCertificate;
235
+ getPeerCertificate(detailed?: false): PeerCertificate;
236
+ getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate;
237
+ /**
238
+ * As the `Finished` messages are message digests of the complete handshake
239
+ * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can
240
+ * be used for external authentication procedures when the authentication
241
+ * provided by SSL/TLS is not desired or is not enough.
242
+ *
243
+ * Corresponds to the `SSL_get_peer_finished` routine in OpenSSL and may be used
244
+ * to implement the `tls-unique` channel binding from [RFC 5929](https://tools.ietf.org/html/rfc5929).
245
+ * @since v9.9.0
246
+ * @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
247
+ * far.
248
+ */
249
+ getPeerFinished(): Buffer | undefined;
250
+ /**
251
+ * Returns a string containing the negotiated SSL/TLS protocol version of the
252
+ * current connection. The value `'unknown'` will be returned for connected
253
+ * sockets that have not completed the handshaking process. The value `null` will
254
+ * be returned for server sockets or disconnected client sockets.
255
+ *
256
+ * Protocol versions are:
257
+ *
258
+ * * `'SSLv3'`
259
+ * * `'TLSv1'`
260
+ * * `'TLSv1.1'`
261
+ * * `'TLSv1.2'`
262
+ * * `'TLSv1.3'`
263
+ *
264
+ * See the OpenSSL [`SSL_get_version`](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_version.html) documentation for more information.
265
+ * @since v5.7.0
266
+ */
267
+ getProtocol(): string | null;
268
+ /**
269
+ * Returns the TLS session data or `undefined` if no session was
270
+ * 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
271
+ * for debugging.
272
+ *
273
+ * See `Session Resumption` for more information.
274
+ *
275
+ * Note: `getSession()` works only for TLSv1.2 and below. For TLSv1.3, applications
276
+ * must use the `'session'` event (it also works for TLSv1.2 and below).
277
+ * @since v0.11.4
278
+ */
279
+ getSession(): Buffer | undefined;
280
+ /**
281
+ * See [SSL\_get\_shared\_sigalgs](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html) for more information.
282
+ * @since v12.11.0
283
+ * @return List of signature algorithms shared between the server and the client in the order of decreasing preference.
284
+ */
285
+ getSharedSigalgs(): string[];
286
+ /**
287
+ * For a client, returns the TLS session ticket if one is available, or`undefined`. For a server, always returns `undefined`.
288
+ *
289
+ * It may be useful for debugging.
290
+ *
291
+ * See `Session Resumption` for more information.
292
+ * @since v0.11.4
293
+ */
294
+ getTLSTicket(): Buffer | undefined;
295
+ /**
296
+ * See `Session Resumption` for more information.
297
+ * @since v0.5.6
298
+ * @return `true` if the session was reused, `false` otherwise.
299
+ */
300
+ isSessionReused(): boolean;
301
+ /**
302
+ * The `tlsSocket.renegotiate()` method initiates a TLS renegotiation process.
303
+ * Upon completion, the `callback` function will be passed a single argument
304
+ * that is either an `Error` (if the request failed) or `null`.
305
+ *
306
+ * This method can be used to request a peer's certificate after the secure
307
+ * connection has been established.
308
+ *
309
+ * When running as the server, the socket will be destroyed with an error after`handshakeTimeout` timeout.
310
+ *
311
+ * For TLSv1.3, renegotiation cannot be initiated, it is not supported by the
312
+ * protocol.
313
+ * @since v0.11.8
314
+ * @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
315
+ * an error, unless the `tlsSocket` has been destroyed, in which case `callback` will not be called at all.
316
+ * @return `true` if renegotiation was initiated, `false` otherwise.
317
+ */
318
+ renegotiate(
319
+ options: {
320
+ rejectUnauthorized?: boolean | undefined;
321
+ requestCert?: boolean | undefined;
322
+ },
323
+ callback: (err: Error | null) => void
324
+ ): undefined | boolean;
325
+ /**
326
+ * The `tlsSocket.setMaxSendFragment()` method sets the maximum TLS fragment size.
327
+ * Returns `true` if setting the limit succeeded; `false` otherwise.
328
+ *
329
+ * Smaller fragment sizes decrease the buffering latency on the client: larger
330
+ * fragments are buffered by the TLS layer until the entire fragment is received
331
+ * and its integrity is verified; large fragments can span multiple roundtrips
332
+ * and their processing can be delayed due to packet loss or reordering. However,
333
+ * smaller fragments add extra TLS framing bytes and CPU overhead, which may
334
+ * decrease overall server throughput.
335
+ * @since v0.11.11
336
+ * @param [size=16384] The maximum TLS fragment size. The maximum value is `16384`.
337
+ */
338
+ setMaxSendFragment(size: number): boolean;
339
+ /**
340
+ * Disables TLS renegotiation for this `TLSSocket` instance. Once called, attempts
341
+ * to renegotiate will trigger an `'error'` event on the `TLSSocket`.
342
+ * @since v8.4.0
343
+ */
344
+ disableRenegotiation(): void;
345
+ /**
346
+ * When enabled, TLS packet trace information is written to `stderr`. This can be
347
+ * used to debug TLS connection problems.
348
+ *
349
+ * 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
350
+ * OpenSSL's `SSL_trace()` function, the format is undocumented, can change
351
+ * without notice, and should not be relied on.
352
+ * @since v12.2.0
353
+ */
354
+ enableTrace(): void;
355
+ /**
356
+ * Returns the peer certificate as an `X509Certificate` object.
357
+ *
358
+ * If there is no peer certificate, or the socket has been destroyed,`undefined` will be returned.
359
+ * @since v15.9.0
360
+ */
361
+ getPeerX509Certificate(): X509Certificate | undefined;
362
+ /**
363
+ * Returns the local certificate as an `X509Certificate` object.
364
+ *
365
+ * If there is no local certificate, or the socket has been destroyed,`undefined` will be returned.
366
+ * @since v15.9.0
367
+ */
368
+ getX509Certificate(): X509Certificate | undefined;
369
+ /**
370
+ * Keying material is used for validations to prevent different kind of attacks in
371
+ * network protocols, for example in the specifications of IEEE 802.1X.
372
+ *
373
+ * Example
374
+ *
375
+ * ```js
376
+ * const keyingMaterial = tlsSocket.exportKeyingMaterial(
377
+ * 128,
378
+ * 'client finished');
379
+ *
380
+ * /*
381
+ * Example return value of keyingMaterial:
382
+ * <Buffer 76 26 af 99 c5 56 8e 42 09 91 ef 9f 93 cb ad 6c 7b 65 f8 53 f1 d8 d9
383
+ * 12 5a 33 b8 b5 25 df 7b 37 9f e0 e2 4f b8 67 83 a3 2f cd 5d 41 42 4c 91
384
+ * 74 ef 2c ... 78 more bytes>
385
+ *
386
+ * ```
387
+ *
388
+ * See the OpenSSL [`SSL_export_keying_material`](https://www.openssl.org/docs/man1.1.1/man3/SSL_export_keying_material.html) documentation for more
389
+ * information.
390
+ * @since v13.10.0, v12.17.0
391
+ * @param length number of bytes to retrieve from keying material
392
+ * @param label an application specific label, typically this will be a value from the [IANA Exporter Label
393
+ * Registry](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels).
394
+ * @param context Optionally provide a context.
395
+ * @return requested bytes of the keying material
396
+ */
397
+ exportKeyingMaterial(length: number, label: string, context: Buffer): Buffer;
398
+ addListener(event: string, listener: (...args: any[]) => void): this;
399
+ addListener(event: 'OCSPResponse', listener: (response: Buffer) => void): this;
400
+ addListener(event: 'secureConnect', listener: () => void): this;
401
+ addListener(event: 'session', listener: (session: Buffer) => void): this;
402
+ addListener(event: 'keylog', listener: (line: Buffer) => void): this;
403
+ emit(event: string | symbol, ...args: any[]): boolean;
404
+ emit(event: 'OCSPResponse', response: Buffer): boolean;
405
+ emit(event: 'secureConnect'): boolean;
406
+ emit(event: 'session', session: Buffer): boolean;
407
+ emit(event: 'keylog', line: Buffer): boolean;
408
+ on(event: string, listener: (...args: any[]) => void): this;
409
+ on(event: 'OCSPResponse', listener: (response: Buffer) => void): this;
410
+ on(event: 'secureConnect', listener: () => void): this;
411
+ on(event: 'session', listener: (session: Buffer) => void): this;
412
+ on(event: 'keylog', listener: (line: Buffer) => void): this;
413
+ once(event: string, listener: (...args: any[]) => void): this;
414
+ once(event: 'OCSPResponse', listener: (response: Buffer) => void): this;
415
+ once(event: 'secureConnect', listener: () => void): this;
416
+ once(event: 'session', listener: (session: Buffer) => void): this;
417
+ once(event: 'keylog', listener: (line: Buffer) => void): this;
418
+ prependListener(event: string, listener: (...args: any[]) => void): this;
419
+ prependListener(event: 'OCSPResponse', listener: (response: Buffer) => void): this;
420
+ prependListener(event: 'secureConnect', listener: () => void): this;
421
+ prependListener(event: 'session', listener: (session: Buffer) => void): this;
422
+ prependListener(event: 'keylog', listener: (line: Buffer) => void): this;
423
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
424
+ prependOnceListener(event: 'OCSPResponse', listener: (response: Buffer) => void): this;
425
+ prependOnceListener(event: 'secureConnect', listener: () => void): this;
426
+ prependOnceListener(event: 'session', listener: (session: Buffer) => void): this;
427
+ prependOnceListener(event: 'keylog', listener: (line: Buffer) => void): this;
428
+ }
429
+ interface CommonConnectionOptions {
430
+ /**
431
+ * An optional TLS context object from tls.createSecureContext()
432
+ */
433
+ secureContext?: SecureContext | undefined;
434
+ /**
435
+ * When enabled, TLS packet trace information is written to `stderr`. This can be
436
+ * used to debug TLS connection problems.
437
+ * @default false
438
+ */
439
+ enableTrace?: boolean | undefined;
440
+ /**
441
+ * If true the server will request a certificate from clients that
442
+ * connect and attempt to verify that certificate. Defaults to
443
+ * false.
444
+ */
445
+ requestCert?: boolean | undefined;
446
+ /**
447
+ * An array of strings or a Buffer naming possible ALPN protocols.
448
+ * (Protocols should be ordered by their priority.)
449
+ */
450
+ ALPNProtocols?: string[] | Uint8Array[] | Uint8Array | undefined;
451
+ /**
452
+ * SNICallback(servername, cb) <Function> A function that will be
453
+ * called if the client supports SNI TLS extension. Two arguments
454
+ * will be passed when called: servername and cb. SNICallback should
455
+ * invoke cb(null, ctx), where ctx is a SecureContext instance.
456
+ * (tls.createSecureContext(...) can be used to get a proper
457
+ * SecureContext.) If SNICallback wasn't provided the default callback
458
+ * with high-level API will be used (see below).
459
+ */
460
+ SNICallback?: ((servername: string, cb: (err: Error | null, ctx?: SecureContext) => void) => void) | undefined;
461
+ /**
462
+ * If true the server will reject any connection which is not
463
+ * authorized with the list of supplied CAs. This option only has an
464
+ * effect if requestCert is true.
465
+ * @default true
466
+ */
467
+ rejectUnauthorized?: boolean | undefined;
468
+ }
469
+ interface TlsOptions extends SecureContextOptions, CommonConnectionOptions, net.ServerOpts {
470
+ /**
471
+ * Abort the connection if the SSL/TLS handshake does not finish in the
472
+ * specified number of milliseconds. A 'tlsClientError' is emitted on
473
+ * the tls.Server object whenever a handshake times out. Default:
474
+ * 120000 (120 seconds).
475
+ */
476
+ handshakeTimeout?: number | undefined;
477
+ /**
478
+ * The number of seconds after which a TLS session created by the
479
+ * server will no longer be resumable. See Session Resumption for more
480
+ * information. Default: 300.
481
+ */
482
+ sessionTimeout?: number | undefined;
483
+ /**
484
+ * 48-bytes of cryptographically strong pseudo-random data.
485
+ */
486
+ ticketKeys?: Buffer | undefined;
487
+ /**
488
+ *
489
+ * @param socket
490
+ * @param identity identity parameter sent from the client.
491
+ * @return pre-shared key that must either be
492
+ * a buffer or `null` to stop the negotiation process. Returned PSK must be
493
+ * compatible with the selected cipher's digest.
494
+ *
495
+ * When negotiating TLS-PSK (pre-shared keys), this function is called
496
+ * with the identity provided by the client.
497
+ * If the return value is `null` the negotiation process will stop and an
498
+ * "unknown_psk_identity" alert message will be sent to the other party.
499
+ * If the server wishes to hide the fact that the PSK identity was not known,
500
+ * the callback must provide some random data as `psk` to make the connection
501
+ * fail with "decrypt_error" before negotiation is finished.
502
+ * PSK ciphers are disabled by default, and using TLS-PSK thus
503
+ * requires explicitly specifying a cipher suite with the `ciphers` option.
504
+ * More information can be found in the RFC 4279.
505
+ */
506
+ pskCallback?(socket: TLSSocket, identity: string): DataView | NodeJS.TypedArray | null;
507
+ /**
508
+ * hint to send to a client to help
509
+ * with selecting the identity during TLS-PSK negotiation. Will be ignored
510
+ * in TLS 1.3. Upon failing to set pskIdentityHint `tlsClientError` will be
511
+ * emitted with `ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED` code.
512
+ */
513
+ pskIdentityHint?: string | undefined;
514
+ }
515
+ interface PSKCallbackNegotation {
516
+ psk: DataView | NodeJS.TypedArray;
517
+ identity: string;
518
+ }
519
+ interface ConnectionOptions extends SecureContextOptions, CommonConnectionOptions {
520
+ host?: string | undefined;
521
+ port?: number | undefined;
522
+ path?: string | undefined; // Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored.
523
+ socket?: stream.Duplex | undefined; // Establish secure connection on a given socket rather than creating a new socket
524
+ checkServerIdentity?: typeof checkServerIdentity | undefined;
525
+ servername?: string | undefined; // SNI TLS Extension
526
+ session?: Buffer | undefined;
527
+ minDHSize?: number | undefined;
528
+ lookup?: net.LookupFunction | undefined;
529
+ timeout?: number | undefined;
530
+ /**
531
+ * When negotiating TLS-PSK (pre-shared keys), this function is called
532
+ * with optional identity `hint` provided by the server or `null`
533
+ * in case of TLS 1.3 where `hint` was removed.
534
+ * It will be necessary to provide a custom `tls.checkServerIdentity()`
535
+ * for the connection as the default one will try to check hostname/IP
536
+ * of the server against the certificate but that's not applicable for PSK
537
+ * because there won't be a certificate present.
538
+ * More information can be found in the RFC 4279.
539
+ *
540
+ * @param hint message sent from the server to help client
541
+ * decide which identity to use during negotiation.
542
+ * Always `null` if TLS 1.3 is used.
543
+ * @returns Return `null` to stop the negotiation process. `psk` must be
544
+ * compatible with the selected cipher's digest.
545
+ * `identity` must use UTF-8 encoding.
546
+ */
547
+ pskCallback?(hint: string | null): PSKCallbackNegotation | null;
548
+ }
549
+ /**
550
+ * Accepts encrypted connections using TLS or SSL.
551
+ * @since v0.3.2
552
+ */
553
+ class Server extends net.Server {
554
+ constructor(secureConnectionListener?: (socket: TLSSocket) => void);
555
+ constructor(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void);
556
+ /**
557
+ * The `server.addContext()` method adds a secure context that will be used if
558
+ * the client request's SNI name matches the supplied `hostname` (or wildcard).
559
+ *
560
+ * When there are multiple matching contexts, the most recently added one is
561
+ * used.
562
+ * @since v0.5.3
563
+ * @param hostname A SNI host name or wildcard (e.g. `'*'`)
564
+ * @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc).
565
+ */
566
+ addContext(hostname: string, context: SecureContextOptions): void;
567
+ /**
568
+ * Returns the session ticket keys.
569
+ *
570
+ * See `Session Resumption` for more information.
571
+ * @since v3.0.0
572
+ * @return A 48-byte buffer containing the session ticket keys.
573
+ */
574
+ getTicketKeys(): Buffer;
575
+ /**
576
+ * The `server.setSecureContext()` method replaces the secure context of an
577
+ * existing server. Existing connections to the server are not interrupted.
578
+ * @since v11.0.0
579
+ * @param options An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc).
580
+ */
581
+ setSecureContext(options: SecureContextOptions): void;
582
+ /**
583
+ * Sets the session ticket keys.
584
+ *
585
+ * Changes to the ticket keys are effective only for future server connections.
586
+ * Existing or currently pending server connections will use the previous keys.
587
+ *
588
+ * See `Session Resumption` for more information.
589
+ * @since v3.0.0
590
+ * @param keys A 48-byte buffer containing the session ticket keys.
591
+ */
592
+ setTicketKeys(keys: Buffer): void;
593
+ /**
594
+ * events.EventEmitter
595
+ * 1. tlsClientError
596
+ * 2. newSession
597
+ * 3. OCSPRequest
598
+ * 4. resumeSession
599
+ * 5. secureConnection
600
+ * 6. keylog
601
+ */
602
+ addListener(event: string, listener: (...args: any[]) => void): this;
603
+ addListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
604
+ addListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this;
605
+ addListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
606
+ addListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
607
+ addListener(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
608
+ addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
609
+ emit(event: string | symbol, ...args: any[]): boolean;
610
+ emit(event: 'tlsClientError', err: Error, tlsSocket: TLSSocket): boolean;
611
+ emit(event: 'newSession', sessionId: Buffer, sessionData: Buffer, callback: () => void): boolean;
612
+ emit(event: 'OCSPRequest', certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void): boolean;
613
+ emit(event: 'resumeSession', sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void): boolean;
614
+ emit(event: 'secureConnection', tlsSocket: TLSSocket): boolean;
615
+ emit(event: 'keylog', line: Buffer, tlsSocket: TLSSocket): boolean;
616
+ on(event: string, listener: (...args: any[]) => void): this;
617
+ on(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
618
+ on(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this;
619
+ on(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
620
+ on(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
621
+ on(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
622
+ on(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
623
+ once(event: string, listener: (...args: any[]) => void): this;
624
+ once(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
625
+ once(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this;
626
+ once(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
627
+ once(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
628
+ once(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
629
+ once(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
630
+ prependListener(event: string, listener: (...args: any[]) => void): this;
631
+ prependListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
632
+ prependListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this;
633
+ prependListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
634
+ prependListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
635
+ prependListener(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
636
+ prependListener(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
637
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
638
+ prependOnceListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
639
+ prependOnceListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this;
640
+ prependOnceListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
641
+ prependOnceListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
642
+ prependOnceListener(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
643
+ prependOnceListener(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
644
+ }
645
+ /**
646
+ * @deprecated since v0.11.3 Use `tls.TLSSocket` instead.
647
+ */
648
+ interface SecurePair {
649
+ encrypted: TLSSocket;
650
+ cleartext: TLSSocket;
651
+ }
652
+ type SecureVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
653
+ interface SecureContextOptions {
654
+ /**
655
+ * Optionally override the trusted CA certificates. Default is to trust
656
+ * the well-known CAs curated by Mozilla. Mozilla's CAs are completely
657
+ * replaced when CAs are explicitly specified using this option.
658
+ */
659
+ ca?: string | Buffer | Array<string | Buffer> | undefined;
660
+ /**
661
+ * Cert chains in PEM format. One cert chain should be provided per
662
+ * private key. Each cert chain should consist of the PEM formatted
663
+ * certificate for a provided private key, followed by the PEM
664
+ * formatted intermediate certificates (if any), in order, and not
665
+ * including the root CA (the root CA must be pre-known to the peer,
666
+ * see ca). When providing multiple cert chains, they do not have to
667
+ * be in the same order as their private keys in key. If the
668
+ * intermediate certificates are not provided, the peer will not be
669
+ * able to validate the certificate, and the handshake will fail.
670
+ */
671
+ cert?: string | Buffer | Array<string | Buffer> | undefined;
672
+ /**
673
+ * Colon-separated list of supported signature algorithms. The list
674
+ * can contain digest algorithms (SHA256, MD5 etc.), public key
675
+ * algorithms (RSA-PSS, ECDSA etc.), combination of both (e.g
676
+ * 'RSA+SHA384') or TLS v1.3 scheme names (e.g. rsa_pss_pss_sha512).
677
+ */
678
+ sigalgs?: string | undefined;
679
+ /**
680
+ * Cipher suite specification, replacing the default. For more
681
+ * information, see modifying the default cipher suite. Permitted
682
+ * ciphers can be obtained via tls.getCiphers(). Cipher names must be
683
+ * uppercased in order for OpenSSL to accept them.
684
+ */
685
+ ciphers?: string | undefined;
686
+ /**
687
+ * Name of an OpenSSL engine which can provide the client certificate.
688
+ */
689
+ clientCertEngine?: string | undefined;
690
+ /**
691
+ * PEM formatted CRLs (Certificate Revocation Lists).
692
+ */
693
+ crl?: string | Buffer | Array<string | Buffer> | undefined;
694
+ /**
695
+ * Diffie Hellman parameters, required for Perfect Forward Secrecy. Use
696
+ * openssl dhparam to create the parameters. The key length must be
697
+ * greater than or equal to 1024 bits or else an error will be thrown.
698
+ * Although 1024 bits is permissible, use 2048 bits or larger for
699
+ * stronger security. If omitted or invalid, the parameters are
700
+ * silently discarded and DHE ciphers will not be available.
701
+ */
702
+ dhparam?: string | Buffer | undefined;
703
+ /**
704
+ * A string describing a named curve or a colon separated list of curve
705
+ * NIDs or names, for example P-521:P-384:P-256, to use for ECDH key
706
+ * agreement. Set to auto to select the curve automatically. Use
707
+ * crypto.getCurves() to obtain a list of available curve names. On
708
+ * recent releases, openssl ecparam -list_curves will also display the
709
+ * name and description of each available elliptic curve. Default:
710
+ * tls.DEFAULT_ECDH_CURVE.
711
+ */
712
+ ecdhCurve?: string | undefined;
713
+ /**
714
+ * Attempt to use the server's cipher suite preferences instead of the
715
+ * client's. When true, causes SSL_OP_CIPHER_SERVER_PREFERENCE to be
716
+ * set in secureOptions
717
+ */
718
+ honorCipherOrder?: boolean | undefined;
719
+ /**
720
+ * Private keys in PEM format. PEM allows the option of private keys
721
+ * being encrypted. Encrypted keys will be decrypted with
722
+ * options.passphrase. Multiple keys using different algorithms can be
723
+ * provided either as an array of unencrypted key strings or buffers,
724
+ * or an array of objects in the form {pem: <string|buffer>[,
725
+ * passphrase: <string>]}. The object form can only occur in an array.
726
+ * object.passphrase is optional. Encrypted keys will be decrypted with
727
+ * object.passphrase if provided, or options.passphrase if it is not.
728
+ */
729
+ key?: string | Buffer | Array<string | Buffer | KeyObject> | undefined;
730
+ /**
731
+ * Name of an OpenSSL engine to get private key from. Should be used
732
+ * together with privateKeyIdentifier.
733
+ */
734
+ privateKeyEngine?: string | undefined;
735
+ /**
736
+ * Identifier of a private key managed by an OpenSSL engine. Should be
737
+ * used together with privateKeyEngine. Should not be set together with
738
+ * key, because both options define a private key in different ways.
739
+ */
740
+ privateKeyIdentifier?: string | undefined;
741
+ /**
742
+ * Optionally set the maximum TLS version to allow. One
743
+ * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the
744
+ * `secureProtocol` option, use one or the other.
745
+ * **Default:** `'TLSv1.3'`, unless changed using CLI options. Using
746
+ * `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets the default to
747
+ * `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used.
748
+ */
749
+ maxVersion?: SecureVersion | undefined;
750
+ /**
751
+ * Optionally set the minimum TLS version to allow. One
752
+ * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the
753
+ * `secureProtocol` option, use one or the other. It is not recommended to use
754
+ * less than TLSv1.2, but it may be required for interoperability.
755
+ * **Default:** `'TLSv1.2'`, unless changed using CLI options. Using
756
+ * `--tls-v1.0` sets the default to `'TLSv1'`. Using `--tls-v1.1` sets the default to
757
+ * `'TLSv1.1'`. Using `--tls-min-v1.3` sets the default to
758
+ * 'TLSv1.3'. If multiple of the options are provided, the lowest minimum is used.
759
+ */
760
+ minVersion?: SecureVersion | undefined;
761
+ /**
762
+ * Shared passphrase used for a single private key and/or a PFX.
763
+ */
764
+ passphrase?: string | undefined;
765
+ /**
766
+ * PFX or PKCS12 encoded private key and certificate chain. pfx is an
767
+ * alternative to providing key and cert individually. PFX is usually
768
+ * encrypted, if it is, passphrase will be used to decrypt it. Multiple
769
+ * PFX can be provided either as an array of unencrypted PFX buffers,
770
+ * or an array of objects in the form {buf: <string|buffer>[,
771
+ * passphrase: <string>]}. The object form can only occur in an array.
772
+ * object.passphrase is optional. Encrypted PFX will be decrypted with
773
+ * object.passphrase if provided, or options.passphrase if it is not.
774
+ */
775
+ pfx?: string | Buffer | Array<string | Buffer | PxfObject> | undefined;
776
+ /**
777
+ * Optionally affect the OpenSSL protocol behavior, which is not
778
+ * usually necessary. This should be used carefully if at all! Value is
779
+ * a numeric bitmask of the SSL_OP_* options from OpenSSL Options
780
+ */
781
+ secureOptions?: number | undefined; // Value is a numeric bitmask of the `SSL_OP_*` options
782
+ /**
783
+ * Legacy mechanism to select the TLS protocol version to use, it does
784
+ * not support independent control of the minimum and maximum version,
785
+ * and does not support limiting the protocol to TLSv1.3. Use
786
+ * minVersion and maxVersion instead. The possible values are listed as
787
+ * SSL_METHODS, use the function names as strings. For example, use
788
+ * 'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method' to allow
789
+ * any TLS protocol version up to TLSv1.3. It is not recommended to use
790
+ * TLS versions less than 1.2, but it may be required for
791
+ * interoperability. Default: none, see minVersion.
792
+ */
793
+ secureProtocol?: string | undefined;
794
+ /**
795
+ * Opaque identifier used by servers to ensure session state is not
796
+ * shared between applications. Unused by clients.
797
+ */
798
+ sessionIdContext?: string | undefined;
799
+ /**
800
+ * 48-bytes of cryptographically strong pseudo-random data.
801
+ * See Session Resumption for more information.
802
+ */
803
+ ticketKeys?: Buffer | undefined;
804
+ /**
805
+ * The number of seconds after which a TLS session created by the
806
+ * server will no longer be resumable. See Session Resumption for more
807
+ * information. Default: 300.
808
+ */
809
+ sessionTimeout?: number | undefined;
810
+ }
811
+ interface SecureContext {
812
+ context: any;
813
+ }
814
+ /**
815
+ * Verifies the certificate `cert` is issued to `hostname`.
816
+ *
817
+ * Returns [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, populating it with `reason`, `host`, and `cert` on
818
+ * failure. On success, returns [undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type).
819
+ *
820
+ * This function is intended to be used in combination with the`checkServerIdentity` option that can be passed to {@link connect} and as
821
+ * such operates on a `certificate object`. For other purposes, consider using `x509.checkHost()` instead.
822
+ *
823
+ * This function can be overwritten by providing an alternative function as the`options.checkServerIdentity` option that is passed to `tls.connect()`. The
824
+ * overwriting function can call `tls.checkServerIdentity()` of course, to augment
825
+ * the checks done with additional verification.
826
+ *
827
+ * This function is only called if the certificate passed all other checks, such as
828
+ * being issued by trusted CA (`options.ca`).
829
+ *
830
+ * Earlier versions of Node.js incorrectly accepted certificates for a given`hostname` if a matching `uniformResourceIdentifier` subject alternative name
831
+ * 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
832
+ * a custom`options.checkServerIdentity` function that implements the desired behavior.
833
+ * @since v0.8.4
834
+ * @param hostname The host name or IP address to verify the certificate against.
835
+ * @param cert A `certificate object` representing the peer's certificate.
836
+ */
837
+ function checkServerIdentity(hostname: string, cert: PeerCertificate): Error | undefined;
838
+ /**
839
+ * Creates a new {@link Server}. The `secureConnectionListener`, if provided, is
840
+ * automatically set as a listener for the `'secureConnection'` event.
841
+ *
842
+ * The `ticketKeys` options is automatically shared between `cluster` module
843
+ * workers.
844
+ *
845
+ * The following illustrates a simple echo server:
846
+ *
847
+ * ```js
848
+ * const tls = require('tls');
849
+ * const fs = require('fs');
850
+ *
851
+ * const options = {
852
+ * key: fs.readFileSync('server-key.pem'),
853
+ * cert: fs.readFileSync('server-cert.pem'),
854
+ *
855
+ * // This is necessary only if using client certificate authentication.
856
+ * requestCert: true,
857
+ *
858
+ * // This is necessary only if the client uses a self-signed certificate.
859
+ * ca: [ fs.readFileSync('client-cert.pem') ]
860
+ * };
861
+ *
862
+ * const server = tls.createServer(options, (socket) => {
863
+ * console.log('server connected',
864
+ * socket.authorized ? 'authorized' : 'unauthorized');
865
+ * socket.write('welcome!\n');
866
+ * socket.setEncoding('utf8');
867
+ * socket.pipe(socket);
868
+ * });
869
+ * server.listen(8000, () => {
870
+ * console.log('server bound');
871
+ * });
872
+ * ```
873
+ *
874
+ * The server can be tested by connecting to it using the example client from {@link connect}.
875
+ * @since v0.3.2
876
+ */
877
+ function createServer(secureConnectionListener?: (socket: TLSSocket) => void): Server;
878
+ function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server;
879
+ /**
880
+ * The `callback` function, if specified, will be added as a listener for the `'secureConnect'` event.
881
+ *
882
+ * `tls.connect()` returns a {@link TLSSocket} object.
883
+ *
884
+ * Unlike the `https` API, `tls.connect()` does not enable the
885
+ * SNI (Server Name Indication) extension by default, which may cause some
886
+ * servers to return an incorrect certificate or reject the connection
887
+ * altogether. To enable SNI, set the `servername` option in addition
888
+ * to `host`.
889
+ *
890
+ * The following illustrates a client for the echo server example from {@link createServer}:
891
+ *
892
+ * ```js
893
+ * // Assumes an echo server that is listening on port 8000.
894
+ * const tls = require('tls');
895
+ * const fs = require('fs');
896
+ *
897
+ * const options = {
898
+ * // Necessary only if the server requires client certificate authentication.
899
+ * key: fs.readFileSync('client-key.pem'),
900
+ * cert: fs.readFileSync('client-cert.pem'),
901
+ *
902
+ * // Necessary only if the server uses a self-signed certificate.
903
+ * ca: [ fs.readFileSync('server-cert.pem') ],
904
+ *
905
+ * // Necessary only if the server's cert isn't for "localhost".
906
+ * checkServerIdentity: () => { return null; },
907
+ * };
908
+ *
909
+ * const socket = tls.connect(8000, options, () => {
910
+ * console.log('client connected',
911
+ * socket.authorized ? 'authorized' : 'unauthorized');
912
+ * process.stdin.pipe(socket);
913
+ * process.stdin.resume();
914
+ * });
915
+ * socket.setEncoding('utf8');
916
+ * socket.on('data', (data) => {
917
+ * console.log(data);
918
+ * });
919
+ * socket.on('end', () => {
920
+ * console.log('server ends connection');
921
+ * });
922
+ * ```
923
+ * @since v0.11.3
924
+ */
925
+ function connect(options: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
926
+ function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
927
+ function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
928
+ /**
929
+ * Creates a new secure pair object with two streams, one of which reads and writes
930
+ * the encrypted data and the other of which reads and writes the cleartext data.
931
+ * Generally, the encrypted stream is piped to/from an incoming encrypted data
932
+ * stream and the cleartext one is used as a replacement for the initial encrypted
933
+ * stream.
934
+ *
935
+ * `tls.createSecurePair()` returns a `tls.SecurePair` object with `cleartext` and`encrypted` stream properties.
936
+ *
937
+ * Using `cleartext` has the same API as {@link TLSSocket}.
938
+ *
939
+ * The `tls.createSecurePair()` method is now deprecated in favor of`tls.TLSSocket()`. For example, the code:
940
+ *
941
+ * ```js
942
+ * pair = tls.createSecurePair(// ... );
943
+ * pair.encrypted.pipe(socket);
944
+ * socket.pipe(pair.encrypted);
945
+ * ```
946
+ *
947
+ * can be replaced by:
948
+ *
949
+ * ```js
950
+ * secureSocket = tls.TLSSocket(socket, options);
951
+ * ```
952
+ *
953
+ * where `secureSocket` has the same API as `pair.cleartext`.
954
+ * @since v0.3.2
955
+ * @deprecated Since v0.11.3 - Use {@link TLSSocket} instead.
956
+ * @param context A secure context object as returned by `tls.createSecureContext()`
957
+ * @param isServer `true` to specify that this TLS connection should be opened as a server.
958
+ * @param requestCert `true` to specify whether a server should request a certificate from a connecting client. Only applies when `isServer` is `true`.
959
+ * @param rejectUnauthorized If not `false` a server automatically reject clients with invalid certificates. Only applies when `isServer` is `true`.
960
+ */
961
+ function createSecurePair(context?: SecureContext, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
962
+ /**
963
+ * {@link createServer} sets the default value of the `honorCipherOrder` option
964
+ * to `true`, other APIs that create secure contexts leave it unset.
965
+ *
966
+ * {@link createServer} uses a 128 bit truncated SHA1 hash value generated
967
+ * from `process.argv` as the default value of the `sessionIdContext` option, other
968
+ * APIs that create secure contexts have no default value.
969
+ *
970
+ * The `tls.createSecureContext()` method creates a `SecureContext` object. It is
971
+ * usable as an argument to several `tls` APIs, such as {@link createServer} and `server.addContext()`, but has no public methods.
972
+ *
973
+ * A key is _required_ for ciphers that use certificates. Either `key` or`pfx` can be used to provide it.
974
+ *
975
+ * If the `ca` option is not given, then Node.js will default to using [Mozilla's publicly trusted list of
976
+ * CAs](https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt).
977
+ * @since v0.11.13
978
+ */
979
+ function createSecureContext(options?: SecureContextOptions): SecureContext;
980
+ /**
981
+ * Returns an array with the names of the supported TLS ciphers. The names are
982
+ * lower-case for historical reasons, but must be uppercased to be used in
983
+ * the `ciphers` option of {@link createSecureContext}.
984
+ *
985
+ * Not all supported ciphers are enabled by default. See `Modifying the default TLS cipher suite`.
986
+ *
987
+ * Cipher names that start with `'tls_'` are for TLSv1.3, all the others are for
988
+ * TLSv1.2 and below.
989
+ *
990
+ * ```js
991
+ * console.log(tls.getCiphers()); // ['aes128-gcm-sha256', 'aes128-sha', ...]
992
+ * ```
993
+ * @since v0.10.2
994
+ */
995
+ function getCiphers(): string[];
996
+ /**
997
+ * The default curve name to use for ECDH key agreement in a tls server.
998
+ * The default value is 'auto'. See tls.createSecureContext() for further
999
+ * information.
1000
+ */
1001
+ let DEFAULT_ECDH_CURVE: string;
1002
+ /**
1003
+ * The default value of the maxVersion option of
1004
+ * tls.createSecureContext(). It can be assigned any of the supported TLS
1005
+ * protocol versions, 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default:
1006
+ * 'TLSv1.3', unless changed using CLI options. Using --tls-max-v1.2 sets
1007
+ * the default to 'TLSv1.2'. Using --tls-max-v1.3 sets the default to
1008
+ * 'TLSv1.3'. If multiple of the options are provided, the highest maximum
1009
+ * is used.
1010
+ */
1011
+ let DEFAULT_MAX_VERSION: SecureVersion;
1012
+ /**
1013
+ * The default value of the minVersion option of tls.createSecureContext().
1014
+ * It can be assigned any of the supported TLS protocol versions,
1015
+ * 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default: 'TLSv1.2', unless
1016
+ * changed using CLI options. Using --tls-min-v1.0 sets the default to
1017
+ * 'TLSv1'. Using --tls-min-v1.1 sets the default to 'TLSv1.1'. Using
1018
+ * --tls-min-v1.3 sets the default to 'TLSv1.3'. If multiple of the options
1019
+ * are provided, the lowest minimum is used.
1020
+ */
1021
+ let DEFAULT_MIN_VERSION: SecureVersion;
1022
+ /**
1023
+ * An immutable array of strings representing the root certificates (in PEM
1024
+ * format) used for verifying peer certificates. This is the default value
1025
+ * of the ca option to tls.createSecureContext().
1026
+ */
1027
+ const rootCertificates: ReadonlyArray<string>;
1028
+ }
1029
+ declare module 'node:tls' {
1030
+ export * from 'tls';
1031
+ }