From 1a4407b4f5087c1627a827b2bf6687773b03bf08 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 15 Apr 2021 11:25:40 +1000 Subject: [PATCH 1/4] Increase test timeout --- src/lib/waku_relay/index.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/waku_relay/index.spec.ts b/src/lib/waku_relay/index.spec.ts index 98da87731f..4ef77a148f 100644 --- a/src/lib/waku_relay/index.spec.ts +++ b/src/lib/waku_relay/index.spec.ts @@ -45,6 +45,7 @@ describe('Waku Relay', () => { }); afterEach(async function () { + this.timeout(5000); await waku1.stop(); await waku2.stop(); }); @@ -185,6 +186,7 @@ describe('Waku Relay', () => { }); it('Js publishes to nim', async function () { + this.timeout(3000); const message = WakuMessage.fromUtf8String('This is a message'); await waku.relay.publish(message); From 31a45bf44e09168f7f37c3be17230e26af4c793b Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 15 Apr 2021 13:44:00 +1000 Subject: [PATCH 2/4] Group imports --- src/lib/waku_relay/index.spec.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/waku_relay/index.spec.ts b/src/lib/waku_relay/index.spec.ts index 4ef77a148f..859e1b113e 100644 --- a/src/lib/waku_relay/index.spec.ts +++ b/src/lib/waku_relay/index.spec.ts @@ -1,9 +1,12 @@ import { expect } from 'chai'; import Pubsub from 'libp2p-interfaces/src/pubsub'; -import { NOISE_KEY_1, NOISE_KEY_2 } from '../../test_utils/constants'; -import { makeLogFileName } from '../../test_utils/log_file'; -import { NimWaku } from '../../test_utils/nim_waku'; +import { + makeLogFileName, + NimWaku, + NOISE_KEY_1, + NOISE_KEY_2, +} from '../../test_utils'; import { delay } from '../delay'; import Waku from '../waku'; import { WakuMessage } from '../waku_message'; From 1a813256e930405c224b4abc1a1ff003d566fee1 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 15 Apr 2021 13:48:49 +1000 Subject: [PATCH 3/4] Start Waku first So that even if the user does not enter a nick, the chat app already acts as a waku node. --- src/chat/index.ts | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/chat/index.ts b/src/chat/index.ts index c555c5db43..2c01b6d3e7 100644 --- a/src/chat/index.ts +++ b/src/chat/index.ts @@ -15,21 +15,31 @@ const ChatContentTopic = 'dingpu'; (async function () { const opts = processArguments(); + const waku = await Waku.create({ listenAddresses: [opts.listenAddr] }); + console.log('Waku started'); + // TODO: Automatically subscribe, tracked with + // https://github.com/status-im/js-waku/issues/17 + await waku.relay.subscribe(); + console.log('Subscribed to waku relay'); + + if (opts.staticNode) { + console.log(`dialing ${opts.staticNode}`); + await waku.dial(opts.staticNode); + } + const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const question = util.promisify(rl.question).bind(rl); - // Looks like wrong type definition of promisify is picked. // May be related to https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20497 const nick = ((await question( 'Please choose a nickname: ' )) as unknown) as string; - console.log(`Hi ${nick}!`); - const waku = await Waku.create({ listenAddresses: [opts.listenAddr] }); + console.log(`Hi, ${nick}!`); // TODO: Bubble event to waku, infer topic, decode msg // Tracked with https://github.com/status-im/js-waku/issues/19 @@ -41,18 +51,6 @@ const ChatContentTopic = 'dingpu'; } }); - console.log('Waku started'); - - if (opts.staticNode) { - console.log(`dialing ${opts.staticNode}`); - await waku.dial(opts.staticNode); - } - - // TODO: Automatically subscribe, tracked with - // https://github.com/status-im/js-waku/issues/17 - await waku.relay.subscribe(); - console.log('Subscribed to waku relay'); - const staticNodeId = opts.staticNode?.getPeerId(); if (staticNodeId) { const storePeerId = PeerId.createFromB58String(staticNodeId); From 503157401e5918a3f7b651f3b7de7a34c1613856 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 15 Apr 2021 11:19:26 +1000 Subject: [PATCH 4/4] Allow passing transports, enable websocket transport --- .cspell.json | 3 +- package-lock.json | 557 ++++++++++++++++++++++--------- package.json | 1 + src/chat/index.ts | 15 +- src/lib/waku.spec.ts | 38 ++- src/lib/waku.ts | 25 +- src/lib/waku_relay/index.spec.ts | 30 +- src/lib/waku_store/index.spec.ts | 16 +- src/types/types.d.ts | 1 + 9 files changed, 503 insertions(+), 183 deletions(-) diff --git a/.cspell.json b/.cspell.json index 966aaf6880..a4013d963c 100644 --- a/.cspell.json +++ b/.cspell.json @@ -56,7 +56,8 @@ "untracked", "upgrader", "waku", - "wakunode" + "wakunode", + "websockets" ], "flagWords": [], "ignorePaths": [ diff --git a/package-lock.json b/package-lock.json index a2099c2e6c..81860df53e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "libp2p-noise": "^2.0.5", "libp2p-secio": "^0.13.1", "libp2p-tcp": "^0.15.3", + "libp2p-websockets": "^0.15.5", "multiaddr": "^8.1.2", "prompt-sync": "^4.2.0", "ts-proto": "^1.74.0", @@ -3687,6 +3688,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, "dependencies": { "object-keys": "^1.0.12" }, @@ -4557,6 +4559,11 @@ "node": ">=0.10.0" } }, + "node_modules/event-iterator": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/event-iterator/-/event-iterator-2.0.0.tgz", + "integrity": "sha512-KGft0ldl31BZVV//jj+IAIGCxkvvUkkON+ScH6zfoX+l+omX6001ggyRSpI0Io2Hlro0ThXotswCtfzS8UkIiQ==" + }, "node_modules/event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -6157,17 +6164,6 @@ "node": ">=8" } }, - "node_modules/globalthis": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.2.tgz", - "integrity": "sha512-ZQnSFO1la8P7auIOQECnm0sSuoMeaSq0EEdXMBFF2QJO4uNcwbyhSgG3MruWNbFTqCLmxVwGOl7LZ9kASvHdeQ==", - "dependencies": { - "define-properties": "^1.1.3" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/globby": { "version": "11.0.2", "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.2.tgz", @@ -6924,27 +6920,26 @@ } }, "node_modules/ipfs-utils": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ipfs-utils/-/ipfs-utils-6.0.1.tgz", - "integrity": "sha512-u6fJDi/LpCEj96JM//cdDWJV44YR7jLdxQ6I0d8Hj/BCPIQPTWsjQeSppKxudMjYRpX4kzdv9WxrNM8dc4rtlQ==", + "version": "6.0.7", + "resolved": "https://registry.npmjs.org/ipfs-utils/-/ipfs-utils-6.0.7.tgz", + "integrity": "sha512-VlFDyRuCSOKXPOXb68nXSUVEPA+eXbdS7LT22k4aZvFNIoB2OtysDEt8lal93UOB/QS0Gy+6DUoxj1wJ37SIxQ==", "dependencies": { "abort-controller": "^3.0.0", "any-signal": "^2.1.0", "buffer": "^6.0.1", "electron-fetch": "^1.7.2", - "err-code": "^2.0.3", + "err-code": "^3.0.1", "fs-extra": "^9.0.1", "is-electron": "^2.2.0", "iso-url": "^1.0.0", - "it-glob": "0.0.10", - "it-to-stream": "^0.1.2", + "it-glob": "~0.0.11", + "it-to-stream": "^1.0.0", "merge-options": "^3.0.4", "nanoid": "^3.1.20", "native-abort-controller": "^1.0.3", - "native-fetch": "2.0.1", + "native-fetch": "^3.0.0", "node-fetch": "^2.6.1", - "stream-to-it": "^0.2.2", - "web-encoding": "^1.0.6" + "stream-to-it": "^0.2.2" } }, "node_modules/ipfs-utils/node_modules/buffer": { @@ -6956,13 +6951,10 @@ "ieee754": "^1.2.1" } }, - "node_modules/ipfs-utils/node_modules/native-fetch": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/native-fetch/-/native-fetch-2.0.1.tgz", - "integrity": "sha512-gv4Bea+ga9QdXINurpkEqun3ap3vnB+WYoe4c8ddqUYEH7B2h6iD39RF8uVN7OwmSfMY3RDxkvBnoI4e2/vLXQ==", - "dependencies": { - "globalthis": "^1.0.1" - } + "node_modules/ipfs-utils/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/is-accessor-descriptor": { "version": "0.1.6", @@ -7549,9 +7541,9 @@ "integrity": "sha512-wiI02c+G1BVuu0jz30Nsr1/et0cpSRulKUusN8HDZXxuX4MdUzfMp2P4JUk+a49Wr1kHitRLrnnh3+UzJ6neaQ==" }, "node_modules/it-glob": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/it-glob/-/it-glob-0.0.10.tgz", - "integrity": "sha512-p1PR15djgPV7pxdLOW9j4WcJdla8+91rJdUU2hU2Jm68vkxpIEXK55VHBeH8Lvqh2vqLtM83t8q4BuJxue6niA==", + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/it-glob/-/it-glob-0.0.11.tgz", + "integrity": "sha512-p02iVYsvOPU7cW4sV9BC62Kz6Mz2aUTJz/cKWDeFqc05kzB3WgSq8OobZabVA/K4boSm6q+s0xOZ8xiArLSoXQ==", "dependencies": { "fs-extra": "^9.0.1", "minimatch": "^3.0.4" @@ -7575,14 +7567,6 @@ "p-defer": "^3.0.0" } }, - "node_modules/it-handshake/node_modules/p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==", - "engines": { - "node": ">=8" - } - }, "node_modules/it-length-prefixed": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/it-length-prefixed/-/it-length-prefixed-3.1.0.tgz", @@ -7669,11 +7653,11 @@ "integrity": "sha512-zfr2iAtekTGhHVWzCqqqgDnHhmzdzfCW92L0GvbaSFlvc3n2Ep/sponzmlNl2Kg39N5Py+02v+Aypc+i2c+9og==" }, "node_modules/it-to-stream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/it-to-stream/-/it-to-stream-0.1.2.tgz", - "integrity": "sha512-DTB5TJRZG3untmZehcaFN0kGWl2bNv7tnJRgQHAO9QEt8jfvVRrebZtnD5NZd4SCj4WVPjl0LSrugNWE/UaZRQ==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/it-to-stream/-/it-to-stream-1.0.0.tgz", + "integrity": "sha512-pLULMZMAB/+vbdvbZtebC0nWBTbG581lk6w8P7DfIIIKUfa8FbY7Oi0FxZcFPbxvISs7A9E+cMpLDBc1XhpAOA==", "dependencies": { - "buffer": "^5.6.0", + "buffer": "^6.0.3", "fast-fifo": "^1.0.0", "get-iterator": "^1.0.2", "p-defer": "^3.0.0", @@ -7681,12 +7665,61 @@ "readable-stream": "^3.6.0" } }, - "node_modules/it-to-stream/node_modules/p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==", - "engines": { - "node": ">=8" + "node_modules/it-to-stream/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/it-ws": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/it-ws/-/it-ws-4.0.0.tgz", + "integrity": "sha512-XmTzpMkevc6rUboy73r0CCNhciMmL/Yxir9O6FujRwdrjysztqLBQ1Xkr4CpY2m7BVSCObKotaCWJeZ29lOXRA==", + "dependencies": { + "buffer": "^6.0.3", + "event-iterator": "^2.0.0", + "iso-url": "^1.1.2", + "ws": "^7.3.1" + } + }, + "node_modules/it-ws/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/iterable-to-stream": { @@ -8099,14 +8132,6 @@ "node": ">= 4.5.0" } }, - "node_modules/libp2p-gossipsub/node_modules/p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==", - "engines": { - "node": ">=8" - } - }, "node_modules/libp2p-gossipsub/node_modules/varint": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", @@ -8161,14 +8186,6 @@ "npm": ">=6.0.0" } }, - "node_modules/libp2p-interfaces/node_modules/p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==", - "engines": { - "node": ">=8" - } - }, "node_modules/libp2p-interfaces/node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -8360,14 +8377,6 @@ "node": ">= 4.5.0" } }, - "node_modules/libp2p-secio/node_modules/p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==", - "engines": { - "node": ">=8" - } - }, "node_modules/libp2p-secio/node_modules/varint": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", @@ -8406,6 +8415,108 @@ "private-ip": "^2.1.1" } }, + "node_modules/libp2p-websockets": { + "version": "0.15.5", + "resolved": "https://registry.npmjs.org/libp2p-websockets/-/libp2p-websockets-0.15.5.tgz", + "integrity": "sha512-pD/J5lp4QM8oyQKjLcnnfwwcNbCRDG33+C4njQ7MUKuD5MphF1s2U0z8FiAlTtyNVflYX82dhTYgI4cPzmoBeA==", + "dependencies": { + "abortable-iterator": "^3.0.0", + "class-is": "^1.1.0", + "debug": "^4.3.1", + "err-code": "^3.0.1", + "ipfs-utils": "^6.0.6", + "it-ws": "^4.0.0", + "libp2p-utils": "^0.3.0", + "mafmt": "^9.0.0", + "multiaddr": "^9.0.1", + "multiaddr-to-uri": "^6.0.0", + "p-defer": "^3.0.0", + "p-timeout": "^4.1.0" + } + }, + "node_modules/libp2p-websockets/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-websockets/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-websockets/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-websockets/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-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==", + "dependencies": { + "multibase": "^4.0.1" + } + }, + "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", @@ -9153,6 +9264,14 @@ "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==", + "dependencies": { + "multiaddr": "^8.0.0" + } + }, "node_modules/multibase": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/multibase/-/multibase-3.1.2.tgz", @@ -9293,14 +9412,6 @@ "uint8arrays": "^1.1.0" } }, - "node_modules/multistream-select/node_modules/p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==", - "engines": { - "node": ">=8" - } - }, "node_modules/murmurhash3js-revisited": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/murmurhash3js-revisited/-/murmurhash3js-revisited-3.0.0.tgz", @@ -10089,6 +10200,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, "engines": { "node": ">= 0.4" } @@ -10293,6 +10405,14 @@ "node": ">=8" } }, + "node_modules/p-defer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", + "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==", + "engines": { + "node": ">=8" + } + }, "node_modules/p-fifo": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-fifo/-/p-fifo-1.0.0.tgz", @@ -10302,14 +10422,6 @@ "p-defer": "^3.0.0" } }, - "node_modules/p-fifo/node_modules/p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==", - "engines": { - "node": ">=8" - } - }, "node_modules/p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", @@ -10405,7 +10517,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-4.1.0.tgz", "integrity": "sha512-+/wmHtzJuWii1sXn3HCuH/FTwGhrp4tmJTxSKJbfS+vkipci6osxXM5mY0jUiRzWKMTgUT8l7HFbeSwZAynqHw==", - "dev": true, "engines": { "node": ">=10" } @@ -13309,6 +13420,26 @@ "typedarray-to-buffer": "^3.1.5" } }, + "node_modules/ws": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.4.tgz", + "integrity": "sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw==", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/xdg-basedir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", @@ -16505,6 +16636,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, "requires": { "object-keys": "^1.0.12" } @@ -17219,6 +17351,11 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, + "event-iterator": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/event-iterator/-/event-iterator-2.0.0.tgz", + "integrity": "sha512-KGft0ldl31BZVV//jj+IAIGCxkvvUkkON+ScH6zfoX+l+omX6001ggyRSpI0Io2Hlro0ThXotswCtfzS8UkIiQ==" + }, "event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -18516,14 +18653,6 @@ } } }, - "globalthis": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.2.tgz", - "integrity": "sha512-ZQnSFO1la8P7auIOQECnm0sSuoMeaSq0EEdXMBFF2QJO4uNcwbyhSgG3MruWNbFTqCLmxVwGOl7LZ9kASvHdeQ==", - "requires": { - "define-properties": "^1.1.3" - } - }, "globby": { "version": "11.0.2", "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.2.tgz", @@ -19128,27 +19257,26 @@ "integrity": "sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q==" }, "ipfs-utils": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ipfs-utils/-/ipfs-utils-6.0.1.tgz", - "integrity": "sha512-u6fJDi/LpCEj96JM//cdDWJV44YR7jLdxQ6I0d8Hj/BCPIQPTWsjQeSppKxudMjYRpX4kzdv9WxrNM8dc4rtlQ==", + "version": "6.0.7", + "resolved": "https://registry.npmjs.org/ipfs-utils/-/ipfs-utils-6.0.7.tgz", + "integrity": "sha512-VlFDyRuCSOKXPOXb68nXSUVEPA+eXbdS7LT22k4aZvFNIoB2OtysDEt8lal93UOB/QS0Gy+6DUoxj1wJ37SIxQ==", "requires": { "abort-controller": "^3.0.0", "any-signal": "^2.1.0", "buffer": "^6.0.1", "electron-fetch": "^1.7.2", - "err-code": "^2.0.3", + "err-code": "^3.0.1", "fs-extra": "^9.0.1", "is-electron": "^2.2.0", "iso-url": "^1.0.0", - "it-glob": "0.0.10", - "it-to-stream": "^0.1.2", + "it-glob": "~0.0.11", + "it-to-stream": "^1.0.0", "merge-options": "^3.0.4", "nanoid": "^3.1.20", "native-abort-controller": "^1.0.3", - "native-fetch": "2.0.1", + "native-fetch": "^3.0.0", "node-fetch": "^2.6.1", - "stream-to-it": "^0.2.2", - "web-encoding": "^1.0.6" + "stream-to-it": "^0.2.2" }, "dependencies": { "buffer": { @@ -19160,13 +19288,10 @@ "ieee754": "^1.2.1" } }, - "native-fetch": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/native-fetch/-/native-fetch-2.0.1.tgz", - "integrity": "sha512-gv4Bea+ga9QdXINurpkEqun3ap3vnB+WYoe4c8ddqUYEH7B2h6iD39RF8uVN7OwmSfMY3RDxkvBnoI4e2/vLXQ==", - "requires": { - "globalthis": "^1.0.1" - } + "err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" } } }, @@ -19630,9 +19755,9 @@ "integrity": "sha512-wiI02c+G1BVuu0jz30Nsr1/et0cpSRulKUusN8HDZXxuX4MdUzfMp2P4JUk+a49Wr1kHitRLrnnh3+UzJ6neaQ==" }, "it-glob": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/it-glob/-/it-glob-0.0.10.tgz", - "integrity": "sha512-p1PR15djgPV7pxdLOW9j4WcJdla8+91rJdUU2hU2Jm68vkxpIEXK55VHBeH8Lvqh2vqLtM83t8q4BuJxue6niA==", + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/it-glob/-/it-glob-0.0.11.tgz", + "integrity": "sha512-p02iVYsvOPU7cW4sV9BC62Kz6Mz2aUTJz/cKWDeFqc05kzB3WgSq8OobZabVA/K4boSm6q+s0xOZ8xiArLSoXQ==", "requires": { "fs-extra": "^9.0.1", "minimatch": "^3.0.4" @@ -19654,13 +19779,6 @@ "it-pushable": "^1.4.0", "it-reader": "^2.0.0", "p-defer": "^3.0.0" - }, - "dependencies": { - "p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==" - } } }, "it-length-prefixed": { @@ -19748,11 +19866,11 @@ "integrity": "sha512-zfr2iAtekTGhHVWzCqqqgDnHhmzdzfCW92L0GvbaSFlvc3n2Ep/sponzmlNl2Kg39N5Py+02v+Aypc+i2c+9og==" }, "it-to-stream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/it-to-stream/-/it-to-stream-0.1.2.tgz", - "integrity": "sha512-DTB5TJRZG3untmZehcaFN0kGWl2bNv7tnJRgQHAO9QEt8jfvVRrebZtnD5NZd4SCj4WVPjl0LSrugNWE/UaZRQ==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/it-to-stream/-/it-to-stream-1.0.0.tgz", + "integrity": "sha512-pLULMZMAB/+vbdvbZtebC0nWBTbG581lk6w8P7DfIIIKUfa8FbY7Oi0FxZcFPbxvISs7A9E+cMpLDBc1XhpAOA==", "requires": { - "buffer": "^5.6.0", + "buffer": "^6.0.3", "fast-fifo": "^1.0.0", "get-iterator": "^1.0.2", "p-defer": "^3.0.0", @@ -19760,10 +19878,36 @@ "readable-stream": "^3.6.0" }, "dependencies": { - "p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==" + "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" + } + } + } + }, + "it-ws": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/it-ws/-/it-ws-4.0.0.tgz", + "integrity": "sha512-XmTzpMkevc6rUboy73r0CCNhciMmL/Yxir9O6FujRwdrjysztqLBQ1Xkr4CpY2m7BVSCObKotaCWJeZ29lOXRA==", + "requires": { + "buffer": "^6.0.3", + "event-iterator": "^2.0.0", + "iso-url": "^1.1.2", + "ws": "^7.3.1" + }, + "dependencies": { + "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" + } } } }, @@ -20143,11 +20287,6 @@ "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.9.2.tgz", "integrity": "sha512-naKSScof4Wn+aoHU6HBsifh92Zeicm1GDQKd1vp3Y/kOi8ub0DozCa9KpvYNCXslFHYRmLNiqRopGdTGwNLpNw==" }, - "p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==" - }, "varint": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", @@ -20200,11 +20339,6 @@ "varint": "^6.0.0" } }, - "p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==" - }, "p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -20382,11 +20516,6 @@ "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.9.2.tgz", "integrity": "sha512-naKSScof4Wn+aoHU6HBsifh92Zeicm1GDQKd1vp3Y/kOi8ub0DozCa9KpvYNCXslFHYRmLNiqRopGdTGwNLpNw==" }, - "p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==" - }, "varint": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", @@ -20423,6 +20552,103 @@ "private-ip": "^2.1.1" } }, + "libp2p-websockets": { + "version": "0.15.5", + "resolved": "https://registry.npmjs.org/libp2p-websockets/-/libp2p-websockets-0.15.5.tgz", + "integrity": "sha512-pD/J5lp4QM8oyQKjLcnnfwwcNbCRDG33+C4njQ7MUKuD5MphF1s2U0z8FiAlTtyNVflYX82dhTYgI4cPzmoBeA==", + "requires": { + "abortable-iterator": "^3.0.0", + "class-is": "^1.1.0", + "debug": "^4.3.1", + "err-code": "^3.0.1", + "ipfs-utils": "^6.0.6", + "it-ws": "^4.0.0", + "libp2p-utils": "^0.3.0", + "mafmt": "^9.0.0", + "multiaddr": "^9.0.1", + "multiaddr-to-uri": "^6.0.0", + "p-defer": "^3.0.0", + "p-timeout": "^4.1.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==" + }, + "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" + } + }, + "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" + } + }, + "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==" + } + } + }, "lines-and-columns": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", @@ -20991,6 +21217,14 @@ "varint": "^5.0.0" } }, + "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==", + "requires": { + "multiaddr": "^8.0.0" + } + }, "multibase": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/multibase/-/multibase-3.1.2.tgz", @@ -21111,13 +21345,6 @@ "it-reader": "^2.0.0", "p-defer": "^3.0.0", "uint8arrays": "^1.1.0" - }, - "dependencies": { - "p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==" - } } }, "murmurhash3js-revisited": { @@ -21746,7 +21973,8 @@ "object-keys": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true }, "object-visit": { "version": "1.0.1", @@ -21912,6 +22140,11 @@ } } }, + "p-defer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", + "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==" + }, "p-fifo": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-fifo/-/p-fifo-1.0.0.tgz", @@ -21919,13 +22152,6 @@ "requires": { "fast-fifo": "^1.0.0", "p-defer": "^3.0.0" - }, - "dependencies": { - "p-defer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-3.0.0.tgz", - "integrity": "sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw==" - } } }, "p-finally": { @@ -21997,8 +22223,7 @@ "p-timeout": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-4.1.0.tgz", - "integrity": "sha512-+/wmHtzJuWii1sXn3HCuH/FTwGhrp4tmJTxSKJbfS+vkipci6osxXM5mY0jUiRzWKMTgUT8l7HFbeSwZAynqHw==", - "dev": true + "integrity": "sha512-+/wmHtzJuWii1sXn3HCuH/FTwGhrp4tmJTxSKJbfS+vkipci6osxXM5mY0jUiRzWKMTgUT8l7HFbeSwZAynqHw==" }, "p-try": { "version": "2.2.0", @@ -24356,6 +24581,12 @@ "typedarray-to-buffer": "^3.1.5" } }, + "ws": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.4.tgz", + "integrity": "sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw==", + "requires": {} + }, "xdg-basedir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", diff --git a/package.json b/package.json index 6baad28b4f..8f92cf28ba 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "libp2p-noise": "^2.0.5", "libp2p-secio": "^0.13.1", "libp2p-tcp": "^0.15.3", + "libp2p-websockets": "^0.15.5", "multiaddr": "^8.1.2", "prompt-sync": "^4.2.0", "ts-proto": "^1.74.0", diff --git a/src/chat/index.ts b/src/chat/index.ts index 2c01b6d3e7..614277d11b 100644 --- a/src/chat/index.ts +++ b/src/chat/index.ts @@ -1,6 +1,7 @@ import readline from 'readline'; import util from 'util'; +import TCP from 'libp2p-tcp'; import Multiaddr from 'multiaddr'; import PeerId from 'peer-id'; @@ -15,15 +16,23 @@ const ChatContentTopic = 'dingpu'; (async function () { const opts = processArguments(); - const waku = await Waku.create({ listenAddresses: [opts.listenAddr] }); - console.log('Waku started'); + const waku = await Waku.create({ + listenAddresses: [opts.listenAddr], + modules: { transport: [TCP] }, + }); + console.log('PeerId: ', waku.libp2p.peerId); + console.log('Listening on '); + waku.libp2p.multiaddrs.forEach((address) => { + console.log(`\t- ${address}`); + }); + // TODO: Automatically subscribe, tracked with // https://github.com/status-im/js-waku/issues/17 await waku.relay.subscribe(); console.log('Subscribed to waku relay'); if (opts.staticNode) { - console.log(`dialing ${opts.staticNode}`); + console.log(`Dialing ${opts.staticNode}`); await waku.dial(opts.staticNode); } diff --git a/src/lib/waku.spec.ts b/src/lib/waku.spec.ts index 62806f78d9..a0ee871d85 100644 --- a/src/lib/waku.spec.ts +++ b/src/lib/waku.spec.ts @@ -1,15 +1,47 @@ import { expect } from 'chai'; +import TCP from 'libp2p-tcp'; -import { makeLogFileName, NimWaku, NOISE_KEY_1 } from '../test_utils/'; +import { + makeLogFileName, + NimWaku, + NOISE_KEY_1, + NOISE_KEY_2, +} from '../test_utils/'; import Waku from './waku'; import { RelayCodec } from './waku_relay'; -describe('Waku', function () { +describe('Waku Dial', function () { + it('js connects to js', async function () { + this.timeout(10_000); + const [waku1, waku2] = await Promise.all([ + Waku.create({ + staticNoiseKey: NOISE_KEY_1, + listenAddresses: ['/ip4/0.0.0.0/tcp/0/wss'], + }), + Waku.create({ staticNoiseKey: NOISE_KEY_2 }), + ]); + const waku1MultiAddrWithId = waku1.getLocalMultiaddrWithID(); + + await waku2.dial(waku1MultiAddrWithId); + + const waku2PeerId = waku2.libp2p.peerId; + + const waku1Peers = waku1.libp2p.peerStore.peers; + + expect(waku1Peers.has(waku2PeerId.toB58String())).to.be.true; + + await Promise.all([waku1.stop(), waku2.stop()]); + }); + describe('Interop: Nim', function () { it('nim connects to js', async function () { this.timeout(10_000); - const waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 }); + const waku = await Waku.create({ + staticNoiseKey: NOISE_KEY_1, + listenAddresses: ['/ip4/0.0.0.0/tcp/0'], + modules: { transport: [TCP] }, + }); const multiAddrWithId = waku.getLocalMultiaddrWithID(); diff --git a/src/lib/waku.ts b/src/lib/waku.ts index b8c63fd7d4..cfc5ccf898 100644 --- a/src/lib/waku.ts +++ b/src/lib/waku.ts @@ -2,7 +2,7 @@ import Libp2p from 'libp2p'; import Mplex from 'libp2p-mplex'; import { bytes } from 'libp2p-noise/dist/src/@types/basic'; import { Noise } from 'libp2p-noise/dist/src/noise'; -import TCP from 'libp2p-tcp'; +import Websockets from 'libp2p-websockets'; import Multiaddr from 'multiaddr'; import pTimeout from 'p-timeout'; import PeerId from 'peer-id'; @@ -17,6 +17,12 @@ const WaitForIdentityTimeoutMs = 2_000; export interface CreateOptions { listenAddresses: string[]; staticNoiseKey: bytes | undefined; + modules: { + transport: import('libp2p-interfaces/src/transport/types').TransportFactory< + any, + any + >[]; + }; } export default class Waku { @@ -28,26 +34,37 @@ export default class Waku { /** * Create new waku node - * @param listenAddresses: Array of Multiaddrs on which the node should listen. If not present, defaults to ['/ip4/0.0.0.0/tcp/0']. + * @param listenAddresses: Array of Multiaddrs on which the node should listen. + * If not present, the node is dial only. * @param staticNoiseKey: A static key to use for noise, * mainly used for test to reduce entropy usage. + * @throws If * @returns {Promise} */ static async create(options: Partial): Promise { const opts = Object.assign( { - listenAddresses: ['/ip4/0.0.0.0/tcp/0'], + listenAddresses: [], staticNoiseKey: undefined, }, options ); + let transport = [Websockets]; + if (opts.modules?.transport) { + transport = transport.concat(opts.modules?.transport); + } + + // FIXME: By controlling the creation of libp2p we have to think about what + // needs to be exposed and what does not. Ideally, we should be able to let + // the user create the WakuStore, WakuRelay instances and pass them when + // creating the libp2p instance. const libp2p = await Libp2p.create({ addresses: { listen: opts.listenAddresses, }, modules: { - transport: [TCP], + transport, streamMuxer: [Mplex], connEncryption: [new Noise(opts.staticNoiseKey)], // eslint-disable-next-line @typescript-eslint/ban-ts-comment diff --git a/src/lib/waku_relay/index.spec.ts b/src/lib/waku_relay/index.spec.ts index 859e1b113e..5a5b735fec 100644 --- a/src/lib/waku_relay/index.spec.ts +++ b/src/lib/waku_relay/index.spec.ts @@ -1,5 +1,6 @@ import { expect } from 'chai'; import Pubsub from 'libp2p-interfaces/src/pubsub'; +import TCP from 'libp2p-tcp'; import { makeLogFileName, @@ -25,7 +26,10 @@ describe('Waku Relay', () => { beforeEach(async function () { [waku1, waku2] = await Promise.all([ Waku.create({ staticNoiseKey: NOISE_KEY_1 }), - Waku.create({ staticNoiseKey: NOISE_KEY_2 }), + Waku.create({ + staticNoiseKey: NOISE_KEY_2, + listenAddresses: ['/ip4/0.0.0.0/tcp/0/wss'], + }), ]); await waku1.dialWithMultiAddr(waku2.libp2p.peerId, waku2.libp2p.multiaddrs); @@ -93,7 +97,11 @@ describe('Waku Relay', () => { beforeEach(async function () { this.timeout(12_000); - waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 }); + waku = await Waku.create({ + staticNoiseKey: NOISE_KEY_1, + listenAddresses: ['/ip4/0.0.0.0/tcp/0'], + modules: { transport: [TCP] }, + }); const multiAddrWithId = waku.getLocalMultiaddrWithID(); nimWaku = new NimWaku(makeLogFileName(this)); @@ -164,7 +172,10 @@ describe('Waku Relay', () => { beforeEach(async function () { this.timeout(10_000); - waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 }); + waku = await Waku.create({ + staticNoiseKey: NOISE_KEY_1, + modules: { transport: [TCP] }, + }); nimWaku = new NimWaku(this.test?.ctx?.currentTest?.title + ''); await nimWaku.start(); @@ -189,7 +200,8 @@ describe('Waku Relay', () => { }); it('Js publishes to nim', async function () { - this.timeout(3000); + this.timeout(5000); + const message = WakuMessage.fromUtf8String('This is a message'); await waku.relay.publish(message); @@ -235,8 +247,14 @@ describe('Waku Relay', () => { beforeEach(async function () { this.timeout(10_000); [waku1, waku2] = await Promise.all([ - Waku.create({ staticNoiseKey: NOISE_KEY_1 }), - Waku.create({ staticNoiseKey: NOISE_KEY_2 }), + Waku.create({ + staticNoiseKey: NOISE_KEY_1, + modules: { transport: [TCP] }, + }), + Waku.create({ + staticNoiseKey: NOISE_KEY_2, + modules: { transport: [TCP] }, + }), ]); nimWaku = new NimWaku(this.test?.ctx?.currentTest?.title + ''); diff --git a/src/lib/waku_store/index.spec.ts b/src/lib/waku_store/index.spec.ts index 3a3d593c32..84ea481b0f 100644 --- a/src/lib/waku_store/index.spec.ts +++ b/src/lib/waku_store/index.spec.ts @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import TCP from 'libp2p-tcp'; import { makeLogFileName, @@ -19,7 +20,10 @@ describe('Waku Store', () => { nimWaku = new NimWaku(makeLogFileName(this)); await nimWaku.start({ store: true }); - const waku0 = await Waku.create({ staticNoiseKey: NOISE_KEY_2 }); + const waku0 = await Waku.create({ + staticNoiseKey: NOISE_KEY_2, + modules: { transport: [TCP] }, + }); await waku0.dial(await nimWaku.getMultiaddrWithId()); await waku0.relay.subscribe(); @@ -41,7 +45,10 @@ describe('Waku Store', () => { await nimWaku.sendMessage(WakuMessage.fromUtf8String(`Message ${i}`)); } - waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 }); + waku = await Waku.create({ + staticNoiseKey: NOISE_KEY_1, + modules: { transport: [TCP] }, + }); await waku.dial(await nimWaku.getMultiaddrWithId()); const nimPeerId = await nimWaku.getPeerId(); @@ -62,7 +69,10 @@ describe('Waku Store', () => { await nimWaku.sendMessage(WakuMessage.fromUtf8String(`Message ${i}`)); } - waku = await Waku.create({ staticNoiseKey: NOISE_KEY_1 }); + waku = await Waku.create({ + staticNoiseKey: NOISE_KEY_1, + modules: { transport: [TCP] }, + }); await waku.dial(await nimWaku.getMultiaddrWithId()); const nimPeerId = await nimWaku.getPeerId(); diff --git a/src/types/types.d.ts b/src/types/types.d.ts index 354945ad2c..673adc8b5b 100644 --- a/src/types/types.d.ts +++ b/src/types/types.d.ts @@ -13,3 +13,4 @@ declare module 'libp2p-secio' { const Secio: any; export = Secio; } +declare module 'libp2p-websockets';