@agoric/network 0.1.1-dev-e468caa.0 → 0.1.1-dev-8c3395c.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/README.md +4 -4
- package/package.json +9 -9
- package/src/network.js +4 -4
- package/src/router.d.ts +2 -2
- package/src/router.d.ts.map +1 -1
- package/src/router.js +4 -4
- package/src/shapes.d.ts +1 -1
- package/src/shapes.js +1 -1
- package/src/types.d.ts +2 -2
- package/src/types.d.ts.map +1 -1
- package/src/types.js +2 -2
package/README.md
CHANGED
|
@@ -57,15 +57,15 @@ E(home.ibcport[0]).connect(remoteEndpoint, connectionHandler)
|
|
|
57
57
|
|
|
58
58
|
The other side of `connect()` is a "listening port". These ports are waiting for inbound connections to be established.
|
|
59
59
|
|
|
60
|
-
To get a listening port, you need a `NetworkInterface` object (such as the one on your `ag-solo` under `home.network`) and ask it to `
|
|
60
|
+
To get a listening port, you need a `NetworkInterface` object (such as the one on your `ag-solo` under `home.network`) and ask it to `bindPort()` to an endpoint. You can either provide a specific port name, or allow the API to allocate a random one for you. The endpoint specifies the type of connection that this port will be able to accept (IBC, TCP, etc), and some properties of that connection. `bindPort()` uses a "multiaddress" to encode this information.
|
|
61
61
|
|
|
62
62
|
```js
|
|
63
63
|
// ask for a random allocation - ends with a slash
|
|
64
|
-
E(home.network).
|
|
64
|
+
E(home.network).bindPort('/ibc-port/')
|
|
65
65
|
.then(port => usePort(port));
|
|
66
66
|
|
|
67
67
|
// or ask for a specific port name
|
|
68
|
-
E(home.network).
|
|
68
|
+
E(home.network).bindPort('/ibc-port/my-cool-port-name')
|
|
69
69
|
.then(port => usePort(port));
|
|
70
70
|
```
|
|
71
71
|
|
|
@@ -147,7 +147,7 @@ Note that if you want to listen on this port again, you can just call `port.addL
|
|
|
147
147
|
|
|
148
148
|
### Closing the Port Entirely
|
|
149
149
|
|
|
150
|
-
Removing a listener doesn't release the port address to make it available for other `
|
|
150
|
+
Removing a listener doesn't release the port address to make it available for other `bindPort()` requests. You can call:
|
|
151
151
|
|
|
152
152
|
```js
|
|
153
153
|
port.revoke();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/network",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-8c3395c.0+8c3395c",
|
|
4
4
|
"description": "Agoric's network protocol API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
"author": "Agoric",
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@agoric/assert": "0.6.1-dev-
|
|
25
|
-
"@agoric/internal": "0.3.3-dev-
|
|
26
|
-
"@agoric/store": "0.9.3-dev-
|
|
27
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
24
|
+
"@agoric/assert": "0.6.1-dev-8c3395c.0+8c3395c",
|
|
25
|
+
"@agoric/internal": "0.3.3-dev-8c3395c.0+8c3395c",
|
|
26
|
+
"@agoric/store": "0.9.3-dev-8c3395c.0+8c3395c",
|
|
27
|
+
"@agoric/vat-data": "0.5.3-dev-8c3395c.0+8c3395c",
|
|
28
28
|
"@endo/base64": "^1.0.4",
|
|
29
29
|
"@endo/far": "^1.1.1",
|
|
30
30
|
"@endo/patterns": "^1.3.1",
|
|
31
31
|
"@endo/promise-kit": "^1.1.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
35
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
36
|
-
"@agoric/zone": "0.2.3-dev-
|
|
34
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-8c3395c.0+8c3395c",
|
|
35
|
+
"@agoric/swingset-vat": "0.32.3-dev-8c3395c.0+8c3395c",
|
|
36
|
+
"@agoric/zone": "0.2.3-dev-8c3395c.0+8c3395c",
|
|
37
37
|
"@endo/bundle-source": "^3.2.2",
|
|
38
38
|
"ava": "^5.3.0",
|
|
39
39
|
"c8": "^9.1.0"
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"typeCoverage": {
|
|
71
71
|
"atLeast": 89.74
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "8c3395c882c738af46f68cdd7265a6a0c3b14091"
|
|
74
74
|
}
|
package/src/network.js
CHANGED
|
@@ -652,7 +652,7 @@ const prepareBinder = (zone, powers) => {
|
|
|
652
652
|
{
|
|
653
653
|
protocolImpl: Shape.ProtocolImplI,
|
|
654
654
|
binder: M.interface('Binder', {
|
|
655
|
-
|
|
655
|
+
bindPort: M.callWhen(Shape.Endpoint).returns(Shape.Vow$(Shape.Port)),
|
|
656
656
|
}),
|
|
657
657
|
binderInboundInstantiateWatcher: M.interface(
|
|
658
658
|
'BinderInboundInstantiateWatcher',
|
|
@@ -840,13 +840,13 @@ const prepareBinder = (zone, powers) => {
|
|
|
840
840
|
localAddr,
|
|
841
841
|
});
|
|
842
842
|
},
|
|
843
|
-
async
|
|
844
|
-
return this.facets.binder.
|
|
843
|
+
async bindPort(localAddr) {
|
|
844
|
+
return this.facets.binder.bindPort(localAddr);
|
|
845
845
|
},
|
|
846
846
|
},
|
|
847
847
|
binder: {
|
|
848
848
|
/** @param {string} localAddr */
|
|
849
|
-
async
|
|
849
|
+
async bindPort(localAddr) {
|
|
850
850
|
const { protocolHandler } = this.state;
|
|
851
851
|
|
|
852
852
|
// Check if we are underspecified (ends in slash)
|
package/src/router.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export function prepareRouterProtocol(zone: import('@agoric/base-zone').Zone, po
|
|
|
56
56
|
*/
|
|
57
57
|
unregisterProtocolHandler(prefix: string, protocolHandler: Remote<ProtocolHandler>): void;
|
|
58
58
|
/** @param {Endpoint} localAddr */
|
|
59
|
-
|
|
59
|
+
bindPort(localAddr: Endpoint): Promise<Port | import("@agoric/vow").Vow<Port>>;
|
|
60
60
|
}>;
|
|
61
61
|
/**
|
|
62
62
|
* A delimited string router implementation
|
|
@@ -79,7 +79,7 @@ export type Router<T> = {
|
|
|
79
79
|
unregister: (prefix: string, route: T) => void;
|
|
80
80
|
};
|
|
81
81
|
export type RouterProtocol = {
|
|
82
|
-
|
|
82
|
+
bindPort: (prefix: string) => PromiseVow<Port>;
|
|
83
83
|
registerProtocolHandler: (paths: string[], protocolHandler: ProtocolHandler) => void;
|
|
84
84
|
unregisterProtocolHandler: (prefix: string, protocolHandler: ProtocolHandler) => void;
|
|
85
85
|
};
|
package/src/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["router.js"],"names":[],"mappings":"AAUA;;;;;;;;;GASG;AAEH;;;;GAIG;AAMI,uCAFI,OAAO,mBAAmB,EAAE,IAAI;IAiBrC,6BAA6B;oBAAjB,QAAQ;IAyBpB;;;OAGG;qBAFQ,MAAM;IAMjB;;;OAGG;uBAFQ,MAAM;GAYtB;AAgBM,4CAJI,OAAO,mBAAmB,EAAE,IAAI,UAChC;;;;;;;;EAAiD;;;;;;;;;;IAoCtD;;;OAGG;mCAFQ,MAAM,EAAE,mBACR,OAAO,eAAe,CAAC;IAYlC;;;OAGG;sCAFQ,MAAM,mBACN,OAAO,eAAe,CAAC;IAclC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["router.js"],"names":[],"mappings":"AAUA;;;;;;;;;GASG;AAEH;;;;GAIG;AAMI,uCAFI,OAAO,mBAAmB,EAAE,IAAI;IAiBrC,6BAA6B;oBAAjB,QAAQ;IAyBpB;;;OAGG;qBAFQ,MAAM;IAMjB;;;OAGG;uBAFQ,MAAM;GAYtB;AAgBM,4CAJI,OAAO,mBAAmB,EAAE,IAAI,UAChC;;;;;;;;EAAiD;;;;;;;;;;IAoCtD;;;OAGG;mCAFQ,MAAM,EAAE,mBACR,OAAO,eAAe,CAAC;IAYlC;;;OAGG;sCAFQ,MAAM,mBACN,OAAO,eAAe,CAAC;IAclC,kCAAkC;wBAAtB,QAAQ;GAUzB;;;;;;;;;eAvKa,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE;;;;;cAE/B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI;;;;;gBAElC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI;;;cA8ElC,CAAC,MAAM,EAAE,MAAM,KAAK,WAAW,IAAI,CAAC;6BACpC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,eAAe,KAAK,IAAI;+BAC3D,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,KAAK,IAAI"}
|
package/src/router.js
CHANGED
|
@@ -93,7 +93,7 @@ export const prepareRouter = zone => {
|
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* @typedef {object} RouterProtocol
|
|
96
|
-
* @property {(prefix: string) => PromiseVow<Port>}
|
|
96
|
+
* @property {(prefix: string) => PromiseVow<Port>} bindPort
|
|
97
97
|
* @property {(paths: string[], protocolHandler: ProtocolHandler) => void} registerProtocolHandler
|
|
98
98
|
* @property {(prefix: string, protocolHandler: ProtocolHandler) => void} unregisterProtocolHandler
|
|
99
99
|
*/
|
|
@@ -119,7 +119,7 @@ export const prepareRouterProtocol = (zone, powers, E = defaultE) => {
|
|
|
119
119
|
M.remotable(),
|
|
120
120
|
).returns(),
|
|
121
121
|
unregisterProtocolHandler: M.call(M.string(), M.remotable()).returns(),
|
|
122
|
-
|
|
122
|
+
bindPort: M.callWhen(Shape.Endpoint).returns(Shape.Vow$(Shape.Port)),
|
|
123
123
|
}),
|
|
124
124
|
() => {
|
|
125
125
|
/** @type {Router<Protocol>} */
|
|
@@ -169,10 +169,10 @@ export const prepareRouterProtocol = (zone, powers, E = defaultE) => {
|
|
|
169
169
|
this.state.protocolHandlers.delete(prefix);
|
|
170
170
|
},
|
|
171
171
|
/** @param {Endpoint} localAddr */
|
|
172
|
-
async
|
|
172
|
+
async bindPort(localAddr) {
|
|
173
173
|
const [route] = this.state.router.getRoutes(localAddr);
|
|
174
174
|
route !== undefined || Fail`No registered router for ${localAddr}`;
|
|
175
|
-
return E(route[1]).
|
|
175
|
+
return E(route[1]).bindPort(localAddr);
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
178
|
);
|
package/src/shapes.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export namespace Shape {
|
|
|
94
94
|
export { rethrowUnlessMissingWatcher_3 as rethrowUnlessMissingWatcher };
|
|
95
95
|
}
|
|
96
96
|
let ProtocolImplI: import("@endo/patterns").InterfaceGuard<{
|
|
97
|
-
|
|
97
|
+
bindPort: import("@endo/patterns").MethodGuard;
|
|
98
98
|
inbound: import("@endo/patterns").MethodGuard;
|
|
99
99
|
outbound: import("@endo/patterns").MethodGuard;
|
|
100
100
|
}>;
|
package/src/shapes.js
CHANGED
|
@@ -178,7 +178,7 @@ export const Shape = /** @type {const} */ harden({
|
|
|
178
178
|
},
|
|
179
179
|
|
|
180
180
|
ProtocolImplI: M.interface('ProtocolImpl', {
|
|
181
|
-
|
|
181
|
+
bindPort: M.callWhen(Shape2.Endpoint).returns(Shape2.Vow$(Shape2.Port)),
|
|
182
182
|
inbound: M.callWhen(Shape2.Endpoint, Shape2.Endpoint).returns(
|
|
183
183
|
Shape2.Vow$(Shape2.InboundAttempt),
|
|
184
184
|
),
|
package/src/types.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ type Protocol = {
|
|
|
33
33
|
* Claim a port, or if
|
|
34
34
|
* ending in ENDPOINT_SEPARATOR, a fresh name
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
bindPort: (prefix: Endpoint) => PromiseVow<Port>;
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
39
|
* A port that has been bound to a protocol
|
|
@@ -202,7 +202,7 @@ type ProtocolImpl = {
|
|
|
202
202
|
* Claim a port, or if
|
|
203
203
|
* ending in ENDPOINT_SEPARATOR, a fresh name
|
|
204
204
|
*/
|
|
205
|
-
|
|
205
|
+
bindPort: (prefix: Endpoint) => PromiseVow<Remote<Port>>;
|
|
206
206
|
/**
|
|
207
207
|
* Make an attempt to connect into this protocol
|
|
208
208
|
*/
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":"qBAIa,OAAO,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC;iBAKnC,OAAO,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;;;;gFAKpB,GAAG,EAAE,KAAK,GAAG,IACxB,CAAC,GAAG,SAAS;IAAE,IAAI,EAAE,OAAO,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAA;CAAE,CAAC;;;;aAK5E,MAAM;;;;;gBAIN,MAAM;;;;;;;;WAML,MAAM,WAAW,IAAI,CAAC;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":"qBAIa,OAAO,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC;iBAKnC,OAAO,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;;;;gFAKpB,GAAG,EAAE,KAAK,GAAG,IACxB,CAAC,GAAG,SAAS;IAAE,IAAI,EAAE,OAAO,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAA;CAAE,CAAC;;;;aAK5E,MAAM;;;;;gBAIN,MAAM;;;;;;;;WAML,MAAM,WAAW,IAAI,CAAC;;;;;;;;;;cAKtB,CAAC,MAAM,EAAE,QAAQ,KAAK,WAAW,IAAI,CAAC;;;;;;;;;;qBAMtC,MAAM,Q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AAK,EAAE,OAAO,eAAe,CAAC,KACvB,WAAW,IAAI,CAAC;;;;;;;;;YAIV,CAAC,IAAI,EAAE,kBAAkB,KAAK,WAAW,UAAU,CAAC;;;;;qBAEpD,MAAM,QAAQ;;;;;sBAEd,MAAM,QAAQ;;;;WAEd,MAAM,WAAW,IAAI,CAAC;;;;;;;;;;cAGtB,CAAC,MAAM,EAAE,QAAQ,KAAK,WAAW,OAAO,IAAI,CAAC,CAAC;;;;aAE9C,CACb,UAAc,EAAE,QAAQ,EACxB,UAAc,EAAE,QAAQ,KACjB,WAAW,cAAc,CAAC;;;;cAEpB,CACb,IAAQ,EAAE,OAAO,IAAI,CAAC,EACtB,UAAc,EAAE,QAAQ,EACxB,iBAAqB,EAAE,OAAO,iBAAiB,CAAC,KACzC,WAAW,UAAU,CAAC"}
|
package/src/types.js
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* @typedef {object} Protocol The network Protocol
|
|
36
|
-
* @property {(prefix: Endpoint) => PromiseVow<Port>}
|
|
36
|
+
* @property {(prefix: Endpoint) => PromiseVow<Port>} bindPort Claim a port, or if
|
|
37
37
|
* ending in ENDPOINT_SEPARATOR, a fresh name
|
|
38
38
|
*/
|
|
39
39
|
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
* @property {() => PromiseVow<void>} close Abort the attempt
|
|
183
183
|
*
|
|
184
184
|
* @typedef {object} ProtocolImpl Things the protocol can do for us
|
|
185
|
-
* @property {(prefix: Endpoint) => PromiseVow<Remote<Port>>}
|
|
185
|
+
* @property {(prefix: Endpoint) => PromiseVow<Remote<Port>>} bindPort Claim a port, or if
|
|
186
186
|
* ending in ENDPOINT_SEPARATOR, a fresh name
|
|
187
187
|
* @property {(
|
|
188
188
|
* listenAddr: Endpoint,
|