@constl/utils-tests 1.2.7 → 1.4.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/src/config.js +1 -0
- package/dist/src/config.js.map +1 -1
- package/dist/src/constellation.d.ts +7 -4
- package/dist/src/constellation.js +1 -2
- package/dist/src/constellation.js.map +1 -1
- package/dist/src/orbite.js.map +1 -1
- package/dist/src/scripts/relai.js +2 -2
- package/dist/src/scripts/relai.js.map +1 -1
- package/dist/src/sfip.d.ts +7 -5
- package/dist/src/sfip.js +5 -0
- package/dist/src/sfip.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/eslint.config.js +27 -0
- package/package.json +39 -37
- package/src/config.ts +1 -0
- package/src/constellation.ts +10 -9
- package/src/orbite.ts +2 -2
- package/src/scripts/relai.ts +2 -2
- package/src/sfip.ts +20 -8
- package/src/version.ts +1 -1
- package/.eslintignore +0 -3
- package/.eslintrc.cjs +0 -30
package/eslint.config.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import eslint from "@eslint/js";
|
|
2
|
+
import tseslint from "typescript-eslint";
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
eslint.configs.recommended,
|
|
6
|
+
...tseslint.configs.recommended,
|
|
7
|
+
{
|
|
8
|
+
files: ["**/*.js", "**/*.ts"],
|
|
9
|
+
languageOptions: {
|
|
10
|
+
parserOptions: {
|
|
11
|
+
ecmaVersion: 12,
|
|
12
|
+
sourceType: "module",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
17
|
+
"@typescript-eslint/no-unused-vars": [
|
|
18
|
+
"warn",
|
|
19
|
+
{
|
|
20
|
+
argsIgnorePattern: "^_",
|
|
21
|
+
varsIgnorePattern: "^_",
|
|
22
|
+
caughtErrorsIgnorePattern: "^_",
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
];
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.4.1",
|
|
3
3
|
"license": "AGPL-3.0-or-later",
|
|
4
4
|
"name": "@constl/utils-tests",
|
|
5
5
|
"author": "Julien Jean Malard-Adam",
|
|
@@ -20,52 +20,54 @@
|
|
|
20
20
|
"postbuild": "./dist/**/*"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@chainsafe/libp2p-gossipsub": "^
|
|
24
|
-
"@chainsafe/libp2p-noise": "^15.
|
|
23
|
+
"@chainsafe/libp2p-gossipsub": "^13.1.0",
|
|
24
|
+
"@chainsafe/libp2p-noise": "^15.1.0",
|
|
25
25
|
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
26
|
-
"@constl/ipa": "1.
|
|
27
|
-
"@
|
|
28
|
-
"@libp2p/
|
|
29
|
-
"@libp2p/
|
|
30
|
-
"@libp2p/
|
|
31
|
-
"@libp2p/
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
26
|
+
"@constl/ipa": "1.1.2",
|
|
27
|
+
"@eslint/js": "^9.7.0",
|
|
28
|
+
"@libp2p/circuit-relay-v2": "^1.1.2",
|
|
29
|
+
"@libp2p/crypto": "^4.1.6",
|
|
30
|
+
"@libp2p/identify": "^2.1.2",
|
|
31
|
+
"@libp2p/interface": "^1.6.1",
|
|
32
|
+
"@libp2p/peer-id-factory": "^4.2.1",
|
|
33
|
+
"@libp2p/websockets": "^8.1.2",
|
|
34
|
+
"@multiformats/multiaddr": "^12.3.0",
|
|
35
|
+
"@multiformats/multiaddr-matcher": "^1.2.4",
|
|
36
|
+
"@orbitdb/feed-db": "^1.0.1",
|
|
35
37
|
"@types/crypto-js": "^4.2.2",
|
|
36
38
|
"@types/file-saver": "^2.0.7",
|
|
37
|
-
"@types/mocha": "^10.0.
|
|
38
|
-
"@types/node": "^20.14.
|
|
39
|
-
"@types/uuid": "^
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
41
|
-
"@typescript-eslint/parser": "^7.
|
|
42
|
-
"aegir": "^
|
|
39
|
+
"@types/mocha": "^10.0.7",
|
|
40
|
+
"@types/node": "^20.14.11",
|
|
41
|
+
"@types/uuid": "^10.0.0",
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^7.16.1",
|
|
43
|
+
"@typescript-eslint/parser": "^7.16.1",
|
|
44
|
+
"aegir": "^44.0.1",
|
|
43
45
|
"buffer": "^6.0.3",
|
|
44
46
|
"core-js": "^3.37.1",
|
|
45
|
-
"electron": "^
|
|
46
|
-
"esbuild": "^0.
|
|
47
|
-
"eslint": "^
|
|
47
|
+
"electron": "^31.2.1",
|
|
48
|
+
"esbuild": "^0.23.0",
|
|
49
|
+
"eslint": "^9.7.0",
|
|
48
50
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
49
51
|
"eslint-config-prettier": "^9.1.0",
|
|
50
52
|
"eslint-config-standard": "^17.1.0",
|
|
51
53
|
"eslint-plugin-import": "^2.29.1",
|
|
52
|
-
"eslint-plugin-
|
|
53
|
-
"eslint-plugin-promise": "^6.
|
|
54
|
-
"execa": "^
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"prettier": "^3.3.0",
|
|
54
|
+
"eslint-plugin-n": "^17.9.0",
|
|
55
|
+
"eslint-plugin-promise": "^6.4.0",
|
|
56
|
+
"execa": "^9.3.0",
|
|
57
|
+
"mocha": "^10.6.0",
|
|
58
|
+
"playwright": "^1.45.2",
|
|
59
|
+
"prettier": "^3.3.3",
|
|
59
60
|
"source-map-support": "^0.5.21",
|
|
60
|
-
"ts-patch": "^3.2.
|
|
61
|
+
"ts-patch": "^3.2.1",
|
|
61
62
|
"tsconfig-paths": "^4.2.0",
|
|
62
63
|
"tscpaths": "^0.0.9",
|
|
63
|
-
"typescript": "5.
|
|
64
|
+
"typescript": "5.4.5",
|
|
65
|
+
"typescript-eslint": "^7.16.1",
|
|
64
66
|
"typescript-transform-paths": "^3.4.7"
|
|
65
67
|
},
|
|
66
68
|
"dependencies": {
|
|
67
|
-
"@helia/block-brokers": "^
|
|
68
|
-
"@orbitdb/quickstart": "
|
|
69
|
+
"@helia/block-brokers": "^3.0.2",
|
|
70
|
+
"@orbitdb/quickstart": "git+https://github.com/orbitdb/quickstart.git#1557ffe",
|
|
69
71
|
"blockstore-core": "^4.4.1",
|
|
70
72
|
"blockstore-level": "^1.1.8",
|
|
71
73
|
"browserify-fs": "^1.0.0",
|
|
@@ -73,16 +75,16 @@
|
|
|
73
75
|
"crypto-browserify": "^3.12.0",
|
|
74
76
|
"events": "^3.3.0",
|
|
75
77
|
"genversion": "^3.2.0",
|
|
76
|
-
"helia": "^
|
|
77
|
-
"libp2p": "^1.
|
|
78
|
+
"helia": "^4.2.4",
|
|
79
|
+
"libp2p": "^1.8.1",
|
|
78
80
|
"os-browserify": "^0.3.0",
|
|
79
81
|
"process": "^0.11.10",
|
|
80
82
|
"read-package-up": "^11.0.0",
|
|
81
|
-
"rimraf": "^
|
|
83
|
+
"rimraf": "^6.0.1",
|
|
82
84
|
"stream-browserify": "^3.0.0",
|
|
83
85
|
"uint8arrays": "^5.1.0",
|
|
84
86
|
"url-polyfill": "^1.1.12",
|
|
85
|
-
"uuid": "^
|
|
87
|
+
"uuid": "^10.0.0",
|
|
86
88
|
"wherearewe": "^2.0.1"
|
|
87
89
|
},
|
|
88
90
|
"scripts": {
|
|
@@ -93,7 +95,7 @@
|
|
|
93
95
|
"test:électron-principal": "pnpm compiler && pnpm aegir test -t electron-main --cov",
|
|
94
96
|
"test:électron-rendu": "pnpm compiler && pnpm aegir test -t electron-renderer --cov",
|
|
95
97
|
"test": "pnpm test:node && pnpm test:navig",
|
|
96
|
-
"formatter": "pnpm prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\" && pnpm eslint
|
|
98
|
+
"formatter": "pnpm prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\" && pnpm eslint src",
|
|
97
99
|
"publier": "pnpm test && (git commit -a -m 'version' || true) && pnpm publish",
|
|
98
100
|
"versioner": "pnpm genversion --es6 --semi src/version.ts"
|
|
99
101
|
}
|
package/src/config.ts
CHANGED
package/src/constellation.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { réseau, client,
|
|
1
|
+
import type { réseau, client, Constellation } from "@constl/ipa";
|
|
2
|
+
import type { OrbitDB } from "@orbitdb/core";
|
|
2
3
|
import { isBrowser } from "wherearewe";
|
|
3
4
|
|
|
4
5
|
import { créerOrbiteTest } from "@/orbite.js";
|
|
5
6
|
import { AttendreRésultat } from "@/attente.js";
|
|
6
7
|
|
|
7
8
|
export const créerConstellationsTest = async <
|
|
8
|
-
T =
|
|
9
|
+
T = Constellation,
|
|
9
10
|
U = client.optsConstellation,
|
|
10
11
|
>({
|
|
11
12
|
n = 1,
|
|
@@ -15,6 +16,7 @@ export const créerConstellationsTest = async <
|
|
|
15
16
|
créerConstellation: (opts: U) => T;
|
|
16
17
|
}): Promise<{
|
|
17
18
|
clients: ReturnType<typeof créerConstellation>[];
|
|
19
|
+
orbites: OrbitDB[];
|
|
18
20
|
fOublier: () => Promise<void>;
|
|
19
21
|
}> => {
|
|
20
22
|
const clients: ReturnType<typeof créerConstellation>[] = [];
|
|
@@ -36,23 +38,23 @@ export const créerConstellationsTest = async <
|
|
|
36
38
|
|
|
37
39
|
const fOublier = async () => {
|
|
38
40
|
await Promise.all(
|
|
39
|
-
clients.map((client) => (client as
|
|
41
|
+
clients.map((client) => (client as Constellation).fermer()),
|
|
40
42
|
);
|
|
41
43
|
await Promise.all(fsOublier.map((f) => f()));
|
|
42
44
|
};
|
|
43
|
-
return { fOublier, clients };
|
|
45
|
+
return { fOublier, clients, orbites };
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
export const constellationConnectéeÀ = async (
|
|
47
|
-
constellation: client.
|
|
48
|
-
connectéeÀ: client.
|
|
49
|
+
constellation: client.Constellation,
|
|
50
|
+
connectéeÀ: client.Constellation,
|
|
49
51
|
): Promise<void> => {
|
|
50
52
|
const dispositifsConnectés = new AttendreRésultat<
|
|
51
53
|
réseau.statutDispositif[]
|
|
52
54
|
>();
|
|
53
55
|
const idCompte2 = await connectéeÀ.obtIdCompte();
|
|
54
56
|
|
|
55
|
-
const fOublier = await constellation.réseau
|
|
57
|
+
const fOublier = await constellation.réseau.suivreConnexionsDispositifs({
|
|
56
58
|
f: (dispositifs) => dispositifsConnectés.mettreÀJour(dispositifs),
|
|
57
59
|
});
|
|
58
60
|
await dispositifsConnectés.attendreQue((dispositifs) => {
|
|
@@ -63,7 +65,7 @@ export const constellationConnectéeÀ = async (
|
|
|
63
65
|
};
|
|
64
66
|
|
|
65
67
|
export const constellationsConnectées = async (
|
|
66
|
-
...clients: client.
|
|
68
|
+
...clients: client.Constellation[]
|
|
67
69
|
): Promise<void> => {
|
|
68
70
|
if (clients.length < 2) return;
|
|
69
71
|
const promesses: Promise<void>[] = [];
|
|
@@ -74,5 +76,4 @@ export const constellationsConnectées = async (
|
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
await Promise.all(promesses);
|
|
77
|
-
return;
|
|
78
79
|
};
|
package/src/orbite.ts
CHANGED
|
@@ -24,7 +24,7 @@ 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 type {
|
|
27
|
+
import type { HeliaLibp2p } from "helia";
|
|
28
28
|
import type {
|
|
29
29
|
FeedStoreTypé,
|
|
30
30
|
KeyValueStoreTypé,
|
|
@@ -46,7 +46,7 @@ export const créerOrbiteTest = async ({
|
|
|
46
46
|
}: {
|
|
47
47
|
n: number;
|
|
48
48
|
}): Promise<{ orbites: OrbitDB[]; fOublier: () => Promise<void> }> => {
|
|
49
|
-
const sfips:
|
|
49
|
+
const sfips: HeliaLibp2p[] = [];
|
|
50
50
|
const orbites: OrbitDB[] = [];
|
|
51
51
|
|
|
52
52
|
const {
|
package/src/scripts/relai.ts
CHANGED
|
@@ -32,7 +32,7 @@ import { webSockets } from "@libp2p/websockets";
|
|
|
32
32
|
import * as filters from "@libp2p/websockets/filters";
|
|
33
33
|
import { identify } from "@libp2p/identify";
|
|
34
34
|
import { createFromPrivKey } from "@libp2p/peer-id-factory";
|
|
35
|
-
import {
|
|
35
|
+
import { keys } from "@libp2p/crypto";
|
|
36
36
|
import { fromString as uint8ArrayFromString } from "uint8arrays/from-string";
|
|
37
37
|
|
|
38
38
|
// output of: console.log(server.peerId.privateKey.toString('hex'))
|
|
@@ -42,7 +42,7 @@ const relayPrivKey =
|
|
|
42
42
|
// const relayId = '12D3KooWAJjbRkp8FPF5MKgMU53aUTxWkqvDrs4zc1VMbwRwfsbE'
|
|
43
43
|
|
|
44
44
|
const encoded = uint8ArrayFromString(relayPrivKey, "hex");
|
|
45
|
-
const privateKey = await unmarshalPrivateKey(encoded);
|
|
45
|
+
const privateKey = await keys.unmarshalPrivateKey(encoded);
|
|
46
46
|
const peerId = await createFromPrivKey(privateKey);
|
|
47
47
|
|
|
48
48
|
const relai = await createLibp2p({
|
package/src/sfip.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
|
|
2
2
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
|
3
3
|
|
|
4
|
-
import { createHelia, type
|
|
4
|
+
import { DefaultLibp2pServices, createHelia, type HeliaLibp2p } from "helia";
|
|
5
5
|
import { bitswap } from "@helia/block-brokers";
|
|
6
6
|
import { createLibp2p, Libp2p } from "libp2p";
|
|
7
7
|
import { MemoryBlockstore } from "blockstore-core";
|
|
8
8
|
import { LevelBlockstore } from "blockstore-level";
|
|
9
9
|
import { multiaddr } from "@multiformats/multiaddr";
|
|
10
10
|
import { WebRTC } from "@multiformats/multiaddr-matcher";
|
|
11
|
+
import {} from "@libp2p/interface";
|
|
11
12
|
|
|
12
13
|
import { isBrowser, isElectronRenderer } from "wherearewe";
|
|
13
14
|
|
|
@@ -20,7 +21,7 @@ export const créerHéliaTest = async ({
|
|
|
20
21
|
dossier,
|
|
21
22
|
}: {
|
|
22
23
|
dossier?: string;
|
|
23
|
-
} = {}): Promise<
|
|
24
|
+
} = {}): Promise<HeliaLibp2p<Libp2p<{ pubsub: GossipSub }>>> => {
|
|
24
25
|
const options =
|
|
25
26
|
isBrowser || isElectronRenderer
|
|
26
27
|
? DefaultLibp2pBrowserOptions
|
|
@@ -40,14 +41,16 @@ export const créerHéliaTest = async ({
|
|
|
40
41
|
blockBrokers: [bitswap()],
|
|
41
42
|
};
|
|
42
43
|
|
|
43
|
-
return createHelia
|
|
44
|
+
return createHelia({ ...heliaOptions });
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
const filtreParDéfaut = () => true;
|
|
47
48
|
|
|
48
|
-
export const connecterPairs = async
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
export const connecterPairs = async <
|
|
50
|
+
T extends Libp2p = Libp2p<DefaultLibp2pServices>,
|
|
51
|
+
>(
|
|
52
|
+
sfip1: HeliaLibp2p<T>,
|
|
53
|
+
sfip2: HeliaLibp2p<T>,
|
|
51
54
|
options = {
|
|
52
55
|
filtre: filtreParDéfaut,
|
|
53
56
|
},
|
|
@@ -82,8 +85,10 @@ export const connecterPairs = async (
|
|
|
82
85
|
}
|
|
83
86
|
};
|
|
84
87
|
|
|
85
|
-
export const toutesConnectées = async (
|
|
86
|
-
|
|
88
|
+
export const toutesConnectées = async (
|
|
89
|
+
sfips: HeliaLibp2p<Libp2p<{ pubsub: GossipSub }>>[],
|
|
90
|
+
) => {
|
|
91
|
+
const connectés: HeliaLibp2p<Libp2p<{ pubsub: GossipSub }>>[] = [];
|
|
87
92
|
for (const sfip of sfips) {
|
|
88
93
|
for (const autre of connectés) {
|
|
89
94
|
await connecterPairs(sfip, autre);
|
|
@@ -103,9 +108,16 @@ export const constObtFichierRelai = async (): Promise<string> => {
|
|
|
103
108
|
|
|
104
109
|
export const lancerRelai = async () => {
|
|
105
110
|
const { $ } = await import("execa");
|
|
111
|
+
|
|
106
112
|
const fichierRelai = await constObtFichierRelai();
|
|
107
113
|
|
|
108
114
|
const relai = $`node ${fichierRelai} &`;
|
|
115
|
+
|
|
116
|
+
relai.catch((e) => {
|
|
117
|
+
// Ignorer l'erreur causée par la termination du processus par notre code
|
|
118
|
+
if (e.signal !== "SIGTERM") throw new Error(e);
|
|
119
|
+
});
|
|
120
|
+
|
|
109
121
|
return () => relai.kill();
|
|
110
122
|
};
|
|
111
123
|
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = "1.
|
|
2
|
+
export const version = "1.4.1";
|
package/.eslintignore
DELETED
package/.eslintrc.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
browser: true,
|
|
4
|
-
es2021: true,
|
|
5
|
-
node: true,
|
|
6
|
-
},
|
|
7
|
-
extends: [
|
|
8
|
-
"eslint:recommended",
|
|
9
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
10
|
-
"plugin:@typescript-eslint/recommended",
|
|
11
|
-
"prettier",
|
|
12
|
-
],
|
|
13
|
-
parser: "@typescript-eslint/parser",
|
|
14
|
-
parserOptions: {
|
|
15
|
-
ecmaVersion: 12,
|
|
16
|
-
sourceType: "module",
|
|
17
|
-
},
|
|
18
|
-
plugins: ["@typescript-eslint"],
|
|
19
|
-
rules: {
|
|
20
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
21
|
-
"@typescript-eslint/no-unused-vars": [
|
|
22
|
-
"warn",
|
|
23
|
-
{
|
|
24
|
-
"argsIgnorePattern": "^_",
|
|
25
|
-
"varsIgnorePattern": "^_",
|
|
26
|
-
"caughtErrorsIgnorePattern": "^_"
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
},
|
|
30
|
-
};
|