merge with master

This commit is contained in:
Sasha 2024-03-12 23:58:57 +01:00
commit de5d71e6ff
No known key found for this signature in database
81 changed files with 584 additions and 1061 deletions

2
.gitignore vendored
View File

@ -13,4 +13,4 @@ test-results
playwright-report
example
allure-results
packages/local-peer-cache-discovery/mock_local_storage
packages/discovery/mock_local_storage

View File

@ -4,12 +4,9 @@
"packages/interfaces": "0.0.22",
"packages/message-hash": "0.1.11",
"packages/enr": "0.0.21",
"packages/peer-exchange": "0.0.20",
"packages/core": "0.0.27",
"packages/dns-discovery": "0.0.21",
"packages/message-encryption": "0.0.25",
"packages/relay": "0.0.10",
"packages/sdk": "0.0.23",
"packages/local-peer-cache-discovery": "1.0.0",
"packages/rln": "0.1.2"
"packages/rln": "0.1.2",
"packages/sdk": "0.0.23"
}

View File

@ -24,9 +24,19 @@ module.exports = [
},
{
name: "DNS discovery",
path: "packages/dns-discovery/bundle/index.js",
path: "packages/discovery/bundle/index.js",
import: "{ PeerDiscoveryDns }",
},
{
name: "Peer Exchange discovery",
path: "packages/discovery/bundle/index.js",
import: "{ wakuPeerExchangeDiscovery }",
},
{
name: "Local Peer Cache Discovery",
path: "packages/discovery/bundle/index.js",
import: "{ wakuLocalPeerCacheDiscovery }",
},
{
name: "Privacy preserving protocols",
path: "packages/relay/bundle/index.js",

323
package-lock.json generated
View File

@ -13,9 +13,7 @@
"packages/enr",
"packages/core",
"packages/relay",
"packages/peer-exchange",
"packages/dns-discovery",
"packages/local-peer-cache-discovery",
"packages/discovery",
"packages/message-encryption",
"packages/rln",
"packages/sdk",
@ -2974,7 +2972,8 @@
},
"node_modules/@libp2p/interfaces": {
"version": "3.3.2",
"license": "Apache-2.0 OR MIT",
"resolved": "https://registry.npmjs.org/@libp2p/interfaces/-/interfaces-3.3.2.tgz",
"integrity": "sha512-p/M7plbrxLzuQchvNwww1Was7ZeGE2NaOFulMaZBYIihU8z3fhaV+a033OqnC/0NTX/yhfdNOG7znhYq3XoR/g==",
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
@ -5241,9 +5240,10 @@
"link": true
},
"node_modules/@waku/create-app": {
"version": "0.1.1-7c24ffa",
"version": "0.1.1-504bcd4",
"resolved": "https://registry.npmjs.org/@waku/create-app/-/create-app-0.1.1-504bcd4.tgz",
"integrity": "sha512-rTGTHLEtEgdmxBTU9ZduEWcZgZG7JsQqIxjHhn3rQNmtggeXjZ5xWo/FAKYcx3Bc1B9igQVUMS/v8NvAGuDd4A==",
"dev": true,
"license": "MIT OR Apache-2.0",
"dependencies": {
"commander": "^9.4.1",
"enquirer": "^2.3.6",
@ -5298,10 +5298,26 @@
"node": ">= 10.0.0"
}
},
"node_modules/@waku/dns-discovery": {
"resolved": "packages/dns-discovery",
"node_modules/@waku/discovery": {
"resolved": "packages/discovery",
"link": true
},
"node_modules/@waku/dns-discovery": {
"version": "0.0.21",
"resolved": "https://registry.npmjs.org/@waku/dns-discovery/-/dns-discovery-0.0.21.tgz",
"integrity": "sha512-l6TVLNiP9HjVrSCWRVP4pKGAADkPzMY2+/tFxnLI1lx3NWmBrkwsEsZHKlfGpdDTT3130nxXkvENcswqWLsc1w==",
"dependencies": {
"@waku/enr": "0.0.21",
"@waku/utils": "0.0.15",
"debug": "^4.3.4",
"dns-query": "^0.11.2",
"hi-base32": "^0.5.1",
"uint8arrays": "^5.0.1"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@waku/enr": {
"resolved": "packages/enr",
"link": true
@ -5311,8 +5327,17 @@
"link": true
},
"node_modules/@waku/local-peer-cache-discovery": {
"resolved": "packages/local-peer-cache-discovery",
"link": true
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@waku/local-peer-cache-discovery/-/local-peer-cache-discovery-1.0.0.tgz",
"integrity": "sha512-He3xudQF8cMbQUU2q9nUlinSW8FSwKX51DLwhPhblVVwhrfdmjvfhjCaMaq2YDoA+y88CIqQG0bLxxl5QADpWQ==",
"dependencies": {
"@libp2p/interface": "^1.1.2",
"@waku/interfaces": "^0.0.22",
"@waku/utils": "^0.0.15"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@waku/message-encryption": {
"resolved": "packages/message-encryption",
@ -5323,8 +5348,24 @@
"link": true
},
"node_modules/@waku/peer-exchange": {
"resolved": "packages/peer-exchange",
"link": true
"version": "0.0.20",
"resolved": "https://registry.npmjs.org/@waku/peer-exchange/-/peer-exchange-0.0.20.tgz",
"integrity": "sha512-Tbdw80VAk4Or6sKUX4LPCkuDo4zYB1/6hOLOMbSo1ck7w8ADNkcByyD5W/wVCmE4wM8Yen2Awb/auIsqunM8LQ==",
"dependencies": {
"@libp2p/interfaces": "^3.3.2",
"@waku/core": "0.0.27",
"@waku/enr": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15",
"debug": "^4.3.4",
"it-all": "^3.0.4",
"it-length-prefixed": "^9.0.4",
"it-pipe": "^3.0.1"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@waku/proto": {
"resolved": "packages/proto",
@ -8167,6 +8208,7 @@
"node": ">= 0.10"
}
},
<<<<<<< HEAD
"node_modules/cosmiconfig": {
"version": "8.0.0",
"dev": true,
@ -8181,6 +8223,8 @@
"node": ">=14"
}
},
=======
>>>>>>> 5296bfbad8d98d2ee40e6570a6ad4546c86b9fcf
"node_modules/cpu-features": {
"version": "0.0.9",
"hasInstallScript": true,
@ -27138,7 +27182,7 @@
"version": "0.1.0",
"devDependencies": {
"@playwright/test": "^1.40.1",
"@waku/create-app": "^0.1.1-7c24ffa",
"@waku/create-app": "^0.1.1-504bcd4",
"dotenv-flow": "^4.1.0",
"serve": "^14.2.1"
}
@ -27193,17 +27237,79 @@
},
"peerDependencies": {
"@multiformats/multiaddr": "^12.0.0",
"@waku/enr": "^0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/message-hash": "^0.1.11",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15",
"libp2p": "^1.1.2"
},
"peerDependenciesMeta": {
"@multiformats/multiaddr": {
"optional": true
},
"@waku/interfaces": {
"optional": true
}
}
},
"packages/discovery": {
"name": "@waku/discovery",
"version": "0.0.1",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@waku/enr": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/proto": "^0.0.6",
"@waku/utils": "0.0.15",
"debug": "^4.3.4",
"dns-query": "^0.11.2",
"hi-base32": "^0.5.1",
"uint8arrays": "^5.0.1"
},
"devDependencies": {
"@libp2p/peer-id": "^4.0.4",
"@libp2p/peer-id-factory": "^4.0.5",
"@multiformats/multiaddr": "^12.0.0",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/chai": "^4.3.11",
"@types/node-localstorage": "^1.3.3",
"@waku/build-utils": "*",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"cspell": "^8.3.2",
"mocha": "^10.3.0",
"node-localstorage": "^3.0.5",
"npm-run-all": "^4.1.5",
"rollup": "^4.12.0",
"sinon": "^17.0.1"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@libp2p/interface": "^1.1.2",
"@waku/core": "0.0.27",
"@waku/enr": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@libp2p/interface": {
"optional": true
},
"@waku/interfaces": {
"optional": true
}
}
},
"packages/dns-discovery": {
"name": "@waku/dns-discovery",
"version": "0.0.21",
"version": "0.0.20",
"extraneous": true,
"license": "MIT OR Apache-2.0",
"dependencies": {
"@waku/enr": "0.0.21",
@ -27231,6 +27337,16 @@
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@waku/enr": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
}
}
},
"packages/enr": {
@ -27267,6 +27383,19 @@
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@multiformats/multiaddr": "^12.0.0",
"@waku/interfaces": "0.0.22",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@multiformats/multiaddr": {
"optional": true
},
"@waku/interfaces": {
"optional": true
}
}
},
"packages/interfaces": {
@ -27286,7 +27415,8 @@
},
"packages/local-peer-cache-discovery": {
"name": "@waku/local-peer-cache-discovery",
"version": "1.0.0",
"version": "0.0.1",
"extraneous": true,
"license": "MIT OR Apache-2.0",
"dependencies": {
"@libp2p/interface": "^1.1.2",
@ -27311,6 +27441,7 @@
},
"engines": {
"node": ">=18"
<<<<<<< HEAD
}
},
"packages/local-peer-cache-discovery/node_modules/@cspell/cspell-bundled-dicts": {
@ -27698,6 +27829,21 @@
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
=======
},
"peerDependencies": {
"@libp2p/interface": "^1.1.2",
"@waku/interfaces": "0.0.22",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@libp2p/interface": {
"optional": true
},
"@waku/interfaces": {
"optional": true
}
>>>>>>> 5296bfbad8d98d2ee40e6570a6ad4546c86b9fcf
}
},
"packages/message-encryption": {
@ -27731,6 +27877,17 @@
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@waku/core": "0.0.27",
"@waku/interfaces": "0.0.22",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
}
}
},
"packages/message-hash": {
@ -27762,11 +27919,21 @@
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@waku/interfaces": "0.0.22",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
}
}
},
"packages/peer-exchange": {
"name": "@waku/peer-exchange",
"version": "0.0.20",
"version": "0.0.19",
"extraneous": true,
"license": "MIT OR Apache-2.0",
"dependencies": {
"@libp2p/interfaces": "^3.3.2",
@ -27793,6 +27960,18 @@
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@waku/core": "0.0.27",
"@waku/enr": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
}
}
},
"packages/proto": {
@ -27841,6 +28020,21 @@
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@chainsafe/libp2p-gossipsub": "^12.0.0",
"@waku/core": "0.0.27",
"@waku/interfaces": "0.0.22",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@chainsafe/libp2p-gossipsub": {
"optional": true
},
"@waku/interfaces": {
"optional": true
}
}
},
"packages/rln": {
@ -29463,6 +29657,7 @@
"@libp2p/ping": "^1.0.12",
"@libp2p/websockets": "^8.0.11",
"@waku/core": "0.0.27",
"@waku/discovery": "0.0.1",
"@waku/dns-discovery": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/local-peer-cache-discovery": "^1.0.0",
@ -29486,7 +29681,22 @@
"node": ">=18"
},
"peerDependencies": {
"@libp2p/bootstrap": "^10"
"@libp2p/bootstrap": "^10",
"@waku/core": "0.0.27",
"@waku/dns-discovery": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/local-peer-cache-discovery": "^1.0.0",
"@waku/peer-exchange": "^0.0.20",
"@waku/relay": "0.0.10",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@libp2p/bootstrap": {
"optional": true
},
"@waku/interfaces": {
"optional": true
}
}
},
"packages/tests": {
@ -29518,9 +29728,8 @@
"@types/mocha": "^10.0.6",
"@types/sinon": "^17.0.3",
"@types/tail": "^2.2.3",
"@waku/dns-discovery": "*",
"@waku/discovery": "*",
"@waku/message-encryption": "*",
"@waku/peer-exchange": "*",
"@waku/sdk": "*",
"allure-commandline": "^2.27.0",
"allure-mocha": "^2.9.2",
@ -29561,6 +29770,14 @@
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@waku/interfaces": "0.0.22"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
}
}
}
},
@ -31377,7 +31594,9 @@
}
},
"@libp2p/interfaces": {
"version": "3.3.2"
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/@libp2p/interfaces/-/interfaces-3.3.2.tgz",
"integrity": "sha512-p/M7plbrxLzuQchvNwww1Was7ZeGE2NaOFulMaZBYIihU8z3fhaV+a033OqnC/0NTX/yhfdNOG7znhYq3XoR/g=="
},
"@libp2p/logger": {
"version": "4.0.6",
@ -32842,7 +33061,7 @@
"version": "file:packages/browser-tests",
"requires": {
"@playwright/test": "^1.40.1",
"@waku/create-app": "^0.1.1-7c24ffa",
"@waku/create-app": "^0.1.1-504bcd4",
"dotenv-flow": "^4.1.0",
"serve": "^14.2.1"
}
@ -32888,7 +33107,9 @@
}
},
"@waku/create-app": {
"version": "0.1.1-7c24ffa",
"version": "0.1.1-504bcd4",
"resolved": "https://registry.npmjs.org/@waku/create-app/-/create-app-0.1.1-504bcd4.tgz",
"integrity": "sha512-rTGTHLEtEgdmxBTU9ZduEWcZgZG7JsQqIxjHhn3rQNmtggeXjZ5xWo/FAKYcx3Bc1B9igQVUMS/v8NvAGuDd4A==",
"dev": true,
"requires": {
"commander": "^9.4.1",
@ -32925,8 +33146,8 @@
}
}
},
"@waku/dns-discovery": {
"version": "file:packages/dns-discovery",
"@waku/discovery": {
"version": "file:packages/discovery",
"requires": {
"@libp2p/peer-id": "^4.0.4",
"@libp2p/peer-id-factory": "^4.0.5",
@ -32935,18 +33156,36 @@
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/chai": "^4.3.11",
"@types/node-localstorage": "^1.3.3",
"@waku/build-utils": "*",
"@waku/enr": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/proto": "^0.0.6",
"@waku/utils": "0.0.15",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"cspell": "^8.3.2",
"debug": "^4.3.4",
"dns-query": "^0.11.2",
"hi-base32": "^0.5.1",
"mocha": "^10.3.0",
"node-localstorage": "^3.0.5",
"npm-run-all": "^4.1.5",
"rollup": "^4.12.0",
"sinon": "^17.0.1",
"uint8arrays": "^5.0.1"
}
},
"@waku/dns-discovery": {
"version": "0.0.21",
"resolved": "https://registry.npmjs.org/@waku/dns-discovery/-/dns-discovery-0.0.21.tgz",
"integrity": "sha512-l6TVLNiP9HjVrSCWRVP4pKGAADkPzMY2+/tFxnLI1lx3NWmBrkwsEsZHKlfGpdDTT3130nxXkvENcswqWLsc1w==",
"requires": {
"@waku/enr": "0.0.21",
"@waku/utils": "0.0.15",
"debug": "^4.3.4",
"dns-query": "^0.11.2",
"hi-base32": "^0.5.1",
"uint8arrays": "^5.0.1"
}
},
@ -32990,16 +33229,13 @@
}
},
"@waku/local-peer-cache-discovery": {
"version": "file:packages/local-peer-cache-discovery",
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@waku/local-peer-cache-discovery/-/local-peer-cache-discovery-1.0.0.tgz",
"integrity": "sha512-He3xudQF8cMbQUU2q9nUlinSW8FSwKX51DLwhPhblVVwhrfdmjvfhjCaMaq2YDoA+y88CIqQG0bLxxl5QADpWQ==",
"requires": {
"@libp2p/interface": "^1.1.2",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/chai": "^4.3.11",
"@types/node-localstorage": "^1.3.3",
"@waku/build-utils": "*",
"@waku/interfaces": "^0.0.22",
<<<<<<< HEAD
"@waku/utils": "^0.0.15",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
@ -33273,6 +33509,9 @@
"version": "1.0.0",
"dev": true
}
=======
"@waku/utils": "^0.0.15"
>>>>>>> 5296bfbad8d98d2ee40e6570a6ad4546c86b9fcf
}
},
"@waku/message-encryption": {
@ -33326,27 +33565,20 @@
}
},
"@waku/peer-exchange": {
"version": "file:packages/peer-exchange",
"version": "0.0.20",
"resolved": "https://registry.npmjs.org/@waku/peer-exchange/-/peer-exchange-0.0.20.tgz",
"integrity": "sha512-Tbdw80VAk4Or6sKUX4LPCkuDo4zYB1/6hOLOMbSo1ck7w8ADNkcByyD5W/wVCmE4wM8Yen2Awb/auIsqunM8LQ==",
"requires": {
"@libp2p/interfaces": "^3.3.2",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@waku/build-utils": "*",
"@waku/core": "0.0.27",
"@waku/enr": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15",
"chai": "^4.3.10",
"cspell": "^8.3.2",
"debug": "^4.3.4",
"it-all": "^3.0.4",
"it-length-prefixed": "^9.0.4",
"it-pipe": "^3.0.1",
"npm-run-all": "^4.1.5",
"rollup": "^4.12.0",
"uint8arraylist": "^2.4.3"
"it-pipe": "^3.0.1"
}
},
"@waku/proto": {
@ -34665,6 +34897,7 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@waku/build-utils": "*",
"@waku/core": "0.0.27",
"@waku/discovery": "0.0.1",
"@waku/dns-discovery": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/local-peer-cache-discovery": "^1.0.0",
@ -34690,11 +34923,10 @@
"@types/sinon": "^17.0.3",
"@types/tail": "^2.2.3",
"@waku/core": "*",
"@waku/dns-discovery": "*",
"@waku/discovery": "*",
"@waku/enr": "*",
"@waku/interfaces": "*",
"@waku/message-encryption": "*",
"@waku/peer-exchange": "*",
"@waku/sdk": "*",
"@waku/utils": "*",
"allure-commandline": "^2.27.0",
@ -36455,6 +36687,7 @@
"vary": "^1"
}
},
<<<<<<< HEAD
"cosmiconfig": {
"version": "8.0.0",
"dev": true,
@ -36465,6 +36698,8 @@
"path-type": "^4.0.0"
}
},
=======
>>>>>>> 5296bfbad8d98d2ee40e6570a6ad4546c86b9fcf
"cpu-features": {
"version": "0.0.9",
"optional": true,

View File

@ -10,9 +10,7 @@
"packages/enr",
"packages/core",
"packages/relay",
"packages/peer-exchange",
"packages/dns-discovery",
"packages/local-peer-cache-discovery",
"packages/discovery",
"packages/message-encryption",
"packages/rln",
"packages/sdk",

View File

@ -12,7 +12,7 @@
},
"devDependencies": {
"@playwright/test": "^1.40.1",
"@waku/create-app": "^0.1.1-7c24ffa",
"@waku/create-app": "^0.1.1-504bcd4",
"dotenv-flow": "^4.1.0",
"serve": "^14.2.1"
}

View File

@ -109,11 +109,19 @@
},
"peerDependencies": {
"@multiformats/multiaddr": "^12.0.0",
"libp2p": "^1.1.2"
"libp2p": "^1.1.2",
"@waku/enr": "^0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/message-hash": "^0.1.11",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@multiformats/multiaddr": {
"optional": true
},
"@waku/interfaces": {
"optional": true
}
},
"files": [

View File

@ -6,7 +6,7 @@ import {
IMessage,
Libp2p,
ProtocolCreateOptions,
SendError
ProtocolError
} from "@waku/interfaces";
import { PushResponse } from "@waku/proto";
import { isMessageSizeUnderCap } from "@waku/utils";
@ -32,7 +32,7 @@ type PreparePushMessageResult =
}
| {
query: null;
error: SendError;
error: ProtocolError;
};
type CoreSendResult =
@ -66,12 +66,12 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
try {
if (!message.payload || message.payload.length === 0) {
log.error("Failed to send waku light push: payload is empty");
return { query: null, error: SendError.EMPTY_PAYLOAD };
return { query: null, error: ProtocolError.EMPTY_PAYLOAD };
}
if (!(await isMessageSizeUnderCap(encoder, message))) {
log.error("Failed to send waku light push: message is bigger than 1MB");
return { query: null, error: SendError.SIZE_TOO_BIG };
return { query: null, error: ProtocolError.SIZE_TOO_BIG };
}
const protoMessage = await encoder.toProtoObj(message);
@ -79,7 +79,7 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
log.error("Failed to encode to protoMessage, aborting push");
return {
query: null,
error: SendError.ENCODE_FAILED
error: ProtocolError.ENCODE_FAILED
};
}
@ -90,7 +90,7 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
return {
query: null,
error: SendError.GENERIC_FAIL
error: ProtocolError.GENERIC_FAIL
};
}
}
@ -126,7 +126,7 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
return {
success: null,
failure: {
error: SendError.REMOTE_PEER_FAULT,
error: ProtocolError.REMOTE_PEER_FAULT,
peerId: peer.id
}
};
@ -146,7 +146,7 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
return {
success: null,
failure: {
error: SendError.GENERIC_FAIL,
error: ProtocolError.GENERIC_FAIL,
peerId: peer.id
}
};
@ -165,7 +165,7 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
return {
success: null,
failure: {
error: SendError.DECODE_FAILED,
error: ProtocolError.DECODE_FAILED,
peerId: peer.id
}
};
@ -176,7 +176,7 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
return {
success: null,
failure: {
error: SendError.REMOTE_PEER_FAULT,
error: ProtocolError.REMOTE_PEER_FAULT,
peerId: peer.id
}
};
@ -187,7 +187,7 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
return {
success: null,
failure: {
error: SendError.REMOTE_PEER_REJECTED,
error: ProtocolError.REMOTE_PEER_REJECTED,
peerId: peer.id
}
};

View File

@ -1,10 +1,12 @@
import type { PeerId } from "@libp2p/interface";
import { IncomingStreamData } from "@libp2p/interface";
import type {
IMetadata,
Libp2pComponents,
PeerIdStr,
ShardInfo
import {
type IMetadata,
type Libp2pComponents,
type PeerIdStr,
ProtocolError,
QueryResult,
type ShardInfo
} from "@waku/interfaces";
import { proto_metadata } from "@waku/proto";
import { encodeRelayShard, Logger, shardInfoToPubsubTopics } from "@waku/utils";
@ -21,7 +23,7 @@ export const MetadataCodec = "/vac/waku/metadata/1.0.0";
class Metadata extends BaseProtocol implements IMetadata {
private libp2pComponents: Libp2pComponents;
handshakesConfirmed: Set<PeerIdStr> = new Set();
handshakesConfirmed: Map<PeerIdStr, ShardInfo> = new Map();
constructor(
public shardInfo: ShardInfo,
@ -57,13 +59,13 @@ class Metadata extends BaseProtocol implements IMetadata {
async (source) => await all(source)
);
const remoteShardInfoResponse =
this.decodeMetadataResponse(encodedResponse);
const { error, shardInfo } = this.decodeMetadataResponse(encodedResponse);
await this.savePeerShardInfo(
connection.remotePeer,
remoteShardInfoResponse
);
if (error) {
return;
}
await this.savePeerShardInfo(connection.remotePeer, shardInfo);
} catch (error) {
log.error("Error handling metadata request", error);
}
@ -72,12 +74,15 @@ class Metadata extends BaseProtocol implements IMetadata {
/**
* Make a metadata query to a peer
*/
async query(peerId: PeerId): Promise<ShardInfo> {
async query(peerId: PeerId): Promise<QueryResult> {
const request = proto_metadata.WakuMetadataRequest.encode(this.shardInfo);
const peer = await this.peerStore.get(peerId);
if (!peer) {
throw new Error(`Peer ${peerId.toString()} not found`);
return {
shardInfo: null,
error: ProtocolError.NO_PEER_AVAILABLE
};
}
const stream = await this.getStream(peer);
@ -90,22 +95,38 @@ class Metadata extends BaseProtocol implements IMetadata {
async (source) => await all(source)
);
const decodedResponse = this.decodeMetadataResponse(encodedResponse);
const { error, shardInfo } = this.decodeMetadataResponse(encodedResponse);
await this.savePeerShardInfo(peerId, decodedResponse);
if (error) {
return {
shardInfo: null,
error
};
}
return decodedResponse;
await this.savePeerShardInfo(peerId, shardInfo);
return {
shardInfo,
error: null
};
}
public async confirmOrAttemptHandshake(peerId: PeerId): Promise<void> {
if (this.handshakesConfirmed.has(peerId.toString())) return;
public async confirmOrAttemptHandshake(peerId: PeerId): Promise<QueryResult> {
const shardInfo = this.handshakesConfirmed.get(peerId.toString());
if (shardInfo) {
return {
shardInfo,
error: null
};
}
await this.query(peerId);
return;
return await this.query(peerId);
}
private decodeMetadataResponse(encodedResponse: Uint8ArrayList[]): ShardInfo {
private decodeMetadataResponse(
encodedResponse: Uint8ArrayList[]
): QueryResult {
const bytes = new Uint8ArrayList();
encodedResponse.forEach((chunk) => {
@ -115,9 +136,18 @@ class Metadata extends BaseProtocol implements IMetadata {
bytes
) as ShardInfo;
if (!response) log.error("Error decoding metadata response");
if (!response) {
log.error("Error decoding metadata response");
return {
shardInfo: null,
error: ProtocolError.DECODE_FAILED
};
}
return response;
return {
shardInfo: response,
error: null
};
}
private async savePeerShardInfo(
@ -131,7 +161,7 @@ class Metadata extends BaseProtocol implements IMetadata {
}
});
this.handshakesConfirmed.add(peerId.toString());
this.handshakesConfirmed.set(peerId.toString(), shardInfo);
}
}

View File

@ -1,7 +1,7 @@
{
"name": "@waku/dns-discovery",
"version": "0.0.21",
"description": "DNS Peer Discovery (EIP-1459)",
"name": "@waku/discovery",
"version": "0.0.1",
"description": "Contains various discovery mechanisms: DNS Discovery (EIP-1459, Peer Exchange, Local Peer Cache Discovery.",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
"exports": {
@ -12,7 +12,7 @@
},
"type": "module",
"author": "Waku Team",
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/dns-discovery#readme",
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/discovery#readme",
"repository": {
"type": "git",
"url": "https://github.com/waku-org/js-waku.git"
@ -51,6 +51,8 @@
"node": ">=18"
},
"dependencies": {
"@waku/interfaces": "0.0.22",
"@waku/proto": "^0.0.6",
"@waku/enr": "0.0.21",
"@waku/utils": "0.0.15",
"debug": "^4.3.4",
@ -66,13 +68,32 @@
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/chai": "^4.3.11",
"@types/node-localstorage": "^1.3.3",
"@waku/build-utils": "*",
"@waku/interfaces": "0.0.22",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"cspell": "^8.3.2",
"mocha": "^10.3.0",
"node-localstorage": "^3.0.5",
"npm-run-all": "^4.1.5",
"rollup": "^4.12.0"
"rollup": "^4.12.0",
"sinon": "^17.0.1"
},
"peerDependencies": {
"@waku/core": "0.0.27",
"@waku/enr": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15",
"@libp2p/interface": "^1.1.2"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
},
"@libp2p/interface": {
"optional": true
}
},
"files": [
"dist",

View File

@ -0,0 +1,21 @@
// DNS Discovery
export { PeerDiscoveryDns, wakuDnsDiscovery } from "./dns/dns_discovery.js";
export { enrTree } from "./dns/constants.js";
export { DnsNodeDiscovery } from "./dns/dns.js";
// Peer Exchange Discovery
export {
wakuPeerExchange,
PeerExchangeCodec,
WakuPeerExchange
} from "./peer-exchange/waku_peer_exchange.js";
export {
wakuPeerExchangeDiscovery,
PeerExchangeDiscovery
} from "./peer-exchange/waku_peer_exchange_discovery.js";
// Local Peer Cache Discovery
export {
LocalPeerCacheDiscovery,
wakuLocalPeerCacheDiscovery
} from "./local-peer-cache/index.js";

View File

@ -11,14 +11,21 @@ import { LocalStoragePeerInfo } from "@waku/interfaces";
import chai, { expect } from "chai";
import chaiAsPromised from "chai-as-promised";
import { MemoryDatastore } from "datastore-core/memory";
import { LocalStorage } from "node-localstorage";
import sinon from "sinon";
import { LocalPeerCacheDiscovery } from "./index.js";
chai.use(chaiAsPromised);
global.localStorage = new LocalStorage("./mock_local_storage");
// dynamically importing the local storage polyfill for node
if (typeof window === "undefined") {
try {
const { LocalStorage } = await import("node-localstorage");
global.localStorage = new LocalStorage("./scratch");
} catch (error) {
console.error("Failed to load localStorage polyfill:", error);
}
}
const mockPeers = [
{

View File

@ -6,5 +6,5 @@
"tsBuildInfoFile": "dist/.tsbuildinfo"
},
"include": ["src"],
"exclude": ["src/**/*.spec.ts", "src/test_utils"]
"exclude": ["src/**/*.spec.ts"]
}

View File

@ -1,305 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
The file is maintained by [Release Please](https://github.com/googleapis/release-please) based on [Conventional Commits](https://www.conventionalcommits.org) specification,
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.6 to 0.0.7
* devDependencies
* @waku/interfaces bumped from 0.0.8 to 0.0.9
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.7 to 0.0.8
* @waku/utils bumped from 0.0.2 to 0.0.3
* devDependencies
* @waku/interfaces bumped from 0.0.9 to 0.0.10
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.8 to 0.0.9
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.10 to 0.0.11
* @waku/utils bumped from 0.0.4 to 0.0.5
* devDependencies
* @waku/interfaces bumped from 0.0.11 to 0.0.12
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.12 to 0.0.13
* @waku/utils bumped from 0.0.6 to 0.0.7
* devDependencies
* @waku/interfaces bumped from 0.0.13 to 0.0.14
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.19 to 0.0.20
* @waku/utils bumped from 0.0.13 to 0.0.14
* devDependencies
* @waku/interfaces bumped from 0.0.20 to 0.0.21
## [0.0.21](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.20...dns-discovery-v0.0.21) (2024-03-04)
### ⚠ BREAKING CHANGES
* protocols filter peers as per configured shard ([#1756](https://github.com/waku-org/js-waku/issues/1756))
### Features
* Protocols filter peers as per configured shard ([#1756](https://github.com/waku-org/js-waku/issues/1756)) ([477c2a5](https://github.com/waku-org/js-waku/commit/477c2a5918f2f75cd2c14bc6ed75e1687c5a09b4))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.20 to 0.0.21
* @waku/utils bumped from 0.0.14 to 0.0.15
* devDependencies
* @waku/interfaces bumped from 0.0.21 to 0.0.22
## [0.0.19](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.18...dns-discovery-v0.0.19) (2023-11-01)
### Features
* Logger with log levels ([#1672](https://github.com/waku-org/js-waku/issues/1672)) ([0f7d63e](https://github.com/waku-org/js-waku/commit/0f7d63ef93716223dc8fea7e8cb09e12e267b386))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.18 to 0.0.19
* @waku/utils bumped from 0.0.12 to 0.0.13
* devDependencies
* @waku/interfaces bumped from 0.0.19 to 0.0.20
## [0.0.18](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.17...dns-discovery-v0.0.18) (2023-10-16)
### Features
* Add Firefox and Webkit to karma ([#1598](https://github.com/waku-org/js-waku/issues/1598)) ([d9e4bcb](https://github.com/waku-org/js-waku/commit/d9e4bcbe3f7bcc092f20621bd362d76426701dab))
* **static-sharding:** Filter peer connections per shards ([#1626](https://github.com/waku-org/js-waku/issues/1626)) ([124a29e](https://github.com/waku-org/js-waku/commit/124a29ebba59c05fbbf199d969e6ba3f9e57d45b))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.17 to 0.0.18
* @waku/utils bumped from 0.0.11 to 0.0.12
* devDependencies
* @waku/interfaces bumped from 0.0.18 to 0.0.19
## [0.0.17](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.16...dns-discovery-v0.0.17) (2023-09-11)
### ⚠ BREAKING CHANGES
* upgrade to libp2p@0.45 ([#1400](https://github.com/waku-org/js-waku/issues/1400))
* @waku/relay ([#1316](https://github.com/waku-org/js-waku/issues/1316))
### Features
* @waku/relay ([#1316](https://github.com/waku-org/js-waku/issues/1316)) ([50c2c25](https://github.com/waku-org/js-waku/commit/50c2c2540f3c5ff78d93f3fea646da0eee246e17))
* Allow passing of multiple ENR URLs to DNS Discovery & dial multiple peers in parallel ([#1379](https://github.com/waku-org/js-waku/issues/1379)) ([f32d7d9](https://github.com/waku-org/js-waku/commit/f32d7d9fe0b930b4fa9c46b8644e6d21be45d5c1))
* **dns-discovery:** Set default for `NodeRequirements` ([#1466](https://github.com/waku-org/js-waku/issues/1466)) ([aab9c08](https://github.com/waku-org/js-waku/commit/aab9c08caefb9f72460261ec0c38df88ae0f02ce))
* Upgrade to libp2p@0.45 ([#1400](https://github.com/waku-org/js-waku/issues/1400)) ([420e6c6](https://github.com/waku-org/js-waku/commit/420e6c698dd8f44d40d34e47d876da5d2e1ce85e))
### Bug Fixes
* **dns-discovery:** Use DOH list from dns-query ([1dd3210](https://github.com/waku-org/js-waku/commit/1dd32101baf2750527369f7f25981882aa1f9527))
* Improve connection manager error handling + edge cases ([#1450](https://github.com/waku-org/js-waku/issues/1450)) ([785df52](https://github.com/waku-org/js-waku/commit/785df528fe6e5010a61391994e222028dbc4e4c5))
* Remove typesVersions ([#1359](https://github.com/waku-org/js-waku/issues/1359)) ([0ad1954](https://github.com/waku-org/js-waku/commit/0ad19540d527309e0174afa7e9fff2924570d361))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.16 to 0.0.17
* @waku/utils bumped from 0.0.10 to 0.0.11
* devDependencies
* @waku/interfaces bumped from 0.0.17 to 0.0.18
## [0.0.16](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.15...dns-discovery-v0.0.16) (2023-08-02)
### Bug Fixes
* Improve connection manager error handling + edge cases ([#1450](https://github.com/waku-org/js-waku/issues/1450)) ([785df52](https://github.com/waku-org/js-waku/commit/785df528fe6e5010a61391994e222028dbc4e4c5))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.15 to 0.0.16
* @waku/utils bumped from 0.0.9 to 0.0.10
* devDependencies
* @waku/interfaces bumped from 0.0.16 to 0.0.17
## [0.0.15](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.14...dns-discovery-v0.0.15) (2023-07-26)
### ⚠ BREAKING CHANGES
* upgrade to libp2p@0.45 ([#1400](https://github.com/waku-org/js-waku/issues/1400))
### Features
* Upgrade to libp2p@0.45 ([#1400](https://github.com/waku-org/js-waku/issues/1400)) ([420e6c6](https://github.com/waku-org/js-waku/commit/420e6c698dd8f44d40d34e47d876da5d2e1ce85e))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.14 to 0.0.15
* @waku/utils bumped from 0.0.8 to 0.0.9
* devDependencies
* @waku/interfaces bumped from 0.0.15 to 0.0.16
## [0.0.14](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.13...dns-discovery-v0.0.14) (2023-06-08)
### Features
* Allow passing of multiple ENR URLs to DNS Discovery & dial multiple peers in parallel ([#1379](https://github.com/waku-org/js-waku/issues/1379)) ([f32d7d9](https://github.com/waku-org/js-waku/commit/f32d7d9fe0b930b4fa9c46b8644e6d21be45d5c1))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.13 to 0.0.14
* @waku/utils bumped from 0.0.7 to 0.0.8
* devDependencies
* @waku/interfaces bumped from 0.0.14 to 0.0.15
## [0.0.12](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.11...dns-discovery-v0.0.12) (2023-05-18)
### ⚠ BREAKING CHANGES
* @waku/relay ([#1316](https://github.com/waku-org/js-waku/issues/1316))
### Features
* @waku/relay ([#1316](https://github.com/waku-org/js-waku/issues/1316)) ([50c2c25](https://github.com/waku-org/js-waku/commit/50c2c2540f3c5ff78d93f3fea646da0eee246e17))
### Bug Fixes
* Remove typesVersions ([#1359](https://github.com/waku-org/js-waku/issues/1359)) ([0ad1954](https://github.com/waku-org/js-waku/commit/0ad19540d527309e0174afa7e9fff2924570d361))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from * to 0.0.12
* @waku/utils bumped from * to 0.0.6
* devDependencies
* @waku/interfaces bumped from * to 0.0.13
## [0.0.10](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.9...dns-discovery-v0.0.10) (2023-04-03)
### Bug Fixes
* **dns-discovery:** Use DOH list from dns-query ([1dd3210](https://github.com/waku-org/js-waku/commit/1dd32101baf2750527369f7f25981882aa1f9527))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.9 to 0.0.10
* @waku/utils bumped from 0.0.3 to 0.0.4
* devDependencies
* @waku/interfaces bumped from 0.0.10 to 0.0.11
## [0.0.6](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.5...dns-discovery-v0.0.6) (2023-03-16)
### ⚠ BREAKING CHANGES
* add exports map to @waku/utils ([#1201](https://github.com/waku-org/js-waku/issues/1201))
* directly convert from ENR to `PeerInfo`, remove unneeded utility
* extract decoder code
* bump typescript
* bump libp2p dependencies
### Features
* Add mocha to dns-discovery ([#1154](https://github.com/waku-org/js-waku/issues/1154)) ([f945eb9](https://github.com/waku-org/js-waku/commit/f945eb90c49bb54322c4cb58c20cfdeee72ff4f2))
* DNS discovery as default bootstrap discovery ([#1114](https://github.com/waku-org/js-waku/issues/1114)) ([11819fc](https://github.com/waku-org/js-waku/commit/11819fc7b14e18385d421facaf2af0832cad1da8))
### Bug Fixes
* **dns-discovery/peer-exchange:** Check if peer is already tagged ([952aadd](https://github.com/waku-org/js-waku/commit/952aadd7bbbe1a7265c5126c1678f552bef0648d))
* Prettier and cspell ignore CHANGELOG ([#1235](https://github.com/waku-org/js-waku/issues/1235)) ([4d7b3e3](https://github.com/waku-org/js-waku/commit/4d7b3e39e6761afaf5d05a13cc4b3c23e15f9bd5))
### Miscellaneous Chores
* Add exports map to @waku/utils ([#1201](https://github.com/waku-org/js-waku/issues/1201)) ([a30b2bd](https://github.com/waku-org/js-waku/commit/a30b2bd747dedeef69b46cfafb88898ba35d8f67))
* Bump libp2p dependencies ([803ae7b](https://github.com/waku-org/js-waku/commit/803ae7bd8ed3de665026446c23cde90e7eba9d36))
* Bump typescript ([12d86e6](https://github.com/waku-org/js-waku/commit/12d86e6abcc68e27c39ca86b4f0dc2b68cdd6000))
* Directly convert from ENR to `PeerInfo`, remove unneeded utility ([6dbcde0](https://github.com/waku-org/js-waku/commit/6dbcde041ab8fa8c2df75cc25319a0eccf6b0454))
* Extract decoder code ([130c49b](https://github.com/waku-org/js-waku/commit/130c49b636807063364f309da0da2a24a68f2178))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from * to 0.0.6
* @waku/utils bumped from * to 0.0.2
* devDependencies
* @waku/interfaces bumped from * to 0.0.8
## [Unreleased]
## [0.0.5] - 2023-01-25
### Changed
- Replaced OpenDNS with AhaDNS in the default DoH DNS list.
### Fixed
- Moved `chai` to `devDependencies`.
## [0.0.4] - 2023-01-18
### Changed
- Improved test coverage, various fixes.
[unreleased]: https://github.com/waku-org/js-waku/compare/@waku/dns-discovery@0.0.5...HEAD
[0.0.5]: https://github.com/status-im/js-waku/compare/@waku/dns-discovery@0.0.4...@waku/dns-discovery@0.0.5
[0.0.4]: https://github.com/status-im/js-waku/compare/f7f28f03b01fa5bc89eaeb083b68981169b45c39...@waku/dns-discovery@0.0.4

View File

@ -1,10 +0,0 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "dist/",
"rootDir": "src",
"tsBuildInfoFile": "dist/.tsbuildinfo"
},
"include": ["src"],
"exclude": ["src/**/*.spec.ts", "src/test_utils"]
}

View File

@ -1,4 +0,0 @@
{
"extends": ["../../typedoc.base.json"],
"entryPoints": ["src/index.ts"]
}

View File

@ -78,6 +78,19 @@
"rollup": "^4.12.0",
"uint8arrays": "^5.0.1"
},
"peerDependencies": {
"@waku/utils": "0.0.15",
"@waku/interfaces": "0.0.22",
"@multiformats/multiaddr": "^12.0.0"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
},
"@multiformats/multiaddr": {
"optional": true
}
},
"files": [
"dist",
"bundle",

View File

@ -1,11 +1,25 @@
import type { PeerId } from "@libp2p/interface";
import type { ShardInfo } from "./enr.js";
import type { IBaseProtocolCore, ShardingParams } from "./protocols.js";
import type {
IBaseProtocolCore,
ProtocolError,
ShardingParams
} from "./protocols.js";
export type QueryResult =
| {
shardInfo: ShardInfo;
error: null;
}
| {
shardInfo: null;
error: ProtocolError;
};
// IMetadata always has shardInfo defined while it is optionally undefined in IBaseProtocol
export interface IMetadata extends Omit<IBaseProtocolCore, "shardInfo"> {
shardInfo: ShardingParams;
confirmOrAttemptHandshake(peerId: PeerId): Promise<void>;
query(peerId: PeerId): Promise<ShardInfo | undefined>;
confirmOrAttemptHandshake(peerId: PeerId): Promise<QueryResult>;
query(peerId: PeerId): Promise<QueryResult>;
}

View File

@ -101,7 +101,7 @@ export type Callback<T extends IDecodedMessage> = (
msg: T
) => void | Promise<void>;
export enum SendError {
export enum ProtocolError {
/** Could not determine the origin of the fault. Best to check connectivity and try again */
GENERIC_FAIL = "Generic error",
/**
@ -150,7 +150,7 @@ export enum SendError {
}
export interface Failure {
error: SendError;
error: ProtocolError;
peerId?: PeerId;
}

View File

@ -1,6 +0,0 @@
module.exports = {
parserOptions: {
tsconfigRootDir: __dirname,
project: "./tsconfig.dev.json"
}
};

View File

@ -1,6 +0,0 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}

View File

@ -1,26 +0,0 @@
const config = {
extension: ['ts'],
spec: 'src/**/*.spec.ts',
require: ['ts-node/register', 'isomorphic-fetch'],
loader: 'ts-node/esm',
'node-option': [
'experimental-specifier-resolution=node',
'loader=ts-node/esm'
],
exit: true
};
if (process.env.CI) {
console.log("Running tests in parallel");
config.parallel = true;
config.jobs = 6;
console.log("Activating allure reporting");
config.reporter = 'mocha-multi-reporters';
config.reporterOptions = {
configFile: '.mocha.reporters.json'
};
} else {
console.log("Running tests serially. To enable parallel execution update mocha config");
}
module.exports = config;

View File

@ -1,20 +0,0 @@
# Changelog
## 1.0.0 (2024-03-04)
### ⚠ BREAKING CHANGES
* rename local-discovery to local-peer-cache-discovery ([#1867](https://github.com/waku-org/js-waku/issues/1867))
### Miscellaneous Chores
* Rename local-discovery to local-peer-cache-discovery ([#1867](https://github.com/waku-org/js-waku/issues/1867)) ([f3cb10d](https://github.com/waku-org/js-waku/commit/f3cb10d484bac134377b8cfd77e077ffc33bd319))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/interfaces bumped from ^0.0.21 to ^0.0.22
* @waku/utils bumped from ^0.0.14 to ^0.0.15

View File

@ -1,3 +0,0 @@
const config = require("../../karma.conf.cjs");
module.exports = config;

View File

@ -1,83 +0,0 @@
{
"name": "@waku/local-peer-cache-discovery",
"version": "1.0.0",
"description": "Local Peer Cache keeps records of healthy peers in the browser's local storage for quicker bootstrapping.",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"type": "module",
"author": "Waku Team",
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/local-peer-cache-discovery#readme",
"repository": {
"type": "git",
"url": "https://github.com/waku-org/js-waku.git"
},
"bugs": {
"url": "https://github.com/waku-org/js-waku/issues"
},
"license": "MIT OR Apache-2.0",
"keywords": [
"waku",
"decentralized",
"secure",
"communication",
"web3",
"ethereum",
"dapps",
"privacy"
],
"scripts": {
"build": "run-s build:**",
"build:esm": "tsc",
"build:bundle": "rollup --config rollup.config.js",
"fix": "run-s fix:*",
"fix:lint": "eslint src *.js --fix",
"check": "run-s check:*",
"check:lint": "eslint src --ext .ts",
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
"check:tsc": "tsc -p tsconfig.dev.json",
"prepublish": "npm run build",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build",
"test": "NODE_ENV=test run-s test:*",
"test:node": "NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha"
},
"engines": {
"node": ">=18"
},
"dependencies": {
"@libp2p/interface": "^1.1.2",
"@waku/interfaces": "^0.0.22",
"@waku/utils": "^0.0.15"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/chai": "^4.3.11",
"@types/node-localstorage": "^1.3.3",
"@waku/build-utils": "*",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"cspell": "^7.3.2",
"mocha": "^10.2.0",
"node-localstorage": "^3.0.5",
"npm-run-all": "^4.1.5",
"rollup": "^4.12.0",
"sinon": "^17.0.1"
},
"files": [
"dist",
"bundle",
"src/**/*.ts",
"!**/*.spec.*",
"!**/*.json",
"CHANGELOG.md",
"LICENSE",
"README.md"
]
}

View File

@ -1,24 +0,0 @@
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import { extractExports } from "@waku/build-utils";
import * as packageJson from "./package.json" assert { type: "json" };
const input = extractExports(packageJson);
export default {
input,
output: {
dir: "bundle",
format: "esm"
},
plugins: [
commonjs(),
json(),
nodeResolve({
browser: true,
preferBuiltins: false
})
]
};

View File

@ -1,3 +0,0 @@
{
"extends": "../../tsconfig.dev"
}

View File

@ -1,4 +0,0 @@
{
"extends": ["../../typedoc.base.json"],
"entryPoints": ["src/index.ts"]
}

View File

@ -99,6 +99,17 @@
"process": "^0.11.10",
"rollup": "^4.12.0"
},
"peerDependencies": {
"@waku/core": "0.0.27",
"@waku/interfaces": "0.0.22",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
}
},
"files": [
"dist",
"bundle",

View File

@ -72,6 +72,15 @@
"process": "^0.11.10",
"rollup": "^4.12.0"
},
"peerDependencies": {
"@waku/interfaces": "0.0.22",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
}
},
"files": [
"dist",
"bundle",

View File

@ -1,6 +0,0 @@
module.exports = {
parserOptions: {
tsconfigRootDir: __dirname,
project: "./tsconfig.dev.json"
}
};

View File

@ -1,285 +0,0 @@
# Changelog
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.12 to 0.0.13
* @waku/enr bumped from 0.0.7 to 0.0.8
* @waku/proto bumped from 0.0.3 to 0.0.4
* @waku/utils bumped from * to 0.0.3
* devDependencies
* @waku/interfaces bumped from 0.0.9 to 0.0.10
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.8 to 0.0.9
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.14 to 0.0.15
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.15 to 0.0.16
* @waku/enr bumped from 0.0.9 to 0.0.10
* @waku/utils bumped from 0.0.3 to 0.0.4
* devDependencies
* @waku/interfaces bumped from 0.0.10 to 0.0.11
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.16 to 0.0.17
* @waku/enr bumped from 0.0.10 to 0.0.11
* @waku/utils bumped from 0.0.4 to 0.0.5
* devDependencies
* @waku/interfaces bumped from 0.0.11 to 0.0.12
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.18 to 0.0.19
* @waku/enr bumped from 0.0.12 to 0.0.13
* @waku/proto bumped from * to 0.0.5
* @waku/utils bumped from 0.0.6 to 0.0.7
* devDependencies
* @waku/interfaces bumped from 0.0.13 to 0.0.14
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.19 to 0.0.20
* @waku/enr bumped from 0.0.13 to 0.0.14
* @waku/utils bumped from 0.0.7 to 0.0.8
* devDependencies
* @waku/interfaces bumped from 0.0.14 to 0.0.15
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.25 to 0.0.26
* @waku/enr bumped from 0.0.19 to 0.0.20
* @waku/interfaces bumped from 0.0.20 to 0.0.21
* @waku/proto bumped from 0.0.5 to 0.0.6
* @waku/utils bumped from 0.0.13 to 0.0.14
## [0.0.20](https://github.com/waku-org/js-waku/compare/peer-exchange-v0.0.19...peer-exchange-v0.0.20) (2024-03-04)
### ⚠ BREAKING CHANGES
* protocols filter peers as per configured shard ([#1756](https://github.com/waku-org/js-waku/issues/1756))
### Features
* Decouple sharding params out of core ([e138b4f](https://github.com/waku-org/js-waku/commit/e138b4f5c49a35a37830e31e8be87d824f53249f))
* Protocols filter peers as per configured shard ([#1756](https://github.com/waku-org/js-waku/issues/1756)) ([477c2a5](https://github.com/waku-org/js-waku/commit/477c2a5918f2f75cd2c14bc6ed75e1687c5a09b4))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.26 to 0.0.27
* @waku/enr bumped from 0.0.20 to 0.0.21
* @waku/interfaces bumped from 0.0.21 to 0.0.22
* @waku/utils bumped from 0.0.14 to 0.0.15
## [0.0.18](https://github.com/waku-org/js-waku/compare/peer-exchange-v0.0.17...peer-exchange-v0.0.18) (2023-11-01)
### Features
* Logger with log levels ([#1672](https://github.com/waku-org/js-waku/issues/1672)) ([0f7d63e](https://github.com/waku-org/js-waku/commit/0f7d63ef93716223dc8fea7e8cb09e12e267b386))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.24 to 0.0.25
* @waku/enr bumped from 0.0.18 to 0.0.19
* @waku/interfaces bumped from 0.0.19 to 0.0.20
* @waku/utils bumped from 0.0.12 to 0.0.13
## [0.0.17](https://github.com/waku-org/js-waku/compare/peer-exchange-v0.0.16...peer-exchange-v0.0.17) (2023-10-16)
### Features
* **static-sharding:** Filter peer connections per shards ([#1626](https://github.com/waku-org/js-waku/issues/1626)) ([124a29e](https://github.com/waku-org/js-waku/commit/124a29ebba59c05fbbf199d969e6ba3f9e57d45b))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.23 to 0.0.24
* @waku/enr bumped from 0.0.17 to 0.0.18
* @waku/interfaces bumped from 0.0.18 to 0.0.19
* @waku/utils bumped from 0.0.11 to 0.0.12
## [0.0.16](https://github.com/waku-org/js-waku/compare/peer-exchange-v0.0.15...peer-exchange-v0.0.16) (2023-09-11)
### ⚠ BREAKING CHANGES
* set peer-exchange with default bootstrap ([#1469](https://github.com/waku-org/js-waku/issues/1469))
### Features
* Pre-emptive stream creation for protocols ([#1516](https://github.com/waku-org/js-waku/issues/1516)) ([b4f8216](https://github.com/waku-org/js-waku/commit/b4f821676120aa06f4772eed62fb105d5afae7c6))
* Set peer-exchange with default bootstrap ([#1469](https://github.com/waku-org/js-waku/issues/1469)) ([81a52a8](https://github.com/waku-org/js-waku/commit/81a52a8097ba948783c9d798ba362af0f27e1c10))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.22 to 0.0.23
* @waku/enr bumped from 0.0.16 to 0.0.17
* @waku/interfaces bumped from 0.0.17 to 0.0.18
* @waku/utils bumped from 0.0.10 to 0.0.11
## [0.0.15](https://github.com/waku-org/js-waku/compare/peer-exchange-v0.0.14...peer-exchange-v0.0.15) (2023-08-02)
### Bug Fixes
* Improve connection manager error handling + edge cases ([#1450](https://github.com/waku-org/js-waku/issues/1450)) ([785df52](https://github.com/waku-org/js-waku/commit/785df528fe6e5010a61391994e222028dbc4e4c5))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.21 to 0.0.22
* @waku/enr bumped from 0.0.15 to 0.0.16
* @waku/utils bumped from 0.0.9 to 0.0.10
* @waku/interfaces bumped from 0.0.16 to 0.0.17
## [0.0.14](https://github.com/waku-org/js-waku/compare/peer-exchange-v0.0.13...peer-exchange-v0.0.14) (2023-07-26)
### ⚠ BREAKING CHANGES
* upgrade to libp2p@0.45 ([#1400](https://github.com/waku-org/js-waku/issues/1400))
### Features
* Enable event emission for peer discovery/connection in ConnectionManager ([#1438](https://github.com/waku-org/js-waku/issues/1438)) ([6ce898d](https://github.com/waku-org/js-waku/commit/6ce898d77132f30b5d8f33b48c7f6276992a486e))
* Upgrade to libp2p@0.45 ([#1400](https://github.com/waku-org/js-waku/issues/1400)) ([420e6c6](https://github.com/waku-org/js-waku/commit/420e6c698dd8f44d40d34e47d876da5d2e1ce85e))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.20 to 0.0.21
* @waku/enr bumped from 0.0.14 to 0.0.15
* @waku/utils bumped from 0.0.8 to 0.0.9
* @waku/interfaces bumped from 0.0.15 to 0.0.16
## [0.0.11](https://github.com/waku-org/js-waku/compare/peer-exchange-v0.0.10...peer-exchange-v0.0.11) (2023-05-18)
### ⚠ BREAKING CHANGES
* @waku/relay ([#1316](https://github.com/waku-org/js-waku/issues/1316))
### Features
* @waku/relay ([#1316](https://github.com/waku-org/js-waku/issues/1316)) ([50c2c25](https://github.com/waku-org/js-waku/commit/50c2c2540f3c5ff78d93f3fea646da0eee246e17))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from * to 0.0.18
* @waku/enr bumped from * to 0.0.12
* @waku/utils bumped from * to 0.0.6
* devDependencies
* @waku/interfaces bumped from * to 0.0.13
## [0.0.5](https://github.com/waku-org/js-waku/compare/peer-exchange-v0.0.4...peer-exchange-v0.0.5) (2023-03-23)
### Features
* Compliance test for peer-exchange discovery ([#1186](https://github.com/waku-org/js-waku/issues/1186)) ([5b0c3c3](https://github.com/waku-org/js-waku/commit/5b0c3c3cac3ddb5687d8f59457d6056527a8666c))
### Bug Fixes
* @waku/peer-exchange uses @waku/core and should depend on it ([e922ed4](https://github.com/waku-org/js-waku/commit/e922ed49ec70553227751518251152c765efd07c))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from * to 0.0.12
* @waku/enr bumped from 0.0.6 to 0.0.7
* devDependencies
* @waku/interfaces bumped from 0.0.8 to 0.0.9
## [0.0.4](https://github.com/waku-org/js-waku/compare/peer-exchange-v0.0.3...peer-exchange-v0.0.4) (2023-03-16)
### ⚠ BREAKING CHANGES
* directly convert from ENR to `PeerInfo`, remove unneeded utility
* extract decoder code
* bump typescript
* bump all prod dependencies
* bump libp2p dependencies
### Features
* Codec as a property of the protocol implementations ([a5ff788](https://github.com/waku-org/js-waku/commit/a5ff788eed419556e11319f22ca9e3109c81df92))
* DNS discovery as default bootstrap discovery ([#1114](https://github.com/waku-org/js-waku/issues/1114)) ([11819fc](https://github.com/waku-org/js-waku/commit/11819fc7b14e18385d421facaf2af0832cad1da8))
### Bug Fixes
* **dns-discovery/peer-exchange:** Check if peer is already tagged ([952aadd](https://github.com/waku-org/js-waku/commit/952aadd7bbbe1a7265c5126c1678f552bef0648d))
* Prettier and cspell ignore CHANGELOG ([#1235](https://github.com/waku-org/js-waku/issues/1235)) ([4d7b3e3](https://github.com/waku-org/js-waku/commit/4d7b3e39e6761afaf5d05a13cc4b3c23e15f9bd5))
* Remove initialising peer-exchange while creating a node ([#1158](https://github.com/waku-org/js-waku/issues/1158)) ([1b41569](https://github.com/waku-org/js-waku/commit/1b4156902387ea35b24b3d6f5d22e4635ea8cf18))
### Miscellaneous Chores
* Bump all prod dependencies ([88cc76d](https://github.com/waku-org/js-waku/commit/88cc76d2b811e1fa4460207f38704ecfe18fb260))
* Bump libp2p dependencies ([803ae7b](https://github.com/waku-org/js-waku/commit/803ae7bd8ed3de665026446c23cde90e7eba9d36))
* Bump typescript ([12d86e6](https://github.com/waku-org/js-waku/commit/12d86e6abcc68e27c39ca86b4f0dc2b68cdd6000))
* Directly convert from ENR to `PeerInfo`, remove unneeded utility ([6dbcde0](https://github.com/waku-org/js-waku/commit/6dbcde041ab8fa8c2df75cc25319a0eccf6b0454))
* Extract decoder code ([130c49b](https://github.com/waku-org/js-waku/commit/130c49b636807063364f309da0da2a24a68f2178))
### Dependencies
* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from * to 0.0.6
* @waku/proto bumped from * to 0.0.3
* devDependencies
* @waku/interfaces bumped from * to 0.0.8
## Changelog
All notable changes to this project will be documented in this file.
The file is maintained by [Release Please](https://github.com/googleapis/release-please) based on [Conventional Commits](https://www.conventionalcommits.org) specification,
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

View File

@ -1,83 +0,0 @@
{
"name": "@waku/peer-exchange",
"version": "0.0.20",
"description": "Peer Exchange (https://rfc.vac.dev/spec/34/) protocol for Waku",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"type": "module",
"author": "Waku Team",
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/peer-exchange#readme",
"repository": {
"type": "git",
"url": "https://github.com/waku-org/js-waku.git"
},
"bugs": {
"url": "https://github.com/waku-org/js-waku/issues"
},
"license": "MIT OR Apache-2.0",
"keywords": [
"waku",
"decentralized",
"secure",
"communication",
"web3",
"ethereum",
"dapps",
"privacy"
],
"scripts": {
"build": "run-s build:**",
"build:esm": "tsc",
"build:bundle": "rollup --config rollup.config.js",
"fix": "run-s fix:*",
"fix:lint": "eslint src *.js --fix",
"check": "run-s check:*",
"check:lint": "eslint src *.js",
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
"check:tsc": "tsc -p tsconfig.dev.json",
"prepublish": "npm run build",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
},
"engines": {
"node": ">=18"
},
"dependencies": {
"@libp2p/interfaces": "^3.3.2",
"@waku/core": "0.0.27",
"@waku/enr": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15",
"debug": "^4.3.4",
"it-all": "^3.0.4",
"it-length-prefixed": "^9.0.4",
"it-pipe": "^3.0.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@waku/build-utils": "*",
"chai": "^4.3.10",
"cspell": "^8.3.2",
"npm-run-all": "^4.1.5",
"rollup": "^4.12.0",
"uint8arraylist": "^2.4.3"
},
"files": [
"dist",
"bundle",
"src/**/*.ts",
"!**/*.spec.*",
"!**/*.json",
"CHANGELOG.md",
"LICENSE",
"README.md"
]
}

View File

@ -1,24 +0,0 @@
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import { extractExports } from "@waku/build-utils";
import * as packageJson from "./package.json" assert { type: "json" };
const input = extractExports(packageJson);
export default {
input,
output: {
dir: "bundle",
format: "esm"
},
plugins: [
commonjs(),
json(),
nodeResolve({
browser: true,
preferBuiltins: false
})
]
};

View File

@ -1,3 +0,0 @@
{
"extends": "../../tsconfig.dev"
}

View File

@ -1,10 +0,0 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "dist/",
"rootDir": "src",
"tsBuildInfoFile": "dist/.tsbuildinfo"
},
"include": ["src"],
"exclude": ["src/**/*.spec.ts", "src/test_utils"]
}

View File

@ -1,4 +0,0 @@
{
"extends": ["../../typedoc.base.json"],
"entryPoints": ["src/index.ts"]
}

View File

@ -66,6 +66,21 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"rollup": "^4.12.0"
},
"peerDependencies": {
"@waku/core": "0.0.27",
"@waku/interfaces": "0.0.22",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.15",
"@chainsafe/libp2p-gossipsub": "^12.0.0"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
},
"@chainsafe/libp2p-gossipsub": {
"optional": true
}
},
"files": [
"dist",
"bundle",

View File

@ -20,8 +20,8 @@ import {
IRelay,
Libp2p,
ProtocolCreateOptions,
ProtocolError,
PubsubTopic,
SendError,
SendResult
} from "@waku/interfaces";
import { isWireSizeUnderCap, toAsyncIterator } from "@waku/utils";
@ -109,7 +109,7 @@ class Relay implements IRelay {
successes,
failures: [
{
error: SendError.TOPIC_NOT_CONFIGURED
error: ProtocolError.TOPIC_NOT_CONFIGURED
}
]
};
@ -122,7 +122,7 @@ class Relay implements IRelay {
successes,
failures: [
{
error: SendError.ENCODE_FAILED
error: ProtocolError.ENCODE_FAILED
}
]
};
@ -134,7 +134,7 @@ class Relay implements IRelay {
successes,
failures: [
{
error: SendError.SIZE_TOO_BIG
error: ProtocolError.SIZE_TOO_BIG
}
]
};

View File

@ -66,6 +66,7 @@
"@libp2p/mplex": "^10.0.12",
"@libp2p/ping": "^1.0.12",
"@libp2p/websockets": "^8.0.11",
"@waku/discovery": "0.0.1",
"@waku/core": "0.0.27",
"@waku/dns-discovery": "0.0.21",
"@waku/interfaces": "0.0.22",
@ -88,7 +89,22 @@
"rollup": "^4.12.0"
},
"peerDependencies": {
"@libp2p/bootstrap": "^10"
"@libp2p/bootstrap": "^10",
"@waku/core": "0.0.27",
"@waku/dns-discovery": "0.0.21",
"@waku/interfaces": "0.0.22",
"@waku/local-peer-cache-discovery": "^1.0.0",
"@waku/peer-exchange": "^0.0.20",
"@waku/relay": "0.0.10",
"@waku/utils": "0.0.15"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
},
"@libp2p/bootstrap": {
"optional": true
}
},
"files": [
"dist",

View File

@ -7,7 +7,7 @@ import {
type IMessage,
type Libp2p,
type ProtocolCreateOptions,
SendError,
ProtocolError,
type SendResult
} from "@waku/interfaces";
import { ensurePubsubTopicIsConfigured, Logger } from "@waku/utils";
@ -37,7 +37,7 @@ export class LightPushSDK extends BaseProtocolSDK implements ILightPushSDK {
return {
failures: [
{
error: SendError.TOPIC_NOT_CONFIGURED
error: ProtocolError.TOPIC_NOT_CONFIGURED
}
],
successes: []
@ -48,7 +48,7 @@ export class LightPushSDK extends BaseProtocolSDK implements ILightPushSDK {
if (!peers.length) {
return {
successes,
failures: [{ error: SendError.NO_PEER_AVAILABLE }]
failures: [{ error: ProtocolError.NO_PEER_AVAILABLE }]
};
}
@ -69,7 +69,7 @@ export class LightPushSDK extends BaseProtocolSDK implements ILightPushSDK {
}
} else {
log.error("Failed to send message to peer", result.reason);
failures.push({ error: SendError.GENERIC_FAIL });
failures.push({ error: ProtocolError.GENERIC_FAIL });
// TODO: handle renewing faulty peers with new peers (https://github.com/waku-org/js-waku/issues/1463)
}
}

View File

@ -74,9 +74,8 @@
"@types/mocha": "^10.0.6",
"@types/sinon": "^17.0.3",
"@types/tail": "^2.2.3",
"@waku/dns-discovery": "*",
"@waku/discovery": "*",
"@waku/message-encryption": "*",
"@waku/peer-exchange": "*",
"@waku/sdk": "*",
"allure-commandline": "^2.27.0",
"allure-mocha": "^2.9.2",

View File

@ -8,7 +8,7 @@ import {
enrTree,
PeerDiscoveryDns,
wakuDnsDiscovery
} from "@waku/dns-discovery";
} from "@waku/discovery";
import { Libp2pComponents } from "@waku/interfaces";
import { createLightNode } from "@waku/sdk";
import { expect } from "chai";

View File

@ -3,7 +3,7 @@ import {
DefaultPubsubTopic,
IRateLimitProof,
LightNode,
SendError
ProtocolError
} from "@waku/interfaces";
import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
@ -97,7 +97,7 @@ const runTests = (strictNodeCheck: boolean): void => {
expect(pushResponse.successes.length).to.eq(0);
console.log("validated 1");
expect(pushResponse.failures?.map((failure) => failure.error)).to.include(
SendError.EMPTY_PAYLOAD
ProtocolError.EMPTY_PAYLOAD
);
console.log("validated 2");
expect(await serviceNodes.messageCollector.waitForMessages(1)).to.eq(
@ -190,7 +190,7 @@ const runTests = (strictNodeCheck: boolean): void => {
expect(pushResponse.successes.length).to.eq(0);
expect(
pushResponse.failures?.map((failure) => failure.error)
).to.include(SendError.REMOTE_PEER_REJECTED);
).to.include(ProtocolError.REMOTE_PEER_REJECTED);
expect(await serviceNodes.messageCollector.waitForMessages(1)).to.eq(
false
);
@ -262,7 +262,7 @@ const runTests = (strictNodeCheck: boolean): void => {
});
expect(pushResponse.successes.length).to.eq(0);
expect(pushResponse.failures?.map((failure) => failure.error)).to.include(
SendError.SIZE_TOO_BIG
ProtocolError.SIZE_TOO_BIG
);
expect(await serviceNodes.messageCollector.waitForMessages(1)).to.eq(
false

View File

@ -3,7 +3,7 @@ import {
DefaultPubsubTopic,
IRateLimitProof,
LightNode,
SendError
ProtocolError
} from "@waku/interfaces";
import { utf8ToBytes } from "@waku/sdk";
import { expect } from "chai";
@ -85,7 +85,7 @@ describe("Waku Light Push: Single Node", function () {
expect(pushResponse.successes.length).to.eq(0);
expect(pushResponse.failures?.map((failure) => failure.error)).to.include(
SendError.EMPTY_PAYLOAD
ProtocolError.EMPTY_PAYLOAD
);
expect(await messageCollector.waitForMessages(1)).to.eq(false);
});
@ -167,7 +167,7 @@ describe("Waku Light Push: Single Node", function () {
} else {
expect(pushResponse.successes.length).to.eq(0);
expect(pushResponse.failures?.map((failure) => failure.error)).to.include(
SendError.REMOTE_PEER_REJECTED
ProtocolError.REMOTE_PEER_REJECTED
);
expect(await messageCollector.waitForMessages(1)).to.eq(false);
}
@ -234,7 +234,7 @@ describe("Waku Light Push: Single Node", function () {
});
expect(pushResponse.successes.length).to.eq(0);
expect(pushResponse.failures?.map((failure) => failure.error)).to.include(
SendError.SIZE_TOO_BIG
ProtocolError.SIZE_TOO_BIG
);
expect(await messageCollector.waitForMessages(1)).to.eq(false);
});

View File

@ -52,11 +52,22 @@ describe("Metadata Protocol", function () {
await waku.start();
await waku.libp2p.dialProtocol(nwaku1Ma, MetadataCodec);
const shardInfoRes =
await waku.libp2p.services.metadata?.query(nwaku1PeerId);
if (!waku.libp2p.services.metadata) {
expect(waku.libp2p.services.metadata).to.not.be.undefined;
return;
}
const { error, shardInfo: shardInfoRes } =
await waku.libp2p.services.metadata.query(nwaku1PeerId);
if (error) {
expect(error).to.be.null;
return;
}
expect(shardInfoRes).to.not.be.undefined;
expect(shardInfoRes?.clusterId).to.equal(shardInfo.clusterId);
expect(shardInfoRes?.shards).to.deep.equal(shardInfo.shards);
expect(shardInfoRes.clusterId).to.equal(shardInfo.clusterId);
expect(shardInfoRes.shards).to.deep.equal(shardInfo.shards);
const activeConnections = waku.libp2p.getConnections();
expect(activeConnections.length).to.equal(1);
@ -89,11 +100,22 @@ describe("Metadata Protocol", function () {
await waku.start();
await waku.libp2p.dialProtocol(nwaku1Ma, MetadataCodec);
const shardInfoRes =
await waku.libp2p.services.metadata?.query(nwaku1PeerId);
if (!waku.libp2p.services.metadata) {
expect(waku.libp2p.services.metadata).to.not.be.undefined;
return;
}
const { error, shardInfo: shardInfoRes } =
await waku.libp2p.services.metadata.query(nwaku1PeerId);
if (error) {
expect(error).to.be.null;
return;
}
expect(shardInfoRes).to.not.be.undefined;
expect(shardInfoRes?.clusterId).to.equal(shardInfo1.clusterId);
expect(shardInfoRes?.shards).to.deep.equal(shardInfo1.shards);
expect(shardInfoRes.clusterId).to.equal(shardInfo1.clusterId);
expect(shardInfoRes.shards).to.deep.equal(shardInfo1.shards);
const activeConnections = waku.libp2p.getConnections();
expect(activeConnections.length).to.equal(1);

View File

@ -1,6 +1,6 @@
import tests from "@libp2p/interface-compliance-tests/peer-discovery";
import { PeerExchangeCodec, PeerExchangeDiscovery } from "@waku/discovery";
import type { LightNode } from "@waku/interfaces";
import { PeerExchangeCodec, PeerExchangeDiscovery } from "@waku/peer-exchange";
import { createLightNode } from "@waku/sdk";
import { singleShardInfoToPubsubTopic } from "@waku/utils";

View File

@ -1,7 +1,7 @@
import { bootstrap } from "@libp2p/bootstrap";
import type { PeerId } from "@libp2p/interface";
import { wakuPeerExchangeDiscovery } from "@waku/discovery";
import type { LightNode, PeersByDiscoveryResult } from "@waku/interfaces";
import { wakuPeerExchangeDiscovery } from "@waku/peer-exchange";
import { createLightNode, Tags } from "@waku/sdk";
import { Logger, singleShardInfoToPubsubTopic } from "@waku/utils";
import { expect } from "chai";

View File

@ -3,8 +3,8 @@ import {
Fleet,
getPredefinedBootstrapNodes
} from "@waku/core/lib/predefined_bootstrap_nodes";
import { wakuPeerExchangeDiscovery } from "@waku/discovery";
import type { LightNode } from "@waku/interfaces";
import { wakuPeerExchangeDiscovery } from "@waku/peer-exchange";
import { createLightNode, DefaultPubsubTopic } from "@waku/sdk";
import { expect } from "chai";

View File

@ -2,12 +2,12 @@ import { bootstrap } from "@libp2p/bootstrap";
import type { PeerId } from "@libp2p/interface";
import { multiaddr } from "@multiformats/multiaddr";
import type { Multiaddr } from "@multiformats/multiaddr";
import type { LightNode, PeerInfo } from "@waku/interfaces";
import {
PeerExchangeCodec,
WakuPeerExchange,
wakuPeerExchangeDiscovery
} from "@waku/peer-exchange";
} from "@waku/discovery";
import type { LightNode, PeerInfo } from "@waku/interfaces";
import { createLightNode, Libp2pComponents } from "@waku/sdk";
import { Logger, singleShardInfoToPubsubTopic } from "@waku/utils";
import { expect } from "chai";

View File

@ -1,5 +1,5 @@
import { createEncoder } from "@waku/core";
import { IRateLimitProof, RelayNode, SendError } from "@waku/interfaces";
import { IRateLimitProof, ProtocolError, RelayNode } from "@waku/interfaces";
import { createRelayNode } from "@waku/sdk/relay";
import { utf8ToBytes } from "@waku/utils/bytes";
import { expect } from "chai";
@ -135,7 +135,7 @@ describe("Waku Relay, Publish", function () {
payload: utf8ToBytes("")
});
expect(pushResponse.failures?.[0].error).to.eq(
SendError.TOPIC_NOT_CONFIGURED
ProtocolError.TOPIC_NOT_CONFIGURED
);
await delay(400);
expect(await messageCollector.waitForMessages(1)).to.eq(false);
@ -148,7 +148,7 @@ describe("Waku Relay, Publish", function () {
});
expect(pushResponse.successes.length).to.eq(0);
expect(pushResponse.failures?.map((failure) => failure.error)).to.include(
SendError.SIZE_TOO_BIG
ProtocolError.SIZE_TOO_BIG
);
await delay(400);
expect(await messageCollector.waitForMessages(1)).to.eq(false);

View File

@ -1,6 +1,6 @@
import { bootstrap } from "@libp2p/bootstrap";
import type { PeerId } from "@libp2p/interface";
import { wakuPeerExchangeDiscovery } from "@waku/peer-exchange";
import { wakuPeerExchangeDiscovery } from "@waku/discovery";
import {
ContentTopicInfo,
createLightNode,

View File

@ -1,7 +1,7 @@
import {
LightNode,
ProtocolError,
Protocols,
SendError,
ShardInfo,
SingleShardInfo
} from "@waku/interfaces";
@ -93,7 +93,7 @@ describe("Static Sharding: Running Nodes", function () {
}
const errors = failures?.map((failure) => failure.error);
expect(errors).to.include(SendError.TOPIC_NOT_CONFIGURED);
expect(errors).to.include(ProtocolError.TOPIC_NOT_CONFIGURED);
});
});

View File

@ -1,5 +1,5 @@
import { bootstrap } from "@libp2p/bootstrap";
import { enrTree, wakuDnsDiscovery } from "@waku/dns-discovery";
import { enrTree, wakuDnsDiscovery } from "@waku/discovery";
import { LightNode } from "@waku/interfaces";
import { createLightNode } from "@waku/sdk";
import { expect } from "chai";

View File

@ -83,6 +83,14 @@
"fast-check": "^3.15.1",
"rollup": "^4.12.0"
},
"peerDependencies": {
"@waku/interfaces": "0.0.22"
},
"peerDependenciesMeta": {
"@waku/interfaces": {
"optional": true
}
},
"files": [
"dist",
"bundle",

View File

@ -100,7 +100,7 @@ export const pubsubTopicToSingleShardInfo = (
};
//TODO: move part of BaseProtocol instead of utils
// return `SendError.TOPIC_NOT_CONFIGURED` instead of throwing
// return `ProtocolError.TOPIC_NOT_CONFIGURED` instead of throwing
export function ensurePubsubTopicIsConfigured(
pubsubTopic: PubsubTopic,
configuredTopics: PubsubTopic[]

View File

@ -11,13 +11,11 @@
"packages/interfaces": {},
"packages/message-hash": {},
"packages/enr": {},
"packages/peer-exchange": {},
"packages/core": {},
"packages/dns-discovery": {},
"packages/message-encryption": {},
"packages/sdk": {},
"packages/relay": {},
"packages/local-peer-cache-discovery": {},
"packages/rln": {}
"packages/rln": {},
"packages/discovery": {}
}
}