Skip to content

Commit

Permalink
Fix: Update parseToken to use safeatob
Browse files Browse the repository at this point in the history
  • Loading branch information
shahbaz17 committed Apr 8, 2024
1 parent 4fb02e1 commit a89abc7
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 11 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
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 a89abc7

Please sign in to comment.