@peerbit/libp2p-test-utils 1.0.2 → 1.0.4
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/lib/esm/session.d.ts +1 -1
- package/lib/esm/session.js +5 -5
- package/lib/esm/session.js.map +1 -1
- package/lib/esm/transports.d.ts +1 -1
- package/lib/esm/transports.js +2 -2
- package/package.json +9 -9
- package/src/session.ts +6 -6
- package/src/transports.ts +3 -3
package/lib/esm/session.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { Libp2p, ServiceFactoryMap } from "libp2p";
|
|
|
2
2
|
import { RecursivePartial } from "@libp2p/interfaces";
|
|
3
3
|
import { Datastore } from "interface-datastore";
|
|
4
4
|
import { ConnectionManagerInit } from "libp2p/dist/src/connection-manager";
|
|
5
|
-
import { Transport } from "@libp2p/interface-transport";
|
|
6
5
|
import { Components } from "libp2p/components";
|
|
7
6
|
import { CircuitRelayService } from "libp2p/dist/src/circuit-relay/index.js";
|
|
8
7
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
|
8
|
+
import type { Transport } from "@libp2p/interface/transport";
|
|
9
9
|
export type LibP2POptions<T extends Record<string, unknown>> = {
|
|
10
10
|
transports?: RecursivePartial<(components: Components) => Transport>[] | undefined;
|
|
11
11
|
connectionManager?: RecursivePartial<ConnectionManagerInit>;
|
package/lib/esm/session.js
CHANGED
|
@@ -41,10 +41,10 @@ export class LSession {
|
|
|
41
41
|
const result = async () => {
|
|
42
42
|
const node = await createLibp2p({
|
|
43
43
|
addresses: {
|
|
44
|
-
listen: ["/ip4/127.0.0.1/tcp/0", "/ip4/127.0.0.1/tcp/0/ws"]
|
|
44
|
+
listen: ["/ip4/127.0.0.1/tcp/0", "/ip4/127.0.0.1/tcp/0/ws"]
|
|
45
45
|
},
|
|
46
46
|
connectionManager: (options?.[i] || options)?.connectionManager ?? {
|
|
47
|
-
minConnections: 0
|
|
47
|
+
minConnections: 0
|
|
48
48
|
},
|
|
49
49
|
datastore: (options?.[i] || options)?.datastore,
|
|
50
50
|
transports: (options?.[i] || options)?.transports ??
|
|
@@ -52,11 +52,11 @@ export class LSession {
|
|
|
52
52
|
services: {
|
|
53
53
|
relay: (options?.[i] || options)?.browser ? undefined : relay(),
|
|
54
54
|
identify: identifyService(),
|
|
55
|
-
...(options?.[i] || options)?.services
|
|
55
|
+
...(options?.[i] || options)?.services
|
|
56
56
|
},
|
|
57
57
|
connectionEncryption: [noise()],
|
|
58
|
-
streamMuxers: [mplex()],
|
|
59
|
-
start: (options?.[i] || options)?.start
|
|
58
|
+
streamMuxers: [mplex({ disconnectThreshold: 10 })],
|
|
59
|
+
start: (options?.[i] || options)?.start
|
|
60
60
|
});
|
|
61
61
|
return node;
|
|
62
62
|
};
|
package/lib/esm/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6B,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGzC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6B,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGzC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CA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AAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,EAAE,KAAK;iBACvC,CAAC,CAAC;gBACH,OAAO,IAAI,CAAC;YACb,CAAC,CAAC;YACF,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;SACxB;QAED,MAAM,IAAI,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAkC,CAAC;QAC5E,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI;QACH,OAAO,OAAO,CAAC,GAAG,CACjB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YAC1B,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC,CAAC,CACF,CAAC;IACH,CAAC;CACD"}
|
package/lib/esm/transports.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Components } from "libp2p/components";
|
|
2
|
-
import type { Transport } from "@libp2p/interface
|
|
2
|
+
import type { Transport } from "@libp2p/interface/transport";
|
|
3
3
|
export declare const transports: (browser: boolean) => ((components: Components) => Transport)[];
|
|
4
4
|
export declare const relay: () => (components: import("libp2p/dist/src/circuit-relay/server").CircuitRelayServerComponents) => import("libp2p/circuit-relay").CircuitRelayService;
|
package/lib/esm/transports.js
CHANGED
|
@@ -7,10 +7,10 @@ import { tcp } from "@libp2p/tcp";
|
|
|
7
7
|
export const transports = (browser) => browser
|
|
8
8
|
? [
|
|
9
9
|
circuitRelayTransport({
|
|
10
|
-
discoverRelays: 1
|
|
10
|
+
discoverRelays: 1
|
|
11
11
|
}),
|
|
12
12
|
webRTC({}),
|
|
13
|
-
webSockets({ filter: filters.all })
|
|
13
|
+
webSockets({ filter: filters.all })
|
|
14
14
|
]
|
|
15
15
|
: [tcp()];
|
|
16
16
|
export const relay = () => circuitRelayServer({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peerbit/libp2p-test-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Test utils for Peerbit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -37,20 +37,20 @@
|
|
|
37
37
|
"author": "dao.xyz",
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@dao-xyz/libp2p-noise": "^
|
|
41
|
-
"@libp2p/mplex": "^
|
|
42
|
-
"@libp2p/tcp": "^
|
|
43
|
-
"@libp2p/webrtc": "
|
|
44
|
-
"@libp2p/websockets": "^
|
|
40
|
+
"@dao-xyz/libp2p-noise": "^13.0.1",
|
|
41
|
+
"@libp2p/mplex": "^9.0.4",
|
|
42
|
+
"@libp2p/tcp": "^8.0.4",
|
|
43
|
+
"@libp2p/webrtc": "^3.1.6",
|
|
44
|
+
"@libp2p/websockets": "^7.0.4",
|
|
45
45
|
"datastore-level": "^10.1.2",
|
|
46
|
-
"libp2p": "^0.
|
|
46
|
+
"libp2p": "^0.46.6",
|
|
47
47
|
"memory-level": "^1.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@peerbit/time": "1.0.
|
|
50
|
+
"@peerbit/time": "1.0.3"
|
|
51
51
|
},
|
|
52
52
|
"localMaintainers": [
|
|
53
53
|
"dao.xyz"
|
|
54
54
|
],
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "0cfa376bc90c31e1063ddaf5435c828b490e0228"
|
|
56
56
|
}
|
package/src/session.ts
CHANGED
|
@@ -6,11 +6,11 @@ import { RecursivePartial } from "@libp2p/interfaces";
|
|
|
6
6
|
import { Datastore } from "interface-datastore";
|
|
7
7
|
import { relay, transports } from "./transports.js";
|
|
8
8
|
import { ConnectionManagerInit } from "libp2p/dist/src/connection-manager";
|
|
9
|
-
import { Transport } from "@libp2p/interface-transport";
|
|
10
9
|
import { Components } from "libp2p/components";
|
|
11
10
|
import { identifyService } from "libp2p/identify";
|
|
12
11
|
import { CircuitRelayService } from "libp2p/dist/src/circuit-relay/index.js";
|
|
13
12
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
|
13
|
+
import type { Transport } from "@libp2p/interface/transport";
|
|
14
14
|
|
|
15
15
|
export type LibP2POptions<T extends Record<string, unknown>> = {
|
|
16
16
|
transports?:
|
|
@@ -78,10 +78,10 @@ export class LSession<T> {
|
|
|
78
78
|
const result = async () => {
|
|
79
79
|
const node = await createLibp2p<T>({
|
|
80
80
|
addresses: {
|
|
81
|
-
listen: ["/ip4/127.0.0.1/tcp/0", "/ip4/127.0.0.1/tcp/0/ws"]
|
|
81
|
+
listen: ["/ip4/127.0.0.1/tcp/0", "/ip4/127.0.0.1/tcp/0/ws"]
|
|
82
82
|
},
|
|
83
83
|
connectionManager: (options?.[i] || options)?.connectionManager ?? {
|
|
84
|
-
minConnections: 0
|
|
84
|
+
minConnections: 0
|
|
85
85
|
},
|
|
86
86
|
datastore: (options?.[i] || options)?.datastore,
|
|
87
87
|
transports:
|
|
@@ -90,11 +90,11 @@ export class LSession<T> {
|
|
|
90
90
|
services: {
|
|
91
91
|
relay: (options?.[i] || options)?.browser ? undefined : relay(),
|
|
92
92
|
identify: identifyService(),
|
|
93
|
-
...(options?.[i] || options)?.services
|
|
93
|
+
...(options?.[i] || options)?.services
|
|
94
94
|
},
|
|
95
95
|
connectionEncryption: [noise()],
|
|
96
|
-
streamMuxers: [mplex()],
|
|
97
|
-
start: (options?.[i] || options)?.start
|
|
96
|
+
streamMuxers: [mplex({ disconnectThreshold: 10 })],
|
|
97
|
+
start: (options?.[i] || options)?.start
|
|
98
98
|
});
|
|
99
99
|
return node;
|
|
100
100
|
};
|
package/src/transports.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { webSockets } from "@libp2p/websockets";
|
|
|
5
5
|
import * as filters from "@libp2p/websockets/filters";
|
|
6
6
|
import { tcp } from "@libp2p/tcp";
|
|
7
7
|
import { Components } from "libp2p/components";
|
|
8
|
-
import type { Transport } from "@libp2p/interface
|
|
8
|
+
import type { Transport } from "@libp2p/interface/transport";
|
|
9
9
|
|
|
10
10
|
export const transports = (
|
|
11
11
|
browser: boolean
|
|
@@ -13,10 +13,10 @@ export const transports = (
|
|
|
13
13
|
browser
|
|
14
14
|
? [
|
|
15
15
|
circuitRelayTransport({
|
|
16
|
-
discoverRelays: 1
|
|
16
|
+
discoverRelays: 1
|
|
17
17
|
}),
|
|
18
18
|
webRTC({}),
|
|
19
|
-
webSockets({ filter: filters.all })
|
|
19
|
+
webSockets({ filter: filters.all })
|
|
20
20
|
]
|
|
21
21
|
: [tcp()];
|
|
22
22
|
|