@fuman/net 0.0.1 → 0.0.3
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/package.json +3 -3
- package/types.d.ts +16 -0
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuman/net",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"description": "experimental network abstractions",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@fuman/io": "^0.0.
|
|
10
|
-
"@fuman/utils": "^0.0.
|
|
9
|
+
"@fuman/io": "^0.0.3",
|
|
10
|
+
"@fuman/utils": "^0.0.3"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
package/types.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { IClosable, IReadable, IWritable } from '@fuman/io';
|
|
2
2
|
export interface IConnection<Address, LocalAddress = Address> extends IReadable, IWritable, IClosable {
|
|
3
|
+
/** local address of the connection (if available) */
|
|
3
4
|
readonly localAddress: LocalAddress | null;
|
|
5
|
+
/** remote address of the connection (if available) */
|
|
4
6
|
readonly remoteAddress: Address | null;
|
|
5
7
|
}
|
|
8
|
+
/** a TCP endpoint */
|
|
6
9
|
export interface TcpEndpoint {
|
|
10
|
+
/** address of the endpoint */
|
|
7
11
|
readonly address: string;
|
|
12
|
+
/** port of the endpoint */
|
|
8
13
|
readonly port: number;
|
|
9
14
|
}
|
|
15
|
+
/** common TLS options */
|
|
10
16
|
export interface TlsOptions {
|
|
11
17
|
/**
|
|
12
18
|
* List of CA certificates to use.
|
|
@@ -18,22 +24,32 @@ export interface TlsOptions {
|
|
|
18
24
|
/** Hostname to use for SNI */
|
|
19
25
|
readonly sni?: string;
|
|
20
26
|
}
|
|
27
|
+
/** TLS options for connecting to an endpoint */
|
|
21
28
|
export interface TlsConnectOptions extends TcpEndpoint, TlsOptions {
|
|
22
29
|
}
|
|
30
|
+
/** TLS options for listening on an endpoint */
|
|
23
31
|
export interface TlsListenOptions extends TcpEndpoint, TlsOptions {
|
|
24
32
|
readonly key?: string;
|
|
25
33
|
readonly cert?: string;
|
|
26
34
|
readonly hosts?: Omit<this, 'hosts' | 'address' | 'port'>[];
|
|
27
35
|
}
|
|
36
|
+
/** a TCP connection */
|
|
28
37
|
export interface ITcpConnection extends IConnection<TcpEndpoint> {
|
|
38
|
+
/** set no-delay flag on the connection */
|
|
29
39
|
setNoDelay: (noDelay: boolean) => void;
|
|
40
|
+
/** set keep-alive flag on the connection */
|
|
30
41
|
setKeepAlive: (keepAlive: boolean) => void;
|
|
31
42
|
}
|
|
43
|
+
/** a TLS connection */
|
|
32
44
|
export interface ITlsConnection extends ITcpConnection {
|
|
45
|
+
/** get the ALPN protocol that was negotiated in the handshake */
|
|
33
46
|
getAlpnProtocol: () => string | null;
|
|
34
47
|
}
|
|
48
|
+
/** a listener for connections */
|
|
35
49
|
export interface IListener<Address, Connection extends IConnection<Address> = IConnection<Address>> extends IClosable {
|
|
50
|
+
/** address of the listener (if available) */
|
|
36
51
|
readonly address: Address | null;
|
|
52
|
+
/** accept a new connection */
|
|
37
53
|
accept: () => Promise<Connection>;
|
|
38
54
|
}
|
|
39
55
|
export type ListenFunction<Options, Listener extends IListener<unknown>> = (options: Options) => Promise<Listener>;
|