Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@web3auth/base

Package Overview
Dependencies
Maintainers
2
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3auth/base - npm Package Compare versions

Comparing version 4.6.0 to 5.0.0-alpha.0

68

dist/base.cjs.js

@@ -130,9 +130,9 @@ /******/ (() => { // webpackBootstrap

}
if (chainId === 3) {
if (chainId === 5) {
return {
chainNamespace,
chainId: "0x3",
rpcTarget: `https://rpc.ankr.com/eth_ropsten`,
displayName: "Ropsten Testnet",
blockExplorer: "https://ropsten.etherscan.io/",
chainId: "0x5",
rpcTarget: `https://rpc.ankr.com/eth_goerli`,
displayName: "Goerli Testnet",
blockExplorer: "https://goerli.etherscan.io/",
ticker: "ETH",

@@ -143,9 +143,9 @@ tickerName: "Ethereum",

}
if (chainId === 4) {
if (chainId === 11155111) {
return {
chainNamespace,
chainId: "0x4",
rpcTarget: `https://rpc.ankr.com/eth_rinkeby`,
displayName: "Rinkeby Testnet",
blockExplorer: "https://rinkeby.etherscan.io/",
chainId: "0xaa36a7",
rpcTarget: `https://rpc.ankr.com/eth_sepolia`,
displayName: "Sepolia Testnet",
blockExplorer: "https://sepolia.etherscan.io/",
ticker: "ETH",

@@ -156,14 +156,2 @@ tickerName: "Ethereum",

}
if (chainId === 5) {
return {
chainNamespace,
chainId: "0x5",
rpcTarget: `https://rpc.ankr.com/eth_goerli`,
displayName: "Goerli Testnet",
blockExplorer: "https://goerli.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum",
decimals: 18
};
}
if (chainId === 137) {

@@ -451,2 +439,10 @@ return {

}
static chainConfigNotAdded() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletLoginError.fromCode(5116, extraMessage);
}
static unsupportedOperation() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletLoginError.fromCode(5117, extraMessage);
}
}

@@ -459,3 +455,5 @@ defineProperty_default()(WalletLoginError, "messages", {

5114: "Wallet popup has been closed by the user",
5115: "User has already enabled mfa, please use the @web3auth/web3auth-web sdk for login with mfa"
5115: "User has already enabled mfa, please use the @web3auth/web3auth-web sdk for login with mfa",
5116: "Chain config has not been added. Please add the chain config before calling switchChain",
5117: "Unsupported operation"
});

@@ -518,3 +516,4 @@ ;// CONCATENATED MODULE: ./src/wallet/index.ts

const ADAPTER_EVENTS = IAdapter_objectSpread(IAdapter_objectSpread({}, ADAPTER_STATUS), {}, {
ADAPTER_DATA_UPDATED: "adapter_data_updated"
ADAPTER_DATA_UPDATED: "adapter_data_updated",
CACHE_CLEAR: "cache_clear"
});

@@ -534,2 +533,3 @@ class BaseAdapter extends openlogin_jrpc_namespaceObject.SafeEventEmitter {

defineProperty_default()(this, "chainConfig", null);
defineProperty_default()(this, "knownChainConfigs", {});
defineProperty_default()(this, "adapterNamespace", void 0);

@@ -567,2 +567,3 @@ defineProperty_default()(this, "currentChainNamespace", void 0);

this.chainConfig = finalChainConfig;
this.addChainConfig(finalChainConfig);
}

@@ -592,2 +593,14 @@ }

}
checkAddChainRequirements() {
let init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
if (!init && !this.provider) throw WalletLoginError.notConnectedError("Not connected with wallet.");
}
checkSwitchChainRequirements(_ref) {
let {
chainId
} = _ref;
let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
if (!init && !this.provider) throw WalletLoginError.notConnectedError("Not connected with wallet.");
if (!this.knownChainConfigs[chainId]) throw WalletLoginError.chainConfigNotAdded("Invalid chainId");
}
updateAdapterData(data) {

@@ -600,2 +613,9 @@ this.adapterData = data;

}
addChainConfig(chainConfig) {
const currentConfig = this.knownChainConfigs[chainConfig.chainId];
this.knownChainConfigs[chainConfig.chainId] = IAdapter_objectSpread(IAdapter_objectSpread({}, currentConfig || {}), chainConfig);
}
getChainConfig(chainId) {
return this.knownChainConfigs[chainId] || null;
}
}

@@ -602,0 +622,0 @@ class BaseNetworkSwitch {}

@@ -42,9 +42,9 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';

}
if (chainId === 3) {
if (chainId === 5) {
return {
chainNamespace,
chainId: "0x3",
rpcTarget: `https://rpc.ankr.com/eth_ropsten`,
displayName: "Ropsten Testnet",
blockExplorer: "https://ropsten.etherscan.io/",
chainId: "0x5",
rpcTarget: `https://rpc.ankr.com/eth_goerli`,
displayName: "Goerli Testnet",
blockExplorer: "https://goerli.etherscan.io/",
ticker: "ETH",

@@ -55,9 +55,9 @@ tickerName: "Ethereum",

}
if (chainId === 4) {
if (chainId === 11155111) {
return {
chainNamespace,
chainId: "0x4",
rpcTarget: `https://rpc.ankr.com/eth_rinkeby`,
displayName: "Rinkeby Testnet",
blockExplorer: "https://rinkeby.etherscan.io/",
chainId: "0xaa36a7",
rpcTarget: `https://rpc.ankr.com/eth_sepolia`,
displayName: "Sepolia Testnet",
blockExplorer: "https://sepolia.etherscan.io/",
ticker: "ETH",

@@ -68,14 +68,2 @@ tickerName: "Ethereum",

}
if (chainId === 5) {
return {
chainNamespace,
chainId: "0x5",
rpcTarget: `https://rpc.ankr.com/eth_goerli`,
displayName: "Goerli Testnet",
blockExplorer: "https://goerli.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum",
decimals: 18
};
}
if (chainId === 137) {

@@ -352,2 +340,10 @@ return {

}
static chainConfigNotAdded() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletLoginError.fromCode(5116, extraMessage);
}
static unsupportedOperation() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletLoginError.fromCode(5117, extraMessage);
}
}

@@ -360,3 +356,5 @@ _defineProperty(WalletLoginError, "messages", {

5114: "Wallet popup has been closed by the user",
5115: "User has already enabled mfa, please use the @web3auth/web3auth-web sdk for login with mfa"
5115: "User has already enabled mfa, please use the @web3auth/web3auth-web sdk for login with mfa",
5116: "Chain config has not been added. Please add the chain config before calling switchChain",
5117: "Unsupported operation"
});

@@ -411,3 +409,4 @@

const ADAPTER_EVENTS = _objectSpread(_objectSpread({}, ADAPTER_STATUS), {}, {
ADAPTER_DATA_UPDATED: "adapter_data_updated"
ADAPTER_DATA_UPDATED: "adapter_data_updated",
CACHE_CLEAR: "cache_clear"
});

@@ -427,2 +426,3 @@ class BaseAdapter extends SafeEventEmitter {

_defineProperty(this, "chainConfig", null);
_defineProperty(this, "knownChainConfigs", {});
this.setAdapterSettings(options);

@@ -455,2 +455,3 @@ }

this.chainConfig = finalChainConfig;
this.addChainConfig(finalChainConfig);
}

@@ -480,2 +481,14 @@ }

}
checkAddChainRequirements() {
let init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
if (!init && !this.provider) throw WalletLoginError.notConnectedError("Not connected with wallet.");
}
checkSwitchChainRequirements(_ref) {
let {
chainId
} = _ref;
let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
if (!init && !this.provider) throw WalletLoginError.notConnectedError("Not connected with wallet.");
if (!this.knownChainConfigs[chainId]) throw WalletLoginError.chainConfigNotAdded("Invalid chainId");
}
updateAdapterData(data) {

@@ -488,2 +501,9 @@ this.adapterData = data;

}
addChainConfig(chainConfig) {
const currentConfig = this.knownChainConfigs[chainConfig.chainId];
this.knownChainConfigs[chainConfig.chainId] = _objectSpread(_objectSpread({}, currentConfig || {}), chainConfig);
}
getChainConfig(chainId) {
return this.knownChainConfigs[chainId] || null;
}
}

@@ -490,0 +510,0 @@ class BaseNetworkSwitch {}

@@ -27,2 +27,3 @@ import { OPENLOGIN_NETWORK_TYPE, OpenloginUserInfo } from "@toruslabs/openlogin";

readonly ADAPTER_DATA_UPDATED: "adapter_data_updated";
readonly CACHE_CLEAR: "cache_clear";
readonly NOT_READY: "not_ready";

@@ -62,2 +63,3 @@ readonly READY: "ready";

adapterData?: unknown;
addChain(chainConfig: CustomChainConfig): Promise<void>;
init(options?: AdapterInitOptions): Promise<void>;

@@ -70,2 +72,5 @@ disconnect(options?: {

setAdapterSettings(adapterSettings: BaseAdapterSettings): void;
switchChain(params: {
chainId: string;
}): Promise<void>;
authenticateUser(): Promise<UserAuthInfo>;

@@ -80,2 +85,3 @@ }

protected chainConfig: CustomChainConfig | null;
protected knownChainConfigs: Record<CustomChainConfig["chainId"], CustomChainConfig>;
abstract adapterNamespace: AdapterNamespaceType;

@@ -93,3 +99,9 @@ abstract currentChainNamespace: ChainNamespaceType;

checkDisconnectionRequirements(): void;
checkAddChainRequirements(init?: boolean): void;
checkSwitchChainRequirements({ chainId }: {
chainId: string;
}, init?: boolean): void;
updateAdapterData(data: unknown): void;
protected addChainConfig(chainConfig: CustomChainConfig): void;
protected getChainConfig(chainId: string): CustomChainConfig | null;
abstract init(options?: AdapterInitOptions): Promise<void>;

@@ -100,2 +112,6 @@ abstract connect(params?: T): Promise<SafeEventEmitterProvider | null>;

abstract authenticateUser(): Promise<UserAuthInfo>;
abstract addChain(chainConfig: CustomChainConfig): Promise<void>;
abstract switchChain(params: {
chainId: string;
}): Promise<void>;
}

@@ -102,0 +118,0 @@ export interface BaseAdapterConfig {

@@ -46,2 +46,4 @@ import { CustomError } from "ts-custom-error";

static mfaEnabled(extraMessage?: string): IWeb3AuthError;
static chainConfigNotAdded(extraMessage?: string): IWeb3AuthError;
static unsupportedOperation(extraMessage?: string): IWeb3AuthError;
}
{
"name": "@web3auth/base",
"version": "4.6.0",
"version": "5.0.0-alpha.0",
"homepage": "https://github.com/Web3Auth/Web3Auth#readme",

@@ -53,3 +53,3 @@ "license": "ISC",

},
"gitHead": "8ec9b078da6781b1225488bc45b41a10a15c8a0b"
"gitHead": "f8efd80b6c25a5c9af2057ed723ca9fb7f3f8e40"
}

@@ -37,2 +37,3 @@ import { OPENLOGIN_NETWORK, OPENLOGIN_NETWORK_TYPE, OpenloginUserInfo } from "@toruslabs/openlogin";

ADAPTER_DATA_UPDATED: "adapter_data_updated",
CACHE_CLEAR: "cache_clear",
} as const;

@@ -68,2 +69,3 @@ export type ADAPTER_STATUS_TYPE = (typeof ADAPTER_STATUS)[keyof typeof ADAPTER_STATUS];

adapterData?: unknown;
addChain(chainConfig: CustomChainConfig): Promise<void>;
init(options?: AdapterInitOptions): Promise<void>;

@@ -74,2 +76,3 @@ disconnect(options?: { cleanup: boolean }): Promise<void>;

setAdapterSettings(adapterSettings: BaseAdapterSettings): void;
switchChain(params: { chainId: string }): Promise<void>;
authenticateUser(): Promise<UserAuthInfo>;

@@ -93,2 +96,4 @@ }

protected knownChainConfigs: Record<CustomChainConfig["chainId"], CustomChainConfig> = {};
public abstract adapterNamespace: AdapterNamespaceType;

@@ -138,2 +143,3 @@

this.chainConfig = finalChainConfig;
this.addChainConfig(finalChainConfig);
}

@@ -173,2 +179,11 @@ }

checkAddChainRequirements(init = false): void {
if (!init && !this.provider) throw WalletLoginError.notConnectedError("Not connected with wallet.");
}
checkSwitchChainRequirements({ chainId }: { chainId: string }, init = false): void {
if (!init && !this.provider) throw WalletLoginError.notConnectedError("Not connected with wallet.");
if (!this.knownChainConfigs[chainId]) throw WalletLoginError.chainConfigNotAdded("Invalid chainId");
}
updateAdapterData(data: unknown): void {

@@ -179,2 +194,14 @@ this.adapterData = data;

protected addChainConfig(chainConfig: CustomChainConfig): void {
const currentConfig = this.knownChainConfigs[chainConfig.chainId];
this.knownChainConfigs[chainConfig.chainId] = {
...(currentConfig || {}),
...chainConfig,
};
}
protected getChainConfig(chainId: string): CustomChainConfig | null {
return this.knownChainConfigs[chainId] || null;
}
abstract init(options?: AdapterInitOptions): Promise<void>;

@@ -185,2 +212,4 @@ abstract connect(params?: T): Promise<SafeEventEmitterProvider | null>;

abstract authenticateUser(): Promise<UserAuthInfo>;
abstract addChain(chainConfig: CustomChainConfig): Promise<void>;
abstract switchChain(params: { chainId: string }): Promise<void>;
}

@@ -187,0 +216,0 @@

@@ -25,9 +25,9 @@ import { CHAIN_NAMESPACES, ChainNamespaceType, CustomChainConfig } from "./IChainInterface";

}
if (chainId === 3) {
if (chainId === 5) {
return {
chainNamespace,
chainId: "0x3",
rpcTarget: `https://rpc.ankr.com/eth_ropsten`,
displayName: "Ropsten Testnet",
blockExplorer: "https://ropsten.etherscan.io/",
chainId: "0x5",
rpcTarget: `https://rpc.ankr.com/eth_goerli`,
displayName: "Goerli Testnet",
blockExplorer: "https://goerli.etherscan.io/",
ticker: "ETH",

@@ -38,9 +38,9 @@ tickerName: "Ethereum",

}
if (chainId === 4) {
if (chainId === 11155111) {
return {
chainNamespace,
chainId: "0x4",
rpcTarget: `https://rpc.ankr.com/eth_rinkeby`,
displayName: "Rinkeby Testnet",
blockExplorer: "https://rinkeby.etherscan.io/",
chainId: "0xaa36a7",
rpcTarget: `https://rpc.ankr.com/eth_sepolia`,
displayName: "Sepolia Testnet",
blockExplorer: "https://sepolia.etherscan.io/",
ticker: "ETH",

@@ -51,14 +51,2 @@ tickerName: "Ethereum",

}
if (chainId === 5) {
return {
chainNamespace,
chainId: "0x5",
rpcTarget: `https://rpc.ankr.com/eth_goerli`,
displayName: "Goerli Testnet",
blockExplorer: "https://goerli.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum",
decimals: 18,
};
}
if (chainId === 137) {

@@ -65,0 +53,0 @@ return {

@@ -133,2 +133,4 @@ import { CustomError } from "ts-custom-error";

5115: "User has already enabled mfa, please use the @web3auth/web3auth-web sdk for login with mfa",
5116: "Chain config has not been added. Please add the chain config before calling switchChain",
5117: "Unsupported operation",
};

@@ -167,2 +169,10 @@

}
public static chainConfigNotAdded(extraMessage = ""): IWeb3AuthError {
return WalletLoginError.fromCode(5116, extraMessage);
}
public static unsupportedOperation(extraMessage = ""): IWeb3AuthError {
return WalletLoginError.fromCode(5117, extraMessage);
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc