From afba3210e9aaa141f140865ea2e6851b677dd8c9 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Tue, 20 Apr 2021 16:51:04 +1000 Subject: [PATCH 01/20] Upgrade libp2p to 0.31.0-rc.3 --- package-lock.json | 1175 ++++++++++++++++++++++++++++-------- package.json | 4 +- src/chat/index.ts | 4 +- src/lib/waku.ts | 2 +- src/test_utils/nim_waku.ts | 4 +- 5 files changed, 924 insertions(+), 265 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1088c7bf4d..5bb5270244 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,14 +12,14 @@ "debug": "^4.3.1", "it-concat": "^1.0.3", "it-length-prefixed": "^3.1.0", - "libp2p": "^0.30.0", + "libp2p": "^0.31.0-rc.3", "libp2p-gossipsub": "^0.7.0", "libp2p-mplex": "^0.10.2", "libp2p-noise": "^2.0.5", "libp2p-secio": "^0.13.1", "libp2p-tcp": "^0.15.3", "libp2p-websockets": "^0.15.5", - "multiaddr": "^8.1.2", + "multiaddr": "^9.0.1", "prompt-sync": "^4.2.0", "ts-proto": "^1.79.3", "uuid": "^3.4.0", @@ -7622,15 +7622,6 @@ "resolved": "https://registry.npmjs.org/it-pipe/-/it-pipe-1.1.0.tgz", "integrity": "sha512-lF0/3qTVeth13TOnHVs0BTFaziwQF7m5Gg+E6JV0BXcLKutC92YjSi7bASgkPOXaLEb+YvNZrPorGMBIJvZfxg==" }, - "node_modules/it-protocol-buffers": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/it-protocol-buffers/-/it-protocol-buffers-0.2.1.tgz", - "integrity": "sha512-UbezSc9BZTw0DU7mFS6iG9PXeycJfTDJlFAlniI3x1CRrKeDP+IW6ERPAFskHI3O+wij18Mk7eHgDtFz4Zk65A==", - "dependencies": { - "it-buffer": "^0.1.1", - "it-length-prefixed": "^3.0.0" - } - }, "node_modules/it-pushable": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/it-pushable/-/it-pushable-1.4.2.tgz", @@ -7903,9 +7894,9 @@ } }, "node_modules/libp2p": { - "version": "0.30.10", - "resolved": "https://registry.npmjs.org/libp2p/-/libp2p-0.30.10.tgz", - "integrity": "sha512-TdFLG4CF7/tLF1ypwNM8+q1YshW3+hYWDWYo6IA5Zyhg2MFDPdsUqaX4JLG0EiYHQvVcrUQF8B7rL49YbDHE7Q==", + "version": "0.31.0-rc.3", + "resolved": "https://registry.npmjs.org/libp2p/-/libp2p-0.31.0-rc.3.tgz", + "integrity": "sha512-spYO0bBrAQRWD/bcR0SK0AUdI9EL9/Yi5qB87mTdZKUrSJE3Wa/A1kh7L3k+w2kO42zvy6KbfoTzKQQxaSIbuw==", "dependencies": { "@motrix/nat-api": "^0.3.1", "abort-controller": "^3.0.0", @@ -7915,9 +7906,9 @@ "cids": "^1.1.5", "class-is": "^1.1.0", "debug": "^4.3.1", - "err-code": "^2.0.0", + "err-code": "^3.0.0", "es6-promisify": "^6.1.1", - "events": "^3.2.0", + "events": "^3.3.0", "hashlru": "^2.3.0", "interface-datastore": "^3.0.3", "ipfs-utils": "^6.0.0", @@ -7926,43 +7917,41 @@ "it-drain": "^1.0.3", "it-filter": "^1.0.1", "it-first": "^1.0.4", - "it-handshake": "^1.0.2", - "it-length-prefixed": "^3.1.0", + "it-handshake": "^2.0.0", + "it-length-prefixed": "^5.0.2", "it-map": "^1.0.4", "it-merge": "1.0.0", "it-pipe": "^1.1.0", - "it-protocol-buffers": "^0.2.0", "it-take": "1.0.0", "libp2p-crypto": "^0.19.0", - "libp2p-interfaces": "^0.8.1", - "libp2p-utils": "^0.2.2", - "mafmt": "^8.0.0", + "libp2p-interfaces": "^0.10.1", + "libp2p-utils": "^0.3.1", + "mafmt": "^9.0.0", "merge-options": "^3.0.4", "moving-average": "^1.0.0", - "multiaddr": "^8.1.0", - "multicodec": "^2.1.0", - "multihashing-async": "^2.0.1", - "multistream-select": "^1.0.0", + "multiaddr": "^9.0.1", + "multicodec": "^3.0.1", + "multihashing-async": "^2.1.2", + "multistream-select": "^2.0.0", "mutable-proxy": "^1.0.0", "node-forge": "^0.10.0", "p-any": "^3.0.0", "p-fifo": "^1.0.0", - "p-retry": "^4.2.0", - "p-settle": "^4.0.1", + "p-retry": "^4.4.0", + "p-settle": "^4.1.1", "peer-id": "^0.14.2", - "private-ip": "^2.0.0", - "protons": "^2.0.0", - "retimer": "^2.0.0", + "private-ip": "^2.1.0", + "protobufjs": "^6.10.2", + "retimer": "^3.0.0", "sanitize-filename": "^1.6.3", "set-delayed-interval": "^1.0.0", "streaming-iterables": "^5.0.2", "timeout-abort-controller": "^1.1.1", "varint": "^6.0.0", - "xsalsa20": "^1.0.2" + "xsalsa20": "^1.1.0" }, "engines": { - "node": ">=12.0.0", - "npm": ">=6.0.0" + "node": ">=14.0.0" } }, "node_modules/libp2p-crypto": { @@ -8079,6 +8068,26 @@ "uint8arrays": "^1.1.0" } }, + "node_modules/libp2p-gossipsub/node_modules/multiaddr": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", + "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "dependencies": { + "cids": "^1.0.0", + "class-is": "^1.1.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^2.0.3", + "is-ip": "^3.1.0", + "multibase": "^3.0.0", + "uint8arrays": "^1.1.0", + "varint": "^5.0.0" + } + }, + "node_modules/libp2p-gossipsub/node_modules/multiaddr/node_modules/varint": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz", + "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" + }, "node_modules/libp2p-gossipsub/node_modules/multicodec": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-2.1.3.tgz", @@ -8138,51 +8147,124 @@ "integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==" }, "node_modules/libp2p-interfaces": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/libp2p-interfaces/-/libp2p-interfaces-0.8.3.tgz", - "integrity": "sha512-Q8YM2oS4gvlPOuespYRp3jZryxYF5RyuyF+SLUhwjFh3yT6HbiKcxTtMmhOEnyyRgawj0NIDdARJ7h5aUcsA5w==", + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/libp2p-interfaces/-/libp2p-interfaces-0.10.1.tgz", + "integrity": "sha512-F6vjYmzxKw1BsRGEyUW3XKe7aIRXIWd65eTXiXAMMFsJFQsPCIU/W+vamUPgT+AWcXA8fQEGAE9TlghwH4yVQg==", "dependencies": { - "@types/bl": "^2.1.0", + "@types/bl": "^4.1.0", "abort-controller": "^3.0.0", "abortable-iterator": "^3.0.0", - "chai": "^4.2.0", + "chai": "^4.3.4", "chai-checkmark": "^1.0.1", "debug": "^4.3.1", - "delay": "^4.4.0", + "delay": "^5.0.0", "detect-node": "^2.0.4", "dirty-chai": "^2.0.1", - "err-code": "^2.0.3", - "it-goodbye": "^2.0.2", - "it-length-prefixed": "^3.1.0", + "err-code": "^3.0.1", + "it-goodbye": "^3.0.0", + "it-length-prefixed": "^5.0.2", "it-pair": "^1.0.0", "it-pipe": "^1.1.0", - "it-pushable": "^1.4.0", + "it-pushable": "^1.4.2", "libp2p-crypto": "^0.19.0", - "libp2p-tcp": "^0.15.0", - "multiaddr": "^8.1.2", - "multibase": "^3.1.1", - "multihashes": "^3.1.1", + "libp2p-tcp": "^0.15.3", + "multiaddr": "^9.0.1", + "multibase": "^4.0.2", + "multihashes": "^4.0.2", "p-defer": "^3.0.0", "p-limit": "^3.1.0", "p-wait-for": "^3.2.0", "peer-id": "^0.14.2", - "protons": "^2.0.0", - "sinon": "^9.2.4", + "protobufjs": "^6.10.2", + "sinon": "^10.0.0", "streaming-iterables": "^5.0.4", - "uint8arrays": "^2.0.5" + "uint8arrays": "^2.1.3" } }, - "node_modules/libp2p-interfaces/node_modules/multihashes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/multihashes/-/multihashes-3.1.2.tgz", - "integrity": "sha512-AP4IoV/YzkNrfbQKZE3OMPibrmy350OmCd6cJkwyM8oExaXIlOY4UnOOVSQtAEuq/LR01XfXKCESidzZvSwHCQ==", + "node_modules/libp2p-interfaces/node_modules/@types/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@types/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-fLthIdXgivtEy4kQ1MY6qzpqE5YJdJ4KjI5TEaLLqyCwt9IGVVY5WTx19uikJQOMERflIiGT75nkwB7CixBfXg==", "dependencies": { - "multibase": "^3.1.0", - "uint8arrays": "^2.0.5", + "@types/node": "*" + } + }, + "node_modules/libp2p-interfaces/node_modules/bl": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-5.0.0.tgz", + "integrity": "sha512-8vxFNZ0pflFfi0WXA3WQXlj6CaMEwsmh63I1CNp0q+wWv8sD0ARx1KovSQd0l2GkwrMIOyedq0EF1FxI+RCZLQ==", + "dependencies": { + "buffer": "^6.0.3", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/libp2p-interfaces/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/libp2p-interfaces/node_modules/delay": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", + "integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/libp2p-interfaces/node_modules/err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" + }, + "node_modules/libp2p-interfaces/node_modules/it-goodbye": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/it-goodbye/-/it-goodbye-3.0.0.tgz", + "integrity": "sha512-4Vje4IH39DBMuHqfm8ADkl1JTUeKbRpx9gzt7KfNLSPUmmRjm6Os8K+9vXhkRgXiJIqaBFEGnC8qVWfrJkBNuw==", + "dependencies": { + "buffer": "^6.0.3" + } + }, + "node_modules/libp2p-interfaces/node_modules/it-length-prefixed": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/it-length-prefixed/-/it-length-prefixed-5.0.2.tgz", + "integrity": "sha512-SqAURaKKsjYbROIdTjW3UtqGrdZo1SHnkbeYYp7JwC5P0IIy7r4C0xNkmK2Va/fBmvXA++hMdDON9+2zesQlUA==", + "dependencies": { + "bl": "^5.0.0", + "buffer": "^6.0.3", "varint": "^6.0.0" + } + }, + "node_modules/libp2p-interfaces/node_modules/multibase": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.4.tgz", + "integrity": "sha512-8/JmrdSGzlw6KTgAJCOqUBSGd1V6186i/X8dDCGy/lbCKrQ+1QB6f3HE+wPr7Tpdj4U3gutaj9jG2rNX6UpiJg==", + "dependencies": { + "@multiformats/base-x": "^4.0.1" }, "engines": { - "node": ">=10.0.0", + "node": ">=12.0.0", "npm": ">=6.0.0" } }, @@ -8195,28 +8277,34 @@ }, "engines": { "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/libp2p-interfaces/node_modules/sinon": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-10.0.0.tgz", + "integrity": "sha512-XAn5DxtGVJBlBWYrcYKEhWCz7FLwZGdyvANRyK06419hyEpdT0dMc5A8Vcxg5SCGHc40CsqoKsc1bt1CbJPfNw==", + "dependencies": { + "@sinonjs/commons": "^1.8.1", + "@sinonjs/fake-timers": "^6.0.1", + "@sinonjs/samsam": "^5.3.1", + "diff": "^4.0.2", + "nise": "^4.1.0", + "supports-color": "^7.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/sinon" } }, "node_modules/libp2p-interfaces/node_modules/uint8arrays": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.3.tgz", - "integrity": "sha512-2h2Z2OIqzrhHmZTv9ViJVyZZreFkHRHeihh7SxLVY/nLUVJhU4ey/u74tWsgMR6hhMSO2g5rhKmdLQIg3lKiUQ==", + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.5.tgz", + "integrity": "sha512-CSR7AO+4AHUeSOnZ/NBNCElDeWfRh9bXtOck27083kc7SznmmHIhNEkEOCQOn0wvrIMjS3IH0TNLR16vuc46mA==", "dependencies": { - "multibase": "^4.0.1", - "web-encoding": "^1.1.0" - } - }, - "node_modules/libp2p-interfaces/node_modules/uint8arrays/node_modules/multibase": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.2.tgz", - "integrity": "sha512-l0XMK4O5I9cCfxC0/UMDX/UxlIlrqkjEZQNG+ZUUrsGhnXWgFXgatYOQSONiR/lQGfBO463UyZkh3SiQBpjRIQ==", - "dependencies": { - "@multiformats/base-x": "^4.0.1", - "web-encoding": "^1.1.0" - }, - "engines": { - "node": ">=12.0.0", - "npm": ">=6.0.0" + "multibase": "^4.0.1" } }, "node_modules/libp2p-interfaces/node_modules/varint": { @@ -8360,6 +8448,26 @@ "streaming-iterables": "^5.0.2" } }, + "node_modules/libp2p-secio/node_modules/multiaddr": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", + "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "dependencies": { + "cids": "^1.0.0", + "class-is": "^1.1.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^2.0.3", + "is-ip": "^3.1.0", + "multibase": "^3.0.0", + "uint8arrays": "^1.1.0", + "varint": "^5.0.0" + } + }, + "node_modules/libp2p-secio/node_modules/multiaddr/node_modules/varint": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz", + "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" + }, "node_modules/libp2p-secio/node_modules/multicodec": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-2.1.3.tgz", @@ -8401,6 +8509,21 @@ "npm": ">=3.0.0" } }, + "node_modules/libp2p-tcp/node_modules/multiaddr": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", + "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "dependencies": { + "cids": "^1.0.0", + "class-is": "^1.1.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^2.0.3", + "is-ip": "^3.1.0", + "multibase": "^3.0.0", + "uint8arrays": "^1.1.0", + "varint": "^5.0.0" + } + }, "node_modules/libp2p-utils": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/libp2p-utils/-/libp2p-utils-0.2.3.tgz", @@ -8415,6 +8538,21 @@ "private-ip": "^2.1.1" } }, + "node_modules/libp2p-utils/node_modules/multiaddr": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", + "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "dependencies": { + "cids": "^1.0.0", + "class-is": "^1.1.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^2.0.3", + "is-ip": "^3.1.0", + "multibase": "^3.0.0", + "uint8arrays": "^1.1.0", + "varint": "^5.0.0" + } + }, "node_modules/libp2p-websockets": { "version": "0.15.5", "resolved": "https://registry.npmjs.org/libp2p-websockets/-/libp2p-websockets-0.15.5.tgz", @@ -8473,59 +8611,121 @@ "multiaddr": "^9.0.1" } }, - "node_modules/libp2p-websockets/node_modules/multiaddr": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-9.0.1.tgz", - "integrity": "sha512-fubxMjVoRPcz3GYBb63Z6ADCY6BoqezbnL2o8owDcfYqhwW61oFtIlsZGiNKIVC2Fk1Od5rf/3z34QSGJFT/uA==", - "dependencies": { - "cids": "^1.0.0", - "dns-over-http-resolver": "^1.0.0", - "err-code": "^3.0.1", - "is-ip": "^3.1.0", - "multibase": "^4.0.2", - "uint8arrays": "^2.1.3", - "varint": "^6.0.0" - } - }, - "node_modules/libp2p-websockets/node_modules/multibase": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.4.tgz", - "integrity": "sha512-8/JmrdSGzlw6KTgAJCOqUBSGd1V6186i/X8dDCGy/lbCKrQ+1QB6f3HE+wPr7Tpdj4U3gutaj9jG2rNX6UpiJg==", - "dependencies": { - "@multiformats/base-x": "^4.0.1" - }, - "engines": { - "node": ">=12.0.0", - "npm": ">=6.0.0" - } - }, "node_modules/libp2p-websockets/node_modules/sprintf-js": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==" }, - "node_modules/libp2p-websockets/node_modules/uint8arrays": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.4.tgz", - "integrity": "sha512-Q/Ys2JhFWpZkw8Hi2Zz7NFpVDH8avK9k2NjYKdOHoOAn5dTtOSNT9xMtaQz5D4kWVPOGKte8CAroEIdTzvF9AA==", + "node_modules/libp2p/node_modules/bl": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-5.0.0.tgz", + "integrity": "sha512-8vxFNZ0pflFfi0WXA3WQXlj6CaMEwsmh63I1CNp0q+wWv8sD0ARx1KovSQd0l2GkwrMIOyedq0EF1FxI+RCZLQ==", "dependencies": { - "multibase": "^4.0.1" + "buffer": "^6.0.3", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" } }, - "node_modules/libp2p-websockets/node_modules/varint": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", - "integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==" - }, - "node_modules/libp2p/node_modules/multicodec": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-2.1.3.tgz", - "integrity": "sha512-0tOH2Gtio39uO41o+2xl9UhRkCWxU5ZmZSbFCh/OjGzkWJI8e6lkN/s4Mj1YfyWoBod+2+S3W+6wO6nhkwN8pA==", + "node_modules/libp2p/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "dependencies": { - "uint8arrays": "1.1.0", + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/libp2p/node_modules/err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" + }, + "node_modules/libp2p/node_modules/ip-address": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-7.1.0.tgz", + "integrity": "sha512-V9pWC/VJf2lsXqP7IWJ+pe3P1/HCYGBMZrrnT62niLGjAfCbeiwXMUxaeHvnVlz19O27pvXP4azs+Pj/A0x+SQ==", + "dependencies": { + "jsbn": "1.1.0", + "sprintf-js": "1.1.2" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/libp2p/node_modules/it-handshake": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-handshake/-/it-handshake-2.0.0.tgz", + "integrity": "sha512-K4q+mz8aLlCK3vTjtgNdHC9c/JbuOATsfogarjMsLcBZC5vYfKbX3Gq3AWcCdjIsIrPqzTlhPKSxl64LJkrt2w==", + "dependencies": { + "it-pushable": "^1.4.0", + "it-reader": "^3.0.0", + "p-defer": "^3.0.0" + } + }, + "node_modules/libp2p/node_modules/it-length-prefixed": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/it-length-prefixed/-/it-length-prefixed-5.0.2.tgz", + "integrity": "sha512-SqAURaKKsjYbROIdTjW3UtqGrdZo1SHnkbeYYp7JwC5P0IIy7r4C0xNkmK2Va/fBmvXA++hMdDON9+2zesQlUA==", + "dependencies": { + "bl": "^5.0.0", + "buffer": "^6.0.3", "varint": "^6.0.0" } }, + "node_modules/libp2p/node_modules/it-reader": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/it-reader/-/it-reader-3.0.0.tgz", + "integrity": "sha512-NxR40odATeaBmSefn6Xn43DplYvn2KtEKQzn4jrTRuPYXMky5M4e+KQ7aTJh0k0vkytLyeenGO1I1GXlGm4laQ==", + "dependencies": { + "bl": "^5.0.0" + } + }, + "node_modules/libp2p/node_modules/libp2p-utils": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/libp2p-utils/-/libp2p-utils-0.3.1.tgz", + "integrity": "sha512-LOVfww7a6Rhtoupl3z1ABuTEli5whY3VLTB9QntsOIwbOcX9GfmjuhqYbEDht9lVPAQl+rCUWbfDMvK121ryUg==", + "dependencies": { + "abortable-iterator": "^3.0.0", + "debug": "^4.3.0", + "err-code": "^3.0.1", + "ip-address": "^7.1.0", + "is-loopback-addr": "^1.0.0", + "multiaddr": "^9.0.1", + "private-ip": "^2.1.1" + } + }, + "node_modules/libp2p/node_modules/mafmt": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/mafmt/-/mafmt-9.0.0.tgz", + "integrity": "sha512-BwKL6FJxc6R85K6gFE/pX7MVyCp0NkM2DJHg0RatxVgDlK4g9kqtfXQUt2iReSmTcgZss/Q/Bdfa2KTg4KyC+g==", + "dependencies": { + "multiaddr": "^9.0.1" + } + }, + "node_modules/libp2p/node_modules/retimer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/retimer/-/retimer-3.0.0.tgz", + "integrity": "sha512-WKE0j11Pa0ZJI5YIk0nflGI7SQsfl2ljihVy7ogh7DeQSeYAUi0ubZ/yEueGtDfUPk6GH5LRw1hBdLq4IwUBWA==" + }, + "node_modules/libp2p/node_modules/sprintf-js": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==" + }, "node_modules/libp2p/node_modules/varint": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", @@ -8693,6 +8893,21 @@ "multiaddr": "^8.0.0" } }, + "node_modules/mafmt/node_modules/multiaddr": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", + "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "dependencies": { + "cids": "^1.0.0", + "class-is": "^1.1.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^2.0.3", + "is-ip": "^3.1.0", + "multibase": "^3.0.0", + "uint8arrays": "^1.1.0", + "varint": "^5.0.0" + } + }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -9250,6 +9465,28 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/multiaddr": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-9.0.1.tgz", + "integrity": "sha512-fubxMjVoRPcz3GYBb63Z6ADCY6BoqezbnL2o8owDcfYqhwW61oFtIlsZGiNKIVC2Fk1Od5rf/3z34QSGJFT/uA==", + "dependencies": { + "cids": "^1.0.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^3.0.1", + "is-ip": "^3.1.0", + "multibase": "^4.0.2", + "uint8arrays": "^2.1.3", + "varint": "^6.0.0" + } + }, + "node_modules/multiaddr-to-uri": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/multiaddr-to-uri/-/multiaddr-to-uri-6.0.0.tgz", + "integrity": "sha512-OjpkVHOXEmIKMO8WChzzQ7aZQcSQX8squxmvtDbRpy7/QNmJ3Z7jv6qyD74C28QtaeNie8O8ngW2AkeiMmKP7A==", + "dependencies": { + "multiaddr": "^8.0.0" + } + }, + "node_modules/multiaddr-to-uri/node_modules/multiaddr": { "version": "8.1.2", "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", @@ -9264,14 +9501,36 @@ "varint": "^5.0.0" } }, - "node_modules/multiaddr-to-uri": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/multiaddr-to-uri/-/multiaddr-to-uri-6.0.0.tgz", - "integrity": "sha512-OjpkVHOXEmIKMO8WChzzQ7aZQcSQX8squxmvtDbRpy7/QNmJ3Z7jv6qyD74C28QtaeNie8O8ngW2AkeiMmKP7A==", + "node_modules/multiaddr/node_modules/err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" + }, + "node_modules/multiaddr/node_modules/multibase": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.4.tgz", + "integrity": "sha512-8/JmrdSGzlw6KTgAJCOqUBSGd1V6186i/X8dDCGy/lbCKrQ+1QB6f3HE+wPr7Tpdj4U3gutaj9jG2rNX6UpiJg==", "dependencies": { - "multiaddr": "^8.0.0" + "@multiformats/base-x": "^4.0.1" + }, + "engines": { + "node": ">=12.0.0", + "npm": ">=6.0.0" } }, + "node_modules/multiaddr/node_modules/uint8arrays": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.5.tgz", + "integrity": "sha512-CSR7AO+4AHUeSOnZ/NBNCElDeWfRh9bXtOck27083kc7SznmmHIhNEkEOCQOn0wvrIMjS3IH0TNLR16vuc46mA==", + "dependencies": { + "multibase": "^4.0.1" + } + }, + "node_modules/multiaddr/node_modules/varint": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", + "integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==" + }, "node_modules/multibase": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/multibase/-/multibase-3.1.2.tgz", @@ -9397,21 +9656,113 @@ } }, "node_modules/multistream-select": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/multistream-select/-/multistream-select-1.0.0.tgz", - "integrity": "sha512-82riQ+qZ0RPY+KbRdeeKKQnFSBCVpUbZ15EniGU2nfwM8NdrpPIeUYXFw4a/pyprcNeRfMgLlG9aCh874p8nJg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/multistream-select/-/multistream-select-2.0.0.tgz", + "integrity": "sha512-MhzWeoIh2Rojqm32glGNmWbzyffrGrYtg68sWKwj8ZuALHGDySNiU5j6wV69BpUtKRQmQ6zWNUB5few57VB7/w==", "dependencies": { - "bl": "^4.0.0", + "bl": "^5.0.0", "debug": "^4.1.1", - "err-code": "^2.0.0", - "it-handshake": "^1.0.2", - "it-length-prefixed": "^3.0.0", + "err-code": "^3.0.1", + "it-first": "^1.0.6", + "it-handshake": "^2.0.0", + "it-length-prefixed": "^5.0.0", "it-pipe": "^1.0.1", - "it-reader": "^2.0.0", + "it-reader": "^3.0.0", "p-defer": "^3.0.0", - "uint8arrays": "^1.1.0" + "uint8arrays": "^2.1.4" } }, + "node_modules/multistream-select/node_modules/bl": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-5.0.0.tgz", + "integrity": "sha512-8vxFNZ0pflFfi0WXA3WQXlj6CaMEwsmh63I1CNp0q+wWv8sD0ARx1KovSQd0l2GkwrMIOyedq0EF1FxI+RCZLQ==", + "dependencies": { + "buffer": "^6.0.3", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/multistream-select/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/multistream-select/node_modules/err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" + }, + "node_modules/multistream-select/node_modules/it-handshake": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-handshake/-/it-handshake-2.0.0.tgz", + "integrity": "sha512-K4q+mz8aLlCK3vTjtgNdHC9c/JbuOATsfogarjMsLcBZC5vYfKbX3Gq3AWcCdjIsIrPqzTlhPKSxl64LJkrt2w==", + "dependencies": { + "it-pushable": "^1.4.0", + "it-reader": "^3.0.0", + "p-defer": "^3.0.0" + } + }, + "node_modules/multistream-select/node_modules/it-length-prefixed": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/it-length-prefixed/-/it-length-prefixed-5.0.2.tgz", + "integrity": "sha512-SqAURaKKsjYbROIdTjW3UtqGrdZo1SHnkbeYYp7JwC5P0IIy7r4C0xNkmK2Va/fBmvXA++hMdDON9+2zesQlUA==", + "dependencies": { + "bl": "^5.0.0", + "buffer": "^6.0.3", + "varint": "^6.0.0" + } + }, + "node_modules/multistream-select/node_modules/it-reader": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/it-reader/-/it-reader-3.0.0.tgz", + "integrity": "sha512-NxR40odATeaBmSefn6Xn43DplYvn2KtEKQzn4jrTRuPYXMky5M4e+KQ7aTJh0k0vkytLyeenGO1I1GXlGm4laQ==", + "dependencies": { + "bl": "^5.0.0" + } + }, + "node_modules/multistream-select/node_modules/multibase": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.4.tgz", + "integrity": "sha512-8/JmrdSGzlw6KTgAJCOqUBSGd1V6186i/X8dDCGy/lbCKrQ+1QB6f3HE+wPr7Tpdj4U3gutaj9jG2rNX6UpiJg==", + "dependencies": { + "@multiformats/base-x": "^4.0.1" + }, + "engines": { + "node": ">=12.0.0", + "npm": ">=6.0.0" + } + }, + "node_modules/multistream-select/node_modules/uint8arrays": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.5.tgz", + "integrity": "sha512-CSR7AO+4AHUeSOnZ/NBNCElDeWfRh9bXtOck27083kc7SznmmHIhNEkEOCQOn0wvrIMjS3IH0TNLR16vuc46mA==", + "dependencies": { + "multibase": "^4.0.1" + } + }, + "node_modules/multistream-select/node_modules/varint": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", + "integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==" + }, "node_modules/murmurhash3js-revisited": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/murmurhash3js-revisited/-/murmurhash3js-revisited-3.0.0.tgz", @@ -19836,15 +20187,6 @@ "resolved": "https://registry.npmjs.org/it-pipe/-/it-pipe-1.1.0.tgz", "integrity": "sha512-lF0/3qTVeth13TOnHVs0BTFaziwQF7m5Gg+E6JV0BXcLKutC92YjSi7bASgkPOXaLEb+YvNZrPorGMBIJvZfxg==" }, - "it-protocol-buffers": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/it-protocol-buffers/-/it-protocol-buffers-0.2.1.tgz", - "integrity": "sha512-UbezSc9BZTw0DU7mFS6iG9PXeycJfTDJlFAlniI3x1CRrKeDP+IW6ERPAFskHI3O+wij18Mk7eHgDtFz4Zk65A==", - "requires": { - "it-buffer": "^0.1.1", - "it-length-prefixed": "^3.0.0" - } - }, "it-pushable": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/it-pushable/-/it-pushable-1.4.2.tgz", @@ -20060,9 +20402,9 @@ } }, "libp2p": { - "version": "0.30.10", - "resolved": "https://registry.npmjs.org/libp2p/-/libp2p-0.30.10.tgz", - "integrity": "sha512-TdFLG4CF7/tLF1ypwNM8+q1YshW3+hYWDWYo6IA5Zyhg2MFDPdsUqaX4JLG0EiYHQvVcrUQF8B7rL49YbDHE7Q==", + "version": "0.31.0-rc.3", + "resolved": "https://registry.npmjs.org/libp2p/-/libp2p-0.31.0-rc.3.tgz", + "integrity": "sha512-spYO0bBrAQRWD/bcR0SK0AUdI9EL9/Yi5qB87mTdZKUrSJE3Wa/A1kh7L3k+w2kO42zvy6KbfoTzKQQxaSIbuw==", "requires": { "@motrix/nat-api": "^0.3.1", "abort-controller": "^3.0.0", @@ -20072,9 +20414,9 @@ "cids": "^1.1.5", "class-is": "^1.1.0", "debug": "^4.3.1", - "err-code": "^2.0.0", + "err-code": "^3.0.0", "es6-promisify": "^6.1.1", - "events": "^3.2.0", + "events": "^3.3.0", "hashlru": "^2.3.0", "interface-datastore": "^3.0.3", "ipfs-utils": "^6.0.0", @@ -20083,50 +20425,133 @@ "it-drain": "^1.0.3", "it-filter": "^1.0.1", "it-first": "^1.0.4", - "it-handshake": "^1.0.2", - "it-length-prefixed": "^3.1.0", + "it-handshake": "^2.0.0", + "it-length-prefixed": "^5.0.2", "it-map": "^1.0.4", "it-merge": "1.0.0", "it-pipe": "^1.1.0", - "it-protocol-buffers": "^0.2.0", "it-take": "1.0.0", "libp2p-crypto": "^0.19.0", - "libp2p-interfaces": "^0.8.1", - "libp2p-utils": "^0.2.2", - "mafmt": "^8.0.0", + "libp2p-interfaces": "^0.10.1", + "libp2p-utils": "^0.3.1", + "mafmt": "^9.0.0", "merge-options": "^3.0.4", "moving-average": "^1.0.0", - "multiaddr": "^8.1.0", - "multicodec": "^2.1.0", - "multihashing-async": "^2.0.1", - "multistream-select": "^1.0.0", + "multiaddr": "^9.0.1", + "multicodec": "^3.0.1", + "multihashing-async": "^2.1.2", + "multistream-select": "^2.0.0", "mutable-proxy": "^1.0.0", "node-forge": "^0.10.0", "p-any": "^3.0.0", "p-fifo": "^1.0.0", - "p-retry": "^4.2.0", - "p-settle": "^4.0.1", + "p-retry": "^4.4.0", + "p-settle": "^4.1.1", "peer-id": "^0.14.2", - "private-ip": "^2.0.0", - "protons": "^2.0.0", - "retimer": "^2.0.0", + "private-ip": "^2.1.0", + "protobufjs": "^6.10.2", + "retimer": "^3.0.0", "sanitize-filename": "^1.6.3", "set-delayed-interval": "^1.0.0", "streaming-iterables": "^5.0.2", "timeout-abort-controller": "^1.1.1", "varint": "^6.0.0", - "xsalsa20": "^1.0.2" + "xsalsa20": "^1.1.0" }, "dependencies": { - "multicodec": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-2.1.3.tgz", - "integrity": "sha512-0tOH2Gtio39uO41o+2xl9UhRkCWxU5ZmZSbFCh/OjGzkWJI8e6lkN/s4Mj1YfyWoBod+2+S3W+6wO6nhkwN8pA==", + "bl": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-5.0.0.tgz", + "integrity": "sha512-8vxFNZ0pflFfi0WXA3WQXlj6CaMEwsmh63I1CNp0q+wWv8sD0ARx1KovSQd0l2GkwrMIOyedq0EF1FxI+RCZLQ==", "requires": { - "uint8arrays": "1.1.0", + "buffer": "^6.0.3", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" + }, + "ip-address": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-7.1.0.tgz", + "integrity": "sha512-V9pWC/VJf2lsXqP7IWJ+pe3P1/HCYGBMZrrnT62niLGjAfCbeiwXMUxaeHvnVlz19O27pvXP4azs+Pj/A0x+SQ==", + "requires": { + "jsbn": "1.1.0", + "sprintf-js": "1.1.2" + } + }, + "it-handshake": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-handshake/-/it-handshake-2.0.0.tgz", + "integrity": "sha512-K4q+mz8aLlCK3vTjtgNdHC9c/JbuOATsfogarjMsLcBZC5vYfKbX3Gq3AWcCdjIsIrPqzTlhPKSxl64LJkrt2w==", + "requires": { + "it-pushable": "^1.4.0", + "it-reader": "^3.0.0", + "p-defer": "^3.0.0" + } + }, + "it-length-prefixed": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/it-length-prefixed/-/it-length-prefixed-5.0.2.tgz", + "integrity": "sha512-SqAURaKKsjYbROIdTjW3UtqGrdZo1SHnkbeYYp7JwC5P0IIy7r4C0xNkmK2Va/fBmvXA++hMdDON9+2zesQlUA==", + "requires": { + "bl": "^5.0.0", + "buffer": "^6.0.3", "varint": "^6.0.0" } }, + "it-reader": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/it-reader/-/it-reader-3.0.0.tgz", + "integrity": "sha512-NxR40odATeaBmSefn6Xn43DplYvn2KtEKQzn4jrTRuPYXMky5M4e+KQ7aTJh0k0vkytLyeenGO1I1GXlGm4laQ==", + "requires": { + "bl": "^5.0.0" + } + }, + "libp2p-utils": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/libp2p-utils/-/libp2p-utils-0.3.1.tgz", + "integrity": "sha512-LOVfww7a6Rhtoupl3z1ABuTEli5whY3VLTB9QntsOIwbOcX9GfmjuhqYbEDht9lVPAQl+rCUWbfDMvK121ryUg==", + "requires": { + "abortable-iterator": "^3.0.0", + "debug": "^4.3.0", + "err-code": "^3.0.1", + "ip-address": "^7.1.0", + "is-loopback-addr": "^1.0.0", + "multiaddr": "^9.0.1", + "private-ip": "^2.1.1" + } + }, + "mafmt": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/mafmt/-/mafmt-9.0.0.tgz", + "integrity": "sha512-BwKL6FJxc6R85K6gFE/pX7MVyCp0NkM2DJHg0RatxVgDlK4g9kqtfXQUt2iReSmTcgZss/Q/Bdfa2KTg4KyC+g==", + "requires": { + "multiaddr": "^9.0.1" + } + }, + "retimer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/retimer/-/retimer-3.0.0.tgz", + "integrity": "sha512-WKE0j11Pa0ZJI5YIk0nflGI7SQsfl2ljihVy7ogh7DeQSeYAUi0ubZ/yEueGtDfUPk6GH5LRw1hBdLq4IwUBWA==" + }, + "sprintf-js": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==" + }, "varint": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", @@ -20242,6 +20667,28 @@ "uint8arrays": "^1.1.0" } }, + "multiaddr": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", + "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "requires": { + "cids": "^1.0.0", + "class-is": "^1.1.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^2.0.3", + "is-ip": "^3.1.0", + "multibase": "^3.0.0", + "uint8arrays": "^1.1.0", + "varint": "^5.0.0" + }, + "dependencies": { + "varint": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz", + "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" + } + } + }, "multicodec": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-2.1.3.tgz", @@ -20296,50 +20743,103 @@ } }, "libp2p-interfaces": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/libp2p-interfaces/-/libp2p-interfaces-0.8.3.tgz", - "integrity": "sha512-Q8YM2oS4gvlPOuespYRp3jZryxYF5RyuyF+SLUhwjFh3yT6HbiKcxTtMmhOEnyyRgawj0NIDdARJ7h5aUcsA5w==", + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/libp2p-interfaces/-/libp2p-interfaces-0.10.1.tgz", + "integrity": "sha512-F6vjYmzxKw1BsRGEyUW3XKe7aIRXIWd65eTXiXAMMFsJFQsPCIU/W+vamUPgT+AWcXA8fQEGAE9TlghwH4yVQg==", "requires": { - "@types/bl": "^2.1.0", + "@types/bl": "^4.1.0", "abort-controller": "^3.0.0", "abortable-iterator": "^3.0.0", - "chai": "^4.2.0", + "chai": "^4.3.4", "chai-checkmark": "^1.0.1", "debug": "^4.3.1", - "delay": "^4.4.0", + "delay": "^5.0.0", "detect-node": "^2.0.4", "dirty-chai": "^2.0.1", - "err-code": "^2.0.3", - "it-goodbye": "^2.0.2", - "it-length-prefixed": "^3.1.0", + "err-code": "^3.0.1", + "it-goodbye": "^3.0.0", + "it-length-prefixed": "^5.0.2", "it-pair": "^1.0.0", "it-pipe": "^1.1.0", - "it-pushable": "^1.4.0", + "it-pushable": "^1.4.2", "libp2p-crypto": "^0.19.0", - "libp2p-tcp": "^0.15.0", - "multiaddr": "^8.1.2", - "multibase": "^3.1.1", - "multihashes": "^3.1.1", + "libp2p-tcp": "^0.15.3", + "multiaddr": "^9.0.1", + "multibase": "^4.0.2", + "multihashes": "^4.0.2", "p-defer": "^3.0.0", "p-limit": "^3.1.0", "p-wait-for": "^3.2.0", "peer-id": "^0.14.2", - "protons": "^2.0.0", - "sinon": "^9.2.4", + "protobufjs": "^6.10.2", + "sinon": "^10.0.0", "streaming-iterables": "^5.0.4", - "uint8arrays": "^2.0.5" + "uint8arrays": "^2.1.3" }, "dependencies": { - "multihashes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/multihashes/-/multihashes-3.1.2.tgz", - "integrity": "sha512-AP4IoV/YzkNrfbQKZE3OMPibrmy350OmCd6cJkwyM8oExaXIlOY4UnOOVSQtAEuq/LR01XfXKCESidzZvSwHCQ==", + "@types/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@types/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-fLthIdXgivtEy4kQ1MY6qzpqE5YJdJ4KjI5TEaLLqyCwt9IGVVY5WTx19uikJQOMERflIiGT75nkwB7CixBfXg==", "requires": { - "multibase": "^3.1.0", - "uint8arrays": "^2.0.5", + "@types/node": "*" + } + }, + "bl": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-5.0.0.tgz", + "integrity": "sha512-8vxFNZ0pflFfi0WXA3WQXlj6CaMEwsmh63I1CNp0q+wWv8sD0ARx1KovSQd0l2GkwrMIOyedq0EF1FxI+RCZLQ==", + "requires": { + "buffer": "^6.0.3", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "delay": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", + "integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==" + }, + "err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" + }, + "it-goodbye": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/it-goodbye/-/it-goodbye-3.0.0.tgz", + "integrity": "sha512-4Vje4IH39DBMuHqfm8ADkl1JTUeKbRpx9gzt7KfNLSPUmmRjm6Os8K+9vXhkRgXiJIqaBFEGnC8qVWfrJkBNuw==", + "requires": { + "buffer": "^6.0.3" + } + }, + "it-length-prefixed": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/it-length-prefixed/-/it-length-prefixed-5.0.2.tgz", + "integrity": "sha512-SqAURaKKsjYbROIdTjW3UtqGrdZo1SHnkbeYYp7JwC5P0IIy7r4C0xNkmK2Va/fBmvXA++hMdDON9+2zesQlUA==", + "requires": { + "bl": "^5.0.0", + "buffer": "^6.0.3", "varint": "^6.0.0" } }, + "multibase": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.4.tgz", + "integrity": "sha512-8/JmrdSGzlw6KTgAJCOqUBSGd1V6186i/X8dDCGy/lbCKrQ+1QB6f3HE+wPr7Tpdj4U3gutaj9jG2rNX6UpiJg==", + "requires": { + "@multiformats/base-x": "^4.0.1" + } + }, "p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -20348,24 +20848,25 @@ "yocto-queue": "^0.1.0" } }, - "uint8arrays": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.3.tgz", - "integrity": "sha512-2h2Z2OIqzrhHmZTv9ViJVyZZreFkHRHeihh7SxLVY/nLUVJhU4ey/u74tWsgMR6hhMSO2g5rhKmdLQIg3lKiUQ==", + "sinon": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-10.0.0.tgz", + "integrity": "sha512-XAn5DxtGVJBlBWYrcYKEhWCz7FLwZGdyvANRyK06419hyEpdT0dMc5A8Vcxg5SCGHc40CsqoKsc1bt1CbJPfNw==", "requires": { - "multibase": "^4.0.1", - "web-encoding": "^1.1.0" - }, - "dependencies": { - "multibase": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.2.tgz", - "integrity": "sha512-l0XMK4O5I9cCfxC0/UMDX/UxlIlrqkjEZQNG+ZUUrsGhnXWgFXgatYOQSONiR/lQGfBO463UyZkh3SiQBpjRIQ==", - "requires": { - "@multiformats/base-x": "^4.0.1", - "web-encoding": "^1.1.0" - } - } + "@sinonjs/commons": "^1.8.1", + "@sinonjs/fake-timers": "^6.0.1", + "@sinonjs/samsam": "^5.3.1", + "diff": "^4.0.2", + "nise": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "uint8arrays": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.5.tgz", + "integrity": "sha512-CSR7AO+4AHUeSOnZ/NBNCElDeWfRh9bXtOck27083kc7SznmmHIhNEkEOCQOn0wvrIMjS3IH0TNLR16vuc46mA==", + "requires": { + "multibase": "^4.0.1" } }, "varint": { @@ -20503,6 +21004,28 @@ "streaming-iterables": "^5.0.2" } }, + "multiaddr": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", + "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "requires": { + "cids": "^1.0.0", + "class-is": "^1.1.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^2.0.3", + "is-ip": "^3.1.0", + "multibase": "^3.0.0", + "uint8arrays": "^1.1.0", + "varint": "^5.0.0" + }, + "dependencies": { + "varint": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz", + "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" + } + } + }, "multicodec": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-2.1.3.tgz", @@ -20537,6 +21060,23 @@ "mafmt": "^8.0.0", "multiaddr": "^8.0.0", "stream-to-it": "^0.2.2" + }, + "dependencies": { + "multiaddr": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", + "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "requires": { + "cids": "^1.0.0", + "class-is": "^1.1.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^2.0.3", + "is-ip": "^3.1.0", + "multibase": "^3.0.0", + "uint8arrays": "^1.1.0", + "varint": "^5.0.0" + } + } } }, "libp2p-utils": { @@ -20551,6 +21091,23 @@ "is-loopback-addr": "^1.0.0", "multiaddr": "^8.0.0", "private-ip": "^2.1.1" + }, + "dependencies": { + "multiaddr": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", + "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "requires": { + "cids": "^1.0.0", + "class-is": "^1.1.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^2.0.3", + "is-ip": "^3.1.0", + "multibase": "^3.0.0", + "uint8arrays": "^1.1.0", + "varint": "^5.0.0" + } + } } }, "libp2p-websockets": { @@ -20608,45 +21165,10 @@ "multiaddr": "^9.0.1" } }, - "multiaddr": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-9.0.1.tgz", - "integrity": "sha512-fubxMjVoRPcz3GYBb63Z6ADCY6BoqezbnL2o8owDcfYqhwW61oFtIlsZGiNKIVC2Fk1Od5rf/3z34QSGJFT/uA==", - "requires": { - "cids": "^1.0.0", - "dns-over-http-resolver": "^1.0.0", - "err-code": "^3.0.1", - "is-ip": "^3.1.0", - "multibase": "^4.0.2", - "uint8arrays": "^2.1.3", - "varint": "^6.0.0" - } - }, - "multibase": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.4.tgz", - "integrity": "sha512-8/JmrdSGzlw6KTgAJCOqUBSGd1V6186i/X8dDCGy/lbCKrQ+1QB6f3HE+wPr7Tpdj4U3gutaj9jG2rNX6UpiJg==", - "requires": { - "@multiformats/base-x": "^4.0.1" - } - }, "sprintf-js": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==" - }, - "uint8arrays": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.4.tgz", - "integrity": "sha512-Q/Ys2JhFWpZkw8Hi2Zz7NFpVDH8avK9k2NjYKdOHoOAn5dTtOSNT9xMtaQz5D4kWVPOGKte8CAroEIdTzvF9AA==", - "requires": { - "multibase": "^4.0.1" - } - }, - "varint": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", - "integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==" } } }, @@ -20789,6 +21311,23 @@ "integrity": "sha512-wwZ5+PU0vQw10kwQRyZin1Z0dqVOp0BnYlX1xvXHS2fmLwrrQCfU1+3tlW5MRcihUwGz1virnVhbRAU1biKfiw==", "requires": { "multiaddr": "^8.0.0" + }, + "dependencies": { + "multiaddr": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", + "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "requires": { + "cids": "^1.0.0", + "class-is": "^1.1.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^2.0.3", + "is-ip": "^3.1.0", + "multibase": "^3.0.0", + "uint8arrays": "^1.1.0", + "varint": "^5.0.0" + } + } } }, "make-dir": { @@ -21204,18 +21743,45 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "multiaddr": { - "version": "8.1.2", - "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", - "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-9.0.1.tgz", + "integrity": "sha512-fubxMjVoRPcz3GYBb63Z6ADCY6BoqezbnL2o8owDcfYqhwW61oFtIlsZGiNKIVC2Fk1Od5rf/3z34QSGJFT/uA==", "requires": { "cids": "^1.0.0", - "class-is": "^1.1.0", "dns-over-http-resolver": "^1.0.0", - "err-code": "^2.0.3", + "err-code": "^3.0.1", "is-ip": "^3.1.0", - "multibase": "^3.0.0", - "uint8arrays": "^1.1.0", - "varint": "^5.0.0" + "multibase": "^4.0.2", + "uint8arrays": "^2.1.3", + "varint": "^6.0.0" + }, + "dependencies": { + "err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" + }, + "multibase": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.4.tgz", + "integrity": "sha512-8/JmrdSGzlw6KTgAJCOqUBSGd1V6186i/X8dDCGy/lbCKrQ+1QB6f3HE+wPr7Tpdj4U3gutaj9jG2rNX6UpiJg==", + "requires": { + "@multiformats/base-x": "^4.0.1" + } + }, + "uint8arrays": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.5.tgz", + "integrity": "sha512-CSR7AO+4AHUeSOnZ/NBNCElDeWfRh9bXtOck27083kc7SznmmHIhNEkEOCQOn0wvrIMjS3IH0TNLR16vuc46mA==", + "requires": { + "multibase": "^4.0.1" + } + }, + "varint": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", + "integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==" + } } }, "multiaddr-to-uri": { @@ -21224,6 +21790,23 @@ "integrity": "sha512-OjpkVHOXEmIKMO8WChzzQ7aZQcSQX8squxmvtDbRpy7/QNmJ3Z7jv6qyD74C28QtaeNie8O8ngW2AkeiMmKP7A==", "requires": { "multiaddr": "^8.0.0" + }, + "dependencies": { + "multiaddr": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-8.1.2.tgz", + "integrity": "sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ==", + "requires": { + "cids": "^1.0.0", + "class-is": "^1.1.0", + "dns-over-http-resolver": "^1.0.0", + "err-code": "^2.0.3", + "is-ip": "^3.1.0", + "multibase": "^3.0.0", + "uint8arrays": "^1.1.0", + "varint": "^5.0.0" + } + } } }, "multibase": { @@ -21333,19 +21916,95 @@ } }, "multistream-select": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/multistream-select/-/multistream-select-1.0.0.tgz", - "integrity": "sha512-82riQ+qZ0RPY+KbRdeeKKQnFSBCVpUbZ15EniGU2nfwM8NdrpPIeUYXFw4a/pyprcNeRfMgLlG9aCh874p8nJg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/multistream-select/-/multistream-select-2.0.0.tgz", + "integrity": "sha512-MhzWeoIh2Rojqm32glGNmWbzyffrGrYtg68sWKwj8ZuALHGDySNiU5j6wV69BpUtKRQmQ6zWNUB5few57VB7/w==", "requires": { - "bl": "^4.0.0", + "bl": "^5.0.0", "debug": "^4.1.1", - "err-code": "^2.0.0", - "it-handshake": "^1.0.2", - "it-length-prefixed": "^3.0.0", + "err-code": "^3.0.1", + "it-first": "^1.0.6", + "it-handshake": "^2.0.0", + "it-length-prefixed": "^5.0.0", "it-pipe": "^1.0.1", - "it-reader": "^2.0.0", + "it-reader": "^3.0.0", "p-defer": "^3.0.0", - "uint8arrays": "^1.1.0" + "uint8arrays": "^2.1.4" + }, + "dependencies": { + "bl": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-5.0.0.tgz", + "integrity": "sha512-8vxFNZ0pflFfi0WXA3WQXlj6CaMEwsmh63I1CNp0q+wWv8sD0ARx1KovSQd0l2GkwrMIOyedq0EF1FxI+RCZLQ==", + "requires": { + "buffer": "^6.0.3", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" + }, + "it-handshake": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/it-handshake/-/it-handshake-2.0.0.tgz", + "integrity": "sha512-K4q+mz8aLlCK3vTjtgNdHC9c/JbuOATsfogarjMsLcBZC5vYfKbX3Gq3AWcCdjIsIrPqzTlhPKSxl64LJkrt2w==", + "requires": { + "it-pushable": "^1.4.0", + "it-reader": "^3.0.0", + "p-defer": "^3.0.0" + } + }, + "it-length-prefixed": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/it-length-prefixed/-/it-length-prefixed-5.0.2.tgz", + "integrity": "sha512-SqAURaKKsjYbROIdTjW3UtqGrdZo1SHnkbeYYp7JwC5P0IIy7r4C0xNkmK2Va/fBmvXA++hMdDON9+2zesQlUA==", + "requires": { + "bl": "^5.0.0", + "buffer": "^6.0.3", + "varint": "^6.0.0" + } + }, + "it-reader": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/it-reader/-/it-reader-3.0.0.tgz", + "integrity": "sha512-NxR40odATeaBmSefn6Xn43DplYvn2KtEKQzn4jrTRuPYXMky5M4e+KQ7aTJh0k0vkytLyeenGO1I1GXlGm4laQ==", + "requires": { + "bl": "^5.0.0" + } + }, + "multibase": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.4.tgz", + "integrity": "sha512-8/JmrdSGzlw6KTgAJCOqUBSGd1V6186i/X8dDCGy/lbCKrQ+1QB6f3HE+wPr7Tpdj4U3gutaj9jG2rNX6UpiJg==", + "requires": { + "@multiformats/base-x": "^4.0.1" + } + }, + "uint8arrays": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.5.tgz", + "integrity": "sha512-CSR7AO+4AHUeSOnZ/NBNCElDeWfRh9bXtOck27083kc7SznmmHIhNEkEOCQOn0wvrIMjS3IH0TNLR16vuc46mA==", + "requires": { + "multibase": "^4.0.1" + } + }, + "varint": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", + "integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==" + } } }, "murmurhash3js-revisited": { diff --git a/package.json b/package.json index ec5177cced..b9020223cd 100644 --- a/package.json +++ b/package.json @@ -54,14 +54,14 @@ "debug": "^4.3.1", "it-concat": "^1.0.3", "it-length-prefixed": "^3.1.0", - "libp2p": "^0.30.0", + "libp2p": "^0.31.0-rc.3", "libp2p-gossipsub": "^0.7.0", "libp2p-mplex": "^0.10.2", "libp2p-noise": "^2.0.5", "libp2p-secio": "^0.13.1", "libp2p-tcp": "^0.15.3", "libp2p-websockets": "^0.15.5", - "multiaddr": "^8.1.2", + "multiaddr": "^9.0.1", "prompt-sync": "^4.2.0", "ts-proto": "^1.79.3", "uuid": "^3.4.0", diff --git a/src/chat/index.ts b/src/chat/index.ts index 7f47707e9f..70b5925b12 100644 --- a/src/chat/index.ts +++ b/src/chat/index.ts @@ -2,7 +2,7 @@ import readline from 'readline'; import util from 'util'; import TCP from 'libp2p-tcp'; -import Multiaddr from 'multiaddr'; +import { multiaddr, Multiaddr } from 'multiaddr'; import Waku from '../lib/waku'; import { WakuMessage } from '../lib/waku_message'; @@ -109,7 +109,7 @@ function processArguments(): Options { switch (arg) { case '--staticNode': opts = Object.assign(opts, { - staticNode: new Multiaddr(passedArgs.shift()), + staticNode: multiaddr(passedArgs.shift()!), }); break; case '--listenAddr': diff --git a/src/lib/waku.ts b/src/lib/waku.ts index 0645e60ae2..459874a483 100644 --- a/src/lib/waku.ts +++ b/src/lib/waku.ts @@ -3,7 +3,7 @@ import Mplex from 'libp2p-mplex'; import { bytes } from 'libp2p-noise/dist/src/@types/basic'; import { Noise } from 'libp2p-noise/dist/src/noise'; import Websockets from 'libp2p-websockets'; -import Multiaddr from 'multiaddr'; +import { Multiaddr } from 'multiaddr'; import PeerId from 'peer-id'; import { RelayCodec, WakuRelay } from './waku_relay'; diff --git a/src/test_utils/nim_waku.ts b/src/test_utils/nim_waku.ts index 61581c1702..f8f7efae54 100644 --- a/src/test_utils/nim_waku.ts +++ b/src/test_utils/nim_waku.ts @@ -4,8 +4,7 @@ import { randomInt } from 'crypto'; import appRoot from 'app-root-path'; import axios from 'axios'; import debug from 'debug'; -import Multiaddr from 'multiaddr'; -import multiaddr from 'multiaddr'; +import { Multiaddr, multiaddr } from 'multiaddr'; import PeerId from 'peer-id'; import { WakuMessage } from '../lib/waku_message'; @@ -199,6 +198,7 @@ export class NimWaku { const res = await this.info(); this.multiaddrWithId = multiaddr(res.listenStr); const peerIdStr = this.multiaddrWithId.getPeerId(); + if (!peerIdStr) throw 'Nim-waku multiaddr does not contain peerId'; this.peerId = PeerId.createFromB58String(peerIdStr); return { peerId: this.peerId, multiaddrWithId: this.multiaddrWithId }; } From df5a4f8326c7f19597037f192abe5b85a3053fb2 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Wed, 21 Apr 2021 15:51:52 +1000 Subject: [PATCH 02/20] waku is undefined --- src/chat/chat_message.ts | 1 + web-chat/package-lock.json | 628 +++++++++++++++++++++++++++++++++++- web-chat/package.json | 3 + web-chat/src/App.tsx | 60 +++- web-chat/src/Send.tsx | 8 +- web-chat/src/WakuContext.ts | 5 +- 6 files changed, 681 insertions(+), 24 deletions(-) diff --git a/src/chat/chat_message.ts b/src/chat/chat_message.ts index 855245aca1..b534b87ce3 100644 --- a/src/chat/chat_message.ts +++ b/src/chat/chat_message.ts @@ -2,6 +2,7 @@ import { Reader } from 'protobufjs/minimal'; import { ChatMessageProto } from '../proto/chat/v2/chat_message'; +// TODO: Move to waku library? export class ChatMessage { public constructor( public timestamp: Date, diff --git a/web-chat/package-lock.json b/web-chat/package-lock.json index 3434e7aeae..e0c8bb6f25 100644 --- a/web-chat/package-lock.json +++ b/web-chat/package-lock.json @@ -15,10 +15,13 @@ "@types/node": "^12.20.7", "@types/react": "^17.0.3", "@types/react-dom": "^17.0.3", + "peer-id": "^0.14.8", "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3", "typescript": "^4.2.4", + "waku": "file:../build/main/lib", + "waku-chat": "file:../build/main/chat", "web-vitals": "^1.1.1" }, "devDependencies": { @@ -27,6 +30,8 @@ "prettier": "^2.2.1" } }, + "../build/main/chat": {}, + "../build/main/lib": {}, "node_modules/@babel/code-frame": { "version": "7.12.13", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz", @@ -2666,6 +2671,11 @@ "react-dom": "^16.8.0 || ^17.0.0" } }, + "node_modules/@multiformats/base-x": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@multiformats/base-x/-/base-x-4.0.1.tgz", + "integrity": "sha512-eMk0b9ReBbV23xXU693TAIrLyeO5iTgBZGSJfpqriG8UkYvr/hC9u9pyMlAakDNHWmbhMZCDs6KQO0jzKD8OTw==" + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", @@ -2775,6 +2785,60 @@ "node": ">= 8" } }, + "node_modules/@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=" + }, + "node_modules/@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" + }, + "node_modules/@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" + }, + "node_modules/@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=" + }, + "node_modules/@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", + "dependencies": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "node_modules/@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=" + }, + "node_modules/@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=" + }, + "node_modules/@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=" + }, + "node_modules/@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=" + }, + "node_modules/@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" + }, "node_modules/@rollup/plugin-node-resolve": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.3.tgz", @@ -3426,6 +3490,11 @@ "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=" }, + "node_modules/@types/long": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", + "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" + }, "node_modules/@types/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.4.tgz", @@ -5089,11 +5158,15 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "optional": true, "dependencies": { "file-uri-to-path": "1.0.0" } }, + "node_modules/blakejs": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.1.0.tgz", + "integrity": "sha1-ad+S75U6qIylGjLfarHFShVfx6U=" + }, "node_modules/bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -5601,6 +5674,21 @@ "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==" }, + "node_modules/cids": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/cids/-/cids-1.1.6.tgz", + "integrity": "sha512-5P+Jas2bVpjiHibp/SOwKY+v7JhAjTChaAZN+vCIrsWXn/JZV0frX22Vp5zZgEyJRPco79pX+yNQ2S3LkRukHQ==", + "dependencies": { + "multibase": "^4.0.1", + "multicodec": "^3.0.1", + "multihashes": "^4.0.1", + "uint8arrays": "^2.1.3" + }, + "engines": { + "node": ">=4.0.0", + "npm": ">=3.0.0" + } + }, "node_modules/cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", @@ -5615,6 +5703,11 @@ "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-0.6.0.tgz", "integrity": "sha512-uc2Vix1frTfnuzxxu1Hp4ktSvM3QaI4oXl4ZUqL1wjTu/BGki9TrCWoqLTg/drR1KwAEarXuRFCG2Svr1GxPFw==" }, + "node_modules/class-is": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/class-is/-/class-is-1.1.0.tgz", + "integrity": "sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw==" + }, "node_modules/class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -7654,6 +7747,11 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" + }, "node_modules/errno": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", @@ -9044,8 +9142,7 @@ "node_modules/file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "optional": true + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" }, "node_modules/filesize": { "version": "6.1.0", @@ -11061,6 +11158,18 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, + "node_modules/iso-random-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/iso-random-stream/-/iso-random-stream-2.0.0.tgz", + "integrity": "sha512-lGuIu104KfBV9ubYTSaE3GeAr6I69iggXxBHbTBc5u/XKlwlWl0LCytnkIZissaKqvxablwRD9B3ktVnmIUnEg==", + "dependencies": { + "events": "^3.3.0", + "readable-stream": "^3.4.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", @@ -13104,6 +13213,11 @@ "node": ">=8" } }, + "node_modules/js-sha3": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -13361,6 +13475,11 @@ "node": ">=4.0" } }, + "node_modules/keypair": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/keypair/-/keypair-1.0.3.tgz", + "integrity": "sha512-0wjZ2z/SfZZq01+3/8jYLd8aEShSa+aat1zyPGQY3IuKoEAp6DJGvu2zt6snELrQU9jbCkIlCyNOD7RdQbHhkQ==" + }, "node_modules/killable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz", @@ -13432,6 +13551,30 @@ "node": ">= 0.8.0" } }, + "node_modules/libp2p-crypto": { + "version": "0.19.4", + "resolved": "https://registry.npmjs.org/libp2p-crypto/-/libp2p-crypto-0.19.4.tgz", + "integrity": "sha512-8iUwiNlU/sFEtXQpxaehmXUQ5Fw6r52H7NH0d8ZSb8nKBbO6r8y8ft6f1to8A81SrFOVd4/zsjEzokpedDvRgw==", + "dependencies": { + "err-code": "^3.0.1", + "is-typedarray": "^1.0.0", + "iso-random-stream": "^2.0.0", + "keypair": "^1.0.1", + "multibase": "^4.0.3", + "multicodec": "^3.0.1", + "multihashes": "^4.0.2", + "multihashing-async": "^2.1.2", + "node-forge": "^0.10.0", + "pem-jwk": "^2.0.0", + "protobufjs": "^6.10.2", + "secp256k1": "^4.0.0", + "uint8arrays": "^2.1.4", + "ursa-optional": "^0.10.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/lines-and-columns": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", @@ -13579,6 +13722,11 @@ "url": "https://tidelift.com/funding/github/npm/loglevel" } }, + "node_modules/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -14053,6 +14201,18 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/multibase": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.4.tgz", + "integrity": "sha512-8/JmrdSGzlw6KTgAJCOqUBSGd1V6186i/X8dDCGy/lbCKrQ+1QB6f3HE+wPr7Tpdj4U3gutaj9jG2rNX6UpiJg==", + "dependencies": { + "@multiformats/base-x": "^4.0.1" + }, + "engines": { + "node": ">=12.0.0", + "npm": ">=6.0.0" + } + }, "node_modules/multicast-dns": { "version": "6.2.3", "resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-6.2.3.tgz", @@ -14070,11 +14230,58 @@ "resolved": "https://registry.npmjs.org/multicast-dns-service-types/-/multicast-dns-service-types-1.1.0.tgz", "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=" }, + "node_modules/multicodec": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-3.0.1.tgz", + "integrity": "sha512-Y6j3wiPojvkF/z6KFIGt84KdJdP2oILEdzc/3YbD3qQ3EerhqtYlfsZTPPNVoCCxNZZdzIpCKrdYFSav17sIrQ==", + "dependencies": { + "uint8arrays": "^2.1.3", + "varint": "^5.0.2" + } + }, + "node_modules/multihashes": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/multihashes/-/multihashes-4.0.2.tgz", + "integrity": "sha512-xpx++1iZr4ZQHjN1mcrXS6904R36LWLxX/CBifczjtmrtCXEX623DMWOF1eiNSg+pFpiZDFVBgou/4v6ayCHSQ==", + "dependencies": { + "multibase": "^4.0.1", + "uint8arrays": "^2.1.3", + "varint": "^5.0.2" + }, + "engines": { + "node": ">=12.0.0", + "npm": ">=6.0.0" + } + }, + "node_modules/multihashing-async": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/multihashing-async/-/multihashing-async-2.1.2.tgz", + "integrity": "sha512-FTPNnWWxwIK5dXXmTFhySSF8Fkdqf7vzqpV09+RWsmfUhrsL/b3Arg3+bRrBnXTtjxm3JRGI3wSAtQHL0QCxhQ==", + "dependencies": { + "blakejs": "^1.1.0", + "err-code": "^3.0.0", + "js-sha3": "^0.8.0", + "multihashes": "^4.0.1", + "murmurhash3js-revisited": "^3.0.0", + "uint8arrays": "^2.1.3" + }, + "engines": { + "node": ">=12.0.0", + "npm": ">=6.0.0" + } + }, + "node_modules/murmurhash3js-revisited": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/murmurhash3js-revisited/-/murmurhash3js-revisited-3.0.0.tgz", + "integrity": "sha512-/sF3ee6zvScXMb1XFJ8gDsSnY+X8PbOyjIuBhtgis10W2Jx4ZjIhikUCIF9c4gpJxVnQIsPAFrSwTCuAjicP6g==", + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/nan": { "version": "2.14.2", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", - "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==", - "optional": true + "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==" }, "node_modules/nanoid": { "version": "3.1.22", @@ -14153,6 +14360,11 @@ "tslib": "^2.0.3" } }, + "node_modules/node-addon-api": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", + "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" + }, "node_modules/node-forge": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", @@ -14161,6 +14373,16 @@ "node": ">= 6.0.0" } }, + "node_modules/node-gyp-build": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", + "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==", + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -15106,6 +15328,40 @@ "node": ">=0.12" } }, + "node_modules/peer-id": { + "version": "0.14.8", + "resolved": "https://registry.npmjs.org/peer-id/-/peer-id-0.14.8.tgz", + "integrity": "sha512-GpuLpob/9FrEFvyZrKKsISEkaBYsON2u0WtiawLHj1ii6ewkoeRiSDFLyIefYhw0jGvQoeoZS05jaT52X7Bvig==", + "dependencies": { + "cids": "^1.1.5", + "class-is": "^1.1.0", + "libp2p-crypto": "^0.19.0", + "minimist": "^1.2.5", + "multihashes": "^4.0.2", + "protobufjs": "^6.10.2", + "uint8arrays": "^2.0.5" + }, + "bin": { + "peer-id": "src/bin.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/pem-jwk": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pem-jwk/-/pem-jwk-2.0.0.tgz", + "integrity": "sha512-rFxu7rVoHgQ5H9YsP50dDWf0rHjreVA2z0yPiWr5WdH/UHb29hKtF7h6l8vNd1cbYR1t0QL+JKhW55a2ZV4KtA==", + "dependencies": { + "asn1.js": "^5.0.1" + }, + "bin": { + "pem-jwk": "bin/pem-jwk.js" + }, + "engines": { + "node": ">=5.10.0" + } + }, "node_modules/performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -16707,6 +16963,36 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "node_modules/protobufjs": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", + "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", + "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/long": "^4.0.1", + "@types/node": "^13.7.0", + "long": "^4.0.0" + }, + "bin": { + "pbjs": "bin/pbjs", + "pbts": "bin/pbts" + } + }, + "node_modules/protobufjs/node_modules/@types/node": { + "version": "13.13.50", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.50.tgz", + "integrity": "sha512-y7kkh+hX/0jZNxMyBR/6asG0QMSaPSzgeVK63dhWHl4QAXCQB8lExXmzLL6SzmOgKHydtawpMnNhlDbv7DXPEA==" + }, "node_modules/proxy-addr": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", @@ -18376,6 +18662,20 @@ "url": "https://opencollective.com/webpack" } }, + "node_modules/secp256k1": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.2.tgz", + "integrity": "sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg==", + "hasInstallScript": true, + "dependencies": { + "elliptic": "^6.5.2", + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/select-hose": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", @@ -20271,6 +20571,14 @@ "node": ">=4.2.0" } }, + "node_modules/uint8arrays": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.5.tgz", + "integrity": "sha512-CSR7AO+4AHUeSOnZ/NBNCElDeWfRh9bXtOck27083kc7SznmmHIhNEkEOCQOn0wvrIMjS3IH0TNLR16vuc46mA==", + "dependencies": { + "multibase": "^4.0.1" + } + }, "node_modules/unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", @@ -20542,6 +20850,19 @@ "node": ">=0.4.x" } }, + "node_modules/ursa-optional": { + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/ursa-optional/-/ursa-optional-0.10.2.tgz", + "integrity": "sha512-TKdwuLboBn7M34RcvVTuQyhvrA8gYKapuVdm0nBP0mnBc7oECOfUQZrY91cefL3/nm64ZyrejSRrhTVdX7NG/A==", + "hasInstallScript": true, + "dependencies": { + "bindings": "^1.5.0", + "nan": "^2.14.2" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", @@ -20634,6 +20955,11 @@ "spdx-expression-parse": "^3.0.0" } }, + "node_modules/varint": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz", + "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -20694,6 +21020,14 @@ "node": ">=10" } }, + "node_modules/waku": { + "resolved": "../build/main/lib", + "link": true + }, + "node_modules/waku-chat": { + "resolved": "../build/main/chat", + "link": true + }, "node_modules/walker": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.7.tgz", @@ -24682,6 +25016,11 @@ "react-is": "^16.8.0 || ^17.0.0" } }, + "@multiformats/base-x": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@multiformats/base-x/-/base-x-4.0.1.tgz", + "integrity": "sha512-eMk0b9ReBbV23xXU693TAIrLyeO5iTgBZGSJfpqriG8UkYvr/hC9u9pyMlAakDNHWmbhMZCDs6KQO0jzKD8OTw==" + }, "@nodelib/fs.scandir": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", @@ -24741,6 +25080,60 @@ } } }, + "@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=" + }, + "@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" + }, + "@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" + }, + "@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=" + }, + "@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", + "requires": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=" + }, + "@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=" + }, + "@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=" + }, + "@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=" + }, + "@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" + }, "@rollup/plugin-node-resolve": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.3.tgz", @@ -25225,6 +25618,11 @@ "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=" }, + "@types/long": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", + "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" + }, "@types/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.4.tgz", @@ -26553,11 +26951,15 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "optional": true, "requires": { "file-uri-to-path": "1.0.0" } }, + "blakejs": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.1.0.tgz", + "integrity": "sha1-ad+S75U6qIylGjLfarHFShVfx6U=" + }, "bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -26972,6 +27374,17 @@ "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==" }, + "cids": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/cids/-/cids-1.1.6.tgz", + "integrity": "sha512-5P+Jas2bVpjiHibp/SOwKY+v7JhAjTChaAZN+vCIrsWXn/JZV0frX22Vp5zZgEyJRPco79pX+yNQ2S3LkRukHQ==", + "requires": { + "multibase": "^4.0.1", + "multicodec": "^3.0.1", + "multihashes": "^4.0.1", + "uint8arrays": "^2.1.3" + } + }, "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", @@ -26986,6 +27399,11 @@ "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-0.6.0.tgz", "integrity": "sha512-uc2Vix1frTfnuzxxu1Hp4ktSvM3QaI4oXl4ZUqL1wjTu/BGki9TrCWoqLTg/drR1KwAEarXuRFCG2Svr1GxPFw==" }, + "class-is": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/class-is/-/class-is-1.1.0.tgz", + "integrity": "sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw==" + }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -28633,6 +29051,11 @@ "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==" }, + "err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" + }, "errno": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", @@ -29676,8 +30099,7 @@ "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "optional": true + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" }, "filesize": { "version": "6.1.0", @@ -31224,6 +31646,15 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, + "iso-random-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/iso-random-stream/-/iso-random-stream-2.0.0.tgz", + "integrity": "sha512-lGuIu104KfBV9ubYTSaE3GeAr6I69iggXxBHbTBc5u/XKlwlWl0LCytnkIZissaKqvxablwRD9B3ktVnmIUnEg==", + "requires": { + "events": "^3.3.0", + "readable-stream": "^3.4.0" + } + }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", @@ -32727,6 +33158,11 @@ } } }, + "js-sha3": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -32942,6 +33378,11 @@ "object.assign": "^4.1.2" } }, + "keypair": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/keypair/-/keypair-1.0.3.tgz", + "integrity": "sha512-0wjZ2z/SfZZq01+3/8jYLd8aEShSa+aat1zyPGQY3IuKoEAp6DJGvu2zt6snELrQU9jbCkIlCyNOD7RdQbHhkQ==" + }, "killable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz", @@ -32998,6 +33439,27 @@ "type-check": "~0.4.0" } }, + "libp2p-crypto": { + "version": "0.19.4", + "resolved": "https://registry.npmjs.org/libp2p-crypto/-/libp2p-crypto-0.19.4.tgz", + "integrity": "sha512-8iUwiNlU/sFEtXQpxaehmXUQ5Fw6r52H7NH0d8ZSb8nKBbO6r8y8ft6f1to8A81SrFOVd4/zsjEzokpedDvRgw==", + "requires": { + "err-code": "^3.0.1", + "is-typedarray": "^1.0.0", + "iso-random-stream": "^2.0.0", + "keypair": "^1.0.1", + "multibase": "^4.0.3", + "multicodec": "^3.0.1", + "multihashes": "^4.0.2", + "multihashing-async": "^2.1.2", + "node-forge": "^0.10.0", + "pem-jwk": "^2.0.0", + "protobufjs": "^6.10.2", + "secp256k1": "^4.0.0", + "uint8arrays": "^2.1.4", + "ursa-optional": "^0.10.1" + } + }, "lines-and-columns": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", @@ -33119,6 +33581,11 @@ "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.7.1.tgz", "integrity": "sha512-Hesni4s5UkWkwCGJMQGAh71PaLUmKFM60dHvq0zi/vDhhrzuk+4GgNbTXJ12YYQJn6ZKBDNIjYcuQGKudvqrIw==" }, + "long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -33497,6 +33964,14 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "multibase": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/multibase/-/multibase-4.0.4.tgz", + "integrity": "sha512-8/JmrdSGzlw6KTgAJCOqUBSGd1V6186i/X8dDCGy/lbCKrQ+1QB6f3HE+wPr7Tpdj4U3gutaj9jG2rNX6UpiJg==", + "requires": { + "@multiformats/base-x": "^4.0.1" + } + }, "multicast-dns": { "version": "6.2.3", "resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-6.2.3.tgz", @@ -33511,11 +33986,47 @@ "resolved": "https://registry.npmjs.org/multicast-dns-service-types/-/multicast-dns-service-types-1.1.0.tgz", "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=" }, + "multicodec": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-3.0.1.tgz", + "integrity": "sha512-Y6j3wiPojvkF/z6KFIGt84KdJdP2oILEdzc/3YbD3qQ3EerhqtYlfsZTPPNVoCCxNZZdzIpCKrdYFSav17sIrQ==", + "requires": { + "uint8arrays": "^2.1.3", + "varint": "^5.0.2" + } + }, + "multihashes": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/multihashes/-/multihashes-4.0.2.tgz", + "integrity": "sha512-xpx++1iZr4ZQHjN1mcrXS6904R36LWLxX/CBifczjtmrtCXEX623DMWOF1eiNSg+pFpiZDFVBgou/4v6ayCHSQ==", + "requires": { + "multibase": "^4.0.1", + "uint8arrays": "^2.1.3", + "varint": "^5.0.2" + } + }, + "multihashing-async": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/multihashing-async/-/multihashing-async-2.1.2.tgz", + "integrity": "sha512-FTPNnWWxwIK5dXXmTFhySSF8Fkdqf7vzqpV09+RWsmfUhrsL/b3Arg3+bRrBnXTtjxm3JRGI3wSAtQHL0QCxhQ==", + "requires": { + "blakejs": "^1.1.0", + "err-code": "^3.0.0", + "js-sha3": "^0.8.0", + "multihashes": "^4.0.1", + "murmurhash3js-revisited": "^3.0.0", + "uint8arrays": "^2.1.3" + } + }, + "murmurhash3js-revisited": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/murmurhash3js-revisited/-/murmurhash3js-revisited-3.0.0.tgz", + "integrity": "sha512-/sF3ee6zvScXMb1XFJ8gDsSnY+X8PbOyjIuBhtgis10W2Jx4ZjIhikUCIF9c4gpJxVnQIsPAFrSwTCuAjicP6g==" + }, "nan": { "version": "2.14.2", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", - "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==", - "optional": true + "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==" }, "nanoid": { "version": "3.1.22", @@ -33582,11 +34093,21 @@ "tslib": "^2.0.3" } }, + "node-addon-api": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", + "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" + }, "node-forge": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", "integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==" }, + "node-gyp-build": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", + "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==" + }, "node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -34322,6 +34843,28 @@ "sha.js": "^2.4.8" } }, + "peer-id": { + "version": "0.14.8", + "resolved": "https://registry.npmjs.org/peer-id/-/peer-id-0.14.8.tgz", + "integrity": "sha512-GpuLpob/9FrEFvyZrKKsISEkaBYsON2u0WtiawLHj1ii6ewkoeRiSDFLyIefYhw0jGvQoeoZS05jaT52X7Bvig==", + "requires": { + "cids": "^1.1.5", + "class-is": "^1.1.0", + "libp2p-crypto": "^0.19.0", + "minimist": "^1.2.5", + "multihashes": "^4.0.2", + "protobufjs": "^6.10.2", + "uint8arrays": "^2.0.5" + } + }, + "pem-jwk": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pem-jwk/-/pem-jwk-2.0.0.tgz", + "integrity": "sha512-rFxu7rVoHgQ5H9YsP50dDWf0rHjreVA2z0yPiWr5WdH/UHb29hKtF7h6l8vNd1cbYR1t0QL+JKhW55a2ZV4KtA==", + "requires": { + "asn1.js": "^5.0.1" + } + }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -35609,6 +36152,33 @@ } } }, + "protobufjs": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", + "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", + "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/long": "^4.0.1", + "@types/node": "^13.7.0", + "long": "^4.0.0" + }, + "dependencies": { + "@types/node": { + "version": "13.13.50", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.50.tgz", + "integrity": "sha512-y7kkh+hX/0jZNxMyBR/6asG0QMSaPSzgeVK63dhWHl4QAXCQB8lExXmzLL6SzmOgKHydtawpMnNhlDbv7DXPEA==" + } + } + }, "proxy-addr": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", @@ -36897,6 +37467,16 @@ "ajv-keywords": "^3.5.2" } }, + "secp256k1": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.2.tgz", + "integrity": "sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg==", + "requires": { + "elliptic": "^6.5.2", + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.0" + } + }, "select-hose": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", @@ -38422,6 +39002,14 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==" }, + "uint8arrays": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.5.tgz", + "integrity": "sha512-CSR7AO+4AHUeSOnZ/NBNCElDeWfRh9bXtOck27083kc7SznmmHIhNEkEOCQOn0wvrIMjS3IH0TNLR16vuc46mA==", + "requires": { + "multibase": "^4.0.1" + } + }, "unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", @@ -38630,6 +39218,15 @@ "requires-port": "^1.0.0" } }, + "ursa-optional": { + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/ursa-optional/-/ursa-optional-0.10.2.tgz", + "integrity": "sha512-TKdwuLboBn7M34RcvVTuQyhvrA8gYKapuVdm0nBP0mnBc7oECOfUQZrY91cefL3/nm64ZyrejSRrhTVdX7NG/A==", + "requires": { + "bindings": "^1.5.0", + "nan": "^2.14.2" + } + }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", @@ -38711,6 +39308,11 @@ "spdx-expression-parse": "^3.0.0" } }, + "varint": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz", + "integrity": "sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow==" + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -38758,6 +39360,12 @@ "xml-name-validator": "^3.0.0" } }, + "waku": { + "version": "file:../build/main/lib" + }, + "waku-chat": { + "version": "file:../build/main/chat" + }, "walker": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.7.tgz", diff --git a/web-chat/package.json b/web-chat/package.json index 2e95ecfd98..eb5629be9b 100644 --- a/web-chat/package.json +++ b/web-chat/package.json @@ -11,10 +11,13 @@ "@types/node": "^12.20.7", "@types/react": "^17.0.3", "@types/react-dom": "^17.0.3", + "peer-id": "^0.14.8", "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3", "typescript": "^4.2.4", + "waku": "file:../build/main/lib", + "waku-chat": "file:../build/main/chat", "web-vitals": "^1.1.1" }, "scripts": { diff --git a/web-chat/src/App.tsx b/web-chat/src/App.tsx index 430729d6b1..3630d292c7 100644 --- a/web-chat/src/App.tsx +++ b/web-chat/src/App.tsx @@ -1,20 +1,27 @@ import { Paper } from '@material-ui/core'; +import { multiaddr } from 'multiaddr'; +import PeerId from 'peer-id'; import React from 'react'; import './App.css'; +import { ChatMessage } from 'waku-chat/chat_message'; +import { WakuMessage } from 'waku/waku_message'; +import { RelayDefaultTopic } from 'waku/waku_relay'; import Room from './Room'; -import WakuMock from './WakuMock'; +import Waku from 'waku/waku'; import { WakuContext } from './WakuContext'; +export const ChatContentTopic = 'dingpu'; + interface Props { } interface State { messages: string[], - waku?: WakuMock + waku?: Waku } class App extends React.Component { - waku?: WakuMock; + waku?: Waku; constructor(props: Props) { super(props); @@ -23,15 +30,36 @@ class App extends React.Component { messages: [] }; - WakuMock.create().then((wakuMock) => { + Waku.create({}).then((waku) => { + this.state = { waku: waku, messages: this.state.messages }; - this.setState({ waku: wakuMock, messages: this.state.messages }); + waku.libp2p.peerStore.addressBook + .add(PeerId.createFromB58String('QmUJKveCpfwA4cY1zRybMEt5z64FRtMHLFFQwndWrSfMmf'), + [multiaddr('/ip4/127.0.0.1/tcp/7777/ws')]); + + waku.libp2p.pubsub.on(RelayDefaultTopic, (event) => { + const wakuMsg = WakuMessage.decode(event.data); + if (wakuMsg.payload) { + const chatMsg = ChatMessage.decode(wakuMsg.payload); + const msgStr = printMessage(chatMsg); + + const messages = this.state.messages.slice(); + messages.push(msgStr); + this.setState({ messages }); + } - wakuMock.on('message', (message) => { - const messages = this.state.messages.slice(); - messages.push(message.message); - this.setState({ messages }); }); + + // Fire and forget + // waku.dial('/ip4/127.0.0.1/tcp/7777/ws/p2p/QmUJKveCpfwA4cY1zRybMEt5z64FRtMHLFFQwndWrSfMmf').then(() => { + // console.log('Remote node dialed'); + // }).catch((e) => { + // console.log('Error when dialing peer ', e); + // }); + }).catch((e) => { + console.log('Error starting waku ', e); + }).then(()=> { + console.log("Waku is started"); }); } @@ -40,7 +68,7 @@ class App extends React.Component {
- + @@ -51,3 +79,15 @@ class App extends React.Component { } export default App; + +// TODO: Make it a proper component +function printMessage(chatMsg: ChatMessage) { + const timestamp = chatMsg.timestamp.toLocaleString([], { + month: 'short', + day: 'numeric', + hour: 'numeric', + minute: '2-digit', + hour12: false + }); + return `<${timestamp}> ${chatMsg.nick}: ${chatMsg.message}`; +} diff --git a/web-chat/src/Send.tsx b/web-chat/src/Send.tsx index 1f393ed1d9..a45f596764 100644 --- a/web-chat/src/Send.tsx +++ b/web-chat/src/Send.tsx @@ -1,4 +1,7 @@ import React from 'react'; +import { ChatMessage } from 'waku-chat/chat_message'; +import { WakuMessage } from 'waku/waku_message'; +import { ChatContentTopic } from './App'; import { useWaku } from './WakuContext'; import { Button } from '@material-ui/core'; @@ -10,7 +13,10 @@ const Send = (props: Props) => { const { waku } = useWaku(); const handleClick = async () => { - await waku!.send(props.message); + const chatMessage = new ChatMessage(new Date(), 'web-chat', props.message); + + const wakuMsg = WakuMessage.fromBytes(chatMessage.encode(), ChatContentTopic); + await waku!.relay.send(wakuMsg); }; return ( diff --git a/web-chat/src/WakuContext.ts b/web-chat/src/WakuContext.ts index fb6c68c4c1..6650c74f5c 100644 --- a/web-chat/src/WakuContext.ts +++ b/web-chat/src/WakuContext.ts @@ -1,9 +1,8 @@ import { createContext, useContext } from 'react'; -import WakuMock from './WakuMock'; +import Waku from 'waku/waku'; export type WakuContextType = { - waku?: WakuMock; - // setWaku: (waku: WakuMock) => void; + waku?: Waku; }; export const WakuContext = createContext({ waku: undefined }); From 3285d498c7219586b943b7cc2c8a48736f287f30 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Wed, 21 Apr 2021 16:11:07 +1000 Subject: [PATCH 03/20] Use useEffect for async start of waku --- web-chat/src/App.tsx | 95 +++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 49 deletions(-) diff --git a/web-chat/src/App.tsx b/web-chat/src/App.tsx index 3630d292c7..29df21e892 100644 --- a/web-chat/src/App.tsx +++ b/web-chat/src/App.tsx @@ -1,7 +1,7 @@ import { Paper } from '@material-ui/core'; import { multiaddr } from 'multiaddr'; import PeerId from 'peer-id'; -import React from 'react'; +import React, { useEffect, useState } from 'react'; import './App.css'; import { ChatMessage } from 'waku-chat/chat_message'; import { WakuMessage } from 'waku/waku_message'; @@ -20,66 +20,63 @@ interface State { waku?: Waku } -class App extends React.Component { - waku?: Waku; +export default function App () { + let [state, setState] = useState({ messages: [] }); - constructor(props: Props) { - super(props); - this.state = { - messages: [] - }; + useEffect(() => { + async function initWaku() { + try { + const waku = await Waku.create({}); + setState(({ messages }) => ( + { waku, messages } + )); - Waku.create({}).then((waku) => { - this.state = { waku: waku, messages: this.state.messages }; + waku.libp2p.pubsub.on(RelayDefaultTopic, (event) => { + const wakuMsg = WakuMessage.decode(event.data); + if (wakuMsg.payload) { + const chatMsg = ChatMessage.decode(wakuMsg.payload); + const msgStr = printMessage(chatMsg); - waku.libp2p.peerStore.addressBook - .add(PeerId.createFromB58String('QmUJKveCpfwA4cY1zRybMEt5z64FRtMHLFFQwndWrSfMmf'), - [multiaddr('/ip4/127.0.0.1/tcp/7777/ws')]); + const messages = state.messages.slice(); + messages.push(msgStr); + setState({ messages, waku }); + } + }); - waku.libp2p.pubsub.on(RelayDefaultTopic, (event) => { - const wakuMsg = WakuMessage.decode(event.data); - if (wakuMsg.payload) { - const chatMsg = ChatMessage.decode(wakuMsg.payload); - const msgStr = printMessage(chatMsg); - - const messages = this.state.messages.slice(); - messages.push(msgStr); - this.setState({ messages }); + try { + await waku.dial('/ip4/127.0.0.1/tcp/7777/ws/p2p/QmUJKveCpfwA4cY1zRybMEt5z64FRtMHLFFQwndWrSfMmf'); + console.log('Remote node dialed'); + } catch (e) { + console.log('Error when dialing peer ', e); } + } catch (e) { + console.log('Issue starting waku ', e); + } - }); + } - // Fire and forget - // waku.dial('/ip4/127.0.0.1/tcp/7777/ws/p2p/QmUJKveCpfwA4cY1zRybMEt5z64FRtMHLFFQwndWrSfMmf').then(() => { - // console.log('Remote node dialed'); - // }).catch((e) => { - // console.log('Error when dialing peer ', e); - // }); - }).catch((e) => { - console.log('Error starting waku ', e); - }).then(()=> { - console.log("Waku is started"); - }); - } + if (!state.waku) { + initWaku() + .then(() => console.log('Waku init done')) + .catch((e) => console.log('Waku init failed ', e)); + } + }, [state.waku]); - render() { - return ( -
-
- - - - - -
+ + return ( +
+
+ + + + +
- ); - } +
+ ); } -export default App; - // TODO: Make it a proper component function printMessage(chatMsg: ChatMessage) { const timestamp = chatMsg.timestamp.toLocaleString([], { From 09fa8a0447c470de0b2bc71843ca619b21d83431 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 10:39:05 +1000 Subject: [PATCH 04/20] Must pass filter.all to connect to ip4 ws peer --- src/lib/waku.ts | 10 ++++++++++ src/types/types.d.ts | 1 + web-chat/src/App.tsx | 16 +++++----------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/lib/waku.ts b/src/lib/waku.ts index 459874a483..7ef89a9123 100644 --- a/src/lib/waku.ts +++ b/src/lib/waku.ts @@ -3,12 +3,15 @@ import Mplex from 'libp2p-mplex'; import { bytes } from 'libp2p-noise/dist/src/@types/basic'; import { Noise } from 'libp2p-noise/dist/src/noise'; import Websockets from 'libp2p-websockets'; +import filters from 'libp2p-websockets/src/filters'; import { Multiaddr } from 'multiaddr'; import PeerId from 'peer-id'; import { RelayCodec, WakuRelay } from './waku_relay'; import { StoreCodec, WakuStore } from './waku_store'; +const transportKey = Websockets.prototype[Symbol.toStringTag]; + export interface CreateOptions { listenAddresses: string[]; staticNoiseKey: bytes | undefined; @@ -70,6 +73,13 @@ export default class Waku { // @ts-ignore: Type needs update pubsub: WakuRelay, }, + config: { + transport: { + [transportKey]: { + filter: filters.all, + }, + }, + }, }); const wakuStore = new WakuStore(libp2p); diff --git a/src/types/types.d.ts b/src/types/types.d.ts index 673adc8b5b..32d9bbda39 100644 --- a/src/types/types.d.ts +++ b/src/types/types.d.ts @@ -14,3 +14,4 @@ declare module 'libp2p-secio' { export = Secio; } declare module 'libp2p-websockets'; +declare module 'libp2p-websockets/src/filters'; diff --git a/web-chat/src/App.tsx b/web-chat/src/App.tsx index 29df21e892..c7e78be74a 100644 --- a/web-chat/src/App.tsx +++ b/web-chat/src/App.tsx @@ -12,15 +12,12 @@ import { WakuContext } from './WakuContext'; export const ChatContentTopic = 'dingpu'; -interface Props { -} - interface State { messages: string[], waku?: Waku } -export default function App () { +export default function App() { let [state, setState] = useState({ messages: [] }); @@ -44,12 +41,9 @@ export default function App () { } }); - try { - await waku.dial('/ip4/127.0.0.1/tcp/7777/ws/p2p/QmUJKveCpfwA4cY1zRybMEt5z64FRtMHLFFQwndWrSfMmf'); - console.log('Remote node dialed'); - } catch (e) { - console.log('Error when dialing peer ', e); - } + waku.libp2p.peerStore.addressBook.add( + PeerId.createFromB58String('QmbEnEniueE2Cetej6UkYAtvHuXuare4fSEeyvm43kdmfq'), + [multiaddr('/ip4/127.0.0.1/tcp/7777/ws')]); } catch (e) { console.log('Issue starting waku ', e); } @@ -61,7 +55,7 @@ export default function App () { .then(() => console.log('Waku init done')) .catch((e) => console.log('Waku init failed ', e)); } - }, [state.waku]); + }); return ( From 1e1ad0332cb2470681701f550e67ec142f8b4785 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 10:58:56 +1000 Subject: [PATCH 05/20] Messages do not replace each other --- web-chat/src/App.tsx | 41 ++++++++++++++--------------------------- web-chat/src/Room.tsx | 23 ++++++++++++++++++----- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/web-chat/src/App.tsx b/web-chat/src/App.tsx index c7e78be74a..a18260238c 100644 --- a/web-chat/src/App.tsx +++ b/web-chat/src/App.tsx @@ -13,7 +13,7 @@ import { WakuContext } from './WakuContext'; export const ChatContentTopic = 'dingpu'; interface State { - messages: string[], + messages: ChatMessage[], waku?: Waku } @@ -25,20 +25,9 @@ export default function App() { async function initWaku() { try { const waku = await Waku.create({}); - setState(({ messages }) => ( - { waku, messages } - )); - waku.libp2p.pubsub.on(RelayDefaultTopic, (event) => { - const wakuMsg = WakuMessage.decode(event.data); - if (wakuMsg.payload) { - const chatMsg = ChatMessage.decode(wakuMsg.payload); - const msgStr = printMessage(chatMsg); - - const messages = state.messages.slice(); - messages.push(msgStr); - setState({ messages, waku }); - } + setState(({ messages }) => { + return {waku, messages}; }); waku.libp2p.peerStore.addressBook.add( @@ -54,10 +43,20 @@ export default function App() { initWaku() .then(() => console.log('Waku init done')) .catch((e) => console.log('Waku init failed ', e)); + } else { + state.waku.libp2p.pubsub.on(RelayDefaultTopic, (event) => { + const wakuMsg = WakuMessage.decode(event.data); + if (wakuMsg.payload) { + const chatMsg = ChatMessage.decode(wakuMsg.payload); + const messages = state.messages.slice(); + messages.push(chatMsg); + console.log("setState on ", messages); + setState({ messages, waku: state.waku }); + } + }); } }); - return (
@@ -70,15 +69,3 @@ export default function App() {
); } - -// TODO: Make it a proper component -function printMessage(chatMsg: ChatMessage) { - const timestamp = chatMsg.timestamp.toLocaleString([], { - month: 'short', - day: 'numeric', - hour: 'numeric', - minute: '2-digit', - hour12: false - }); - return `<${timestamp}> ${chatMsg.nick}: ${chatMsg.message}`; -} diff --git a/web-chat/src/Room.tsx b/web-chat/src/Room.tsx index 96a5bace22..8290724a8a 100644 --- a/web-chat/src/Room.tsx +++ b/web-chat/src/Room.tsx @@ -6,11 +6,12 @@ import { ListItemText } from '@material-ui/core'; import React from 'react'; +import { ChatMessage } from 'waku-chat/chat_message'; import MessageInput from './MessageInput'; import Send from './Send'; interface Props { - lines: string[], + lines: ChatMessage[], } interface State { @@ -58,16 +59,16 @@ export default class Room extends React.Component { } interface LinesProps { - messages: string[] + messages: ChatMessage[] } const Lines = (props: LinesProps) => { const renderedLines = []; - for (const line of props.messages) { + for (const i in props.messages) { renderedLines.push( - ); } @@ -78,3 +79,15 @@ const Lines = (props: LinesProps) => { ); }; + +// TODO: Make it a proper component +function printMessage(chatMsg: ChatMessage) { + const timestamp = chatMsg.timestamp.toLocaleString([], { + month: 'short', + day: 'numeric', + hour: 'numeric', + minute: '2-digit', + hour12: false + }); + return `<${timestamp}> ${chatMsg.nick}: ${chatMsg.message}`; +} From 9937652105b4cde6fac6fd05973932544379124d Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 11:09:10 +1000 Subject: [PATCH 06/20] Remove listener when unmounting component --- web-chat/src/App.tsx | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/web-chat/src/App.tsx b/web-chat/src/App.tsx index a18260238c..2cf1554022 100644 --- a/web-chat/src/App.tsx +++ b/web-chat/src/App.tsx @@ -27,7 +27,7 @@ export default function App() { const waku = await Waku.create({}); setState(({ messages }) => { - return {waku, messages}; + return { waku, messages }; }); waku.libp2p.peerStore.addressBook.add( @@ -39,21 +39,29 @@ export default function App() { } + const handleNewMessages = (event: { data: Uint8Array }) => { + const wakuMsg = WakuMessage.decode(event.data); + if (wakuMsg.payload) { + const chatMsg = ChatMessage.decode(wakuMsg.payload); + const messages = state.messages.slice(); + messages.push(chatMsg); + console.log('setState on ', messages); + setState({ messages, waku: state.waku }); + } + + }; + if (!state.waku) { initWaku() .then(() => console.log('Waku init done')) .catch((e) => console.log('Waku init failed ', e)); } else { - state.waku.libp2p.pubsub.on(RelayDefaultTopic, (event) => { - const wakuMsg = WakuMessage.decode(event.data); - if (wakuMsg.payload) { - const chatMsg = ChatMessage.decode(wakuMsg.payload); - const messages = state.messages.slice(); - messages.push(chatMsg); - console.log("setState on ", messages); - setState({ messages, waku: state.waku }); - } - }); + state.waku.libp2p.pubsub.on(RelayDefaultTopic, handleNewMessages); + + // To clean up listener when component unmounts + return () => { + state.waku?.libp2p.pubsub.removeListener(RelayDefaultTopic, handleNewMessages); + }; } }); From 69a3f73ee66ecb5586970c5db2c71cb40b2b2495 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 14:47:43 +1000 Subject: [PATCH 07/20] Self emit to see own messages --- src/lib/waku.ts | 41 +++++++++++++++------------- src/lib/waku_relay/index.ts | 53 ++++++++++++++++++++++++++++++------- web-chat/src/App.tsx | 2 +- 3 files changed, 67 insertions(+), 29 deletions(-) diff --git a/src/lib/waku.ts b/src/lib/waku.ts index 7ef89a9123..cd1e15ebc3 100644 --- a/src/lib/waku.ts +++ b/src/lib/waku.ts @@ -1,4 +1,4 @@ -import Libp2p from 'libp2p'; +import Libp2p, { Libp2pConfig, Libp2pModules, Libp2pOptions } from 'libp2p'; import Mplex from 'libp2p-mplex'; import { bytes } from 'libp2p-noise/dist/src/@types/basic'; import { Noise } from 'libp2p-noise/dist/src/noise'; @@ -12,16 +12,14 @@ import { StoreCodec, WakuStore } from './waku_store'; const transportKey = Websockets.prototype[Symbol.toStringTag]; -export interface CreateOptions { - listenAddresses: string[]; - staticNoiseKey: bytes | undefined; - modules: { - transport: import('libp2p-interfaces/src/transport/types').TransportFactory< - any, - any - >[]; - }; -} +export type CreateOptions = + | { + listenAddresses: string[] | undefined; + staticNoiseKey: bytes | undefined; + modules: Partial; + config: Partial; + } + | (Libp2pOptions & import('libp2p').CreateOptions); export default class Waku { public libp2p: Libp2p; @@ -52,6 +50,19 @@ export default class Waku { options ); + opts.config = Object.assign( + { + transport: { + [transportKey]: { + filter: filters.all, + }, + }, + }, + options.config + ); + + opts.modules = Object.assign({}, options.modules); + let transport = [Websockets]; if (opts.modules?.transport) { transport = transport.concat(opts.modules?.transport); @@ -73,13 +84,7 @@ export default class Waku { // @ts-ignore: Type needs update pubsub: WakuRelay, }, - config: { - transport: { - [transportKey]: { - filter: filters.all, - }, - }, - }, + config: opts.config, }); const wakuStore = new WakuStore(libp2p); diff --git a/src/lib/waku_relay/index.ts b/src/lib/waku_relay/index.ts index 487ca819bd..c04f5619d5 100644 --- a/src/lib/waku_relay/index.ts +++ b/src/lib/waku_relay/index.ts @@ -1,6 +1,15 @@ import Gossipsub from 'libp2p-gossipsub'; -import { Libp2p } from 'libp2p-gossipsub/src/interfaces'; +import { + AddrInfo, + Libp2p, + MessageIdFunction, +} from 'libp2p-gossipsub/src/interfaces'; import { ControlPrune, PeerInfo } from 'libp2p-gossipsub/src/message'; +import { MessageCache } from 'libp2p-gossipsub/src/message-cache'; +import { + PeerScoreParams, + PeerScoreThresholds, +} from 'libp2p-gossipsub/src/score'; import { createGossipRpc, messageIdToString, @@ -19,26 +28,50 @@ import { RelayHeartbeat } from './relay_heartbeat'; export * from './constants'; export * from './relay_heartbeat'; +/** + * See GossipOptions from libp2p-gossipsub + */ +interface GossipOptions { + emitSelf: boolean; + gossipIncoming: boolean; + fallbackToFloodsub: boolean; + floodPublish: boolean; + doPX: boolean; + msgIdFn: MessageIdFunction; + messageCache: MessageCache; + globalSignaturePolicy: string; + scoreParams: Partial; + scoreThresholds: Partial; + directPeers: AddrInfo[]; + D: number; + Dlo: number; + Dhi: number; + Dscore: number; + Dout: number; + Dlazy: number; +} + export class WakuRelay extends Gossipsub { heartbeat: RelayHeartbeat; /** * - * @param libp2p: Libp2p + * @param {Libp2p} libp2p + * @param {Partial} [options] */ - constructor(libp2p: Libp2p) { - super(libp2p, { - emitSelf: false, - // Ensure that no signature is expected in the messages. - globalSignaturePolicy: SignaturePolicy.StrictNoSign, - }); + constructor(libp2p: Libp2p, options?: Partial) { + super( + libp2p, + Object.assign(options, { + // Ensure that no signature is included nor expected in the messages. + globalSignaturePolicy: SignaturePolicy.StrictNoSign, + }) + ); this.heartbeat = new RelayHeartbeat(this); const multicodecs = [constants.RelayCodec]; - // This is the downside of using `libp2p-gossipsub` instead of - // implementing WakuRelay from scratch. Object.assign(this, { multicodecs }); } diff --git a/web-chat/src/App.tsx b/web-chat/src/App.tsx index 2cf1554022..ed76e6063d 100644 --- a/web-chat/src/App.tsx +++ b/web-chat/src/App.tsx @@ -24,7 +24,7 @@ export default function App() { useEffect(() => { async function initWaku() { try { - const waku = await Waku.create({}); + const waku = await Waku.create({ config: { pubsub: { enabled: true, emitSelf: true } } }); setState(({ messages }) => { return { waku, messages }; From 79846ee1966abdbb1bfddd6dd8949387943717db Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 14:57:30 +1000 Subject: [PATCH 08/20] Pass send message from room so other components can send --- web-chat/src/Room.tsx | 29 ++++++++++++++++------------- web-chat/src/Send.tsx | 17 ++--------------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/web-chat/src/Room.tsx b/web-chat/src/Room.tsx index 8290724a8a..02f03a881f 100644 --- a/web-chat/src/Room.tsx +++ b/web-chat/src/Room.tsx @@ -5,10 +5,13 @@ import { ListItem, ListItemText } from '@material-ui/core'; -import React from 'react'; +import React, { useState } from 'react'; import { ChatMessage } from 'waku-chat/chat_message'; +import { WakuMessage } from 'waku/waku_message'; +import { ChatContentTopic } from './App'; import MessageInput from './MessageInput'; import Send from './Send'; +import { useWaku } from './WakuContext'; interface Props { lines: ChatMessage[], @@ -19,43 +22,43 @@ interface State { } -export default class Room extends React.Component { - constructor(props: Props) { - super(props); +export default function Room (props :Props) { + let [state, setState] = useState({ messageToSend: '' }); + const { waku } = useWaku(); - this.state = { messageToSend: '' }; + const messageHandler = (msg: string) => { + setState({ messageToSend: msg }); } - messageHandler(msg: string) { - this.setState({ messageToSend: msg }); + const sendMessage = async () => { + const chatMessage = new ChatMessage(new Date(), 'web-chat', state.messageToSend); + const wakuMsg = WakuMessage.fromBytes(chatMessage.encode(), ChatContentTopic); + await waku!.relay.send(wakuMsg); } - - render() { return ( - + - + - + ); - } } interface LinesProps { diff --git a/web-chat/src/Send.tsx b/web-chat/src/Send.tsx index a45f596764..29d97a9e6e 100644 --- a/web-chat/src/Send.tsx +++ b/web-chat/src/Send.tsx @@ -1,26 +1,13 @@ import React from 'react'; -import { ChatMessage } from 'waku-chat/chat_message'; -import { WakuMessage } from 'waku/waku_message'; -import { ChatContentTopic } from './App'; -import { useWaku } from './WakuContext'; import { Button } from '@material-ui/core'; interface Props { - message: string + sendMessage: () => void } const Send = (props: Props) => { - const { waku } = useWaku(); - - const handleClick = async () => { - const chatMessage = new ChatMessage(new Date(), 'web-chat', props.message); - - const wakuMsg = WakuMessage.fromBytes(chatMessage.encode(), ChatContentTopic); - await waku!.relay.send(wakuMsg); - }; - return ( - ); From 06d8c2aca60bb27379e7d325b73db5e15e498fa9 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 15:11:37 +1000 Subject: [PATCH 09/20] Enable using enter key to send message --- web-chat/src/MessageInput.tsx | 13 ++++++++++++- web-chat/src/Room.tsx | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/web-chat/src/MessageInput.tsx b/web-chat/src/MessageInput.tsx index 3858e1ce9e..d398698b7c 100644 --- a/web-chat/src/MessageInput.tsx +++ b/web-chat/src/MessageInput.tsx @@ -1,8 +1,9 @@ -import React, { ChangeEvent } from 'react'; +import React, { ChangeEvent, KeyboardEvent } from 'react'; import { TextField } from '@material-ui/core'; interface Props { messageHandler: (msg: string) => void; + sendMessage: () => void; } interface State { @@ -19,13 +20,22 @@ export default class MessageInput extends React.Component { } messageHandler(event: ChangeEvent) { + this.setState({inputText: event.target.value}) this.props.messageHandler(event.target.value); } + keyPressHandler(event: KeyboardEvent) { + if (event.key === 'Enter') { + this.props.sendMessage() + this.setState({inputText: ''}) + } + } + render() { return ( { shrink: true, }} onChange={this.messageHandler.bind(this)} + onKeyPress={this.keyPressHandler.bind(this)} /> ); } diff --git a/web-chat/src/Room.tsx b/web-chat/src/Room.tsx index 02f03a881f..5513068798 100644 --- a/web-chat/src/Room.tsx +++ b/web-chat/src/Room.tsx @@ -49,7 +49,7 @@ export default function Room (props :Props) { - + From 25e6b1cbd39c133b12b41efec189574b81b9a3fa Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 15:43:21 +1000 Subject: [PATCH 10/20] Default connection to a running instance of go-waku --- web-chat/src/App.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web-chat/src/App.tsx b/web-chat/src/App.tsx index ed76e6063d..c077016916 100644 --- a/web-chat/src/App.tsx +++ b/web-chat/src/App.tsx @@ -30,9 +30,11 @@ export default function App() { return { waku, messages }; }); + // FIXME: Connect to a go-waku instance by default, temporary hack until + // we have a go-waku instance in the fleet waku.libp2p.peerStore.addressBook.add( - PeerId.createFromB58String('QmbEnEniueE2Cetej6UkYAtvHuXuare4fSEeyvm43kdmfq'), - [multiaddr('/ip4/127.0.0.1/tcp/7777/ws')]); + PeerId.createFromB58String('16Uiu2HAmVVi6Q4j7MAKVibquW8aA27UNrA4Q8Wkz9EetGViu8ZF1'), + [multiaddr('/ip4/134.209.113.86/tcp/9001/ws')]); } catch (e) { console.log('Issue starting waku ', e); } From 4c8a243c513f713a8917ecec48bd52216f96a495 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 15:57:43 +1000 Subject: [PATCH 11/20] Improve usage of setState --- web-chat/src/Room.tsx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/web-chat/src/Room.tsx b/web-chat/src/Room.tsx index 5513068798..59efac061a 100644 --- a/web-chat/src/Room.tsx +++ b/web-chat/src/Room.tsx @@ -17,21 +17,16 @@ interface Props { lines: ChatMessage[], } -interface State { - messageToSend: string -} - - export default function Room (props :Props) { - let [state, setState] = useState({ messageToSend: '' }); + let [messageToSend, setMessageToSend] = useState(''); const { waku } = useWaku(); const messageHandler = (msg: string) => { - setState({ messageToSend: msg }); + setMessageToSend(msg); } const sendMessage = async () => { - const chatMessage = new ChatMessage(new Date(), 'web-chat', state.messageToSend); + const chatMessage = new ChatMessage(new Date(), 'web-chat', messageToSend); const wakuMsg = WakuMessage.fromBytes(chatMessage.encode(), ChatContentTopic); await waku!.relay.send(wakuMsg); } From 2297d09d582e50eec77eefbbe39fdc4e927f8ed2 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 16:12:28 +1000 Subject: [PATCH 12/20] Enable using commands --- web-chat/src/App.tsx | 18 +++++++++++++++++- web-chat/src/Room.tsx | 11 ++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/web-chat/src/App.tsx b/web-chat/src/App.tsx index c077016916..f0aecdc0ff 100644 --- a/web-chat/src/App.tsx +++ b/web-chat/src/App.tsx @@ -67,12 +67,28 @@ export default function App() { } }); + const commandHandler = (cmd: string) => { + let commandResponse = 'internal error'; + switch (cmd) { + case '/help': + commandResponse = '/help Display this help'; + break; + default: + commandResponse = 'Unknown Command' + } + + setState(({waku, messages}) => { + messages.push(new ChatMessage(new Date(), 'Command Response', commandResponse)); + return {waku, messages}; + }) + } + return (
- +
diff --git a/web-chat/src/Room.tsx b/web-chat/src/Room.tsx index 59efac061a..a045331698 100644 --- a/web-chat/src/Room.tsx +++ b/web-chat/src/Room.tsx @@ -15,6 +15,7 @@ import { useWaku } from './WakuContext'; interface Props { lines: ChatMessage[], + commandHandler: (cmd: string) => void; } export default function Room (props :Props) { @@ -26,9 +27,13 @@ export default function Room (props :Props) { } const sendMessage = async () => { - const chatMessage = new ChatMessage(new Date(), 'web-chat', messageToSend); - const wakuMsg = WakuMessage.fromBytes(chatMessage.encode(), ChatContentTopic); - await waku!.relay.send(wakuMsg); + if (messageToSend.startsWith('/')) { + props.commandHandler(messageToSend) + } else { + const chatMessage = new ChatMessage(new Date(), 'web-chat', messageToSend); + const wakuMsg = WakuMessage.fromBytes(chatMessage.encode(), ChatContentTopic); + await waku!.relay.send(wakuMsg); + } } return ( From 80bf4eb4eab5ce0369eefb91292c15c1193c2530 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 16:50:37 +1000 Subject: [PATCH 13/20] Implement /peers and /connect commands --- web-chat/src/App.tsx | 85 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 16 deletions(-) diff --git a/web-chat/src/App.tsx b/web-chat/src/App.tsx index f0aecdc0ff..48138bb966 100644 --- a/web-chat/src/App.tsx +++ b/web-chat/src/App.tsx @@ -24,7 +24,14 @@ export default function App() { useEffect(() => { async function initWaku() { try { - const waku = await Waku.create({ config: { pubsub: { enabled: true, emitSelf: true } } }); + const waku = await Waku.create({ + config: { + pubsub: { + enabled: true, + emitSelf: true + } + } + }); setState(({ messages }) => { return { waku, messages }; @@ -67,28 +74,74 @@ export default function App() { } }); - const commandHandler = (cmd: string) => { - let commandResponse = 'internal error'; - switch (cmd) { - case '/help': - commandResponse = '/help Display this help'; - break; - default: - commandResponse = 'Unknown Command' - } + const commandHandler = (input: string) => { + let commandResponses: string[] = []; + const args = input.split(' '); + const cmd = args.shift()!; + const waku = state.waku; + if (!waku) { + commandResponses.push('Waku is not yet initialized'); + } else { + switch (cmd) { + case '/help': + commandResponses.push('/connect : connect to the given peer'); + commandResponses.push('/help: Display this help'); + break; + case '/connect': + const peer = args.shift(); + if (!peer) { + commandResponses.push('No peer provided'); + } else { + try { + const peerMultiaddr = multiaddr(peer); + const peerId = peerMultiaddr.getPeerId(); + if (!peerId) { + commandResponses.push('Peer Id needed to dial'); + } else { + waku.libp2p.peerStore.addressBook.add( + PeerId.createFromB58String(peerId), + [peerMultiaddr]); + } + } catch (e) { + commandResponses.push('Invalid multaddr: ' + e); + } + } + break; + case '/peers': + waku.libp2p.peerStore.peers.forEach((peer, peerId) => { + commandResponses.push(peerId + ":") + let addresses = " addresses: [" + peer.addresses.forEach(({multiaddr}) => { + addresses += " " + multiaddr.toString() + ","; + }) + addresses = addresses.replace(/,$/,""); + addresses += "]"; + commandResponses.push(addresses); + let protos = " protos: ["; + protos += peer.protocols; + protos+= "]" + commandResponses.push(protos) + }) + break; + default: + commandResponses.push('Unknown Command'); + } - setState(({waku, messages}) => { - messages.push(new ChatMessage(new Date(), 'Command Response', commandResponse)); - return {waku, messages}; - }) - } + } + setState(({ waku, messages }) => { + commandResponses.forEach((res) => { + messages.push(new ChatMessage(new Date(), cmd, res)); + }); + return { waku, messages }; + }); + }; return (
- +
From c7ba19f43e2aac40ebf032d178815bff5909028b Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 16:56:59 +1000 Subject: [PATCH 14/20] Ensure text is cleared when clicking "send" --- web-chat/src/MessageInput.tsx | 43 +++++++++++++++++++++++------------ web-chat/src/Room.tsx | 10 +------- web-chat/src/Send.tsx | 16 ------------- 3 files changed, 29 insertions(+), 40 deletions(-) delete mode 100644 web-chat/src/Send.tsx diff --git a/web-chat/src/MessageInput.tsx b/web-chat/src/MessageInput.tsx index d398698b7c..e1b93e2e0f 100644 --- a/web-chat/src/MessageInput.tsx +++ b/web-chat/src/MessageInput.tsx @@ -1,5 +1,5 @@ import React, { ChangeEvent, KeyboardEvent } from 'react'; -import { TextField } from '@material-ui/core'; +import { Button, Grid, TextField } from '@material-ui/core'; interface Props { messageHandler: (msg: string) => void; @@ -26,25 +26,38 @@ export default class MessageInput extends React.Component { keyPressHandler(event: KeyboardEvent) { if (event.key === 'Enter') { - this.props.sendMessage() - this.setState({inputText: ''}) + this.sendMessage() } } + sendMessage() { + this.props.sendMessage() + this.setState({inputText: ''}) + } + render() { return ( - + + + + + + + + ); } } diff --git a/web-chat/src/Room.tsx b/web-chat/src/Room.tsx index a045331698..308df11bd2 100644 --- a/web-chat/src/Room.tsx +++ b/web-chat/src/Room.tsx @@ -10,7 +10,6 @@ import { ChatMessage } from 'waku-chat/chat_message'; import { WakuMessage } from 'waku/waku_message'; import { ChatContentTopic } from './App'; import MessageInput from './MessageInput'; -import Send from './Send'; import { useWaku } from './WakuContext'; interface Props { @@ -47,14 +46,7 @@ export default function Room (props :Props) { - - - - - - - - + diff --git a/web-chat/src/Send.tsx b/web-chat/src/Send.tsx deleted file mode 100644 index 29d97a9e6e..0000000000 --- a/web-chat/src/Send.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import { Button } from '@material-ui/core'; - -interface Props { - sendMessage: () => void -} - -const Send = (props: Props) => { - return ( - - ); -}; - -export default Send; From 5aee9f4841b8d7a82dd0ee197c71ae9b40ef6bb4 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 17:01:46 +1000 Subject: [PATCH 15/20] Convert to functional component --- web-chat/src/MessageInput.tsx | 44 +++++++++++++---------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/web-chat/src/MessageInput.tsx b/web-chat/src/MessageInput.tsx index e1b93e2e0f..18d2a4c1a7 100644 --- a/web-chat/src/MessageInput.tsx +++ b/web-chat/src/MessageInput.tsx @@ -1,4 +1,4 @@ -import React, { ChangeEvent, KeyboardEvent } from 'react'; +import React, { ChangeEvent, KeyboardEvent, useState } from 'react'; import { Button, Grid, TextField } from '@material-ui/core'; interface Props { @@ -6,58 +6,46 @@ interface Props { sendMessage: () => void; } -interface State { - inputText: string; -} +export default function MessageInput(props: Props) { + const [inputText, setInputText] = useState('') -export default class MessageInput extends React.Component { - constructor(props: Props) { - super(props); - - this.state = { - inputText: '' - }; + const sendMessage = () => { + props.sendMessage() + setInputText('') } - messageHandler(event: ChangeEvent) { - this.setState({inputText: event.target.value}) - this.props.messageHandler(event.target.value); - } + const messageHandler = (event: ChangeEvent) => { + setInputText(event.target.value) + props.messageHandler(event.target.value); + }; - keyPressHandler(event: KeyboardEvent) { + const keyPressHandler = (event: KeyboardEvent) => { if (event.key === 'Enter') { - this.sendMessage() + sendMessage() } } - sendMessage() { - this.props.sendMessage() - this.setState({inputText: ''}) - } - - render() { return ( - ); - } } From 13e93b176d4691174daf8a24079edfec6cf69351 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 17:02:10 +1000 Subject: [PATCH 16/20] Convert to functional component --- web-chat/src/MessageInput.tsx | 59 ++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/web-chat/src/MessageInput.tsx b/web-chat/src/MessageInput.tsx index 18d2a4c1a7..9ac2d340a2 100644 --- a/web-chat/src/MessageInput.tsx +++ b/web-chat/src/MessageInput.tsx @@ -7,45 +7,46 @@ interface Props { } export default function MessageInput(props: Props) { - const [inputText, setInputText] = useState('') + const [inputText, setInputText] = useState(''); const sendMessage = () => { - props.sendMessage() - setInputText('') - } + props.sendMessage(); + setInputText(''); + }; const messageHandler = (event: ChangeEvent) => { - setInputText(event.target.value) + setInputText(event.target.value); props.messageHandler(event.target.value); }; const keyPressHandler = (event: KeyboardEvent) => { if (event.key === 'Enter') { - sendMessage() + sendMessage(); } - } + }; - return ( - - - - - - - + return ( + + + - ); + + + + + ); } From fae5959d2fa295d82a6c2106725b48a72feee903 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 17:03:33 +1000 Subject: [PATCH 17/20] Format tsx files --- web-chat/package.json | 8 ++-- web-chat/src/App.tsx | 59 +++++++++++++----------- web-chat/src/MessageInput.tsx | 33 ++++++++------ web-chat/src/Room.tsx | 86 ++++++++++++++++++----------------- 4 files changed, 100 insertions(+), 86 deletions(-) diff --git a/web-chat/package.json b/web-chat/package.json index eb5629be9b..dd304fbc74 100644 --- a/web-chat/package.json +++ b/web-chat/package.json @@ -27,11 +27,11 @@ "eject": "react-scripts eject", "fix": "run-s fix:*", "test": "run-s build test:*", - "test:lint": "eslint src --ext .ts", - "test:prettier": "prettier \"src/**/*.ts\" --list-different", + "test:lint": "eslint src --ext .ts --ext .tsx", + "test:prettier": "prettier \"src/**/*.{ts,tsx}\" --list-different", "test:spelling": "cspell \"{README.md,.github/*.md,src/**/*.ts}\"", - "fix:prettier": "prettier \"src/**/*.ts\" --write", - "fix:lint": "eslint src --ext .ts --fix" + "fix:prettier": "prettier \"src/**/*.{ts,tsx}\" --write", + "fix:lint": "eslint src --ext .ts --ext .tsx --fix" }, "eslintConfig": { "extends": [ diff --git a/web-chat/src/App.tsx b/web-chat/src/App.tsx index 48138bb966..4b1437261d 100644 --- a/web-chat/src/App.tsx +++ b/web-chat/src/App.tsx @@ -13,14 +13,13 @@ import { WakuContext } from './WakuContext'; export const ChatContentTopic = 'dingpu'; interface State { - messages: ChatMessage[], - waku?: Waku + messages: ChatMessage[]; + waku?: Waku; } export default function App() { let [state, setState] = useState({ messages: [] }); - useEffect(() => { async function initWaku() { try { @@ -28,9 +27,9 @@ export default function App() { config: { pubsub: { enabled: true, - emitSelf: true - } - } + emitSelf: true, + }, + }, }); setState(({ messages }) => { @@ -40,12 +39,14 @@ export default function App() { // FIXME: Connect to a go-waku instance by default, temporary hack until // we have a go-waku instance in the fleet waku.libp2p.peerStore.addressBook.add( - PeerId.createFromB58String('16Uiu2HAmVVi6Q4j7MAKVibquW8aA27UNrA4Q8Wkz9EetGViu8ZF1'), - [multiaddr('/ip4/134.209.113.86/tcp/9001/ws')]); + PeerId.createFromB58String( + '16Uiu2HAmVVi6Q4j7MAKVibquW8aA27UNrA4Q8Wkz9EetGViu8ZF1' + ), + [multiaddr('/ip4/134.209.113.86/tcp/9001/ws')] + ); } catch (e) { console.log('Issue starting waku ', e); } - } const handleNewMessages = (event: { data: Uint8Array }) => { @@ -57,7 +58,6 @@ export default function App() { console.log('setState on ', messages); setState({ messages, waku: state.waku }); } - }; if (!state.waku) { @@ -69,7 +69,10 @@ export default function App() { // To clean up listener when component unmounts return () => { - state.waku?.libp2p.pubsub.removeListener(RelayDefaultTopic, handleNewMessages); + state.waku?.libp2p.pubsub.removeListener( + RelayDefaultTopic, + handleNewMessages + ); }; } }); @@ -84,7 +87,9 @@ export default function App() { } else { switch (cmd) { case '/help': - commandResponses.push('/connect : connect to the given peer'); + commandResponses.push( + '/connect : connect to the given peer' + ); commandResponses.push('/help: Display this help'); break; case '/connect': @@ -100,7 +105,8 @@ export default function App() { } else { waku.libp2p.peerStore.addressBook.add( PeerId.createFromB58String(peerId), - [peerMultiaddr]); + [peerMultiaddr] + ); } } catch (e) { commandResponses.push('Invalid multaddr: ' + e); @@ -109,24 +115,23 @@ export default function App() { break; case '/peers': waku.libp2p.peerStore.peers.forEach((peer, peerId) => { - commandResponses.push(peerId + ":") - let addresses = " addresses: [" - peer.addresses.forEach(({multiaddr}) => { - addresses += " " + multiaddr.toString() + ","; - }) - addresses = addresses.replace(/,$/,""); - addresses += "]"; + commandResponses.push(peerId + ':'); + let addresses = ' addresses: ['; + peer.addresses.forEach(({ multiaddr }) => { + addresses += ' ' + multiaddr.toString() + ','; + }); + addresses = addresses.replace(/,$/, ''); + addresses += ']'; commandResponses.push(addresses); - let protos = " protos: ["; + let protos = ' protos: ['; protos += peer.protocols; - protos+= "]" - commandResponses.push(protos) - }) + protos += ']'; + commandResponses.push(protos); + }); break; default: commandResponses.push('Unknown Command'); } - } setState(({ waku, messages }) => { commandResponses.forEach((res) => { @@ -137,8 +142,8 @@ export default function App() { }; return ( -
-
+
+
diff --git a/web-chat/src/MessageInput.tsx b/web-chat/src/MessageInput.tsx index 9ac2d340a2..760c544bf9 100644 --- a/web-chat/src/MessageInput.tsx +++ b/web-chat/src/MessageInput.tsx @@ -26,24 +26,29 @@ export default function MessageInput(props: Props) { }; return ( - + - - diff --git a/web-chat/src/Room.tsx b/web-chat/src/Room.tsx index 308df11bd2..b1f20a9339 100644 --- a/web-chat/src/Room.tsx +++ b/web-chat/src/Room.tsx @@ -1,10 +1,4 @@ -import { - Box, - Grid, - List, - ListItem, - ListItemText -} from '@material-ui/core'; +import { Box, Grid, List, ListItem, ListItemText } from '@material-ui/core'; import React, { useState } from 'react'; import { ChatMessage } from 'waku-chat/chat_message'; import { WakuMessage } from 'waku/waku_message'; @@ -13,66 +7,76 @@ import MessageInput from './MessageInput'; import { useWaku } from './WakuContext'; interface Props { - lines: ChatMessage[], + lines: ChatMessage[]; commandHandler: (cmd: string) => void; } -export default function Room (props :Props) { +export default function Room(props: Props) { let [messageToSend, setMessageToSend] = useState(''); const { waku } = useWaku(); const messageHandler = (msg: string) => { setMessageToSend(msg); - } + }; const sendMessage = async () => { if (messageToSend.startsWith('/')) { - props.commandHandler(messageToSend) + props.commandHandler(messageToSend); } else { - const chatMessage = new ChatMessage(new Date(), 'web-chat', messageToSend); - const wakuMsg = WakuMessage.fromBytes(chatMessage.encode(), ChatContentTopic); + const chatMessage = new ChatMessage( + new Date(), + 'web-chat', + messageToSend + ); + const wakuMsg = WakuMessage.fromBytes( + chatMessage.encode(), + ChatContentTopic + ); await waku!.relay.send(wakuMsg); } - } - - return ( - - - - - - - - - - - + }; + return ( + + + + + - ); + + + + + + ); } interface LinesProps { - messages: ChatMessage[] + messages: ChatMessage[]; } const Lines = (props: LinesProps) => { const renderedLines = []; for (const i in props.messages) { - renderedLines.push( - - ); + renderedLines.push( + + + + ); } - return ( - - {renderedLines} - - ); + return {renderedLines}; }; // TODO: Make it a proper component @@ -82,7 +86,7 @@ function printMessage(chatMsg: ChatMessage) { day: 'numeric', hour: 'numeric', minute: '2-digit', - hour12: false + hour12: false, }); return `<${timestamp}> ${chatMsg.nick}: ${chatMsg.message}`; } From f0cd4064cbc3cbbda365103df15b430bb7a754cb Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 17:05:19 +1000 Subject: [PATCH 18/20] Enable button once waku is ready --- web-chat/src/MessageInput.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web-chat/src/MessageInput.tsx b/web-chat/src/MessageInput.tsx index 760c544bf9..f3fc69d688 100644 --- a/web-chat/src/MessageInput.tsx +++ b/web-chat/src/MessageInput.tsx @@ -1,5 +1,6 @@ import React, { ChangeEvent, KeyboardEvent, useState } from 'react'; import { Button, Grid, TextField } from '@material-ui/core'; +import { useWaku } from './WakuContext'; interface Props { messageHandler: (msg: string) => void; @@ -8,6 +9,7 @@ interface Props { export default function MessageInput(props: Props) { const [inputText, setInputText] = useState(''); + const { waku } = useWaku(); const sendMessage = () => { props.sendMessage(); @@ -40,6 +42,7 @@ export default function MessageInput(props: Props) { }} onChange={messageHandler} onKeyPress={keyPressHandler} + disabled={!waku} /> @@ -48,6 +51,7 @@ export default function MessageInput(props: Props) { color="primary" size="large" onClick={sendMessage} + disabled={!waku} > Send From 46f3bf6320495466542f0367e965636fe3f66bb3 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 21:06:28 +1000 Subject: [PATCH 19/20] Add new word --- .cspell.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.cspell.json b/.cspell.json index a4013d963c..bfb951b8cd 100644 --- a/.cspell.json +++ b/.cspell.json @@ -22,6 +22,7 @@ "execa", "exponentiate", "fanout", + "floodsub", "globby", "gossipsub", "iasked", From a34addb891371829613af43911eea0cb436341a0 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 22 Apr 2021 21:30:16 +1000 Subject: [PATCH 20/20] Do not use npm ci for webchat --- .github/workflows/webchat-ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/webchat-ci.yml b/.github/workflows/webchat-ci.yml index d0fec5a17f..467230eb22 100644 --- a/.github/workflows/webchat-ci.yml +++ b/.github/workflows/webchat-ci.yml @@ -33,10 +33,9 @@ jobs: - name: "[js-waku] build" run: npm run build - - name: install using npm ci - uses: bahmutov/npm-install@v1 - with: - working-directory: web-chat + - name: install using npm i + run: npm install + working-directory: web-chat - name: test run: npm run test