Skip to content

Commit

Permalink
Merge pull request #103 from Web3Auth/fix/parseToken
Browse files Browse the repository at this point in the history
Fix: Update parseToken to use safeatob
  • Loading branch information
himanshuchawla009 authored Apr 8, 2024
2 parents 4fb02e1 + 8061bb1 commit 6066484
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 15 deletions.
83 changes: 75 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@toruslabs/fnd-base": "^13.1.1",
"@toruslabs/metadata-helpers": "^5.x",
"@toruslabs/openlogin-session-manager": "^3.0.0",
"@toruslabs/openlogin-utils": "^8.0.0",
"@toruslabs/torus.js": "^12.1.0",
"@toruslabs/tss-client": "^2.1.0",
"@toruslabs/tss-lib": "^2.0.0",
Expand Down
8 changes: 4 additions & 4 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { ec as EllipticCurve } from "elliptic";

export const DEFAULT_CHAIN_CONFIG: CustomChainConfig = {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: "0x5",
rpcTarget: "https://rpc.ankr.com/eth_goerli",
displayName: "Goerli Testnet",
blockExplorer: "https://goerli.etherscan.io",
chainId: "0xaa36a7",
rpcTarget: "https://rpc.ankr.com/eth_sepolia",
displayName: "Ethereum Sepolia Testnet",
blockExplorer: "https://sepolia.etherscan.io",
ticker: "ETH",
tickerName: "Ethereum",
decimals: 18,
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getPubKeyPoint, Point, Point as TkeyPoint, randomSelection } from "@tkey-mpc/common-types";
import ThresholdKey from "@tkey-mpc/core";
import { generatePrivate } from "@toruslabs/eccrypto";
import { safeatob } from "@toruslabs/openlogin-utils";
import { keccak256 } from "@toruslabs/torus.js";
import BN from "bn.js";

Expand Down Expand Up @@ -59,9 +60,8 @@ export function storageAvailable(type: string): boolean {
* @returns Extracted JSON payload from the token
*/
export function parseToken(token: string) {
const base64Url = token.split(".")[1];
const base64 = base64Url.replace("-", "+").replace("_", "/");
return JSON.parse(atob(base64 || ""));
const payload = token.split(".")[1];
return JSON.parse(safeatob(payload));
}

/**
Expand Down

0 comments on commit 6066484

Please sign in to comment.