@node-red/editor-client 2.0.4 → 2.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 (77) hide show
  1. package/locales/en-US/editor.json +37 -7
  2. package/locales/ko/editor.json +1 -1
  3. package/package.json +2 -2
  4. package/public/red/about +109 -0
  5. package/public/red/images/node-red-256.svg +1 -0
  6. package/public/red/keymap.json +13 -2
  7. package/public/red/red.js +6122 -3663
  8. package/public/red/red.min.js +1 -1
  9. package/public/red/style.min.css +2 -2
  10. package/public/red/tours/first-flow.js +80 -0
  11. package/public/red/tours/welcome.js +135 -0
  12. package/public/tours/first-flow.js +82 -0
  13. package/public/types/node/assert.d.ts +127 -0
  14. package/public/types/node/async_hooks.d.ts +229 -0
  15. package/public/types/node/buffer.d.ts +25 -1
  16. package/public/types/node/child_process.d.ts +514 -6
  17. package/public/types/node/cluster.d.ts +265 -0
  18. package/public/types/node/console.d.ts +136 -1
  19. package/public/types/node/crypto.d.ts +1189 -1
  20. package/public/types/node/dgram.d.ts +144 -1
  21. package/public/types/node/dns.d.ts +383 -10
  22. package/public/types/node/domain.d.ts +27 -1
  23. package/public/types/node/events.d.ts +81 -1
  24. package/public/types/node/fs.d.ts +2273 -1
  25. package/public/types/node/globals.d.ts +616 -1
  26. package/public/types/node/http.d.ts +489 -1
  27. package/public/types/node/http2.d.ts +961 -0
  28. package/public/types/node/https.d.ts +142 -0
  29. package/public/types/node/module.d.ts +55 -0
  30. package/public/types/node/net.d.ts +296 -1
  31. package/public/types/node/os.d.ts +242 -1
  32. package/public/types/node/path.d.ts +156 -1
  33. package/public/types/node/perf_hooks.d.ts +274 -0
  34. package/public/types/node/process.d.ts +412 -1
  35. package/public/types/node/querystring.d.ts +31 -1
  36. package/public/types/node/readline.d.ts +173 -0
  37. package/public/types/node/stream.d.ts +358 -0
  38. package/public/types/node/string_decoder.d.ts +10 -0
  39. package/public/types/node/timers.d.ts +19 -0
  40. package/public/types/node/tls.d.ts +783 -0
  41. package/public/types/node/trace_events.d.ts +64 -0
  42. package/public/types/node/tty.d.ts +69 -0
  43. package/public/types/node/url.d.ts +119 -1
  44. package/public/types/node/util.d.ts +210 -0
  45. package/public/types/node/v8.d.ts +190 -0
  46. package/public/types/node/vm.d.ts +155 -0
  47. package/public/types/node/wasi.d.ts +89 -0
  48. package/public/types/node/worker_threads.d.ts +241 -0
  49. package/public/types/node/zlib.d.ts +364 -0
  50. package/public/types/node-red/func.d.ts +1 -1
  51. package/public/types/node-red/util.d.ts +1 -1
  52. package/public/vendor/ace/worker-jsonata.js +1 -1
  53. package/public/vendor/monaco/dist/ThirdPartyNotices.txt +192 -192
  54. package/public/vendor/monaco/dist/css.worker.js +1 -1
  55. package/public/vendor/monaco/dist/editor.js +2 -2
  56. package/public/vendor/monaco/dist/editor.worker.js +1 -1
  57. package/public/vendor/monaco/dist/html.worker.js +1 -1
  58. package/public/vendor/monaco/dist/json.worker.js +1 -1
  59. package/public/vendor/monaco/dist/locale/cs.js +44 -10
  60. package/public/vendor/monaco/dist/locale/de.js +46 -12
  61. package/public/vendor/monaco/dist/locale/es.js +46 -12
  62. package/public/vendor/monaco/dist/locale/fr.js +43 -9
  63. package/public/vendor/monaco/dist/locale/it.js +45 -11
  64. package/public/vendor/monaco/dist/locale/ja.js +45 -11
  65. package/public/vendor/monaco/dist/locale/ko.js +44 -10
  66. package/public/vendor/monaco/dist/locale/pl.js +42 -8
  67. package/public/vendor/monaco/dist/locale/pt-br.js +49 -15
  68. package/public/vendor/monaco/dist/locale/qps-ploc.js +1445 -0
  69. package/public/vendor/monaco/dist/locale/ru.js +48 -14
  70. package/public/vendor/monaco/dist/locale/tr.js +49 -15
  71. package/public/vendor/monaco/dist/locale/zh-hans.js +48 -14
  72. package/public/vendor/monaco/dist/locale/zh-hant.js +45 -11
  73. package/public/vendor/monaco/dist/theme/monoindustrial.json +228 -0
  74. package/public/vendor/monaco/dist/theme/solarized-dark.json +1082 -0
  75. package/public/vendor/monaco/dist/ts.worker.js +2 -2
  76. package/public/vendor/vendor.js +4 -4
  77. package/templates/index.mst +5 -1
@@ -0,0 +1,783 @@
1
+
2
+ /* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
3
+
4
+ declare module 'tls' {
5
+ import * as net from 'net';
6
+
7
+ const CLIENT_RENEG_LIMIT: number;
8
+ const CLIENT_RENEG_WINDOW: number;
9
+
10
+ interface Certificate {
11
+ /**
12
+ * Country code.
13
+ */
14
+ C: string;
15
+ /**
16
+ * Street.
17
+ */
18
+ ST: string;
19
+ /**
20
+ * Locality.
21
+ */
22
+ L: string;
23
+ /**
24
+ * Organization.
25
+ */
26
+ O: string;
27
+ /**
28
+ * Organizational unit.
29
+ */
30
+ OU: string;
31
+ /**
32
+ * Common name.
33
+ */
34
+ CN: string;
35
+ }
36
+
37
+ interface PeerCertificate {
38
+ subject: Certificate;
39
+ issuer: Certificate;
40
+ subjectaltname: string;
41
+ infoAccess: NodeJS.Dict<string[]>;
42
+ modulus: string;
43
+ exponent: string;
44
+ valid_from: string;
45
+ valid_to: string;
46
+ fingerprint: string;
47
+ fingerprint256: string;
48
+ ext_key_usage: string[];
49
+ serialNumber: string;
50
+ raw: Buffer;
51
+ }
52
+
53
+ interface DetailedPeerCertificate extends PeerCertificate {
54
+ issuerCertificate: DetailedPeerCertificate;
55
+ }
56
+
57
+ interface CipherNameAndProtocol {
58
+ /**
59
+ * The cipher name.
60
+ */
61
+ name: string;
62
+ /**
63
+ * SSL/TLS protocol version.
64
+ */
65
+ version: string;
66
+
67
+ /**
68
+ * IETF name for the cipher suite.
69
+ */
70
+ standardName: string;
71
+ }
72
+
73
+ interface EphemeralKeyInfo {
74
+ /**
75
+ * The supported types are 'DH' and 'ECDH'.
76
+ */
77
+ type: string;
78
+ /**
79
+ * The name property is available only when type is 'ECDH'.
80
+ */
81
+ name?: string | undefined;
82
+ /**
83
+ * The size of parameter of an ephemeral key exchange.
84
+ */
85
+ size: number;
86
+ }
87
+
88
+ interface KeyObject {
89
+ /**
90
+ * Private keys in PEM format.
91
+ */
92
+ pem: string | Buffer;
93
+ /**
94
+ * Optional passphrase.
95
+ */
96
+ passphrase?: string | undefined;
97
+ }
98
+
99
+ interface PxfObject {
100
+ /**
101
+ * PFX or PKCS12 encoded private key and certificate chain.
102
+ */
103
+ buf: string | Buffer;
104
+ /**
105
+ * Optional passphrase.
106
+ */
107
+ passphrase?: string | undefined;
108
+ }
109
+
110
+ interface TLSSocketOptions extends SecureContextOptions, CommonConnectionOptions {
111
+ /**
112
+ * If true the TLS socket will be instantiated in server-mode.
113
+ * Defaults to false.
114
+ */
115
+ isServer?: boolean | undefined;
116
+ /**
117
+ * An optional net.Server instance.
118
+ */
119
+ server?: net.Server | undefined;
120
+
121
+ /**
122
+ * An optional Buffer instance containing a TLS session.
123
+ */
124
+ session?: Buffer | undefined;
125
+ /**
126
+ * If true, specifies that the OCSP status request extension will be
127
+ * added to the client hello and an 'OCSPResponse' event will be
128
+ * emitted on the socket before establishing a secure communication
129
+ */
130
+ requestOCSP?: boolean | undefined;
131
+ }
132
+
133
+ class TLSSocket extends net.Socket {
134
+ /**
135
+ * Construct a new tls.TLSSocket object from an existing TCP socket.
136
+ */
137
+ constructor(socket: net.Socket, options?: TLSSocketOptions);
138
+
139
+ /**
140
+ * A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false.
141
+ */
142
+ authorized: boolean;
143
+ /**
144
+ * The reason why the peer's certificate has not been verified.
145
+ * This property becomes available only when tlsSocket.authorized === false.
146
+ */
147
+ authorizationError: Error;
148
+ /**
149
+ * Static boolean value, always true.
150
+ * May be used to distinguish TLS sockets from regular ones.
151
+ */
152
+ encrypted: boolean;
153
+
154
+ /**
155
+ * String containing the selected ALPN protocol.
156
+ * Before a handshake has completed, this value is always null.
157
+ * When a handshake is completed but not ALPN protocol was selected, tlsSocket.alpnProtocol equals false.
158
+ */
159
+ alpnProtocol: string | false | null;
160
+
161
+ /**
162
+ * Returns an object representing the local certificate. The returned
163
+ * object has some properties corresponding to the fields of the
164
+ * certificate.
165
+ *
166
+ * See tls.TLSSocket.getPeerCertificate() for an example of the
167
+ * certificate structure.
168
+ *
169
+ * If there is no local certificate, an empty object will be returned.
170
+ * If the socket has been destroyed, null will be returned.
171
+ */
172
+ getCertificate(): PeerCertificate | object | null;
173
+ /**
174
+ * Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.
175
+ * @returns Returns an object representing the cipher name
176
+ * and the SSL/TLS protocol version of the current connection.
177
+ */
178
+ getCipher(): CipherNameAndProtocol;
179
+ /**
180
+ * Returns an object representing the type, name, and size of parameter
181
+ * of an ephemeral key exchange in Perfect Forward Secrecy on a client
182
+ * connection. It returns an empty object when the key exchange is not
183
+ * ephemeral. As this is only supported on a client socket; null is
184
+ * returned if called on a server socket. The supported types are 'DH'
185
+ * and 'ECDH'. The name property is available only when type is 'ECDH'.
186
+ *
187
+ * For example: { type: 'ECDH', name: 'prime256v1', size: 256 }.
188
+ */
189
+ getEphemeralKeyInfo(): EphemeralKeyInfo | object | null;
190
+ /**
191
+ * Returns the latest Finished message that has
192
+ * been sent to the socket as part of a SSL/TLS handshake, or undefined
193
+ * if no Finished message has been sent yet.
194
+ *
195
+ * As the Finished messages are message digests of the complete
196
+ * handshake (with a total of 192 bits for TLS 1.0 and more for SSL
197
+ * 3.0), they can be used for external authentication procedures when
198
+ * the authentication provided by SSL/TLS is not desired or is not
199
+ * enough.
200
+ *
201
+ * Corresponds to the SSL_get_finished routine in OpenSSL and may be
202
+ * used to implement the tls-unique channel binding from RFC 5929.
203
+ */
204
+ getFinished(): Buffer | undefined;
205
+ /**
206
+ * Returns an object representing the peer's certificate.
207
+ * The returned object has some properties corresponding to the field of the certificate.
208
+ * If detailed argument is true the full chain with issuer property will be returned,
209
+ * if false only the top certificate without issuer property.
210
+ * If the peer does not provide a certificate, it returns null or an empty object.
211
+ * @param detailed - If true; the full chain with issuer property will be returned.
212
+ * @returns An object representing the peer's certificate.
213
+ */
214
+ getPeerCertificate(detailed: true): DetailedPeerCertificate;
215
+ getPeerCertificate(detailed?: false): PeerCertificate;
216
+ getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate;
217
+ /**
218
+ * Returns the latest Finished message that is expected or has actually
219
+ * been received from the socket as part of a SSL/TLS handshake, or
220
+ * undefined if there is no Finished message so far.
221
+ *
222
+ * As the Finished messages are message digests of the complete
223
+ * handshake (with a total of 192 bits for TLS 1.0 and more for SSL
224
+ * 3.0), they can be used for external authentication procedures when
225
+ * the authentication provided by SSL/TLS is not desired or is not
226
+ * enough.
227
+ *
228
+ * Corresponds to the SSL_get_peer_finished routine in OpenSSL and may
229
+ * be used to implement the tls-unique channel binding from RFC 5929.
230
+ */
231
+ getPeerFinished(): Buffer | undefined;
232
+ /**
233
+ * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
234
+ * The value `'unknown'` will be returned for connected sockets that have not completed the handshaking process.
235
+ * The value `null` will be returned for server sockets or disconnected client sockets.
236
+ * See https://www.openssl.org/docs/man1.0.2/ssl/SSL_get_version.html for more information.
237
+ * @returns negotiated SSL/TLS protocol version of the current connection
238
+ */
239
+ getProtocol(): string | null;
240
+ /**
241
+ * Could be used to speed up handshake establishment when reconnecting to the server.
242
+ * @returns ASN.1 encoded TLS session or undefined if none was negotiated.
243
+ */
244
+ getSession(): Buffer | undefined;
245
+ /**
246
+ * Returns a list of signature algorithms shared between the server and
247
+ * the client in the order of decreasing preference.
248
+ */
249
+ getSharedSigalgs(): string[];
250
+ /**
251
+ * NOTE: Works only with client TLS sockets.
252
+ * Useful only for debugging, for session reuse provide session option to tls.connect().
253
+ * @returns TLS session ticket or undefined if none was negotiated.
254
+ */
255
+ getTLSTicket(): Buffer | undefined;
256
+ /**
257
+ * Returns true if the session was reused, false otherwise.
258
+ */
259
+ isSessionReused(): boolean;
260
+ /**
261
+ * Initiate TLS renegotiation process.
262
+ *
263
+ * NOTE: Can be used to request peer's certificate after the secure connection has been established.
264
+ * ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout.
265
+ * @param options - The options may contain the following fields: rejectUnauthorized,
266
+ * requestCert (See tls.createServer() for details).
267
+ * @param callback - callback(err) will be executed with null as err, once the renegotiation
268
+ * is successfully completed.
269
+ * @return `undefined` when socket is destroy, `false` if negotiaion can't be initiated.
270
+ */
271
+ renegotiate(options: { rejectUnauthorized?: boolean | undefined, requestCert?: boolean | undefined }, callback: (err: Error | null) => void): undefined | boolean;
272
+ /**
273
+ * Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512).
274
+ * Smaller fragment size decreases buffering latency on the client: large fragments are buffered by
275
+ * the TLS layer until the entire fragment is received and its integrity is verified;
276
+ * large fragments can span multiple roundtrips, and their processing can be delayed due to packet
277
+ * loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead,
278
+ * which may decrease overall server throughput.
279
+ * @param size - TLS fragment size (default and maximum value is: 16384, minimum is: 512).
280
+ * @returns Returns true on success, false otherwise.
281
+ */
282
+ setMaxSendFragment(size: number): boolean;
283
+
284
+ /**
285
+ * Disables TLS renegotiation for this TLSSocket instance. Once called,
286
+ * attempts to renegotiate will trigger an 'error' event on the
287
+ * TLSSocket.
288
+ */
289
+ disableRenegotiation(): void;
290
+
291
+ /**
292
+ * When enabled, TLS packet trace information is written to `stderr`. This can be
293
+ * used to debug TLS connection problems.
294
+ *
295
+ * Note: The format of the output is identical to the output of `openssl s_client
296
+ * -trace` or `openssl s_server -trace`. While it is produced by OpenSSL's
297
+ * `SSL_trace()` function, the format is undocumented, can change without notice,
298
+ * and should not be relied on.
299
+ */
300
+ enableTrace(): void;
301
+
302
+ /**
303
+ * @param length number of bytes to retrieve from keying material
304
+ * @param label an application specific label, typically this will be a value from the
305
+ * [IANA Exporter Label Registry](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels).
306
+ * @param context optionally provide a context.
307
+ */
308
+ exportKeyingMaterial(length: number, label: string, context: Buffer): Buffer;
309
+
310
+ addListener(event: string, listener: (...args: any[]) => void): this;
311
+ addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
312
+ addListener(event: "secureConnect", listener: () => void): this;
313
+ addListener(event: "session", listener: (session: Buffer) => void): this;
314
+ addListener(event: "keylog", listener: (line: Buffer) => void): this;
315
+
316
+ emit(event: string | symbol, ...args: any[]): boolean;
317
+ emit(event: "OCSPResponse", response: Buffer): boolean;
318
+ emit(event: "secureConnect"): boolean;
319
+ emit(event: "session", session: Buffer): boolean;
320
+ emit(event: "keylog", line: Buffer): boolean;
321
+
322
+ on(event: string, listener: (...args: any[]) => void): this;
323
+ on(event: "OCSPResponse", listener: (response: Buffer) => void): this;
324
+ on(event: "secureConnect", listener: () => void): this;
325
+ on(event: "session", listener: (session: Buffer) => void): this;
326
+ on(event: "keylog", listener: (line: Buffer) => void): this;
327
+
328
+ once(event: string, listener: (...args: any[]) => void): this;
329
+ once(event: "OCSPResponse", listener: (response: Buffer) => void): this;
330
+ once(event: "secureConnect", listener: () => void): this;
331
+ once(event: "session", listener: (session: Buffer) => void): this;
332
+ once(event: "keylog", listener: (line: Buffer) => void): this;
333
+
334
+ prependListener(event: string, listener: (...args: any[]) => void): this;
335
+ prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
336
+ prependListener(event: "secureConnect", listener: () => void): this;
337
+ prependListener(event: "session", listener: (session: Buffer) => void): this;
338
+ prependListener(event: "keylog", listener: (line: Buffer) => void): this;
339
+
340
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
341
+ prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
342
+ prependOnceListener(event: "secureConnect", listener: () => void): this;
343
+ prependOnceListener(event: "session", listener: (session: Buffer) => void): this;
344
+ prependOnceListener(event: "keylog", listener: (line: Buffer) => void): this;
345
+ }
346
+
347
+ interface CommonConnectionOptions {
348
+ /**
349
+ * An optional TLS context object from tls.createSecureContext()
350
+ */
351
+ secureContext?: SecureContext | undefined;
352
+
353
+ /**
354
+ * When enabled, TLS packet trace information is written to `stderr`. This can be
355
+ * used to debug TLS connection problems.
356
+ * @default false
357
+ */
358
+ enableTrace?: boolean | undefined;
359
+ /**
360
+ * If true the server will request a certificate from clients that
361
+ * connect and attempt to verify that certificate. Defaults to
362
+ * false.
363
+ */
364
+ requestCert?: boolean | undefined;
365
+ /**
366
+ * An array of strings or a Buffer naming possible ALPN protocols.
367
+ * (Protocols should be ordered by their priority.)
368
+ */
369
+ ALPNProtocols?: string[] | Uint8Array[] | Uint8Array | undefined;
370
+ /**
371
+ * SNICallback(servername, cb) <Function> A function that will be
372
+ * called if the client supports SNI TLS extension. Two arguments
373
+ * will be passed when called: servername and cb. SNICallback should
374
+ * invoke cb(null, ctx), where ctx is a SecureContext instance.
375
+ * (tls.createSecureContext(...) can be used to get a proper
376
+ * SecureContext.) If SNICallback wasn't provided the default callback
377
+ * with high-level API will be used (see below).
378
+ */
379
+ SNICallback?: ((servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void) | undefined;
380
+ /**
381
+ * If true the server will reject any connection which is not
382
+ * authorized with the list of supplied CAs. This option only has an
383
+ * effect if requestCert is true.
384
+ * @default true
385
+ */
386
+ rejectUnauthorized?: boolean | undefined;
387
+ }
388
+
389
+ interface TlsOptions extends SecureContextOptions, CommonConnectionOptions, net.ServerOpts {
390
+ /**
391
+ * Abort the connection if the SSL/TLS handshake does not finish in the
392
+ * specified number of milliseconds. A 'tlsClientError' is emitted on
393
+ * the tls.Server object whenever a handshake times out. Default:
394
+ * 120000 (120 seconds).
395
+ */
396
+ handshakeTimeout?: number | undefined;
397
+ /**
398
+ * The number of seconds after which a TLS session created by the
399
+ * server will no longer be resumable. See Session Resumption for more
400
+ * information. Default: 300.
401
+ */
402
+ sessionTimeout?: number | undefined;
403
+ /**
404
+ * 48-bytes of cryptographically strong pseudo-random data.
405
+ */
406
+ ticketKeys?: Buffer | undefined;
407
+
408
+ /**
409
+ *
410
+ * @param socket
411
+ * @param identity identity parameter sent from the client.
412
+ * @return pre-shared key that must either be
413
+ * a buffer or `null` to stop the negotiation process. Returned PSK must be
414
+ * compatible with the selected cipher's digest.
415
+ *
416
+ * When negotiating TLS-PSK (pre-shared keys), this function is called
417
+ * with the identity provided by the client.
418
+ * If the return value is `null` the negotiation process will stop and an
419
+ * "unknown_psk_identity" alert message will be sent to the other party.
420
+ * If the server wishes to hide the fact that the PSK identity was not known,
421
+ * the callback must provide some random data as `psk` to make the connection
422
+ * fail with "decrypt_error" before negotiation is finished.
423
+ * PSK ciphers are disabled by default, and using TLS-PSK thus
424
+ * requires explicitly specifying a cipher suite with the `ciphers` option.
425
+ * More information can be found in the RFC 4279.
426
+ */
427
+
428
+ pskCallback?(socket: TLSSocket, identity: string): DataView | NodeJS.TypedArray | null;
429
+ /**
430
+ * hint to send to a client to help
431
+ * with selecting the identity during TLS-PSK negotiation. Will be ignored
432
+ * in TLS 1.3. Upon failing to set pskIdentityHint `tlsClientError` will be
433
+ * emitted with `ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED` code.
434
+ */
435
+ pskIdentityHint?: string | undefined;
436
+ }
437
+
438
+ interface PSKCallbackNegotation {
439
+ psk: DataView | NodeJS.TypedArray;
440
+ identity: string;
441
+ }
442
+
443
+ interface ConnectionOptions extends SecureContextOptions, CommonConnectionOptions {
444
+ host?: string | undefined;
445
+ port?: number | undefined;
446
+ path?: string | undefined; // Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored.
447
+ socket?: net.Socket | undefined; // Establish secure connection on a given socket rather than creating a new socket
448
+ checkServerIdentity?: typeof checkServerIdentity | undefined;
449
+ servername?: string | undefined; // SNI TLS Extension
450
+ session?: Buffer | undefined;
451
+ minDHSize?: number | undefined;
452
+ lookup?: net.LookupFunction | undefined;
453
+ timeout?: number | undefined;
454
+ /**
455
+ * When negotiating TLS-PSK (pre-shared keys), this function is called
456
+ * with optional identity `hint` provided by the server or `null`
457
+ * in case of TLS 1.3 where `hint` was removed.
458
+ * It will be necessary to provide a custom `tls.checkServerIdentity()`
459
+ * for the connection as the default one will try to check hostname/IP
460
+ * of the server against the certificate but that's not applicable for PSK
461
+ * because there won't be a certificate present.
462
+ * More information can be found in the RFC 4279.
463
+ *
464
+ * @param hint message sent from the server to help client
465
+ * decide which identity to use during negotiation.
466
+ * Always `null` if TLS 1.3 is used.
467
+ * @returns Return `null` to stop the negotiation process. `psk` must be
468
+ * compatible with the selected cipher's digest.
469
+ * `identity` must use UTF-8 encoding.
470
+ */
471
+ pskCallback?(hint: string | null): PSKCallbackNegotation | null;
472
+ }
473
+
474
+ class Server extends net.Server {
475
+ constructor(secureConnectionListener?: (socket: TLSSocket) => void);
476
+ constructor(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void);
477
+
478
+ /**
479
+ * The server.addContext() method adds a secure context that will be
480
+ * used if the client request's SNI name matches the supplied hostname
481
+ * (or wildcard).
482
+ */
483
+ addContext(hostName: string, credentials: SecureContextOptions): void;
484
+ /**
485
+ * Returns the session ticket keys.
486
+ */
487
+ getTicketKeys(): Buffer;
488
+ /**
489
+ *
490
+ * The server.setSecureContext() method replaces the
491
+ * secure context of an existing server. Existing connections to the
492
+ * server are not interrupted.
493
+ */
494
+ setSecureContext(details: SecureContextOptions): void;
495
+ /**
496
+ * The server.setSecureContext() method replaces the secure context of
497
+ * an existing server. Existing connections to the server are not
498
+ * interrupted.
499
+ */
500
+ setTicketKeys(keys: Buffer): void;
501
+
502
+ /**
503
+ * events.EventEmitter
504
+ * 1. tlsClientError
505
+ * 2. newSession
506
+ * 3. OCSPRequest
507
+ * 4. resumeSession
508
+ * 5. secureConnection
509
+ * 6. keylog
510
+ */
511
+ addListener(event: string, listener: (...args: any[]) => void): this;
512
+ addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
513
+ addListener(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
514
+ addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
515
+ addListener(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
516
+ addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
517
+ addListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
518
+
519
+ emit(event: string | symbol, ...args: any[]): boolean;
520
+ emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean;
521
+ emit(event: "newSession", sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void): boolean;
522
+ emit(event: "OCSPRequest", certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void): boolean;
523
+ emit(event: "resumeSession", sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean;
524
+ emit(event: "secureConnection", tlsSocket: TLSSocket): boolean;
525
+ emit(event: "keylog", line: Buffer, tlsSocket: TLSSocket): boolean;
526
+
527
+ on(event: string, listener: (...args: any[]) => void): this;
528
+ on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
529
+ on(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
530
+ on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
531
+ on(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
532
+ on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
533
+ on(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
534
+
535
+ once(event: string, listener: (...args: any[]) => void): this;
536
+ once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
537
+ once(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
538
+ once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
539
+ once(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
540
+ once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
541
+ once(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
542
+
543
+ prependListener(event: string, listener: (...args: any[]) => void): this;
544
+ prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
545
+ prependListener(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
546
+ prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
547
+ prependListener(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
548
+ prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
549
+ prependListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
550
+
551
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
552
+ prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
553
+ prependOnceListener(event: "newSession", listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void): this;
554
+ prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: (err: Error | null, resp: Buffer) => void) => void): this;
555
+ prependOnceListener(event: "resumeSession", listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void): this;
556
+ prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
557
+ prependOnceListener(event: "keylog", listener: (line: Buffer, tlsSocket: TLSSocket) => void): this;
558
+ }
559
+
560
+ interface SecurePair {
561
+ encrypted: TLSSocket;
562
+ cleartext: TLSSocket;
563
+ }
564
+
565
+ type SecureVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
566
+
567
+ interface SecureContextOptions {
568
+ /**
569
+ * Optionally override the trusted CA certificates. Default is to trust
570
+ * the well-known CAs curated by Mozilla. Mozilla's CAs are completely
571
+ * replaced when CAs are explicitly specified using this option.
572
+ */
573
+ ca?: string | Buffer | Array<string | Buffer> | undefined;
574
+ /**
575
+ * Cert chains in PEM format. One cert chain should be provided per
576
+ * private key. Each cert chain should consist of the PEM formatted
577
+ * certificate for a provided private key, followed by the PEM
578
+ * formatted intermediate certificates (if any), in order, and not
579
+ * including the root CA (the root CA must be pre-known to the peer,
580
+ * see ca). When providing multiple cert chains, they do not have to
581
+ * be in the same order as their private keys in key. If the
582
+ * intermediate certificates are not provided, the peer will not be
583
+ * able to validate the certificate, and the handshake will fail.
584
+ */
585
+ cert?: string | Buffer | Array<string | Buffer> | undefined;
586
+ /**
587
+ * Colon-separated list of supported signature algorithms. The list
588
+ * can contain digest algorithms (SHA256, MD5 etc.), public key
589
+ * algorithms (RSA-PSS, ECDSA etc.), combination of both (e.g
590
+ * 'RSA+SHA384') or TLS v1.3 scheme names (e.g. rsa_pss_pss_sha512).
591
+ */
592
+ sigalgs?: string | undefined;
593
+ /**
594
+ * Cipher suite specification, replacing the default. For more
595
+ * information, see modifying the default cipher suite. Permitted
596
+ * ciphers can be obtained via tls.getCiphers(). Cipher names must be
597
+ * uppercased in order for OpenSSL to accept them.
598
+ */
599
+ ciphers?: string | undefined;
600
+ /**
601
+ * Name of an OpenSSL engine which can provide the client certificate.
602
+ */
603
+ clientCertEngine?: string | undefined;
604
+ /**
605
+ * PEM formatted CRLs (Certificate Revocation Lists).
606
+ */
607
+ crl?: string | Buffer | Array<string | Buffer> | undefined;
608
+ /**
609
+ * Diffie Hellman parameters, required for Perfect Forward Secrecy. Use
610
+ * openssl dhparam to create the parameters. The key length must be
611
+ * greater than or equal to 1024 bits or else an error will be thrown.
612
+ * Although 1024 bits is permissible, use 2048 bits or larger for
613
+ * stronger security. If omitted or invalid, the parameters are
614
+ * silently discarded and DHE ciphers will not be available.
615
+ */
616
+ dhparam?: string | Buffer | undefined;
617
+ /**
618
+ * A string describing a named curve or a colon separated list of curve
619
+ * NIDs or names, for example P-521:P-384:P-256, to use for ECDH key
620
+ * agreement. Set to auto to select the curve automatically. Use
621
+ * crypto.getCurves() to obtain a list of available curve names. On
622
+ * recent releases, openssl ecparam -list_curves will also display the
623
+ * name and description of each available elliptic curve. Default:
624
+ * tls.DEFAULT_ECDH_CURVE.
625
+ */
626
+ ecdhCurve?: string | undefined;
627
+ /**
628
+ * Attempt to use the server's cipher suite preferences instead of the
629
+ * client's. When true, causes SSL_OP_CIPHER_SERVER_PREFERENCE to be
630
+ * set in secureOptions
631
+ */
632
+ honorCipherOrder?: boolean | undefined;
633
+ /**
634
+ * Private keys in PEM format. PEM allows the option of private keys
635
+ * being encrypted. Encrypted keys will be decrypted with
636
+ * options.passphrase. Multiple keys using different algorithms can be
637
+ * provided either as an array of unencrypted key strings or buffers,
638
+ * or an array of objects in the form {pem: <string|buffer>[,
639
+ * passphrase: <string>]}. The object form can only occur in an array.
640
+ * object.passphrase is optional. Encrypted keys will be decrypted with
641
+ * object.passphrase if provided, or options.passphrase if it is not.
642
+ */
643
+ key?: string | Buffer | Array<Buffer | KeyObject> | undefined;
644
+ /**
645
+ * Name of an OpenSSL engine to get private key from. Should be used
646
+ * together with privateKeyIdentifier.
647
+ */
648
+ privateKeyEngine?: string | undefined;
649
+ /**
650
+ * Identifier of a private key managed by an OpenSSL engine. Should be
651
+ * used together with privateKeyEngine. Should not be set together with
652
+ * key, because both options define a private key in different ways.
653
+ */
654
+ privateKeyIdentifier?: string | undefined;
655
+ /**
656
+ * Optionally set the maximum TLS version to allow. One
657
+ * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the
658
+ * `secureProtocol` option, use one or the other.
659
+ * **Default:** `'TLSv1.3'`, unless changed using CLI options. Using
660
+ * `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets the default to
661
+ * `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used.
662
+ */
663
+ maxVersion?: SecureVersion | undefined;
664
+ /**
665
+ * Optionally set the minimum TLS version to allow. One
666
+ * of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the
667
+ * `secureProtocol` option, use one or the other. It is not recommended to use
668
+ * less than TLSv1.2, but it may be required for interoperability.
669
+ * **Default:** `'TLSv1.2'`, unless changed using CLI options. Using
670
+ * `--tls-v1.0` sets the default to `'TLSv1'`. Using `--tls-v1.1` sets the default to
671
+ * `'TLSv1.1'`. Using `--tls-min-v1.3` sets the default to
672
+ * 'TLSv1.3'. If multiple of the options are provided, the lowest minimum is used.
673
+ */
674
+ minVersion?: SecureVersion | undefined;
675
+ /**
676
+ * Shared passphrase used for a single private key and/or a PFX.
677
+ */
678
+ passphrase?: string | undefined;
679
+ /**
680
+ * PFX or PKCS12 encoded private key and certificate chain. pfx is an
681
+ * alternative to providing key and cert individually. PFX is usually
682
+ * encrypted, if it is, passphrase will be used to decrypt it. Multiple
683
+ * PFX can be provided either as an array of unencrypted PFX buffers,
684
+ * or an array of objects in the form {buf: <string|buffer>[,
685
+ * passphrase: <string>]}. The object form can only occur in an array.
686
+ * object.passphrase is optional. Encrypted PFX will be decrypted with
687
+ * object.passphrase if provided, or options.passphrase if it is not.
688
+ */
689
+ pfx?: string | Buffer | Array<string | Buffer | PxfObject> | undefined;
690
+ /**
691
+ * Optionally affect the OpenSSL protocol behavior, which is not
692
+ * usually necessary. This should be used carefully if at all! Value is
693
+ * a numeric bitmask of the SSL_OP_* options from OpenSSL Options
694
+ */
695
+ secureOptions?: number | undefined; // Value is a numeric bitmask of the `SSL_OP_*` options
696
+ /**
697
+ * Legacy mechanism to select the TLS protocol version to use, it does
698
+ * not support independent control of the minimum and maximum version,
699
+ * and does not support limiting the protocol to TLSv1.3. Use
700
+ * minVersion and maxVersion instead. The possible values are listed as
701
+ * SSL_METHODS, use the function names as strings. For example, use
702
+ * 'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method' to allow
703
+ * any TLS protocol version up to TLSv1.3. It is not recommended to use
704
+ * TLS versions less than 1.2, but it may be required for
705
+ * interoperability. Default: none, see minVersion.
706
+ */
707
+ secureProtocol?: string | undefined;
708
+ /**
709
+ * Opaque identifier used by servers to ensure session state is not
710
+ * shared between applications. Unused by clients.
711
+ */
712
+ sessionIdContext?: string | undefined;
713
+ /**
714
+ * 48-bytes of cryptographically strong pseudo-random data.
715
+ * See Session Resumption for more information.
716
+ */
717
+ ticketKeys?: Buffer | undefined;
718
+ /**
719
+ * The number of seconds after which a TLS session created by the
720
+ * server will no longer be resumable. See Session Resumption for more
721
+ * information. Default: 300.
722
+ */
723
+ sessionTimeout?: number | undefined;
724
+ }
725
+
726
+ interface SecureContext {
727
+ context: any;
728
+ }
729
+
730
+ /*
731
+ * Verifies the certificate `cert` is issued to host `host`.
732
+ * @host The hostname to verify the certificate against
733
+ * @cert PeerCertificate representing the peer's certificate
734
+ *
735
+ * Returns Error object, populating it with the reason, host and cert on failure. On success, returns undefined.
736
+ */
737
+ function checkServerIdentity(host: string, cert: PeerCertificate): Error | undefined;
738
+ function createServer(secureConnectionListener?: (socket: TLSSocket) => void): Server;
739
+ function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server;
740
+ function connect(options: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
741
+ function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
742
+ function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
743
+ /**
744
+ * @deprecated since v0.11.3 Use `tls.TLSSocket` instead.
745
+ */
746
+ function createSecurePair(credentials?: SecureContext, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
747
+ function createSecureContext(options?: SecureContextOptions): SecureContext;
748
+ function getCiphers(): string[];
749
+
750
+ /**
751
+ * The default curve name to use for ECDH key agreement in a tls server.
752
+ * The default value is 'auto'. See tls.createSecureContext() for further
753
+ * information.
754
+ */
755
+ let DEFAULT_ECDH_CURVE: string;
756
+ /**
757
+ * The default value of the maxVersion option of
758
+ * tls.createSecureContext(). It can be assigned any of the supported TLS
759
+ * protocol versions, 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default:
760
+ * 'TLSv1.3', unless changed using CLI options. Using --tls-max-v1.2 sets
761
+ * the default to 'TLSv1.2'. Using --tls-max-v1.3 sets the default to
762
+ * 'TLSv1.3'. If multiple of the options are provided, the highest maximum
763
+ * is used.
764
+ */
765
+ let DEFAULT_MAX_VERSION: SecureVersion;
766
+ /**
767
+ * The default value of the minVersion option of tls.createSecureContext().
768
+ * It can be assigned any of the supported TLS protocol versions,
769
+ * 'TLSv1.3', 'TLSv1.2', 'TLSv1.1', or 'TLSv1'. Default: 'TLSv1.2', unless
770
+ * changed using CLI options. Using --tls-min-v1.0 sets the default to
771
+ * 'TLSv1'. Using --tls-min-v1.1 sets the default to 'TLSv1.1'. Using
772
+ * --tls-min-v1.3 sets the default to 'TLSv1.3'. If multiple of the options
773
+ * are provided, the lowest minimum is used.
774
+ */
775
+ let DEFAULT_MIN_VERSION: SecureVersion;
776
+
777
+ /**
778
+ * An immutable array of strings representing the root certificates (in PEM
779
+ * format) used for verifying peer certificates. This is the default value
780
+ * of the ca option to tls.createSecureContext().
781
+ */
782
+ const rootCertificates: ReadonlyArray<string>;
783
+ }