@agoric/network 0.1.1-orchestration-dev-096c4e8.0 → 0.1.1-other-dev-3eb1a1d.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 -7
- package/package.json +24 -26
- package/src/bytes.d.ts +23 -6
- package/src/bytes.d.ts.map +1 -1
- package/src/bytes.js +63 -26
- package/src/index.d.ts +2 -0
- package/src/index.js +3 -0
- package/src/multiaddr.d.ts.map +1 -1
- package/src/network.d.ts +85 -83
- package/src/network.d.ts.map +1 -1
- package/src/network.js +1100 -514
- package/src/router.d.ts +23 -21
- package/src/router.d.ts.map +1 -1
- package/src/router.js +22 -19
- package/src/shapes.d.ts +117 -0
- package/src/shapes.d.ts.map +1 -0
- package/src/shapes.js +191 -0
- package/src/types.d.ts +54 -42
- package/src/types.d.ts.map +1 -1
- package/src/types.js +63 -50
- package/exported.js +0 -1
- package/tsconfig.build.json +0 -6
- package/tsconfig.json +0 -14
- package/typedoc.json +0 -9
package/README.md
CHANGED
|
@@ -57,15 +57,12 @@ 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
|
|
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 for a port, via the `PortAllocator`.
|
|
61
61
|
|
|
62
62
|
```js
|
|
63
63
|
// ask for a random allocation - ends with a slash
|
|
64
|
-
E(home.network).
|
|
65
|
-
.then(
|
|
66
|
-
|
|
67
|
-
// or ask for a specific port name
|
|
68
|
-
E(home.network).bind('/ibc-port/my-cool-port-name')
|
|
64
|
+
E(home.network).getPortAllocator()
|
|
65
|
+
.then(portAllocator => E(portAllocator).allocateCustomIBCPort())
|
|
69
66
|
.then(port => usePort(port));
|
|
70
67
|
```
|
|
71
68
|
|
|
@@ -147,7 +144,7 @@ Note that if you want to listen on this port again, you can just call `port.addL
|
|
|
147
144
|
|
|
148
145
|
### Closing the Port Entirely
|
|
149
146
|
|
|
150
|
-
Removing a listener doesn't release the port address to make it available for other `
|
|
147
|
+
Removing a listener doesn't release the port address to make it available for other `PortAllocator` requests. You can call:
|
|
151
148
|
|
|
152
149
|
```js
|
|
153
150
|
port.revoke();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/network",
|
|
3
|
-
"version": "0.1.1-
|
|
3
|
+
"version": "0.1.1-other-dev-3eb1a1d.0+3eb1a1d",
|
|
4
4
|
"description": "Agoric's network protocol API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "exit 0",
|
|
10
10
|
"prepack": "tsc --build tsconfig.build.json",
|
|
11
|
-
"postpack": "git clean -f '*.d.ts*'",
|
|
11
|
+
"postpack": "git clean -f '*.d.ts*' '*.tsbuildinfo'",
|
|
12
12
|
"test": "ava",
|
|
13
|
-
"test:c8": "c8 $C8_OPTIONS ava",
|
|
13
|
+
"test:c8": "c8 --all $C8_OPTIONS ava",
|
|
14
14
|
"test:xs": "exit 0",
|
|
15
15
|
"lint-fix": "yarn lint:eslint --fix",
|
|
16
16
|
"lint": "run-s --continue-on-error lint:*",
|
|
@@ -21,45 +21,43 @@
|
|
|
21
21
|
"author": "Agoric",
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@agoric/
|
|
25
|
-
"@agoric/
|
|
26
|
-
"@agoric/
|
|
27
|
-
"@
|
|
28
|
-
"@endo/
|
|
29
|
-
"@endo/far": "^1.
|
|
30
|
-
"@endo/
|
|
31
|
-
"@endo/
|
|
24
|
+
"@agoric/internal": "0.3.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
25
|
+
"@agoric/store": "0.9.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
26
|
+
"@agoric/vat-data": "0.5.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
27
|
+
"@endo/base64": "^1.0.9",
|
|
28
|
+
"@endo/errors": "^1.2.8",
|
|
29
|
+
"@endo/far": "^1.1.9",
|
|
30
|
+
"@endo/pass-style": "^1.4.7",
|
|
31
|
+
"@endo/patterns": "^1.4.7",
|
|
32
|
+
"@endo/promise-kit": "^1.1.8"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"@agoric/swingset-liveslots": "0.10.3-
|
|
35
|
-
"@agoric/swingset-vat": "0.32.3-
|
|
36
|
-
"@agoric/
|
|
37
|
-
"@
|
|
35
|
+
"@agoric/swingset-liveslots": "0.10.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
36
|
+
"@agoric/swingset-vat": "0.32.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
37
|
+
"@agoric/vow": "0.1.1-other-dev-3eb1a1d.0+3eb1a1d",
|
|
38
|
+
"@agoric/zone": "0.2.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
39
|
+
"@endo/bundle-source": "^3.5.0",
|
|
38
40
|
"ava": "^5.3.0",
|
|
39
|
-
"c8": "^
|
|
41
|
+
"c8": "^10.1.2"
|
|
40
42
|
},
|
|
41
43
|
"exports": {
|
|
42
|
-
".": "./src/index.js"
|
|
43
|
-
"./exported.js": "./exported.js"
|
|
44
|
+
".": "./src/index.js"
|
|
44
45
|
},
|
|
45
46
|
"files": [
|
|
46
47
|
"CHANGELOG.md",
|
|
47
48
|
"src/",
|
|
48
49
|
"scripts/",
|
|
49
|
-
"tools/"
|
|
50
|
-
"*.json",
|
|
51
|
-
"globals.d.ts",
|
|
52
|
-
"exported.js"
|
|
50
|
+
"tools/"
|
|
53
51
|
],
|
|
54
52
|
"publishConfig": {
|
|
55
53
|
"access": "public"
|
|
56
54
|
},
|
|
57
55
|
"engines": {
|
|
58
|
-
"node": "
|
|
56
|
+
"node": "^18.12 || ^20.9"
|
|
59
57
|
},
|
|
60
58
|
"ava": {
|
|
61
59
|
"files": [
|
|
62
|
-
"test
|
|
60
|
+
"test/**/*.test.*"
|
|
63
61
|
],
|
|
64
62
|
"require": [
|
|
65
63
|
"@endo/init/debug.js"
|
|
@@ -68,7 +66,7 @@
|
|
|
68
66
|
"workerThreads": false
|
|
69
67
|
},
|
|
70
68
|
"typeCoverage": {
|
|
71
|
-
"atLeast":
|
|
69
|
+
"atLeast": 91.16
|
|
72
70
|
},
|
|
73
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "3eb1a1d2d75b2b4a94807cd3bf759bc9fc531f05"
|
|
74
72
|
}
|
package/src/bytes.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @import {Bytes} from './types.js';
|
|
3
|
+
*/
|
|
4
|
+
/** @typedef {Bytes | Buffer | Uint8Array | Iterable<number>} ByteSource */
|
|
5
|
+
/**
|
|
6
|
+
* This function is a coercer instead of an asserter because in a future where
|
|
7
|
+
* binary data has better support across vats and potentially its own type, we
|
|
8
|
+
* might allow more `specimen`s than just `ByteSource`.
|
|
9
|
+
*
|
|
10
|
+
* @param {unknown} specimen
|
|
11
|
+
* @returns {ByteSource}
|
|
12
|
+
*/
|
|
13
|
+
export function coerceToByteSource(specimen: unknown): ByteSource;
|
|
14
|
+
/**
|
|
15
|
+
* Convert a Uint8Array or other sequence of octets to a string representation
|
|
16
|
+
* that `@endo/marshal` accepts as Passable.
|
|
3
17
|
*
|
|
4
|
-
* @param {
|
|
18
|
+
* @param {ByteSource} byteSource
|
|
5
19
|
* @returns {Bytes}
|
|
6
20
|
*/
|
|
7
|
-
export function toBytes(
|
|
21
|
+
export function toBytes(byteSource: ByteSource): Bytes;
|
|
8
22
|
/**
|
|
9
23
|
* Convert bytes to a String.
|
|
10
24
|
*
|
|
@@ -15,15 +29,18 @@ export function bytesToString(bytes: Bytes): string;
|
|
|
15
29
|
/**
|
|
16
30
|
* Base64, as specified in https://tools.ietf.org/html/rfc4648#section-4
|
|
17
31
|
*
|
|
18
|
-
* @param {
|
|
32
|
+
* @param {ByteSource} byteSource
|
|
19
33
|
* @returns {string} base64 encoding
|
|
20
34
|
*/
|
|
21
|
-
export function
|
|
35
|
+
export function byteSourceToBase64(byteSource: ByteSource): string;
|
|
22
36
|
/**
|
|
23
|
-
* Decodes a string into
|
|
37
|
+
* Decodes a base64 string into bytes.
|
|
24
38
|
*
|
|
25
39
|
* @param {string} string Base64-encoded string
|
|
26
40
|
* @returns {Bytes} decoded bytes
|
|
27
41
|
*/
|
|
28
42
|
export function base64ToBytes(string: string): Bytes;
|
|
43
|
+
export type ByteSource = Bytes | Buffer | Uint8Array | Iterable<number>;
|
|
44
|
+
import type { Bytes } from './types.js';
|
|
45
|
+
import type { Bytes as Bytes_1 } from './types.js';
|
|
29
46
|
//# sourceMappingURL=bytes.d.ts.map
|
package/src/bytes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["bytes.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["bytes.js"],"names":[],"mappings":"AAKA;;GAEG;AAEH,2EAA2E;AAE3E;;;;;;;GAOG;AACH,6CAHW,OAAO,GACL,UAAU,CAgBtB;AAuBD;;;;;;GAMG;AACH,oCAHW,UAAU,GACR,KAAK,CAOjB;AAED;;;;;GAKG;AACH,qCAHW,KAAK,GACH,MAAM,CAIlB;AAED;;;;;GAKG;AACH,+CAHW,UAAU,GACR,MAAM,CAKlB;AAED;;;;;GAKG;AACH,sCAHW,MAAM,GACJ,KAAK,CAIjB;yBA1Fa,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;2BAHpC,YAAY;sCAAZ,YAAY"}
|
package/src/bytes.js
CHANGED
|
@@ -1,25 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { X, Fail } from '@endo/errors';
|
|
2
3
|
import { encodeBase64, decodeBase64 } from '@endo/base64';
|
|
4
|
+
import { isObject } from '@endo/pass-style';
|
|
3
5
|
|
|
4
|
-
/* eslint-disable no-bitwise */
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
+
* @import {Bytes} from './types.js';
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** @typedef {Bytes | Buffer | Uint8Array | Iterable<number>} ByteSource */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This function is a coercer instead of an asserter because in a future where
|
|
14
|
+
* binary data has better support across vats and potentially its own type, we
|
|
15
|
+
* might allow more `specimen`s than just `ByteSource`.
|
|
7
16
|
*
|
|
8
|
-
* @param {
|
|
9
|
-
* @returns {
|
|
17
|
+
* @param {unknown} specimen
|
|
18
|
+
* @returns {ByteSource}
|
|
19
|
+
*/
|
|
20
|
+
export function coerceToByteSource(specimen) {
|
|
21
|
+
if (typeof specimen === 'string') {
|
|
22
|
+
return specimen;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
isObject(specimen) ||
|
|
26
|
+
assert.fail(X`non-object ${specimen} is not a ByteSource`, TypeError);
|
|
27
|
+
|
|
28
|
+
const obj = /** @type {{}} */ (specimen);
|
|
29
|
+
typeof obj[Symbol.iterator] === 'function' ||
|
|
30
|
+
assert.fail(X`non-iterable ${specimen} is not a ByteSource`, TypeError);
|
|
31
|
+
|
|
32
|
+
// Good enough... it's iterable and can be converted later.
|
|
33
|
+
return /** @type {ByteSource} */ (specimen);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {ByteSource} contents
|
|
10
38
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
39
|
+
const coerceToByteArray = contents => {
|
|
40
|
+
if (typeof contents === 'string') {
|
|
41
|
+
return Uint8Array.from(contents, c => {
|
|
42
|
+
const b = c.charCodeAt(0);
|
|
43
|
+
b <= 0xff || Fail`character cannot be coerced to an octet: ${c}`;
|
|
44
|
+
return b;
|
|
45
|
+
});
|
|
46
|
+
} else if (contents instanceof Uint8Array) {
|
|
47
|
+
// Reconstruct to ensure we have a Uint8Array and not a Buffer.
|
|
48
|
+
return new Uint8Array(
|
|
49
|
+
contents.buffer,
|
|
50
|
+
contents.byteOffset,
|
|
51
|
+
contents.byteLength,
|
|
52
|
+
);
|
|
17
53
|
}
|
|
54
|
+
return new Uint8Array(contents);
|
|
55
|
+
};
|
|
18
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Convert a Uint8Array or other sequence of octets to a string representation
|
|
59
|
+
* that `@endo/marshal` accepts as Passable.
|
|
60
|
+
*
|
|
61
|
+
* @param {ByteSource} byteSource
|
|
62
|
+
* @returns {Bytes}
|
|
63
|
+
*/
|
|
64
|
+
export function toBytes(byteSource) {
|
|
19
65
|
// We return the raw characters in the lower half of
|
|
20
66
|
// the String's representation.
|
|
21
|
-
const buf =
|
|
22
|
-
return String.fromCharCode
|
|
67
|
+
const buf = coerceToByteArray(byteSource);
|
|
68
|
+
return String.fromCharCode(...buf);
|
|
23
69
|
}
|
|
24
70
|
|
|
25
71
|
/**
|
|
@@ -35,25 +81,16 @@ export function bytesToString(bytes) {
|
|
|
35
81
|
/**
|
|
36
82
|
* Base64, as specified in https://tools.ietf.org/html/rfc4648#section-4
|
|
37
83
|
*
|
|
38
|
-
* @param {
|
|
84
|
+
* @param {ByteSource} byteSource
|
|
39
85
|
* @returns {string} base64 encoding
|
|
40
86
|
*/
|
|
41
|
-
export function
|
|
42
|
-
|
|
43
|
-
let bytes;
|
|
44
|
-
if (typeof data === 'string') {
|
|
45
|
-
bytes = new Uint8Array(data.length);
|
|
46
|
-
for (let i = 0; i < data.length; i += 1) {
|
|
47
|
-
bytes[i] = data.charCodeAt(i);
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
bytes = new Uint8Array(data);
|
|
51
|
-
}
|
|
87
|
+
export function byteSourceToBase64(byteSource) {
|
|
88
|
+
const bytes = coerceToByteArray(byteSource);
|
|
52
89
|
return encodeBase64(bytes);
|
|
53
90
|
}
|
|
54
91
|
|
|
55
92
|
/**
|
|
56
|
-
* Decodes a string into
|
|
93
|
+
* Decodes a base64 string into bytes.
|
|
57
94
|
*
|
|
58
95
|
* @param {string} string Base64-encoded string
|
|
59
96
|
* @returns {Bytes} decoded bytes
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from './network.js';
|
|
2
|
+
export * from './shapes.js';
|
|
2
3
|
export { prepareRouter, prepareRouterProtocol } from './router.js';
|
|
3
4
|
export * from './multiaddr.js';
|
|
4
5
|
export * from './bytes.js';
|
|
6
|
+
// eslint-disable-next-line import/export -- doesn't know types
|
|
7
|
+
export * from './types.js';
|
package/src/multiaddr.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiaddr.d.ts","sourceRoot":"","sources":["multiaddr.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,0BAHW,QAAQ,
|
|
1
|
+
{"version":3,"file":"multiaddr.d.ts","sourceRoot":"","sources":["multiaddr.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,0BAHW,QAAQ,GACN,SAAS,CA0BrB;AAED;;;;;GAKG;AACH,4BAHW,SAAS,GAAG,QAAQ,GAClB,QAAQ,CAQpB;;;;;;;;;;;;;;;;;;;;;;wBAlDY,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;;;;;uBAElB,MAAM"}
|
package/src/network.d.ts
CHANGED
|
@@ -4,36 +4,33 @@
|
|
|
4
4
|
* @param {string} addr
|
|
5
5
|
*/
|
|
6
6
|
export function getPrefixes(addr: string): string[];
|
|
7
|
+
/** @typedef {ReturnType<typeof prepareEchoConnectionKit>} MakeEchoConnectionKit */
|
|
7
8
|
/**
|
|
8
9
|
* Create a protocol handler that just connects to itself.
|
|
9
10
|
*
|
|
10
11
|
* @param {import('@agoric/base-zone').Zone} zone
|
|
11
|
-
* @param {
|
|
12
|
+
* @param {VowTools} powers
|
|
12
13
|
*/
|
|
13
|
-
export function prepareLoopbackProtocolHandler(zone: import(
|
|
14
|
-
isRetryableReason?: ((reason: any) => boolean) | undefined;
|
|
15
|
-
watchPromise?: ((p: PromiseLike<any>, watcher: import("@agoric/vow/src/watch-promise.js").PromiseWatcher, ...args: unknown[]) => void) | undefined;
|
|
16
|
-
} | undefined) => {
|
|
17
|
-
when: <T = any, TResult1 = import("@agoric/vow/src/E.js").Unwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("@agoric/vow/src/E.js").Unwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
|
|
18
|
-
watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = T_1>(specimenP: import("@agoric/vow").ERef<T_1 | import("@agoric/vow").Vow<T_1>>, watcher?: import("@agoric/vow").Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: unknown) => import("@agoric/vow").Vow<TResult1_1 | TResult2_1>;
|
|
19
|
-
makeVowKit: <T_2>() => import("@agoric/vow").VowKit<T_2>;
|
|
20
|
-
}>): (instancePrefix?: string | undefined) => import("@endo/exo/src/exo-makers.js").Guarded<{
|
|
14
|
+
export function prepareLoopbackProtocolHandler(zone: import("@agoric/base-zone").Zone, { watch, allVows }: VowTools): (instancePrefix?: string | undefined) => import("@endo/exo").Guarded<{
|
|
21
15
|
onCreate(_impl: any, _protocolHandler: any): Promise<void>;
|
|
22
16
|
generatePortID(_localAddr: any, _protocolHandler: any): Promise<string>;
|
|
23
17
|
onBind(_port: any, _localAddr: any, _protocolHandler: any): Promise<void>;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @param {*} _port
|
|
20
|
+
* @param {Endpoint} localAddr
|
|
21
|
+
* @param {Endpoint} remoteAddr
|
|
22
|
+
* @returns {import('@agoric/vow').PromiseVow<AttemptDescription>}}
|
|
23
|
+
*/
|
|
24
|
+
onConnect(_port: any, localAddr: Endpoint, remoteAddr: Endpoint): import("@agoric/vow").PromiseVow<AttemptDescription>;
|
|
28
25
|
onInstantiate(_port: any, _localAddr: any, _remote: any, _protocol: any): Promise<string>;
|
|
29
26
|
onListen(port: any, localAddr: any, listenHandler: any, _protocolHandler: any): Promise<void>;
|
|
30
27
|
/**
|
|
31
|
-
* @param {Port} port
|
|
28
|
+
* @param {Remote<Port>} port
|
|
32
29
|
* @param {Endpoint} localAddr
|
|
33
|
-
* @param {ListenHandler} listenHandler
|
|
30
|
+
* @param {Remote<ListenHandler>} listenHandler
|
|
34
31
|
* @param {*} _protocolHandler
|
|
35
32
|
*/
|
|
36
|
-
onListenRemove(port: Port
|
|
33
|
+
onListenRemove(port: Remote<Port>, localAddr: Endpoint, listenHandler: Remote<ListenHandler>, _protocolHandler: any): Promise<void>;
|
|
37
34
|
onRevoke(_port: any, _localAddr: any, _protocolHandler: any): Promise<void>;
|
|
38
35
|
}>;
|
|
39
36
|
/**
|
|
@@ -41,68 +38,11 @@ export function prepareLoopbackProtocolHandler(zone: import('@agoric/base-zone')
|
|
|
41
38
|
* casually.
|
|
42
39
|
*/
|
|
43
40
|
export const ENDPOINT_SEPARATOR: "/";
|
|
44
|
-
export
|
|
45
|
-
let ConnectionI: import("@endo/patterns").InterfaceGuard<{
|
|
46
|
-
send: import("@endo/patterns").MethodGuard;
|
|
47
|
-
close: import("@endo/patterns").MethodGuard;
|
|
48
|
-
getLocalAddress: import("@endo/patterns").MethodGuard;
|
|
49
|
-
getRemoteAddress: import("@endo/patterns").MethodGuard;
|
|
50
|
-
}>;
|
|
51
|
-
let InboundAttemptI: import("@endo/patterns").InterfaceGuard<{
|
|
52
|
-
accept: import("@endo/patterns").MethodGuard;
|
|
53
|
-
getLocalAddress: import("@endo/patterns").MethodGuard;
|
|
54
|
-
getRemoteAddress: import("@endo/patterns").MethodGuard;
|
|
55
|
-
close: import("@endo/patterns").MethodGuard;
|
|
56
|
-
}>;
|
|
57
|
-
let PortI: import("@endo/patterns").InterfaceGuard<{
|
|
58
|
-
getLocalAddress: import("@endo/patterns").MethodGuard;
|
|
59
|
-
addListener: import("@endo/patterns").MethodGuard;
|
|
60
|
-
connect: import("@endo/patterns").MethodGuard;
|
|
61
|
-
removeListener: import("@endo/patterns").MethodGuard;
|
|
62
|
-
revoke: import("@endo/patterns").MethodGuard;
|
|
63
|
-
}>;
|
|
64
|
-
let ProtocolHandlerI: import("@endo/patterns").InterfaceGuard<{
|
|
65
|
-
onCreate: import("@endo/patterns").MethodGuard;
|
|
66
|
-
generatePortID: import("@endo/patterns").MethodGuard;
|
|
67
|
-
onBind: import("@endo/patterns").MethodGuard;
|
|
68
|
-
onListen: import("@endo/patterns").MethodGuard;
|
|
69
|
-
onListenRemove: import("@endo/patterns").MethodGuard;
|
|
70
|
-
onInstantiate: import("@endo/patterns").MethodGuard;
|
|
71
|
-
onConnect: import("@endo/patterns").MethodGuard;
|
|
72
|
-
onRevoke: import("@endo/patterns").MethodGuard;
|
|
73
|
-
}>;
|
|
74
|
-
let ProtocolImplI: import("@endo/patterns").InterfaceGuard<{
|
|
75
|
-
bind: import("@endo/patterns").MethodGuard;
|
|
76
|
-
inbound: import("@endo/patterns").MethodGuard;
|
|
77
|
-
outbound: import("@endo/patterns").MethodGuard;
|
|
78
|
-
}>;
|
|
79
|
-
function Vow$(shape: any): import("@endo/patterns").Matcher;
|
|
80
|
-
let AttemptDescription: import("@endo/patterns").Matcher;
|
|
81
|
-
let Opts: import("@endo/patterns").Matcher;
|
|
82
|
-
let Data: import("@endo/patterns").Matcher;
|
|
83
|
-
let Bytes: import("@endo/patterns").Matcher;
|
|
84
|
-
let Endpoint: import("@endo/patterns").Matcher;
|
|
85
|
-
let Vow: import("@endo/patterns").Matcher;
|
|
86
|
-
let ConnectionHandler: import("@endo/patterns").Matcher;
|
|
87
|
-
let Connection: import("@endo/patterns").Matcher;
|
|
88
|
-
let InboundAttempt: import("@endo/patterns").Matcher;
|
|
89
|
-
let Listener: import("@endo/patterns").Matcher;
|
|
90
|
-
let ListenHandler: import("@endo/patterns").Matcher;
|
|
91
|
-
let Port: import("@endo/patterns").Matcher;
|
|
92
|
-
let ProtocolHandler: import("@endo/patterns").Matcher;
|
|
93
|
-
let ProtocolImpl: import("@endo/patterns").Matcher;
|
|
94
|
-
}
|
|
41
|
+
export const CLOSE_REASON_FINALIZER: "closed-by-finalizer";
|
|
95
42
|
export function rethrowUnlessMissing(err: unknown): undefined;
|
|
96
|
-
export function crossoverConnection(zone: import(
|
|
97
|
-
export function prepareNetworkProtocol(zone: import(
|
|
98
|
-
|
|
99
|
-
watchPromise?: ((p: PromiseLike<any>, watcher: import("@agoric/vow/src/watch-promise.js").PromiseWatcher, ...args: unknown[]) => void) | undefined;
|
|
100
|
-
} | undefined) => {
|
|
101
|
-
when: <T = any, TResult1 = import("@agoric/vow/src/E.js").Unwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("@agoric/vow/src/E.js").Unwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
|
|
102
|
-
watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = T_1>(specimenP: import("@agoric/vow").ERef<T_1 | import("@agoric/vow").Vow<T_1>>, watcher?: import("@agoric/vow").Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: unknown) => import("@agoric/vow").Vow<TResult1_1 | TResult2_1>;
|
|
103
|
-
makeVowKit: <T_2>() => import("@agoric/vow").VowKit<T_2>;
|
|
104
|
-
}>): (protocolHandler: ProtocolHandler) => Protocol;
|
|
105
|
-
export function prepareEchoConnectionKit(zone: import('@agoric/base-zone').Zone): () => import("@endo/exo/src/exo-makers.js").GuardedKit<{
|
|
43
|
+
export function crossoverConnection(zone: import("@agoric/zone").Zone, handler0: Remote<Required<ConnectionHandler>>, addr0: Endpoint, handler1: Remote<Required<ConnectionHandler>>, addr1: Endpoint, makeConnection: (opts: ConnectionOpts) => Connection, finalizer: Finalizer, current?: globalThis.WeakSetStore<Closable> | undefined): Connection[];
|
|
44
|
+
export function prepareNetworkProtocol(zone: import("@agoric/base-zone").Zone, powers: Powers): (protocolHandler: Remote<ProtocolHandler>) => Protocol;
|
|
45
|
+
export function prepareEchoConnectionKit(zone: import("@agoric/base-zone").Zone): () => import("@endo/exo").GuardedKit<{
|
|
106
46
|
handler: {
|
|
107
47
|
/**
|
|
108
48
|
* @param {Connection} _connection
|
|
@@ -112,13 +52,13 @@ export function prepareEchoConnectionKit(zone: import('@agoric/base-zone').Zone)
|
|
|
112
52
|
onReceive(_connection: Connection, bytes: Bytes, _connectionHandler: ConnectionHandler): Promise<string>;
|
|
113
53
|
/**
|
|
114
54
|
* @param {Connection} _connection
|
|
115
|
-
* @param {CloseReason} [
|
|
55
|
+
* @param {CloseReason} [reason]
|
|
116
56
|
* @param {ConnectionHandler} [_connectionHandler]
|
|
117
57
|
*/
|
|
118
|
-
onClose(_connection: Connection,
|
|
58
|
+
onClose(_connection: Connection, reason?: CloseReason, _connectionHandler?: ConnectionHandler | undefined): Promise<void>;
|
|
119
59
|
};
|
|
120
60
|
listener: {
|
|
121
|
-
onAccept(_port: any, _localAddr: any, _remoteAddr: any, _listenHandler: any): Promise<import("@endo/exo
|
|
61
|
+
onAccept(_port: any, _localAddr: any, _remoteAddr: any, _listenHandler: any): Promise<import("@endo/exo").Guarded<{
|
|
122
62
|
/**
|
|
123
63
|
* @param {Connection} _connection
|
|
124
64
|
* @param {Bytes} bytes
|
|
@@ -127,20 +67,82 @@ export function prepareEchoConnectionKit(zone: import('@agoric/base-zone').Zone)
|
|
|
127
67
|
onReceive(_connection: Connection, bytes: Bytes, _connectionHandler: ConnectionHandler): Promise<string>;
|
|
128
68
|
/**
|
|
129
69
|
* @param {Connection} _connection
|
|
130
|
-
* @param {CloseReason} [
|
|
70
|
+
* @param {CloseReason} [reason]
|
|
131
71
|
* @param {ConnectionHandler} [_connectionHandler]
|
|
132
72
|
*/
|
|
133
|
-
onClose(_connection: Connection,
|
|
73
|
+
onClose(_connection: Connection, reason?: CloseReason, _connectionHandler?: ConnectionHandler | undefined): Promise<void>;
|
|
134
74
|
}>>;
|
|
135
75
|
onListen(port: any, _listenHandler: any): Promise<void>;
|
|
136
76
|
};
|
|
137
77
|
}>;
|
|
78
|
+
export function preparePortAllocator(zone: import("@agoric/base-zone").Zone, { watch }: Powers): (args_0: {
|
|
79
|
+
protocol: Protocol;
|
|
80
|
+
}) => import("@endo/exo").Guarded<{
|
|
81
|
+
allocateCustomIBCPort(specifiedName?: string): Promise<import("@agoric/vow").Vow<Port>>;
|
|
82
|
+
allocateICAControllerPort(): Promise<import("@agoric/vow").Vow<Port>>;
|
|
83
|
+
allocateICQControllerPort(): Promise<import("@agoric/vow").Vow<Port>>;
|
|
84
|
+
allocateCustomLocalPort(specifiedName?: string): Promise<import("@agoric/vow").Vow<Port>>;
|
|
85
|
+
}>;
|
|
86
|
+
export function prepareNetworkPowers(zone: import("@agoric/base-zone").Zone, vowTools: VowTools): Powers;
|
|
87
|
+
export type MakeEchoConnectionKit = ReturnType<typeof prepareEchoConnectionKit>;
|
|
88
|
+
export type Powers = VowTools & {
|
|
89
|
+
finalizer: Finalizer;
|
|
90
|
+
};
|
|
138
91
|
export type ConnectionOpts = {
|
|
139
92
|
addrs: Endpoint[];
|
|
140
|
-
handlers: ConnectionHandler[];
|
|
93
|
+
handlers: Remote<Required<ConnectionHandler>>[];
|
|
141
94
|
conns: MapStore<number, Connection>;
|
|
142
95
|
current: WeakSetStore<Closable>;
|
|
143
96
|
l: 0 | 1;
|
|
144
97
|
r: 0 | 1;
|
|
145
98
|
};
|
|
99
|
+
export type PortAllocator = ReturnType<ReturnType<typeof preparePortAllocator>>;
|
|
100
|
+
export type Finalizer = ReturnType<typeof prepareFinalizer>;
|
|
101
|
+
import type { VowTools } from '@agoric/vow';
|
|
102
|
+
import type { Endpoint } from './types.js';
|
|
103
|
+
import type { AttemptDescription } from './types.js';
|
|
104
|
+
import type { Port } from './types.js';
|
|
105
|
+
import type { Remote } from '@agoric/vow';
|
|
106
|
+
import type { ListenHandler } from './types.js';
|
|
107
|
+
import type { ConnectionHandler } from './types.js';
|
|
108
|
+
import type { Connection } from './types.js';
|
|
109
|
+
import type { Closable } from './types.js';
|
|
110
|
+
import type { ProtocolHandler } from './types.js';
|
|
111
|
+
import type { Protocol } from './types.js';
|
|
112
|
+
import type { Bytes } from './types.js';
|
|
113
|
+
import type { CloseReason } from './types.js';
|
|
114
|
+
/** @typedef {ReturnType<ReturnType<typeof preparePortAllocator>>} PortAllocator */
|
|
115
|
+
/**
|
|
116
|
+
* Return a package-specific singleton that pins objects until they are
|
|
117
|
+
* explicitly unpinned or finalized. It needs to pin objects only because they
|
|
118
|
+
* are resources that need to be released.
|
|
119
|
+
*
|
|
120
|
+
* The reason this functionality wasn't just baked into the other network exos
|
|
121
|
+
* is to maintain upgrade-compatible with minimal additional changes.
|
|
122
|
+
*
|
|
123
|
+
* @param {import('@agoric/base-zone').Zone} zone
|
|
124
|
+
* @param {VowTools} vowTools
|
|
125
|
+
*/
|
|
126
|
+
declare function prepareFinalizer(zone: import("@agoric/base-zone").Zone, { watch }: VowTools): import("@endo/exo").Guarded<{
|
|
127
|
+
has(obj: any): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Add a connection and handler for an `onClose` method to be called upon
|
|
130
|
+
* finalization.
|
|
131
|
+
* @param {Remote<Connection>} conn
|
|
132
|
+
* @param {Remote<Required<ConnectionHandler>>} handler
|
|
133
|
+
*/
|
|
134
|
+
initConnection(conn: Remote<Connection>, handler: Remote<Required<ConnectionHandler>>): void;
|
|
135
|
+
/**
|
|
136
|
+
* Add an object with a `close` method to be called (such as an
|
|
137
|
+
* `inboundAttempt`) upon finalization.
|
|
138
|
+
* @param {Remote<{ close(): PromiseVow<any> }>} closer
|
|
139
|
+
*/
|
|
140
|
+
initCloser(closer: Remote<{
|
|
141
|
+
close(): PromiseVow<any>;
|
|
142
|
+
}>): void;
|
|
143
|
+
finalize(obj: any): import("@agoric/vow").Vow<any> | undefined;
|
|
144
|
+
unpin(obj: any): void;
|
|
145
|
+
}>;
|
|
146
|
+
import type { PromiseVow } from '@agoric/vow';
|
|
147
|
+
export {};
|
|
146
148
|
//# sourceMappingURL=network.d.ts.map
|
package/src/network.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["network.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["network.js"],"names":[],"mappings":"AA2CA;;;;GAIG;AACH,kCAFW,MAAM,YAahB;AAwtCD,mFAAmF;AAEnF;;;;;GAKG;AACH,qDAHW,OAAO,mBAAmB,EAAE,IAAI,sBAChC,QAAQ;;;;IAmCX;;;;;OAKG;qBAJQ,GAAC,aACD,QAAQ,cACR,QAAQ,GACN,OAAO,aAAa,EAAE,UAAU,CAAC,kBAAkB,CAAC;;;IA+DjE;;;;;OAKG;yBAJQ,OAAO,IAAI,CAAC,aACZ,QAAQ,iBACR,OAAO,aAAa,CAAC,oBACrB,GAAC;;GA+CnB;AA75CD;;;GAGG;AACH,qCAAsC;AAGtC,2DAA4D;AAGrD,0CADK,OAAO,aAWlB;AA4JM,0CATI,OAAO,cAAc,EAAE,IAAI,YAC3B,OAAO,QAAQ,CAAC,iBAAiB,CAAC,CAAC,SACnC,QAAQ,YACR,OAAO,QAAQ,CAAC,iBAAiB,CAAC,CAAC,SACnC,QAAQ,kBACR,CAAC,IAAI,EAAE,cAAc,KAAK,UAAU,aACpC,SAAS,yEAqDnB;AAw6BM,6CAHI,OAAO,mBAAmB,EAAE,IAAI,UAChC,MAAM,qBAMJ,OAAO,eAAe,CAAC,KACrB,QAAQ,CA2BtB;AAOM,+CAFI,OAAO,mBAAmB,EAAE,IAAI;;QAsCnC;;;;WAIG;+BAHQ,UAAU,SACV,KAAK,sBACL,iBAAiB;QAU5B;;;;WAIG;6BAHQ,UAAU,WACV,WAAW;;;;YAftB;;;;eAIG;mCAHQ,UAAU,SACV,KAAK,sBACL,iBAAiB;YAU5B;;;;eAIG;iCAHQ,UAAU,WACV,WAAW;;;;GAyB7B;AAuKM,2CAHI,OAAO,mBAAmB,EAAE,IAAI,aAChC,MAAM;cAkBF,QAAQ;;;;;;GAkDpB;AAwEI,2CAJI,OAAO,mBAAmB,EAAE,IAAI,YAChC,QAAQ,GACN,MAAM,CAKlB;oCAnTa,UAAU,CAAC,OAAO,wBAAwB,CAAC;qBAnwC3C,QAAQ,GAAG;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE;;WA6DnC,QAAQ,EAAE;cACV,OAAO,QAAQ,CAAC,iBAAiB,CAAC,CAAC,EAAE;WACrC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;aAC5B,YAAY,CAAC,QAAQ,CAAC;OACtB,CAAC,GAAC,CAAC;OACH,CAAC,GAAC,CAAC;;4BA06CH,UAAU,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;wBA4EnD,UAAU,CAAC,OAAO,gBAAgB,CAAC;8BA3jDF,aAAa;8BAD8G,YAAY;wCAAZ,YAAY;0BAAZ,YAAY;4BACvI,aAAa;mCAD8G,YAAY;uCAAZ,YAAY;gCAAZ,YAAY;8BAAZ,YAAY;qCAAZ,YAAY;8BAAZ,YAAY;2BAAZ,YAAY;iCAAZ,YAAY;AAg/CtL,mFAAmF;AAEnF;;;;;;;;;;GAUG;AACH,wCAHW,OAAO,mBAAmB,EAAE,IAAI,aAChC,QAAQ;;IAcf;;;;;OAKG;yBAFQ,OAAO,UAAU,CAAC,WAClB,OAAO,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAK9C;;;;OAIG;uBADQ,OAAO;QAAE,KAAK,IAAI,WAAW,GAAG,CAAC,CAAA;KAAE,CAAC;;;GA0BlD;gCA9iD8C,aAAa"}
|