Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1995 committed Aug 29, 2024
1 parent 16d21ab commit 4fd1f0b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
2 changes: 0 additions & 2 deletions package-lock.json

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

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
"dependencies": {
"@ethereumjs/util": "^9.1.0",
"@toruslabs/constants": "^14.0.0",
"@toruslabs/eccrypto": "^5.0.4",
"@toruslabs/ffjavascript": "^4.0.0",
"@toruslabs/metadata-helpers": "^6.0.0",
"@toruslabs/secure-pub-sub": "^1.0.0",
Expand All @@ -130,7 +129,6 @@
"bn.js": "^5.2.1",
"bowser": "^2.11.0",
"color": "^4.2.3",
"elliptic": "^6.5.7",
"enc-utils": "^3.0.0",
"end-of-stream": "^1.4.4",
"events": "^3.3.0",
Expand Down
11 changes: 1 addition & 10 deletions src/core/utils.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import { getPublic, sign } from "@toruslabs/eccrypto";
import { keccak256 } from "@toruslabs/metadata-helpers";
import bowser from "bowser";

import { base64url, LOGIN_PROVIDER, safeatob } from "../utils";
import { LOGIN_PROVIDER, safeatob } from "../utils";
import { loglevel as log } from "./logger";

// don't use destructuring for process.env cause it messes up webpack env plugin
export const version = process.env.AUTH_VERSION;

export async function whitelistUrl(clientId: string, appKey: string, origin: string): Promise<string> {
const appKeyBuf = Buffer.from(appKey.padStart(64, "0"), "hex");
if (base64url.encode(getPublic(appKeyBuf)) !== clientId) throw new Error("appKey mismatch");
const sig = await sign(appKeyBuf, keccak256(Buffer.from(origin, "utf8")));
return base64url.encode(sig);
}

export type HashQueryParamResult = {
sessionId?: string;
sessionNamespace?: string;
Expand Down

0 comments on commit 4fd1f0b

Please sign in to comment.