@agoric/network 0.1.1-dev-7ffae88.0 → 0.1.1-orchestration-dev-096c4e8.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/package.json +14 -10
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/network.d.ts +130 -28
- package/src/network.d.ts.map +1 -1
- package/src/network.js +869 -426
- package/src/router.d.ts +42 -22
- package/src/router.d.ts.map +1 -1
- package/src/router.js +147 -77
- package/src/types.d.ts +29 -28
- package/src/types.d.ts.map +1 -1
- package/src/types.js +36 -29
- package/tsconfig.json +1 -0
- package/typedoc.json +9 -0
package/src/types.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @template T
|
|
5
|
+
* @typedef {Promise<T | import('@agoric/vow').Vow<T>>} PromiseVow
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* @typedef {string | Buffer | ArrayBuffer} Data
|
|
3
10
|
*
|
|
@@ -11,12 +18,12 @@
|
|
|
11
18
|
|
|
12
19
|
/**
|
|
13
20
|
* @typedef {object} Closable A closable object
|
|
14
|
-
* @property {() =>
|
|
21
|
+
* @property {() => PromiseVow<void>} close Terminate the object
|
|
15
22
|
*/
|
|
16
23
|
|
|
17
24
|
/**
|
|
18
25
|
* @typedef {object} Protocol The network Protocol
|
|
19
|
-
* @property {(prefix: Endpoint) =>
|
|
26
|
+
* @property {(prefix: Endpoint) => PromiseVow<Port>} bind Claim a port, or if
|
|
20
27
|
* ending in ENDPOINT_SEPARATOR, a fresh name
|
|
21
28
|
*/
|
|
22
29
|
|
|
@@ -24,14 +31,14 @@
|
|
|
24
31
|
* @typedef {object} Port A port that has been bound to a protocol
|
|
25
32
|
* @property {() => Endpoint} getLocalAddress Get the locally bound name of this
|
|
26
33
|
* port
|
|
27
|
-
* @property {(acceptHandler: ListenHandler) =>
|
|
34
|
+
* @property {(acceptHandler: ListenHandler) => PromiseVow<void>} addListener
|
|
28
35
|
* Begin accepting incoming connections
|
|
29
36
|
* @property {(
|
|
30
37
|
* remote: Endpoint,
|
|
31
38
|
* connectionHandler?: ConnectionHandler,
|
|
32
|
-
* ) =>
|
|
39
|
+
* ) => PromiseVow<Connection>} connect
|
|
33
40
|
* Make an outbound connection
|
|
34
|
-
* @property {(acceptHandler: ListenHandler) =>
|
|
41
|
+
* @property {(acceptHandler: ListenHandler) => PromiseVow<void>} removeListener
|
|
35
42
|
* Remove the currently-bound listener
|
|
36
43
|
* @property {() => void} revoke Deallocate the port entirely, removing all
|
|
37
44
|
* listeners and closing all active connections
|
|
@@ -39,25 +46,25 @@
|
|
|
39
46
|
|
|
40
47
|
/**
|
|
41
48
|
* @typedef {object} ListenHandler A handler for incoming connections
|
|
42
|
-
* @property {(port: Port, l: ListenHandler) =>
|
|
49
|
+
* @property {(port: Port, l: ListenHandler) => PromiseVow<void>} [onListen] The
|
|
43
50
|
* listener has been registered
|
|
44
51
|
* @property {(
|
|
45
52
|
* port: Port,
|
|
46
53
|
* localAddr: Endpoint,
|
|
47
54
|
* remoteAddr: Endpoint,
|
|
48
55
|
* l: ListenHandler,
|
|
49
|
-
* ) =>
|
|
56
|
+
* ) => PromiseVow<ConnectionHandler>} onAccept
|
|
50
57
|
* A new connection is incoming
|
|
51
58
|
* @property {(
|
|
52
59
|
* port: Port,
|
|
53
60
|
* localAddr: Endpoint,
|
|
54
61
|
* remoteAddr: Endpoint,
|
|
55
62
|
* l: ListenHandler,
|
|
56
|
-
* ) =>
|
|
63
|
+
* ) => PromiseVow<void>} [onReject]
|
|
57
64
|
* The connection was rejected
|
|
58
|
-
* @property {(port: Port, rej: any, l: ListenHandler) =>
|
|
65
|
+
* @property {(port: Port, rej: any, l: ListenHandler) => PromiseVow<void>} [onError]
|
|
59
66
|
* There was an error while listening
|
|
60
|
-
* @property {(port: Port, l: ListenHandler) =>
|
|
67
|
+
* @property {(port: Port, l: ListenHandler) => PromiseVow<void>} [onRemove] The
|
|
61
68
|
* listener has been removed
|
|
62
69
|
*/
|
|
63
70
|
|
|
@@ -66,9 +73,9 @@
|
|
|
66
73
|
* @property {(
|
|
67
74
|
* packetBytes: Data,
|
|
68
75
|
* opts?: Record<string, any>,
|
|
69
|
-
* ) =>
|
|
76
|
+
* ) => PromiseVow<Bytes>} send
|
|
70
77
|
* Send a packet on the connection
|
|
71
|
-
* @property {() =>
|
|
78
|
+
* @property {() => PromiseVow<void>} close Close both ends of the connection
|
|
72
79
|
* @property {() => Endpoint} getLocalAddress Get the locally bound name of this
|
|
73
80
|
* connection
|
|
74
81
|
* @property {() => Endpoint} getRemoteAddress Get the name of the counterparty
|
|
@@ -81,20 +88,20 @@
|
|
|
81
88
|
* localAddr: Endpoint,
|
|
82
89
|
* remoteAddr: Endpoint,
|
|
83
90
|
* c: ConnectionHandler,
|
|
84
|
-
* ) => void} [onOpen]
|
|
91
|
+
* ) => PromiseVow<void>} [onOpen]
|
|
85
92
|
* The connection has been opened
|
|
86
93
|
* @property {(
|
|
87
94
|
* connection: Connection,
|
|
88
|
-
*
|
|
95
|
+
* ack: Bytes,
|
|
89
96
|
* c: ConnectionHandler,
|
|
90
97
|
* opts?: Record<string, any>,
|
|
91
|
-
* ) =>
|
|
98
|
+
* ) => PromiseVow<Data>} [onReceive]
|
|
92
99
|
* The connection received a packet
|
|
93
100
|
* @property {(
|
|
94
101
|
* connection: Connection,
|
|
95
102
|
* reason?: CloseReason,
|
|
96
103
|
* c?: ConnectionHandler,
|
|
97
|
-
* ) =>
|
|
104
|
+
* ) => PromiseVow<void>} [onClose]
|
|
98
105
|
* The connection has been closed
|
|
99
106
|
*
|
|
100
107
|
* @typedef {any | null} CloseReason The reason a connection was closed
|
|
@@ -110,36 +117,36 @@
|
|
|
110
117
|
/**
|
|
111
118
|
* @typedef {object} ProtocolHandler A handler for things the protocol
|
|
112
119
|
* implementation will invoke
|
|
113
|
-
* @property {(protocol: ProtocolImpl, p: ProtocolHandler) =>
|
|
120
|
+
* @property {(protocol: ProtocolImpl, p: ProtocolHandler) => PromiseVow<void>} onCreate
|
|
114
121
|
* This protocol is created
|
|
115
|
-
* @property {(localAddr: Endpoint, p: ProtocolHandler) =>
|
|
122
|
+
* @property {(localAddr: Endpoint, p: ProtocolHandler) => PromiseVow<string>} generatePortID
|
|
116
123
|
* Create a fresh port identifier for this protocol
|
|
117
124
|
* @property {(
|
|
118
125
|
* port: Port,
|
|
119
126
|
* localAddr: Endpoint,
|
|
120
127
|
* p: ProtocolHandler,
|
|
121
|
-
* ) =>
|
|
128
|
+
* ) => PromiseVow<void>} onBind
|
|
122
129
|
* A port will be bound
|
|
123
130
|
* @property {(
|
|
124
131
|
* port: Port,
|
|
125
132
|
* localAddr: Endpoint,
|
|
126
133
|
* listenHandler: ListenHandler,
|
|
127
134
|
* p: ProtocolHandler,
|
|
128
|
-
* ) =>
|
|
135
|
+
* ) => PromiseVow<void>} onListen
|
|
129
136
|
* A port was listening
|
|
130
137
|
* @property {(
|
|
131
138
|
* port: Port,
|
|
132
139
|
* localAddr: Endpoint,
|
|
133
140
|
* listenHandler: ListenHandler,
|
|
134
141
|
* p: ProtocolHandler,
|
|
135
|
-
* ) =>
|
|
142
|
+
* ) => PromiseVow<void>} onListenRemove
|
|
136
143
|
* A port listener has been reset
|
|
137
144
|
* @property {(
|
|
138
145
|
* port: Port,
|
|
139
146
|
* localAddr: Endpoint,
|
|
140
147
|
* remote: Endpoint,
|
|
141
148
|
* p: ProtocolHandler,
|
|
142
|
-
* ) =>
|
|
149
|
+
* ) => PromiseVow<Endpoint>} [onInstantiate]
|
|
143
150
|
* Return unique suffix for local address
|
|
144
151
|
* @property {(
|
|
145
152
|
* port: Port,
|
|
@@ -147,36 +154,36 @@
|
|
|
147
154
|
* remote: Endpoint,
|
|
148
155
|
* c: ConnectionHandler,
|
|
149
156
|
* p: ProtocolHandler,
|
|
150
|
-
* ) =>
|
|
157
|
+
* ) => PromiseVow<AttemptDescription>} onConnect
|
|
151
158
|
* A port initiates an outbound connection
|
|
152
159
|
* @property {(
|
|
153
160
|
* port: Port,
|
|
154
161
|
* localAddr: Endpoint,
|
|
155
162
|
* p: ProtocolHandler,
|
|
156
|
-
* ) =>
|
|
163
|
+
* ) => PromiseVow<void>} onRevoke
|
|
157
164
|
* The port is being completely destroyed
|
|
158
165
|
*
|
|
159
166
|
* @typedef {object} InboundAttempt An inbound connection attempt
|
|
160
|
-
* @property {(desc: AttemptDescription) =>
|
|
167
|
+
* @property {(desc: AttemptDescription) => PromiseVow<Connection>} accept
|
|
161
168
|
* Establish the connection
|
|
162
169
|
* @property {() => Endpoint} getLocalAddress Return the local address for this
|
|
163
170
|
* attempt
|
|
164
171
|
* @property {() => Endpoint} getRemoteAddress Return the remote address for
|
|
165
172
|
* this attempt
|
|
166
|
-
* @property {() =>
|
|
173
|
+
* @property {() => PromiseVow<void>} close Abort the attempt
|
|
167
174
|
*
|
|
168
175
|
* @typedef {object} ProtocolImpl Things the protocol can do for us
|
|
169
|
-
* @property {(prefix: Endpoint) =>
|
|
176
|
+
* @property {(prefix: Endpoint) => PromiseVow<Port>} bind Claim a port, or if
|
|
170
177
|
* ending in ENDPOINT_SEPARATOR, a fresh name
|
|
171
178
|
* @property {(
|
|
172
179
|
* listenAddr: Endpoint,
|
|
173
180
|
* remoteAddr: Endpoint,
|
|
174
|
-
* ) =>
|
|
181
|
+
* ) => PromiseVow<InboundAttempt>} inbound
|
|
175
182
|
* Make an attempt to connect into this protocol
|
|
176
183
|
* @property {(
|
|
177
184
|
* port: Port,
|
|
178
185
|
* remoteAddr: Endpoint,
|
|
179
186
|
* connectionHandler: ConnectionHandler,
|
|
180
|
-
* ) =>
|
|
187
|
+
* ) => PromiseVow<Connection>} outbound
|
|
181
188
|
* Create an outbound connection
|
|
182
189
|
*/
|
package/tsconfig.json
CHANGED