fix: @waku/interfaces

This commit is contained in:
fryorcraken.eth 2022-11-01 16:30:24 +11:00
parent 4eddad3166
commit 057507f94f
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
16 changed files with 81 additions and 646 deletions

575
package-lock.json generated
View File

@ -22519,10 +22519,12 @@
"version": "0.0.1", "version": "0.0.1",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"dependencies": { "dependencies": {
"@chainsafe/libp2p-gossipsub": "^4.1.1",
"@libp2p/interface-connection": "^3.0.2", "@libp2p/interface-connection": "^3.0.2",
"@libp2p/interface-peer-id": "^1.0.5", "@libp2p/interface-peer-id": "^1.0.5",
"@libp2p/interface-peer-store": "^1.2.2",
"@multiformats/multiaddr": "^11.0.6", "@multiformats/multiaddr": "^11.0.6",
"libp2p": "^0.40.0" "libp2p": "0.38.0"
}, },
"devDependencies": { "devDependencies": {
"@semantic-release/changelog": "^6.0.1", "@semantic-release/changelog": "^6.0.1",
@ -22551,19 +22553,6 @@
"node": ">=16" "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": { "packages/interfaces/node_modules/@libp2p/interface-connection": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.2.tgz", "resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.2.tgz",
@ -22580,98 +22569,6 @@
"npm": ">=7.0.0" "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": { "packages/interfaces/node_modules/@multiformats/multiaddr": {
"version": "11.0.6", "version": "11.0.6",
"resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-11.0.6.tgz", "resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-11.0.6.tgz",
@ -22689,178 +22586,6 @@
"npm": ">=7.0.0" "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": { "packages/interfaces/node_modules/multiformats": {
"version": "10.0.2", "version": "10.0.2",
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-10.0.2.tgz", "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-10.0.2.tgz",
@ -22870,45 +22595,6 @@
"npm": ">=7.0.0" "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": { "packages/interfaces/node_modules/uint8arrays": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-4.0.2.tgz", "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-4.0.2.tgz",
@ -27276,9 +26962,11 @@
"@waku/interfaces": { "@waku/interfaces": {
"version": "file:packages/interfaces", "version": "file:packages/interfaces",
"requires": { "requires": {
"@libp2p/interface-connection": "*", "@chainsafe/libp2p-gossipsub": "^4.1.1",
"@libp2p/interface-peer-id": "*", "@libp2p/interface-connection": "^3.0.2",
"@multiformats/multiaddr": "*", "@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/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^9.0.2", "@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1", "@semantic-release/git": "^10.0.1",
@ -27294,7 +26982,7 @@
"eslint-plugin-functional": "^4.0.2", "eslint-plugin-functional": "^4.0.2",
"eslint-plugin-import": "^2.25.3", "eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"libp2p": "*", "libp2p": "0.38.0",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "^2.1.1", "prettier": "^2.1.1",
"semantic-release": "^19.0.5", "semantic-release": "^19.0.5",
@ -27303,15 +26991,6 @@
"typescript": "^4.6.3" "typescript": "^4.6.3"
}, },
"dependencies": { "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": { "@libp2p/interface-connection": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.2.tgz", "resolved": "https://registry.npmjs.org/@libp2p/interface-connection/-/interface-connection-3.0.2.tgz",
@ -27324,78 +27003,6 @@
"uint8arraylist": "^2.1.1" "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": { "@multiformats/multiaddr": {
"version": "11.0.6", "version": "11.0.6",
"resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-11.0.6.tgz", "resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-11.0.6.tgz",
@ -27409,175 +27016,11 @@
"varint": "^6.0.0" "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": { "multiformats": {
"version": "10.0.2", "version": "10.0.2",
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-10.0.2.tgz", "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-10.0.2.tgz",
"integrity": "sha512-nJEHLFOYhO4L+aNApHhCnWqa31FyqAHv9Q77AhmwU3KsM2f1j7tuJpCk5ByZ33smzycNCpSG5klNIejIyfFx2A==" "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": { "uint8arrays": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-4.0.2.tgz", "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-4.0.2.tgz",

View File

@ -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: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", "nwaku:force-build": "(cd ../../nwaku && rm -rf ./build/ ./vendor) && run-s nwaku:build",
"check": "run-s check:*", "check": "run-s check:*",
"check:tsc": "tsc -p tsconfig.dev.json",
"check:lint": "eslint src --ext .ts", "check:lint": "eslint src --ext .ts",
"check:prettier": "prettier . --list-different", "check:prettier": "prettier . --list-different",
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
"check:tsc": "tsc -p tsconfig.dev.json",
"test": "run-s test:*", "test": "run-s test:*",
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha", "test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha",
"test:browser": "karma start karma.conf.cjs", "test:browser": "karma start karma.conf.cjs",

View File

@ -14,7 +14,7 @@ export * as proto_message from "./proto/message";
export * as proto_topic_only_message from "./proto/topic_only_message"; export * as proto_topic_only_message from "./proto/topic_only_message";
export * as waku from "./lib/waku"; 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 * as waku_filter from "./lib/waku_filter";
export { WakuFilter } from "./lib/waku_filter"; export { WakuFilter } from "./lib/waku_filter";

View File

@ -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 = { const EmptyMessage: ProtoMessage = {
payload: undefined, payload: undefined,

View File

@ -1,26 +1,15 @@
import type { GossipSub } from "@chainsafe/libp2p-gossipsub"; import { PeerProtocolsChangeData } from "@libp2p/interface-peer-store";
import { Peer, PeerProtocolsChangeData } from "@libp2p/interface-peer-store"; import type { PointToPointProtocol, Relay, Waku } from "@waku/interfaces";
import { Protocols } from "@waku/interfaces";
import debug from "debug"; import debug from "debug";
import type { Libp2p } from "libp2p";
import { pEvent } from "p-event"; import { pEvent } from "p-event";
import type { Waku } from "./interfaces";
import { Protocols } from "./waku";
import { FilterCodec } from "./waku_filter"; import { FilterCodec } from "./waku_filter";
import { LightPushCodec } from "./waku_light_push"; import { LightPushCodec } from "./waku_light_push";
import { StoreCodec } from "./waku_store"; import { StoreCodec } from "./waku_store";
const log = debug("waku:wait-for-remote-peer"); const log = debug("waku:wait-for-remote-peer");
interface WakuProtocol {
libp2p: Libp2p;
peers: () => Promise<Peer[]>;
}
interface WakuGossipSubProtocol extends GossipSub {
getMeshPeers: () => string[];
}
/** /**
* Wait for a remote peer to be ready given the passed protocols. * Wait for a remote peer to be ready given the passed protocols.
* Must be used after attempting to connect to nodes, using * 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. * Wait for a peer with the given protocol to be connected.
*/ */
async function waitForConnectedPeer( async function waitForConnectedPeer(
waku: WakuProtocol, waku: PointToPointProtocol,
codecs: string[] codecs: string[]
): Promise<void> { ): Promise<void> {
const peers = await waku.peers(); 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 * Wait for a peer with the given protocol to be connected and in the gossipsub
* mesh. * mesh.
*/ */
async function waitForGossipSubPeerInMesh( async function waitForGossipSubPeerInMesh(waku: Relay): Promise<void> {
waku: WakuGossipSubProtocol
): Promise<void> {
let peers = waku.getMeshPeers(); let peers = waku.getMeshPeers();
while (peers.length == 0) { while (peers.length == 0) {

View File

@ -4,10 +4,11 @@ import type { PubSub } from "@libp2p/interface-pubsub";
import { peerIdFromString } from "@libp2p/peer-id"; import { peerIdFromString } from "@libp2p/peer-id";
import type { Multiaddr } from "@multiformats/multiaddr"; import type { Multiaddr } from "@multiformats/multiaddr";
import { 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 debug from "debug";
import type { Libp2p } from "libp2p"; import type { Libp2p } from "libp2p";
import { Waku } from "./interfaces";
import { FilterCodec, WakuFilter } from "./waku_filter"; import { FilterCodec, WakuFilter } from "./waku_filter";
import { LightPushCodec, WakuLightPush } from "./waku_light_push"; import { LightPushCodec, WakuLightPush } from "./waku_light_push";
import { EncoderV0 } from "./waku_message/version_0"; import { EncoderV0 } from "./waku_message/version_0";
@ -21,13 +22,6 @@ export const DefaultRelayKeepAliveValueSecs = 5 * 60;
const log = debug("waku:waku"); const log = debug("waku:waku");
export enum Protocols {
Relay = "relay",
Store = "store",
LightPush = "lightpush",
Filter = "filter",
}
export interface WakuOptions { export interface WakuOptions {
/** /**
* Set keep alive frequency in seconds: Waku will send a `/ipfs/ping/1.0.0` * Set keep alive frequency in seconds: Waku will send a `/ipfs/ping/1.0.0`

View File

@ -2,6 +2,13 @@ import type { Stream } from "@libp2p/interface-connection";
import type { PeerId } from "@libp2p/interface-peer-id"; import type { PeerId } from "@libp2p/interface-peer-id";
import type { Peer } from "@libp2p/interface-peer-store"; import type { Peer } from "@libp2p/interface-peer-store";
import type { IncomingStreamData } from "@libp2p/interface-registrar"; import type { IncomingStreamData } from "@libp2p/interface-registrar";
import type {
Callback,
Decoder,
Filter,
Message,
ProtocolOptions,
} from "@waku/interfaces";
import debug from "debug"; import debug from "debug";
import all from "it-all"; import all from "it-all";
import * as lp from "it-length-prefixed"; import * as lp from "it-length-prefixed";
@ -11,7 +18,6 @@ import type { Libp2p } from "libp2p";
import { WakuMessage as WakuMessageProto } from "../../proto/message"; import { WakuMessage as WakuMessageProto } from "../../proto/message";
import { DefaultPubSubTopic } from "../constants"; import { DefaultPubSubTopic } from "../constants";
import { groupByContentTopic } from "../group_by"; import { groupByContentTopic } from "../group_by";
import { Decoder, Message } from "../interfaces";
import { selectConnection } from "../select_connection"; import { selectConnection } from "../select_connection";
import { import {
getPeersForProtocol, getPeersForProtocol,
@ -39,21 +45,6 @@ export interface CreateOptions {
pubSubTopic?: string; 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<T extends Message> = (
msg: T
) => void | Promise<void>;
export type UnsubscribeFunction = () => Promise<void>; export type UnsubscribeFunction = () => Promise<void>;
/** /**
@ -63,9 +54,9 @@ export type UnsubscribeFunction = () => Promise<void>;
* - https://github.com/status-im/go-waku/issues/245 * - https://github.com/status-im/go-waku/issues/245
* - https://github.com/status-im/nwaku/issues/948 * - https://github.com/status-im/nwaku/issues/948
*/ */
export class WakuFilter { export class WakuFilter implements Filter {
pubSubTopic: string; pubSubTopic: string;
private subscriptions: Map<string, FilterCallback<any>>; private subscriptions: Map<string, Callback<any>>;
private decoders: Map< private decoders: Map<
string, // content topic string, // content topic
Set<Decoder<any>> Set<Decoder<any>>
@ -88,8 +79,8 @@ export class WakuFilter {
*/ */
async subscribe<T extends Message>( async subscribe<T extends Message>(
decoders: Decoder<T>[], decoders: Decoder<T>[],
callback: FilterCallback<T>, callback: Callback<T>,
opts?: FilterSubscriptionOpts opts?: ProtocolOptions
): Promise<UnsubscribeFunction> { ): Promise<UnsubscribeFunction> {
const topic = opts?.pubsubTopic ?? this.pubSubTopic; const topic = opts?.pubsubTopic ?? this.pubSubTopic;
@ -212,7 +203,7 @@ export class WakuFilter {
} }
} }
private addCallback(requestId: string, callback: FilterCallback<any>): void { private addCallback(requestId: string, callback: Callback<any>): void {
this.subscriptions.set(requestId, callback); this.subscriptions.set(requestId, callback);
} }

View File

@ -1,5 +1,11 @@
import type { PeerId } from "@libp2p/interface-peer-id"; import type { PeerId } from "@libp2p/interface-peer-id";
import type { Peer } from "@libp2p/interface-peer-store"; import type { Peer } from "@libp2p/interface-peer-store";
import type {
Encoder,
Message,
ProtocolOptions,
SendResult,
} from "@waku/interfaces";
import debug from "debug"; import debug from "debug";
import all from "it-all"; import all from "it-all";
import * as lp from "it-length-prefixed"; import * as lp from "it-length-prefixed";
@ -9,7 +15,6 @@ import { Uint8ArrayList } from "uint8arraylist";
import { PushResponse } from "../../proto/light_push"; import { PushResponse } from "../../proto/light_push";
import { DefaultPubSubTopic } from "../constants"; import { DefaultPubSubTopic } from "../constants";
import { Encoder, Message, SendResult } from "../interfaces";
import { selectConnection } from "../select_connection"; import { selectConnection } from "../select_connection";
import { import {
getPeersForProtocol, getPeersForProtocol,
@ -36,11 +41,6 @@ export interface CreateOptions {
pubSubTopic?: string; pubSubTopic?: string;
} }
export interface PushOptions {
peerId?: PeerId;
pubSubTopic?: string;
}
/** /**
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/). * Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
*/ */
@ -54,9 +54,9 @@ export class WakuLightPush {
async push( async push(
encoder: Encoder, encoder: Encoder,
message: Partial<Message>, message: Partial<Message>,
opts?: PushOptions opts?: ProtocolOptions
): Promise<SendResult> { ): Promise<SendResult> {
const pubSubTopic = opts?.pubSubTopic ? opts.pubSubTopic : this.pubSubTopic; const pubSubTopic = opts?.pubsubTopic ? opts.pubsubTopic : this.pubSubTopic;
const res = await selectPeerForProtocol( const res = await selectPeerForProtocol(
this.libp2p.peerStore, this.libp2p.peerStore,

View File

@ -1,7 +1,7 @@
import type { Decoder, Message, ProtoMessage } from "@waku/interfaces";
import debug from "debug"; import debug from "debug";
import * as proto from "../../proto/topic_only_message"; import * as proto from "../../proto/topic_only_message";
import type { Decoder, Message, ProtoMessage } from "../interfaces";
const log = debug("waku:message:topic-only"); const log = debug("waku:message:topic-only");

View File

@ -1,8 +1,13 @@
import type {
Decoder,
Encoder,
Message,
ProtoMessage,
RateLimitProof,
} from "@waku/interfaces";
import debug from "debug"; import debug from "debug";
import * as proto from "../../proto/message"; import * as proto from "../../proto/message";
import { Decoder, Message, ProtoMessage, RateLimitProof } from "../interfaces";
import { Encoder } from "../interfaces";
const log = debug("waku:message:version-0"); const log = debug("waku:message:version-0");

View File

@ -1,9 +1,9 @@
import * as secp from "@noble/secp256k1"; import * as secp from "@noble/secp256k1";
import type { Decoder, Encoder, Message, ProtoMessage } from "@waku/interfaces";
import debug from "debug"; import debug from "debug";
import * as proto from "../../proto/message"; import * as proto from "../../proto/message";
import { keccak256, randomBytes, sign } from "../crypto"; import { keccak256, randomBytes, sign } from "../crypto";
import { Decoder, Encoder, Message, ProtoMessage } from "../interfaces";
import { concat, hexToBytes } from "../utils"; import { concat, hexToBytes } from "../utils";
import { Symmetric } from "./constants"; import { Symmetric } from "./constants";

View File

@ -8,10 +8,17 @@ import {
TopicStr, TopicStr,
} from "@chainsafe/libp2p-gossipsub/dist/src/types"; } from "@chainsafe/libp2p-gossipsub/dist/src/types";
import { SignaturePolicy } from "@chainsafe/libp2p-gossipsub/types"; import { SignaturePolicy } from "@chainsafe/libp2p-gossipsub/types";
import type {
Callback,
Decoder,
Encoder,
Message,
Relay,
SendResult,
} from "@waku/interfaces";
import debug from "debug"; import debug from "debug";
import { DefaultPubSubTopic } from "../constants"; import { DefaultPubSubTopic } from "../constants";
import { Decoder, Encoder, Message, SendResult } from "../interfaces";
import { pushOrInitMapSet } from "../push_or_init_map"; import { pushOrInitMapSet } from "../push_or_init_map";
import { TopicOnlyDecoder } from "../waku_message/topic_only_message"; import { TopicOnlyDecoder } from "../waku_message/topic_only_message";
@ -19,8 +26,6 @@ import * as constants from "./constants";
const log = debug("waku:relay"); const log = debug("waku:relay");
export type Callback<T extends Message> = (msg: T) => void;
export type Observer<T extends Message> = { export type Observer<T extends Message> = {
decoder: Decoder<T>; decoder: Decoder<T>;
callback: Callback<T>; callback: Callback<T>;
@ -49,7 +54,7 @@ export type CreateOptions = {
* *
* @implements {require('libp2p-interfaces/src/pubsub')} * @implements {require('libp2p-interfaces/src/pubsub')}
*/ */
export class WakuRelay extends GossipSub { export class WakuRelay extends GossipSub implements Relay {
pubSubTopic: string; pubSubTopic: string;
defaultDecoder: Decoder<Message>; defaultDecoder: Decoder<Message>;
public static multicodec: string = constants.RelayCodecs[0]; public static multicodec: string = constants.RelayCodecs[0];

View File

@ -1,6 +1,7 @@
import type { Connection } from "@libp2p/interface-connection"; import type { Connection } from "@libp2p/interface-connection";
import type { PeerId } from "@libp2p/interface-peer-id"; import type { PeerId } from "@libp2p/interface-peer-id";
import { Peer } from "@libp2p/interface-peer-store"; import { Peer } from "@libp2p/interface-peer-store";
import { Decoder, Message } from "@waku/interfaces";
import debug from "debug"; import debug from "debug";
import all from "it-all"; import all from "it-all";
import * as lp from "it-length-prefixed"; import * as lp from "it-length-prefixed";
@ -10,7 +11,6 @@ import { Uint8ArrayList } from "uint8arraylist";
import * as proto from "../../proto/store"; import * as proto from "../../proto/store";
import { DefaultPubSubTopic } from "../constants"; import { DefaultPubSubTopic } from "../constants";
import { Decoder, Message } from "../interfaces";
import { selectConnection } from "../select_connection"; import { selectConnection } from "../select_connection";
import { getPeersForProtocol, selectPeerForProtocol } from "../select_peer"; import { getPeersForProtocol, selectPeerForProtocol } from "../select_peer";
import { toProtoMessage } from "../to_proto_message"; import { toProtoMessage } from "../to_proto_message";

View File

@ -63,10 +63,10 @@
"node": ">=16" "node": ">=16"
}, },
"dependencies": { "dependencies": {
"@waku/interfaces": "*",
"@waku/core": "*" "@waku/core": "*"
}, },
"devDependencies": { "devDependencies": {
"@waku/interfaces": "*",
"@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0", "@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0", "@rollup/plugin-node-resolve": "^13.3.0",

View File

@ -50,6 +50,14 @@
"engines": { "engines": {
"node": ">=16" "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": { "devDependencies": {
"@semantic-release/changelog": "^6.0.1", "@semantic-release/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^9.0.2", "@semantic-release/commit-analyzer": "^9.0.2",
@ -166,11 +174,5 @@
"CHANGELOG.md", "CHANGELOG.md",
"LICENSE", "LICENSE",
"README.md" "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"
}
} }

View File

@ -1,5 +1,7 @@
import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
import type { Stream } from "@libp2p/interface-connection"; import type { Stream } from "@libp2p/interface-connection";
import type { PeerId } from "@libp2p/interface-peer-id"; import type { PeerId } from "@libp2p/interface-peer-id";
import type { Peer } from "@libp2p/interface-peer-store";
import type { Multiaddr } from "@multiformats/multiaddr"; import type { Multiaddr } from "@multiformats/multiaddr";
import type { Libp2p } from "libp2p"; import type { Libp2p } from "libp2p";
@ -10,6 +12,11 @@ export enum Protocols {
Filter = "filter", Filter = "filter",
} }
export interface PointToPointProtocol {
libp2p: Libp2p;
peers: () => Promise<Peer[]>;
}
export type ProtocolOptions = { export type ProtocolOptions = {
pubsubTopic?: string; pubsubTopic?: string;
/** /**
@ -20,7 +27,7 @@ export type ProtocolOptions = {
export type Callback<T extends Message> = (msg: T) => void | Promise<void>; export type Callback<T extends Message> = (msg: T) => void | Promise<void>;
export interface Filter { export interface Filter extends PointToPointProtocol {
subscribe: <T extends Message>( subscribe: <T extends Message>(
decoders: Decoder<T>[], decoders: Decoder<T>[],
callback: Callback<T>, callback: Callback<T>,
@ -28,7 +35,7 @@ export interface Filter {
) => Promise<() => Promise<void>>; ) => Promise<() => Promise<void>>;
} }
export interface LightPush { export interface LightPush extends PointToPointProtocol {
push: ( push: (
encoder: Encoder, encoder: Encoder,
message: Partial<Message>, message: Partial<Message>,
@ -70,7 +77,7 @@ export type StoreQueryOptions = {
timeFilter?: TimeFilter; timeFilter?: TimeFilter;
} & ProtocolOptions; } & ProtocolOptions;
export interface Store { export interface Store extends PointToPointProtocol {
queryOrderedCallback: <T extends Message>( queryOrderedCallback: <T extends Message>(
decoders: Decoder<T>[], decoders: Decoder<T>[],
callback: (message: T) => Promise<void | boolean> | boolean | void, callback: (message: T) => Promise<void | boolean> | boolean | void,
@ -89,12 +96,13 @@ export interface Store {
) => AsyncGenerator<Promise<T | undefined>[]>; ) => AsyncGenerator<Promise<T | undefined>[]>;
} }
export interface Relay { export interface Relay extends GossipSub {
send: (encoder: Encoder, message: Partial<Message>) => Promise<SendResult>; send: (encoder: Encoder, message: Partial<Message>) => Promise<SendResult>;
addObserver: <T extends Message>( addObserver: <T extends Message>(
decoder: Decoder<T>, decoder: Decoder<T>,
callback: Callback<T> callback: Callback<T>
) => () => void; ) => () => void;
getMeshPeers: () => string[];
} }
export interface Waku { export interface Waku {