Merge pull request #168 from waku-org/chore/@waku-core-0.0.8
This commit is contained in:
commit
047715670d
|
@ -9,10 +9,10 @@
|
|||
"@material-ui/core": "^4.12.4",
|
||||
"@material-ui/icons": "^4.11.3",
|
||||
"@waku/byte-utils": "0.0.2",
|
||||
"@waku/core": "0.0.6",
|
||||
"@waku/create": "0.0.4",
|
||||
"@waku/interfaces": "0.0.5",
|
||||
"@waku/message-encryption": "0.0.4",
|
||||
"@waku/core": "^0.0.8",
|
||||
"@waku/create": "^0.0.6",
|
||||
"@waku/interfaces": "^0.0.6",
|
||||
"@waku/message-encryption": "^0.0.7",
|
||||
"ethers": "5.7.1",
|
||||
"fontsource-roboto": "^4.0.0",
|
||||
"protobufjs": "^7.1.2",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,8 +2,9 @@ import "@ethersproject/shims";
|
|||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import "./App.css";
|
||||
import type { WakuPrivacy } from "@waku/interfaces";
|
||||
import { AsymDecoder, SymDecoder } from "@waku/message-encryption";
|
||||
import type { RelayNode, IDecoder } from "@waku/interfaces";
|
||||
import { createDecoder as createSymmetricDecoder } from "@waku/message-encryption/symmetric";
|
||||
import { createDecoder, DecodedMessage } from "@waku/message-encryption/ecies";
|
||||
import { KeyPair, PublicKeyMessageEncryptionKey } from "./crypto";
|
||||
import { Message } from "./messaging/Messages";
|
||||
import "fontsource-roboto";
|
||||
|
@ -67,13 +68,13 @@ const useStyles = makeStyles({
|
|||
});
|
||||
|
||||
function App() {
|
||||
const [waku, setWaku] = useState<WakuPrivacy>();
|
||||
const [waku, setWaku] = useState<RelayNode>();
|
||||
const [provider, setProvider] = useState<Web3Provider>();
|
||||
const [encryptionKeyPair, setEncryptionKeyPair] = useState<
|
||||
KeyPair | undefined
|
||||
>();
|
||||
const [privateMessageDecoder, setPrivateMessageDecoder] =
|
||||
useState<AsymDecoder>();
|
||||
useState<IDecoder<DecodedMessage>>();
|
||||
const [publicKeys, setPublicKeys] = useState<Map<string, Uint8Array>>(
|
||||
new Map()
|
||||
);
|
||||
|
@ -109,7 +110,7 @@ function App() {
|
|||
setPublicKeys
|
||||
);
|
||||
|
||||
const publicKeyMessageDecoder = new SymDecoder(
|
||||
const publicKeyMessageDecoder = createSymmetricDecoder(
|
||||
PublicKeyContentTopic,
|
||||
PublicKeyMessageEncryptionKey
|
||||
);
|
||||
|
@ -134,7 +135,7 @@ function App() {
|
|||
if (!encryptionKeyPair) return;
|
||||
|
||||
setPrivateMessageDecoder(
|
||||
new AsymDecoder(PrivateMessageContentTopic, encryptionKeyPair.privateKey)
|
||||
createDecoder(PrivateMessageContentTopic, encryptionKeyPair.privateKey)
|
||||
);
|
||||
}, [encryptionKeyPair]);
|
||||
|
||||
|
|
|
@ -6,14 +6,14 @@ import {
|
|||
PublicKeyMessageEncryptionKey,
|
||||
} from "./crypto";
|
||||
import { PublicKeyMessage } from "./messaging/wire";
|
||||
import type { WakuPrivacy } from "@waku/interfaces";
|
||||
import { SymEncoder } from "@waku/message-encryption";
|
||||
import type { RelayNode } from "@waku/interfaces";
|
||||
import { createEncoder } from "@waku/message-encryption/symmetric";
|
||||
import { PublicKeyContentTopic } from "./waku";
|
||||
import type { TypedDataSigner } from "@ethersproject/abstract-signer";
|
||||
|
||||
interface Props {
|
||||
encryptionKeyPair: KeyPair | undefined;
|
||||
waku: WakuPrivacy | undefined;
|
||||
waku: RelayNode | undefined;
|
||||
address: string | undefined;
|
||||
signer: TypedDataSigner | undefined;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export default function BroadcastPublicKey({
|
|||
})();
|
||||
const payload = _publicKeyMessage.encode();
|
||||
|
||||
const publicKeyMessageEncoder = new SymEncoder(
|
||||
const publicKeyMessageEncoder = createEncoder(
|
||||
PublicKeyContentTopic,
|
||||
PublicKeyMessageEncryptionKey
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Messages, { Message } from "./Messages";
|
||||
import type { WakuPrivacy } from "@waku/interfaces";
|
||||
import type { RelayNode } from "@waku/interfaces";
|
||||
import SendMessage from "./SendMessage";
|
||||
import { makeStyles } from "@material-ui/core";
|
||||
|
||||
|
@ -13,7 +13,7 @@ const useStyles = makeStyles({
|
|||
});
|
||||
|
||||
interface Props {
|
||||
waku: WakuPrivacy | undefined;
|
||||
waku: RelayNode | undefined;
|
||||
recipients: Map<string, Uint8Array>;
|
||||
messages: Message[];
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import {
|
|||
TextField,
|
||||
} from "@material-ui/core";
|
||||
import React, { ChangeEvent, useState, KeyboardEvent } from "react";
|
||||
import type { WakuPrivacy } from "@waku/interfaces";
|
||||
import { AsymEncoder } from "@waku/message-encryption";
|
||||
import type { RelayNode } from "@waku/interfaces";
|
||||
import { createEncoder } from "@waku/message-encryption/ecies";
|
||||
import { PrivateMessage } from "./wire";
|
||||
import { PrivateMessageContentTopic } from "../waku";
|
||||
import { hexToBytes } from "@waku/byte-utils";
|
||||
|
@ -24,7 +24,7 @@ const useStyles = makeStyles((theme) => ({
|
|||
}));
|
||||
|
||||
export interface Props {
|
||||
waku: WakuPrivacy | undefined;
|
||||
waku: RelayNode | undefined;
|
||||
// address, public key
|
||||
recipients: Map<string, Uint8Array>;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ export default function SendMessage({ waku, recipients }: Props) {
|
|||
}
|
||||
|
||||
async function sendMessage(
|
||||
waku: WakuPrivacy,
|
||||
waku: RelayNode,
|
||||
recipientAddress: string,
|
||||
recipientPublicKey: Uint8Array,
|
||||
message: string,
|
||||
|
@ -118,10 +118,7 @@ async function sendMessage(
|
|||
});
|
||||
const payload = privateMessage.encode();
|
||||
|
||||
const encoder = new AsymEncoder(
|
||||
PrivateMessageContentTopic,
|
||||
recipientPublicKey
|
||||
);
|
||||
const encoder = createEncoder(PrivateMessageContentTopic, recipientPublicKey);
|
||||
|
||||
console.log("pushing");
|
||||
const res = await waku.relay.send(encoder, { payload });
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
import { Dispatch, SetStateAction } from "react";
|
||||
import type { Message as WakuMessage, WakuPrivacy } from "@waku/interfaces";
|
||||
import type { RelayNode } from "@waku/interfaces";
|
||||
import { Protocols } from "@waku/interfaces";
|
||||
import { PrivateMessage, PublicKeyMessage } from "./messaging/wire";
|
||||
import { validatePublicKeyMessage } from "./crypto";
|
||||
import { Message } from "./messaging/Messages";
|
||||
import { equals } from "uint8arrays/equals";
|
||||
import { waitForRemotePeer } from "@waku/core/lib/wait_for_remote_peer";
|
||||
import { createPrivacyNode } from "@waku/create";
|
||||
import { waitForRemotePeer } from "@waku/core";
|
||||
import { createRelayNode } from "@waku/create";
|
||||
import { bytesToHex, hexToBytes } from "@waku/byte-utils";
|
||||
import type { DecodedMessage } from "@waku/message-encryption";
|
||||
|
||||
export const PublicKeyContentTopic = "/eth-pm/1/public-key/proto";
|
||||
export const PrivateMessageContentTopic = "/eth-pm/1/private-message/proto";
|
||||
|
||||
export async function initWaku(): Promise<WakuPrivacy> {
|
||||
const waku = await createPrivacyNode({ defaultBootstrap: true });
|
||||
export async function initWaku(): Promise<RelayNode> {
|
||||
const waku = await createRelayNode({ defaultBootstrap: true });
|
||||
await waku.start();
|
||||
await waitForRemotePeer(waku, [Protocols.Relay]);
|
||||
|
||||
|
@ -23,7 +24,7 @@ export async function initWaku(): Promise<WakuPrivacy> {
|
|||
export function handlePublicKeyMessage(
|
||||
myAddress: string | undefined,
|
||||
setter: Dispatch<SetStateAction<Map<string, Uint8Array>>>,
|
||||
msg: WakuMessage
|
||||
msg: DecodedMessage
|
||||
) {
|
||||
console.log("Public Key Message received:", msg);
|
||||
if (!msg.payload) return;
|
||||
|
@ -49,7 +50,7 @@ export function handlePublicKeyMessage(
|
|||
export async function handlePrivateMessage(
|
||||
setter: Dispatch<SetStateAction<Message[]>>,
|
||||
address: string,
|
||||
wakuMsg: WakuMessage
|
||||
wakuMsg: DecodedMessage
|
||||
) {
|
||||
console.log("Private Message received:", wakuMsg);
|
||||
if (!wakuMsg.payload) return;
|
||||
|
|
Loading…
Reference in New Issue