From aae15ecdf3da4be48b7488cc61fcbd0ea56d114d Mon Sep 17 00:00:00 2001 From: julienmalard Date: Mon, 3 Mar 2025 12:14:30 +0100 Subject: [PATCH 01/11] =?UTF-8?q?Arr=C3=AAter=20libp2p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index d8ce797c14..b7b57b12bc 100644 --- a/src/client.ts +++ b/src/client.ts @@ -2768,7 +2768,10 @@ export class Constellation { await this.épingles.fermer(); await orbite.fermer({ arrêterOrbite: !this._orbiteExterne }); - if (this.sfip && !this._sfipExterne) await this.sfip.stop(); + if (this.sfip && !this._sfipExterne) { + await this.sfip.stop(); + await this.sfip.libp2p.stop(); + } // Effacer fichier verrou await this.effacerVerrou(); From ad4676a048c34b2179cbe1ae5e7e1e99291ad8d9 Mon Sep 17 00:00:00 2001 From: julienmalard Date: Mon, 3 Mar 2025 12:16:39 +0100 Subject: [PATCH 02/11] version --- package.json | 2 +- src/version.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d434e61a7f..32fb79c9c8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.5.17", + "version": "1.5.18", "license": "AGPL-3.0-or-later", "name": "@constl/ipa", "author": "Julien Jean Malard-Adam", diff --git a/src/version.ts b/src/version.ts index d8f56aa944..0de0439172 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,2 +1,2 @@ // Generated by genversion. -export const version = "1.5.17"; +export const version = "1.5.18"; From 7805c01b8a29710b389aa593a58a6f32c32a702e Mon Sep 17 00:00:00 2001 From: julienmalard Date: Fri, 28 Feb 2025 22:39:02 +0100 Subject: [PATCH 03/11] Communication directe pour messages entre pairs --- docu/src/ipa/client.md | 8 +- package.json | 21 +- pnpm-lock.yaml | 304 +++------- src/client.ts | 40 +- src/const.ts | 2 + src/encryption.ts | 124 ---- src/index.ts | 1 - src/reseau.ts | 486 +++++++++------- test/encryption.spec.ts | 51 -- "test/r\303\251seau.spec.ts" | 1048 +++++++++++++++++++--------------- 10 files changed, 966 insertions(+), 1119 deletions(-) delete mode 100644 src/encryption.ts delete mode 100644 test/encryption.spec.ts diff --git a/docu/src/ipa/client.md b/docu/src/ipa/client.md index d62c2daabf..ea1c448b88 100644 --- a/docu/src/ipa/client.md +++ b/docu/src/ipa/client.md @@ -107,20 +107,20 @@ const idDispositif = await client.obtIdDispositif(); ``` -### `client.obtIdSFIP()` -Obtenir l'identifiant du nœud de Système de fichiers interplanétaire ([SFIP](https://ipfs.io/)) connecté au compte Constellation. +### `client.obtIdLibp2p()` +Obtenir l'identifiant libp2p du dispositif présent. #### Retour | Type | Description | | ---- | ----------- | -| `Promise` | L'identifiant SFIP du compte. | +| `Promise` | L'identifiant libp2p du dispositif. | #### Exemple ```ts import { créerConstellation } from "@constl/ipa"; const client = créerConstellation(); -const idSFIP = await client.obtIdSFIP(); +const idLibp2p = await client.obtIdLibp2p(); ``` diff --git a/package.json b/package.json index 32fb79c9c8..8b2d8dbf31 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "express": "^4.21.2", "globals": "^15.15.0", "image-type": "^5.2.0", + "it-stream-types": "^2.0.2", "keyv": "^5.2.3", "mocha": "^11.1.0", "os-browserify": "^0.3.0", @@ -107,24 +108,23 @@ "@ipld/dag-cbor": "^9.2.2", "@lassi-js/kili": "^0.4.1", "@libp2p/autonat": "^2.0.24", - "@libp2p/bootstrap": "^11.0.27", - "@libp2p/circuit-relay-v2": "^3.2.3", + "@libp2p/bootstrap": "^11.0.28", + "@libp2p/circuit-relay-v2": "^3.2.4", "@libp2p/dcutr": "^2.0.23", "@libp2p/identify": "^3.0.23", "@libp2p/interface-transport": "^4.0.3", - "@libp2p/kad-dht": "^14.2.10", - "@libp2p/mdns": "^11.0.27", + "@libp2p/kad-dht": "^14.2.11", + "@libp2p/mdns": "^11.0.28", "@libp2p/peer-id": "^5.0.14", "@libp2p/ping": "^2.0.23", "@libp2p/pubsub-peer-discovery": "^11.0.1", "@libp2p/tcp": "^10.1.3", "@libp2p/upnp-nat": "^3.1.7", - "@libp2p/webrtc": "^5.2.4", + "@libp2p/webrtc": "^5.2.5", "@libp2p/websockets": "^9.2.3", - "@libp2p/webtransport": "^5.0.32", - "@localfirst/auth": "^6.0.0", - "@localfirst/crypto": "^6.0.0", + "@libp2p/webtransport": "^5.0.33", "@multiformats/multiaddr-matcher": "^1.6.0", + "@noble/hashes": "^1.7.1", "@orbitdb/core": "^2.5.0", "@orbitdb/feed-db": "^1.1.2", "@orbitdb/ordered-keyvalue-db": "^1.1.2", @@ -136,6 +136,7 @@ "blockstore-fs": "^2.0.2", "blockstore-idb": "^2.0.1", "browser-fs-access": "^0.35.0", + "bs58": "^6.0.0", "chokidar": "^4.0.3", "crypto-js": "^4.2.0", "datastore-fs": "^10.0.2", @@ -153,9 +154,11 @@ "indexed-db-stream": "^1.0.0", "iso-constants": "github:inverted-capital/iso-constants#patch-1", "it-drain": "^3.0.7", + "it-pipe": "^3.0.1", + "it-pushable": "^3.2.3", "it-to-buffer": "^4.0.7", "jszip": "^3.10.1", - "libp2p": "^2.7.3", + "libp2p": "^2.7.4", "lodash-es": "^4.17.21", "merge-options": "^3.0.4", "multiformats": "^13.3.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 337351337c..dd2f90adb0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,11 +45,11 @@ importers: specifier: ^2.0.24 version: 2.0.24 '@libp2p/bootstrap': - specifier: ^11.0.27 - version: 11.0.27 + specifier: ^11.0.28 + version: 11.0.28 '@libp2p/circuit-relay-v2': - specifier: ^3.2.3 - version: 3.2.3 + specifier: ^3.2.4 + version: 3.2.4 '@libp2p/dcutr': specifier: ^2.0.23 version: 2.0.23 @@ -60,11 +60,11 @@ importers: specifier: ^4.0.3 version: 4.0.3 '@libp2p/kad-dht': - specifier: ^14.2.10 - version: 14.2.10 + specifier: ^14.2.11 + version: 14.2.11 '@libp2p/mdns': - specifier: ^11.0.27 - version: 11.0.27 + specifier: ^11.0.28 + version: 11.0.28 '@libp2p/peer-id': specifier: ^5.0.14 version: 5.0.14 @@ -81,23 +81,20 @@ importers: specifier: ^3.1.7 version: 3.1.7 '@libp2p/webrtc': - specifier: ^5.2.4 - version: 5.2.4(react-native@0.76.6(@babel/core@7.26.9)(@babel/preset-env@7.26.0(@babel/core@7.26.9))(react@18.3.1)) + specifier: ^5.2.5 + version: 5.2.5(react-native@0.76.6(@babel/core@7.26.9)(@babel/preset-env@7.26.0(@babel/core@7.26.9))(react@18.3.1)) '@libp2p/websockets': specifier: ^9.2.3 version: 9.2.3 '@libp2p/webtransport': - specifier: ^5.0.32 - version: 5.0.32 - '@localfirst/auth': - specifier: ^6.0.0 - version: 6.0.0 - '@localfirst/crypto': - specifier: ^6.0.0 - version: 6.0.0 + specifier: ^5.0.33 + version: 5.0.33 '@multiformats/multiaddr-matcher': specifier: ^1.6.0 version: 1.6.0 + '@noble/hashes': + specifier: ^1.7.1 + version: 1.7.1 '@orbitdb/core': specifier: ^2.5.0 version: 2.5.0 @@ -131,6 +128,9 @@ importers: browser-fs-access: specifier: ^0.35.0 version: 0.35.0 + bs58: + specifier: ^6.0.0 + version: 6.0.0 chokidar: specifier: ^4.0.3 version: 4.0.3 @@ -182,6 +182,12 @@ importers: it-drain: specifier: ^3.0.7 version: 3.0.7 + it-pipe: + specifier: ^3.0.1 + version: 3.0.1 + it-pushable: + specifier: ^3.2.3 + version: 3.2.3 it-to-buffer: specifier: ^4.0.7 version: 4.0.7 @@ -189,8 +195,8 @@ importers: specifier: ^3.10.1 version: 3.10.1 libp2p: - specifier: ^2.7.3 - version: 2.7.3 + specifier: ^2.7.4 + version: 2.7.4 lodash-es: specifier: ^4.17.21 version: 4.17.21 @@ -357,6 +363,9 @@ importers: image-type: specifier: ^5.2.0 version: 5.2.0 + it-stream-types: + specifier: ^2.0.2 + version: 2.0.2 keyv: specifier: ^5.2.3 version: 5.2.3 @@ -1925,9 +1934,6 @@ packages: '@helia/utils@1.2.1': resolution: {integrity: sha512-qvr2Um9rtM/vNQX9/rCM25XTnZzY3FI7txN2AC/pb1eN8UH6+W8aynoj9EhDVp0LHBJLXU519tWyuvsdOyquYg==} - '@herbcaudill/eventemitter42@0.3.3': - resolution: {integrity: sha512-eeHXSsVu9yMOkriTNg3HegRHyCT+kdoPw/kvwNVRp+XjcJVYgX8kb+Fe6NuLun16G18F8z4DK1ghoGG5Ddsm1Q==} - '@humanfs/core@0.19.1': resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} engines: {node: '>=18.18.0'} @@ -2052,11 +2058,11 @@ packages: '@libp2p/autonat@2.0.24': resolution: {integrity: sha512-l++B5SGEOWPM2gn1TOUckiWp8WaHBIg8ZvphQNctutIom7dAWwN2Q+gnQ6HTKlQZQY6jT2MDrHwWVbshogbheA==} - '@libp2p/bootstrap@11.0.27': - resolution: {integrity: sha512-mDz6Kv41hLJYkpklIoIhTCjv70Bn2eXpK7K0YEy+Xcp6uApaV1q5ieB+dQSn5P5XDJb5tm6L18XrKEycbQsALA==} + '@libp2p/bootstrap@11.0.28': + resolution: {integrity: sha512-QhFF5icdDZFKlJS2EPnu17nn9vkfYoI9YN2fLCSRoR7jymDCz9fZz/OKDmaeXo+2Qmlley3Pbgw19WwX1YFLMw==} - '@libp2p/circuit-relay-v2@3.2.3': - resolution: {integrity: sha512-diearrX4Odo8L033DmN+PHqi8bdisi33XAfFGnRpd9zMMNhiZz2nMFQb3IY/eR7ugv9jRZxiD7WyGxstVOjF5A==} + '@libp2p/circuit-relay-v2@3.2.4': + resolution: {integrity: sha512-335OgOD8Dpjdf/EzzuJPus38Vw6Q6z9eQl9GDBFPJ2W0OGcgJbAu6bzFvE2HHRqDxLAt+faAb1D2Peup1TzolQ==} '@libp2p/config@1.1.1': resolution: {integrity: sha512-AGZfD8VTt++qJSBPyFHHlIzAfZeReL/PrDT6/p0U84O0Q+T3h/nHBNATOOyLaV9zwldyZEIMZAnWKcXgKPoZNQ==} @@ -2109,8 +2115,8 @@ packages: resolution: {integrity: sha512-p/M7plbrxLzuQchvNwww1Was7ZeGE2NaOFulMaZBYIihU8z3fhaV+a033OqnC/0NTX/yhfdNOG7znhYq3XoR/g==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} - '@libp2p/kad-dht@14.2.10': - resolution: {integrity: sha512-YCBJWxfGNW7yo3mbHPjBOA5xBXxmMvVuYvct5105YkjKnFcKbZV0k35MYS/J30M6OJlONONlzbMg//jP9gnmTw==} + '@libp2p/kad-dht@14.2.11': + resolution: {integrity: sha512-V0fSKMH0zkB3Qx+x4VkIl279SrmKIwsV1WzLilWD9hlhSLQbQWnKoS6B8X2nd19fT2FD1ujTdC/Edokx8utZPg==} '@libp2p/keychain@5.1.1': resolution: {integrity: sha512-YywXsQJ63dQ6aLSTAcV4Z4vqOzTFhB11QDXFu4V0qWO8p1gMJsWFqsTpwNbBigV4ZsnIbSht2fap0xEMLUOblQ==} @@ -2122,11 +2128,11 @@ packages: '@libp2p/logger@5.1.10': resolution: {integrity: sha512-1Wh0nmW5edgyWyD/Wwt0YidzhZ/r9xA30m39kwo+9rsoWjOSThlhwr6jckuIPlPOCEPXevZDH0FNC/2mH5I1Ng==} - '@libp2p/mdns@11.0.27': - resolution: {integrity: sha512-IkTP8NtmUNJhAeQROzq4Hy2e7OhpJVff83jmtuRgC1tTj7y4Ruw5XfPNkUAFTk1MJSL3kUSighBo/LHw0wCciQ==} + '@libp2p/mdns@11.0.28': + resolution: {integrity: sha512-P/lbvV8kEgBfluPWg6DH40w4kRuL5H0DQWvDFZerjXx1jESdCC5+Y4SQrYIhCQFU24qSLhDL9vzsD91cdV2U6A==} - '@libp2p/mplex@11.0.27': - resolution: {integrity: sha512-F1WrzuHHCm88TTmy+XhnZqT7+swoYC95P58WKSZ1gF3i8UeiejSPW/7kdQTonlK1jiLYm9o/6/XJNW1eKysZNA==} + '@libp2p/mplex@11.0.28': + resolution: {integrity: sha512-SXICLqSZUX/uhRKEyQCDuhaeSi2ukz2E/WkhpbM9J5r0htNR5/7DrcpaPD1D+FVoED5wqvFOzyQazljFBOUk9A==} '@libp2p/multistream-select@6.0.17': resolution: {integrity: sha512-IvHzfcrEiGUL2iHFR6oqXm3XjpWXOS4HuL4wrlBt0Y/KU85vJ2Uqxk9bWsujWAzdZt7ArSjm8Ot9FLhXtXJE+Q==} @@ -2181,64 +2187,19 @@ packages: '@libp2p/utils@6.5.5': resolution: {integrity: sha512-WidS5xlEhdWExeXI9ryUF2Xl2qzgdcHSMe44V+qt502ik0ehH2NIaZBZAmlz9ugNGW9D5me4mEm8mi12WxBjPw==} - '@libp2p/webrtc@5.2.4': - resolution: {integrity: sha512-cwwtZvwQh3Kdrp5d0Y1BQkv7BmpCw/uqNsvHJeOuwvU1jLW8Cnp8Yg9KdNbgykjx6SgLrp4tva3AYr/zDSDRBg==} + '@libp2p/webrtc@5.2.5': + resolution: {integrity: sha512-D3jzUfZ0okpOixRnyt+Bt8dVBzM9VhpUopx3ZAka7dp+CQlPjXD0sIAklB3XvF6oTfVMytFSpNUt7cTNvqgQxw==} '@libp2p/websockets@9.2.3': resolution: {integrity: sha512-YvWkaFC4QUAl9d9r0A86O+x2M4z1Bz7Ff85DPi4mSN1cQQm3ky3JU1oXy5+Zg4V+VqVCTaAvu6IzjuwL8tKFIA==} - '@libp2p/webtransport@5.0.32': - resolution: {integrity: sha512-g1amssP7FvjlURWcIEJKx6a2gpqz18hf4Y34UxErJmEelmcPkNkxA/202T85ajPpgXi51Itw5ktlha5vGCHxqw==} - - '@localfirst/auth@6.0.0': - resolution: {integrity: sha512-qEs0bhVKV9c1VnzWErRYk6j3DcM3CqAuNAj4DR3dZzBc6tGEYkPvzB6CpoOAxlz/i7U77SGFkvT9BWfk22zreQ==} - engines: {node: '>=18'} - - '@localfirst/crdx@6.0.0': - resolution: {integrity: sha512-uuQ6G1WlubO6fMTwMai0Iysf2Qye8ojB4b6DEbxZESeSErdrjkBFQd7YRj9WihLFagTF6jvg/58OSLjE3I7KdQ==} - engines: {node: '>=18'} - - '@localfirst/crypto@6.0.0': - resolution: {integrity: sha512-hlZfry2BilI2F2KTp0m700gub9Y39Zh7Ba4guxA5BAIiIYaDIfACkEl912xSajN07CXc2SKhmTKNmfZvHlM8vg==} - engines: {node: '>=18'} - - '@localfirst/shared@6.0.0': - resolution: {integrity: sha512-qYl4SNbXBN4NIrWnskeTwGMkWI90vq+uhIO7AfUY4yoYtLoG+nyo352npX8xB8/aeEGVyR8rXXJu6bCsmnnxUw==} + '@libp2p/webtransport@5.0.33': + resolution: {integrity: sha512-XLBb72TRa6LEizGgeaVR5eHsPa7M8cIXe9Xmr/UWevRHZHbb0wLvQehpHZKyqjL0Sxkayiq0xts9sEQSofiMWA==} '@mrmlnc/readdir-enhanced@2.2.1': resolution: {integrity: sha512-bPHp6Ji8b41szTOcaP63VlnbbO5Ny6dwAATtY6JTjh5N2OLrb5Qk/Th5cRkRQhkWCt+EJsYrNB0MiL+Gpn6e3g==} engines: {node: '>=4'} - '@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3': - resolution: {integrity: sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw==} - cpu: [arm64] - os: [darwin] - - '@msgpackr-extract/msgpackr-extract-darwin-x64@3.0.3': - resolution: {integrity: sha512-mdzd3AVzYKuUmiWOQ8GNhl64/IoFGol569zNRdkLReh6LRLHOXxU4U8eq0JwaD8iFHdVGqSy4IjFL4reoWCDFw==} - cpu: [x64] - os: [darwin] - - '@msgpackr-extract/msgpackr-extract-linux-arm64@3.0.3': - resolution: {integrity: sha512-YxQL+ax0XqBJDZiKimS2XQaf+2wDGVa1enVRGzEvLLVFeqa5kx2bWbtcSXgsxjQB7nRqqIGFIcLteF/sHeVtQg==} - cpu: [arm64] - os: [linux] - - '@msgpackr-extract/msgpackr-extract-linux-arm@3.0.3': - resolution: {integrity: sha512-fg0uy/dG/nZEXfYilKoRe7yALaNmHoYeIoJuJ7KJ+YyU2bvY8vPv27f7UKhGRpY6euFYqEVhxCFZgAUNQBM3nw==} - cpu: [arm] - os: [linux] - - '@msgpackr-extract/msgpackr-extract-linux-x64@3.0.3': - resolution: {integrity: sha512-cvwNfbP07pKUfq1uH+S6KJ7dT9K8WOE4ZiAcsrSes+UY55E/0jLYc+vq+DO7jlmqRb5zAggExKm0H7O/CBaesg==} - cpu: [x64] - os: [linux] - - '@msgpackr-extract/msgpackr-extract-win32-x64@3.0.3': - resolution: {integrity: sha512-x0fWaQtYp4E6sktbsdAqnehxDgEc/VwM7uLsRCYWaiGu0ykYdZPiS8zCWdnjHwyiumousxfBm4SO31eXqwEZhQ==} - cpu: [x64] - os: [win32] - '@multiformats/dns@1.0.6': resolution: {integrity: sha512-nt/5UqjMPtyvkG9BQYdJ4GfLK3nMqGpFZOzf4hAmIa0sJh2LlS9YKXZ4FgwBDsaHvzZqR/rUFIywIc7pkHNNuw==} @@ -2361,9 +2322,6 @@ packages: '@orbitdb/set-db@1.1.2': resolution: {integrity: sha512-zgMWoMPxN6kJv++JZhgkfx7+ZoDgeLgV5vTU6LG5ZZLg4LLg9irqneoc80Gg93vf4nP6jQiGxC5d8SmeDZsBFA==} - '@paralleldrive/cuid2@2.2.2': - resolution: {integrity: sha512-ZOBkgDwEdoYVlSeRbYYXs0S9MejQofiVYoTbKzy/6GQa39/q5tQU2IX46+shYnUkpEl3wc+J6wRlar7r2EK2xA==} - '@peculiar/asn1-cms@2.3.15': resolution: {integrity: sha512-B+DoudF+TCrxoJSTjjcY8Mmu+lbv8e7pXGWrhNp2/EGJp9EEcpzjBCar7puU57sGifyzaRVM03oD5L7t7PghQg==} @@ -3310,8 +3268,8 @@ packages: balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - base-x@4.0.0: - resolution: {integrity: sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==} + base-x@5.0.0: + resolution: {integrity: sha512-sMW3VGSX1QWVFA6l8U62MLKz29rRfpTlYdCqLdpLo1/Yd4zZwSbnUaDfciIAowAqvq7YFnWq9hrhdg1KYgc1lQ==} base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} @@ -3425,8 +3383,8 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true - bs58@5.0.0: - resolution: {integrity: sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==} + bs58@6.0.0: + resolution: {integrity: sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw==} bser@2.1.1: resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==} @@ -3540,9 +3498,6 @@ packages: ccount@2.0.1: resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} - cd@0.3.3: - resolution: {integrity: sha512-X2y0Ssu48ucdkrNgCdg6k3EZWjWVy/dsEywUUTeZEIW31f3bQfq65Svm+TzU1Hz+qqhdmyCdjGhUvRsSKHl/mw==} - chai-as-promised@7.1.2: resolution: {integrity: sha512-aBDHZxRzYnUYuIAIPBH2s511DjlKPzXNlXSGFC8CwmroWQLfrW0LtE1nK3MAwwNhJPa9raEjNCmRoFpG0Hurdw==} peerDependencies: @@ -6166,14 +6121,8 @@ packages: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} - libp2p@2.7.3: - resolution: {integrity: sha512-+KJvvlXTS0xahxdZ2ppV2crq0WsJwfepKsSMrg1G5anrDT65b3Fc1O7fORB0yi6gQa9VC9qtT8lVIhKe0GVOzA==} - - libsodium-sumo@0.7.15: - resolution: {integrity: sha512-5tPmqPmq8T8Nikpm1Nqj0hBHvsLFCXvdhBFV7SGOitQPZAA6jso8XoL0r4L7vmfKXr486fiQInvErHtEvizFMw==} - - libsodium-wrappers-sumo@0.7.15: - resolution: {integrity: sha512-aSWY8wKDZh5TC7rMvEdTHoyppVq/1dTSAeAR7H6pzd6QRT3vQWcT5pGwCotLcpPEOLXX6VvqihSPkpEhYAjANA==} + libp2p@2.7.4: + resolution: {integrity: sha512-/jZCe6khlcTt10USjrWJnqWaX2tiUAtB15qDDWvj0aEKABWWoxQtaK/Yr1l1gJy25IVTWZ/doSCnQftm0fCXJw==} lie@3.3.0: resolution: {integrity: sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==} @@ -6751,13 +6700,6 @@ packages: resolution: {integrity: sha512-kh8ARjh8rMN7Du2igDRO9QJnqCb2xYTJxyQYK7vJJS4TvLLmsbyhiKpSW+t+y26gyOyMd0riphX0GeWKU3ky5g==} engines: {node: '>=12.13'} - msgpackr-extract@3.0.3: - resolution: {integrity: sha512-P0efT1C9jIdVRefqjzOQ9Xml57zpOXnIuS+csaB4MdZbTdmGDLo8XhzBG1N7aO11gKDDkJvBLULeFTo46wwreA==} - hasBin: true - - msgpackr@1.11.2: - resolution: {integrity: sha512-F9UngXRlPyWCDEASDpTf6c9uNhGPTqnTeLVt7bN+bU1eajoR/8V9ys2BRaV5C/e5ihE6sJ9uPIKaYt6bFuO32g==} - multicast-dns@7.2.5: resolution: {integrity: sha512-2eznPJP8z2BFLX50tf0LuODrpINqP1RVIm/CObbTcBRITQgmC/TjcREF1NeTBzIcR5XO/ukWo+YHOjBbFwIupg==} hasBin: true @@ -6852,10 +6794,6 @@ packages: resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==} engines: {node: '>= 6.13.0'} - node-gyp-build-optional-packages@5.2.2: - resolution: {integrity: sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==} - hasBin: true - node-gyp-build@4.8.4: resolution: {integrity: sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==} hasBin: true @@ -9097,9 +9035,6 @@ packages: resolution: {integrity: sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==} engines: {node: '>=4.0'} - xstate@5.19.2: - resolution: {integrity: sha512-B8fL2aP0ogn5aviAXFzI5oZseAMqN00fg/TeDa3ZtatyDcViYLIfuQl4y8qmHCiKZgGEzmnTyNtNQL9oeJE2gw==} - xtend@2.0.6: resolution: {integrity: sha512-fOZg4ECOlrMl+A6Msr7EIFcON1L26mb4NY5rurSkOex/TWhazOrg6eXD/B0XkuiYcYhQDWLXzQxLMVJ7LXwokg==} engines: {node: '>=0.4'} @@ -10203,7 +10138,7 @@ snapshots: dependencies: '@helia/block-brokers': 4.0.4 '@libp2p/peer-id': 5.0.14 - '@libp2p/webrtc': 5.2.4(react-native@0.76.6(@babel/core@7.26.9)(@babel/preset-env@7.26.0(@babel/core@7.26.9))(react@18.3.1)) + '@libp2p/webrtc': 5.2.5(react-native@0.76.6(@babel/core@7.26.9)(@babel/preset-env@7.26.0(@babel/core@7.26.9))(react@18.3.1)) '@orbitdb/core': 2.5.0 blockstore-core: 5.0.2 blockstore-level: 2.0.1 @@ -10213,7 +10148,7 @@ snapshots: events: 3.3.0 genversion: 3.2.0 helia: 5.2.1(react-native@0.76.6(@babel/core@7.26.9)(@babel/preset-env@7.26.0(@babel/core@7.26.9))(react@18.3.1)) - libp2p: 2.7.3 + libp2p: 2.7.4 os-browserify: 0.3.0 process: 0.11.10 read-package-up: 11.0.0 @@ -10896,8 +10831,6 @@ snapshots: progress-events: 1.0.1 uint8arrays: 5.1.0 - '@herbcaudill/eventemitter42@0.3.3': {} - '@humanfs/core@0.19.1': {} '@humanfs/node@0.16.6': @@ -11087,7 +11020,7 @@ snapshots: protons-runtime: 5.5.0 uint8arraylist: 2.4.8 - '@libp2p/bootstrap@11.0.27': + '@libp2p/bootstrap@11.0.28': dependencies: '@libp2p/interface': 2.6.1 '@libp2p/interface-internal': 2.3.5 @@ -11095,7 +11028,7 @@ snapshots: '@multiformats/mafmt': 12.1.6 '@multiformats/multiaddr': 12.4.0 - '@libp2p/circuit-relay-v2@3.2.3': + '@libp2p/circuit-relay-v2@3.2.4': dependencies: '@libp2p/crypto': 5.0.13 '@libp2p/interface': 2.6.1 @@ -11260,7 +11193,7 @@ snapshots: '@libp2p/interfaces@3.3.2': {} - '@libp2p/kad-dht@14.2.10': + '@libp2p/kad-dht@14.2.11': dependencies: '@libp2p/crypto': 5.0.13 '@libp2p/interface': 2.6.1 @@ -11323,7 +11256,7 @@ snapshots: multiformats: 13.3.2 weald: 1.0.4 - '@libp2p/mdns@11.0.27': + '@libp2p/mdns@11.0.28': dependencies: '@libp2p/interface': 2.6.1 '@libp2p/interface-internal': 2.3.5 @@ -11334,7 +11267,7 @@ snapshots: dns-packet: 5.6.1 multicast-dns: 7.2.5 - '@libp2p/mplex@11.0.27': + '@libp2p/mplex@11.0.28': dependencies: '@libp2p/interface': 2.6.1 '@libp2p/utils': 6.5.5 @@ -11533,7 +11466,7 @@ snapshots: uint8arraylist: 2.4.8 uint8arrays: 5.1.0 - '@libp2p/webrtc@5.2.4(react-native@0.76.6(@babel/core@7.26.9)(@babel/preset-env@7.26.0(@babel/core@7.26.9))(react@18.3.1))': + '@libp2p/webrtc@5.2.5(react-native@0.76.6(@babel/core@7.26.9)(@babel/preset-env@7.26.0(@babel/core@7.26.9))(react@18.3.1))': dependencies: '@chainsafe/is-ip': 2.1.0 '@chainsafe/libp2p-noise': 16.0.3 @@ -11587,7 +11520,7 @@ snapshots: - bufferutil - utf-8-validate - '@libp2p/webtransport@5.0.32': + '@libp2p/webtransport@5.0.33': dependencies: '@chainsafe/libp2p-noise': 16.0.3 '@libp2p/interface': 2.6.1 @@ -11602,75 +11535,11 @@ snapshots: uint8arraylist: 2.4.8 uint8arrays: 5.1.0 - '@localfirst/auth@6.0.0': - dependencies: - '@herbcaudill/eventemitter42': 0.3.3 - '@localfirst/crdx': 6.0.0 - '@localfirst/crypto': 6.0.0 - '@localfirst/shared': 6.0.0 - '@paralleldrive/cuid2': 2.2.2 - lodash-es: 4.17.21 - msgpackr: 1.11.2 - xstate: 5.19.2 - transitivePeerDependencies: - - supports-color - - '@localfirst/crdx@6.0.0': - dependencies: - '@herbcaudill/eventemitter42': 0.3.3 - '@localfirst/crypto': 6.0.0 - '@localfirst/shared': 6.0.0 - '@paralleldrive/cuid2': 2.2.2 - '@types/lodash-es': 4.17.12 - lodash-es: 4.17.21 - msgpackr: 1.11.2 - transitivePeerDependencies: - - supports-color - - '@localfirst/crypto@6.0.0': - dependencies: - '@localfirst/shared': 6.0.0 - '@types/lodash-es': 4.17.12 - bs58: 5.0.0 - libsodium-wrappers-sumo: 0.7.15 - lodash-es: 4.17.21 - msgpackr: 1.11.2 - transitivePeerDependencies: - - supports-color - - '@localfirst/shared@6.0.0': - dependencies: - '@herbcaudill/eventemitter42': 0.3.3 - cd: 0.3.3 - debug: 4.4.0(supports-color@8.1.1) - eventemitter3: 5.0.1 - lodash-es: 4.17.21 - transitivePeerDependencies: - - supports-color - '@mrmlnc/readdir-enhanced@2.2.1': dependencies: call-me-maybe: 1.0.2 glob-to-regexp: 0.3.0 - '@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3': - optional: true - - '@msgpackr-extract/msgpackr-extract-darwin-x64@3.0.3': - optional: true - - '@msgpackr-extract/msgpackr-extract-linux-arm64@3.0.3': - optional: true - - '@msgpackr-extract/msgpackr-extract-linux-arm@3.0.3': - optional: true - - '@msgpackr-extract/msgpackr-extract-linux-x64@3.0.3': - optional: true - - '@msgpackr-extract/msgpackr-extract-win32-x64@3.0.3': - optional: true - '@multiformats/dns@1.0.6': dependencies: '@types/dns-packet': 5.6.5 @@ -11843,10 +11712,6 @@ snapshots: - supports-color - utf-8-validate - '@paralleldrive/cuid2@2.2.2': - dependencies: - '@noble/hashes': 1.7.1 - '@peculiar/asn1-cms@2.3.15': dependencies: '@peculiar/asn1-schema': 2.3.15 @@ -13191,7 +13056,7 @@ snapshots: balanced-match@1.0.2: {} - base-x@4.0.0: {} + base-x@5.0.0: {} base64-js@1.5.1: {} @@ -13389,9 +13254,9 @@ snapshots: node-releases: 2.0.19 update-browserslist-db: 1.1.2(browserslist@4.24.4) - bs58@5.0.0: + bs58@6.0.0: dependencies: - base-x: 4.0.0 + base-x: 5.0.0 bser@2.1.1: dependencies: @@ -13513,8 +13378,6 @@ snapshots: ccount@2.0.1: {} - cd@0.3.3: {} - chai-as-promised@7.1.2(chai@4.5.0): dependencies: chai: 4.5.0 @@ -15856,21 +15719,21 @@ snapshots: '@helia/utils': 1.2.1 '@ipshipyard/libp2p-auto-tls': 1.0.0 '@libp2p/autonat': 2.0.24 - '@libp2p/bootstrap': 11.0.27 - '@libp2p/circuit-relay-v2': 3.2.3 + '@libp2p/bootstrap': 11.0.28 + '@libp2p/circuit-relay-v2': 3.2.4 '@libp2p/config': 1.1.1 '@libp2p/dcutr': 2.0.23 '@libp2p/identify': 3.0.23 '@libp2p/interface': 2.6.1 - '@libp2p/kad-dht': 14.2.10 + '@libp2p/kad-dht': 14.2.11 '@libp2p/keychain': 5.1.1 - '@libp2p/mdns': 11.0.27 - '@libp2p/mplex': 11.0.27 + '@libp2p/mdns': 11.0.28 + '@libp2p/mplex': 11.0.28 '@libp2p/ping': 2.0.23 '@libp2p/tcp': 10.1.3 '@libp2p/tls': 2.0.17 '@libp2p/upnp-nat': 3.1.7 - '@libp2p/webrtc': 5.2.4(react-native@0.76.6(@babel/core@7.26.9)(@babel/preset-env@7.26.0(@babel/core@7.26.9))(react@18.3.1)) + '@libp2p/webrtc': 5.2.5(react-native@0.76.6(@babel/core@7.26.9)(@babel/preset-env@7.26.0(@babel/core@7.26.9))(react@18.3.1)) '@libp2p/websockets': 9.2.3 '@multiformats/dns': 1.0.6 blockstore-core: 5.0.2 @@ -15878,7 +15741,7 @@ snapshots: interface-blockstore: 5.3.1 interface-datastore: 8.3.1 ipns: 10.0.1 - libp2p: 2.7.3 + libp2p: 2.7.4 multiformats: 13.3.2 transitivePeerDependencies: - bufferutil @@ -16878,7 +16741,7 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 - libp2p@2.7.3: + libp2p@2.7.4: dependencies: '@chainsafe/is-ip': 2.1.0 '@chainsafe/netmask': 2.0.0 @@ -16909,12 +16772,6 @@ snapshots: race-signal: 1.1.3 uint8arrays: 5.1.0 - libsodium-sumo@0.7.15: {} - - libsodium-wrappers-sumo@0.7.15: - dependencies: - libsodium-sumo: 0.7.15 - lie@3.3.0: dependencies: immediate: 3.0.6 @@ -17834,22 +17691,6 @@ snapshots: ms@3.0.0-canary.1: {} - msgpackr-extract@3.0.3: - dependencies: - node-gyp-build-optional-packages: 5.2.2 - optionalDependencies: - '@msgpackr-extract/msgpackr-extract-darwin-arm64': 3.0.3 - '@msgpackr-extract/msgpackr-extract-darwin-x64': 3.0.3 - '@msgpackr-extract/msgpackr-extract-linux-arm': 3.0.3 - '@msgpackr-extract/msgpackr-extract-linux-arm64': 3.0.3 - '@msgpackr-extract/msgpackr-extract-linux-x64': 3.0.3 - '@msgpackr-extract/msgpackr-extract-win32-x64': 3.0.3 - optional: true - - msgpackr@1.11.2: - optionalDependencies: - msgpackr-extract: 3.0.3 - multicast-dns@7.2.5: dependencies: dns-packet: 5.6.1 @@ -17936,11 +17777,6 @@ snapshots: node-forge@1.3.1: {} - node-gyp-build-optional-packages@5.2.2: - dependencies: - detect-libc: 2.0.3 - optional: true - node-gyp-build@4.8.4: {} node-int64@0.4.0: {} @@ -20406,8 +20242,6 @@ snapshots: xmlbuilder@11.0.1: {} - xstate@5.19.2: {} - xtend@2.0.6: dependencies: is-object: 0.1.2 diff --git a/src/client.ts b/src/client.ts index b7b57b12bc..5985f591e8 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,6 +1,6 @@ import Semaphore from "@chriscdn/promise-semaphore"; import { unixfs } from "@helia/unixfs"; -import { Libp2p, PeerId } from "@libp2p/interface"; +import { Libp2p } from "@libp2p/interface"; import deepEqual from "deep-equal"; import { எண்ணிக்கை } from "ennikkai"; import indexedDbStream from "indexed-db-stream"; @@ -26,6 +26,8 @@ import { JSONSchemaType } from "ajv"; import Base64 from "crypto-js/enc-base64.js"; import md5 from "crypto-js/md5.js"; import sha256 from "crypto-js/sha256.js"; +import { randomBytes } from "@noble/hashes/utils"; +import bs58 from "bs58"; import { HeliaLibp2p } from "helia"; import JSZip from "jszip"; @@ -40,7 +42,6 @@ import { import { keys } from "@libp2p/crypto"; import { Automatisations } from "@/automatisation.js"; import { BDs } from "@/bds.js"; -import { Encryption, EncryptionLocalFirst } from "@/encryption.js"; import { Épingles } from "@/epingles.js"; import { Favoris, @@ -87,7 +88,7 @@ import { initSFIP } from "@/sfip/index.js"; import { Protocoles } from "./protocoles.js"; import type { PrivateKey } from "@libp2p/interface"; import type { ServicesLibp2p } from "@/sfip/index.js"; -import type { ContenuMessageRejoindreCompte } from "@/reseau.js"; +import type { ContenuMessageRejoindreCompte, statutDispositif } from "@/reseau.js"; import type { infoUtilisateur, objRôles } from "@/accès/types.js"; import type { SetDatabaseType } from "@orbitdb/set-db"; import type { OrderedKeyValueDatabaseType } from "@orbitdb/ordered-keyvalue-db"; @@ -279,18 +280,19 @@ export class Constellation { _sfipExterne: boolean; idCompte?: string; - encryption: Encryption; sujet_réseau: string; motsDePasseRejoindreCompte: { [key: string]: number }; ennikkai: எண்ணிக்கை; verrouObtIdBd: Semaphore; _intervaleVerrou?: NodeJS.Timeout; + signaleurArrêt: AbortController; constructor(opts: optsConstellation = {}) { this._opts = opts; this.événements = new TypedEmitter<ÉvénementsClient>(); + this.signaleurArrêt = new AbortController(); this.sujet_réseau = opts.sujetRéseau || "réseau-constellation"; this.motsDePasseRejoindreCompte = {}; @@ -299,7 +301,6 @@ export class Constellation { this._orbiteExterne = this._sfipExterne = false; - this.encryption = new EncryptionLocalFirst(); this.ennikkai = new எண்ணிக்கை({}); this.épingles = new Épingles({ client: this }); @@ -986,6 +987,7 @@ export class Constellation { }): Promise { const fSuivi = async ({ id, + fSuivreBd, }: { id: string; fSuivreBd: schémaFonctionSuivi; @@ -1000,14 +1002,14 @@ export class Constellation { const typeAccès = (accès as AccessController).type; if (typeAccès === "ipfs") { - await f((accès as IPFSAccessController).write); + await fSuivreBd((accès as IPFSAccessController).write); await fOublier(); return faisRien; } else if (typeAccès === "contrôleur-constellation") { const contrôleurConstellation = accès as ContrôleurConstellation; const fFinale = async () => { const mods = contrôleurConstellation.gestRôles._rôles[MODÉRATEUR]; - await f(mods); + await fSuivreBd(mods); }; contrôleurConstellation.gestRôles.on("misÀJour", fFinale); fFinale(); @@ -1020,7 +1022,15 @@ export class Constellation { return faisRien; } }; - return await suivreBdDeFonction({ + + const info: {autorisés: string[]; infos: statutDispositif[]; idCompte?: string} = { autorisés: [], infos: []}; + const fFinale = async () => { + if (!idCompte) return; + const autorisésEtAcceptés = info.autorisés.filter(id => info.infos.find(i=>i.infoDispositif.idDispositif === id)?.infoDispositif.idCompte === idCompte) + return await f(autorisésEtAcceptés); + }; + + const fOublierDispositifsAutorisés = await suivreBdDeFonction({ fRacine: async ({ fSuivreRacine, }: { @@ -1033,9 +1043,11 @@ export class Constellation { return await this.suivreIdCompte({ f: fSuivreRacine }); } }, - f: ignorerNonDéfinis(f), - fSuivre: fSuivi, + f: ignorerNonDéfinis(async (x: string[]) => { info.autorisés = x; return await fFinale()}), + fSuivre: async ({id, fSuivreBd}: {id: string; fSuivreBd: schémaFonctionSuivi}) => {info.idCompte = id; return await fSuivi({id, fSuivreBd})}, }); + const fOublierInfosDispositifs = await this.réseau.suivreConnexionsDispositifs({f: async x => {info.infos = x; return await fFinale()}}) + return async () => {await Promise.all([fOublierDispositifsAutorisés(), fOublierInfosDispositifs()])}; } async nommerDispositif({ @@ -1111,7 +1123,7 @@ export class Constellation { codeSecret: string; }> { const idCompte = await this.obtIdCompte(); - const codeSecret = await this.encryption.clefAléatoire(); + const codeSecret = bs58.encode(randomBytes(6 * 3)).slice(0, 6); this.motsDePasseRejoindreCompte[codeSecret] = Date.now(); const idDispositif = await this.obtIdDispositif(); return { idCompte, codeSecret: `${idDispositif}:${codeSecret}` }; @@ -1287,9 +1299,9 @@ export class Constellation { }; } - async obtIdSFIP(): Promise { + async obtIdLibp2p(): Promise { const { sfip } = await this.attendreSfipEtOrbite(); - return sfip.libp2p.peerId; + return sfip.libp2p.peerId.toString(); } async obtIdDispositif(): Promise { @@ -2763,6 +2775,8 @@ export class Constellation { async fermer(): Promise { await this.attendreInitialisée(); const { orbite } = await this.attendreSfipEtOrbite(); + this.signaleurArrêt.abort(); + await (await stockageLocal(await this.dossier())).fermer?.(); await this.fermerCompte(); await this.épingles.fermer(); diff --git a/src/const.ts b/src/const.ts index bd46476bcf..90e5c92e03 100644 --- a/src/const.ts +++ b/src/const.ts @@ -1,5 +1,7 @@ import { schémaSpécificationBd } from "./bds"; +export const PROTOCOLE_CONSTELLATION = "Constellation"; + // À faire export const SCHÉMA_BD_LICENCES: schémaSpécificationBd | undefined = undefined; export const CLEF_TABLEAU_LICENCES_APPROUVÉES: string | undefined = undefined; diff --git a/src/encryption.ts b/src/encryption.ts deleted file mode 100644 index 1b2506f249..0000000000 --- a/src/encryption.ts +++ /dev/null @@ -1,124 +0,0 @@ -import Semaphore from "@chriscdn/promise-semaphore"; -import { TypedEmitter } from "tiny-typed-emitter"; -import type { Base58 } from "@localfirst/auth"; - -const importationAuth = import("@localfirst/auth"); -const importationCrypto = import("@localfirst/crypto"); - -const verrouImportation = new Semaphore(); -let auth: Awaited; -const obtAuth = async (): Promise> => { - await verrouImportation.acquire("auth"); - if (!auth) auth = await importationAuth; - verrouImportation.release("auth"); - return auth; -}; - -let crypto: Awaited; -const obtCrypto = async (): Promise> => { - await verrouImportation.acquire("crypto"); - if (!crypto) crypto = await importationCrypto; - verrouImportation.release("crypto"); - return crypto; -}; - -export interface Encryption { - nom: string; - - obtClefs(): Promise<{ publique: string; secrète: string }>; - encrypter({ - message, - clefPubliqueDestinataire, - }: { - message: string; - clefPubliqueDestinataire: string; - }): Promise; - - décrypter({ - message, - clefPubliqueExpéditeur, - }: { - message: string; - clefPubliqueExpéditeur: string; - }): Promise; - - clefAléatoire(): Promise; - - // Nécessaire pour le mandataire - obtNom(): Promise; -} - -type ÉvénementsEncryptionLocalFirst = { - clefs: (args: { secrète: Base58; publique: Base58 }) => void; -}; - -export class EncryptionLocalFirst implements Encryption { - événements: TypedEmitter<ÉvénementsEncryptionLocalFirst>; - clefs?: { publique: Base58; secrète: Base58 }; - nom = "local-first-auth"; - - constructor() { - this.événements = new TypedEmitter<ÉvénementsEncryptionLocalFirst>(); - - obtAuth().then(({ asymmetric }) => { - const { publicKey, secretKey } = asymmetric.keyPair(); - this.clefs = { secrète: secretKey, publique: publicKey }; - this.événements.emit("clefs", this.clefs); - }); - } - - async obtClefs(): Promise<{ publique: Base58; secrète: Base58 }> { - const clefs = - this.clefs || - (await new Promise<{ publique: Base58; secrète: Base58 }>((résoudre) => { - this.événements.once("clefs", résoudre); - })); - return clefs; - } - - async encrypter({ - message, - clefPubliqueDestinataire, - }: { - message: string; - clefPubliqueDestinataire: string; - }): Promise { - const { asymmetric } = await obtAuth(); - const clefs = await this.obtClefs(); - - return asymmetric - .encrypt({ - secret: message, - recipientPublicKey: clefPubliqueDestinataire as Base58, - senderSecretKey: clefs.secrète as Base58, - }) - .toString(); - } - - async décrypter({ - message, - clefPubliqueExpéditeur, - }: { - message: string; - clefPubliqueExpéditeur: string; - }): Promise { - const { asymmetric } = await obtAuth(); - const clefs = await this.obtClefs(); - - const décrypté = asymmetric.decrypt({ - cipher: message as Base58, - recipientSecretKey: clefs.secrète as Base58, - senderPublicKey: clefPubliqueExpéditeur as Base58, - }); - return décrypté; - } - - async clefAléatoire(n: number = 6): Promise { - const { randomKey } = await obtCrypto(); - return randomKey(n); - } - - async obtNom(): Promise { - return this.nom; - } -} diff --git a/src/index.ts b/src/index.ts index 0279dea589..119513995a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,6 @@ export * as mandataire from "@/mandataire/index.js"; export * as automatisation from "@/automatisation.js"; export * as bds from "@/bds.js"; export * as client from "@/client.js"; -export * as encryption from "@/encryption.js"; export * as épingles from "@/epingles.js"; export * as favoris from "@/favoris.js"; export * as licences from "@/licences.js"; diff --git a/src/reseau.ts b/src/reseau.ts index 2a0d88e188..a83bf5e873 100644 --- a/src/reseau.ts +++ b/src/reseau.ts @@ -1,10 +1,11 @@ -import { EventEmitter } from "events"; import { isValidAddress } from "@orbitdb/core"; import Semaphore from "@chriscdn/promise-semaphore"; import { multiaddr } from "@multiformats/multiaddr"; import { sum } from "lodash-es"; - +import { TypedEmitter } from "tiny-typed-emitter"; +import { pipe } from "it-pipe"; +import { pushable } from "it-pushable"; import { GossipsubMessage } from "@chainsafe/libp2p-gossipsub"; import { faisRien, @@ -14,6 +15,8 @@ import { } from "@constl/utils-ipa"; import { JSONSchemaType } from "ajv"; import { v4 as uuidv4 } from "uuid"; +import { peerIdFromString } from "@libp2p/peer-id"; +import { anySignal } from "any-signal"; import { ContrôleurConstellation as générerContrôleurConstellation } from "@/accès/cntrlConstellation.js"; import { Constellation, @@ -30,9 +33,18 @@ import { rechercherProfilsSelonActivité } from "@/recherche/profil.js"; import { rechercherTous } from "@/recherche/utils.js"; import { ComposanteClientDic } from "./composanteClient.js"; import { estUnContrôleurConstellation } from "./accès/utils.js"; +import { PROTOCOLE_CONSTELLATION } from "./const.js"; +import type { Pushable } from "it-pushable"; +// import type {Sink} from 'it-stream-types'; + import type { ÉpingleFavoris, ÉpingleFavorisAvecId } from "@/favoris.js"; import type { infoScore } from "@/bds.js"; -import type { Libp2pEvents, PeerUpdate } from "@libp2p/interface"; +import type { + Connection, + Libp2pEvents, + PeerUpdate, + Stream, +} from "@libp2p/interface"; import type { élémentBdListeDonnées, élémentDonnées } from "@/tableaux.js"; import type { infoAuteur, @@ -57,12 +69,11 @@ type ContrôleurConstellation = Awaited< >; export type infoDispositif = { - idSFIP: string; + idLibp2p: string; idDispositif: string; idCompte: string; clefPublique: string; signatures: { id: string; publicKey: string }; - encryption?: { type: string; clefPublique: string }; }; export type statutDispositif = { @@ -146,60 +157,47 @@ export type bdDeMembre = { bd: string; }; -interface Message { - encrypté: boolean; - données: string | DonnéesMessage; - destinataire?: string; -} - -export interface MessageEncrypté extends Message { - encrypté: true; - clefPubliqueExpéditeur: string; - données: string; -} - -export interface MessageNonEncrypté extends Message { - encrypté: false; - données: DonnéesMessage; -} - -export interface DonnéesMessage { - signature: Signature; - valeur: ValeurMessage; -} - -export interface ValeurMessage { - type: string; - contenu: ContenuMessage; -} +export type MessageGossipSub = MessageGossipSubSalut | MessageGossipSubTexte; -export interface ContenuMessage { - [key: string]: unknown; -} +export type MessageDirecte = + | MessageDirecteRequêteRejoindreCompte + | MessageDirecteTexte; -export interface ValeurMessageSalut extends ValeurMessage { +export type MessageGossipSubSalut = { type: "Salut !"; contenu: ContenuMessageSalut; -} +}; -export interface ContenuMessageSalut extends ContenuMessage { - idSFIP: string; - idDispositif: string; - idCompte: string; - clefPublique: string; - signatures: { id: string; publicKey: string }; - encryption?: { type: string; clefPublique: string }; -} +export type MessageGossipSubTexte = { + type: "texte"; + contenu: string; +}; + +export type ContenuMessageSalut = { + contenu: { + idLibp2p: string; + idDispositif: string; + idCompte: string; + clefPublique: string; + signatures: { id: string; publicKey: string }; + }; + signature: Signature; +}; -export interface ValeurMessageRequêteRejoindreCompte extends ValeurMessage { +export type MessageDirecteRequêteRejoindreCompte = { type: "Je veux rejoindre ce compte"; contenu: ContenuMessageRejoindreCompte; -} +}; -export interface ContenuMessageRejoindreCompte extends ContenuMessage { +export type ContenuMessageRejoindreCompte = { idDispositif: string; empreinteVérification: string; -} +}; + +export type MessageDirecteTexte = { + type: "texte"; + contenu: { message: string }; +}; export type statutConfianceMembre = "FIABLE" | "BLOQUÉ" | "NEUTRE"; @@ -223,6 +221,13 @@ const CONFIANCE_DE_FAVORIS = 0.7; const DÉLAI_SESOUVENIR_MEMBRES_EN_LIGNE = 1000 * 60 * 60 * 24 * 30; // 1 mois const N_DÉSIRÉ_SOUVENIR_MEMBRES_EN_LIGNE = 50; +type ÉvénementsRéseau = { + changementConnexions: () => void; + messageDirecte: (args: { de: string; message: MessageDirecte }) => void; + changementMembresBloqués: () => void; + membreVu: () => void; +}; + export class Réseau extends ComposanteClientDic { client: Constellation; bloquésPrivés: Set; @@ -232,8 +237,12 @@ export class Réseau extends ComposanteClientDic { [key: string]: statutDispositif; }; + connexionsDirectes: { + [key: string]: Pushable; + }; + fsOublier: schémaFonctionOublier[]; - événements: EventEmitter; + événements: TypedEmitter<ÉvénementsRéseau>; constructor({ client }: { client: Constellation }) { super({ @@ -247,12 +256,14 @@ export class Réseau extends ComposanteClientDic { this.bloquésPrivés = new Set(); this.dispositifsEnLigne = {}; + this.connexionsDirectes = {}; + this.client .obtDeStockageLocal({ clef: "dispositifsEnLigne" }) .then((x) => (this.dispositifsEnLigne = JSON.parse(x || "{}"))); this.fsOublier = []; this._fermé = false; - this.événements = new EventEmitter(); + this.événements = new TypedEmitter<ÉvénementsRéseau>(); } async initialiser(): Promise { @@ -261,14 +272,14 @@ export class Réseau extends ComposanteClientDic { const promesses: { [clef: string]: Promise } = {}; const pubsub = sfip.libp2p.services.pubsub; - pubsub.subscribe(this.client.sujet_réseau); + const libp2p = sfip.libp2p; const fÉcoutePubSub = (évé: CustomEvent) => { const messageGs = évé.detail.msg; const id = uuidv4(); if (messageGs.topic === this.client.sujet_réseau) { try { - const promesse = this.messageReçu({ + const promesse = this.messageGossipSubReçu({ msg: JSON.parse(new TextDecoder().decode(messageGs.data)), }); promesses[id] = promesse; @@ -282,16 +293,61 @@ export class Réseau extends ComposanteClientDic { } }; pubsub.addEventListener("gossipsub:message", fÉcoutePubSub); + pubsub.subscribe(this.client.sujet_réseau); + + const gérerProtocoleConstellation = async ({ + connection, + stream, + }: { + connection: Connection; + stream: Stream; + }) => { + const idPairSource = String(connection.remotePeer); + if (this.connexionsDirectes[idPairSource]) return; + try { + this.connexionsDirectes[idPairSource] = pushable(); + pipe(stream, async (source) => { + for await (const value of source) { + const octets = value.subarray(); + const messageDécodé = JSON.parse(new TextDecoder().decode(octets)); + this.événements.emit("messageDirecte", { + de: idPairSource, + message: messageDécodé, + }); + } + }); + pipe(this.connexionsDirectes[idPairSource], stream); + } catch { + delete this.connexionsDirectes[idPairSource]; + } + }; + + await libp2p.handle(PROTOCOLE_CONSTELLATION, gérerProtocoleConstellation, { + runOnLimitedConnection: true, + }); + libp2p.addEventListener( + "peer:disconnect", + ({ detail: pair }) => delete this.connexionsDirectes[pair.toString()], + ); + + this.fsOublier.push( + await this.suivreMessagesDirectes({ + type: "Je veux rejoindre ce compte", + f: ({ contenu }) => + this.client.considérerRequêteRejoindreCompte({ + requête: contenu as ContenuMessageRejoindreCompte, + }), + }), + ); this.fsOublier.push(async () => { + await libp2p.unhandle(PROTOCOLE_CONSTELLATION); // @ts-expect-error erreur de définition types sur GossipSub if (pubsub.isStarted()) pubsub.unsubscribe(this.client.sujet_réseau); pubsub.removeEventListener("gossipsub:message", fÉcoutePubSub); await Promise.all(Object.values(promesses)); }); - const libp2p = sfip.libp2p; - const fSuivreConnexions = () => { this.événements.emit("changementConnexions"); }; @@ -299,6 +355,7 @@ export class Réseau extends ComposanteClientDic { const événements: (keyof Libp2pEvents)[] = [ "peer:connect", "peer:disconnect", + "peer:update", ]; for (const é of événements) { libp2p.addEventListener(é, fSuivreConnexions); @@ -309,15 +366,79 @@ export class Réseau extends ComposanteClientDic { }), ); - const intervale = setInterval(() => { - this.direSalut(); + const intervale = setInterval(async () => { + await this.direSalut(); }, INTERVALE_SALUT); + this.fsOublier.unshift(async () => clearInterval(intervale)); await this.direSalut(); } - async suivreMessageGossipsub({ + async obtFluxDispositif({ + idDispositif, + signal, + }: { + idDispositif: string; + signal?: AbortSignal; + }): Promise> { + + const signalCombiné = anySignal([ + this.client.signaleurArrêt.signal, + ...(signal ? [signal] : []), + ]); + + const { sfip } = await this.client.attendreSfipEtOrbite(); + const idLibp2pDestinataire = await uneFois( + async (fSuivi: schémaFonctionSuivi) => { + return await this.suivreConnexionsDispositifs({ + f: async (dispositifs) => { + const correspondant = dispositifs?.find( + (d) => d.infoDispositif.idDispositif === idDispositif, + ); + if (correspondant) + return await fSuivi(correspondant.infoDispositif.idLibp2p); + }, + }); + }, + ); + + if (this.connexionsDirectes[idLibp2pDestinataire]) return this.connexionsDirectes[idLibp2pDestinataire]; + + const idPairDestinataire = peerIdFromString(idLibp2pDestinataire); + await sfip.libp2p.dial(idPairDestinataire); + + const flux = await sfip.libp2p.dialProtocol( + idPairDestinataire, + PROTOCOLE_CONSTELLATION, + { signal: signalCombiné, runOnLimitedConnection: true }, + ); + signalCombiné.clear(); + + const fluxÀÉcrire = pushable(); + this.connexionsDirectes[idLibp2pDestinataire] = fluxÀÉcrire; + pipe(fluxÀÉcrire, flux); // Pas d'await + + return fluxÀÉcrire; + } + + async envoyerMessageGossipsub({ + message, + sujet, + }: { + message: unknown; + sujet?: string; + }): Promise { + sujet ??= this.client.sujet_réseau; + const pubsub = (await this.client.attendreSfipEtOrbite()).sfip.libp2p + .services.pubsub; + + const octetsMessage = new TextEncoder().encode(JSON.stringify(message)); + const retour = await pubsub.publish(sujet, Buffer.from(octetsMessage)); + return retour.recipients.map((r) => r.toString()); + } + + async suivreMessagesGossipsub({ sujet, f, }: { @@ -373,81 +494,23 @@ export class Réseau extends ComposanteClientDic { async envoyerMessageAuDispositif({ msg, idDispositif, + signal, }: { - msg: ValeurMessage; - idDispositif?: string; + msg: MessageDirecte; + idDispositif: string; + signal?: AbortSignal; }) { - const signature = await this.client.signer({ - message: JSON.stringify(msg), - }); - - const msgSigné: DonnéesMessage = { - signature, - valeur: msg, - }; - let idSFIP: string | undefined = undefined; - let encryption: { type: string; clefPublique: string } | undefined; - if (idDispositif) { - const dispositif = await uneFois( - async (fSuivi: schémaFonctionSuivi) => { - return await this.suivreConnexionsDispositifs({ - f: async (dispositifs) => { - const correspondant = dispositifs.find( - (dsp) => dsp.infoDispositif.idDispositif === idDispositif, - ); - if (correspondant) { - return await fSuivi(correspondant); - } - }, - }); - }, - ); - ({ idSFIP, encryption } = dispositif.infoDispositif); - } - - let msgPourDispositif: MessageNonEncrypté | MessageEncrypté; - if (idDispositif) { - // Arrêter si le dispositif n'a pas la même encryption que nous - if (encryption?.type !== this.client.encryption.nom) return; - - const msgEncrypté = await this.client.encryption.encrypter({ - message: JSON.stringify(msgSigné), - clefPubliqueDestinataire: encryption.clefPublique, - }); - const { publique: clefPubliqueExpéditeur } = - await this.client.encryption.obtClefs(); - msgPourDispositif = { - encrypté: true, - clefPubliqueExpéditeur, - données: msgEncrypté, - }; - if (idSFIP) { - msgPourDispositif.destinataire = idSFIP; - } - } else { - msgPourDispositif = { - encrypté: false, - données: msgSigné, - }; - if (idSFIP) { - msgPourDispositif.destinataire = idSFIP; - } - } + const flux = await this.obtFluxDispositif({ idDispositif, signal }); - const sujet = this.client.sujet_réseau; - const { sfip } = await this.client.attendreSfipEtOrbite(); - const pubsub = sfip.libp2p.services.pubsub; - const msgBinaire = new TextEncoder().encode( - JSON.stringify(msgPourDispositif), - ); - await pubsub.publish(sujet, Buffer.from(msgBinaire)); + const msgBinaire = new TextEncoder().encode(JSON.stringify(msg)); + flux.push(msgBinaire); } async envoyerMessageAuMembre({ msg, idCompte, }: { - msg: ValeurMessage; + msg: MessageDirecte; idCompte: string; }): Promise { const maintenant = Date.now(); @@ -459,7 +522,8 @@ export class Réseau extends ComposanteClientDic { throw new Error( `Aucun dispositif présentement en ligne pour membre ${idCompte}`, ); - await Promise.all( + + await Promise.all( dispositifsMembre.map(async (d) => { await this.envoyerMessageAuDispositif({ msg, @@ -469,33 +533,66 @@ export class Réseau extends ComposanteClientDic { ); } - async direSalut({ à }: { à?: string } = {}): Promise { + async suivreMessagesDirectes({ + f, + type, + de, + }: { + f: schémaFonctionSuivi; + type?: MessageDirecte["type"] | MessageDirecte["type"][]; + de?: string; + }): Promise { + if (de) { + de = await uneFois(async (fSuivi: schémaFonctionSuivi) => { + return await this.suivreConnexionsDispositifs({ + f: async (dispositifs) => { + const correspondant = dispositifs?.find( + (d) => d.infoDispositif.idDispositif === de, + ); + if (correspondant) + return await fSuivi(correspondant.infoDispositif.idLibp2p); + }, + }); + }); + } + const gérerMessage = async ({ + de: messageDe, + message, + }: { + de: string; + message: MessageDirecte; + }) => { + if (type && !(message.type === type)) return; + if (de && !(de === messageDe)) return; + await f(message); + }; + + this.événements.on("messageDirecte", gérerMessage); + return async () => { + this.événements.off("messageDirecte", gérerMessage); + }; + } + + async direSalut(): Promise { const { orbite } = await this.client.attendreSfipEtOrbite(); - const valeur: ValeurMessageSalut = { + const contenu = { + idLibp2p: await this.client.obtIdLibp2p(), + idDispositif: orbite.identity.id, + clefPublique: orbite.identity.publicKey, + signatures: orbite.identity.signatures, + idCompte: await this.client.obtIdCompte(), + }; + const signature = await this.client.signer({ + message: JSON.stringify(contenu), + }); + const valeur: MessageGossipSubSalut = { type: "Salut !", contenu: { - idSFIP: (await this.client.obtIdSFIP()).toString(), - idDispositif: orbite.identity.id, - clefPublique: orbite.identity.publicKey, - signatures: orbite.identity.signatures, - idCompte: await this.client.obtIdCompte(), + contenu, + signature, }, }; - const { publique: clefPublique } = await this.client.encryption.obtClefs(); - if (this.client.encryption) { - valeur.contenu.encryption = { - type: this.client.encryption.nom, - clefPublique, - }; - } - try { - await this.envoyerMessageAuDispositif({ msg: valeur, idDispositif: à }); - } catch (e) { - // On peut avoir cette erreur si l'autre poste s'est déconnecté entre-temps - if (!e.toString().includes("PublishError.InsufficientPeers")) { - throw e; - } - } + await this.envoyerMessageGossipsub({ message: valeur }); } async envoyerDemandeRejoindreCompte({ @@ -511,7 +608,7 @@ export class Réseau extends ComposanteClientDic { } else { codeSecretOriginal = codeSecret; } - const msg: ValeurMessageRequêteRejoindreCompte = { + const msg: MessageDirecteRequêteRejoindreCompte = { type: "Je veux rejoindre ce compte", contenu: { idDispositif, @@ -524,80 +621,42 @@ export class Réseau extends ComposanteClientDic { await this.envoyerMessageAuDispositif({ msg, - idDispositif: idDispositifQuiInvite, + idDispositif: idDispositifQuiInvite!, }); } - async messageReçu({ msg }: { msg: Message }): Promise { + async messageGossipSubReçu({ + msg, + }: { + msg: MessageGossipSub; + }): Promise { if (this._fermé) return; - const { encrypté, destinataire } = msg; - - if ( - destinataire && - destinataire !== (await this.client.obtIdSFIP()).toString() - ) - return; - - const données: DonnéesMessage = encrypté - ? JSON.parse( - await this.client.encryption.décrypter({ - message: (msg as MessageEncrypté).données, - clefPubliqueExpéditeur: (msg as MessageEncrypté) - .clefPubliqueExpéditeur, - }), - ) - : msg.données; - - let valeur: ValeurMessage; - let signature: Signature; - try { - ({ valeur, signature } = données); - } catch { - // console.log("Erreur message externe : ", JSON.stringify(données), JSON.stringify(msg)); - return; - } - - // Ignorer les messages de nous-mêmes const { orbite } = await this.client.attendreSfipEtOrbite(); - if (signature.clefPublique === orbite.identity.publicKey) { - return; - } - // Assurer que la signature est valide (message envoyé par détenteur de idDispositif) - const signatureValide = await this.client.vérifierSignature({ - signature, - message: JSON.stringify(valeur), - }); - if (!signatureValide) return; + switch (msg.type) { + case "Salut !": { + const { signature, contenu } = msg.contenu; - const contenu = valeur.contenu; + // Ignorer les messages de nous-mêmes + if (signature.clefPublique === orbite.identity.publicKey) return; + const { clefPublique } = contenu; - switch (valeur.type) { - case "Salut !": { - const contenuSalut = contenu as ContenuMessageSalut; - const { clefPublique } = contenuSalut; + // Assurer que la signature est valide (message envoyé par détenteur de idDispositif) + const signatureValide = await this.client.vérifierSignature({ + signature, + message: JSON.stringify(contenu), + }); + if (!signatureValide) return; // S'assurer que idDispositif est la même que celle sur la signature if (clefPublique !== signature.clefPublique) return; - await this.recevoirSalut({ message: contenuSalut }); - - if (!destinataire) - await this.direSalut({ à: contenuSalut.idDispositif }); // Renvoyer le message, si ce n'était pas déjà fait - break; - } - case "Je veux rejoindre ce compte": { - const contenuMessage = contenu as ContenuMessageRejoindreCompte; - - await this.client.considérerRequêteRejoindreCompte({ - requête: contenuMessage, - }); + await this.recevoirSalut({ message: msg.contenu }); break; } } - // this.écouteursMessages[valeur.type]?.(contenu); } async recevoirSalut({ @@ -605,14 +664,17 @@ export class Réseau extends ComposanteClientDic { }: { message: ContenuMessageSalut; }): Promise { - const dispositifValid = await this._validerInfoMembre({ info: message }); + const dispositifValid = await this._validerInfoMembre({ + info: message.contenu, + }); if (!dispositifValid) return; - // Peut-être possible de convertir à une méthode peer.onDisconnect pour détecter vuÀ ? - this.dispositifsEnLigne[message.idDispositif] = { - infoDispositif: message, + // À faire : Peut-être possible de convertir à une méthode peer.onDisconnect pour détecter vuÀ ? + const { idDispositif } = message.contenu; + this.dispositifsEnLigne[idDispositif] = { + infoDispositif: message.contenu, vuÀ: - message.idDispositif === (await this.client.obtIdDispositif()) + idDispositif === (await this.client.obtIdDispositif()) ? undefined : new Date().getTime(), }; @@ -1414,14 +1476,10 @@ export class Réseau extends ComposanteClientDic { }): Promise { const moi: statutDispositif = { infoDispositif: { - idSFIP: (await this.client.obtIdSFIP()).toString(), + idLibp2p: await this.client.obtIdLibp2p(), idDispositif: await this.client.obtIdDispositif(), idCompte: await this.client.obtIdCompte(), clefPublique: (await this.client.obtIdentitéOrbite()).publicKey, - encryption: { - type: await this.client.encryption.obtNom(), - clefPublique: (await this.client.encryption.obtClefs()).publique, - }, signatures: (await this.client.obtIdentitéOrbite()).signatures, }, }; diff --git a/test/encryption.spec.ts b/test/encryption.spec.ts deleted file mode 100644 index 4e2c969cd0..0000000000 --- a/test/encryption.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { expect } from "aegir/chai"; -import { Encryption, EncryptionLocalFirst } from "@/encryption.js"; - -describe("Encryption", function () { - let encrypteur1: Encryption; - let encrypteur2: Encryption; - let encrypteur3: Encryption; - - before(async () => { - encrypteur1 = new EncryptionLocalFirst(); - encrypteur2 = new EncryptionLocalFirst(); - encrypteur3 = new EncryptionLocalFirst(); - }); - - it("Encrypter et décrypter", async () => { - const clefs2 = await encrypteur2.obtClefs(); - - const messageSecret = "போய்து வறேன்"; - const messageEncrypté = await encrypteur1.encrypter({ - message: messageSecret, - clefPubliqueDestinataire: clefs2.publique, - }); - - const clefs1 = await encrypteur1.obtClefs(); - - const messageDécrypté = await encrypteur2.décrypter({ - message: messageEncrypté, - clefPubliqueExpéditeur: clefs1.publique, - }); - - expect(messageDécrypté).to.equal(messageSecret); - }); - - it("Quelqu'un d'autre ne peut pas décrypter", async () => { - const clefs1 = await encrypteur1.obtClefs(); - const clefs2 = await encrypteur2.obtClefs(); - - const messageSecret = "போய்து வறேன்"; - const messageEncrypté = await encrypteur1.encrypter({ - message: messageSecret, - clefPubliqueDestinataire: clefs2.publique, - }); - - expect( - encrypteur3.décrypter({ - message: messageEncrypté, - clefPubliqueExpéditeur: clefs1.publique, - }), - ).to.be.rejected(); - }); -}); diff --git "a/test/r\303\251seau.spec.ts" "b/test/r\303\251seau.spec.ts" index 120cca9695..d02625cb94 100644 --- "a/test/r\303\251seau.spec.ts" +++ "b/test/r\303\251seau.spec.ts" @@ -34,37 +34,38 @@ import type { élémentBdListeDonnées } from "@/tableaux.js"; const { créerConstellationsTest } = utilsTestConstellation; async function toutPréparer(n: number) { - const { fOublier: fOublierClients, clients } = await créerConstellationsTest({ - n, - créerConstellation, - }); - const idsNodesSFIP = await Promise.all( - clients.map(async (c) => (await c.obtIdSFIP()).toString()), + const { fOublier: fOublierConstls, clients: constls } = + await créerConstellationsTest({ + n, + créerConstellation, + }); + const idsLibp2p = await Promise.all( + constls.map(async (c) => await c.obtIdLibp2p()), ); - const idsOrbite = await Promise.all( - clients.map(async (c) => await c.obtIdDispositif()), + const idsDispositifs = await Promise.all( + constls.map(async (c) => await c.obtIdDispositif()), ); - const idsBdCompte = await Promise.all( - clients.map(async (c) => await c.obtIdCompte()), + const idsComptes = await Promise.all( + constls.map(async (c) => await c.obtIdCompte()), ); return { - clients, - fOublierClients, - idsNodesSFIP, - idsOrbite, - idsBdCompte, + constls, + fOublierConstls, + idsLibp2p, + idsDispositifs, + idsComptes, }; } if (isNode || isElectronMain) { - describe("Réseau", function () { + describe.only("Réseau", function () { describe("Suivre en ligne", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let idsNodesSFIP: string[]; - let idsOrbite: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let idsLibp2p: string[]; + let idsDispositifs: string[]; + let constls: Constellation[]; const rés = new utilsTestAttente.AttendreRésultat< { pair: string; adresses: string[] }[] @@ -78,21 +79,21 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, idsNodesSFIP, idsOrbite, clients, fOublierClients } = + ({ idsComptes, idsLibp2p, idsDispositifs, constls, fOublierConstls } = await toutPréparer(3)); fsOublier.push( - await clients[0].réseau.suivreConnexionsPostesSFIP({ + await constls[0].réseau.suivreConnexionsPostesSFIP({ f: (c) => rés.mettreÀJour(c), }), ); fsOublier.push( - await clients[0].réseau.suivreConnexionsDispositifs({ + await constls[0].réseau.suivreConnexionsDispositifs({ f: (d) => dispositifs.mettreÀJour(d), }), ); fsOublier.push( - await clients[0].réseau.suivreConnexionsMembres({ + await constls[0].réseau.suivreConnexionsMembres({ f: (c) => membresEnLigne.mettreÀJour(c), }), ); @@ -100,7 +101,7 @@ if (isNode || isElectronMain) { after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); rés.toutAnnuler(); dispositifs.toutAnnuler(); membresEnLigne.toutAnnuler(); @@ -108,11 +109,11 @@ if (isNode || isElectronMain) { it("Autres postes détectés", async () => { const val = await rés.attendreQue((x) => - idsNodesSFIP.slice(1).every((id) => x.find((p) => p.pair === id)), + idsLibp2p.slice(1).every((id) => x.find((p) => p.pair === id)), ); expect(val.map((p) => p.pair)).to.have.members([ - idsNodesSFIP[1], - idsNodesSFIP[2], + idsLibp2p[1], + idsLibp2p[2], ]); expect(val.map((p) => p.adresses.length)).to.have.members([1, 1]); }); @@ -122,28 +123,23 @@ if (isNode || isElectronMain) { (x?: statutDispositif[]) => !!x && x.length >= 3, ); expect(val.map((d) => d.infoDispositif.idDispositif)).to.have.members( - idsOrbite, + idsDispositifs, ); }); it("Autres membres détectés", async () => { const réfRés: infoMembre[] = []; - for (let i = 0; i <= clients.length - 1; i++) { - const identitéOrbite = await clients[i].obtIdentitéOrbite(); + for (let i = 0; i <= constls.length - 1; i++) { + const identitéOrbite = await constls[i].obtIdentitéOrbite(); réfRés.push({ - idCompte: idsBdCompte[i], + idCompte: idsComptes[i], protocoles: [], dispositifs: [ { - idSFIP: idsNodesSFIP[i], - idDispositif: idsOrbite[i], - idCompte: idsBdCompte[i], + idLibp2p: idsLibp2p[i], + idDispositif: idsDispositifs[i], + idCompte: idsComptes[i], clefPublique: identitéOrbite.publicKey, - encryption: { - type: await clients[i].encryption.obtNom(), - clefPublique: (await clients[i].encryption.obtClefs()) - .publique, - }, signatures: identitéOrbite.signatures, }, ], @@ -158,31 +154,31 @@ if (isNode || isElectronMain) { const fiablesPropres = new utilsTestAttente.AttendreRésultat(); const fiablesAutres = new utilsTestAttente.AttendreRésultat(); - let fOublierClients: () => Promise; - let idsBdCompte: string[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; - let clients: Constellation[]; + let constls: Constellation[]; const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(2)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(2)); fsOublier.push( - await clients[0].réseau.suivreFiables({ + await constls[0].réseau.suivreFiables({ f: (m) => fiablesPropres.mettreÀJour(m), }), ); fsOublier.push( - await clients[1].réseau.suivreFiables({ + await constls[1].réseau.suivreFiables({ f: (m) => fiablesAutres.mettreÀJour(m), - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], }), ); }); after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); fiablesPropres.toutAnnuler(); fiablesAutres.toutAnnuler(); }); @@ -193,35 +189,35 @@ if (isNode || isElectronMain) { }); it("Faire confiance", async () => { - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[1], }); const val = await fiablesPropres.attendreQue( (x) => !!x && x.length > 0, ); expect(val.length).to.equal(1); - expect(val).to.have.members([idsBdCompte[1]]); + expect(val).to.have.members([idsComptes[1]]); }); it("Détecter confiance d'autre membre", async () => { const val = await fiablesAutres.attendreQue((x) => !!x && x.length > 0); expect(val.length).to.equal(1); - expect(val).to.have.members([idsBdCompte[1]]); + expect(val).to.have.members([idsComptes[1]]); }); it("Un débloquage accidental ne fait rien", async () => { - await clients[0].réseau.débloquerMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.débloquerMembre({ + idCompte: idsComptes[1], }); const val = await fiablesPropres.attendreExiste(); expect(Array.isArray(val)).to.be.true(); expect(val.length).to.equal(1); - expect(val).to.have.members([idsBdCompte[1]]); + expect(val).to.have.members([idsComptes[1]]); }); it("Il n'était pas si chouette que ça après tout", async () => { - await clients[0].réseau.nePlusFaireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.nePlusFaireConfianceAuMembre({ + idCompte: idsComptes[1], }); const val = await fiablesPropres.attendreQue((x) => x.length === 0); expect(val).to.be.an.empty("array"); @@ -229,9 +225,9 @@ if (isNode || isElectronMain) { }); describe("Membres bloqués", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; const bloquésTous = new utilsTestAttente.AttendreRésultat(); const bloquésPubliques = new utilsTestAttente.AttendreRésultat< @@ -244,28 +240,28 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(3)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(3)); fsOublier.push( - await clients[0].réseau.suivreBloqués({ + await constls[0].réseau.suivreBloqués({ f: (m) => bloquésTous.mettreÀJour(m), }), ); fsOublier.push( - await clients[0].réseau.suivreBloquésPubliques({ + await constls[0].réseau.suivreBloquésPubliques({ f: (m) => bloquésPubliques.mettreÀJour(m), }), ); fsOublier.push( - await clients[1].réseau.suivreBloqués({ + await constls[1].réseau.suivreBloqués({ f: (m) => bloquésAutreMembre.mettreÀJour(m), - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], }), ); }); after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); bloquésTous.toutAnnuler(); bloquésPubliques.toutAnnuler(); @@ -278,24 +274,24 @@ if (isNode || isElectronMain) { }); it("Bloquer quelqu'un", async () => { - await clients[0].réseau.bloquerMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.bloquerMembre({ + idCompte: idsComptes[1], }); const val = await bloquésTous.attendreQue((x) => !!x && x.length > 0); expect(val.length).to.equal(1); expect(val).to.have.deep.members([ { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], privé: false, }, ]); - expect(bloquésPubliques.val).to.have.members([idsBdCompte[1]]); + expect(bloquésPubliques.val).to.have.members([idsComptes[1]]); }); it("Un dé-confiance accidental ne fait rien", async () => { - await clients[0].réseau.nePlusFaireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.nePlusFaireConfianceAuMembre({ + idCompte: idsComptes[1], }); const bloqués = await bloquésTous.attendreQue( @@ -304,15 +300,15 @@ if (isNode || isElectronMain) { expect(bloqués).to.have.deep.members([ { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], privé: false, }, ]); }); it("Bloquer privé", async () => { - await clients[0].réseau.bloquerMembre({ - idCompte: idsBdCompte[2], + await constls[0].réseau.bloquerMembre({ + idCompte: idsComptes[2], privé: true, }); @@ -321,11 +317,11 @@ if (isNode || isElectronMain) { ); expect(bloqués).to.have.deep.members([ { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], privé: false, }, { - idCompte: idsBdCompte[2], + idCompte: idsComptes[2], privé: true, }, ]); @@ -337,7 +333,7 @@ if (isNode || isElectronMain) { ); expect(val).to.have.deep.members([ { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], privé: false, }, ]); @@ -345,34 +341,34 @@ if (isNode || isElectronMain) { it("On ne détecte pas le bloqué privé d'un autre membre", async () => { const val = await bloquésAutreMembre.attendreExiste(); - expect(val.map((b) => b.idCompte)).not.to.contain(idsBdCompte[2]); + expect(val.map((b) => b.idCompte)).not.to.contain(idsComptes[2]); }); it("Débloquer publique", async () => { - await clients[0].réseau.débloquerMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.débloquerMembre({ + idCompte: idsComptes[1], }); const val = await bloquésPubliques.attendreQue((x) => x.length === 0); expect(val.length).to.equal(0); }); it("Débloquer privé", async () => { - await clients[0].réseau.débloquerMembre({ - idCompte: idsBdCompte[2], + await constls[0].réseau.débloquerMembre({ + idCompte: idsComptes[2], }); const val = await bloquésTous.attendreQue((x) => x.length === 0); expect(val.length).to.equal(0); }); it("Passer de bloqué privé à bloqué publique", async () => { - await clients[0].réseau.bloquerMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.bloquerMembre({ + idCompte: idsComptes[1], privé: true, }); let val = await bloquésPubliques.attendreExiste(); expect(val.length).to.equal(0); - await clients[0].réseau.bloquerMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.bloquerMembre({ + idCompte: idsComptes[1], privé: false, }); val = await bloquésPubliques.attendreQue((x) => x.length > 0); @@ -383,9 +379,9 @@ if (isNode || isElectronMain) { describe("Suivre relations immédiates", function () { describe("Relations explicites", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; const relationsPropres = new utilsTestAttente.AttendreRésultat< infoConfiance[] @@ -397,23 +393,23 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(3)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(3)); fsOublier.push( - await clients[0].réseau.suivreRelationsImmédiates({ + await constls[0].réseau.suivreRelationsImmédiates({ f: (c) => relationsPropres.mettreÀJour(c), }), ); fsOublier.push( - await clients[1].réseau.suivreRelationsImmédiates({ + await constls[1].réseau.suivreRelationsImmédiates({ f: (c) => relationsAutres.mettreÀJour(c), - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], }), ); }); after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); relationsPropres.toutAnnuler(); relationsAutres.toutAnnuler(); @@ -430,12 +426,12 @@ if (isNode || isElectronMain) { it("Ajout membre de confiance détecté", async () => { const réf: infoConfiance[] = [ { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, }, ]; - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[1], }); const val = await relationsPropres.attendreQue( (x) => !!x && !!x.length, @@ -447,17 +443,17 @@ if (isNode || isElectronMain) { it("Bloquer membre détecté", async () => { const réf: infoConfiance[] = [ { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, }, { - idCompte: idsBdCompte[2], + idCompte: idsComptes[2], confiance: -1, }, ]; - await clients[0].réseau.bloquerMembre({ - idCompte: idsBdCompte[2], + await constls[0].réseau.bloquerMembre({ + idCompte: idsComptes[2], }); const val = await relationsPropres.attendreQue( (x) => !!x && x.length === 2, @@ -468,18 +464,18 @@ if (isNode || isElectronMain) { it("Débloquer membre détecté", async () => { const réf: infoConfiance[] = [ { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, }, ]; - await clients[0].réseau.débloquerMembre({ - idCompte: idsBdCompte[2], + await constls[0].réseau.débloquerMembre({ + idCompte: idsComptes[2], }); const val = await relationsPropres.attendreQue( (x) => - x.find((r) => r.idCompte === idsBdCompte[1])?.confiance !== -1, + x.find((r) => r.idCompte === idsComptes[1])?.confiance !== -1, ); - expect(val.find((r) => r.idCompte === idsBdCompte[1])).to.deep.equal( + expect(val.find((r) => r.idCompte === idsComptes[1])).to.deep.equal( réf[0], ); }); @@ -487,7 +483,7 @@ if (isNode || isElectronMain) { it("Ajout membres au réseau d'un autre membre détecté", async () => { const réf: infoConfiance[] = [ { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, }, ]; @@ -500,8 +496,8 @@ if (isNode || isElectronMain) { }); it("Enlever membre de confiance détecté", async () => { - await clients[0].réseau.nePlusFaireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.nePlusFaireConfianceAuMembre({ + idCompte: idsComptes[1], }); const val = await relationsPropres.attendreQue( (x) => !!x && x.length == 0, @@ -511,9 +507,9 @@ if (isNode || isElectronMain) { }); describe("Relations indirectes", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; let idMotClef1: string; let idMotClef2: string; @@ -531,49 +527,49 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(2)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(2)); fsOublier.push( - await clients[0].réseau.suivreRelationsImmédiates({ + await constls[0].réseau.suivreRelationsImmédiates({ f: (c) => relationsPropres.mettreÀJour(c), }), ); fsOublier.push( - await clients[1].réseau.suivreRelationsImmédiates({ + await constls[1].réseau.suivreRelationsImmédiates({ f: (c) => relationsAutres.mettreÀJour(c), - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], }), ); }); after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); relationsPropres.toutAnnuler(); relationsAutres.toutAnnuler(); }); it("Ajout aux favoris détecté", async () => { - idMotClef2 = await clients[1].motsClefs.créerMotClef(); - await clients[0].motsClefs.épinglerMotClef({ + idMotClef2 = await constls[1].motsClefs.créerMotClef(); + await constls[0].motsClefs.épinglerMotClef({ idMotClef: idMotClef2, }); const val = await relationsPropres.attendreQue( (x) => !!x && x.length > 0, ); - expect(val.map((r) => r.idCompte)).to.contain(idsBdCompte[1]); + expect(val.map((r) => r.idCompte)).to.contain(idsComptes[1]); }); it("Ajout aux favoris d'un tiers détecté", async () => { const val = await relationsAutres.attendreQue( (x) => !!x && Boolean(x.length), ); - expect(val.map((r) => r.idCompte)).to.contain(idsBdCompte[1]); + expect(val.map((r) => r.idCompte)).to.contain(idsComptes[1]); }); it("Enlever favori détecté", async () => { - await clients[0].favoris.désépinglerFavori({ + await constls[0].favoris.désépinglerFavori({ idObjet: idMotClef2, }); const valPropres = await relationsPropres.attendreQue( @@ -588,12 +584,12 @@ if (isNode || isElectronMain) { }); it("Ajout coauteur variable détecté", async () => { - idVariable = await clients[0].variables.créerVariable({ + idVariable = await constls[0].variables.créerVariable({ catégorie: "numérique", }); - await clients[0].variables.inviterAuteur({ + await constls[0].variables.inviterAuteur({ idVariable, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MEMBRE, }); @@ -601,16 +597,16 @@ if (isNode || isElectronMain) { (x) => !!x && Boolean(x.length), ); - expect(val.map((r) => r.idCompte)).to.contain(idsBdCompte[1]); + expect(val.map((r) => r.idCompte)).to.contain(idsComptes[1]); }); it("Ajout coauteur variable d'un tiers détecté", async () => { const val = await relationsAutres.attendreQue((x) => x.length > 0); - expect(val.map((r) => r.idCompte)).to.contain(idsBdCompte[1]); + expect(val.map((r) => r.idCompte)).to.contain(idsComptes[1]); }); it("Enlever variable détecté", async () => { - await clients[0].variables.effacerVariable({ idVariable }); + await constls[0].variables.effacerVariable({ idVariable }); const valPropres = await relationsPropres.attendreQue( (x) => x.length < 1, ); @@ -621,10 +617,10 @@ if (isNode || isElectronMain) { }); it("Ajout coauteur BD détecté", async () => { - idBd = await clients[0].bds.créerBd({ licence: "ODbl-1_0" }); - await clients[0].bds.inviterAuteur({ + idBd = await constls[0].bds.créerBd({ licence: "ODbl-1_0" }); + await constls[0].bds.inviterAuteur({ idBd, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MEMBRE, }); @@ -632,18 +628,18 @@ if (isNode || isElectronMain) { (x) => !!x && Boolean(x.length), ); - expect(val.map((r) => r.idCompte)).to.contain(idsBdCompte[1]); + expect(val.map((r) => r.idCompte)).to.contain(idsComptes[1]); }); it("Ajout coauteur BD d'un tiers détecté", async () => { const val = await relationsAutres.attendreQue( (x) => !!x && Boolean(x.length), ); - expect(val.map((r) => r.idCompte)).to.contain(idsBdCompte[1]); + expect(val.map((r) => r.idCompte)).to.contain(idsComptes[1]); }); it("Enlever bd détecté", async () => { - await clients[0].bds.effacerBd({ idBd }); + await constls[0].bds.effacerBd({ idBd }); const valPropres = await relationsPropres.attendreQue( (x) => x.length < 1, ); @@ -654,28 +650,28 @@ if (isNode || isElectronMain) { }); it("Ajout coauteur projet détecté", async () => { - idProjet = await clients[0].projets.créerProjet(); - await clients[0].projets.inviterAuteur({ + idProjet = await constls[0].projets.créerProjet(); + await constls[0].projets.inviterAuteur({ idProjet, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MEMBRE, }); const val = await relationsPropres.attendreQue( (x) => !!x && Boolean(x.length), ); - expect(val.map((r) => r.idCompte)).to.contain(idsBdCompte[1]); + expect(val.map((r) => r.idCompte)).to.contain(idsComptes[1]); }); it("Ajout coauteur projet d'un tiers détecté", async () => { const val = await relationsAutres.attendreQue( (x) => !!x && Boolean(x.length), ); - expect(val.map((r) => r.idCompte)).to.contain(idsBdCompte[1]); + expect(val.map((r) => r.idCompte)).to.contain(idsComptes[1]); }); it("Enlever projet détecté", async () => { - await clients[0].projets.effacerProjet({ idProjet }); + await constls[0].projets.effacerProjet({ idProjet }); const valPropres = await relationsPropres.attendreQue( (x) => !x.length, ); @@ -686,28 +682,28 @@ if (isNode || isElectronMain) { }); it("Ajout coauteur mot-clef détecté", async () => { - idMotClef1 = await clients[0].motsClefs.créerMotClef(); - await clients[0].motsClefs.inviterAuteur({ + idMotClef1 = await constls[0].motsClefs.créerMotClef(); + await constls[0].motsClefs.inviterAuteur({ idMotClef: idMotClef1, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MEMBRE, }); const val = await relationsPropres.attendreQue( (x) => !!x && Boolean(x.length), ); - expect(val.map((r) => r.idCompte)).to.contain(idsBdCompte[1]); + expect(val.map((r) => r.idCompte)).to.contain(idsComptes[1]); }); it("Ajout coauteur mot-clef d'un tiers détecté", async () => { const val = await relationsAutres.attendreQue( (x) => !!x && Boolean(x.length), ); - expect(val.map((r) => r.idCompte)).to.contain(idsBdCompte[1]); + expect(val.map((r) => r.idCompte)).to.contain(idsComptes[1]); }); it("Enlever mot-clef détecté", async () => { - await clients[0].motsClefs.effacerMotClef({ + await constls[0].motsClefs.effacerMotClef({ idMotClef: idMotClef1, }); const valPropres = await relationsPropres.attendreQue( @@ -725,18 +721,18 @@ if (isNode || isElectronMain) { }); describe("Suivre relations confiance", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; let fOublier: schémaFonctionOublier; let fChangerProfondeur: schémaRetourFonctionRechercheParProfondeur["fChangerProfondeur"]; const rés = new utilsTestAttente.AttendreRésultat(); before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(3)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(3)); ({ fOublier, fChangerProfondeur } = - await clients[0].réseau.suivreRelationsConfiance({ + await constls[0].réseau.suivreRelationsConfiance({ f: (r) => rés.mettreÀJour(r), profondeur: 2, })); @@ -744,7 +740,7 @@ if (isNode || isElectronMain) { after(async () => { if (fOublier) await fOublier(); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); rés.toutAnnuler(); }); @@ -752,14 +748,14 @@ if (isNode || isElectronMain) { it("Relations immédiates", async () => { const réf: infoRelation[] = [ { - de: idsBdCompte[0], - pour: idsBdCompte[1], + de: idsComptes[0], + pour: idsComptes[1], confiance: 1, profondeur: 1, }, ]; - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[1], }); const val = await rés.attendreQue((x) => !!x && !!x.length); @@ -768,20 +764,20 @@ if (isNode || isElectronMain) { it("Relations indirectes", async () => { const réf: infoRelation[] = [ { - de: idsBdCompte[0], - pour: idsBdCompte[1], + de: idsComptes[0], + pour: idsComptes[1], confiance: 1, profondeur: 1, }, { - de: idsBdCompte[1], - pour: idsBdCompte[2], + de: idsComptes[1], + pour: idsComptes[2], confiance: 1, profondeur: 2, }, ]; - await clients[1].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[2], + await constls[1].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[2], }); const val = await rés.attendreQue((x) => !!x && x.length > 1); @@ -791,8 +787,8 @@ if (isNode || isElectronMain) { it("Diminuer profondeur", async () => { const réf: infoRelation[] = [ { - de: idsBdCompte[0], - pour: idsBdCompte[1], + de: idsComptes[0], + pour: idsComptes[1], confiance: 1, profondeur: 1, }, @@ -805,14 +801,14 @@ if (isNode || isElectronMain) { it("Augmenter profondeur", async () => { const réf: infoRelation[] = [ { - de: idsBdCompte[0], - pour: idsBdCompte[1], + de: idsComptes[0], + pour: idsComptes[1], confiance: 1, profondeur: 1, }, { - de: idsBdCompte[1], - pour: idsBdCompte[2], + de: idsComptes[1], + pour: idsComptes[2], confiance: 1, profondeur: 2, }, @@ -826,10 +822,10 @@ if (isNode || isElectronMain) { }); describe("Suivre comptes réseau", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; let moiMême: infoMembreRéseau; - let clients: Constellation[]; + let constls: Constellation[]; let fOublier: schémaFonctionOublier; let fChangerProfondeur: schémaRetourFonctionRechercheParProfondeur["fChangerProfondeur"]; @@ -837,14 +833,14 @@ if (isNode || isElectronMain) { const rés = new utilsTestAttente.AttendreRésultat(); before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(3)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(3)); moiMême = { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], profondeur: 0, confiance: 1, }; ({ fOublier, fChangerProfondeur } = - await clients[0].réseau.suivreComptesRéseau({ + await constls[0].réseau.suivreComptesRéseau({ f: (c) => rés.mettreÀJour(c), profondeur: 2, })); @@ -852,7 +848,7 @@ if (isNode || isElectronMain) { after(async () => { if (fOublier) await fOublier(); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); rés.toutAnnuler(); }); @@ -860,13 +856,13 @@ if (isNode || isElectronMain) { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, profondeur: 1, }, ]; - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[1], }); const val = await rés.attendreQue((x) => !!x && x.length > 1); @@ -876,18 +872,18 @@ if (isNode || isElectronMain) { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, profondeur: 1, }, { - idCompte: idsBdCompte[2], + idCompte: idsComptes[2], confiance: 0.8, profondeur: 2, }, ]; - await clients[1].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[2], + await constls[1].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[2], }); await rés.attendreQue((x) => !!x && x.length > 2); @@ -897,18 +893,18 @@ if (isNode || isElectronMain) { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, profondeur: 1, }, { - idCompte: idsBdCompte[2], + idCompte: idsComptes[2], confiance: 1, profondeur: 1, }, ]; - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[2], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[2], }); const val = await rés.attendreQue( @@ -922,18 +918,18 @@ if (isNode || isElectronMain) { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, profondeur: 1, }, { - idCompte: idsBdCompte[2], + idCompte: idsComptes[2], confiance: 0.8, profondeur: 2, }, ]; - await clients[0].réseau.nePlusFaireConfianceAuMembre({ - idCompte: idsBdCompte[2], + await constls[0].réseau.nePlusFaireConfianceAuMembre({ + idCompte: idsComptes[2], }); const val = await rés.attendreQue( @@ -947,13 +943,13 @@ if (isNode || isElectronMain) { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, profondeur: 1, }, ]; - await clients[1].réseau.nePlusFaireConfianceAuMembre({ - idCompte: idsBdCompte[2], + await constls[1].réseau.nePlusFaireConfianceAuMembre({ + idCompte: idsComptes[2], }); const val = await rés.attendreQue((x) => x.length === 2); @@ -962,8 +958,8 @@ if (isNode || isElectronMain) { it("Enlever relation confiance directe", async () => { const réf = [moiMême]; - await clients[0].réseau.nePlusFaireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.nePlusFaireConfianceAuMembre({ + idCompte: idsComptes[1], }); const val = await rés.attendreQue((x) => !!x && x.length === 1); @@ -973,13 +969,13 @@ if (isNode || isElectronMain) { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: -1, profondeur: 1, }, ]; - await clients[0].réseau.bloquerMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.bloquerMembre({ + idCompte: idsComptes[1], }); const val = await rés.attendreQue((x) => !!x && x.length > 1); @@ -988,8 +984,8 @@ if (isNode || isElectronMain) { it("Membre débloqué directement", async () => { const réf = [moiMême]; - await clients[0].réseau.débloquerMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.débloquerMembre({ + idCompte: idsComptes[1], }); const val = await rés.attendreQue((x) => !!x && x.length === 1); @@ -999,21 +995,21 @@ if (isNode || isElectronMain) { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, profondeur: 1, }, { - idCompte: idsBdCompte[2], + idCompte: idsComptes[2], confiance: -0.9, profondeur: 2, }, ]; - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[1], }); - await clients[1].réseau.bloquerMembre({ - idCompte: idsBdCompte[2], + await constls[1].réseau.bloquerMembre({ + idCompte: idsComptes[2], }); const val = await rés.attendreQue((x) => !!x && x.length === 3); @@ -1023,51 +1019,50 @@ if (isNode || isElectronMain) { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, profondeur: 1, }, { - idCompte: idsBdCompte[2], + idCompte: idsComptes[2], confiance: 1, profondeur: 1, }, ]; - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[2], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[2], }); const val = await rés.attendreQue( (x) => - !!x && - x.find((y) => y.idCompte === idsBdCompte[2])?.confiance === 1, + !!x && x.find((y) => y.idCompte === idsComptes[2])?.confiance === 1, ); expect(val).to.have.deep.members(réf); - await clients[0].réseau.nePlusFaireConfianceAuMembre({ - idCompte: idsBdCompte[2], + await constls[0].réseau.nePlusFaireConfianceAuMembre({ + idCompte: idsComptes[2], }); - await clients[0].réseau.nePlusFaireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.nePlusFaireConfianceAuMembre({ + idCompte: idsComptes[1], }); - await clients[1].réseau.débloquerMembre({ - idCompte: idsBdCompte[2], + await constls[1].réseau.débloquerMembre({ + idCompte: idsComptes[2], }); }); it("Diminuer profondeur", async () => { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, profondeur: 1, }, ]; - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[1], }); - await clients[1].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[2], + await constls[1].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[2], }); rés.attendreQue( (x) => !!x && x.length === 3 && x.every((r) => r.confiance > 0), @@ -1081,12 +1076,12 @@ if (isNode || isElectronMain) { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, profondeur: 1, }, { - idCompte: idsBdCompte[2], + idCompte: idsComptes[2], confiance: 0.8, profondeur: 2, }, @@ -1101,10 +1096,10 @@ if (isNode || isElectronMain) { }); describe("Suivre comptes réseau et en ligne", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; let moiMême: infoMembreRéseau; - let clients: Constellation[]; + let constls: Constellation[]; let fOublier: schémaFonctionOublier; let fChangerProfondeur: schémaRetourFonctionRechercheParProfondeur["fChangerProfondeur"]; @@ -1112,15 +1107,15 @@ if (isNode || isElectronMain) { const rés = new utilsTestAttente.AttendreRésultat(); before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(3)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(3)); moiMême = { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], profondeur: 0, confiance: 1, }; ({ fOublier, fChangerProfondeur } = - await clients[0].réseau.suivreComptesRéseauEtEnLigne({ + await constls[0].réseau.suivreComptesRéseauEtEnLigne({ f: (c) => rés.mettreÀJour(c), profondeur: 2, })); @@ -1128,7 +1123,7 @@ if (isNode || isElectronMain) { after(async () => { if (fOublier) await fOublier(); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); rés.toutAnnuler(); }); @@ -1136,12 +1131,12 @@ if (isNode || isElectronMain) { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 0, profondeur: Infinity, }, { - idCompte: idsBdCompte[2], + idCompte: idsComptes[2], confiance: 0, profondeur: Infinity, }, @@ -1155,49 +1150,49 @@ if (isNode || isElectronMain) { const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, profondeur: 1, }, { - idCompte: idsBdCompte[2], + idCompte: idsComptes[2], confiance: 0, profondeur: Infinity, }, ]; - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[1], }); const val = await rés.attendreQue( (x) => !!x && - x.find((x) => x.idCompte === idsBdCompte[1])?.confiance === 1 && - x.find((x) => x.idCompte === idsBdCompte[2])?.confiance === 0, + x.find((x) => x.idCompte === idsComptes[1])?.confiance === 1 && + x.find((x) => x.idCompte === idsComptes[2])?.confiance === 0, ); expect(val).to.have.deep.members(réf); }); it("Changer profondeur", async () => { - await clients[1].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[2], + await constls[1].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[2], }); await rés.attendreQue( (x) => !!x && - (x.find((x) => x.idCompte === idsBdCompte[2])?.confiance || 0) > 0, + (x.find((x) => x.idCompte === idsComptes[2])?.confiance || 0) > 0, ); const réf: infoMembreRéseau[] = [ moiMême, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], confiance: 1, profondeur: 1, }, { - idCompte: idsBdCompte[2], + idCompte: idsComptes[2], confiance: 0, profondeur: Infinity, }, @@ -1205,8 +1200,7 @@ if (isNode || isElectronMain) { fChangerProfondeur(1); const val = await rés.attendreQue( (x) => - !!x && - x.find((x) => x.idCompte === idsBdCompte[2])?.confiance === 0, + !!x && x.find((x) => x.idCompte === idsComptes[2])?.confiance === 0, ); expect(val).to.have.deep.members(réf); @@ -1214,9 +1208,9 @@ if (isNode || isElectronMain) { }); describe("Suivre confiance mon réseau pour membre", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; let fOublier: schémaFonctionOublier; let fChangerProfondeur: schémaRetourFonctionRechercheParProfondeur["fChangerProfondeur"]; @@ -1224,10 +1218,10 @@ if (isNode || isElectronMain) { const rés = new utilsTestAttente.AttendreRésultat(); before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(3)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(3)); ({ fOublier, fChangerProfondeur } = - await clients[0].réseau.suivreConfianceMonRéseauPourMembre({ - idCompte: idsBdCompte[2], + await constls[0].réseau.suivreConfianceMonRéseauPourMembre({ + idCompte: idsComptes[2], f: (confiance) => rés.mettreÀJour(confiance), profondeur: 4, })); @@ -1237,7 +1231,7 @@ if (isNode || isElectronMain) { rés.toutAnnuler(); if (fOublier) await fOublier(); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); }); it("Confiance initiale 0", async () => { @@ -1245,11 +1239,11 @@ if (isNode || isElectronMain) { }); it("Faire confiance au membre", async () => { - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[1], }); - await clients[1].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[2], + await constls[1].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[2], }); const val = await rés.attendreQue((x) => !!x && x > 0); @@ -1263,9 +1257,9 @@ if (isNode || isElectronMain) { }); describe("Suivre confiance auteurs", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; let fOublier: schémaFonctionOublier; let idMotClef: string; @@ -1273,10 +1267,10 @@ if (isNode || isElectronMain) { const rés = new utilsTestAttente.AttendreRésultat(); before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(3)); - idMotClef = await clients[1].motsClefs.créerMotClef(); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(3)); + idMotClef = await constls[1].motsClefs.créerMotClef(); - fOublier = await clients[0].réseau.suivreConfianceAuteurs({ + fOublier = await constls[0].réseau.suivreConfianceAuteurs({ idItem: idMotClef, clef: "motsClefs", f: (confiance) => rés.mettreÀJour(confiance), @@ -1285,7 +1279,7 @@ if (isNode || isElectronMain) { after(async () => { if (fOublier) await fOublier(); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); rés.toutAnnuler(); }); @@ -1294,8 +1288,8 @@ if (isNode || isElectronMain) { }); it("Ajout auteur au réseau", async () => { - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[1], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[1], }); const val = await rés.attendreQue((x) => !!x && x > 0); @@ -1303,19 +1297,19 @@ if (isNode || isElectronMain) { }); it("Ajout coauteur au réseau", async () => { - await clients[1].motsClefs.inviterAuteur({ + await constls[1].motsClefs.inviterAuteur({ idMotClef, - idCompteAuteur: idsBdCompte[2], + idCompteAuteur: idsComptes[2], rôle: MEMBRE, }); - await clients[2].motsClefs.ajouterÀMesMotsClefs({ idMotClef }); + await constls[2].motsClefs.ajouterÀMesMotsClefs({ idMotClef }); const valAvant = await rés.attendreQue((x) => !!x && x > 1); expect(valAvant).to.be.greaterThan(1); expect(valAvant).to.be.lessThan(2); - await clients[0].réseau.faireConfianceAuMembre({ - idCompte: idsBdCompte[2], + await constls[0].réseau.faireConfianceAuMembre({ + idCompte: idsComptes[2], }); const val = await rés.attendreQue((x) => !!x && x > valAvant); @@ -1323,7 +1317,7 @@ if (isNode || isElectronMain) { }); it("Coauteur se retire", async () => { - await clients[2].motsClefs.enleverDeMesMotsClefs({ idMotClef }); + await constls[2].motsClefs.enleverDeMesMotsClefs({ idMotClef }); const val = await rés.attendreQue((x) => !!x && x < 2); expect(val).to.equal(1); @@ -1331,9 +1325,9 @@ if (isNode || isElectronMain) { }); describe("Auteurs", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; let idMotClef: string; let idVariable: string; @@ -1348,37 +1342,37 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(2)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(2)); - idMotClef = await clients[0].motsClefs.créerMotClef(); + idMotClef = await constls[0].motsClefs.créerMotClef(); fsOublier.push( - await clients[0].réseau.suivreAuteursMotClef({ + await constls[0].réseau.suivreAuteursMotClef({ idMotClef, f: (auteurs) => résMotClef.mettreÀJour(auteurs), }), ); - idVariable = await clients[0].variables.créerVariable({ + idVariable = await constls[0].variables.créerVariable({ catégorie: "numérique", }); fsOublier.push( - await clients[0].réseau.suivreAuteursVariable({ + await constls[0].réseau.suivreAuteursVariable({ idVariable, f: (auteurs) => résVariable.mettreÀJour(auteurs), }), ); - idBd = await clients[0].bds.créerBd({ licence: "ODbl-1_0" }); + idBd = await constls[0].bds.créerBd({ licence: "ODbl-1_0" }); fsOublier.push( - await clients[0].réseau.suivreAuteursBd({ + await constls[0].réseau.suivreAuteursBd({ idBd, f: (auteurs) => résBds.mettreÀJour(auteurs), }), ); - idProjet = await clients[0].projets.créerProjet(); + idProjet = await constls[0].projets.créerProjet(); fsOublier.push( - await clients[0].réseau.suivreAuteursProjet({ + await constls[0].réseau.suivreAuteursProjet({ idProjet, f: (auteurs) => résProjet.mettreÀJour(auteurs), }), @@ -1387,7 +1381,7 @@ if (isNode || isElectronMain) { after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); résMotClef.toutAnnuler(); résVariable.toutAnnuler(); résBds.toutAnnuler(); @@ -1397,19 +1391,19 @@ if (isNode || isElectronMain) { it("Mots-clefs : Inviter auteur", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: false, rôle: MEMBRE, }, ]; - await clients[0].motsClefs.inviterAuteur({ + await constls[0].motsClefs.inviterAuteur({ idMotClef, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MEMBRE, }); @@ -1419,20 +1413,20 @@ if (isNode || isElectronMain) { it("Mots-clefs : Accepter invitation", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: true, rôle: MEMBRE, }, ]; - await clients[1].motsClefs.ajouterÀMesMotsClefs({ idMotClef }); + await constls[1].motsClefs.ajouterÀMesMotsClefs({ idMotClef }); const val = await résMotClef.attendreQue((x) => - Boolean(!!x && x.find((y) => y.idCompte === idsBdCompte[1])?.accepté), + Boolean(!!x && x.find((y) => y.idCompte === idsComptes[1])?.accepté), ); expect(val).to.deep.equal(réf); @@ -1440,35 +1434,35 @@ if (isNode || isElectronMain) { it("Mots-clefs : Refuser invitation", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: false, rôle: MEMBRE, }, ]; - await clients[1].motsClefs.enleverDeMesMotsClefs({ idMotClef }); + await constls[1].motsClefs.enleverDeMesMotsClefs({ idMotClef }); const val = await résMotClef.attendreQue( - (x) => !!x && !x.find((y) => y.idCompte === idsBdCompte[1])?.accepté, + (x) => !!x && !x.find((y) => y.idCompte === idsComptes[1])?.accepté, ); expect(val).to.deep.equal(réf); }); it("Mots-clefs : Promotion à modérateur", async () => { - await clients[0].motsClefs.inviterAuteur({ + await constls[0].motsClefs.inviterAuteur({ idMotClef, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MODÉRATEUR, }); await résMotClef.attendreQue( (auteurs) => !!auteurs && - auteurs.find((a) => a.idCompte === idsBdCompte[1])?.rôle === + auteurs.find((a) => a.idCompte === idsComptes[1])?.rôle === MODÉRATEUR, ); }); @@ -1476,19 +1470,19 @@ if (isNode || isElectronMain) { it("Variables : Inviter auteur", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: false, rôle: MEMBRE, }, ]; - await clients[0].variables.inviterAuteur({ + await constls[0].variables.inviterAuteur({ idVariable, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MEMBRE, }); @@ -1498,22 +1492,22 @@ if (isNode || isElectronMain) { it("Variables : Accepter invitation", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: true, rôle: MEMBRE, }, ]; - await clients[1].variables.ajouterÀMesVariables({ + await constls[1].variables.ajouterÀMesVariables({ idVariable, }); const val = await résVariable.attendreQue( - (x) => !!x?.find((y) => y.idCompte === idsBdCompte[1])?.accepté, + (x) => !!x?.find((y) => y.idCompte === idsComptes[1])?.accepté, ); expect(val).to.have.deep.members(réf); @@ -1521,37 +1515,37 @@ if (isNode || isElectronMain) { it("Variables : Refuser invitation", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: false, rôle: MEMBRE, }, ]; - await clients[1].variables.enleverDeMesVariables({ + await constls[1].variables.enleverDeMesVariables({ idVariable, }); const val = await résVariable.attendreQue( - (x) => !!x && !x.find((y) => y.idCompte === idsBdCompte[1])?.accepté, + (x) => !!x && !x.find((y) => y.idCompte === idsComptes[1])?.accepté, ); expect(val).to.have.deep.members(réf); }); it("Variables : Promotion à modérateur", async () => { - await clients[0].variables.inviterAuteur({ + await constls[0].variables.inviterAuteur({ idVariable, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MODÉRATEUR, }); await résVariable.attendreQue( (auteurs) => !!auteurs && - auteurs.find((a) => a.idCompte === idsBdCompte[1])?.rôle === + auteurs.find((a) => a.idCompte === idsComptes[1])?.rôle === MODÉRATEUR, ); }); @@ -1559,19 +1553,19 @@ if (isNode || isElectronMain) { it("Bds : Inviter auteur", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: false, rôle: MEMBRE, }, ]; - await clients[0].bds.inviterAuteur({ + await constls[0].bds.inviterAuteur({ idBd, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MEMBRE, }); @@ -1581,20 +1575,20 @@ if (isNode || isElectronMain) { it("Bds : Accepter invitation", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: true, rôle: MEMBRE, }, ]; - await clients[1].bds.ajouterÀMesBds({ idBd }); + await constls[1].bds.ajouterÀMesBds({ idBd }); const val = await résBds.attendreQue((x) => - Boolean(!!x && x.find((y) => y.idCompte === idsBdCompte[1])?.accepté), + Boolean(!!x && x.find((y) => y.idCompte === idsComptes[1])?.accepté), ); expect(val).to.have.deep.members(réf); @@ -1602,35 +1596,35 @@ if (isNode || isElectronMain) { it("Bds : Refuser invitation", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: false, rôle: MEMBRE, }, ]; - await clients[1].bds.enleverDeMesBds({ idBd }); + await constls[1].bds.enleverDeMesBds({ idBd }); const val = await résBds.attendreQue( - (x) => !!x && !x.find((y) => y.idCompte === idsBdCompte[1])?.accepté, + (x) => !!x && !x.find((y) => y.idCompte === idsComptes[1])?.accepté, ); expect(val).to.have.deep.members(réf); }); it("Bds : Promotion à modérateur", async () => { - await clients[0].bds.inviterAuteur({ + await constls[0].bds.inviterAuteur({ idBd, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MODÉRATEUR, }); await résBds.attendreQue( (auteurs) => !!auteurs && - auteurs.find((a) => a.idCompte === idsBdCompte[1])?.rôle === + auteurs.find((a) => a.idCompte === idsComptes[1])?.rôle === MODÉRATEUR, ); }); @@ -1638,19 +1632,19 @@ if (isNode || isElectronMain) { it("Projets : Inviter auteur", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: false, rôle: MEMBRE, }, ]; - await clients[0].projets.inviterAuteur({ + await constls[0].projets.inviterAuteur({ idProjet, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MEMBRE, }); @@ -1660,20 +1654,20 @@ if (isNode || isElectronMain) { it("Projets : Accepter invitation", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: true, rôle: MEMBRE, }, ]; - await clients[1].projets.ajouterÀMesProjets({ idProjet }); + await constls[1].projets.ajouterÀMesProjets({ idProjet }); const val = await résProjet.attendreQue((x) => - Boolean(!!x && x.find((y) => y.idCompte === idsBdCompte[1])?.accepté), + Boolean(!!x && x.find((y) => y.idCompte === idsComptes[1])?.accepté), ); expect(val).to.have.deep.members(réf); @@ -1681,44 +1675,44 @@ if (isNode || isElectronMain) { it("Projets : Refuser invitation", async () => { const réf: infoAuteur[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], accepté: true, rôle: MODÉRATEUR, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], accepté: false, rôle: MEMBRE, }, ]; - await clients[1].projets.enleverDeMesProjets({ idProjet }); + await constls[1].projets.enleverDeMesProjets({ idProjet }); const val = await résProjet.attendreQue( - (x) => !!x && !x.find((y) => y.idCompte === idsBdCompte[1])?.accepté, + (x) => !!x && !x.find((y) => y.idCompte === idsComptes[1])?.accepté, ); expect(val).to.have.deep.members(réf); }); it("Projets : Promotion à modérateur", async () => { - await clients[0].projets.inviterAuteur({ + await constls[0].projets.inviterAuteur({ idProjet, - idCompteAuteur: idsBdCompte[1], + idCompteAuteur: idsComptes[1], rôle: MODÉRATEUR, }); await résProjet.attendreQue( (auteurs) => !!auteurs && - auteurs.find((a) => a.idCompte === idsBdCompte[1])?.rôle === + auteurs.find((a) => a.idCompte === idsComptes[1])?.rôle === MODÉRATEUR, ); }); }); describe("Suivre membre", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; let IMAGE: Buffer; const résNom = new utilsTestAttente.AttendreRésultat<{ @@ -1737,23 +1731,23 @@ if (isNode || isElectronMain) { nomFichier: "logo.svg", }); - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(2)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(2)); fsOublier.push( - await clients[1].profil.suivreNoms({ - idCompte: idsBdCompte[0], + await constls[1].profil.suivreNoms({ + idCompte: idsComptes[0], f: (n) => résNom.mettreÀJour(n), }), ); fsOublier.push( - await clients[1].profil.suivreCourriel({ - idCompte: idsBdCompte[0], + await constls[1].profil.suivreCourriel({ + idCompte: idsComptes[0], f: (c) => résCourriel.mettreÀJour(c), }), ); fsOublier.push( - await clients[1].profil.suivreImage({ - idCompte: idsBdCompte[0], + await constls[1].profil.suivreImage({ + idCompte: idsComptes[0], f: (i) => résImage.mettreÀJour(i), }), ); @@ -1761,14 +1755,14 @@ if (isNode || isElectronMain) { after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); résNom.toutAnnuler(); résCourriel.toutAnnuler(); résImage.toutAnnuler(); }); it("Nom détecté", async () => { - await clients[0].profil.sauvegarderNom({ + await constls[0].profil.sauvegarderNom({ langue: "fr", nom: "Julien", }); @@ -1778,7 +1772,7 @@ if (isNode || isElectronMain) { }); it("Courriel détecté", async () => { - await clients[0].profil.sauvegarderCourriel({ + await constls[0].profil.sauvegarderCourriel({ courriel: "தொடர்பு@லஸ்ஸி.இந்தியா", }); @@ -1789,7 +1783,7 @@ if (isNode || isElectronMain) { }); it("Image détectée", async () => { - await clients[0].profil.sauvegarderImage({ + await constls[0].profil.sauvegarderImage({ image: { contenu: IMAGE, nomFichier: "image.svg" }, }); @@ -1801,9 +1795,9 @@ if (isNode || isElectronMain) { }); describe("Suivre mots-clefs", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; let idMotClef1: string; let idMotClef2: string; @@ -1814,16 +1808,16 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(2)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(2)); fsOublier.push( - await clients[1].réseau.suivreMotsClefsMembre({ - idCompte: idsBdCompte[0], + await constls[1].réseau.suivreMotsClefsMembre({ + idCompte: idsComptes[0], f: (motsClefs) => résAutres.mettreÀJour(motsClefs), }), ); fsOublier.push( - await clients[1].réseau.suivreMotsClefsMembre({ - idCompte: idsBdCompte[1], + await constls[1].réseau.suivreMotsClefsMembre({ + idCompte: idsComptes[1], f: (motsClefs) => résPropres.mettreÀJour(motsClefs), }), ); @@ -1831,29 +1825,29 @@ if (isNode || isElectronMain) { after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); résPropres.toutAnnuler(); résAutres.toutAnnuler(); }); it("Mes propres mots-clefs détectés", async () => { - idMotClef2 = await clients[1].motsClefs.créerMotClef(); + idMotClef2 = await constls[1].motsClefs.créerMotClef(); const val = await résPropres.attendreQue((x) => !!x && !!x.length); expect(val).to.contain(idMotClef2); }); it("Mot-clef d'un autre membre détecté", async () => { - idMotClef1 = await clients[0].motsClefs.créerMotClef(); + idMotClef1 = await constls[0].motsClefs.créerMotClef(); const val = await résAutres.attendreQue((x) => !!x && !!x.length); expect(val).to.contain(idMotClef1); }); }); describe("Suivre variables", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; let idVariable1: string; let idVariable2: string; @@ -1864,16 +1858,16 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(2)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(2)); fsOublier.push( - await clients[1].réseau.suivreVariablesMembre({ - idCompte: idsBdCompte[0], + await constls[1].réseau.suivreVariablesMembre({ + idCompte: idsComptes[0], f: (variables) => résAutres.mettreÀJour(variables), }), ); fsOublier.push( - await clients[1].réseau.suivreVariablesMembre({ - idCompte: idsBdCompte[1], + await constls[1].réseau.suivreVariablesMembre({ + idCompte: idsComptes[1], f: (variables) => résPropres.mettreÀJour(variables), }), ); @@ -1884,11 +1878,11 @@ if (isNode || isElectronMain) { résAutres.toutAnnuler(); await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); }); it("Mes variables détectées", async () => { - idVariable2 = await clients[1].variables.créerVariable({ + idVariable2 = await constls[1].variables.créerVariable({ catégorie: "numérique", }); @@ -1897,7 +1891,7 @@ if (isNode || isElectronMain) { }); it("Variable d'un autre membre détectée", async () => { - idVariable1 = await clients[0].variables.créerVariable({ + idVariable1 = await constls[0].variables.créerVariable({ catégorie: "numérique", }); const val = await résAutres.attendreQue((x) => Boolean(x?.length)); @@ -1906,9 +1900,9 @@ if (isNode || isElectronMain) { }); describe("Suivre BDs", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; const résPropres = new utilsTestAttente.AttendreRésultat(); const résAutres = new utilsTestAttente.AttendreRésultat(); @@ -1916,16 +1910,16 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(2)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(2)); fsOublier.push( - await clients[1].réseau.suivreBdsMembre({ - idCompte: idsBdCompte[0], + await constls[1].réseau.suivreBdsMembre({ + idCompte: idsComptes[0], f: (bds) => résAutres.mettreÀJour(bds), }), ); fsOublier.push( - await clients[1].réseau.suivreBdsMembre({ - idCompte: idsBdCompte[1], + await constls[1].réseau.suivreBdsMembre({ + idCompte: idsComptes[1], f: (bds) => résPropres.mettreÀJour(bds), }), ); @@ -1933,29 +1927,29 @@ if (isNode || isElectronMain) { after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); résPropres.toutAnnuler(); résAutres.toutAnnuler(); }); it("Mes BDs détectées", async () => { - const idBd = await clients[1].bds.créerBd({ licence: "ODbl-1_0" }); + const idBd = await constls[1].bds.créerBd({ licence: "ODbl-1_0" }); const val = await résPropres.attendreQue((x) => !!x && !!x.length); expect(val).to.contain(idBd); }); it("BD d'un autre membre détectée", async () => { - const idBd = await clients[0].bds.créerBd({ licence: "ODbl-1_0" }); + const idBd = await constls[0].bds.créerBd({ licence: "ODbl-1_0" }); const val = await résAutres.attendreQue((x) => !!x && !!x.length); expect(val).to.contain(idBd); }); }); describe("Suivre projets", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; const résPropres = new utilsTestAttente.AttendreRésultat(); const résAutres = new utilsTestAttente.AttendreRésultat(); @@ -1963,16 +1957,16 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(2)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(2)); fsOublier.push( - await clients[1].réseau.suivreProjetsMembre({ - idCompte: idsBdCompte[0], + await constls[1].réseau.suivreProjetsMembre({ + idCompte: idsComptes[0], f: (projets) => résAutres.mettreÀJour(projets), }), ); fsOublier.push( - await clients[1].réseau.suivreProjetsMembre({ - idCompte: idsBdCompte[1], + await constls[1].réseau.suivreProjetsMembre({ + idCompte: idsComptes[1], f: (projets) => résPropres.mettreÀJour(projets), }), ); @@ -1980,29 +1974,29 @@ if (isNode || isElectronMain) { after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); résPropres.toutAnnuler(); résAutres.toutAnnuler(); }); it("Mes projets détectés", async () => { - const idProjet = await clients[1].projets.créerProjet(); + const idProjet = await constls[1].projets.créerProjet(); const val = await résPropres.attendreQue((x) => !!x && !!x.length); expect(val).to.contain(idProjet); }); it("Projet d'un autre membre détecté", async () => { - const idProjet = await clients[0].projets.créerProjet(); + const idProjet = await constls[0].projets.créerProjet(); const val = await résAutres.attendreQue((x) => !!x && !!x.length); expect(val).to.contain(idProjet); }); }); describe("Suivre favoris", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; let idMotClef: string; @@ -2016,22 +2010,22 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(2)); + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(2)); fsOublier.push( - await clients[1].réseau.suivreFavorisMembre({ - idCompte: idsBdCompte[0], + await constls[1].réseau.suivreFavorisMembre({ + idCompte: idsComptes[0], f: (favoris) => résAutres.mettreÀJour(favoris), }), ); fsOublier.push( - await clients[1].réseau.suivreFavorisMembre({ - idCompte: idsBdCompte[1], + await constls[1].réseau.suivreFavorisMembre({ + idCompte: idsComptes[1], f: (favoris) => résPropres.mettreÀJour(favoris), }), ); - idMotClef = await clients[0].motsClefs.créerMotClef({ + idMotClef = await constls[0].motsClefs.créerMotClef({ épingler: false, }); }); @@ -2041,7 +2035,7 @@ if (isNode || isElectronMain) { résAutres.toutAnnuler(); await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); }); it("Mes favoris détectés", async () => { @@ -2052,7 +2046,7 @@ if (isNode || isElectronMain) { base: TOUS, }, }; - await clients[1].favoris.épinglerFavori({ + await constls[1].favoris.épinglerFavori({ idObjet: idMotClef, épingle: { type: "motClef", @@ -2073,7 +2067,7 @@ if (isNode || isElectronMain) { base: TOUS, }, }; - await clients[0].favoris.épinglerFavori({ + await constls[0].favoris.épinglerFavori({ idObjet: idMotClef, épingle: { type: "motClef", @@ -2090,9 +2084,9 @@ if (isNode || isElectronMain) { }); describe("Suivre favoris objet", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; let idMotClef: string; let fOublier: schémaFonctionOublier; @@ -2102,12 +2096,12 @@ if (isNode || isElectronMain) { >(); before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(2)); - idMotClef = await clients[0].motsClefs.créerMotClef({ + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(2)); + idMotClef = await constls[0].motsClefs.créerMotClef({ épingler: false, }); - ({ fOublier } = await clients[0].réseau.suivreFavorisObjet({ + ({ fOublier } = await constls[0].réseau.suivreFavorisObjet({ idObjet: idMotClef, f: (favoris) => rés.mettreÀJour(favoris), profondeur: 4, @@ -2116,7 +2110,7 @@ if (isNode || isElectronMain) { after(async () => { if (fOublier) await fOublier(); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); rés.toutAnnuler(); }); @@ -2128,7 +2122,7 @@ if (isNode || isElectronMain) { it("Ajout à mes favoris détecté", async () => { const réf: { épingle: ÉpingleFavorisAvecId; idCompte: string }[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], épingle: { idObjet: idMotClef, épingle: { @@ -2138,7 +2132,7 @@ if (isNode || isElectronMain) { }, }, ]; - await clients[0].favoris.épinglerFavori({ + await constls[0].favoris.épinglerFavori({ idObjet: idMotClef, épingle: { type: "motClef", base: TOUS }, }); @@ -2150,21 +2144,21 @@ if (isNode || isElectronMain) { it("Ajout aux favoris d'un autre membre détecté", async () => { const réf: { épingle: ÉpingleFavorisAvecId; idCompte: string }[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], épingle: { épingle: { type: "motClef", base: TOUS }, idObjet: idMotClef, }, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], épingle: { épingle: { type: "motClef", base: TOUS }, idObjet: idMotClef, }, }, ]; - await clients[1].favoris.épinglerFavori({ + await constls[1].favoris.épinglerFavori({ idObjet: idMotClef, épingle: { type: "motClef", @@ -2178,10 +2172,10 @@ if (isNode || isElectronMain) { }); describe("Suivre réplications", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let idsOrbite: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let idsDispositifs: string[]; + let constls: Constellation[]; let idBd: string; @@ -2189,12 +2183,12 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, idsOrbite, clients, fOublierClients } = + ({ idsComptes, idsDispositifs, constls, fOublierConstls } = await toutPréparer(2)); - idBd = await clients[0].bds.créerBd({ licence: "ODbl-1_0" }); + idBd = await constls[0].bds.créerBd({ licence: "ODbl-1_0" }); fsOublier.push( ( - await clients[0].réseau.suivreRéplications({ + await constls[0].réseau.suivreRéplications({ idObjet: idBd, f: (bds) => rés.mettreÀJour(bds), profondeur: 4, @@ -2205,12 +2199,12 @@ if (isNode || isElectronMain) { after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); rés.toutAnnuler(); }); it("Auteur de la BD pour commencer", async () => { - await clients[0].favoris.épinglerFavori({ + await constls[0].favoris.épinglerFavori({ idObjet: idBd, épingle: { type: "motClef", base: TOUS }, }); @@ -2218,15 +2212,15 @@ if (isNode || isElectronMain) { const val = await rés.attendreQue((x) => !!x && x.membres.length > 0); expect(val.membres.map((m) => m.infoMembre.idCompte)).to.contain( - idsBdCompte[0], + idsComptes[0], ); expect( val.dispositifs.map((d) => d.dispositif.idDispositif), - ).to.contain(idsOrbite[0]); + ).to.contain(idsDispositifs[0]); }); it("Ajout d'une réplication détectée", async () => { - await clients[1].favoris.épinglerFavori({ + await constls[1].favoris.épinglerFavori({ idObjet: idBd, épingle: { type: "bd", @@ -2241,19 +2235,19 @@ if (isNode || isElectronMain) { const val = await rés.attendreQue((x) => !!x && x.membres.length > 1); expect(val.membres.map((m) => m.infoMembre.idCompte)).to.have.members([ - idsBdCompte[0], - idsBdCompte[1], + idsComptes[0], + idsComptes[1], ]); expect( val.dispositifs.map((d) => d.dispositif.idDispositif), - ).to.have.members([idsOrbite[0], idsOrbite[1]]); + ).to.have.members([idsDispositifs[0], idsDispositifs[1]]); }); }); describe("Suivre BD par mot-clef unique", function () { - let fOublierClients: () => Promise; - let idsBdCompte: string[]; - let clients: Constellation[]; + let fOublierConstls: () => Promise; + let idsComptes: string[]; + let constls: Constellation[]; let idNuée: string; let idBd1: string; @@ -2282,18 +2276,18 @@ if (isNode || isElectronMain) { const fsOublier: schémaFonctionOublier[] = []; before(async () => { - ({ idsBdCompte, clients, fOublierClients } = await toutPréparer(2)); - const idVarClef = await clients[0].variables.créerVariable({ + ({ idsComptes, constls, fOublierConstls } = await toutPréparer(2)); + const idVarClef = await constls[0].variables.créerVariable({ catégorie: "chaîneNonTraductible", }); - const idVarLangue = await clients[0].variables.créerVariable({ + const idVarLangue = await constls[0].variables.créerVariable({ catégorie: "chaîneNonTraductible", }); - const idVarTrad = await clients[0].variables.créerVariable({ + const idVarTrad = await constls[0].variables.créerVariable({ catégorie: "chaîneNonTraductible", }); - idNuée = await clients[0].nuées.créerNuée({}); + idNuée = await constls[0].nuées.créerNuée({}); const schéma: schémaSpécificationBd = { licence: "ODbl-1_0", @@ -2318,14 +2312,14 @@ if (isNode || isElectronMain) { ], }; - idBd1 = await clients[0].bds.créerBdDeSchéma({ schéma }); - idBd2 = await clients[1].bds.créerBdDeSchéma({ schéma }); + idBd1 = await constls[0].bds.créerBdDeSchéma({ schéma }); + idBd2 = await constls[1].bds.créerBdDeSchéma({ schéma }); - await clients[0].bds.rejoindreNuées({ + await constls[0].bds.rejoindreNuées({ idsNuées: idNuée, idBd: idBd1, }); - await clients[1].bds.rejoindreNuées({ + await constls[1].bds.rejoindreNuées({ idsNuées: idNuée, idBd: idBd2, }); @@ -2335,7 +2329,7 @@ if (isNode || isElectronMain) { async ( fSuivi: schémaFonctionSuivi, ): Promise => { - return await clients[0].bds.suivreTableauxBd({ + return await constls[0].bds.suivreTableauxBd({ idBd: idBd1, f: fSuivi, }); @@ -2348,7 +2342,7 @@ if (isNode || isElectronMain) { async ( fSuivi: schémaFonctionSuivi, ): Promise => { - return await clients[1].bds.suivreTableauxBd({ + return await constls[1].bds.suivreTableauxBd({ idBd: idBd2, f: fSuivi, }); @@ -2358,7 +2352,7 @@ if (isNode || isElectronMain) { fsOublier.push( ( - await clients[0].réseau.suivreBdsDeNuée({ + await constls[0].réseau.suivreBdsDeNuée({ idNuée, f: (bds) => résBds.mettreÀJour(bds), }) @@ -2366,7 +2360,7 @@ if (isNode || isElectronMain) { ); fsOublier.push( ( - await clients[0].réseau.suivreÉlémentsDeTableauxUniques({ + await constls[0].réseau.suivreÉlémentsDeTableauxUniques({ idNuéeUnique: idNuée, clef: clefTableau, f: (éléments) => résÉléments.mettreÀJour(éléments), @@ -2375,19 +2369,19 @@ if (isNode || isElectronMain) { ); id1 = ( - await clients[0].tableaux.ajouterÉlément({ + await constls[0].tableaux.ajouterÉlément({ idTableau: idTableau1, vals: données1, }) )[0]; id2 = ( - await clients[0].tableaux.ajouterÉlément({ + await constls[0].tableaux.ajouterÉlément({ idTableau: idTableau1, vals: données2, }) )[0]; id3 = ( - await clients[1].tableaux.ajouterÉlément({ + await constls[1].tableaux.ajouterÉlément({ idTableau: idTableau2, vals: données3, }) @@ -2396,7 +2390,7 @@ if (isNode || isElectronMain) { after(async () => { await Promise.all(fsOublier.map((f) => f())); - if (fOublierClients) await fOublierClients(); + if (fOublierConstls) await fOublierConstls(); résBds.toutAnnuler(); résÉléments.toutAnnuler(); }); @@ -2418,21 +2412,21 @@ if (isNode || isElectronMain) { const réf: élémentDeMembre<élémentBdListeDonnées>[] = [ { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], élément: { id: id1, données: données1, }, }, { - idCompte: idsBdCompte[0], + idCompte: idsComptes[0], élément: { id: id2, données: données2, }, }, { - idCompte: idsBdCompte[1], + idCompte: idsComptes[1], élément: { id: id3, données: données3, @@ -2443,5 +2437,123 @@ if (isNode || isElectronMain) { expect(élémentsSansId).to.have.deep.members(réf); }); }); + + describe.only("Messages", function () { + let fOublierConstls: () => Promise; + let idsDispositifs: string[]; + let idsComptes: string[]; + let constls: Constellation[]; + + const rés = new utilsTestAttente.AttendreRésultat(); + const fsOublier: schémaFonctionOublier[] = []; + + before(async () => { + ({ idsComptes, idsDispositifs, constls, fOublierConstls } = + await toutPréparer(3)); + }); + + after(async () => { + await Promise.all(fsOublier.map((f) => f())); + if (fOublierConstls) await fOublierConstls(); + rés.toutAnnuler(); + }); + + const messageReçu = ({ + de, + à, + }: { + de: string; + à: Constellation | Constellation[]; + }): { promesseBienReçu: Promise; messageÀEnvoyer: string } => { + const messageÀEnvoyer = `C'est bien moi : ${de}`; + if (!Array.isArray(à)) à = [à]; + + const promesseReçuParDispositif = (d: Constellation) => + new Promise((résoudre) => { + let fOublierSuivreMesages: schémaFonctionOublier | undefined = + undefined; + d.réseau + .suivreMessagesDirectes({ + type: "texte", + de, + f: (message) => { + fOublierSuivreMesages?.(); + résoudre( + (message.contenu as { message: string }).message === + messageÀEnvoyer, + ); + }, + }) + .then((fOublier) => (fOublierSuivreMesages = fOublier)); + }); + + const promesseBienReçu = Promise.all( + à.map((d) => promesseReçuParDispositif(d)), + ).then((réceptions) => réceptions.every((r) => r)); + return { + promesseBienReçu, + messageÀEnvoyer, + }; + }; + + it("Envoyer message à un autre dispositif", async () => { + const { promesseBienReçu, messageÀEnvoyer } = messageReçu({ + de: idsDispositifs[0], + à: constls[1], + }); + + await constls[0].réseau.envoyerMessageAuDispositif({ + msg: { + type: "texte", + contenu: { message: messageÀEnvoyer }, + }, + idDispositif: idsDispositifs[1], + }); + const bienReçu = await promesseBienReçu; + expect(bienReçu).to.be.true(); + }); + it("Envoyer message à un autre membre", async () => { + const { promesseBienReçu, messageÀEnvoyer } = messageReçu({ + de: idsDispositifs[0], + à: constls[1], + }); + + await constls[0].réseau.envoyerMessageAuMembre({ + msg: { + type: "texte", + contenu: { message: messageÀEnvoyer }, + }, + idCompte: idsComptes[1], + }); + const bienReçu = await promesseBienReçu; + expect(bienReçu).to.be.true(); + }); + + it("Envoyer message à un autre membre qui a plusieurs dispositifs", async () => { + const { promesseBienReçu, messageÀEnvoyer } = messageReçu({ + de: idsDispositifs[0], + à: [constls[1], constls[2]], + }); + + const invitation = await constls[1].générerInvitationRejoindreCompte(); + await constls[2].demanderEtPuisRejoindreCompte(invitation); + await uneFois( + async (fSuivi: schémaFonctionSuivi) => { + return await constls[0].suivreDispositifs({idCompte: idsComptes[1], f: fSuivi}) + }, + ids => !!ids && ids.length > 1 + ); + + await constls[0].réseau.envoyerMessageAuMembre({ + msg: { + type: "texte", + contenu: { message: messageÀEnvoyer }, + }, + idCompte: idsComptes[1], + }); + const bienReçu = await promesseBienReçu; + expect(bienReçu).to.be.true(); + }); + }); }); } From d27e3a441754b87fd795b8db9634e9776f3470e1 Mon Sep 17 00:00:00 2001 From: julienmalard Date: Fri, 28 Feb 2025 22:39:31 +0100 Subject: [PATCH 04/11] =?UTF-8?q?R=C3=A9activer=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "test/r\303\251seau.spec.ts" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/test/r\303\251seau.spec.ts" "b/test/r\303\251seau.spec.ts" index d02625cb94..055b69c41c 100644 --- "a/test/r\303\251seau.spec.ts" +++ "b/test/r\303\251seau.spec.ts" @@ -59,7 +59,7 @@ async function toutPréparer(n: number) { } if (isNode || isElectronMain) { - describe.only("Réseau", function () { + describe("Réseau", function () { describe("Suivre en ligne", function () { let fOublierConstls: () => Promise; let idsComptes: string[]; @@ -2438,7 +2438,7 @@ if (isNode || isElectronMain) { }); }); - describe.only("Messages", function () { + describe("Messages", function () { let fOublierConstls: () => Promise; let idsDispositifs: string[]; let idsComptes: string[]; From 4abcc4ba6e1af9b9471e01e4a6b44021468a9c1f Mon Sep 17 00:00:00 2001 From: julienmalard Date: Fri, 28 Feb 2025 22:41:03 +0100 Subject: [PATCH 05/11] Documentation --- "docu/src/ipa/r\303\251seau.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/docu/src/ipa/r\303\251seau.md" "b/docu/src/ipa/r\303\251seau.md" index caec9edd49..8eea570272 100644 --- "a/docu/src/ipa/r\303\251seau.md" +++ "b/docu/src/ipa/r\303\251seau.md" @@ -713,7 +713,7 @@ interface statutMembre { } type infoDispositif = { - idSFIP: string; + idLibp2p: string; idDispositif: string; idCompte: string; clefPublique: string; From 4e0ce6827d2a9b1055df2b1644846b9f2772546c Mon Sep 17 00:00:00 2001 From: julienmalard Date: Fri, 28 Feb 2025 22:49:48 +0100 Subject: [PATCH 06/11] Formattage --- src/reseau.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/reseau.ts b/src/reseau.ts index a83bf5e873..bea890ba7b 100644 --- a/src/reseau.ts +++ b/src/reseau.ts @@ -382,7 +382,6 @@ export class Réseau extends ComposanteClientDic { idDispositif: string; signal?: AbortSignal; }): Promise> { - const signalCombiné = anySignal([ this.client.signaleurArrêt.signal, ...(signal ? [signal] : []), @@ -403,7 +402,8 @@ export class Réseau extends ComposanteClientDic { }, ); - if (this.connexionsDirectes[idLibp2pDestinataire]) return this.connexionsDirectes[idLibp2pDestinataire]; + if (this.connexionsDirectes[idLibp2pDestinataire]) + return this.connexionsDirectes[idLibp2pDestinataire]; const idPairDestinataire = peerIdFromString(idLibp2pDestinataire); await sfip.libp2p.dial(idPairDestinataire); @@ -523,7 +523,7 @@ export class Réseau extends ComposanteClientDic { `Aucun dispositif présentement en ligne pour membre ${idCompte}`, ); - await Promise.all( + await Promise.all( dispositifsMembre.map(async (d) => { await this.envoyerMessageAuDispositif({ msg, From 7ae01f03a7673d841b7e7f25cd3f24edc0f2aafe Mon Sep 17 00:00:00 2001 From: julienmalard Date: Fri, 28 Feb 2025 22:50:31 +0100 Subject: [PATCH 07/11] Formattage --- "test/r\303\251seau.spec.ts" | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git "a/test/r\303\251seau.spec.ts" "b/test/r\303\251seau.spec.ts" index 055b69c41c..d36d4b6a38 100644 --- "a/test/r\303\251seau.spec.ts" +++ "b/test/r\303\251seau.spec.ts" @@ -2539,9 +2539,12 @@ if (isNode || isElectronMain) { await constls[2].demanderEtPuisRejoindreCompte(invitation); await uneFois( async (fSuivi: schémaFonctionSuivi) => { - return await constls[0].suivreDispositifs({idCompte: idsComptes[1], f: fSuivi}) + return await constls[0].suivreDispositifs({ + idCompte: idsComptes[1], + f: fSuivi, + }); }, - ids => !!ids && ids.length > 1 + (ids) => !!ids && ids.length > 1, ); await constls[0].réseau.envoyerMessageAuMembre({ From b2d6854eb288bf0fc5346771477f87d76dde39fa Mon Sep 17 00:00:00 2001 From: julienmalard Date: Fri, 28 Feb 2025 23:01:25 +0100 Subject: [PATCH 08/11] =?UTF-8?q?Formattage=20et=20r=C3=A9parer=20suivi=20?= =?UTF-8?q?dispositifs=20si=20`idCompte`=20n'est=20pas=20sp=C3=A9cifi?= =?UTF-8?q?=C3=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client.ts | 51 ++++++++++++++++++++++++++++++++++----------- test/client.spec.ts | 4 ++-- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/client.ts b/src/client.ts index 5985f591e8..6c19c61609 100644 --- a/src/client.ts +++ b/src/client.ts @@ -88,7 +88,10 @@ import { initSFIP } from "@/sfip/index.js"; import { Protocoles } from "./protocoles.js"; import type { PrivateKey } from "@libp2p/interface"; import type { ServicesLibp2p } from "@/sfip/index.js"; -import type { ContenuMessageRejoindreCompte, statutDispositif } from "@/reseau.js"; +import type { + ContenuMessageRejoindreCompte, + statutDispositif, +} from "@/reseau.js"; import type { infoUtilisateur, objRôles } from "@/accès/types.js"; import type { SetDatabaseType } from "@orbitdb/set-db"; import type { OrderedKeyValueDatabaseType } from "@orbitdb/ordered-keyvalue-db"; @@ -985,6 +988,12 @@ export class Constellation { f: schémaFonctionSuivi; idCompte?: string; }): Promise { + const info: { + autorisés: string[]; + infos: statutDispositif[]; + idCompte?: string; + } = { autorisés: [], infos: [] }; + const fSuivi = async ({ id, fSuivreBd, @@ -992,6 +1001,7 @@ export class Constellation { id: string; fSuivreBd: schémaFonctionSuivi; }): Promise => { + info.idCompte = id; const { orbite } = await this.attendreSfipEtOrbite(); const { bd, fOublier } = await orbite.ouvrirBdTypée({ id, @@ -1007,14 +1017,14 @@ export class Constellation { return faisRien; } else if (typeAccès === "contrôleur-constellation") { const contrôleurConstellation = accès as ContrôleurConstellation; - const fFinale = async () => { + const fFinaleSuiviCompte = async () => { const mods = contrôleurConstellation.gestRôles._rôles[MODÉRATEUR]; await fSuivreBd(mods); }; - contrôleurConstellation.gestRôles.on("misÀJour", fFinale); - fFinale(); + contrôleurConstellation.gestRôles.on("misÀJour", fFinaleSuiviCompte); + fFinaleSuiviCompte(); return async () => { - contrôleurConstellation.gestRôles.off("misÀJour", fFinale); + contrôleurConstellation.gestRôles.off("misÀJour", fFinaleSuiviCompte); await fOublier(); }; } else { @@ -1023,10 +1033,13 @@ export class Constellation { } }; - const info: {autorisés: string[]; infos: statutDispositif[]; idCompte?: string} = { autorisés: [], infos: []}; const fFinale = async () => { - if (!idCompte) return; - const autorisésEtAcceptés = info.autorisés.filter(id => info.infos.find(i=>i.infoDispositif.idDispositif === id)?.infoDispositif.idCompte === idCompte) + if (!info.idCompte) return; + const autorisésEtAcceptés = info.autorisés.filter( + (idDispositif) => + info.infos.find((i) => i.infoDispositif.idDispositif === idDispositif) + ?.infoDispositif?.idCompte === info.idCompte, + ); return await f(autorisésEtAcceptés); }; @@ -1043,11 +1056,25 @@ export class Constellation { return await this.suivreIdCompte({ f: fSuivreRacine }); } }, - f: ignorerNonDéfinis(async (x: string[]) => { info.autorisés = x; return await fFinale()}), - fSuivre: async ({id, fSuivreBd}: {id: string; fSuivreBd: schémaFonctionSuivi}) => {info.idCompte = id; return await fSuivi({id, fSuivreBd})}, + f: ignorerNonDéfinis(async (x: string[]) => { + info.autorisés = x; + return await fFinale(); + }), + fSuivre: fSuivi, }); - const fOublierInfosDispositifs = await this.réseau.suivreConnexionsDispositifs({f: async x => {info.infos = x; return await fFinale()}}) - return async () => {await Promise.all([fOublierDispositifsAutorisés(), fOublierInfosDispositifs()])}; + const fOublierInfosDispositifs = + await this.réseau.suivreConnexionsDispositifs({ + f: async (x) => { + info.infos = x; + return await fFinale(); + }, + }); + return async () => { + await Promise.all([ + fOublierDispositifsAutorisés(), + fOublierInfosDispositifs(), + ]); + }; } async nommerDispositif({ diff --git a/test/client.spec.ts b/test/client.spec.ts index a697e58af2..67c9f1caa6 100644 --- a/test/client.spec.ts +++ b/test/client.spec.ts @@ -74,7 +74,7 @@ describe("Fermeture sécuritaire", function () { }); if (isNode || isElectronMain) { - describe("Contrôle dispositifs", function () { + describe.only("Contrôle dispositifs", function () { let fOublierClients: () => Promise; let orbites: OrbitDbTest[]; let orbite2: OrbitDbTest, orbite3: OrbitDbTest; @@ -137,7 +137,7 @@ if (isNode || isElectronMain) { describe("Initiale", function () { it("Mon dispositif est présent", async () => { - const val = await mesDispositifs.attendreExiste(); + const val = await mesDispositifs.attendreQue(ids => ids?.length > 0); expect(val).to.have.members([idDispositif1]); }); }); From 210cd35810aada0c757bab39b745375d0066997f Mon Sep 17 00:00:00 2001 From: julienmalard Date: Fri, 28 Feb 2025 23:01:44 +0100 Subject: [PATCH 09/11] =?UTF-8?q?R=C3=A9activer=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/client.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/client.spec.ts b/test/client.spec.ts index 67c9f1caa6..07c36a8f45 100644 --- a/test/client.spec.ts +++ b/test/client.spec.ts @@ -74,7 +74,7 @@ describe("Fermeture sécuritaire", function () { }); if (isNode || isElectronMain) { - describe.only("Contrôle dispositifs", function () { + describe("Contrôle dispositifs", function () { let fOublierClients: () => Promise; let orbites: OrbitDbTest[]; let orbite2: OrbitDbTest, orbite3: OrbitDbTest; From 62e629cecc0517db5e2f74bd855e23cb98cf4700 Mon Sep 17 00:00:00 2001 From: julienmalard Date: Fri, 28 Feb 2025 22:39:02 +0100 Subject: [PATCH 10/11] Communication directe pour messages entre pairs --- "test/r\303\251seau.spec.ts" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/test/r\303\251seau.spec.ts" "b/test/r\303\251seau.spec.ts" index d36d4b6a38..54cedf50d8 100644 --- "a/test/r\303\251seau.spec.ts" +++ "b/test/r\303\251seau.spec.ts" @@ -59,7 +59,7 @@ async function toutPréparer(n: number) { } if (isNode || isElectronMain) { - describe("Réseau", function () { + describe.only("Réseau", function () { describe("Suivre en ligne", function () { let fOublierConstls: () => Promise; let idsComptes: string[]; From 779da2bc927dd753f435953a9d7a8194f85cfecc Mon Sep 17 00:00:00 2001 From: julienmalard Date: Mon, 3 Mar 2025 12:21:06 +0100 Subject: [PATCH 11/11] =?UTF-8?q?R=C3=A9activer=20tous=20les=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "test/r\303\251seau.spec.ts" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/test/r\303\251seau.spec.ts" "b/test/r\303\251seau.spec.ts" index 54cedf50d8..d36d4b6a38 100644 --- "a/test/r\303\251seau.spec.ts" +++ "b/test/r\303\251seau.spec.ts" @@ -59,7 +59,7 @@ async function toutPréparer(n: number) { } if (isNode || isElectronMain) { - describe.only("Réseau", function () { + describe("Réseau", function () { describe("Suivre en ligne", function () { let fOublierConstls: () => Promise; let idsComptes: string[];