@ac-kit/node 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/README.md +2 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/net/connection-closed-error.d.ts +12 -0
- package/dist/net/connection-closed-error.d.ts.map +1 -0
- package/dist/net/connection-closed-error.js +15 -0
- package/dist/net/connection-closed-error.js.map +1 -0
- package/dist/net/dgram-socket.d.ts +2 -2
- package/dist/net/dgram-socket.d.ts.map +1 -1
- package/dist/net/dgram-socket.js +35 -35
- package/dist/net/dgram-socket.js.map +1 -1
- package/dist/net/inet-socket.d.ts +64 -0
- package/dist/net/inet-socket.d.ts.map +1 -0
- package/dist/net/inet-socket.js +103 -0
- package/dist/net/inet-socket.js.map +1 -0
- package/dist/net/ipc-server.d.ts +63 -0
- package/dist/net/ipc-server.d.ts.map +1 -0
- package/dist/net/ipc-server.js +75 -0
- package/dist/net/ipc-server.js.map +1 -0
- package/dist/net/ipc-socket.d.ts +55 -22
- package/dist/net/ipc-socket.d.ts.map +1 -1
- package/dist/net/ipc-socket.js +50 -46
- package/dist/net/ipc-socket.js.map +1 -1
- package/dist/net/stream-server.d.ts +80 -0
- package/dist/net/stream-server.d.ts.map +1 -0
- package/dist/net/stream-server.js +129 -0
- package/dist/net/stream-server.js.map +1 -0
- package/dist/net/stream-socket.d.ts +37 -8
- package/dist/net/stream-socket.d.ts.map +1 -1
- package/dist/net/stream-socket.js +80 -27
- package/dist/net/stream-socket.js.map +1 -1
- package/dist/net/tcp-server.d.ts +31 -73
- package/dist/net/tcp-server.d.ts.map +1 -1
- package/dist/net/tcp-server.js +41 -147
- package/dist/net/tcp-server.js.map +1 -1
- package/dist/net/tcp-socket.d.ts +21 -61
- package/dist/net/tcp-socket.d.ts.map +1 -1
- package/dist/net/tcp-socket.js +23 -126
- package/dist/net/tcp-socket.js.map +1 -1
- package/dist/net/tls-server.d.ts +87 -0
- package/dist/net/tls-server.d.ts.map +1 -0
- package/dist/net/tls-server.js +103 -0
- package/dist/net/tls-server.js.map +1 -0
- package/dist/net/tls-socket.d.ts +235 -14
- package/dist/net/tls-socket.d.ts.map +1 -1
- package/dist/net/tls-socket.js +241 -91
- package/dist/net/tls-socket.js.map +1 -1
- package/package.json +4 -4
- package/dist/shell/escape-command-arg.d.ts +0 -9
- package/dist/shell/escape-command-arg.d.ts.map +0 -1
- package/dist/shell/escape-command-arg.js +0 -13
- package/dist/shell/escape-command-arg.js.map +0 -1
- package/dist/shell/escape-command.d.ts +0 -10
- package/dist/shell/escape-command.d.ts.map +0 -1
- package/dist/shell/escape-command.js +0 -12
- package/dist/shell/escape-command.js.map +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as tls from "node:tls";
|
|
2
|
+
import { TcpServer } from "./tcp-server.js";
|
|
3
|
+
import { TlsSocket } from "./tls-socket.js";
|
|
4
|
+
/**
|
|
5
|
+
* TLS server accepting encrypted incoming connections.
|
|
6
|
+
*
|
|
7
|
+
* Example usage:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const server = TlsServer.from({ key, cert });
|
|
11
|
+
* server.subscribe("secureConnection", (socket) => {
|
|
12
|
+
* console.log("Client cipher:", socket.getCipher().name);
|
|
13
|
+
* });
|
|
14
|
+
* await server.listen(8443, "0.0.0.0");
|
|
15
|
+
* // ... later
|
|
16
|
+
* await server.close();
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Every event of {@link TcpServer} is still emitted, so
|
|
20
|
+
* {@link TcpServerEvents.connection} reports the plaintext socket accepted
|
|
21
|
+
* _before_ the handshake. Wait for {@link TlsServerEvents.secureConnection} to
|
|
22
|
+
* read or write application data.
|
|
23
|
+
*
|
|
24
|
+
* The session-resumption events Node.js exposes with a completion callback
|
|
25
|
+
* (`newSession`, `resumeSession` and `OCSPRequest`) are deliberately not
|
|
26
|
+
* forwarded: Node.js falls back to its default behaviour only while no listener
|
|
27
|
+
* is attached, so forwarding them would stall every handshake that nobody
|
|
28
|
+
* subscribed to.
|
|
29
|
+
*/
|
|
30
|
+
export class TlsServer extends TcpServer {
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new {@link TlsServer} instance.
|
|
33
|
+
*
|
|
34
|
+
* @param options Options for creating the underlying Node.js server,
|
|
35
|
+
* including the certificate chain and private key to serve.
|
|
36
|
+
* @returns A new `TlsServer` instance.
|
|
37
|
+
*/
|
|
38
|
+
static from(options) {
|
|
39
|
+
return new TlsServer(tls.createServer(options ?? {}));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Adds a secure context to serve when a client requests `hostname` through
|
|
43
|
+
* SNI.
|
|
44
|
+
*
|
|
45
|
+
* @param hostname The server name to match, which may contain wildcards.
|
|
46
|
+
* @param context The secure context or the options to build one from.
|
|
47
|
+
*/
|
|
48
|
+
addContext(hostname, context) {
|
|
49
|
+
this.server.addContext(hostname, context);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Replaces the default secure context, affecting connections established
|
|
53
|
+
* after the call.
|
|
54
|
+
*
|
|
55
|
+
* @param context The options to build the secure context from.
|
|
56
|
+
*/
|
|
57
|
+
setSecureContext(context) {
|
|
58
|
+
this.server.setSecureContext(context);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns the keys used to encrypt session tickets.
|
|
62
|
+
*
|
|
63
|
+
* Sharing them across server instances lets clients resume a session on any
|
|
64
|
+
* of them; they are sensitive key material and must be handled as secrets.
|
|
65
|
+
*
|
|
66
|
+
* @returns The 48-byte session ticket keys.
|
|
67
|
+
*/
|
|
68
|
+
getTicketKeys() {
|
|
69
|
+
return this.server.getTicketKeys();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Sets the keys used to encrypt session tickets, affecting connections
|
|
73
|
+
* established after the call.
|
|
74
|
+
*
|
|
75
|
+
* @param keys The 48-byte session ticket keys.
|
|
76
|
+
*/
|
|
77
|
+
setTicketKeys(keys) {
|
|
78
|
+
this.server.setTicketKeys(keys);
|
|
79
|
+
}
|
|
80
|
+
setupEventForwarding() {
|
|
81
|
+
super.setupEventForwarding();
|
|
82
|
+
this.server.on("secureConnection", (socket) => {
|
|
83
|
+
this.dispatch("secureConnection", [wrap_(socket)]);
|
|
84
|
+
});
|
|
85
|
+
this.server.on("tlsClientError", (error, socket) => {
|
|
86
|
+
this.dispatch("tlsClientError", [error, wrap_(socket)]);
|
|
87
|
+
});
|
|
88
|
+
this.server.on("keylog", (line, socket) => {
|
|
89
|
+
this.dispatch("keylog", [line, wrap_(socket)]);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** Keeps one wrapper per accepted socket, so subscribers can correlate events. */
|
|
94
|
+
const wrappers_ = new WeakMap();
|
|
95
|
+
function wrap_(socket) {
|
|
96
|
+
let wrapper = wrappers_.get(socket);
|
|
97
|
+
if (wrapper === undefined) {
|
|
98
|
+
wrapper = new TlsSocket(socket);
|
|
99
|
+
wrappers_.set(socket, wrapper);
|
|
100
|
+
}
|
|
101
|
+
return wrapper;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=tls-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tls-server.js","sourceRoot":"","sources":["../../src/net/tls-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAIhC,OAAO,EAAE,SAAS,EAAwB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAyB,MAAM,iBAAiB,CAAC;AAoBnE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,SAAU,SAAQ,SAAsC;IACpE;;;;;;OAMG;IACH,MAAM,CAAU,IAAI,CAAC,OAA0B;QAC9C,OAAO,IAAI,SAAS,CAAC,GAA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J,CAAC;CACD;AAED,kFAAkF;AAClF,MAAM,SAAS,GAAG,IAAI,OAAO,EAA4B,CAAC;AAE1D,SAAS,KAAK,CAAC,MAAqB;IACnC,IAAI,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEpC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;QAChC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
package/dist/net/tls-socket.d.ts
CHANGED
|
@@ -2,44 +2,265 @@ import type { X509Certificate } from "node:crypto";
|
|
|
2
2
|
import type { Duplex } from "node:stream";
|
|
3
3
|
import * as tls from "node:tls";
|
|
4
4
|
import type { Except } from "type-fest";
|
|
5
|
-
import type
|
|
6
|
-
|
|
7
|
-
export type TlsSocketEvents =
|
|
5
|
+
import { InetSocket, type InetSocketEvents } from "./inet-socket.js";
|
|
6
|
+
/** Event map for {@link TlsSocket}. */
|
|
7
|
+
export type TlsSocketEvents = InetSocketEvents & {
|
|
8
|
+
/** Emitted once the handshake completed and the connection is usable. */
|
|
8
9
|
secureConnect: [];
|
|
10
|
+
/**
|
|
11
|
+
* Emitted once the handshake completed, including after a renegotiation.
|
|
12
|
+
*
|
|
13
|
+
* Unlike {@link TlsSocketEvents.secureConnect} this also fires on sockets
|
|
14
|
+
* accepted by a server.
|
|
15
|
+
*/
|
|
16
|
+
secure: [];
|
|
17
|
+
/**
|
|
18
|
+
* Emitted with the stapled OCSP response, or `null` when the server sent
|
|
19
|
+
* none. Only emitted when `requestOCSP` was set.
|
|
20
|
+
*/
|
|
9
21
|
ocspResponse: [response: Buffer | null];
|
|
22
|
+
/** Emitted with each line of TLS key material, for traffic decryption. */
|
|
10
23
|
keylog: [line: Buffer];
|
|
24
|
+
/** Emitted with a session ticket that can be reused to resume the session. */
|
|
11
25
|
session: [session: Buffer];
|
|
12
26
|
};
|
|
13
|
-
|
|
14
|
-
export type
|
|
27
|
+
/** Options accepted by {@link TlsSocket.from}. */
|
|
28
|
+
export type TlsSocketOptions = Except<tls.TLSSocketOptions, "isServer" | "server">;
|
|
29
|
+
/** Options accepted by {@link TlsSocket.connect}. */
|
|
30
|
+
export type TlsSocketConnectOptions = Except<tls.ConnectionOptions, "port" | "path" | "socket"> & {
|
|
31
|
+
/** Aborts the connection attempt and destroys the socket. */
|
|
15
32
|
signal?: AbortSignal;
|
|
16
33
|
};
|
|
17
|
-
|
|
34
|
+
/** Options accepted by {@link TlsSocket.renegotiate}. */
|
|
35
|
+
export type TlsSocketRenegotiateOptions = {
|
|
36
|
+
/** Whether to reject a peer certificate that fails verification. */
|
|
37
|
+
rejectUnauthorized?: boolean;
|
|
38
|
+
/** Whether to request a certificate from the peer. */
|
|
39
|
+
requestCert?: boolean;
|
|
40
|
+
};
|
|
41
|
+
/** A ready-made secure context, or the options to build one from. */
|
|
42
|
+
export type TlsSecureContext = tls.SecureContextOptions | tls.SecureContext;
|
|
43
|
+
/**
|
|
44
|
+
* TLS socket for establishing encrypted connections to TLS servers.
|
|
45
|
+
*
|
|
46
|
+
* Unlike {@link TcpSocket}, a TLS connection cannot be established on an
|
|
47
|
+
* existing instance: Node.js creates the socket as part of the handshake. The
|
|
48
|
+
* connection therefore starts from the static {@link TlsSocket.connect}, which
|
|
49
|
+
* resolves only once the handshake completed and the peer certificate has been
|
|
50
|
+
* verified.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* const socket = await TlsSocket.connect(443, { host: "example.com" });
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* The same method upgrades an already-connected plaintext stream, which is what
|
|
57
|
+
* `STARTTLS`-style protocols need. The plaintext transport is destroyed if the
|
|
58
|
+
* handshake fails, so a failed upgrade can never fall back to cleartext.
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* const plain = TcpSocket.from();
|
|
62
|
+
* await plain.connect(587, { host: "mail.example.com" });
|
|
63
|
+
* // ... negotiate STARTTLS over the plaintext connection ...
|
|
64
|
+
* const secure = await TlsSocket.connect(plain.stream, {
|
|
65
|
+
* servername: "mail.example.com",
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* Accessors that report handshake results ({@link TlsSocket.authorized},
|
|
70
|
+
* {@link TlsSocket.getPeerCertificate}, {@link TlsSocket.getCipher}, …) are
|
|
71
|
+
* only meaningful once the handshake completed.
|
|
72
|
+
*/
|
|
73
|
+
export declare class TlsSocket extends InetSocket<tls.TLSSocket, TlsSocketEvents> {
|
|
74
|
+
/**
|
|
75
|
+
* Wraps an existing stream in a TLS socket without waiting for the handshake.
|
|
76
|
+
*
|
|
77
|
+
* The handshake starts immediately and its outcome is reported through the
|
|
78
|
+
* {@link TlsSocketEvents.secureConnect} and {@link StreamSocketEvents.error}
|
|
79
|
+
* events. Prefer {@link TlsSocket.connect}, which reports both through the
|
|
80
|
+
* returned promise; use this method only to drive the handshake manually.
|
|
81
|
+
*
|
|
82
|
+
* @param stream The plaintext stream to encrypt.
|
|
83
|
+
* @param options Options for the underlying Node.js TLS socket.
|
|
84
|
+
* @returns A new `TlsSocket` instance whose handshake is in progress.
|
|
85
|
+
*/
|
|
18
86
|
static from(stream: Duplex, options?: TlsSocketOptions): TlsSocket;
|
|
87
|
+
/**
|
|
88
|
+
* Connects to a TLS server and resolves once the handshake completed.
|
|
89
|
+
*
|
|
90
|
+
* @param port The port to connect to.
|
|
91
|
+
* @param options Connection options, including the host, the secure context
|
|
92
|
+
* and an optional abort signal.
|
|
93
|
+
* @returns A promise that resolves with the connected socket.
|
|
94
|
+
*/
|
|
19
95
|
static connect(port: number, options?: TlsSocketConnectOptions): Promise<TlsSocket>;
|
|
96
|
+
/**
|
|
97
|
+
* Connects to a TLS server listening on a local endpoint and resolves once
|
|
98
|
+
* the handshake completed.
|
|
99
|
+
*
|
|
100
|
+
* @param path Filesystem path of the Unix domain socket, or the name of the
|
|
101
|
+
* Windows named pipe.
|
|
102
|
+
* @param options Connection options, including the secure context and an
|
|
103
|
+
* optional abort signal.
|
|
104
|
+
* @returns A promise that resolves with the connected socket.
|
|
105
|
+
*/
|
|
106
|
+
static connect(path: string, options?: TlsSocketConnectOptions): Promise<TlsSocket>;
|
|
107
|
+
/**
|
|
108
|
+
* Upgrades an already-connected stream to TLS and resolves once the handshake
|
|
109
|
+
* completed.
|
|
110
|
+
*
|
|
111
|
+
* @param stream The plaintext stream to encrypt.
|
|
112
|
+
* @param options Connection options, including the secure context and an
|
|
113
|
+
* optional abort signal.
|
|
114
|
+
* @returns A promise that resolves with the secured socket.
|
|
115
|
+
*/
|
|
116
|
+
static connect(stream: Duplex, options?: TlsSocketConnectOptions): Promise<TlsSocket>;
|
|
117
|
+
/** Always `true`; distinguishes a TLS socket from a plaintext one. */
|
|
20
118
|
get encrypted(): boolean;
|
|
119
|
+
/** Whether the peer certificate was signed by one of the configured CAs. */
|
|
21
120
|
get authorized(): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Reason why the peer certificate was rejected, or `null` when the peer is
|
|
123
|
+
* authorized or the handshake has not completed yet.
|
|
124
|
+
*/
|
|
22
125
|
get authorizationError(): Error | null;
|
|
126
|
+
/**
|
|
127
|
+
* Protocol selected through ALPN, or `null` before the handshake completed
|
|
128
|
+
* and when no protocol was negotiated.
|
|
129
|
+
*/
|
|
23
130
|
get alpnProtocol(): string | null;
|
|
131
|
+
/**
|
|
132
|
+
* Server name requested through SNI, or `null` when the peer sent none.
|
|
133
|
+
*
|
|
134
|
+
* Only set on sockets accepted by a server.
|
|
135
|
+
*/
|
|
136
|
+
get servername(): string | null;
|
|
137
|
+
/**
|
|
138
|
+
* Returns the local certificate, or `null` when none was presented.
|
|
139
|
+
*
|
|
140
|
+
* @returns The local certificate or `null`.
|
|
141
|
+
*/
|
|
24
142
|
getCertificate(): tls.PeerCertificate | null;
|
|
143
|
+
/**
|
|
144
|
+
* Returns the peer certificate, or `null` when the peer presented none.
|
|
145
|
+
*
|
|
146
|
+
* @param detailed Whether to include the full issuer chain.
|
|
147
|
+
* @returns The peer certificate or `null`.
|
|
148
|
+
*/
|
|
149
|
+
getPeerCertificate(detailed: true): tls.DetailedPeerCertificate | null;
|
|
150
|
+
getPeerCertificate(detailed?: false): tls.PeerCertificate | null;
|
|
151
|
+
/**
|
|
152
|
+
* Returns the peer certificate as an `X509Certificate`, or `null` when the
|
|
153
|
+
* peer presented none.
|
|
154
|
+
*
|
|
155
|
+
* @returns The peer certificate or `null`.
|
|
156
|
+
*/
|
|
157
|
+
getPeerX509Certificate(): X509Certificate | null;
|
|
158
|
+
/**
|
|
159
|
+
* Returns the local certificate as an `X509Certificate`, or `null` when none
|
|
160
|
+
* was presented.
|
|
161
|
+
*
|
|
162
|
+
* @returns The local certificate or `null`.
|
|
163
|
+
*/
|
|
164
|
+
getX509Certificate(): X509Certificate | null;
|
|
165
|
+
/**
|
|
166
|
+
* Returns the negotiated cipher suite.
|
|
167
|
+
*
|
|
168
|
+
* @returns The cipher name, standard name and protocol version.
|
|
169
|
+
*/
|
|
25
170
|
getCipher(): tls.CipherNameAndProtocol;
|
|
26
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Returns the type, name and size of the ephemeral key exchange, or `null`
|
|
173
|
+
* when the key exchange was not ephemeral.
|
|
174
|
+
*
|
|
175
|
+
* @returns The ephemeral key information or `null`.
|
|
176
|
+
*/
|
|
177
|
+
getEphemeralKeyInfo(): tls.EphemeralKeyInfo | null;
|
|
178
|
+
/**
|
|
179
|
+
* Returns the latest `Finished` message sent to the peer, or `null` when no
|
|
180
|
+
* handshake completed.
|
|
181
|
+
*
|
|
182
|
+
* @returns The message or `null`.
|
|
183
|
+
*/
|
|
27
184
|
getFinished(): Buffer | null;
|
|
28
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Returns the latest `Finished` message received from the peer, or `null`
|
|
187
|
+
* when no handshake completed.
|
|
188
|
+
*
|
|
189
|
+
* @returns The message or `null`.
|
|
190
|
+
*/
|
|
29
191
|
getPeerFinished(): Buffer | null;
|
|
192
|
+
/**
|
|
193
|
+
* Returns the negotiated protocol version, or `null` before the handshake
|
|
194
|
+
* completed.
|
|
195
|
+
*
|
|
196
|
+
* @returns The protocol version such as `TLSv1.3`, or `null`.
|
|
197
|
+
*/
|
|
30
198
|
getProtocol(): string | null;
|
|
199
|
+
/**
|
|
200
|
+
* Returns the negotiated session, which can be passed back as the `session`
|
|
201
|
+
* connect option to resume it.
|
|
202
|
+
*
|
|
203
|
+
* @returns The session or `null`.
|
|
204
|
+
*/
|
|
31
205
|
getSession(): Buffer | null;
|
|
206
|
+
/**
|
|
207
|
+
* Returns the session ticket, or `null` when the peer issued none.
|
|
208
|
+
*
|
|
209
|
+
* @returns The session ticket or `null`.
|
|
210
|
+
*/
|
|
211
|
+
getTLSTicket(): Buffer | null;
|
|
212
|
+
/**
|
|
213
|
+
* Returns the signature algorithms shared between client and server, in
|
|
214
|
+
* descending order of preference.
|
|
215
|
+
*
|
|
216
|
+
* @returns The shared signature algorithms.
|
|
217
|
+
*/
|
|
32
218
|
getSharedSigalgs(): string[];
|
|
33
|
-
|
|
219
|
+
/**
|
|
220
|
+
* Indicates whether the session was resumed rather than renegotiated.
|
|
221
|
+
*
|
|
222
|
+
* @returns `true` when the session was reused.
|
|
223
|
+
*/
|
|
34
224
|
isSessionReused(): boolean;
|
|
35
|
-
|
|
36
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Keying material for the connection, as defined by RFC 5705.
|
|
227
|
+
*
|
|
228
|
+
* @param length Number of bytes to derive.
|
|
229
|
+
* @param label Application-specific label.
|
|
230
|
+
* @param context Optional application-specific context.
|
|
231
|
+
* @returns The derived keying material.
|
|
232
|
+
*/
|
|
233
|
+
exportKeyingMaterial(length: number, label: string, context?: Buffer): Buffer;
|
|
234
|
+
/**
|
|
235
|
+
* Renegotiates the TLS session and resolves once the new handshake completed.
|
|
236
|
+
*
|
|
237
|
+
* @param options Renegotiation options.
|
|
238
|
+
* @returns A promise that resolves once renegotiation completed.
|
|
239
|
+
* @throws {ConnectionClosedError} When the socket is already destroyed, since
|
|
240
|
+
* Node.js would never invoke the completion callback.
|
|
241
|
+
*/
|
|
242
|
+
renegotiate(options?: TlsSocketRenegotiateOptions): Promise<void>;
|
|
243
|
+
/**
|
|
244
|
+
* Sets the private key and certificate to use for this socket, overriding the
|
|
245
|
+
* ones inherited from the secure context.
|
|
246
|
+
*
|
|
247
|
+
* @param context The secure context or the options to build one from.
|
|
248
|
+
*/
|
|
249
|
+
setKeyCert(context: TlsSecureContext): void;
|
|
250
|
+
/**
|
|
251
|
+
* Sets the maximum TLS fragment size.
|
|
252
|
+
*
|
|
253
|
+
* @param size The maximum fragment size, between 512 and 16384.
|
|
254
|
+
* @returns `true` when the limit was set.
|
|
255
|
+
*/
|
|
37
256
|
setMaxSendFragment(size: number): boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Disables renegotiation. Any further renegotiation attempt by the peer emits
|
|
259
|
+
* an error instead.
|
|
260
|
+
*/
|
|
38
261
|
disableRenegotiation(): void;
|
|
262
|
+
/** Enables OpenSSL trace output on standard error, for debugging. */
|
|
39
263
|
enableTrace(): void;
|
|
40
|
-
getPeerX509Certificate(): X509Certificate | null;
|
|
41
|
-
getX509Certificate(): X509Certificate | null;
|
|
42
|
-
exportKeyingMaterial(length: number, label: string, context: Buffer): Buffer;
|
|
43
264
|
protected setupEventForwarding(): void;
|
|
44
265
|
}
|
|
45
266
|
//# sourceMappingURL=tls-socket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tls-socket.d.ts","sourceRoot":"","sources":["../../src/net/tls-socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,GAAG,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