Skip to content

Commit

Permalink
Merge pull request #349 from Web3Auth/fix/vuln
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
himanshuchawla009 authored Nov 22, 2024
2 parents 217b801 + 378c9d3 commit d1c3a74
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 57 deletions.
1 change: 0 additions & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"node-option": ["experimental-specifier-resolution=node", "import=tsx"],
"extension": ["ts", "js"],
"require": ["./test/setup.mjs"],
"timeout": 0,
"exit": true
}
94 changes: 60 additions & 34 deletions package-lock.json

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

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,30 @@
"devDependencies": {
"@babel/register": "^7.25.9",
"@babel/runtime": "^7.26.0",
"@rollup/plugin-replace": "^5.0.7",
"@rollup/plugin-replace": "^6.0.1",
"@toruslabs/config": "^2.2.0",
"@toruslabs/eslint-config-typescript": "^3.3.4",
"@toruslabs/torus-scripts": "^6.1.6",
"@types/color": "^4.2.0",
"@types/elliptic": "^6.4.18",
"@types/end-of-stream": "^1.4.4",
"@types/json-stable-stringify": "^1.1.0",
"@types/mocha": "^10.0.9",
"@types/node": "^20",
"@types/mocha": "^10.0.10",
"@types/node": "^22",
"@types/once": "^1.4.5",
"@types/pump": "^1.1.3",
"@types/readable-stream": "^4.0.18",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"husky": "^9.1.6",
"husky": "^9.1.7",
"jsdom": "^25.0.1",
"jsdom-global": "^3.0.2",
"lint-staged": "^15.2.10",
"mocha": "^10.8.2",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"tsconfig-paths": "^4.2.0",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"tsconfig-paths-webpack-plugin": "^4.2.0",
"tslib": "^2.8.1",
"tsx": "^4.19.2",
"typescript": "^5.6.3"
Expand All @@ -100,8 +100,8 @@
"@babel/runtime": "7.x"
},
"optionalDependencies": {
"@nx/nx-linux-x64-gnu": "^19.6.3",
"@rollup/rollup-linux-x64-gnu": "^4.24.4"
"@nx/nx-linux-x64-gnu": "^20.1.2",
"@rollup/rollup-linux-x64-gnu": "^4.27.3"
},
"author": "Torus Labs",
"license": "MIT",
Expand All @@ -125,7 +125,7 @@
"@toruslabs/metadata-helpers": "^6.0.0",
"@toruslabs/secure-pub-sub": "^1.1.0",
"@toruslabs/session-manager": "^3.2.0",
"@toruslabs/starkware-crypto": "^4.0.0",
"@toruslabs/starkware-crypto": "^4.0.1",
"@toruslabs/tweetnacl-js": "^1.0.4",
"base64url": "^3.0.1",
"bip39": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/core/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {
type WEB3AUTH_LEGACY_NETWORK_TYPE,
WEB3AUTH_NETWORK,
} from "../utils";
import { loglevel as log } from "../utils/logger";
import { InitializationError, LoginError } from "./errors";
import { loglevel as log } from "./logger";
import PopupHandler, { PopupResponse } from "./PopupHandler";
import { constructURL, getHashQueryParams, getTimeout, version } from "./utils";

Expand Down
2 changes: 1 addition & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./auth";
export * from "./errors";
export * from "./logger";
export * from "../utils/logger";
export * from "./utils";
2 changes: 1 addition & 1 deletion src/core/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import bowser from "bowser";

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

// don't use destructuring for process.env cause it messes up webpack env plugin
export const version = process.env.AUTH_VERSION;
Expand Down
14 changes: 8 additions & 6 deletions src/jrpc/jrpcEngine.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Duplex } from "readable-stream";

import { loglevel as log } from "../utils/logger";
import { JsonRpcErrorsArg, rpcErrors } from "./errors/errors";
import { serializeError } from "./errors/utils";
import { getMessageFromCode, serializeError } from "./errors/utils";
import {
JRPCEngineEndCallback,
JRPCEngineNextCallback,
Expand Down Expand Up @@ -82,11 +83,12 @@ export class JRPCEngine extends SafeEventEmitter<JrpcEngineEvents> {
const error = err || res.error;
if (error) {
if (typeof error === "object" && Object.keys(error).includes("stack") === false) error.stack = "Stack trace is not available.";
log.error(error);

res.error = serializeError(error, {
shouldIncludeStack: true,
fallbackError: {
message: error?.message || error?.toString(),
message: error?.message || error?.toString() || getMessageFromCode(error?.code || -32603),
code: error?.code || -32603,
stack: error?.stack || "Stack trace is not available.",
data: error?.data || error?.message || error?.toString(),
Expand Down Expand Up @@ -328,11 +330,11 @@ export class JRPCEngine extends SafeEventEmitter<JrpcEngineEvents> {
delete res.result;
if (!res.error) {
if (typeof error === "object" && Object.keys(error).includes("stack") === false) error.stack = "Stack trace is not available.";

log.error(error);
res.error = serializeError(error, {
shouldIncludeStack: true,
fallbackError: {
message: error?.message || error?.toString(),
message: error?.message || error?.toString() || getMessageFromCode((error as { code?: number })?.code || -32603),
code: (error as { code?: number })?.code || -32603,
stack: error?.stack || "Stack trace is not available.",
data: (error as { data?: string })?.data || error?.message || error?.toString(),
Expand Down Expand Up @@ -428,10 +430,10 @@ export function providerFromEngine(engine: JRPCEngine): SafeEventEmitterProvider
const res = await engine.handle(req);
if (res.error) {
if (typeof res.error === "object" && Object.keys(res.error).includes("stack") === false) res.error.stack = "Stack trace is not available.";

log.error(res.error);
const err = serializeError(res.error, {
fallbackError: {
message: res.error?.message || res.error?.toString(),
message: res.error?.message || res.error?.toString() || getMessageFromCode(res.error?.code || -32603),
code: res.error?.code || -32603,
stack: res.error?.stack || "Stack trace is not available.",
data: res.error?.data || res.error?.message || res.error?.toString(),
Expand Down
File renamed without changes.
5 changes: 0 additions & 5 deletions test/setup.mjs

This file was deleted.

0 comments on commit d1c3a74

Please sign in to comment.