Skip to content

Commit

Permalink
chore: use next version of libraries for light-js and noise-js (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
weboko authored Apr 23, 2024
1 parent f60c456 commit ebf7beb
Show file tree
Hide file tree
Showing 4 changed files with 4,272 additions and 8,065 deletions.
16 changes: 11 additions & 5 deletions examples/light-js/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ <h2>Store</h2>
createDecoder,
utf8ToBytes,
bytesToUtf8,
} from "https://unpkg.com/@waku/[email protected].24-070b625.0/bundle/index.js";
} from "https://unpkg.com/@waku/[email protected].25-fd60cc2.0/bundle/index.js";
import {
enrTree,
DnsNodeDiscovery,
} from "https://unpkg.com/@waku/[email protected]/bundle/index.js";
import { messageHash } from "https://unpkg.com/@waku/[email protected]/bundle/index.js";
wakuDnsDiscovery,
} from "https://unpkg.com/@waku/[email protected]/bundle/index.js";
import { messageHash } from "https://unpkg.com/@waku/[email protected]/bundle/index.js";

const peerIdDiv = document.getElementById("peer-id");
const remotePeerIdDiv = document.getElementById("remote-peer-id");
Expand All @@ -99,7 +100,7 @@ <h2>Store</h2>

const ContentTopic = "/js-waku-examples/1/chat/utf8";
const decoder = createDecoder(ContentTopic);
const encoder = createEncoder({ contentTopic: ContentTopic });
const encoder = createEncoder({ contentTopic: ContentTopic});
// Each key is a unique identifier for the message. Each value is an obj { text, timestamp }
let messages = {};
let unsubscribe;
Expand All @@ -125,7 +126,12 @@ <h2>Store</h2>
}

statusDiv.innerHTML = "<p>Creating Waku node.</p>";
const node = await createLightNode();
const node = await createLightNode({
shardInfo: {
contentTopics: [ContentTopic]
},
defaultBootstrap: true,
});

statusDiv.innerHTML = "<p>Starting Waku node.</p>";
await node.start();
Expand Down
12 changes: 10 additions & 2 deletions examples/noise-js/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { createLightNode, waitForRemotePeer } from "@waku/sdk";
import * as utils from "@waku/utils/bytes";
import { contentTopicToPubsubTopic } from "@waku/utils";
import * as noise from "@waku/noise";
import protobuf from "protobufjs";
import QRCode from "qrcode";

const ContentTopic = "/noise-js/1/message/proto";
const PubsubTopic = contentTopicToPubsubTopic(ContentTopic);

// Protobuf
const ProtoChatMessage = new protobuf.Type("ChatMessage")
.add(new protobuf.Field("timestamp", 1, "uint64"))
Expand All @@ -19,6 +23,9 @@ async function main() {
// Starting the node
const node = await createLightNode({
defaultBootstrap: true,
shardInfo: {
contentTopics: [ContentTopic],
}
});

try {
Expand All @@ -27,13 +34,14 @@ async function main() {

ui.waku.connected();

const myStaticKey = noise.generateX25519KeyPair();
const myStaticKey = new noise.X25519DHKey();
const urlPairingInfo = getPairingInfoFromURL();

const pairingObj = new noise.WakuPairing(
PubsubTopic,
node.lightPush,
node.filter,
myStaticKey,
myStaticKey.generateKeyPair(),
urlPairingInfo || new noise.ResponderParameters()
);
const pExecute = pairingObj.execute(120000); // timeout after 2m
Expand Down
Loading

0 comments on commit ebf7beb

Please sign in to comment.