49: Integrate js-waku in web chat app r=D4nte a=D4nte

Resolves #14

Co-authored-by: Franck Royer <franck@status.im>
This commit is contained in:
bors[bot] 2021-04-22 11:37:55 +00:00 committed by GitHub
commit 8a6caf55a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 1888 additions and 456 deletions

View File

@ -22,6 +22,7 @@
"execa",
"exponentiate",
"fanout",
"floodsub",
"globby",
"gossipsub",
"iasked",

View File

@ -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

1175
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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",

View File

@ -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,

View File

@ -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':

View File

@ -1,24 +1,25 @@
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';
import Websockets from 'libp2p-websockets';
import Multiaddr from 'multiaddr';
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';
export interface CreateOptions {
listenAddresses: string[];
staticNoiseKey: bytes | undefined;
modules: {
transport: import('libp2p-interfaces/src/transport/types').TransportFactory<
any,
any
>[];
};
}
const transportKey = Websockets.prototype[Symbol.toStringTag];
export type CreateOptions =
| {
listenAddresses: string[] | undefined;
staticNoiseKey: bytes | undefined;
modules: Partial<Libp2pModules>;
config: Partial<Libp2pConfig>;
}
| (Libp2pOptions & import('libp2p').CreateOptions);
export default class Waku {
public libp2p: Libp2p;
@ -49,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);
@ -70,6 +84,7 @@ export default class Waku {
// @ts-ignore: Type needs update
pubsub: WakuRelay,
},
config: opts.config,
});
const wakuStore = new WakuStore(libp2p);

View File

@ -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<PeerScoreParams>;
scoreThresholds: Partial<PeerScoreThresholds>;
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<GossipOptions>} [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<GossipOptions>) {
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 });
}

View File

@ -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 };
}

View File

@ -14,3 +14,4 @@ declare module 'libp2p-secio' {
export = Secio;
}
declare module 'libp2p-websockets';
declare module 'libp2p-websockets/src/filters';

View File

@ -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",

View File

@ -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": {
@ -24,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": [

View File

@ -1,53 +1,155 @@
import { Paper } from '@material-ui/core';
import React from 'react';
import { multiaddr } from 'multiaddr';
import PeerId from 'peer-id';
import React, { useEffect, useState } 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';
interface Props {
}
export const ChatContentTopic = 'dingpu';
interface State {
messages: string[],
waku?: WakuMock
messages: ChatMessage[];
waku?: Waku;
}
class App extends React.Component<Props, State> {
waku?: WakuMock;
export default function App() {
let [state, setState] = useState<State>({ messages: [] });
constructor(props: Props) {
super(props);
useEffect(() => {
async function initWaku() {
try {
const waku = await Waku.create({
config: {
pubsub: {
enabled: true,
emitSelf: true,
},
},
});
this.state = {
messages: []
setState(({ messages }) => {
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(
'16Uiu2HAmVVi6Q4j7MAKVibquW8aA27UNrA4Q8Wkz9EetGViu8ZF1'
),
[multiaddr('/ip4/134.209.113.86/tcp/9001/ws')]
);
} catch (e) {
console.log('Issue starting waku ', e);
}
}
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 });
}
};
WakuMock.create().then((wakuMock) => {
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, handleNewMessages);
this.setState({ waku: wakuMock, messages: this.state.messages });
// To clean up listener when component unmounts
return () => {
state.waku?.libp2p.pubsub.removeListener(
RelayDefaultTopic,
handleNewMessages
);
};
}
});
wakuMock.on('message', (message) => {
const messages = this.state.messages.slice();
messages.push(message.message);
this.setState({ messages });
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 <Multiaddr>: 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 }) => {
commandResponses.forEach((res) => {
messages.push(new ChatMessage(new Date(), cmd, res));
});
return { waku, messages };
});
}
};
render() {
return (
<div className='App'>
<div className='chat-room'>
<WakuContext.Provider value={{ waku: this.state.waku }}>
<Paper >
<Room lines={this.state.messages} />
</Paper>
</WakuContext.Provider>
</div>
return (
<div className="App">
<div className="chat-room">
<WakuContext.Provider value={{ waku: state.waku }}>
<Paper>
<Room lines={state.messages} commandHandler={commandHandler} />
</Paper>
</WakuContext.Provider>
</div>
);
}
</div>
);
}
export default App;

View File

@ -1,39 +1,61 @@
import React, { ChangeEvent } from 'react';
import { TextField } from '@material-ui/core';
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;
sendMessage: () => void;
}
interface State {
inputText: string;
}
export default class MessageInput extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
inputText: ''
};
}
messageHandler(event: ChangeEvent<HTMLInputElement>) {
this.props.messageHandler(event.target.value);
}
render() {
return (
<TextField variant='outlined'
label='Send a message'
fullWidth
style={{ margin: 8 }}
margin="normal"
InputLabelProps={{
shrink: true,
}}
onChange={this.messageHandler.bind(this)}
/>
);
}
export default function MessageInput(props: Props) {
const [inputText, setInputText] = useState<string>('');
const { waku } = useWaku();
const sendMessage = () => {
props.sendMessage();
setInputText('');
};
const messageHandler = (event: ChangeEvent<HTMLInputElement>) => {
setInputText(event.target.value);
props.messageHandler(event.target.value);
};
const keyPressHandler = (event: KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'Enter') {
sendMessage();
}
};
return (
<Grid container spacing={2} direction="row" alignItems="center">
<Grid item xs={11}>
<TextField
variant="outlined"
label="Send a message"
value={inputText}
fullWidth
style={{ margin: 8 }}
margin="normal"
InputLabelProps={{
shrink: true,
}}
onChange={messageHandler}
onKeyPress={keyPressHandler}
disabled={!waku}
/>
</Grid>
<Grid item xs={1}>
<Button
variant="contained"
color="primary"
size="large"
onClick={sendMessage}
disabled={!waku}
>
Send
</Button>
</Grid>
</Grid>
);
}

View File

@ -1,80 +1,92 @@
import {
Box,
Grid,
List,
ListItem,
ListItemText
} from '@material-ui/core';
import React from 'react';
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';
import { ChatContentTopic } from './App';
import MessageInput from './MessageInput';
import Send from './Send';
import { useWaku } from './WakuContext';
interface Props {
lines: string[],
lines: ChatMessage[];
commandHandler: (cmd: string) => void;
}
interface State {
messageToSend: string
}
export default function Room(props: Props) {
let [messageToSend, setMessageToSend] = useState<string>('');
const { waku } = useWaku();
const messageHandler = (msg: string) => {
setMessageToSend(msg);
};
export default class Room extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { messageToSend: '' };
}
messageHandler(msg: string) {
this.setState({ messageToSend: msg });
}
render() {
return (
<Grid container spacing={2}>
<Grid item xs={12}>
<Box height={800} maxHeight={800}
style={{ flex: 1, maxHeight: '100%', overflow: 'scroll' }}>
<Lines messages={this.props.lines} />
</Box>
</Grid>
<Grid item xs={12}>
<Grid container spacing={2} direction='row' alignItems='center'>
<Grid item xs={11}>
<MessageInput messageHandler={this.messageHandler.bind(this)} />
</Grid>
<Grid item xs={1}>
<Send message={this.state.messageToSend} />
</Grid>
</Grid>
</Grid>
const sendMessage = async () => {
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 (
<Grid container spacing={2}>
<Grid item xs={12}>
<Box
height={800}
maxHeight={800}
style={{ flex: 1, maxHeight: '100%', overflow: 'scroll' }}
>
<Lines messages={props.lines} />
</Box>
</Grid>
);
}
<Grid item xs={12}>
<MessageInput
messageHandler={messageHandler}
sendMessage={sendMessage}
/>
</Grid>
</Grid>
);
}
interface LinesProps {
messages: string[]
messages: ChatMessage[];
}
const Lines = (props: LinesProps) => {
const renderedLines = [];
for (const line of props.messages) {
renderedLines.push(<ListItem>
<ListItemText
primary={line}
/>
</ListItem>);
for (const i in props.messages) {
renderedLines.push(
<ListItem>
<ListItemText
key={'chat-message-' + i}
primary={printMessage(props.messages[i])}
/>
</ListItem>
);
}
return (
<List dense={true}>
{renderedLines}
</List>
);
return <List dense={true}>{renderedLines}</List>;
};
// 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}`;
}

View File

@ -1,23 +0,0 @@
import React from 'react';
import { useWaku } from './WakuContext';
import { Button } from '@material-ui/core';
interface Props {
message: string
}
const Send = (props: Props) => {
const { waku } = useWaku();
const handleClick = async () => {
await waku!.send(props.message);
};
return (
<Button variant="contained" color="primary" size="large" onClick={handleClick}>
Send
</Button>
);
};
export default Send;

View File

@ -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<WakuContextType>({ waku: undefined });