@types/node 16.4.1 → 16.4.5

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