From 057507f94faf98a7544b422d4bb4dc220b7de6d2 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 1 Nov 2022 16:30:24 +1100 Subject: [PATCH] fix: @waku/interfaces --- package-lock.json | 575 +----------------- packages/core/package.json | 2 +- packages/core/src/index.ts | 2 +- packages/core/src/lib/to_proto_message.ts | 4 +- packages/core/src/lib/wait_for_remote_peer.ts | 23 +- packages/core/src/lib/waku.ts | 10 +- packages/core/src/lib/waku_filter/index.ts | 33 +- .../core/src/lib/waku_light_push/index.ts | 16 +- .../lib/waku_message/topic_only_message.ts | 2 +- .../core/src/lib/waku_message/version_0.ts | 9 +- .../core/src/lib/waku_message/version_1.ts | 2 +- packages/core/src/lib/waku_relay/index.ts | 13 +- packages/core/src/lib/waku_store/index.ts | 2 +- packages/create/package.json | 2 +- packages/interfaces/package.json | 16 +- packages/interfaces/src/index.ts | 16 +- 16 files changed, 81 insertions(+), 646 deletions(-) diff --git a/package-lock.json b/package-lock.json index f3644047f1..6a4ed2f74e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22519,10 +22519,12 @@ "version": "0.0.1", "license": "MIT OR Apache-2.0", "dependencies": { + "@chainsafe/libp2p-gossipsub": "^4.1.1", "@libp2p/interface-connection": "^3.0.2", "@libp2p/interface-peer-id": "^1.0.5", + "@libp2p/interface-peer-store": "^1.2.2", "@multiformats/multiaddr": "^11.0.6", - "libp2p": "^0.40.0" + "libp2p": "0.38.0" }, "devDependencies": { "@semantic-release/changelog": "^6.0.1", @@ -22551,19 +22553,6 @@ "node": ">=16" } }, - "packages/interfaces/node_modules/@libp2p/interface-address-manager": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-address-manager/-/interface-address-manager-2.0.0.tgz", - "integrity": "sha512-cEzZMxgy71geUcNMZtbF/gNNZbtc8Gx6MI/bj2sPT7ZVqMR7XhSCrpzm3kBkWpSHdWMYImfXCwU0oLg4UtI9Ow==", - "dependencies": { - "@libp2p/interfaces": "^3.0.0", - "@multiformats/multiaddr": "^11.0.0" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, "packages/interfaces/node_modules/@libp2p/interface-connection": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.2.tgz", @@ -22580,98 +22569,6 @@ "npm": ">=7.0.0" } }, - "packages/interfaces/node_modules/@libp2p/interface-connection-encrypter": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@libp2p/interface-connection-encrypter/-/interface-connection-encrypter-3.0.1.tgz", - "integrity": "sha512-KZ/4vuLokv2fNCnEAM5S91t8v5lMWXdYa26v/iGLqLgiH5MXmIGOgLLGdboXNMYM2ZYYCBgEpSHv+ZRbfO524Q==", - "dependencies": { - "@libp2p/interface-peer-id": "^1.0.0", - "it-stream-types": "^1.0.4", - "uint8arraylist": "^2.1.1" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/@libp2p/interface-pubsub": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-pubsub/-/interface-pubsub-3.0.0.tgz", - "integrity": "sha512-3ziZ/mNdCRlfdzSetu38nNbQU6u/rtpQtgI4S4iaSW7MTyivKscWDEPCo5DkF9Uck25hNCbYHhOyKDBoIMdr6Q==", - "dependencies": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interface-peer-id": "^1.0.0", - "@libp2p/interfaces": "^3.0.0", - "it-pushable": "^3.0.0", - "uint8arraylist": "^2.0.0" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/@libp2p/interface-stream-muxer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-stream-muxer/-/interface-stream-muxer-3.0.0.tgz", - "integrity": "sha512-qv7Z4KJC2SLu/GhwDzT71VBHhtu2fpSL/DGh0iFmkxicQsMmdpiqmXv9EGKw3+jdQL57uKIUm98OpOi2Hge0kg==", - "dependencies": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interfaces": "^3.0.0", - "it-stream-types": "^1.0.4" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/@libp2p/interface-transport": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.0.tgz", - "integrity": "sha512-aK33gpkEzfEtoSPlS7z624Tubf49CD2x4DUbXOmQCXDP/rhh3gAQq5XU5dcincM3QXlx6RRSO1PWRqM8EnLE0Q==", - "dependencies": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interface-stream-muxer": "^3.0.0", - "@libp2p/interfaces": "^3.0.0", - "@multiformats/multiaddr": "^11.0.0", - "it-stream-types": "^1.0.4" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/@libp2p/peer-store": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/peer-store/-/peer-store-5.0.0.tgz", - "integrity": "sha512-Yz/JykQ9xA0cpv4jIOt9dzYXBAugjoJFPVpA8/LEwU6Y+aUcTIAC3AhOe88QxjYxy4pz+H7C711K2HNCj207jg==", - "dependencies": { - "@libp2p/interface-peer-id": "^1.0.4", - "@libp2p/interface-peer-info": "^1.0.3", - "@libp2p/interface-peer-store": "^1.2.2", - "@libp2p/interface-record": "^2.0.1", - "@libp2p/interfaces": "^3.0.3", - "@libp2p/logger": "^2.0.0", - "@libp2p/peer-id": "^1.1.15", - "@libp2p/peer-record": "^4.0.3", - "@multiformats/multiaddr": "^11.0.0", - "err-code": "^3.0.1", - "interface-datastore": "^7.0.0", - "it-all": "^1.0.6", - "it-filter": "^1.0.3", - "it-foreach": "^0.1.1", - "it-map": "^1.0.6", - "it-pipe": "^2.0.3", - "mortice": "^3.0.0", - "multiformats": "^10.0.0", - "protons-runtime": "^4.0.1", - "uint8arraylist": "^2.1.1", - "uint8arrays": "^4.0.2" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, "packages/interfaces/node_modules/@multiformats/multiaddr": { "version": "11.0.6", "resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-11.0.6.tgz", @@ -22689,178 +22586,6 @@ "npm": ">=7.0.0" } }, - "packages/interfaces/node_modules/it-drain": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-drain/-/it-drain-2.0.0.tgz", - "integrity": "sha512-oa/5iyBtRs9UW486vPpyDTC0ee3rqx5qlrPI7txIUJcqqtiO5yVozEB6LQrl5ysQYv+P3y/dlKEqwVqlCV0SEA==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/it-first": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-first/-/it-first-2.0.0.tgz", - "integrity": "sha512-fzZGzVf01exFyIZXNjkpSMFr1eW2+J1K0v018tYY26Dd4f/O3pWlBTdrOBfSQRZwtI8Pst6c7eKhYczWvFs6tA==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/it-merge": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-merge/-/it-merge-2.0.0.tgz", - "integrity": "sha512-mH4bo/ZrMoU+Wlu7ZuYPNNh9oWZ/GvYbeXZ0zll97+Rp6H4jFu98iu6v9qqXDz//RUjdO9zGh8awzMfOElsjpA==", - "dependencies": { - "it-pushable": "^3.1.0" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/it-sort": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-sort/-/it-sort-2.0.0.tgz", - "integrity": "sha512-yeAE97b5PEjCrWFUiNyR90eJdGslj8FB3cjT84rsc+mzx9lxPyR2zJkYB9ZOJoWE5MMebxqcQCLRT3OSlzo7Zg==", - "dependencies": { - "it-all": "^2.0.0" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/it-sort/node_modules/it-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", - "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/libp2p": { - "version": "0.40.0", - "resolved": "https://registry.npmjs.org/libp2p/-/libp2p-0.40.0.tgz", - "integrity": "sha512-AeLaA+8KIhUhjpXZcs20+Pnf2wIBp+zdSYPD1IgGCF0PlMbTdCvaIqhPzpTSd3+e5k7NZlgpd/BvCOLgQbfm5Q==", - "dependencies": { - "@achingbrain/nat-port-mapper": "^1.0.3", - "@libp2p/connection": "^4.0.2", - "@libp2p/crypto": "^1.0.4", - "@libp2p/interface-address-manager": "^2.0.0", - "@libp2p/interface-connection": "^3.0.2", - "@libp2p/interface-connection-encrypter": "^3.0.1", - "@libp2p/interface-connection-manager": "^1.1.1", - "@libp2p/interface-content-routing": "^1.0.2", - "@libp2p/interface-dht": "^1.0.1", - "@libp2p/interface-metrics": "^3.0.0", - "@libp2p/interface-peer-discovery": "^1.0.1", - "@libp2p/interface-peer-id": "^1.0.4", - "@libp2p/interface-peer-info": "^1.0.3", - "@libp2p/interface-peer-routing": "^1.0.1", - "@libp2p/interface-peer-store": "^1.2.2", - "@libp2p/interface-pubsub": "^3.0.0", - "@libp2p/interface-registrar": "^2.0.3", - "@libp2p/interface-stream-muxer": "^3.0.0", - "@libp2p/interface-transport": "^2.0.0", - "@libp2p/interfaces": "^3.0.3", - "@libp2p/logger": "^2.0.1", - "@libp2p/multistream-select": "^3.0.0", - "@libp2p/peer-collections": "^2.0.0", - "@libp2p/peer-id": "^1.1.15", - "@libp2p/peer-id-factory": "^1.0.18", - "@libp2p/peer-record": "^4.0.3", - "@libp2p/peer-store": "^5.0.0", - "@libp2p/tracked-map": "^2.0.1", - "@libp2p/utils": "^3.0.2", - "@multiformats/mafmt": "^11.0.2", - "@multiformats/multiaddr": "^11.0.0", - "abortable-iterator": "^4.0.2", - "any-signal": "^3.0.0", - "datastore-core": "^8.0.1", - "err-code": "^3.0.1", - "events": "^3.3.0", - "hashlru": "^2.3.0", - "interface-datastore": "^7.0.0", - "it-all": "^2.0.0", - "it-drain": "^2.0.0", - "it-filter": "^2.0.0", - "it-first": "^2.0.0", - "it-foreach": "^1.0.0", - "it-handshake": "^4.1.2", - "it-length-prefixed": "^8.0.2", - "it-map": "^2.0.0", - "it-merge": "^2.0.0", - "it-pair": "^2.0.2", - "it-pipe": "^2.0.3", - "it-sort": "^2.0.0", - "it-stream-types": "^1.0.4", - "merge-options": "^3.0.4", - "multiformats": "^10.0.0", - "mutable-proxy": "^1.0.0", - "node-forge": "^1.3.1", - "p-fifo": "^1.0.0", - "p-retry": "^5.0.0", - "p-settle": "^5.0.0", - "private-ip": "^2.3.3", - "protons-runtime": "^4.0.1", - "rate-limiter-flexible": "^2.3.11", - "retimer": "^3.0.0", - "sanitize-filename": "^1.6.3", - "set-delayed-interval": "^1.0.0", - "timeout-abort-controller": "^3.0.0", - "uint8arraylist": "^2.3.2", - "uint8arrays": "^4.0.2", - "wherearewe": "^2.0.0", - "xsalsa20": "^1.1.0" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/libp2p/node_modules/it-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", - "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/libp2p/node_modules/it-filter": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-filter/-/it-filter-2.0.0.tgz", - "integrity": "sha512-E68+zzoNNI7MxdH1T4lUTgwpCyEnymlH349Qg2mcvsqLmYRkaZLM4NfZZ0hUuH7/5DkWXubQSDOYH396va8mpg==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/libp2p/node_modules/it-foreach": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/it-foreach/-/it-foreach-1.0.0.tgz", - "integrity": "sha512-2j5HK1P6aMwEvgL6K5nzUwOk+81B/mjt05PxiSspFEKwJnqy1LfJYlLLS6llBoM+NdoUxf6EsBCHidFGmsXvhw==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/libp2p/node_modules/it-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-map/-/it-map-2.0.0.tgz", - "integrity": "sha512-mLgtk/NZaN7NZ06iLrMXCA6jjhtZO0vZT5Ocsp31H+nsGI18RSPVmUbFyA1sWx7q+g92J22Sixya7T2QSSAwfA==", - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - } - }, - "packages/interfaces/node_modules/long": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/long/-/long-5.2.0.tgz", - "integrity": "sha512-9RTUNjK60eJbx3uz+TEGF7fUr29ZDxR5QzXcyDpeSfeH28S9ycINflOgOlppit5U+4kNTe83KQnMEerw7GmE8w==" - }, "packages/interfaces/node_modules/multiformats": { "version": "10.0.2", "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-10.0.2.tgz", @@ -22870,45 +22595,6 @@ "npm": ">=7.0.0" } }, - "packages/interfaces/node_modules/protobufjs": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.1.2.tgz", - "integrity": "sha512-4ZPTPkXCdel3+L81yw3dG6+Kq3umdWKh7Dc7GW/CpNk4SX3hK58iPCWeCyhVTDrbkNeKrYNZ7EojM5WDaEWTLQ==", - "hasInstallScript": true, - "dependencies": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/node": ">=13.7.0", - "long": "^5.0.0" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "packages/interfaces/node_modules/protons-runtime": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-4.0.1.tgz", - "integrity": "sha512-SPeV+8TzJAp5UJYPV7vJkLRi08CP0DksxpKK60rcNaZSPkMBQwc0jQrmkHqwc5P0cYbZzKsdYrUBwRrDLrzTfQ==", - "dependencies": { - "protobufjs": "^7.0.0", - "uint8arraylist": "^2.3.2" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - }, - "peerDependencies": { - "uint8arraylist": "^2.3.2" - } - }, "packages/interfaces/node_modules/uint8arrays": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-4.0.2.tgz", @@ -27276,9 +26962,11 @@ "@waku/interfaces": { "version": "file:packages/interfaces", "requires": { - "@libp2p/interface-connection": "*", - "@libp2p/interface-peer-id": "*", - "@multiformats/multiaddr": "*", + "@chainsafe/libp2p-gossipsub": "^4.1.1", + "@libp2p/interface-connection": "^3.0.2", + "@libp2p/interface-peer-id": "^1.0.5", + "@libp2p/interface-peer-store": "^1.2.2", + "@multiformats/multiaddr": "^11.0.6", "@semantic-release/changelog": "^6.0.1", "@semantic-release/commit-analyzer": "^9.0.2", "@semantic-release/git": "^10.0.1", @@ -27294,7 +26982,7 @@ "eslint-plugin-functional": "^4.0.2", "eslint-plugin-import": "^2.25.3", "eslint-plugin-prettier": "^4.0.0", - "libp2p": "*", + "libp2p": "0.38.0", "npm-run-all": "^4.1.5", "prettier": "^2.1.1", "semantic-release": "^19.0.5", @@ -27303,15 +26991,6 @@ "typescript": "^4.6.3" }, "dependencies": { - "@libp2p/interface-address-manager": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-address-manager/-/interface-address-manager-2.0.0.tgz", - "integrity": "sha512-cEzZMxgy71geUcNMZtbF/gNNZbtc8Gx6MI/bj2sPT7ZVqMR7XhSCrpzm3kBkWpSHdWMYImfXCwU0oLg4UtI9Ow==", - "requires": { - "@libp2p/interfaces": "^3.0.0", - "@multiformats/multiaddr": "^11.0.0" - } - }, "@libp2p/interface-connection": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.2.tgz", @@ -27324,78 +27003,6 @@ "uint8arraylist": "^2.1.1" } }, - "@libp2p/interface-connection-encrypter": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@libp2p/interface-connection-encrypter/-/interface-connection-encrypter-3.0.1.tgz", - "integrity": "sha512-KZ/4vuLokv2fNCnEAM5S91t8v5lMWXdYa26v/iGLqLgiH5MXmIGOgLLGdboXNMYM2ZYYCBgEpSHv+ZRbfO524Q==", - "requires": { - "@libp2p/interface-peer-id": "^1.0.0", - "it-stream-types": "^1.0.4", - "uint8arraylist": "^2.1.1" - } - }, - "@libp2p/interface-pubsub": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-pubsub/-/interface-pubsub-3.0.0.tgz", - "integrity": "sha512-3ziZ/mNdCRlfdzSetu38nNbQU6u/rtpQtgI4S4iaSW7MTyivKscWDEPCo5DkF9Uck25hNCbYHhOyKDBoIMdr6Q==", - "requires": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interface-peer-id": "^1.0.0", - "@libp2p/interfaces": "^3.0.0", - "it-pushable": "^3.0.0", - "uint8arraylist": "^2.0.0" - } - }, - "@libp2p/interface-stream-muxer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-stream-muxer/-/interface-stream-muxer-3.0.0.tgz", - "integrity": "sha512-qv7Z4KJC2SLu/GhwDzT71VBHhtu2fpSL/DGh0iFmkxicQsMmdpiqmXv9EGKw3+jdQL57uKIUm98OpOi2Hge0kg==", - "requires": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interfaces": "^3.0.0", - "it-stream-types": "^1.0.4" - } - }, - "@libp2p/interface-transport": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/interface-transport/-/interface-transport-2.0.0.tgz", - "integrity": "sha512-aK33gpkEzfEtoSPlS7z624Tubf49CD2x4DUbXOmQCXDP/rhh3gAQq5XU5dcincM3QXlx6RRSO1PWRqM8EnLE0Q==", - "requires": { - "@libp2p/interface-connection": "^3.0.0", - "@libp2p/interface-stream-muxer": "^3.0.0", - "@libp2p/interfaces": "^3.0.0", - "@multiformats/multiaddr": "^11.0.0", - "it-stream-types": "^1.0.4" - } - }, - "@libp2p/peer-store": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@libp2p/peer-store/-/peer-store-5.0.0.tgz", - "integrity": "sha512-Yz/JykQ9xA0cpv4jIOt9dzYXBAugjoJFPVpA8/LEwU6Y+aUcTIAC3AhOe88QxjYxy4pz+H7C711K2HNCj207jg==", - "requires": { - "@libp2p/interface-peer-id": "^1.0.4", - "@libp2p/interface-peer-info": "^1.0.3", - "@libp2p/interface-peer-store": "^1.2.2", - "@libp2p/interface-record": "^2.0.1", - "@libp2p/interfaces": "^3.0.3", - "@libp2p/logger": "^2.0.0", - "@libp2p/peer-id": "^1.1.15", - "@libp2p/peer-record": "^4.0.3", - "@multiformats/multiaddr": "^11.0.0", - "err-code": "^3.0.1", - "interface-datastore": "^7.0.0", - "it-all": "^1.0.6", - "it-filter": "^1.0.3", - "it-foreach": "^0.1.1", - "it-map": "^1.0.6", - "it-pipe": "^2.0.3", - "mortice": "^3.0.0", - "multiformats": "^10.0.0", - "protons-runtime": "^4.0.1", - "uint8arraylist": "^2.1.1", - "uint8arrays": "^4.0.2" - } - }, "@multiformats/multiaddr": { "version": "11.0.6", "resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-11.0.6.tgz", @@ -27409,175 +27016,11 @@ "varint": "^6.0.0" } }, - "it-drain": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-drain/-/it-drain-2.0.0.tgz", - "integrity": "sha512-oa/5iyBtRs9UW486vPpyDTC0ee3rqx5qlrPI7txIUJcqqtiO5yVozEB6LQrl5ysQYv+P3y/dlKEqwVqlCV0SEA==" - }, - "it-first": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-first/-/it-first-2.0.0.tgz", - "integrity": "sha512-fzZGzVf01exFyIZXNjkpSMFr1eW2+J1K0v018tYY26Dd4f/O3pWlBTdrOBfSQRZwtI8Pst6c7eKhYczWvFs6tA==" - }, - "it-merge": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-merge/-/it-merge-2.0.0.tgz", - "integrity": "sha512-mH4bo/ZrMoU+Wlu7ZuYPNNh9oWZ/GvYbeXZ0zll97+Rp6H4jFu98iu6v9qqXDz//RUjdO9zGh8awzMfOElsjpA==", - "requires": { - "it-pushable": "^3.1.0" - } - }, - "it-sort": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-sort/-/it-sort-2.0.0.tgz", - "integrity": "sha512-yeAE97b5PEjCrWFUiNyR90eJdGslj8FB3cjT84rsc+mzx9lxPyR2zJkYB9ZOJoWE5MMebxqcQCLRT3OSlzo7Zg==", - "requires": { - "it-all": "^2.0.0" - }, - "dependencies": { - "it-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", - "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==" - } - } - }, - "libp2p": { - "version": "0.40.0", - "resolved": "https://registry.npmjs.org/libp2p/-/libp2p-0.40.0.tgz", - "integrity": "sha512-AeLaA+8KIhUhjpXZcs20+Pnf2wIBp+zdSYPD1IgGCF0PlMbTdCvaIqhPzpTSd3+e5k7NZlgpd/BvCOLgQbfm5Q==", - "requires": { - "@achingbrain/nat-port-mapper": "^1.0.3", - "@libp2p/connection": "^4.0.2", - "@libp2p/crypto": "^1.0.4", - "@libp2p/interface-address-manager": "^2.0.0", - "@libp2p/interface-connection": "^3.0.2", - "@libp2p/interface-connection-encrypter": "^3.0.1", - "@libp2p/interface-connection-manager": "^1.1.1", - "@libp2p/interface-content-routing": "^1.0.2", - "@libp2p/interface-dht": "^1.0.1", - "@libp2p/interface-metrics": "^3.0.0", - "@libp2p/interface-peer-discovery": "^1.0.1", - "@libp2p/interface-peer-id": "^1.0.4", - "@libp2p/interface-peer-info": "^1.0.3", - "@libp2p/interface-peer-routing": "^1.0.1", - "@libp2p/interface-peer-store": "^1.2.2", - "@libp2p/interface-pubsub": "^3.0.0", - "@libp2p/interface-registrar": "^2.0.3", - "@libp2p/interface-stream-muxer": "^3.0.0", - "@libp2p/interface-transport": "^2.0.0", - "@libp2p/interfaces": "^3.0.3", - "@libp2p/logger": "^2.0.1", - "@libp2p/multistream-select": "^3.0.0", - "@libp2p/peer-collections": "^2.0.0", - "@libp2p/peer-id": "^1.1.15", - "@libp2p/peer-id-factory": "^1.0.18", - "@libp2p/peer-record": "^4.0.3", - "@libp2p/peer-store": "^5.0.0", - "@libp2p/tracked-map": "^2.0.1", - "@libp2p/utils": "^3.0.2", - "@multiformats/mafmt": "^11.0.2", - "@multiformats/multiaddr": "^11.0.0", - "abortable-iterator": "^4.0.2", - "any-signal": "^3.0.0", - "datastore-core": "^8.0.1", - "err-code": "^3.0.1", - "events": "^3.3.0", - "hashlru": "^2.3.0", - "interface-datastore": "^7.0.0", - "it-all": "^2.0.0", - "it-drain": "^2.0.0", - "it-filter": "^2.0.0", - "it-first": "^2.0.0", - "it-foreach": "^1.0.0", - "it-handshake": "^4.1.2", - "it-length-prefixed": "^8.0.2", - "it-map": "^2.0.0", - "it-merge": "^2.0.0", - "it-pair": "^2.0.2", - "it-pipe": "^2.0.3", - "it-sort": "^2.0.0", - "it-stream-types": "^1.0.4", - "merge-options": "^3.0.4", - "multiformats": "^10.0.0", - "mutable-proxy": "^1.0.0", - "node-forge": "^1.3.1", - "p-fifo": "^1.0.0", - "p-retry": "^5.0.0", - "p-settle": "^5.0.0", - "private-ip": "^2.3.3", - "protons-runtime": "^4.0.1", - "rate-limiter-flexible": "^2.3.11", - "retimer": "^3.0.0", - "sanitize-filename": "^1.6.3", - "set-delayed-interval": "^1.0.0", - "timeout-abort-controller": "^3.0.0", - "uint8arraylist": "^2.3.2", - "uint8arrays": "^4.0.2", - "wherearewe": "^2.0.0", - "xsalsa20": "^1.1.0" - }, - "dependencies": { - "it-all": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-all/-/it-all-2.0.0.tgz", - "integrity": "sha512-I/yi9ogTY59lFxtfsDSlI9w9QZtC/5KJt6g7CPPBJJh2xql2ZS7Ghcp9hoqDDbc4QfwQvtx8Loy0zlKQ8H5gFg==" - }, - "it-filter": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-filter/-/it-filter-2.0.0.tgz", - "integrity": "sha512-E68+zzoNNI7MxdH1T4lUTgwpCyEnymlH349Qg2mcvsqLmYRkaZLM4NfZZ0hUuH7/5DkWXubQSDOYH396va8mpg==" - }, - "it-foreach": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/it-foreach/-/it-foreach-1.0.0.tgz", - "integrity": "sha512-2j5HK1P6aMwEvgL6K5nzUwOk+81B/mjt05PxiSspFEKwJnqy1LfJYlLLS6llBoM+NdoUxf6EsBCHidFGmsXvhw==" - }, - "it-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/it-map/-/it-map-2.0.0.tgz", - "integrity": "sha512-mLgtk/NZaN7NZ06iLrMXCA6jjhtZO0vZT5Ocsp31H+nsGI18RSPVmUbFyA1sWx7q+g92J22Sixya7T2QSSAwfA==" - } - } - }, - "long": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/long/-/long-5.2.0.tgz", - "integrity": "sha512-9RTUNjK60eJbx3uz+TEGF7fUr29ZDxR5QzXcyDpeSfeH28S9ycINflOgOlppit5U+4kNTe83KQnMEerw7GmE8w==" - }, "multiformats": { "version": "10.0.2", "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-10.0.2.tgz", "integrity": "sha512-nJEHLFOYhO4L+aNApHhCnWqa31FyqAHv9Q77AhmwU3KsM2f1j7tuJpCk5ByZ33smzycNCpSG5klNIejIyfFx2A==" }, - "protobufjs": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.1.2.tgz", - "integrity": "sha512-4ZPTPkXCdel3+L81yw3dG6+Kq3umdWKh7Dc7GW/CpNk4SX3hK58iPCWeCyhVTDrbkNeKrYNZ7EojM5WDaEWTLQ==", - "requires": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/node": ">=13.7.0", - "long": "^5.0.0" - } - }, - "protons-runtime": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-4.0.1.tgz", - "integrity": "sha512-SPeV+8TzJAp5UJYPV7vJkLRi08CP0DksxpKK60rcNaZSPkMBQwc0jQrmkHqwc5P0cYbZzKsdYrUBwRrDLrzTfQ==", - "requires": { - "protobufjs": "^7.0.0", - "uint8arraylist": "^2.3.2" - } - }, "uint8arrays": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-4.0.2.tgz", diff --git a/packages/core/package.json b/packages/core/package.json index 35a156b0a2..6330c6e139 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -79,10 +79,10 @@ "nwaku:build": "(PROC=$(nproc --all 2>/dev/null || echo 2); cd ../../nwaku; make -j$PROC update; NIMFLAGS=\"-d:chronicles_colors=off -d:chronicles_sinks=textlines -d:chronicles_log_level=TRACE\" make -j$PROC wakunode2)", "nwaku:force-build": "(cd ../../nwaku && rm -rf ./build/ ./vendor) && run-s nwaku:build", "check": "run-s check:*", + "check:tsc": "tsc -p tsconfig.dev.json", "check:lint": "eslint src --ext .ts", "check:prettier": "prettier . --list-different", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", - "check:tsc": "tsc -p tsconfig.dev.json", "test": "run-s test:*", "test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha", "test:browser": "karma start karma.conf.cjs", diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index f78145d5a3..cef0c3a427 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -14,7 +14,7 @@ export * as proto_message from "./proto/message"; export * as proto_topic_only_message from "./proto/topic_only_message"; export * as waku from "./lib/waku"; -export { WakuNode, Protocols } from "./lib/waku"; +export { WakuNode } from "./lib/waku"; export * as waku_filter from "./lib/waku_filter"; export { WakuFilter } from "./lib/waku_filter"; diff --git a/packages/core/src/lib/to_proto_message.ts b/packages/core/src/lib/to_proto_message.ts index edb8a7695d..a2a60fd0c4 100644 --- a/packages/core/src/lib/to_proto_message.ts +++ b/packages/core/src/lib/to_proto_message.ts @@ -1,6 +1,6 @@ -import { WakuMessage as WakuMessageProto } from "../proto/message"; +import { ProtoMessage } from "@waku/interfaces"; -import { ProtoMessage } from "./interfaces"; +import { WakuMessage as WakuMessageProto } from "../proto/message"; const EmptyMessage: ProtoMessage = { payload: undefined, diff --git a/packages/core/src/lib/wait_for_remote_peer.ts b/packages/core/src/lib/wait_for_remote_peer.ts index dd58bc13d3..caa254239a 100644 --- a/packages/core/src/lib/wait_for_remote_peer.ts +++ b/packages/core/src/lib/wait_for_remote_peer.ts @@ -1,26 +1,15 @@ -import type { GossipSub } from "@chainsafe/libp2p-gossipsub"; -import { Peer, PeerProtocolsChangeData } from "@libp2p/interface-peer-store"; +import { PeerProtocolsChangeData } from "@libp2p/interface-peer-store"; +import type { PointToPointProtocol, Relay, Waku } from "@waku/interfaces"; +import { Protocols } from "@waku/interfaces"; import debug from "debug"; -import type { Libp2p } from "libp2p"; import { pEvent } from "p-event"; -import type { Waku } from "./interfaces"; -import { Protocols } from "./waku"; import { FilterCodec } from "./waku_filter"; import { LightPushCodec } from "./waku_light_push"; import { StoreCodec } from "./waku_store"; const log = debug("waku:wait-for-remote-peer"); -interface WakuProtocol { - libp2p: Libp2p; - peers: () => Promise; -} - -interface WakuGossipSubProtocol extends GossipSub { - getMeshPeers: () => string[]; -} - /** * Wait for a remote peer to be ready given the passed protocols. * Must be used after attempting to connect to nodes, using @@ -90,7 +79,7 @@ export async function waitForRemotePeer( * Wait for a peer with the given protocol to be connected. */ async function waitForConnectedPeer( - waku: WakuProtocol, + waku: PointToPointProtocol, codecs: string[] ): Promise { const peers = await waku.peers(); @@ -119,9 +108,7 @@ async function waitForConnectedPeer( * Wait for a peer with the given protocol to be connected and in the gossipsub * mesh. */ -async function waitForGossipSubPeerInMesh( - waku: WakuGossipSubProtocol -): Promise { +async function waitForGossipSubPeerInMesh(waku: Relay): Promise { let peers = waku.getMeshPeers(); while (peers.length == 0) { diff --git a/packages/core/src/lib/waku.ts b/packages/core/src/lib/waku.ts index ca8449c02c..f792eb6c56 100644 --- a/packages/core/src/lib/waku.ts +++ b/packages/core/src/lib/waku.ts @@ -4,10 +4,11 @@ import type { PubSub } from "@libp2p/interface-pubsub"; import { peerIdFromString } from "@libp2p/peer-id"; import type { Multiaddr } from "@multiformats/multiaddr"; import { multiaddr } from "@multiformats/multiaddr"; +import type { Waku } from "@waku/interfaces"; +import { Protocols } from "@waku/interfaces"; import debug from "debug"; import type { Libp2p } from "libp2p"; -import { Waku } from "./interfaces"; import { FilterCodec, WakuFilter } from "./waku_filter"; import { LightPushCodec, WakuLightPush } from "./waku_light_push"; import { EncoderV0 } from "./waku_message/version_0"; @@ -21,13 +22,6 @@ export const DefaultRelayKeepAliveValueSecs = 5 * 60; const log = debug("waku:waku"); -export enum Protocols { - Relay = "relay", - Store = "store", - LightPush = "lightpush", - Filter = "filter", -} - export interface WakuOptions { /** * Set keep alive frequency in seconds: Waku will send a `/ipfs/ping/1.0.0` diff --git a/packages/core/src/lib/waku_filter/index.ts b/packages/core/src/lib/waku_filter/index.ts index 65e6b45981..9b526b5d45 100644 --- a/packages/core/src/lib/waku_filter/index.ts +++ b/packages/core/src/lib/waku_filter/index.ts @@ -2,6 +2,13 @@ import type { Stream } from "@libp2p/interface-connection"; import type { PeerId } from "@libp2p/interface-peer-id"; import type { Peer } from "@libp2p/interface-peer-store"; import type { IncomingStreamData } from "@libp2p/interface-registrar"; +import type { + Callback, + Decoder, + Filter, + Message, + ProtocolOptions, +} from "@waku/interfaces"; import debug from "debug"; import all from "it-all"; import * as lp from "it-length-prefixed"; @@ -11,7 +18,6 @@ import type { Libp2p } from "libp2p"; import { WakuMessage as WakuMessageProto } from "../../proto/message"; import { DefaultPubSubTopic } from "../constants"; import { groupByContentTopic } from "../group_by"; -import { Decoder, Message } from "../interfaces"; import { selectConnection } from "../select_connection"; import { getPeersForProtocol, @@ -39,21 +45,6 @@ export interface CreateOptions { pubSubTopic?: string; } -export type FilterSubscriptionOpts = { - /** - * The Pubsub topic for the subscription - */ - pubsubTopic?: string; - /** - * Optionally specify a PeerId for the subscription. If not included, will use a random peer. - */ - peerId?: PeerId; -}; - -export type FilterCallback = ( - msg: T -) => void | Promise; - export type UnsubscribeFunction = () => Promise; /** @@ -63,9 +54,9 @@ export type UnsubscribeFunction = () => Promise; * - https://github.com/status-im/go-waku/issues/245 * - https://github.com/status-im/nwaku/issues/948 */ -export class WakuFilter { +export class WakuFilter implements Filter { pubSubTopic: string; - private subscriptions: Map>; + private subscriptions: Map>; private decoders: Map< string, // content topic Set> @@ -88,8 +79,8 @@ export class WakuFilter { */ async subscribe( decoders: Decoder[], - callback: FilterCallback, - opts?: FilterSubscriptionOpts + callback: Callback, + opts?: ProtocolOptions ): Promise { const topic = opts?.pubsubTopic ?? this.pubSubTopic; @@ -212,7 +203,7 @@ export class WakuFilter { } } - private addCallback(requestId: string, callback: FilterCallback): void { + private addCallback(requestId: string, callback: Callback): void { this.subscriptions.set(requestId, callback); } diff --git a/packages/core/src/lib/waku_light_push/index.ts b/packages/core/src/lib/waku_light_push/index.ts index 0674213dcd..95ac899349 100644 --- a/packages/core/src/lib/waku_light_push/index.ts +++ b/packages/core/src/lib/waku_light_push/index.ts @@ -1,5 +1,11 @@ import type { PeerId } from "@libp2p/interface-peer-id"; import type { Peer } from "@libp2p/interface-peer-store"; +import type { + Encoder, + Message, + ProtocolOptions, + SendResult, +} from "@waku/interfaces"; import debug from "debug"; import all from "it-all"; import * as lp from "it-length-prefixed"; @@ -9,7 +15,6 @@ import { Uint8ArrayList } from "uint8arraylist"; import { PushResponse } from "../../proto/light_push"; import { DefaultPubSubTopic } from "../constants"; -import { Encoder, Message, SendResult } from "../interfaces"; import { selectConnection } from "../select_connection"; import { getPeersForProtocol, @@ -36,11 +41,6 @@ export interface CreateOptions { pubSubTopic?: string; } -export interface PushOptions { - peerId?: PeerId; - pubSubTopic?: string; -} - /** * Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/). */ @@ -54,9 +54,9 @@ export class WakuLightPush { async push( encoder: Encoder, message: Partial, - opts?: PushOptions + opts?: ProtocolOptions ): Promise { - const pubSubTopic = opts?.pubSubTopic ? opts.pubSubTopic : this.pubSubTopic; + const pubSubTopic = opts?.pubsubTopic ? opts.pubsubTopic : this.pubSubTopic; const res = await selectPeerForProtocol( this.libp2p.peerStore, diff --git a/packages/core/src/lib/waku_message/topic_only_message.ts b/packages/core/src/lib/waku_message/topic_only_message.ts index f72bb8bd63..9514847d21 100644 --- a/packages/core/src/lib/waku_message/topic_only_message.ts +++ b/packages/core/src/lib/waku_message/topic_only_message.ts @@ -1,7 +1,7 @@ +import type { Decoder, Message, ProtoMessage } from "@waku/interfaces"; import debug from "debug"; import * as proto from "../../proto/topic_only_message"; -import type { Decoder, Message, ProtoMessage } from "../interfaces"; const log = debug("waku:message:topic-only"); diff --git a/packages/core/src/lib/waku_message/version_0.ts b/packages/core/src/lib/waku_message/version_0.ts index aa83150f8d..4220a20c9c 100644 --- a/packages/core/src/lib/waku_message/version_0.ts +++ b/packages/core/src/lib/waku_message/version_0.ts @@ -1,8 +1,13 @@ +import type { + Decoder, + Encoder, + Message, + ProtoMessage, + RateLimitProof, +} from "@waku/interfaces"; import debug from "debug"; import * as proto from "../../proto/message"; -import { Decoder, Message, ProtoMessage, RateLimitProof } from "../interfaces"; -import { Encoder } from "../interfaces"; const log = debug("waku:message:version-0"); diff --git a/packages/core/src/lib/waku_message/version_1.ts b/packages/core/src/lib/waku_message/version_1.ts index 0a9a6117c6..3b6d46a8e3 100644 --- a/packages/core/src/lib/waku_message/version_1.ts +++ b/packages/core/src/lib/waku_message/version_1.ts @@ -1,9 +1,9 @@ import * as secp from "@noble/secp256k1"; +import type { Decoder, Encoder, Message, ProtoMessage } from "@waku/interfaces"; import debug from "debug"; import * as proto from "../../proto/message"; import { keccak256, randomBytes, sign } from "../crypto"; -import { Decoder, Encoder, Message, ProtoMessage } from "../interfaces"; import { concat, hexToBytes } from "../utils"; import { Symmetric } from "./constants"; diff --git a/packages/core/src/lib/waku_relay/index.ts b/packages/core/src/lib/waku_relay/index.ts index b5cbeb48e6..420bf10cbe 100644 --- a/packages/core/src/lib/waku_relay/index.ts +++ b/packages/core/src/lib/waku_relay/index.ts @@ -8,10 +8,17 @@ import { TopicStr, } from "@chainsafe/libp2p-gossipsub/dist/src/types"; import { SignaturePolicy } from "@chainsafe/libp2p-gossipsub/types"; +import type { + Callback, + Decoder, + Encoder, + Message, + Relay, + SendResult, +} from "@waku/interfaces"; import debug from "debug"; import { DefaultPubSubTopic } from "../constants"; -import { Decoder, Encoder, Message, SendResult } from "../interfaces"; import { pushOrInitMapSet } from "../push_or_init_map"; import { TopicOnlyDecoder } from "../waku_message/topic_only_message"; @@ -19,8 +26,6 @@ import * as constants from "./constants"; const log = debug("waku:relay"); -export type Callback = (msg: T) => void; - export type Observer = { decoder: Decoder; callback: Callback; @@ -49,7 +54,7 @@ export type CreateOptions = { * * @implements {require('libp2p-interfaces/src/pubsub')} */ -export class WakuRelay extends GossipSub { +export class WakuRelay extends GossipSub implements Relay { pubSubTopic: string; defaultDecoder: Decoder; public static multicodec: string = constants.RelayCodecs[0]; diff --git a/packages/core/src/lib/waku_store/index.ts b/packages/core/src/lib/waku_store/index.ts index 9a7f833b1f..9f02bec8dd 100644 --- a/packages/core/src/lib/waku_store/index.ts +++ b/packages/core/src/lib/waku_store/index.ts @@ -1,6 +1,7 @@ import type { Connection } from "@libp2p/interface-connection"; import type { PeerId } from "@libp2p/interface-peer-id"; import { Peer } from "@libp2p/interface-peer-store"; +import { Decoder, Message } from "@waku/interfaces"; import debug from "debug"; import all from "it-all"; import * as lp from "it-length-prefixed"; @@ -10,7 +11,6 @@ import { Uint8ArrayList } from "uint8arraylist"; import * as proto from "../../proto/store"; import { DefaultPubSubTopic } from "../constants"; -import { Decoder, Message } from "../interfaces"; import { selectConnection } from "../select_connection"; import { getPeersForProtocol, selectPeerForProtocol } from "../select_peer"; import { toProtoMessage } from "../to_proto_message"; diff --git a/packages/create/package.json b/packages/create/package.json index b094e5ea30..ff58c21b75 100644 --- a/packages/create/package.json +++ b/packages/create/package.json @@ -63,10 +63,10 @@ "node": ">=16" }, "dependencies": { + "@waku/interfaces": "*", "@waku/core": "*" }, "devDependencies": { - "@waku/interfaces": "*", "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^13.3.0", diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 2a7b21152d..24d6822bf1 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -50,6 +50,14 @@ "engines": { "node": ">=16" }, + "dependencies": { + "@chainsafe/libp2p-gossipsub": "^4.1.1", + "@libp2p/interface-connection": "^3.0.2", + "@libp2p/interface-peer-id": "^1.0.5", + "@libp2p/interface-peer-store": "^1.2.2", + "@multiformats/multiaddr": "^11.0.6", + "libp2p": "0.38.0" + }, "devDependencies": { "@semantic-release/changelog": "^6.0.1", "@semantic-release/commit-analyzer": "^9.0.2", @@ -166,11 +174,5 @@ "CHANGELOG.md", "LICENSE", "README.md" - ], - "dependencies": { - "@libp2p/interface-connection": "^3.0.2", - "@libp2p/interface-peer-id": "^1.0.5", - "@multiformats/multiaddr": "^11.0.6", - "libp2p": "^0.40.0" - } + ] } diff --git a/packages/interfaces/src/index.ts b/packages/interfaces/src/index.ts index cd804aa97f..105230f424 100644 --- a/packages/interfaces/src/index.ts +++ b/packages/interfaces/src/index.ts @@ -1,5 +1,7 @@ +import type { GossipSub } from "@chainsafe/libp2p-gossipsub"; import type { Stream } from "@libp2p/interface-connection"; import type { PeerId } from "@libp2p/interface-peer-id"; +import type { Peer } from "@libp2p/interface-peer-store"; import type { Multiaddr } from "@multiformats/multiaddr"; import type { Libp2p } from "libp2p"; @@ -10,6 +12,11 @@ export enum Protocols { Filter = "filter", } +export interface PointToPointProtocol { + libp2p: Libp2p; + peers: () => Promise; +} + export type ProtocolOptions = { pubsubTopic?: string; /** @@ -20,7 +27,7 @@ export type ProtocolOptions = { export type Callback = (msg: T) => void | Promise; -export interface Filter { +export interface Filter extends PointToPointProtocol { subscribe: ( decoders: Decoder[], callback: Callback, @@ -28,7 +35,7 @@ export interface Filter { ) => Promise<() => Promise>; } -export interface LightPush { +export interface LightPush extends PointToPointProtocol { push: ( encoder: Encoder, message: Partial, @@ -70,7 +77,7 @@ export type StoreQueryOptions = { timeFilter?: TimeFilter; } & ProtocolOptions; -export interface Store { +export interface Store extends PointToPointProtocol { queryOrderedCallback: ( decoders: Decoder[], callback: (message: T) => Promise | boolean | void, @@ -89,12 +96,13 @@ export interface Store { ) => AsyncGenerator[]>; } -export interface Relay { +export interface Relay extends GossipSub { send: (encoder: Encoder, message: Partial) => Promise; addObserver: ( decoder: Decoder, callback: Callback ) => () => void; + getMeshPeers: () => string[]; } export interface Waku {