Skip to content

Commit

Permalink
update url parse
Browse files Browse the repository at this point in the history
  • Loading branch information
koko37 committed Dec 10, 2024
1 parent b716f7d commit 78c95a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/lib/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ export const generateHash = async (password, passcode, cb = () => {}) => {
export const getEvmPrivateKey = (h) =>
ethers.keccak256(abi.encode(["string"], [h]));

const URL_DELIMITER = "\u0002";

export function generateUrl(password, passcode, network) {
const merged = Buffer.from(
password + "\u0002" + passcode + "\u0002" + network,
password + URL_DELIMITER + passcode + URL_DELIMITER + network,
"utf-8"
);
const base64Encoded = merged.toString("base64");
Expand All @@ -60,7 +62,7 @@ export function generateUrl(password, passcode, network) {
export function parseUrl(token) {
const payload = token.slice(6, token.length - 6);
const base64Decoded = Buffer.from(payload, "base64").toString("utf-8");
const [password, passcode, network] = base64Decoded.split("\u0002");
const [password, passcode, network] = base64Decoded.split(URL_DELIMITER);
return [password, passcode, network];
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Menu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const Menu = () => {
const networkName = findNetworkNameByChainId(network, chainId);
const link = generateUrl(password, passcode, networkName);
copy(
window.location.origin + window.location.pathname + "?secret=" + link
window.location.origin + window.location.pathname + "?wallet=" + link
);
toast("Wallet link copied into clipboard.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Signin/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const SignIn = () => {
// get "secret" param from URL
const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
const secret = params.get("secret");
const secret = params.get("wallet");
if (!secret) {
return;
}
Expand Down

0 comments on commit 78c95a0

Please sign in to comment.