mirror of
https://github.com/status-im/js-waku-examples.git
synced 2025-02-10 14:06:46 +00:00
change format of sharing URL
This commit is contained in:
parent
1aa1823963
commit
8f04dc659e
@ -23,20 +23,18 @@ const wakuStatusSpan = document.getElementById("waku-status");
|
|||||||
const handshakeStatusSpan = document.getElementById("handshake-status");
|
const handshakeStatusSpan = document.getElementById("handshake-status");
|
||||||
|
|
||||||
function getPairingInfofromUrl() {
|
function getPairingInfofromUrl() {
|
||||||
const urlParts = window.location.href.split("?");
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
if (urlParts.length < 2) return undefined;
|
|
||||||
|
|
||||||
const pairingParts = decodeURIComponent(urlParts[1]).split(":");
|
const messageNameTag = urlParams.get("messageNameTag");
|
||||||
if (pairingParts.length < 6)
|
const qrCodeString = urlParams.get("qrCode");
|
||||||
throw new Error("invalid pairing information format");
|
|
||||||
|
|
||||||
const qrMessageNameTag = new Uint8Array(
|
if (!(messageNameTag && qrCodeString)) {
|
||||||
utils.hexToBytes(pairingParts.shift())
|
return undefined;
|
||||||
);
|
}
|
||||||
|
|
||||||
return new noise.InitiatorParameters(
|
return new noise.InitiatorParameters(
|
||||||
pairingParts.join(":"),
|
qrCodeString,
|
||||||
qrMessageNameTag
|
utils.hexToBytes(messageNameTag)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,10 +231,11 @@ async function main() {
|
|||||||
const pInfo = pairingObj.getPairingInfo();
|
const pInfo = pairingObj.getPairingInfo();
|
||||||
|
|
||||||
// Data to encode in the QR code. The qrMessageNametag too to the QR string (separated by )
|
// Data to encode in the QR code. The qrMessageNametag too to the QR string (separated by )
|
||||||
const qrString =
|
const messageNameTagParam = `messageNameTag=${utils.bytesToHex(
|
||||||
utils.bytesToHex(pInfo.qrMessageNameTag) + ":" + pInfo.qrCode;
|
pInfo.qrMessageNameTag
|
||||||
const qrURLString =
|
)}`;
|
||||||
window.location.href + "?" + encodeURIComponent(qrString);
|
const qrCodeParam = `qrCode=${encodeURIComponent(pInfo.qrCode)}`;
|
||||||
|
const qrURLString = `${window.location.href}?${messageNameTagParam}&${qrCodeParam}`;
|
||||||
|
|
||||||
handshakeStatusSpan.innerHTML = "generating QR code...";
|
handshakeStatusSpan.innerHTML = "generating QR code...";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user