@node-red/editor-client 3.0.2 → 3.1.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 (127) hide show
  1. package/locales/de/editor.json +2 -0
  2. package/locales/de/infotips.json +0 -0
  3. package/locales/de/jsonata.json +0 -0
  4. package/locales/en-US/editor.json +37 -6
  5. package/locales/en-US/infotips.json +0 -0
  6. package/locales/en-US/jsonata.json +0 -0
  7. package/locales/fr/editor.json +1238 -0
  8. package/locales/fr/infotips.json +23 -0
  9. package/locales/fr/jsonata.json +274 -0
  10. package/locales/ja/editor.json +48 -9
  11. package/locales/ko/editor.json +233 -31
  12. package/locales/ko/infotips.json +0 -0
  13. package/locales/ko/jsonata.json +0 -0
  14. package/locales/pt-BR/editor.json +1208 -0
  15. package/locales/pt-BR/infotips.json +23 -0
  16. package/locales/pt-BR/jsonata.json +274 -0
  17. package/locales/ru/editor.json +2 -0
  18. package/locales/ru/infotips.json +0 -0
  19. package/locales/ru/jsonata.json +0 -0
  20. package/locales/zh-CN/editor.json +1175 -1049
  21. package/locales/zh-TW/editor.json +3 -0
  22. package/package.json +1 -1
  23. package/public/red/about +140 -0
  24. package/public/red/red.js +2699 -1397
  25. package/public/red/red.min.js +4 -3
  26. package/public/red/style.min.css +1 -1
  27. package/public/red/tours/3.0/images/context-menu.png +0 -0
  28. package/public/red/tours/3.0/welcome.js +155 -0
  29. package/public/red/tours/images/context-menu.png +0 -0
  30. package/public/red/tours/images/global-env-vars.png +0 -0
  31. package/public/red/tours/images/hiding-flows.png +0 -0
  32. package/public/red/tours/images/locking-flows.png +0 -0
  33. package/public/red/tours/images/mermaid.png +0 -0
  34. package/public/red/tours/images/node-help.png +0 -0
  35. package/public/red/tours/images/tab-changes.png +0 -0
  36. package/public/red/tours/welcome.js +111 -94
  37. package/public/types/node/assert/strict.d.ts +11 -0
  38. package/public/types/node/assert.d.ts +898 -64
  39. package/public/types/node/async_hooks.d.ts +362 -94
  40. package/public/types/node/buffer.d.ts +2158 -14
  41. package/public/types/node/child_process.d.ts +1109 -257
  42. package/public/types/node/cluster.d.ts +349 -200
  43. package/public/types/node/console.d.ts +313 -43
  44. package/public/types/node/crypto.d.ts +3329 -656
  45. package/public/types/node/dgram.d.ts +459 -58
  46. package/public/types/node/diagnostics_channel.d.ts +155 -0
  47. package/public/types/node/dns/promises.d.ts +371 -0
  48. package/public/types/node/dns.d.ts +532 -265
  49. package/public/types/node/domain.d.ts +159 -16
  50. package/public/types/node/events.d.ts +589 -30
  51. package/public/types/node/fs/promises.d.ts +1097 -0
  52. package/public/types/node/fs.d.ts +2484 -958
  53. package/public/types/node/globals.d.ts +43 -503
  54. package/public/types/node/http.d.ts +1156 -145
  55. package/public/types/node/http2.d.ts +1610 -470
  56. package/public/types/node/https.d.ts +462 -72
  57. package/public/types/node/module.d.ts +72 -13
  58. package/public/types/node/net.d.ts +663 -131
  59. package/public/types/node/os.d.ts +238 -25
  60. package/public/types/node/path.d.ts +57 -23
  61. package/public/types/node/perf_hooks.d.ts +424 -112
  62. package/public/types/node/process.d.ts +1261 -193
  63. package/public/types/node/querystring.d.ts +107 -7
  64. package/public/types/node/readline.d.ts +443 -74
  65. package/public/types/node/stream/consumers.d.ts +15 -0
  66. package/public/types/node/stream/promises.d.ts +45 -0
  67. package/public/types/node/stream/web.d.ts +395 -0
  68. package/public/types/node/stream.d.ts +1081 -177
  69. package/public/types/node/string_decoder.d.ts +57 -0
  70. package/public/types/node/test.d.ts +193 -0
  71. package/public/types/node/timers/promises.d.ts +96 -0
  72. package/public/types/node/timers.d.ts +87 -12
  73. package/public/types/node/tls.d.ts +457 -222
  74. package/public/types/node/trace_events.d.ts +107 -10
  75. package/public/types/node/tty.d.ts +158 -23
  76. package/public/types/node/url.d.ts +734 -28
  77. package/public/types/node/util.d.ts +1542 -164
  78. package/public/types/node/v8.d.ts +261 -73
  79. package/public/types/node/vm.d.ts +384 -32
  80. package/public/types/node/wasi.d.ts +92 -23
  81. package/public/types/node/worker_threads.d.ts +531 -123
  82. package/public/types/node/zlib.d.ts +216 -63
  83. package/public/types/node-red/func.d.ts +3 -0
  84. package/public/vendor/jquery/css/base/images/ui-icons_444444_256x240.png +0 -0
  85. package/public/vendor/jquery/css/base/images/ui-icons_555555_256x240.png +0 -0
  86. package/public/vendor/jquery/css/base/images/ui-icons_777620_256x240.png +0 -0
  87. package/public/vendor/jquery/css/base/images/ui-icons_777777_256x240.png +0 -0
  88. package/public/vendor/jquery/css/base/images/ui-icons_cc0000_256x240.png +0 -0
  89. package/public/vendor/jquery/css/base/images/ui-icons_ffffff_256x240.png +0 -0
  90. package/public/vendor/jquery/css/base/jquery-ui.min.css +4 -4
  91. package/public/vendor/mermaid/mermaid.min.js +1284 -0
  92. package/public/vendor/monaco/dist/{ade705761eb7e702770d.ttf → 7064e66c3890a12c47b4.ttf} +0 -0
  93. package/public/vendor/monaco/dist/css.worker.js +1 -1
  94. package/public/vendor/monaco/dist/css.worker.js.LICENSE.txt +1 -1
  95. package/public/vendor/monaco/dist/editor.js +1 -1
  96. package/public/vendor/monaco/dist/editor.js.LICENSE.txt +5 -1
  97. package/public/vendor/monaco/dist/editor.worker.js +1 -1
  98. package/public/vendor/monaco/dist/html.worker.js +1 -1
  99. package/public/vendor/monaco/dist/html.worker.js.LICENSE.txt +1 -1
  100. package/public/vendor/monaco/dist/json.worker.js +1 -1
  101. package/public/vendor/monaco/dist/json.worker.js.LICENSE.txt +1 -1
  102. package/public/vendor/monaco/dist/locale/cs.js +319 -71
  103. package/public/vendor/monaco/dist/locale/de.js +323 -75
  104. package/public/vendor/monaco/dist/locale/es.js +318 -70
  105. package/public/vendor/monaco/dist/locale/fr.js +327 -79
  106. package/public/vendor/monaco/dist/locale/it.js +325 -77
  107. package/public/vendor/monaco/dist/locale/ja.js +337 -89
  108. package/public/vendor/monaco/dist/locale/ko.js +324 -76
  109. package/public/vendor/monaco/dist/locale/pl.js +322 -74
  110. package/public/vendor/monaco/dist/locale/pt-br.js +321 -73
  111. package/public/vendor/monaco/dist/locale/qps-ploc.js +1580 -1332
  112. package/public/vendor/monaco/dist/locale/ru.js +324 -76
  113. package/public/vendor/monaco/dist/locale/tr.js +326 -78
  114. package/public/vendor/monaco/dist/locale/zh-hans.js +328 -80
  115. package/public/vendor/monaco/dist/locale/zh-hant.js +321 -73
  116. package/public/vendor/monaco/dist/theme/forge.json +236 -0
  117. package/public/vendor/monaco/dist/theme/github-dark.json +348 -0
  118. package/public/vendor/monaco/dist/theme/github-light.json +348 -0
  119. package/public/vendor/monaco/dist/theme/nord.json +93 -0
  120. package/public/vendor/monaco/dist/ts.worker.js +1 -1
  121. package/public/vendor/monaco/dist/ts.worker.js.LICENSE.txt +14 -6
  122. package/public/vendor/vendor.js +9 -15
  123. /package/public/red/tours/{images → 3.0/images}/continuous-search.png +0 -0
  124. /package/public/red/tours/{images → 3.0/images}/debug-path-tooltip.png +0 -0
  125. /package/public/red/tours/{images → 3.0/images}/junction-quick-add.png +0 -0
  126. /package/public/red/tours/{images → 3.0/images}/junction-slice.gif +0 -0
  127. /package/public/red/tours/{images → 3.0/images}/split-wire-with-links.gif +0 -0
@@ -1,13 +1,21 @@
1
1
 
2
2
  /* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
3
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/v16.9.0/lib/tls.js)
13
+ */
4
14
  declare module 'tls' {
5
- import * as net from 'net';
6
- import * as stream from 'stream';
7
-
15
+ import { X509Certificate } from 'node:crypto';
16
+ import * as net from 'node:net';
8
17
  const CLIENT_RENEG_LIMIT: number;
9
18
  const CLIENT_RENEG_WINDOW: number;
10
-
11
19
  interface Certificate {
12
20
  /**
13
21
  * Country code.
@@ -34,7 +42,6 @@ declare module 'tls' {
34
42
  */
35
43
  CN: string;
36
44
  }
37
-
38
45
  interface PeerCertificate {
39
46
  subject: Certificate;
40
47
  issuer: Certificate;
@@ -50,11 +57,9 @@ declare module 'tls' {
50
57
  serialNumber: string;
51
58
  raw: Buffer;
52
59
  }
53
-
54
60
  interface DetailedPeerCertificate extends PeerCertificate {
55
61
  issuerCertificate: DetailedPeerCertificate;
56
62
  }
57
-
58
63
  interface CipherNameAndProtocol {
59
64
  /**
60
65
  * The cipher name.
@@ -64,13 +69,11 @@ declare module 'tls' {
64
69
  * SSL/TLS protocol version.
65
70
  */
66
71
  version: string;
67
-
68
72
  /**
69
73
  * IETF name for the cipher suite.
70
74
  */
71
75
  standardName: string;
72
76
  }
73
-
74
77
  interface EphemeralKeyInfo {
75
78
  /**
76
79
  * The supported types are 'DH' and 'ECDH'.
@@ -85,7 +88,6 @@ declare module 'tls' {
85
88
  */
86
89
  size: number;
87
90
  }
88
-
89
91
  interface KeyObject {
90
92
  /**
91
93
  * Private keys in PEM format.
@@ -96,7 +98,6 @@ declare module 'tls' {
96
98
  */
97
99
  passphrase?: string | undefined;
98
100
  }
99
-
100
101
  interface PxfObject {
101
102
  /**
102
103
  * PFX or PKCS12 encoded private key and certificate chain.
@@ -107,7 +108,6 @@ declare module 'tls' {
107
108
  */
108
109
  passphrase?: string | undefined;
109
110
  }
110
-
111
111
  interface TLSSocketOptions extends SecureContextOptions, CommonConnectionOptions {
112
112
  /**
113
113
  * If true the TLS socket will be instantiated in server-mode.
@@ -118,7 +118,6 @@ declare module 'tls' {
118
118
  * An optional net.Server instance.
119
119
  */
120
120
  server?: net.Server | undefined;
121
-
122
121
  /**
123
122
  * An optional Buffer instance containing a TLS session.
124
123
  */
@@ -130,227 +129,307 @@ declare module 'tls' {
130
129
  */
131
130
  requestOCSP?: boolean | undefined;
132
131
  }
133
-
132
+ /**
133
+ * Performs transparent encryption of written data and all required TLS
134
+ * negotiation.
135
+ *
136
+ * Instances of `tls.TLSSocket` implement the duplex `Stream` interface.
137
+ *
138
+ * Methods that return TLS connection metadata (e.g.{@link TLSSocket.getPeerCertificate} will only return data while the
139
+ * connection is open.
140
+ * @since v0.11.4
141
+ */
134
142
  class TLSSocket extends net.Socket {
135
143
  /**
136
144
  * Construct a new tls.TLSSocket object from an existing TCP socket.
137
145
  */
138
146
  constructor(socket: net.Socket, options?: TLSSocketOptions);
139
-
140
147
  /**
141
- * A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false.
148
+ * Returns `true` if the peer certificate was signed by one of the CAs specified
149
+ * when creating the `tls.TLSSocket` instance, otherwise `false`.
150
+ * @since v0.11.4
142
151
  */
143
152
  authorized: boolean;
144
153
  /**
145
- * The reason why the peer's certificate has not been verified.
146
- * This property becomes available only when tlsSocket.authorized === false.
154
+ * Returns the reason why the peer's certificate was not been verified. This
155
+ * property is set only when `tlsSocket.authorized === false`.
156
+ * @since v0.11.4
147
157
  */
148
158
  authorizationError: Error;
149
159
  /**
150
- * Static boolean value, always true.
151
- * May be used to distinguish TLS sockets from regular ones.
160
+ * Always returns `true`. This may be used to distinguish TLS sockets from regular`net.Socket` instances.
161
+ * @since v0.11.4
152
162
  */
153
- encrypted: boolean;
154
-
163
+ encrypted: true;
155
164
  /**
156
165
  * String containing the selected ALPN protocol.
157
166
  * Before a handshake has completed, this value is always null.
158
167
  * When a handshake is completed but not ALPN protocol was selected, tlsSocket.alpnProtocol equals false.
159
168
  */
160
169
  alpnProtocol: string | false | null;
161
-
162
170
  /**
163
- * Returns an object representing the local certificate. The returned
164
- * object has some properties corresponding to the fields of the
165
- * certificate.
171
+ * Returns an object representing the local certificate. The returned object has
172
+ * some properties corresponding to the fields of the certificate.
166
173
  *
167
- * See tls.TLSSocket.getPeerCertificate() for an example of the
168
- * certificate structure.
174
+ * See {@link TLSSocket.getPeerCertificate} for an example of the certificate
175
+ * structure.
169
176
  *
170
- * If there is no local certificate, an empty object will be returned.
171
- * If the socket has been destroyed, null will be returned.
177
+ * If there is no local certificate, an empty object will be returned. If the
178
+ * socket has been destroyed, `null` will be returned.
179
+ * @since v11.2.0
172
180
  */
173
181
  getCertificate(): PeerCertificate | object | null;
174
182
  /**
175
- * Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.
176
- * @returns Returns an object representing the cipher name
177
- * and the SSL/TLS protocol version of the current connection.
183
+ * Returns an object containing information on the negotiated cipher suite.
184
+ *
185
+ * For example:
186
+ *
187
+ * ```json
188
+ * {
189
+ * "name": "AES128-SHA256",
190
+ * "standardName": "TLS_RSA_WITH_AES_128_CBC_SHA256",
191
+ * "version": "TLSv1.2"
192
+ * }
193
+ * ```
194
+ *
195
+ * See [SSL\_CIPHER\_get\_name](https://www.openssl.org/docs/man1.1.1/man3/SSL_CIPHER_get_name.html) for more information.
196
+ * @since v0.11.4
178
197
  */
179
198
  getCipher(): CipherNameAndProtocol;
180
199
  /**
181
- * Returns an object representing the type, name, and size of parameter
182
- * of an ephemeral key exchange in Perfect Forward Secrecy on a client
200
+ * Returns an object representing the type, name, and size of parameter of
201
+ * an ephemeral key exchange in `perfect forward secrecy` on a client
183
202
  * connection. It returns an empty object when the key exchange is not
184
- * ephemeral. As this is only supported on a client socket; null is
185
- * returned if called on a server socket. The supported types are 'DH'
186
- * and 'ECDH'. The name property is available only when type is 'ECDH'.
203
+ * ephemeral. As this is only supported on a client socket; `null` is returned
204
+ * if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The`name` property is available only when type is `'ECDH'`.
187
205
  *
188
- * For example: { type: 'ECDH', name: 'prime256v1', size: 256 }.
206
+ * For example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }`.
207
+ * @since v5.0.0
189
208
  */
190
209
  getEphemeralKeyInfo(): EphemeralKeyInfo | object | null;
191
210
  /**
192
- * Returns the latest Finished message that has
193
- * been sent to the socket as part of a SSL/TLS handshake, or undefined
194
- * if no Finished message has been sent yet.
195
- *
196
- * As the Finished messages are message digests of the complete
197
- * handshake (with a total of 192 bits for TLS 1.0 and more for SSL
198
- * 3.0), they can be used for external authentication procedures when
199
- * the authentication provided by SSL/TLS is not desired or is not
200
- * enough.
211
+ * As the `Finished` messages are message digests of the complete handshake
212
+ * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can
213
+ * be used for external authentication procedures when the authentication
214
+ * provided by SSL/TLS is not desired or is not enough.
201
215
  *
202
- * Corresponds to the SSL_get_finished routine in OpenSSL and may be
203
- * used to implement the tls-unique channel binding from RFC 5929.
216
+ * Corresponds to the `SSL_get_finished` routine in OpenSSL and may be used
217
+ * to implement the `tls-unique` channel binding from [RFC 5929](https://tools.ietf.org/html/rfc5929).
218
+ * @since v9.9.0
219
+ * @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.
204
220
  */
205
221
  getFinished(): Buffer | undefined;
206
222
  /**
207
- * Returns an object representing the peer's certificate.
208
- * The returned object has some properties corresponding to the field of the certificate.
209
- * If detailed argument is true the full chain with issuer property will be returned,
210
- * if false only the top certificate without issuer property.
211
- * If the peer does not provide a certificate, it returns null or an empty object.
212
- * @param detailed - If true; the full chain with issuer property will be returned.
213
- * @returns An object representing the peer's certificate.
223
+ * Returns an object representing the peer's certificate. If the peer does not
224
+ * provide a certificate, an empty object will be returned. If the socket has been
225
+ * destroyed, `null` will be returned.
226
+ *
227
+ * If the full certificate chain was requested, each certificate will include an`issuerCertificate` property containing an object representing its issuer's
228
+ * certificate.
229
+ * @since v0.11.4
230
+ * @param detailed Include the full certificate chain if `true`, otherwise include just the peer's certificate.
231
+ * @return A certificate object.
214
232
  */
215
233
  getPeerCertificate(detailed: true): DetailedPeerCertificate;
216
234
  getPeerCertificate(detailed?: false): PeerCertificate;
217
235
  getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate;
218
236
  /**
219
- * Returns the latest Finished message that is expected or has actually
220
- * been received from the socket as part of a SSL/TLS handshake, or
221
- * undefined if there is no Finished message so far.
237
+ * As the `Finished` messages are message digests of the complete handshake
238
+ * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can
239
+ * be used for external authentication procedures when the authentication
240
+ * provided by SSL/TLS is not desired or is not enough.
222
241
  *
223
- * As the Finished messages are message digests of the complete
224
- * handshake (with a total of 192 bits for TLS 1.0 and more for SSL
225
- * 3.0), they can be used for external authentication procedures when
226
- * the authentication provided by SSL/TLS is not desired or is not
227
- * enough.
228
- *
229
- * Corresponds to the SSL_get_peer_finished routine in OpenSSL and may
230
- * be used to implement the tls-unique channel binding from RFC 5929.
242
+ * Corresponds to the `SSL_get_peer_finished` routine in OpenSSL and may be used
243
+ * to implement the `tls-unique` channel binding from [RFC 5929](https://tools.ietf.org/html/rfc5929).
244
+ * @since v9.9.0
245
+ * @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
246
+ * far.
231
247
  */
232
248
  getPeerFinished(): Buffer | undefined;
233
249
  /**
234
- * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
235
- * The value `'unknown'` will be returned for connected sockets that have not completed the handshaking process.
236
- * The value `null` will be returned for server sockets or disconnected client sockets.
237
- * See https://www.openssl.org/docs/man1.0.2/ssl/SSL_get_version.html for more information.
238
- * @returns negotiated SSL/TLS protocol version of the current connection
250
+ * Returns a string containing the negotiated SSL/TLS protocol version of the
251
+ * current connection. The value `'unknown'` will be returned for connected
252
+ * sockets that have not completed the handshaking process. The value `null` will
253
+ * be returned for server sockets or disconnected client sockets.
254
+ *
255
+ * Protocol versions are:
256
+ *
257
+ * * `'SSLv3'`
258
+ * * `'TLSv1'`
259
+ * * `'TLSv1.1'`
260
+ * * `'TLSv1.2'`
261
+ * * `'TLSv1.3'`
262
+ *
263
+ * See the OpenSSL [`SSL_get_version`](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_version.html) documentation for more information.
264
+ * @since v5.7.0
239
265
  */
240
266
  getProtocol(): string | null;
241
267
  /**
242
- * Could be used to speed up handshake establishment when reconnecting to the server.
243
- * @returns ASN.1 encoded TLS session or undefined if none was negotiated.
268
+ * Returns the TLS session data or `undefined` if no session was
269
+ * 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
270
+ * for debugging.
271
+ *
272
+ * See `Session Resumption` for more information.
273
+ *
274
+ * Note: `getSession()` works only for TLSv1.2 and below. For TLSv1.3, applications
275
+ * must use the `'session'` event (it also works for TLSv1.2 and below).
276
+ * @since v0.11.4
244
277
  */
245
278
  getSession(): Buffer | undefined;
246
279
  /**
247
- * Returns a list of signature algorithms shared between the server and
248
- * the client in the order of decreasing preference.
280
+ * See [SSL\_get\_shared\_sigalgs](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html) for more information.
281
+ * @since v12.11.0
282
+ * @return List of signature algorithms shared between the server and the client in the order of decreasing preference.
249
283
  */
250
284
  getSharedSigalgs(): string[];
251
285
  /**
252
- * NOTE: Works only with client TLS sockets.
253
- * Useful only for debugging, for session reuse provide session option to tls.connect().
254
- * @returns TLS session ticket or undefined if none was negotiated.
286
+ * For a client, returns the TLS session ticket if one is available, or`undefined`. For a server, always returns `undefined`.
287
+ *
288
+ * It may be useful for debugging.
289
+ *
290
+ * See `Session Resumption` for more information.
291
+ * @since v0.11.4
255
292
  */
256
293
  getTLSTicket(): Buffer | undefined;
257
294
  /**
258
- * Returns true if the session was reused, false otherwise.
295
+ * See `Session Resumption` for more information.
296
+ * @since v0.5.6
297
+ * @return `true` if the session was reused, `false` otherwise.
259
298
  */
260
299
  isSessionReused(): boolean;
261
300
  /**
262
- * Initiate TLS renegotiation process.
301
+ * The `tlsSocket.renegotiate()` method initiates a TLS renegotiation process.
302
+ * Upon completion, the `callback` function will be passed a single argument
303
+ * that is either an `Error` (if the request failed) or `null`.
263
304
  *
264
- * NOTE: Can be used to request peer's certificate after the secure connection has been established.
265
- * ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout.
266
- * @param options - The options may contain the following fields: rejectUnauthorized,
267
- * requestCert (See tls.createServer() for details).
268
- * @param callback - callback(err) will be executed with null as err, once the renegotiation
269
- * is successfully completed.
270
- * @return `undefined` when socket is destroy, `false` if negotiaion can't be initiated.
271
- */
272
- renegotiate(options: { rejectUnauthorized?: boolean | undefined, requestCert?: boolean | undefined }, callback: (err: Error | null) => void): undefined | boolean;
273
- /**
274
- * Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512).
275
- * Smaller fragment size decreases buffering latency on the client: large fragments are buffered by
276
- * the TLS layer until the entire fragment is received and its integrity is verified;
277
- * large fragments can span multiple roundtrips, and their processing can be delayed due to packet
278
- * loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead,
279
- * which may decrease overall server throughput.
280
- * @param size - TLS fragment size (default and maximum value is: 16384, minimum is: 512).
281
- * @returns Returns true on success, false otherwise.
305
+ * This method can be used to request a peer's certificate after the secure
306
+ * connection has been established.
307
+ *
308
+ * When running as the server, the socket will be destroyed with an error after`handshakeTimeout` timeout.
309
+ *
310
+ * For TLSv1.3, renegotiation cannot be initiated, it is not supported by the
311
+ * protocol.
312
+ * @since v0.11.8
313
+ * @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
314
+ * an error, unless the `tlsSocket` has been destroyed, in which case `callback` will not be called at all.
315
+ * @return `true` if renegotiation was initiated, `false` otherwise.
316
+ */
317
+ renegotiate(
318
+ options: {
319
+ rejectUnauthorized?: boolean | undefined;
320
+ requestCert?: boolean | undefined;
321
+ },
322
+ callback: (err: Error | null) => void
323
+ ): undefined | boolean;
324
+ /**
325
+ * The `tlsSocket.setMaxSendFragment()` method sets the maximum TLS fragment size.
326
+ * Returns `true` if setting the limit succeeded; `false` otherwise.
327
+ *
328
+ * Smaller fragment sizes decrease the buffering latency on the client: larger
329
+ * fragments are buffered by the TLS layer until the entire fragment is received
330
+ * and its integrity is verified; large fragments can span multiple roundtrips
331
+ * and their processing can be delayed due to packet loss or reordering. However,
332
+ * smaller fragments add extra TLS framing bytes and CPU overhead, which may
333
+ * decrease overall server throughput.
334
+ * @since v0.11.11
335
+ * @param [size=16384] The maximum TLS fragment size. The maximum value is `16384`.
282
336
  */
283
337
  setMaxSendFragment(size: number): boolean;
284
-
285
338
  /**
286
- * Disables TLS renegotiation for this TLSSocket instance. Once called,
287
- * attempts to renegotiate will trigger an 'error' event on the
288
- * TLSSocket.
339
+ * Disables TLS renegotiation for this `TLSSocket` instance. Once called, attempts
340
+ * to renegotiate will trigger an `'error'` event on the `TLSSocket`.
341
+ * @since v8.4.0
289
342
  */
290
343
  disableRenegotiation(): void;
291
-
292
344
  /**
293
345
  * When enabled, TLS packet trace information is written to `stderr`. This can be
294
346
  * used to debug TLS connection problems.
295
347
  *
296
- * Note: The format of the output is identical to the output of `openssl s_client
297
- * -trace` or `openssl s_server -trace`. While it is produced by OpenSSL's
298
- * `SSL_trace()` function, the format is undocumented, can change without notice,
348
+ * Note: 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 OpenSSL's`SSL_trace()` function, the format is
349
+ * undocumented, can change without notice,
299
350
  * and should not be relied on.
351
+ * @since v12.2.0
300
352
  */
301
353
  enableTrace(): void;
302
-
303
354
  /**
355
+ * Returns the peer certificate as an `X509Certificate` object.
356
+ *
357
+ * If there is no peer certificate, or the socket has been destroyed,`undefined` will be returned.
358
+ * @since v15.9.0
359
+ */
360
+ getPeerX509Certificate(): X509Certificate | undefined;
361
+ /**
362
+ * Returns the local certificate as an `X509Certificate` object.
363
+ *
364
+ * If there is no local certificate, or the socket has been destroyed,`undefined` will be returned.
365
+ * @since v15.9.0
366
+ */
367
+ getX509Certificate(): X509Certificate | undefined;
368
+ /**
369
+ * Keying material is used for validations to prevent different kind of attacks in
370
+ * network protocols, for example in the specifications of IEEE 802.1X.
371
+ *
372
+ * Example
373
+ *
374
+ * ```js
375
+ * const keyingMaterial = tlsSocket.exportKeyingMaterial(
376
+ * 128,
377
+ * 'client finished');
378
+ *
379
+ *
380
+ * Example return value of keyingMaterial:
381
+ * <Buffer 76 26 af 99 c5 56 8e 42 09 91 ef 9f 93 cb ad 6c 7b 65 f8 53 f1 d8 d9
382
+ * 12 5a 33 b8 b5 25 df 7b 37 9f e0 e2 4f b8 67 83 a3 2f cd 5d 41 42 4c 91
383
+ * 74 ef 2c ... 78 more bytes>
384
+ *
385
+ * ```
386
+ *
387
+ * See the OpenSSL [`SSL_export_keying_material`](https://www.openssl.org/docs/man1.1.1/man3/SSL_export_keying_material.html) documentation for more
388
+ * information.
389
+ * @since v13.10.0, v12.17.0
304
390
  * @param length number of bytes to retrieve from keying material
305
- * @param label an application specific label, typically this will be a value from the
306
- * [IANA Exporter Label Registry](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels).
307
- * @param context optionally provide a context.
391
+ * @param label an application specific label, typically this will be a value from the [IANA Exporter Label
392
+ * Registry](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels).
393
+ * @param context Optionally provide a context.
394
+ * @return requested bytes of the keying material
308
395
  */
309
396
  exportKeyingMaterial(length: number, label: string, context: Buffer): Buffer;
310
-
311
397
  addListener(event: string, listener: (...args: any[]) => void): this;
312
- addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
313
- addListener(event: "secureConnect", listener: () => void): this;
314
- addListener(event: "session", listener: (session: Buffer) => void): this;
315
- addListener(event: "keylog", listener: (line: Buffer) => void): this;
316
-
398
+ addListener(event: 'OCSPResponse', listener: (response: Buffer) => void): this;
399
+ addListener(event: 'secureConnect', listener: () => void): this;
400
+ addListener(event: 'session', listener: (session: Buffer) => void): this;
401
+ addListener(event: 'keylog', listener: (line: Buffer) => void): this;
317
402
  emit(event: string | symbol, ...args: any[]): boolean;
318
- emit(event: "OCSPResponse", response: Buffer): boolean;
319
- emit(event: "secureConnect"): boolean;
320
- emit(event: "session", session: Buffer): boolean;
321
- emit(event: "keylog", line: Buffer): boolean;
322
-
403
+ emit(event: 'OCSPResponse', response: Buffer): boolean;
404
+ emit(event: 'secureConnect'): boolean;
405
+ emit(event: 'session', session: Buffer): boolean;
406
+ emit(event: 'keylog', line: Buffer): boolean;
323
407
  on(event: string, listener: (...args: any[]) => void): this;
324
- on(event: "OCSPResponse", listener: (response: Buffer) => void): this;
325
- on(event: "secureConnect", listener: () => void): this;
326
- on(event: "session", listener: (session: Buffer) => void): this;
327
- on(event: "keylog", listener: (line: Buffer) => void): this;
328
-
408
+ on(event: 'OCSPResponse', listener: (response: Buffer) => void): this;
409
+ on(event: 'secureConnect', listener: () => void): this;
410
+ on(event: 'session', listener: (session: Buffer) => void): this;
411
+ on(event: 'keylog', listener: (line: Buffer) => void): this;
329
412
  once(event: string, listener: (...args: any[]) => void): this;
330
- once(event: "OCSPResponse", listener: (response: Buffer) => void): this;
331
- once(event: "secureConnect", listener: () => void): this;
332
- once(event: "session", listener: (session: Buffer) => void): this;
333
- once(event: "keylog", listener: (line: Buffer) => void): this;
334
-
413
+ once(event: 'OCSPResponse', listener: (response: Buffer) => void): this;
414
+ once(event: 'secureConnect', listener: () => void): this;
415
+ once(event: 'session', listener: (session: Buffer) => void): this;
416
+ once(event: 'keylog', listener: (line: Buffer) => void): this;
335
417
  prependListener(event: string, listener: (...args: any[]) => void): this;
336
- prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
337
- prependListener(event: "secureConnect", listener: () => void): this;
338
- prependListener(event: "session", listener: (session: Buffer) => void): this;
339
- prependListener(event: "keylog", listener: (line: Buffer) => void): this;
340
-
418
+ prependListener(event: 'OCSPResponse', listener: (response: Buffer) => void): this;
419
+ prependListener(event: 'secureConnect', listener: () => void): this;
420
+ prependListener(event: 'session', listener: (session: Buffer) => void): this;
421
+ prependListener(event: 'keylog', listener: (line: Buffer) => void): this;
341
422
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
342
- prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
343
- prependOnceListener(event: "secureConnect", listener: () => void): this;
344
- prependOnceListener(event: "session", listener: (session: Buffer) => void): this;
345
- prependOnceListener(event: "keylog", listener: (line: Buffer) => void): this;
423
+ prependOnceListener(event: 'OCSPResponse', listener: (response: Buffer) => void): this;
424
+ prependOnceListener(event: 'secureConnect', listener: () => void): this;
425
+ prependOnceListener(event: 'session', listener: (session: Buffer) => void): this;
426
+ prependOnceListener(event: 'keylog', listener: (line: Buffer) => void): this;
346
427
  }
347
-
348
428
  interface CommonConnectionOptions {
349
429
  /**
350
430
  * An optional TLS context object from tls.createSecureContext()
351
431
  */
352
432
  secureContext?: SecureContext | undefined;
353
-
354
433
  /**
355
434
  * When enabled, TLS packet trace information is written to `stderr`. This can be
356
435
  * used to debug TLS connection problems.
@@ -377,7 +456,7 @@ declare module 'tls' {
377
456
  * SecureContext.) If SNICallback wasn't provided the default callback
378
457
  * with high-level API will be used (see below).
379
458
  */
380
- SNICallback?: ((servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void) | undefined;
459
+ SNICallback?: ((servername: string, cb: (err: Error | null, ctx?: SecureContext) => void) => void) | undefined;
381
460
  /**
382
461
  * If true the server will reject any connection which is not
383
462
  * authorized with the list of supplied CAs. This option only has an
@@ -386,7 +465,6 @@ declare module 'tls' {
386
465
  */
387
466
  rejectUnauthorized?: boolean | undefined;
388
467
  }
389
-
390
468
  interface TlsOptions extends SecureContextOptions, CommonConnectionOptions, net.ServerOpts {
391
469
  /**
392
470
  * Abort the connection if the SSL/TLS handshake does not finish in the
@@ -405,7 +483,6 @@ declare module 'tls' {
405
483
  * 48-bytes of cryptographically strong pseudo-random data.
406
484
  */
407
485
  ticketKeys?: Buffer | undefined;
408
-
409
486
  /**
410
487
  *
411
488
  * @param socket
@@ -425,7 +502,6 @@ declare module 'tls' {
425
502
  * requires explicitly specifying a cipher suite with the `ciphers` option.
426
503
  * More information can be found in the RFC 4279.
427
504
  */
428
-
429
505
  pskCallback?(socket: TLSSocket, identity: string): DataView | NodeJS.TypedArray | null;
430
506
  /**
431
507
  * hint to send to a client to help
@@ -435,17 +511,15 @@ declare module 'tls' {
435
511
  */
436
512
  pskIdentityHint?: string | undefined;
437
513
  }
438
-
439
514
  interface PSKCallbackNegotation {
440
515
  psk: DataView | NodeJS.TypedArray;
441
516
  identity: string;
442
517
  }
443
-
444
518
  interface ConnectionOptions extends SecureContextOptions, CommonConnectionOptions {
445
519
  host?: string | undefined;
446
520
  port?: number | undefined;
447
521
  path?: string | undefined; // Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored.
448
- socket?: stream.Duplex | undefined; // Establish secure connection on a given socket rather than creating a new socket
522
+ socket?: net.Socket | undefined; // Establish secure connection on a given socket rather than creating a new socket
449
523
  checkServerIdentity?: typeof checkServerIdentity | undefined;
450
524
  servername?: string | undefined; // SNI TLS Extension
451
525
  session?: Buffer | undefined;
@@ -471,35 +545,50 @@ declare module 'tls' {
471
545
  */
472
546
  pskCallback?(hint: string | null): PSKCallbackNegotation | null;
473
547
  }
474
-
548
+ /**
549
+ * Accepts encrypted connections using TLS or SSL.
550
+ * @since v0.3.2
551
+ */
475
552
  class Server extends net.Server {
476
553
  constructor(secureConnectionListener?: (socket: TLSSocket) => void);
477
554
  constructor(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void);
478
-
479
555
  /**
480
- * The server.addContext() method adds a secure context that will be
481
- * used if the client request's SNI name matches the supplied hostname
482
- * (or wildcard).
556
+ * The `server.addContext()` method adds a secure context that will be used if
557
+ * the client request's SNI name matches the supplied `hostname` (or wildcard).
558
+ *
559
+ * When there are multiple matching contexts, the most recently added one is
560
+ * used.
561
+ * @since v0.5.3
562
+ * @param hostname A SNI host name or wildcard (e.g. `'*'`)
563
+ * @param context An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc).
483
564
  */
484
- addContext(hostName: string, credentials: SecureContextOptions): void;
565
+ addContext(hostname: string, context: SecureContextOptions): void;
485
566
  /**
486
567
  * Returns the session ticket keys.
568
+ *
569
+ * See `Session Resumption` for more information.
570
+ * @since v3.0.0
571
+ * @return A 48-byte buffer containing the session ticket keys.
487
572
  */
488
573
  getTicketKeys(): Buffer;
489
574
  /**
490
- *
491
- * The server.setSecureContext() method replaces the
492
- * secure context of an existing server. Existing connections to the
493
- * server are not interrupted.
575
+ * The `server.setSecureContext()` method replaces the secure context of an
576
+ * existing server. Existing connections to the server are not interrupted.
577
+ * @since v11.0.0
578
+ * @param options An object containing any of the possible properties from the {@link createSecureContext} `options` arguments (e.g. `key`, `cert`, `ca`, etc).
494
579
  */
495
- setSecureContext(details: SecureContextOptions): void;
580
+ setSecureContext(options: SecureContextOptions): void;
496
581
  /**
497
- * The server.setSecureContext() method replaces the secure context of
498
- * an existing server. Existing connections to the server are not
499
- * interrupted.
582
+ * Sets the session ticket keys.
583
+ *
584
+ * Changes to the ticket keys are effective only for future server connections.
585
+ * Existing or currently pending server connections will use the previous keys.
586
+ *
587
+ * See `Session Resumption` for more information.
588
+ * @since v3.0.0
589
+ * @param keys A 48-byte buffer containing the session ticket keys.
500
590
  */
501
591
  setTicketKeys(keys: Buffer): void;
502
-
503
592
  /**
504
593
  * events.EventEmitter
505
594
  * 1. tlsClientError
@@ -510,61 +599,56 @@ declare module 'tls' {
510
599
  * 6. keylog
511
600
  */
512
601
  addListener(event: string, listener: (...args: any[]) => void): this;
513
- addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
514
- addListener(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
515
- addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
516
- addListener(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
517
- addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
518
- addListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
519
-
602
+ addListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
603
+ addListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this;
604
+ addListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
605
+ addListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
606
+ addListener(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
607
+ addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
520
608
  emit(event: string | symbol, ...args: any[]): boolean;
521
- emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean;
522
- emit(event: "newSession", sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void): boolean;
523
- emit(event: "OCSPRequest", certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void): boolean;
524
- emit(event: "resumeSession", sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean;
525
- emit(event: "secureConnection", tlsSocket: TLSSocket): boolean;
526
- emit(event: "keylog", line: Buffer, tlsSocket: TLSSocket): boolean;
527
-
609
+ emit(event: 'tlsClientError', err: Error, tlsSocket: TLSSocket): boolean;
610
+ emit(event: 'newSession', sessionId: Buffer, sessionData: Buffer, callback: () => void): boolean;
611
+ emit(event: 'OCSPRequest', certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void): boolean;
612
+ emit(event: 'resumeSession', sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void): boolean;
613
+ emit(event: 'secureConnection', tlsSocket: TLSSocket): boolean;
614
+ emit(event: 'keylog', line: Buffer, tlsSocket: TLSSocket): boolean;
528
615
  on(event: string, listener: (...args: any[]) => void): this;
529
- on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
530
- on(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
531
- on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
532
- on(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
533
- on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
534
- on(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
535
-
616
+ on(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
617
+ on(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this;
618
+ on(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
619
+ on(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
620
+ on(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
621
+ on(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
536
622
  once(event: string, listener: (...args: any[]) => void): this;
537
- once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
538
- once(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
539
- once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
540
- once(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
541
- once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
542
- once(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
543
-
623
+ once(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
624
+ once(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this;
625
+ once(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
626
+ once(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
627
+ once(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
628
+ once(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
544
629
  prependListener(event: string, listener: (...args: any[]) => void): this;
545
- prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
546
- prependListener(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
547
- prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
548
- prependListener(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
549
- prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
550
- prependListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
551
-
630
+ prependListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
631
+ prependListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this;
632
+ prependListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
633
+ prependListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
634
+ prependListener(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
635
+ prependListener(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
552
636
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
553
- prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
554
- prependOnceListener(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
555
- prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
556
- prependOnceListener(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
557
- prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
558
- prependOnceListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
637
+ prependOnceListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: TLSSocket) => void): this;
638
+ prependOnceListener(event: 'newSession', listener: (sessionId: Buffer, sessionData: Buffer, callback: () => void) => void): this;
639
+ prependOnceListener(event: 'OCSPRequest', listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
640
+ prependOnceListener(event: 'resumeSession', listener: (sessionId: Buffer, callback: (err: Error | null, sessionData: Buffer | null) => void) => void): this;
641
+ prependOnceListener(event: 'secureConnection', listener: (tlsSocket: TLSSocket) => void): this;
642
+ prependOnceListener(event: 'keylog', listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
559
643
  }
560
-
644
+ /**
645
+ * @deprecated since v0.11.3 Use `tls.TLSSocket` instead.
646
+ */
561
647
  interface SecurePair {
562
648
  encrypted: TLSSocket;
563
649
  cleartext: TLSSocket;
564
650
  }
565
-
566
651
  type SecureVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
567
-
568
652
  interface SecureContextOptions {
569
653
  /**
570
654
  * Optionally override the trusted CA certificates. Default is to trust
@@ -723,31 +807,183 @@ declare module 'tls' {
723
807
  */
724
808
  sessionTimeout?: number | undefined;
725
809
  }
726
-
727
810
  interface SecureContext {
728
811
  context: any;
729
812
  }
730
-
731
- /*
732
- * Verifies the certificate `cert` is issued to host `host`.
733
- * @host The hostname to verify the certificate against
734
- * @cert PeerCertificate representing the peer's certificate
813
+ /**
814
+ * Verifies the certificate `cert` is issued to `hostname`.
815
+ *
816
+ * Returns [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, populating it with `reason`, `host`, and `cert` on
817
+ * failure. On success, returns [undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type).
818
+ *
819
+ * This function can be overwritten by providing alternative function as part of
820
+ * the `options.checkServerIdentity` option passed to `tls.connect()`. The
821
+ * overwriting function can call `tls.checkServerIdentity()` of course, to augment
822
+ * the checks done with additional verification.
823
+ *
824
+ * This function is only called if the certificate passed all other checks, such as
825
+ * being issued by trusted CA (`options.ca`).
826
+ * @since v0.8.4
827
+ * @param hostname The host name or IP address to verify the certificate against.
828
+ * @param cert A `certificate object` representing the peer's certificate.
829
+ */
830
+ function checkServerIdentity(hostname: string, cert: PeerCertificate): Error | undefined;
831
+ /**
832
+ * Creates a new {@link Server}. The `secureConnectionListener`, if provided, is
833
+ * automatically set as a listener for the `'secureConnection'` event.
834
+ *
835
+ * The `ticketKeys` options is automatically shared between `cluster` module
836
+ * workers.
837
+ *
838
+ * The following illustrates a simple echo server:
839
+ *
840
+ * ```js
841
+ * const tls = require('tls');
842
+ * const fs = require('fs');
843
+ *
844
+ * const options = {
845
+ * key: fs.readFileSync('server-key.pem'),
846
+ * cert: fs.readFileSync('server-cert.pem'),
735
847
  *
736
- * Returns Error object, populating it with the reason, host and cert on failure. On success, returns undefined.
848
+ * // This is necessary only if using client certificate authentication.
849
+ * requestCert: true,
850
+ *
851
+ * // This is necessary only if the client uses a self-signed certificate.
852
+ * ca: [ fs.readFileSync('client-cert.pem') ]
853
+ * };
854
+ *
855
+ * const server = tls.createServer(options, (socket) => {
856
+ * console.log('server connected',
857
+ * socket.authorized ? 'authorized' : 'unauthorized');
858
+ * socket.write('welcome!\n');
859
+ * socket.setEncoding('utf8');
860
+ * socket.pipe(socket);
861
+ * });
862
+ * server.listen(8000, () => {
863
+ * console.log('server bound');
864
+ * });
865
+ * ```
866
+ *
867
+ * The server can be tested by connecting to it using the example client from {@link connect}.
868
+ * @since v0.3.2
737
869
  */
738
- function checkServerIdentity(host: string, cert: PeerCertificate): Error | undefined;
739
870
  function createServer(secureConnectionListener?: (socket: TLSSocket) => void): Server;
740
871
  function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server;
872
+ /**
873
+ * The `callback` function, if specified, will be added as a listener for the `'secureConnect'` event.
874
+ *
875
+ * `tls.connect()` returns a {@link TLSSocket} object.
876
+ *
877
+ * Unlike the `https` API, `tls.connect()` does not enable the
878
+ * SNI (Server Name Indication) extension by default, which may cause some
879
+ * servers to return an incorrect certificate or reject the connection
880
+ * altogether. To enable SNI, set the `servername` option in addition
881
+ * to `host`.
882
+ *
883
+ * The following illustrates a client for the echo server example from {@link createServer}:
884
+ *
885
+ * ```js
886
+ * // Assumes an echo server that is listening on port 8000.
887
+ * const tls = require('tls');
888
+ * const fs = require('fs');
889
+ *
890
+ * const options = {
891
+ * // Necessary only if the server requires client certificate authentication.
892
+ * key: fs.readFileSync('client-key.pem'),
893
+ * cert: fs.readFileSync('client-cert.pem'),
894
+ *
895
+ * // Necessary only if the server uses a self-signed certificate.
896
+ * ca: [ fs.readFileSync('server-cert.pem') ],
897
+ *
898
+ * // Necessary only if the server's cert isn't for "localhost".
899
+ * checkServerIdentity: () => { return null; },
900
+ * };
901
+ *
902
+ * const socket = tls.connect(8000, options, () => {
903
+ * console.log('client connected',
904
+ * socket.authorized ? 'authorized' : 'unauthorized');
905
+ * process.stdin.pipe(socket);
906
+ * process.stdin.resume();
907
+ * });
908
+ * socket.setEncoding('utf8');
909
+ * socket.on('data', (data) => {
910
+ * console.log(data);
911
+ * });
912
+ * socket.on('end', () => {
913
+ * console.log('server ends connection');
914
+ * });
915
+ * ```
916
+ * @since v0.11.3
917
+ */
741
918
  function connect(options: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
742
919
  function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
743
920
  function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
744
921
  /**
745
- * @deprecated since v0.11.3 Use `tls.TLSSocket` instead.
922
+ * Creates a new secure pair object with two streams, one of which reads and writes
923
+ * the encrypted data and the other of which reads and writes the cleartext data.
924
+ * Generally, the encrypted stream is piped to/from an incoming encrypted data
925
+ * stream and the cleartext one is used as a replacement for the initial encrypted
926
+ * stream.
927
+ *
928
+ * `tls.createSecurePair()` returns a `tls.SecurePair` object with `cleartext` and`encrypted` stream properties.
929
+ *
930
+ * Using `cleartext` has the same API as {@link TLSSocket}.
931
+ *
932
+ * The `tls.createSecurePair()` method is now deprecated in favor of`tls.TLSSocket()`. For example, the code:
933
+ *
934
+ * ```js
935
+ * pair = tls.createSecurePair(// ... );
936
+ * pair.encrypted.pipe(socket);
937
+ * socket.pipe(pair.encrypted);
938
+ * ```
939
+ *
940
+ * can be replaced by:
941
+ *
942
+ * ```js
943
+ * secureSocket = tls.TLSSocket(socket, options);
944
+ * ```
945
+ *
946
+ * where `secureSocket` has the same API as `pair.cleartext`.
947
+ * @since v0.3.2
948
+ * @deprecated Since v0.11.3 - Use {@link TLSSocket} instead.
949
+ * @param context A secure context object as returned by `tls.createSecureContext()`
950
+ * @param isServer `true` to specify that this TLS connection should be opened as a server.
951
+ * @param requestCert `true` to specify whether a server should request a certificate from a connecting client. Only applies when `isServer` is `true`.
952
+ * @param rejectUnauthorized If not `false` a server automatically reject clients with invalid certificates. Only applies when `isServer` is `true`.
953
+ */
954
+ function createSecurePair(context?: SecureContext, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
955
+ /**
956
+ * {@link createServer} sets the default value of the `honorCipherOrder` option
957
+ * to `true`, other APIs that create secure contexts leave it unset.
958
+ *
959
+ * {@link createServer} uses a 128 bit truncated SHA1 hash value generated
960
+ * from `process.argv` as the default value of the `sessionIdContext` option, other
961
+ * APIs that create secure contexts have no default value.
962
+ *
963
+ * The `tls.createSecureContext()` method creates a `SecureContext` object. It is
964
+ * usable as an argument to several `tls` APIs, such as {@link createServer} and `server.addContext()`, but has no public methods.
965
+ *
966
+ * A key is _required_ for ciphers that use certificates. Either `key` or`pfx` can be used to provide it.
967
+ *
968
+ * If the `ca` option is not given, then Node.js will default to using [Mozilla's publicly trusted list of
969
+ * CAs](https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt).
970
+ * @since v0.11.13
746
971
  */
747
- function createSecurePair(credentials?: SecureContext, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
748
972
  function createSecureContext(options?: SecureContextOptions): SecureContext;
973
+ /**
974
+ * Returns an array with the names of the supported TLS ciphers. The names are
975
+ * lower-case for historical reasons, but must be uppercased to be used in
976
+ * the `ciphers` option of {@link createSecureContext}.
977
+ *
978
+ * Cipher names that start with `'tls_'` are for TLSv1.3, all the others are for
979
+ * TLSv1.2 and below.
980
+ *
981
+ * ```js
982
+ * console.log(tls.getCiphers()); // ['aes128-gcm-sha256', 'aes128-sha', ...]
983
+ * ```
984
+ * @since v0.10.2
985
+ */
749
986
  function getCiphers(): string[];
750
-
751
987
  /**
752
988
  * The default curve name to use for ECDH key agreement in a tls server.
753
989
  * The default value is 'auto'. See tls.createSecureContext() for further
@@ -774,7 +1010,6 @@ declare module 'tls' {
774
1010
  * are provided, the lowest minimum is used.
775
1011
  */
776
1012
  let DEFAULT_MIN_VERSION: SecureVersion;
777
-
778
1013
  /**
779
1014
  * An immutable array of strings representing the root certificates (in PEM
780
1015
  * format) used for verifying peer certificates. This is the default value