mirror of
https://github.com/waku-org/js-waku.git
synced 2025-01-13 14:05:24 +00:00
Merge pull request #605 from status-im/examples-with-npmjs-waku-dependencies
Import js-waku from npmjs.com instead of locally for examples
This commit is contained in:
commit
94c8cdf016
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@ -3,16 +3,16 @@ name: CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'staging'
|
||||
- 'trying'
|
||||
- "master"
|
||||
- "staging"
|
||||
- "trying"
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
env:
|
||||
BUF_VERSION: '0.56.0'
|
||||
NIM_WAKU_VERSION: 'v0.9'
|
||||
BUF_VERSION: "0.56.0"
|
||||
NIM_WAKU_VERSION: "v0.9"
|
||||
strategy:
|
||||
matrix:
|
||||
node: [16]
|
||||
@ -51,7 +51,7 @@ jobs:
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
with:
|
||||
version: '3.x'
|
||||
version: "3.x"
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Cache npm cache
|
||||
|
25
.github/workflows/examples-ci.yml
vendored
25
.github/workflows/examples-ci.yml
vendored
@ -3,26 +3,33 @@ name: Examples CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'staging'
|
||||
- 'trying'
|
||||
- "master"
|
||||
- "staging"
|
||||
- "trying"
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
examples_build_and_test:
|
||||
strategy:
|
||||
matrix:
|
||||
example: [ web-chat, eth-pm, eth-pm-wallet-encryption, relay-reactjs-chat, store-reactjs-chat, relay-angular-chat ]
|
||||
example:
|
||||
[
|
||||
web-chat,
|
||||
eth-pm,
|
||||
eth-pm-wallet-encryption,
|
||||
relay-reactjs-chat,
|
||||
store-reactjs-chat,
|
||||
relay-angular-chat,
|
||||
]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install NodeJS
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
node-version: "16"
|
||||
|
||||
- name: Check if `yarn` or `npm` is used.
|
||||
id: use-yarn
|
||||
@ -37,12 +44,6 @@ jobs:
|
||||
path: ~/.npm
|
||||
key: examples-node-v1-${{ hashFiles('**/package-lock.json') }}
|
||||
|
||||
- name: "[js-waku] install using npm ci"
|
||||
uses: bahmutov/npm-install@v1
|
||||
|
||||
- name: "[js-waku] build"
|
||||
run: npm run build
|
||||
|
||||
- name: (npm) ${{ matrix.example }} install using npm i
|
||||
if: steps.use-yarn.outputs.lockfile != 'yarn.lock'
|
||||
run: npm install
|
||||
|
@ -32,9 +32,11 @@ pipeline {
|
||||
|
||||
stage('Examples') {
|
||||
parallel {
|
||||
stage('web-chat') { steps { script { buildExample() } } }
|
||||
stage('eth-pm') { steps { script { buildExample() } } }
|
||||
stage('eth-pm-wallet-encryption') { steps { script { buildExample() } } }
|
||||
stage('relay-reactjs-chat') { steps { script { buildExample() } } }
|
||||
stage('store-reactjs-chat') { steps { script { buildExample() } } }
|
||||
stage('web-chat') { steps { script { buildExample() } } }
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +58,6 @@ def buildExample(example=STAGE_NAME) {
|
||||
def dest = "${WORKSPACE}/build/docs/examples/${example}"
|
||||
dir("examples/${example}") {
|
||||
sh 'npm install'
|
||||
sh 'npm run build'
|
||||
sh "mkdir -p ${dest}"
|
||||
sh "cp -r build/. ${dest}"
|
||||
}
|
||||
|
3954
examples/eth-pm-wallet-encryption/package-lock.json
generated
3954
examples/eth-pm-wallet-encryption/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@
|
||||
"eth-sig-util": "^3.0.1",
|
||||
"ethers": "^5.5.4",
|
||||
"fontsource-roboto": "^4.0.0",
|
||||
"js-waku": "file:../../build/main",
|
||||
"js-waku": "^0.19.2",
|
||||
"protobufjs": "^6.11.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
@ -56,12 +56,17 @@
|
||||
"devDependencies": {
|
||||
"@ethersproject/shims": "^5.5.0",
|
||||
"@types/node": "^17.0.17",
|
||||
"assert": "^2.0.0",
|
||||
"buffer": "^6.0.3",
|
||||
"cra-webpack-rewired": "^1.0.1",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"cspell": "^5.18.4",
|
||||
"eslint": "^8.9.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.5.1",
|
||||
"process": "^0.11.10",
|
||||
"react-scripts": "5.0.0",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"typescript": "^4.5.5"
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import "@ethersproject/shims";
|
||||
|
||||
import { PublicKeyMessage } from "./messaging/wire";
|
||||
import { hexToBytes, bytesToHex } from "js-waku/lib/utils";
|
||||
import { utils } from "js-waku";
|
||||
import * as sigUtil from "eth-sig-util";
|
||||
import { equals } from "uint8arrays/equals";
|
||||
|
||||
@ -29,8 +29,8 @@ export async function createPublicKeyMessage(
|
||||
|
||||
return new PublicKeyMessage({
|
||||
encryptionPublicKey: encryptionPublicKey,
|
||||
ethAddress: hexToBytes(address),
|
||||
signature: hexToBytes(signature),
|
||||
ethAddress: utils.hexToBytes(address),
|
||||
signature: utils.hexToBytes(signature),
|
||||
});
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) {
|
||||
message: {
|
||||
message:
|
||||
"By signing this message you certify that messages addressed to `ownerAddress` must be encrypted with `encryptionPublicKey`",
|
||||
encryptionPublicKey: bytesToHex(encryptionPublicKey),
|
||||
encryptionPublicKey: utils.bytesToHex(encryptionPublicKey),
|
||||
ownerAddress: fromAddress,
|
||||
},
|
||||
// Refers to the keys of the *types* object below.
|
||||
@ -81,7 +81,7 @@ export async function signEncryptionKey(
|
||||
|
||||
console.log("TYPED SIGNED:" + JSON.stringify(result));
|
||||
|
||||
return hexToBytes(result);
|
||||
return utils.hexToBytes(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,13 +90,16 @@ export async function signEncryptionKey(
|
||||
export function validatePublicKeyMessage(msg: PublicKeyMessage): boolean {
|
||||
const recovered = sigUtil.recoverTypedSignature_v4({
|
||||
data: JSON.parse(
|
||||
buildMsgParams(msg.encryptionPublicKey, "0x" + bytesToHex(msg.ethAddress))
|
||||
buildMsgParams(
|
||||
msg.encryptionPublicKey,
|
||||
"0x" + utils.bytesToHex(msg.ethAddress)
|
||||
)
|
||||
),
|
||||
sig: "0x" + bytesToHex(msg.signature),
|
||||
sig: "0x" + utils.bytesToHex(msg.signature),
|
||||
});
|
||||
|
||||
console.log("Recovered", recovered);
|
||||
console.log("ethAddress", "0x" + bytesToHex(msg.ethAddress));
|
||||
console.log("ethAddress", "0x" + utils.bytesToHex(msg.ethAddress));
|
||||
|
||||
return equals(hexToBytes(recovered), msg.ethAddress);
|
||||
return equals(utils.hexToBytes(recovered), msg.ethAddress);
|
||||
}
|
||||
|
@ -7,8 +7,7 @@ import {
|
||||
TextField,
|
||||
} from "@material-ui/core";
|
||||
import React, { ChangeEvent, useState, KeyboardEvent } from "react";
|
||||
import { Waku, WakuMessage } from "js-waku";
|
||||
import { bytesToHex, hexToBytes } from "js-waku/lib/utils";
|
||||
import { utils, Waku, WakuMessage } from "js-waku";
|
||||
import { PrivateMessage } from "./wire";
|
||||
import { PrivateMessageContentTopic } from "../waku";
|
||||
import * as sigUtil from "eth-sig-util";
|
||||
@ -111,7 +110,7 @@ async function encodeEncryptedWakuMessage(
|
||||
address: string
|
||||
): Promise<WakuMessage> {
|
||||
const privateMessage = new PrivateMessage({
|
||||
toAddress: hexToBytes(address),
|
||||
toAddress: utils.hexToBytes(address),
|
||||
message: message,
|
||||
});
|
||||
|
||||
@ -119,7 +118,7 @@ async function encodeEncryptedWakuMessage(
|
||||
|
||||
const encObj = sigUtil.encrypt(
|
||||
Buffer.from(publicKey).toString("base64"),
|
||||
{ data: bytesToHex(payload) },
|
||||
{ data: utils.bytesToHex(payload) },
|
||||
"x25519-xsalsa20-poly1305"
|
||||
);
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
import { Waku, WakuMessage } from "js-waku";
|
||||
import { utils, Waku, WakuMessage } from "js-waku";
|
||||
import { PrivateMessage, PublicKeyMessage } from "./messaging/wire";
|
||||
import { validatePublicKeyMessage } from "./crypto";
|
||||
import { Message } from "./messaging/Messages";
|
||||
import { bytesToHex, hexToBytes } from "js-waku/lib/utils";
|
||||
import { equals } from "uint8arrays/equals";
|
||||
|
||||
export const PublicKeyContentTopic =
|
||||
@ -37,7 +36,7 @@ export function handlePublicKeyMessage(
|
||||
if (!msg.payload) return;
|
||||
const publicKeyMsg = PublicKeyMessage.decode(msg.payload);
|
||||
if (!publicKeyMsg) return;
|
||||
if (myAddress && equals(publicKeyMsg.ethAddress, hexToBytes(myAddress)))
|
||||
if (myAddress && equals(publicKeyMsg.ethAddress, utils.hexToBytes(myAddress)))
|
||||
return;
|
||||
|
||||
const res = validatePublicKeyMessage(publicKeyMsg);
|
||||
@ -46,7 +45,7 @@ export function handlePublicKeyMessage(
|
||||
if (res) {
|
||||
setPublicKeys((prevPks: Map<string, Uint8Array>) => {
|
||||
prevPks.set(
|
||||
bytesToHex(publicKeyMsg.ethAddress),
|
||||
utils.bytesToHex(publicKeyMsg.ethAddress),
|
||||
publicKeyMsg.encryptionPublicKey
|
||||
);
|
||||
return new Map(prevPks);
|
||||
@ -79,7 +78,7 @@ export async function handlePrivateMessage(
|
||||
console.log("Failed to decode Private Message");
|
||||
return;
|
||||
}
|
||||
if (!equals(privateMessage.toAddress, hexToBytes(address))) return;
|
||||
if (!equals(privateMessage.toAddress, utils.hexToBytes(address))) return;
|
||||
|
||||
const timestamp = wakuMsg.timestamp ? wakuMsg.timestamp : new Date();
|
||||
|
||||
|
3995
examples/eth-pm/package-lock.json
generated
3995
examples/eth-pm/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@
|
||||
"eth-sig-util": "^3.0.1",
|
||||
"ethers": "^5.5.4",
|
||||
"fontsource-roboto": "^4.0.0",
|
||||
"js-waku": "file:../../build/main",
|
||||
"js-waku": "^0.19.2",
|
||||
"protobufjs": "^6.11.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
@ -56,12 +56,17 @@
|
||||
"devDependencies": {
|
||||
"@ethersproject/shims": "^5.5.0",
|
||||
"@types/node": "^17.0.19",
|
||||
"assert": "^2.0.0",
|
||||
"buffer": "^6.0.3",
|
||||
"cra-webpack-rewired": "^1.0.1",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"cspell": "^5.18.4",
|
||||
"eslint": "^8.9.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.5.1",
|
||||
"process": "^0.11.10",
|
||||
"react-scripts": "5.0.0",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"typescript": "^4.5.5"
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
import "@ethersproject/shims";
|
||||
|
||||
import { PublicKeyMessage } from "./messaging/wire";
|
||||
import { hexToBytes, bytesToHex } from "js-waku/lib/utils";
|
||||
import { generatePrivateKey, getPublicKey } from "js-waku";
|
||||
import { generatePrivateKey, getPublicKey, utils } from "js-waku";
|
||||
import * as sigUtil from "eth-sig-util";
|
||||
import { PublicKeyContentTopic } from "./waku";
|
||||
import { keccak256 } from "ethers/lib/utils";
|
||||
import { equals } from "uint8arrays/equals";
|
||||
|
||||
export const PublicKeyMessageEncryptionKey = hexToBytes(
|
||||
export const PublicKeyMessageEncryptionKey = utils.hexToBytes(
|
||||
keccak256(Buffer.from(PublicKeyContentTopic, "utf-8"))
|
||||
);
|
||||
|
||||
@ -50,8 +49,8 @@ export async function createPublicKeyMessage(
|
||||
|
||||
return new PublicKeyMessage({
|
||||
encryptionPublicKey: encryptionPublicKey,
|
||||
ethAddress: hexToBytes(address),
|
||||
signature: hexToBytes(signature),
|
||||
ethAddress: utils.hexToBytes(address),
|
||||
signature: utils.hexToBytes(signature),
|
||||
});
|
||||
}
|
||||
|
||||
@ -64,7 +63,7 @@ function buildMsgParams(encryptionPublicKey: Uint8Array, fromAddress: string) {
|
||||
message: {
|
||||
message:
|
||||
"By signing this message you certify that messages addressed to `ownerAddress` must be encrypted with `encryptionPublicKey`",
|
||||
encryptionPublicKey: bytesToHex(encryptionPublicKey),
|
||||
encryptionPublicKey: utils.bytesToHex(encryptionPublicKey),
|
||||
ownerAddress: fromAddress,
|
||||
},
|
||||
// Refers to the keys of the *types* object below.
|
||||
@ -102,7 +101,7 @@ export async function signEncryptionKey(
|
||||
|
||||
console.log("TYPED SIGNED:" + JSON.stringify(result));
|
||||
|
||||
return hexToBytes(result);
|
||||
return utils.hexToBytes(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,13 +110,16 @@ export async function signEncryptionKey(
|
||||
export function validatePublicKeyMessage(msg: PublicKeyMessage): boolean {
|
||||
const recovered = sigUtil.recoverTypedSignature_v4({
|
||||
data: JSON.parse(
|
||||
buildMsgParams(msg.encryptionPublicKey, "0x" + bytesToHex(msg.ethAddress))
|
||||
buildMsgParams(
|
||||
msg.encryptionPublicKey,
|
||||
"0x" + utils.bytesToHex(msg.ethAddress)
|
||||
)
|
||||
),
|
||||
sig: "0x" + bytesToHex(msg.signature),
|
||||
sig: "0x" + utils.bytesToHex(msg.signature),
|
||||
});
|
||||
|
||||
console.log("Recovered", recovered);
|
||||
console.log("ethAddress", "0x" + bytesToHex(msg.ethAddress));
|
||||
console.log("ethAddress", "0x" + utils.bytesToHex(msg.ethAddress));
|
||||
|
||||
return equals(hexToBytes(recovered), msg.ethAddress);
|
||||
return equals(utils.hexToBytes(recovered), msg.ethAddress);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { KeyPair } from "../crypto";
|
||||
import { bytesToHex, hexToBytes } from "js-waku/lib/utils";
|
||||
import { utils } from "js-waku";
|
||||
|
||||
/**
|
||||
* Save keypair to storage, encrypted with password
|
||||
@ -11,9 +11,9 @@ export async function saveKeyPairToStorage(
|
||||
const { salt, iv, cipher } = await encryptKey(EncryptionKeyPair, password);
|
||||
|
||||
const data = {
|
||||
salt: bytesToHex(salt),
|
||||
iv: bytesToHex(iv),
|
||||
cipher: bytesToHex(cipher),
|
||||
salt: utils.bytesToHex(salt),
|
||||
iv: utils.bytesToHex(iv),
|
||||
cipher: utils.bytesToHex(cipher),
|
||||
};
|
||||
|
||||
localStorage.setItem("cipherEncryptionKeyPair", JSON.stringify(data));
|
||||
@ -29,9 +29,9 @@ export async function loadKeyPairFromStorage(
|
||||
if (!str) return;
|
||||
const data = JSON.parse(str);
|
||||
|
||||
const salt = hexToBytes(data.salt);
|
||||
const iv = hexToBytes(data.iv);
|
||||
const cipher = hexToBytes(data.cipher);
|
||||
const salt = utils.hexToBytes(data.salt);
|
||||
const iv = utils.hexToBytes(data.iv);
|
||||
const cipher = utils.hexToBytes(data.cipher);
|
||||
|
||||
return await decryptKey(salt, iv, cipher, password);
|
||||
}
|
||||
|
@ -7,8 +7,7 @@ import {
|
||||
TextField,
|
||||
} from "@material-ui/core";
|
||||
import React, { ChangeEvent, useState, KeyboardEvent } from "react";
|
||||
import { Waku, WakuMessage } from "js-waku";
|
||||
import { hexToBytes } from "js-waku/lib/utils";
|
||||
import { utils, Waku, WakuMessage } from "js-waku";
|
||||
import { PrivateMessage } from "./wire";
|
||||
import { PrivateMessageContentTopic } from "../waku";
|
||||
|
||||
@ -110,7 +109,7 @@ async function encodeEncryptedWakuMessage(
|
||||
address: string
|
||||
): Promise<WakuMessage> {
|
||||
const privateMessage = new PrivateMessage({
|
||||
toAddress: hexToBytes(address),
|
||||
toAddress: utils.hexToBytes(address),
|
||||
message: message,
|
||||
});
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
import { Waku, WakuMessage } from "js-waku";
|
||||
import { utils, Waku, WakuMessage } from "js-waku";
|
||||
import { PrivateMessage, PublicKeyMessage } from "./messaging/wire";
|
||||
import { validatePublicKeyMessage } from "./crypto";
|
||||
import { Message } from "./messaging/Messages";
|
||||
import { bytesToHex, hexToBytes } from "js-waku/lib/utils";
|
||||
import { equals } from "uint8arrays/equals";
|
||||
|
||||
export const PublicKeyContentTopic = "/eth-pm/1/public-key/proto";
|
||||
@ -35,7 +34,7 @@ export function handlePublicKeyMessage(
|
||||
if (!msg.payload) return;
|
||||
const publicKeyMsg = PublicKeyMessage.decode(msg.payload);
|
||||
if (!publicKeyMsg) return;
|
||||
if (myAddress && equals(publicKeyMsg.ethAddress, hexToBytes(myAddress)))
|
||||
if (myAddress && equals(publicKeyMsg.ethAddress, utils.hexToBytes(myAddress)))
|
||||
return;
|
||||
|
||||
const res = validatePublicKeyMessage(publicKeyMsg);
|
||||
@ -44,7 +43,7 @@ export function handlePublicKeyMessage(
|
||||
if (res) {
|
||||
setter((prevPks: Map<string, Uint8Array>) => {
|
||||
prevPks.set(
|
||||
bytesToHex(publicKeyMsg.ethAddress),
|
||||
utils.bytesToHex(publicKeyMsg.ethAddress),
|
||||
publicKeyMsg.encryptionPublicKey
|
||||
);
|
||||
return new Map(prevPks);
|
||||
@ -64,7 +63,7 @@ export async function handlePrivateMessage(
|
||||
console.log("Failed to decode Private Message");
|
||||
return;
|
||||
}
|
||||
if (!equals(privateMessage.toAddress, hexToBytes(address))) return;
|
||||
if (!equals(privateMessage.toAddress, utils.hexToBytes(address))) return;
|
||||
|
||||
const timestamp = wakuMsg.timestamp ? wakuMsg.timestamp : new Date();
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
{
|
||||
"name": "@waku/relay-angular-chat",
|
||||
"version": "0.1.0",
|
||||
"homepage": "/examples/relay-angular-chat",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test"
|
||||
"test": "ng test",
|
||||
"test-ci": "ng test --watch=false"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
@ -19,7 +21,7 @@
|
||||
"@angular/platform-browser-dynamic": "~13.2.0",
|
||||
"@angular/router": "~13.2.0",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"js-waku": "file:../../build/esm",
|
||||
"js-waku": "^0.19.2",
|
||||
"protons": "^2.0.3",
|
||||
"rxjs": "~7.5.0",
|
||||
"stream-browserify": "^3.0.0",
|
||||
@ -31,7 +33,7 @@
|
||||
"@angular/cli": "~13.2.2",
|
||||
"@angular/compiler-cli": "~13.2.0",
|
||||
"@types/bl": "^5.0.2",
|
||||
"@types/jasmine": "~4.0.0",
|
||||
"@types/jasmine": "~3.10.0",
|
||||
"@types/node": "^17.0.21",
|
||||
"jasmine-core": "~4.0.0",
|
||||
"karma": "~6.3.0",
|
||||
|
File diff suppressed because it is too large
Load Diff
11506
examples/relay-reactjs-chat/package-lock.json
generated
11506
examples/relay-reactjs-chat/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@
|
||||
"@testing-library/react": "^12.1.2",
|
||||
"@testing-library/user-event": "^14.0.4",
|
||||
"it-pipe": "^2.0.3",
|
||||
"js-waku": "file:../../",
|
||||
"js-waku": "^0.19.2",
|
||||
"protobufjs": "^6.11.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
|
3353
examples/store-reactjs-chat/package-lock.json
generated
3353
examples/store-reactjs-chat/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@
|
||||
"assert": "^2.0.0",
|
||||
"buffer": "^6.0.3",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"js-waku": "file:../../build/esm",
|
||||
"js-waku": "^0.19.2",
|
||||
"protons": "^2.0.3",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
|
@ -6,9 +6,14 @@ module.exports = {
|
||||
if (!config.resolve) config.resolve = {};
|
||||
if (!config.resolve.fallback) config.resolve.fallback = {};
|
||||
Object.assign(config.resolve.fallback, {
|
||||
assert: require.resolve("assert"),
|
||||
buffer: require.resolve("buffer"),
|
||||
crypto: require.resolve("crypto-browserify"),
|
||||
http: require.resolve("http-browserify"),
|
||||
https: require.resolve("https-browserify"),
|
||||
stream: require.resolve("stream-browserify"),
|
||||
url: require.resolve("url"),
|
||||
zlib: require.resolve("browserify-zlib"),
|
||||
});
|
||||
|
||||
if (!config.plugins) config.plugins = [];
|
||||
@ -34,9 +39,14 @@ module.exports = {
|
||||
if (!config.resolve) config.resolve = {};
|
||||
if (!config.resolve.fallback) config.resolve.fallback = {};
|
||||
Object.assign(config.resolve.fallback, {
|
||||
assert: require.resolve("assert"),
|
||||
buffer: require.resolve("buffer"),
|
||||
crypto: require.resolve("crypto-browserify"),
|
||||
http: require.resolve("http-browserify"),
|
||||
https: require.resolve("https-browserify"),
|
||||
stream: require.resolve("stream-browserify"),
|
||||
url: require.resolve("url"),
|
||||
zlib: require.resolve("browserify-zlib"),
|
||||
});
|
||||
|
||||
if (!config.plugins) config.plugins = [];
|
||||
|
3877
examples/web-chat/package-lock.json
generated
3877
examples/web-chat/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -5,9 +5,12 @@
|
||||
"homepage": "/examples/web-chat",
|
||||
"dependencies": {
|
||||
"@livechat/ui-kit": "^0.5.0-20",
|
||||
"browserify-zlib": "^0.2.0",
|
||||
"buffer": "^6.0.3",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"js-waku": "file:../../build/main",
|
||||
"http-browserify": "^1.7.0",
|
||||
"https-browserify": "^1.0.0",
|
||||
"js-waku": "^0.19.2",
|
||||
"process": "^0.11.10",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
@ -22,13 +25,15 @@
|
||||
"@types/node": "^17.0.17",
|
||||
"@types/react": "^18.0.2",
|
||||
"@types/react-dom": "^18.0.0",
|
||||
"assert": "^2.0.0",
|
||||
"cra-webpack-rewired": "^1.0.1",
|
||||
"cspell": "^5.18.4",
|
||||
"gh-pages": "^3.2.3",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.5.1",
|
||||
"react-scripts": "5.0.0",
|
||||
"typescript": "^4.5.5"
|
||||
"typescript": "^4.5.5",
|
||||
"url": "^0.11.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cra-webpack-rewired start",
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { useEffect, useReducer, useState } from "react";
|
||||
import "./App.css";
|
||||
import {
|
||||
PageDirection,
|
||||
discovery,
|
||||
getPredefinedBootstrapNodes,
|
||||
PageDirection,
|
||||
Waku,
|
||||
WakuMessage,
|
||||
} from "js-waku";
|
||||
@ -12,7 +13,6 @@ import { WakuContext } from "./WakuContext";
|
||||
import { ThemeProvider } from "@livechat/ui-kit";
|
||||
import { generate } from "server-name-generator";
|
||||
import { Message } from "./Message";
|
||||
import { Fleet } from "js-waku/lib/discovery/predefined";
|
||||
|
||||
const themes = {
|
||||
AuthorName: {
|
||||
@ -198,9 +198,9 @@ async function initWaku(setter: (waku: Waku) => void) {
|
||||
function selectFleetEnv() {
|
||||
// Works with react-scripts
|
||||
if (process?.env?.NODE_ENV === "development") {
|
||||
return Fleet.Test;
|
||||
return discovery.predefined.Fleet.Test;
|
||||
} else {
|
||||
return Fleet.Prod;
|
||||
return discovery.predefined.Fleet.Prod;
|
||||
}
|
||||
}
|
||||
|
||||
|
41
package-lock.json
generated
41
package-lock.json
generated
@ -32,7 +32,6 @@
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.1",
|
||||
"@size-limit/preset-big-lib": "^7.0.8",
|
||||
"@types/app-root-path": "^1.2.4",
|
||||
"@types/bl": "^5.0.2",
|
||||
"@types/chai": "^4.2.15",
|
||||
"@types/mocha": "^9.1.0",
|
||||
"@types/node": "^17.0.6",
|
||||
@ -1437,16 +1436,6 @@
|
||||
"integrity": "sha1-p4twMoKzKsVN52j1US7MNWmRncc=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/bl": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/bl/-/bl-5.0.2.tgz",
|
||||
"integrity": "sha512-V4g3uJIfBHeDd/35QTPOujJ4+viJJVtNwC2LmBUZeXGSGL60R5iTsBEZ9Nh+wP3asMOA/LEFHxmKT6JzK+Vd0A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"@types/readable-stream": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/chai": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.0.tgz",
|
||||
@ -1569,16 +1558,6 @@
|
||||
"integrity": "sha512-5qOlnZscTn4xxM5MeGXAMOsIOIKIbh9e85zJWfBRVPlRMEVawzoPhINYbRGkBZCI8LxvBe7tJCdWiarA99OZfQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/readable-stream": {
|
||||
"version": "2.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-2.3.13.tgz",
|
||||
"integrity": "sha512-4JSCx8EUzaW9Idevt+9lsRAt1lcSccoQfE+AouM1gk8sFxnnytKNIO3wTl9Dy+4m6jRJ1yXhboLHHT/LXBQiEw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"safe-buffer": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/retry": {
|
||||
"version": "0.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.1.tgz",
|
||||
@ -13930,16 +13909,6 @@
|
||||
"integrity": "sha1-p4twMoKzKsVN52j1US7MNWmRncc=",
|
||||
"dev": true
|
||||
},
|
||||
"@types/bl": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/bl/-/bl-5.0.2.tgz",
|
||||
"integrity": "sha512-V4g3uJIfBHeDd/35QTPOujJ4+viJJVtNwC2LmBUZeXGSGL60R5iTsBEZ9Nh+wP3asMOA/LEFHxmKT6JzK+Vd0A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*",
|
||||
"@types/readable-stream": "*"
|
||||
}
|
||||
},
|
||||
"@types/chai": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.0.tgz",
|
||||
@ -14062,16 +14031,6 @@
|
||||
"integrity": "sha512-5qOlnZscTn4xxM5MeGXAMOsIOIKIbh9e85zJWfBRVPlRMEVawzoPhINYbRGkBZCI8LxvBe7tJCdWiarA99OZfQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/readable-stream": {
|
||||
"version": "2.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/readable-stream/-/readable-stream-2.3.13.tgz",
|
||||
"integrity": "sha512-4JSCx8EUzaW9Idevt+9lsRAt1lcSccoQfE+AouM1gk8sFxnnytKNIO3wTl9Dy+4m6jRJ1yXhboLHHT/LXBQiEw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*",
|
||||
"safe-buffer": "*"
|
||||
}
|
||||
},
|
||||
"@types/retry": {
|
||||
"version": "0.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.1.tgz",
|
||||
|
@ -34,7 +34,7 @@
|
||||
"build:umd:min:bundle": "webpack --config webpack.config.min.bundle.js",
|
||||
"size": "npm run build:esm && size-limit",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier \"src/**/*.ts\" \"./*.json\" \"*.conf.js\" --write",
|
||||
"fix:prettier": "prettier \"src/**/*.ts\" \"./*.json\" \"*.conf.js\" \".github/**/*.yml\" --write",
|
||||
"fix:lint": "eslint src --ext .ts --fix",
|
||||
"pretest": "run-s pretest:*",
|
||||
"pretest:1-init-git-submodules": "[ -f './nim-waku/build/wakunode2' ] || git submodule update --init --recursive",
|
||||
@ -44,7 +44,7 @@
|
||||
"nim-waku:force-build": "(cd nim-waku && rm -rf ./build/ ./vendor && make -j$(nproc --all 2>/dev/null || echo 2) update) && run-s nim-waku:build",
|
||||
"test": "run-s build test:*",
|
||||
"test:lint": "eslint src --ext .ts",
|
||||
"test:prettier": "prettier \"src/**/*.ts\" \"./*.json\" \"*.conf.js\" --list-different",
|
||||
"test:prettier": "prettier \"src/**/*.ts\" \"./*.json\" \"*.conf.js\" \".github/**/*.yml\" --list-different",
|
||||
"test:spelling": "cspell \"{README.md,.github/*.md,guides/*.md,src/**/*.ts}\"",
|
||||
"test:unit": "nyc --silent mocha",
|
||||
"test:karma": "karma start",
|
||||
@ -88,7 +88,6 @@
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.1",
|
||||
"@size-limit/preset-big-lib": "^7.0.8",
|
||||
"@types/app-root-path": "^1.2.4",
|
||||
"@types/bl": "^5.0.2",
|
||||
"@types/chai": "^4.2.15",
|
||||
"@types/mocha": "^9.1.0",
|
||||
"@types/node": "^17.0.6",
|
||||
|
Loading…
x
Reference in New Issue
Block a user