chore: noise-js and noise-rtc style issues and configuration

This commit is contained in:
Sasha 2023-01-27 23:46:36 +01:00 committed by GitHub
parent 95d13a52db
commit d673c76491
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 24 deletions

View File

@ -37,7 +37,7 @@
} }
.container { .container {
width: 800px; width: 100%;
min-width: 300px; min-width: 300px;
max-width: 800px; max-width: 800px;
height: 100%; height: 100%;

View File

@ -189,7 +189,6 @@
type="text" type="text"
></textarea> ></textarea>
<button id="send-btn" type="button" disabled>Send message</button> <button id="send-btn" type="button" disabled>Send message</button>
<button id="connect-chat-btn" type="button">Connect to chat</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -23,13 +23,7 @@ async function main() {
ui.waku.connecting(); ui.waku.connecting();
// Starting the node // Starting the node
const node = await createLightNode({ const node = await createLightNode({ defaultBootstrap: true });
libp2p: {
peerDiscovery: [
new PeerDiscoveryStaticPeers(getPredefinedBootstrapNodes(Fleet.Test)),
],
},
});
try { try {
await node.start(); await node.start();
@ -76,16 +70,6 @@ async function main() {
ui.hide(); ui.hide();
} }
/*
// The information needs to be backed up to decrypt messages sent with
// codecs generated with the handshake. The `handshakeResult` variable
// contains private information that needs to be stored safely
const contentTopic = pairingObj.contentTopic;
const handshakeResult = pairingObj.getHandshakeResult();
// To restore the codecs for decrypting older messages, or continuing an existing
// session, use this:
[encoder, decoder] = WakuPairing.getSecureCodec(contentTopic, handshakeResult);
*/
ui.message.display(); ui.message.display();
const { peerConnection, sendMessage: sendRTCMessage } = initRTC({ const { peerConnection, sendMessage: sendRTCMessage } = initRTC({
@ -97,7 +81,6 @@ async function main() {
if (event.candidate) { if (event.candidate) {
console.log("candidate sent"); console.log("candidate sent");
try { try {
// if (!peerConnection.remoteDescription) return;
ui.rtc.sendingCandidate(); ui.rtc.sendingCandidate();
await sendWakuMessage({ await sendWakuMessage({
type: "candidate", type: "candidate",
@ -165,7 +148,6 @@ async function main() {
const receiveCandidate = async (data) => { const receiveCandidate = async (data) => {
try { try {
// if (!peerConnection.pendingRemoteDescription) return;
console.log("candidate saved"); console.log("candidate saved");
await peerConnection.addIceCandidate( await peerConnection.addIceCandidate(
new RTCIceCandidate(data.candidate) new RTCIceCandidate(data.candidate)
@ -305,7 +287,6 @@ async function buildWakuMessage(node, noiseExecute) {
const sendMessage = async (message) => { const sendMessage = async (message) => {
let payload = ProtoMessage.create({ let payload = ProtoMessage.create({
// data: utils.utf8ToBytes(JSON.stringify(message)),
data: JSON.stringify(message), data: JSON.stringify(message),
}); });
payload = ProtoMessage.encode(payload).finish(); payload = ProtoMessage.encode(payload).finish();
@ -316,7 +297,6 @@ async function buildWakuMessage(node, noiseExecute) {
const listenToMessages = async (fn) => { const listenToMessages = async (fn) => {
return node.filter.subscribe([decoder], ({ payload }) => { return node.filter.subscribe([decoder], ({ payload }) => {
const { data } = ProtoMessage.decode(payload); const { data } = ProtoMessage.decode(payload);
// fn(JSON.parse(utils.bytesToUtf8(data)));
fn(JSON.parse(data)); fn(JSON.parse(data));
}); });
}; };
@ -485,7 +465,7 @@ function initUI() {
this._render({ this._render({
nick, nick,
time: timestamp * 1000, time: timestamp,
text, text,
}); });
}, },