@constl/utils-tests 2.1.5 → 2.2.1
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/dist/@types.d.ts +2 -1
- package/dist/@types.d.ts.map +1 -0
- package/dist/attente.d.ts +1 -0
- package/dist/attente.d.ts.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js.map +1 -1
- package/dist/constellation.d.ts +2 -1
- package/dist/constellation.d.ts.map +1 -0
- package/dist/dossiers.d.ts +1 -0
- package/dist/dossiers.d.ts.map +1 -0
- package/dist/h/303/251lia.d.ts +5 -6
- package/dist/h/303/251lia.d.ts.map +1 -0
- package/dist/h/303/251lia.js +19 -20
- package/dist/h/303/251lia.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/libp2p/config.d.ts +6 -5
- package/dist/libp2p/config.d.ts.map +1 -0
- package/dist/libp2p/config.js +3 -1
- package/dist/libp2p/config.js.map +1 -1
- package/dist/libp2p/index.d.ts +2 -1
- package/dist/libp2p/index.d.ts.map +1 -0
- package/dist/libp2p/libp2p.d.ts +3 -2
- package/dist/libp2p/libp2p.d.ts.map +1 -0
- package/dist/libp2p/libp2p.js +2 -2
- package/dist/libp2p/libp2p.js.map +1 -1
- package/dist/libp2p/utils.d.ts +4 -3
- package/dist/libp2p/utils.d.ts.map +1 -0
- package/dist/libp2p/utils.js +6 -4
- package/dist/libp2p/utils.js.map +1 -1
- package/dist/orbite.d.ts +5 -4
- package/dist/orbite.d.ts.map +1 -0
- package/dist/orbite.js +8 -5
- package/dist/orbite.js.map +1 -1
- package/dist/relai/bin.d.ts +1 -0
- package/dist/relai/bin.d.ts.map +1 -0
- package/dist/relai/consts.d.ts +1 -0
- package/dist/relai/consts.d.ts.map +1 -0
- package/dist/relai/index.d.ts +1 -0
- package/dist/relai/index.d.ts.map +1 -0
- package/dist/relai/relai.d.ts +1 -0
- package/dist/relai/relai.d.ts.map +1 -0
- package/dist/relai/utils.d.ts +1 -0
- package/dist/relai/utils.d.ts.map +1 -0
- package/dist/scripts/node-globals.d.ts +1 -0
- package/dist/scripts/node-globals.d.ts.map +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/version.d.ts +2 -1
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +1 -1
- package/eslint.config.js +33 -0
- package/package.json +21 -24
- package/pnpm-workspace.yaml +0 -8
- package/src/@types.ts +1 -1
- package/src/config.ts +1 -2
- package/src/constellation.ts +1 -1
- package/src/h/303/251lia.ts +40 -40
- package/src/index.ts +3 -3
- package/src/libp2p/config.ts +9 -5
- package/src/libp2p/index.ts +2 -2
- package/src/libp2p/libp2p.ts +4 -4
- package/src/libp2p/utils.ts +10 -7
- package/src/orbite.ts +9 -9
- package/src/version.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +4 -34
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.1
|
|
2
|
+
"version": "2.2.1",
|
|
3
3
|
"license": "AGPL-3.0-or-later",
|
|
4
4
|
"name": "@constl/utils-tests",
|
|
5
5
|
"author": "Julien Jean Malard-Adam",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": "./dist/index.js",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/reseau-constellation/utils-tests.git"
|
|
12
|
+
},
|
|
9
13
|
"engines": {
|
|
10
14
|
"node": ">=20"
|
|
11
15
|
},
|
|
@@ -22,7 +26,6 @@
|
|
|
22
26
|
"devDependencies": {
|
|
23
27
|
"@chainsafe/libp2p-noise": "^17.0.0",
|
|
24
28
|
"@chainsafe/libp2p-yamux": "^8.0.1",
|
|
25
|
-
"@constl/bohr-db": "^2.2.10",
|
|
26
29
|
"@eslint/js": "^10.0.1",
|
|
27
30
|
"@libp2p/circuit-relay-v2": "^4.2.13",
|
|
28
31
|
"@libp2p/crypto": "^5.1.23",
|
|
@@ -31,42 +34,39 @@
|
|
|
31
34
|
"@libp2p/websockets": "^10.1.21",
|
|
32
35
|
"@multiformats/multiaddr": "^13.0.3",
|
|
33
36
|
"@multiformats/multiaddr-matcher": "^3.0.2",
|
|
34
|
-
"@orbitdb/core-types": "^
|
|
35
|
-
"@orbitdb/feed-db": "^1.4.2",
|
|
37
|
+
"@orbitdb/core-types": "^2.0.0",
|
|
36
38
|
"@types/crypto-js": "^4.2.2",
|
|
37
39
|
"@types/file-saver": "^2.0.7",
|
|
38
40
|
"@types/mocha": "^10.0.10",
|
|
39
|
-
"@types/node": "^26.6.
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
41
|
-
"@typescript-eslint/parser": "^8.
|
|
41
|
+
"@types/node": "^26.6.4",
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^8.71.0",
|
|
43
|
+
"@typescript-eslint/parser": "^8.71.0",
|
|
42
44
|
"aegir": "^48.1.6",
|
|
43
|
-
"ajv": "^8.20.0",
|
|
44
45
|
"buffer": "^6.0.3",
|
|
45
46
|
"core-js": "^3.50.0",
|
|
46
|
-
"electron": "^44.
|
|
47
|
+
"electron": "^44.5.1",
|
|
47
48
|
"esbuild": "^0.28.2",
|
|
48
|
-
"eslint": "^
|
|
49
|
+
"eslint": "^9.39.5",
|
|
49
50
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
50
51
|
"eslint-config-prettier": "^10.1.8",
|
|
51
52
|
"eslint-config-standard": "^17.1.0",
|
|
53
|
+
"eslint-import-resolver-typescript": "^4.4.5",
|
|
52
54
|
"eslint-plugin-import": "^2.32.0",
|
|
53
|
-
"eslint-plugin-n": "^18.
|
|
55
|
+
"eslint-plugin-n": "^18.4.1",
|
|
54
56
|
"eslint-plugin-promise": "^7.3.0",
|
|
55
57
|
"execa": "^10.0.1",
|
|
56
|
-
"mocha": "^
|
|
58
|
+
"mocha": "^11.8.0",
|
|
57
59
|
"playwright": "^1.63.0",
|
|
58
60
|
"prettier": "^3.9.9",
|
|
59
61
|
"progress-events": "^1.1.0",
|
|
60
62
|
"source-map-support": "^0.5.21",
|
|
61
|
-
"ts-patch": "^4.0.1",
|
|
62
63
|
"tsconfig-paths": "^4.2.0",
|
|
63
64
|
"tscpaths": "^0.0.9",
|
|
64
65
|
"typescript": "^6.0.3",
|
|
65
|
-
"typescript-eslint": "^8.
|
|
66
|
-
"typescript-transform-paths": "^4.0.0"
|
|
66
|
+
"typescript-eslint": "^8.71.0"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@helia/
|
|
69
|
+
"@helia/libp2p": "^2.1.5",
|
|
70
70
|
"@libp2p/gossipsub": "^17.1.2",
|
|
71
71
|
"@libp2p/peer-id": "^6.0.15",
|
|
72
72
|
"@libp2p/ping": "^3.1.13",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"crypto-browserify": "^3.12.1",
|
|
81
81
|
"events": "^3.3.0",
|
|
82
82
|
"genversion": "^3.2.0",
|
|
83
|
-
"helia": "
|
|
83
|
+
"helia": "7.1.16",
|
|
84
84
|
"libp2p": "^3.3.11",
|
|
85
85
|
"os-browserify": "^0.3.0",
|
|
86
86
|
"process": "^0.11.10",
|
|
@@ -91,20 +91,17 @@
|
|
|
91
91
|
"uuid": "^14.0.2",
|
|
92
92
|
"wherearewe": "^2.0.1"
|
|
93
93
|
},
|
|
94
|
-
"publishConfig": {
|
|
95
|
-
"@reseau-constellation:registry": "https://npm.pkg.github.com"
|
|
96
|
-
},
|
|
97
94
|
"scripts": {
|
|
98
95
|
"nettoyer": "rimraf dist",
|
|
99
|
-
"compiler": "
|
|
100
|
-
"compiler:prod": "
|
|
96
|
+
"compiler": "rimraf tsconfig.build.tsbuildinfo && pnpm versioner && pnpm nettoyer && pnpm tsc -p tsconfig.json",
|
|
97
|
+
"compiler:prod": "rimraf tsconfig.build.tsbuildinfo && pnpm versioner && pnpm nettoyer && pnpm tsc -p tsconfig.build.json",
|
|
101
98
|
"test:node": "pnpm compiler && pnpm aegir test -t node -f \"dist/test/**/*.spec.js\" --cov -- --exit",
|
|
102
99
|
"test:navig": "pnpm compiler && pnpm aegir test -t browser -f \"dist/test/**/*.spec.js\" --cov",
|
|
103
100
|
"test:électron-principal": "pnpm compiler && pnpm aegir test -t electron-main -f \"dist/test/**/*.spec.js\" --cov",
|
|
104
101
|
"test:électron-rendu": "pnpm compiler && pnpm aegir test -t electron-renderer -f \"dist/test/**/*.spec.js\" --cov",
|
|
105
102
|
"test": "pnpm test:node && pnpm test:navig",
|
|
106
|
-
"formatter": "pnpm prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\" && pnpm eslint
|
|
107
|
-
"publier": "pnpm compiler:prod && (git commit -a -m 'version' || true) && pnpm stage publish",
|
|
103
|
+
"formatter": "pnpm prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\" && pnpm eslint . --fix",
|
|
104
|
+
"publier": "pnpm test && pnpm compiler:prod && (git commit -a -m 'version' || true) && pnpm stage publish",
|
|
108
105
|
"versioner": "pnpm genversion --es6 --semi src/version.ts"
|
|
109
106
|
}
|
|
110
107
|
}
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
allowBuilds:
|
|
2
|
-
'@ipshipyard/node-datachannel': true
|
|
3
|
-
aws-sdk: false
|
|
4
2
|
bun: true
|
|
5
3
|
classic-level: true
|
|
6
4
|
core-js: true
|
|
7
5
|
deno: true
|
|
8
6
|
electron: true
|
|
9
7
|
esbuild: true
|
|
10
|
-
iso-constants@https://codeload.github.com/inverted-capital/iso-constants/tar.gz/2af6fdfb2cacaa03ebd58543703918783e62649f: true
|
|
11
8
|
node-datachannel: true
|
|
12
9
|
unrs-resolver: true
|
|
13
10
|
|
|
14
|
-
overrides:
|
|
15
|
-
xlsx: "@e965/xlsx"
|
|
16
|
-
|
|
17
|
-
blockExoticSubdeps: false
|
|
18
|
-
|
|
19
11
|
packages: []
|
package/src/@types.ts
CHANGED
package/src/config.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { lancerRelai } from "./relai/index.js";
|
|
1
2
|
import type { PartialOptions } from "aegir";
|
|
2
3
|
import type { BuildOptions } from "esbuild";
|
|
3
4
|
|
|
4
|
-
import { lancerRelai } from "./relai/index.js";
|
|
5
|
-
|
|
6
5
|
export const obtConfigEsbuild = async (): Promise<BuildOptions> => {
|
|
7
6
|
const { createRequire } = (await import("module")).default;
|
|
8
7
|
const path = await import("path");
|
package/src/constellation.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isBrowser } from "wherearewe";
|
|
2
2
|
import { créerOrbitesTest } from "./orbite.js";
|
|
3
3
|
import { dossierTempo } from "./dossiers.js";
|
|
4
|
-
import { OrbitDB } from "@orbitdb/core";
|
|
4
|
+
import type { OrbitDB } from "@orbitdb/core";
|
|
5
5
|
|
|
6
6
|
interface InterfaceConstellation {
|
|
7
7
|
fermer: () => Promise<void>;
|
package/src/h/303/251lia.ts
CHANGED
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
import { Helia, createHelia } from "helia";
|
|
2
|
-
import { ServicesLibp2pTest, créerLibp2psTest } from "./libp2p/index.js";
|
|
3
|
-
import { Libp2p } from "@libp2p/interface";
|
|
4
|
-
import { bitswap } from "@helia/block-brokers";
|
|
5
|
-
import { MemoryBlockstore } from "blockstore-core";
|
|
6
1
|
import { join } from "path";
|
|
7
|
-
import {
|
|
2
|
+
import { MemoryBlockstore } from "blockstore-core";
|
|
3
|
+
import { createHelia } from "helia";
|
|
8
4
|
import { IDBBlockstore } from "blockstore-idb";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { isBrowser, isElectronMain, isNode } from "wherearewe";
|
|
6
|
+
import { type HeliaWithLibp2p } from "@helia/libp2p";
|
|
7
|
+
import { sousDossier } from "./utils.js";
|
|
8
|
+
import {
|
|
9
|
+
OptionsDéfautLibp2pNavigateur,
|
|
10
|
+
OptionsDéfautLibp2pNode,
|
|
11
|
+
toutesConnectées,
|
|
12
|
+
type ServicesLibp2pTest,
|
|
13
|
+
} from "./libp2p/index.js";
|
|
14
|
+
import { obtenirAdresseRelai } from "./relai/index.ts";
|
|
11
15
|
|
|
12
16
|
export const créerHéliasTest = async ({
|
|
13
17
|
n,
|
|
14
18
|
dossier,
|
|
15
|
-
adresseRelai,
|
|
16
19
|
}: {
|
|
17
20
|
n: number;
|
|
18
21
|
dossier?: string;
|
|
19
|
-
adresseRelai?: string;
|
|
20
22
|
}): Promise<{
|
|
21
|
-
hélias:
|
|
23
|
+
hélias: HeliaWithLibp2p<ServicesLibp2pTest>[];
|
|
22
24
|
fermer: () => Promise<void>;
|
|
23
25
|
}> => {
|
|
24
|
-
|
|
26
|
+
const optionsLibp2p = isBrowser
|
|
27
|
+
? OptionsDéfautLibp2pNavigateur()
|
|
28
|
+
: OptionsDéfautLibp2pNode();
|
|
25
29
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return await createHelia(optionsHélia);
|
|
51
|
-
}),
|
|
52
|
-
);
|
|
30
|
+
const hélias: HeliaWithLibp2p<ServicesLibp2pTest>[] = [];
|
|
31
|
+
for (const i of Array(n).keys()) {
|
|
32
|
+
const dossierBlocs = dossier
|
|
33
|
+
? join(sousDossier({ dossier, i }), "hélia", "blocks")
|
|
34
|
+
: undefined;
|
|
35
|
+
const stockageBlocs = dossierBlocs
|
|
36
|
+
? isNode || isElectronMain
|
|
37
|
+
? new (await import("blockstore-fs")).FsBlockstore(dossierBlocs)
|
|
38
|
+
: new IDBBlockstore(dossierBlocs)
|
|
39
|
+
: new MemoryBlockstore();
|
|
40
|
+
(stockageBlocs as IDBBlockstore).open?.();
|
|
41
|
+
const optionsHélia = {
|
|
42
|
+
blockstore: stockageBlocs,
|
|
43
|
+
libp2p: optionsLibp2p,
|
|
44
|
+
};
|
|
45
|
+
const hélia = await createHelia(optionsHélia).start();
|
|
46
|
+
hélias.push(hélia);
|
|
47
|
+
await toutesConnectées(
|
|
48
|
+
hélias.map((h) => h.libp2p),
|
|
49
|
+
{
|
|
50
|
+
adresseRelai: obtenirAdresseRelai(),
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
}
|
|
53
54
|
|
|
54
55
|
const fermer = async () => {
|
|
55
56
|
await Promise.all(
|
|
@@ -59,7 +60,6 @@ export const créerHéliasTest = async ({
|
|
|
59
60
|
await h.blockstore.unwrap()?.unwrap()?.child?.db?.close();
|
|
60
61
|
}),
|
|
61
62
|
);
|
|
62
|
-
await fermerLibsp2p();
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
return { hélias, fermer };
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export {
|
|
2
|
-
ServicesLibp2pTest,
|
|
3
|
-
ComposantesServiceClefPrivée,
|
|
2
|
+
type ServicesLibp2pTest,
|
|
3
|
+
type ComposantesServiceClefPrivée,
|
|
4
4
|
ServiceClefPrivée,
|
|
5
5
|
OptionsDéfautLibp2pNode,
|
|
6
6
|
OptionsDéfautLibp2pNavigateur,
|
|
@@ -26,4 +26,4 @@ export { obtConfigEsbuild, générerConfigÆgir } from "./config.js";
|
|
|
26
26
|
export { créerConstellationsTest } from "./constellation.js";
|
|
27
27
|
export { dossierTempo } from "./dossiers.js";
|
|
28
28
|
export { créerHéliasTest } from "./hélia.js";
|
|
29
|
-
export { créerOrbitesTest } from "./orbite.js";
|
|
29
|
+
export { créerOrbitesTest, attendreSync } from "./orbite.js";
|
package/src/libp2p/config.ts
CHANGED
|
@@ -24,18 +24,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
24
24
|
SOFTWARE.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
gossipsub,
|
|
29
|
+
type GossipSubComponents,
|
|
30
|
+
type GossipSub,
|
|
31
|
+
} from "@libp2p/gossipsub";
|
|
28
32
|
import { noise } from "@chainsafe/libp2p-noise";
|
|
29
33
|
import { yamux } from "@chainsafe/libp2p-yamux";
|
|
30
34
|
import { circuitRelayTransport } from "@libp2p/circuit-relay-v2";
|
|
31
|
-
import { Identify, identify } from "@libp2p/identify";
|
|
35
|
+
import { type Identify, identify } from "@libp2p/identify";
|
|
32
36
|
import { webRTC } from "@libp2p/webrtc";
|
|
33
37
|
import { webSockets } from "@libp2p/websockets";
|
|
34
38
|
|
|
35
|
-
import { Libp2pOptions } from "libp2p";
|
|
39
|
+
import { type Libp2pOptions } from "libp2p";
|
|
36
40
|
|
|
37
|
-
import { PrivateKey } from "@libp2p/interface";
|
|
38
|
-
import { ping, Ping } from "@libp2p/ping";
|
|
41
|
+
import { type PrivateKey } from "@libp2p/interface";
|
|
42
|
+
import { ping, type Ping } from "@libp2p/ping";
|
|
39
43
|
|
|
40
44
|
export type ServicesLibp2pTest = {
|
|
41
45
|
ping: Ping;
|
package/src/libp2p/index.ts
CHANGED
package/src/libp2p/libp2p.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Libp2p } from "@libp2p/interface";
|
|
2
1
|
import { createLibp2p } from "libp2p";
|
|
2
|
+
import { isBrowser } from "wherearewe";
|
|
3
|
+
import { obtenirAdresseRelai } from "../relai/index.js";
|
|
3
4
|
import {
|
|
4
5
|
OptionsDéfautLibp2pNavigateur,
|
|
5
6
|
OptionsDéfautLibp2pNode,
|
|
6
|
-
ServicesLibp2pTest,
|
|
7
|
+
type ServicesLibp2pTest,
|
|
7
8
|
} from "./config.js";
|
|
8
|
-
import { isBrowser } from "wherearewe";
|
|
9
9
|
import { connecterPairs } from "./utils.js";
|
|
10
|
-
import {
|
|
10
|
+
import type { Libp2p } from "@libp2p/interface";
|
|
11
11
|
|
|
12
12
|
export const créerLibp2psTest = async ({
|
|
13
13
|
n,
|
package/src/libp2p/utils.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Libp2p } from "@libp2p/interface";
|
|
2
1
|
import { WebRTC } from "@multiformats/multiaddr-matcher";
|
|
3
|
-
import { multiaddr, Multiaddr } from "@multiformats/multiaddr";
|
|
2
|
+
import { multiaddr, type Multiaddr } from "@multiformats/multiaddr";
|
|
4
3
|
import { isBrowser, isElectronRenderer } from "wherearewe";
|
|
5
|
-
import {
|
|
4
|
+
import { que } from "../attente.ts";
|
|
5
|
+
import type { Libp2p } from "@libp2p/interface";
|
|
6
|
+
import type { ServicesLibp2pTest } from "./config.js";
|
|
6
7
|
|
|
7
8
|
const filtreParDéfaut = () => true;
|
|
8
9
|
|
|
@@ -22,7 +23,7 @@ export const connecterPairs = async <
|
|
|
22
23
|
if (isBrowser || isElectronRenderer) {
|
|
23
24
|
await libp2p1.dial(multiaddr(options.adresseRelai));
|
|
24
25
|
|
|
25
|
-
const adresse1 = await new Promise<Multiaddr>((
|
|
26
|
+
const adresse1 = await new Promise<Multiaddr>((résoudre) => {
|
|
26
27
|
const testConnecté = () => {
|
|
27
28
|
const adresse = libp2p1
|
|
28
29
|
.getMultiaddrs()
|
|
@@ -30,14 +31,15 @@ export const connecterPairs = async <
|
|
|
30
31
|
.pop();
|
|
31
32
|
if (adresse != null) {
|
|
32
33
|
clearInterval(interval);
|
|
33
|
-
|
|
34
|
+
résoudre(adresse);
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
37
|
const interval = setInterval(testConnecté, 100);
|
|
37
38
|
testConnecté();
|
|
38
39
|
});
|
|
39
40
|
libp2p2.dial(adresse1);
|
|
40
|
-
|
|
41
|
+
|
|
42
|
+
await new Promise((résoudre) => {
|
|
41
43
|
const testConnecté = () => {
|
|
42
44
|
const adresse = libp2p1
|
|
43
45
|
.getConnections()
|
|
@@ -45,7 +47,7 @@ export const connecterPairs = async <
|
|
|
45
47
|
.pop();
|
|
46
48
|
if (adresse != null) {
|
|
47
49
|
clearInterval(interval);
|
|
48
|
-
|
|
50
|
+
résoudre(adresse);
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
53
|
const interval = setInterval(testConnecté, 100);
|
|
@@ -56,6 +58,7 @@ export const connecterPairs = async <
|
|
|
56
58
|
multiaddrs: libp2p1.getMultiaddrs().filter(filtre),
|
|
57
59
|
});
|
|
58
60
|
await libp2p2.dial(libp2p1.peerId);
|
|
61
|
+
await que(() => !!libp2p1.getPeers().find((p) => p.equals(libp2p2.peerId)));
|
|
59
62
|
}
|
|
60
63
|
};
|
|
61
64
|
|
package/src/orbite.ts
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import { type BaseDatabase, type OrbitDB, createOrbitDB } from "@orbitdb/core";
|
|
2
3
|
import { dossierTempo } from "./dossiers.js";
|
|
3
|
-
import { ServicesLibp2pTest } from "./libp2p/index.js";
|
|
4
|
+
import { type ServicesLibp2pTest } from "./libp2p/index.js";
|
|
4
5
|
import { créerHéliasTest } from "./hélia.js";
|
|
5
|
-
import { join } from "path";
|
|
6
6
|
import { sousDossier } from "./utils.js";
|
|
7
|
-
import { obtenirAdresseRelai } from "./relai/utils.js";
|
|
8
7
|
|
|
9
8
|
export const créerOrbitesTest = async ({
|
|
10
9
|
n,
|
|
11
10
|
dossier,
|
|
12
|
-
adresseRelai,
|
|
13
11
|
}: {
|
|
14
12
|
n: number;
|
|
15
13
|
dossier?: string;
|
|
16
|
-
adresseRelai?: string;
|
|
17
14
|
}): Promise<{
|
|
18
15
|
orbites: OrbitDB<ServicesLibp2pTest>[];
|
|
19
16
|
fermer: () => Promise<void>;
|
|
20
17
|
}> => {
|
|
21
|
-
adresseRelai = adresseRelai ?? obtenirAdresseRelai();
|
|
22
|
-
|
|
23
18
|
let effacerDossier: () => void = () => {};
|
|
24
19
|
if (!dossier) {
|
|
25
20
|
({ dossier, effacer: effacerDossier } = await dossierTempo());
|
|
@@ -29,7 +24,6 @@ export const créerOrbitesTest = async ({
|
|
|
29
24
|
const { hélias, fermer: fermerHélias } = await créerHéliasTest({
|
|
30
25
|
n,
|
|
31
26
|
dossier,
|
|
32
|
-
adresseRelai,
|
|
33
27
|
});
|
|
34
28
|
|
|
35
29
|
let i = 0;
|
|
@@ -54,3 +48,9 @@ export const créerOrbitesTest = async ({
|
|
|
54
48
|
fermer,
|
|
55
49
|
};
|
|
56
50
|
};
|
|
51
|
+
|
|
52
|
+
export const attendreSync = async (bd: BaseDatabase): Promise<void> => {
|
|
53
|
+
return new Promise<void>((résoudre) => {
|
|
54
|
+
bd.events.once("update", () => résoudre());
|
|
55
|
+
});
|
|
56
|
+
};
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version =
|
|
2
|
+
export const version = '2.2.1';
|