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

@web3auth/base

Package Overview
Dependencies
Maintainers
1
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 0.0.1 to 0.1.0

dist/types/chain/config.d.ts

367

dist/base.cjs.js

@@ -115,5 +115,9 @@ module.exports =

// EXPORTS
__webpack_require__.d(__webpack_exports__, "BASE_ADAPTER_EVENTS", function() { return /* reexport */ BASE_ADAPTER_EVENTS; });
__webpack_require__.d(__webpack_exports__, "ADAPTER_CATEGORY", function() { return /* reexport */ ADAPTER_CATEGORY; });
__webpack_require__.d(__webpack_exports__, "ADAPTER_STATUS", function() { return /* reexport */ ADAPTER_STATUS; });
__webpack_require__.d(__webpack_exports__, "BaseAdapter", function() { return /* reexport */ IAdapter_BaseAdapter; });
__webpack_require__.d(__webpack_exports__, "DEFAULT_INFURA_ID", function() { return /* reexport */ DEFAULT_INFURA_ID; });
__webpack_require__.d(__webpack_exports__, "getEvmChainConfig", function() { return /* reexport */ getEvmChainConfig; });
__webpack_require__.d(__webpack_exports__, "getSolanaChainConfig", function() { return /* reexport */ getSolanaChainConfig; });
__webpack_require__.d(__webpack_exports__, "getChainConfig", function() { return /* reexport */ getChainConfig; });
__webpack_require__.d(__webpack_exports__, "CHAIN_NAMESPACES", function() { return /* reexport */ CHAIN_NAMESPACES; });

@@ -125,2 +129,3 @@ __webpack_require__.d(__webpack_exports__, "ADAPTER_NAMESPACES", function() { return /* reexport */ ADAPTER_NAMESPACES; });

__webpack_require__.d(__webpack_exports__, "PROVIDER_EVENTS", function() { return /* reexport */ PROVIDER_EVENTS; });
__webpack_require__.d(__webpack_exports__, "storageAvailable", function() { return /* reexport */ storageAvailable; });
__webpack_require__.d(__webpack_exports__, "MULTI_CHAIN_ADAPTERS", function() { return /* reexport */ MULTI_CHAIN_ADAPTERS; });

@@ -138,51 +143,2 @@ __webpack_require__.d(__webpack_exports__, "SOLANA_ADAPTERS", function() { return /* reexport */ SOLANA_ADAPTERS; });

// CONCATENATED MODULE: ./src/adapter/IAdapter.ts
const BASE_ADAPTER_EVENTS = {
READY: "ready",
CONNECTED: "connected",
DISCONNECTED: "disconnected",
CONNECTING: "connecting",
ERRORED: "errored"
};
const ADAPTER_CATEGORY = {
EXTERNAL: "external",
IN_APP: "in_app"
};
class IAdapter_BaseAdapter extends openlogin_jrpc_["SafeEventEmitter"] {
constructor() {
super(...arguments);
defineProperty_default()(this, "namespace", void 0);
defineProperty_default()(this, "currentChainNamespace", void 0);
defineProperty_default()(this, "type", void 0);
defineProperty_default()(this, "connecting", void 0);
defineProperty_default()(this, "ready", void 0);
defineProperty_default()(this, "connected", void 0);
defineProperty_default()(this, "provider", void 0);
}
}
// CONCATENATED MODULE: ./src/chain/IChainInterface.ts
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { defineProperty_default()(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
const CHAIN_NAMESPACES = {
EIP155: "eip155",
SOLANA: "solana"
}; // eip155 for all evm chains
const ADAPTER_NAMESPACES = _objectSpread(_objectSpread({}, CHAIN_NAMESPACES), {}, {
MULTICHAIN: "multichain"
}); // eip155 for all evm chains
// EXTERNAL MODULE: external "ts-custom-error"

@@ -237,3 +193,3 @@ var external_ts_custom_error_ = __webpack_require__(2);

let extraMessage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
return new WalletInitializationError(code, "".concat(WalletInitializationError.messages[code]).concat(extraMessage));
return new WalletInitializationError(code, "".concat(WalletInitializationError.messages[code], ", ").concat(extraMessage));
} // Custom methods

@@ -277,5 +233,5 @@

static rpcConnectionError() {
static invalidProviderConfigError() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletInitializationError.fromCode(5012, extraMessage);
return WalletInitializationError.fromCode(5008, extraMessage);
}

@@ -285,10 +241,20 @@

let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletInitializationError.fromCode(5013, extraMessage);
return WalletInitializationError.fromCode(5009, extraMessage);
}
static invalidProviderConfigError() {
static rpcConnectionError() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletInitializationError.fromCode(5008, extraMessage);
return WalletInitializationError.fromCode(5010, extraMessage);
}
static invalidParams() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletInitializationError.fromCode(5011, extraMessage);
}
static invalidNetwork() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletInitializationError.fromCode(5013, extraMessage);
}
}

@@ -310,3 +276,5 @@ /**

5009: "Provider is not ready yet",
5010: "Failed to connect with rpc url"
5010: "Failed to connect with rpc url",
5011: "Invalid params passed in",
5013: "Invalid network provided"
});

@@ -331,3 +299,3 @@

let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletLoginError.fromCode(5009, extraMessage);
return WalletLoginError.fromCode(5111, extraMessage);
}

@@ -337,3 +305,3 @@

let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletLoginError.fromCode(5010, extraMessage);
return WalletLoginError.fromCode(5112, extraMessage);
}

@@ -343,3 +311,3 @@

let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletLoginError.fromCode(5011, extraMessage);
return WalletLoginError.fromCode(5113, extraMessage);
}

@@ -351,6 +319,248 @@

5000: "Custom",
5011: "Failed to connect with wallet",
5012: "Failed to disconnect from wallet",
5013: "Wallet is not connected"
5111: "Failed to connect with wallet",
5112: "Failed to disconnect from wallet",
5113: "Wallet is not connected"
});
// CONCATENATED MODULE: ./src/adapter/IAdapter.ts
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { defineProperty_default()(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
const ADAPTER_CATEGORY = {
EXTERNAL: "external",
IN_APP: "in_app"
};
const ADAPTER_STATUS = {
NOT_READY: "not_ready",
READY: "ready",
CONNECTING: "connecting",
CONNECTED: "connected",
DISCONNECTED: "disconnected",
ERRORED: "errored"
};
class IAdapter_BaseAdapter extends openlogin_jrpc_["SafeEventEmitter"] {
constructor() {
super(...arguments);
defineProperty_default()(this, "adapterData", {});
defineProperty_default()(this, "chainConfig", void 0);
defineProperty_default()(this, "adapterNamespace", void 0);
defineProperty_default()(this, "currentChainNamespace", void 0);
defineProperty_default()(this, "type", void 0);
defineProperty_default()(this, "name", void 0);
defineProperty_default()(this, "status", void 0);
defineProperty_default()(this, "provider", void 0);
}
get chainConfigProxy() {
return this.chainConfig ? _objectSpread({}, this.chainConfig) : undefined;
}
setChainConfig(customChainConfig) {
if (this.status === ADAPTER_STATUS.READY) return;
if (!customChainConfig.chainNamespace) throw WalletInitializationError.notReady("ChainNamespace is required while setting chainConfig");
const defaultChainConfig = getChainConfig(this.currentChainNamespace, customChainConfig.chainId);
this.chainConfig = _objectSpread(_objectSpread({}, defaultChainConfig), customChainConfig);
}
checkConnectionRequirements() {
if (this.status === ADAPTER_STATUS.CONNECTING) throw WalletLoginError.connectionError("Already pending connection");
if (this.status === ADAPTER_STATUS.CONNECTED) throw WalletLoginError.connectionError("Already connected");
if (this.status !== ADAPTER_STATUS.READY) throw WalletLoginError.connectionError("Wallet adapter is not ready yet");
}
checkInitializationRequirements() {
if (this.status === ADAPTER_STATUS.NOT_READY) return;
if (this.status === ADAPTER_STATUS.CONNECTING) throw WalletInitializationError.notReady("Already pending connection");
if (this.status === ADAPTER_STATUS.CONNECTED) throw WalletInitializationError.notReady("Already connected");
if (this.status === ADAPTER_STATUS.READY) throw WalletInitializationError.notReady("Adapter is already initialized");
}
}
// CONCATENATED MODULE: ./src/chain/IChainInterface.ts
function IChainInterface_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function IChainInterface_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? IChainInterface_ownKeys(Object(source), !0).forEach(function (key) { defineProperty_default()(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : IChainInterface_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
const CHAIN_NAMESPACES = {
EIP155: "eip155",
SOLANA: "solana"
}; // eip155 for all evm chains
const ADAPTER_NAMESPACES = IChainInterface_objectSpread(IChainInterface_objectSpread({}, CHAIN_NAMESPACES), {}, {
MULTICHAIN: "multichain"
}); // eip155 for all evm chains
// CONCATENATED MODULE: ./src/chain/config.ts
const DEFAULT_INFURA_ID = "776218ac4734478c90191dde8cae483c";
const getDefaultNetworkId = chainNamespace => {
if (chainNamespace === CHAIN_NAMESPACES.EIP155) {
return 1;
} else if (chainNamespace === CHAIN_NAMESPACES.SOLANA) {
return 1;
}
throw new Error("Chain namespace ".concat(chainNamespace, " is not supported"));
};
const getEvmChainConfig = chainId => {
const chainNamespace = CHAIN_NAMESPACES.EIP155;
if (chainId === 1) {
return {
chainNamespace,
chainId: "0x1",
rpcTarget: "https://mainnet.infura.io/v3/".concat(DEFAULT_INFURA_ID),
displayName: "Ethereum Mainnet",
blockExplorer: "https://etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum"
};
} else if (chainId === 3) {
return {
chainNamespace,
chainId: "0x3",
rpcTarget: "https://ropsten.infura.io/v3/".concat(DEFAULT_INFURA_ID),
displayName: "ropsten",
blockExplorer: "https://ropsten.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum"
};
} else if (chainId === 4) {
return {
chainNamespace,
chainId: "0x4",
rpcTarget: "https://rinkeby.infura.io/v3/".concat(DEFAULT_INFURA_ID),
displayName: "rinkeby",
blockExplorer: "https://rinkeby.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum"
};
} else if (chainId === 5) {
return {
chainNamespace,
chainId: "0x5",
rpcTarget: "https://goerli.infura.io/v3/".concat(DEFAULT_INFURA_ID),
displayName: "goerli",
blockExplorer: "https://goerli.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum"
};
} else if (chainId === 42) {
return {
chainNamespace,
chainId: "0x2a",
rpcTarget: "https://kovan.infura.io/v3/".concat(DEFAULT_INFURA_ID),
displayName: "kovan",
blockExplorer: "https://kovan.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum"
};
} else if (chainId === 137) {
return {
chainNamespace,
rpcTarget: "https://polygon-rpc.com",
blockExplorer: "https://polygonscan.com",
chainId: "0x89",
displayName: "Polygon Mainnet",
ticker: "matic",
tickerName: "matic"
};
} else if (chainId === 80001) {
return {
chainNamespace,
rpcTarget: "https://rpc-mumbai.maticvigil.com",
blockExplorer: "https://mumbai-explorer.matic.today",
chainId: "0x13881",
displayName: "Polygon Mumbai Testnet",
ticker: "matic",
tickerName: "matic"
};
} else if (chainId === 56) {
return {
chainNamespace,
rpcTarget: "https://bsc-dataseed.binance.org",
blockExplorer: "https://bscscan.com",
chainId: "0x38",
displayName: "Binance SmartChain Mainnet",
ticker: "BNB",
tickerName: "BNB"
};
} else if (chainId === 97) {
return {
chainNamespace,
rpcTarget: "https://data-seed-prebsc-2-s3.binance.org:8545",
blockExplorer: "https://testnet.bscscan.com",
chainId: "0x61",
displayName: "Binance SmartChain Testnet",
ticker: "BNB",
tickerName: "BNB"
};
}
return null;
};
const getSolanaChainConfig = chainId => {
const chainNamespace = CHAIN_NAMESPACES.SOLANA;
if (chainId === 1) {
return {
chainNamespace,
blockExplorer: "https://explorer.solana.com",
chainId: "0x1",
displayName: "Solana Mainnet",
rpcTarget: "https://api.mainnet-beta.solana.com",
ticker: "SOL",
tickerName: "Solana Token"
};
} else if (chainId === 2) {
return {
rpcTarget: "https://api.testnet.solana.com",
blockExplorer: "https://explorer.solana.com?cluster=testnet",
chainId: "0x2",
chainNamespace,
displayName: "testnet",
ticker: "SOL",
tickerName: "solana"
};
} else if (chainId === 3) {
return {
rpcTarget: "https://api.devnet.solana.com",
blockExplorer: "https://explorer.solana.com?cluster=devnet",
chainId: "0x3",
chainNamespace,
displayName: "devnet",
ticker: "SOL",
tickerName: "solana"
};
}
return null;
};
const getChainConfig = (chainNamespace, chainId) => {
const finalChainId = chainId ? typeof chainId === "number" ? chainId : parseInt(chainId, 16) : getDefaultNetworkId(chainNamespace);
if (chainNamespace === CHAIN_NAMESPACES.EIP155) {
return getEvmChainConfig(finalChainId);
} else if (chainNamespace === CHAIN_NAMESPACES.SOLANA) {
return getSolanaChainConfig(finalChainId);
}
return undefined;
};
// CONCATENATED MODULE: ./src/provider/IProvider.ts

@@ -361,2 +571,27 @@ const PROVIDER_EVENTS = {

};
// CONCATENATED MODULE: ./src/utils.ts
function storageAvailable(type) {
let storageExists = false;
let storageLength = 0;
let storage;
try {
storage = window[type];
storageExists = true;
storageLength = storage.length;
const x = "__storage_test__";
storage.setItem(x, x);
storage.removeItem(x);
return true;
} catch (error) {
const _error = error;
return !!(_error && ( // everything except Firefox
_error.code === 22 || // Firefox
_error.code === 1014 || // test name field too, because code might not be present
// everything except Firefox
_error.name === "QuotaExceededError" || // Firefox
_error.name === "NS_ERROR_DOM_QUOTA_REACHED") && // acknowledge QuotaExceededError only if there's something already stored
storageExists && storageLength !== 0);
}
}
// CONCATENATED MODULE: ./src/wallet/index.ts

@@ -371,3 +606,5 @@

OPENLOGIN: "openlogin",
CUSTOM_AUTH: "custom-auth"
CUSTOM_AUTH: "custom-auth",
WALLET_CONNECT_V1: "wallet-connect-v1",
WALLET_CONNECT_V2: "wallet-connect-v2"
};

@@ -390,4 +627,6 @@ const SOLANA_ADAPTERS = wallet_objectSpread({

/***/ })
/******/ ]);
//# sourceMappingURL=base.cjs.js.map

@@ -0,30 +1,5 @@

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { SafeEventEmitter } from '@toruslabs/openlogin-jrpc';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { CustomError } from 'ts-custom-error';
const BASE_ADAPTER_EVENTS = {
READY: "ready",
CONNECTED: "connected",
DISCONNECTED: "disconnected",
CONNECTING: "connecting",
ERRORED: "errored"
};
const ADAPTER_CATEGORY = {
EXTERNAL: "external",
IN_APP: "in_app"
};
class BaseAdapter extends SafeEventEmitter {}
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
const CHAIN_NAMESPACES = {
EIP155: "eip155",
SOLANA: "solana"
};
const ADAPTER_NAMESPACES = _objectSpread$1(_objectSpread$1({}, CHAIN_NAMESPACES), {}, {
MULTICHAIN: "multichain"
});
class Web3AuthError extends CustomError {

@@ -72,3 +47,3 @@ constructor(code, message) {

let extraMessage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
return new WalletInitializationError(code, "".concat(WalletInitializationError.messages[code]).concat(extraMessage));
return new WalletInitializationError(code, "".concat(WalletInitializationError.messages[code], ", ").concat(extraMessage));
} // Custom methods

@@ -112,5 +87,5 @@

static rpcConnectionError() {
static invalidProviderConfigError() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletInitializationError.fromCode(5012, extraMessage);
return WalletInitializationError.fromCode(5008, extraMessage);
}

@@ -120,10 +95,20 @@

let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletInitializationError.fromCode(5013, extraMessage);
return WalletInitializationError.fromCode(5009, extraMessage);
}
static invalidProviderConfigError() {
static rpcConnectionError() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletInitializationError.fromCode(5008, extraMessage);
return WalletInitializationError.fromCode(5010, extraMessage);
}
static invalidParams() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletInitializationError.fromCode(5011, extraMessage);
}
static invalidNetwork() {
let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletInitializationError.fromCode(5013, extraMessage);
}
}

@@ -145,3 +130,5 @@ /**

5009: "Provider is not ready yet",
5010: "Failed to connect with rpc url"
5010: "Failed to connect with rpc url",
5011: "Invalid params passed in",
5013: "Invalid network provided"
});

@@ -166,3 +153,3 @@

let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletLoginError.fromCode(5009, extraMessage);
return WalletLoginError.fromCode(5111, extraMessage);
}

@@ -172,3 +159,3 @@

let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletLoginError.fromCode(5010, extraMessage);
return WalletLoginError.fromCode(5112, extraMessage);
}

@@ -178,3 +165,3 @@

let extraMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
return WalletLoginError.fromCode(5011, extraMessage);
return WalletLoginError.fromCode(5113, extraMessage);
}

@@ -186,7 +173,227 @@

5000: "Custom",
5011: "Failed to connect with wallet",
5012: "Failed to disconnect from wallet",
5013: "Wallet is not connected"
5111: "Failed to connect with wallet",
5112: "Failed to disconnect from wallet",
5113: "Wallet is not connected"
});
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
const ADAPTER_CATEGORY = {
EXTERNAL: "external",
IN_APP: "in_app"
};
const ADAPTER_STATUS = {
NOT_READY: "not_ready",
READY: "ready",
CONNECTING: "connecting",
CONNECTED: "connected",
DISCONNECTED: "disconnected",
ERRORED: "errored"
};
class BaseAdapter extends SafeEventEmitter {
constructor() {
super(...arguments);
_defineProperty(this, "adapterData", {});
_defineProperty(this, "chainConfig", void 0);
}
get chainConfigProxy() {
return this.chainConfig ? _objectSpread$2({}, this.chainConfig) : undefined;
}
setChainConfig(customChainConfig) {
if (this.status === ADAPTER_STATUS.READY) return;
if (!customChainConfig.chainNamespace) throw WalletInitializationError.notReady("ChainNamespace is required while setting chainConfig");
const defaultChainConfig = getChainConfig(this.currentChainNamespace, customChainConfig.chainId);
this.chainConfig = _objectSpread$2(_objectSpread$2({}, defaultChainConfig), customChainConfig);
}
checkConnectionRequirements() {
if (this.status === ADAPTER_STATUS.CONNECTING) throw WalletLoginError.connectionError("Already pending connection");
if (this.status === ADAPTER_STATUS.CONNECTED) throw WalletLoginError.connectionError("Already connected");
if (this.status !== ADAPTER_STATUS.READY) throw WalletLoginError.connectionError("Wallet adapter is not ready yet");
}
checkInitializationRequirements() {
if (this.status === ADAPTER_STATUS.NOT_READY) return;
if (this.status === ADAPTER_STATUS.CONNECTING) throw WalletInitializationError.notReady("Already pending connection");
if (this.status === ADAPTER_STATUS.CONNECTED) throw WalletInitializationError.notReady("Already connected");
if (this.status === ADAPTER_STATUS.READY) throw WalletInitializationError.notReady("Adapter is already initialized");
}
}
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
const CHAIN_NAMESPACES = {
EIP155: "eip155",
SOLANA: "solana"
};
const ADAPTER_NAMESPACES = _objectSpread$1(_objectSpread$1({}, CHAIN_NAMESPACES), {}, {
MULTICHAIN: "multichain"
});
const DEFAULT_INFURA_ID = "776218ac4734478c90191dde8cae483c";
const getDefaultNetworkId = chainNamespace => {
if (chainNamespace === CHAIN_NAMESPACES.EIP155) {
return 1;
} else if (chainNamespace === CHAIN_NAMESPACES.SOLANA) {
return 1;
}
throw new Error("Chain namespace ".concat(chainNamespace, " is not supported"));
};
const getEvmChainConfig = chainId => {
const chainNamespace = CHAIN_NAMESPACES.EIP155;
if (chainId === 1) {
return {
chainNamespace,
chainId: "0x1",
rpcTarget: "https://mainnet.infura.io/v3/".concat(DEFAULT_INFURA_ID),
displayName: "Ethereum Mainnet",
blockExplorer: "https://etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum"
};
} else if (chainId === 3) {
return {
chainNamespace,
chainId: "0x3",
rpcTarget: "https://ropsten.infura.io/v3/".concat(DEFAULT_INFURA_ID),
displayName: "ropsten",
blockExplorer: "https://ropsten.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum"
};
} else if (chainId === 4) {
return {
chainNamespace,
chainId: "0x4",
rpcTarget: "https://rinkeby.infura.io/v3/".concat(DEFAULT_INFURA_ID),
displayName: "rinkeby",
blockExplorer: "https://rinkeby.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum"
};
} else if (chainId === 5) {
return {
chainNamespace,
chainId: "0x5",
rpcTarget: "https://goerli.infura.io/v3/".concat(DEFAULT_INFURA_ID),
displayName: "goerli",
blockExplorer: "https://goerli.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum"
};
} else if (chainId === 42) {
return {
chainNamespace,
chainId: "0x2a",
rpcTarget: "https://kovan.infura.io/v3/".concat(DEFAULT_INFURA_ID),
displayName: "kovan",
blockExplorer: "https://kovan.etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum"
};
} else if (chainId === 137) {
return {
chainNamespace,
rpcTarget: "https://polygon-rpc.com",
blockExplorer: "https://polygonscan.com",
chainId: "0x89",
displayName: "Polygon Mainnet",
ticker: "matic",
tickerName: "matic"
};
} else if (chainId === 80001) {
return {
chainNamespace,
rpcTarget: "https://rpc-mumbai.maticvigil.com",
blockExplorer: "https://mumbai-explorer.matic.today",
chainId: "0x13881",
displayName: "Polygon Mumbai Testnet",
ticker: "matic",
tickerName: "matic"
};
} else if (chainId === 56) {
return {
chainNamespace,
rpcTarget: "https://bsc-dataseed.binance.org",
blockExplorer: "https://bscscan.com",
chainId: "0x38",
displayName: "Binance SmartChain Mainnet",
ticker: "BNB",
tickerName: "BNB"
};
} else if (chainId === 97) {
return {
chainNamespace,
rpcTarget: "https://data-seed-prebsc-2-s3.binance.org:8545",
blockExplorer: "https://testnet.bscscan.com",
chainId: "0x61",
displayName: "Binance SmartChain Testnet",
ticker: "BNB",
tickerName: "BNB"
};
}
return null;
};
const getSolanaChainConfig = chainId => {
const chainNamespace = CHAIN_NAMESPACES.SOLANA;
if (chainId === 1) {
return {
chainNamespace,
blockExplorer: "https://explorer.solana.com",
chainId: "0x1",
displayName: "Solana Mainnet",
rpcTarget: "https://api.mainnet-beta.solana.com",
ticker: "SOL",
tickerName: "Solana Token"
};
} else if (chainId === 2) {
return {
rpcTarget: "https://api.testnet.solana.com",
blockExplorer: "https://explorer.solana.com?cluster=testnet",
chainId: "0x2",
chainNamespace,
displayName: "testnet",
ticker: "SOL",
tickerName: "solana"
};
} else if (chainId === 3) {
return {
rpcTarget: "https://api.devnet.solana.com",
blockExplorer: "https://explorer.solana.com?cluster=devnet",
chainId: "0x3",
chainNamespace,
displayName: "devnet",
ticker: "SOL",
tickerName: "solana"
};
}
return null;
};
const getChainConfig = (chainNamespace, chainId) => {
const finalChainId = chainId ? typeof chainId === "number" ? chainId : parseInt(chainId, 16) : getDefaultNetworkId(chainNamespace);
if (chainNamespace === CHAIN_NAMESPACES.EIP155) {
return getEvmChainConfig(finalChainId);
} else if (chainNamespace === CHAIN_NAMESPACES.SOLANA) {
return getSolanaChainConfig(finalChainId);
}
return undefined;
};
const PROVIDER_EVENTS = {

@@ -197,2 +404,27 @@ INITIALIZED: "initialized",

function storageAvailable(type) {
let storageExists = false;
let storageLength = 0;
let storage;
try {
storage = window[type];
storageExists = true;
storageLength = storage.length;
const x = "__storage_test__";
storage.setItem(x, x);
storage.removeItem(x);
return true;
} catch (error) {
const _error = error;
return !!(_error && ( // everything except Firefox
_error.code === 22 || // Firefox
_error.code === 1014 || // test name field too, because code might not be present
// everything except Firefox
_error.name === "QuotaExceededError" || // Firefox
_error.name === "NS_ERROR_DOM_QUOTA_REACHED") && // acknowledge QuotaExceededError only if there's something already stored
storageExists && storageLength !== 0);
}
}
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

@@ -204,3 +436,5 @@

OPENLOGIN: "openlogin",
CUSTOM_AUTH: "custom-auth"
CUSTOM_AUTH: "custom-auth",
WALLET_CONNECT_V1: "wallet-connect-v1",
WALLET_CONNECT_V2: "wallet-connect-v2"
};

@@ -217,3 +451,3 @@ const SOLANA_ADAPTERS = _objectSpread({

export { ADAPTER_CATEGORY, ADAPTER_NAMESPACES, BASE_ADAPTER_EVENTS, BaseAdapter, CHAIN_NAMESPACES, EVM_ADAPTERS, MULTI_CHAIN_ADAPTERS, PROVIDER_EVENTS, SOLANA_ADAPTERS, WALLET_ADAPTERS, WalletInitializationError, WalletLoginError, Web3AuthError };
export { ADAPTER_CATEGORY, ADAPTER_NAMESPACES, ADAPTER_STATUS, BaseAdapter, CHAIN_NAMESPACES, DEFAULT_INFURA_ID, EVM_ADAPTERS, MULTI_CHAIN_ADAPTERS, PROVIDER_EVENTS, SOLANA_ADAPTERS, WALLET_ADAPTERS, WalletInitializationError, WalletLoginError, Web3AuthError, getChainConfig, getEvmChainConfig, getSolanaChainConfig, storageAvailable };
//# sourceMappingURL=base.esm.js.map

106

dist/types/adapter/IAdapter.d.ts
import { SafeEventEmitter } from "@toruslabs/openlogin-jrpc";
import { AdapterNamespaceType, ChainNamespaceType } from "../chain/IChainInterface";
import { AdapterNamespaceType, ChainNamespaceType, CustomChainConfig } from "../chain/IChainInterface";
import { SafeEventEmitterProvider } from "../provider/IProvider";
export declare const BASE_ADAPTER_EVENTS: {
READY: string;
CONNECTED: string;
DISCONNECTED: string;
CONNECTING: string;
ERRORED: string;
};
export declare type UserInfo = {

@@ -44,3 +37,3 @@ /**

export declare type ADAPTER_CATEGORY_TYPE = typeof ADAPTER_CATEGORY[keyof typeof ADAPTER_CATEGORY];
interface AdapterInitOptions {
export interface AdapterInitOptions {
/**

@@ -51,33 +44,96 @@ * Whether to auto connect to the adapter based on redirect mode or saved adapters

}
export declare const ADAPTER_STATUS: {
readonly NOT_READY: "not_ready";
readonly READY: "ready";
readonly CONNECTING: "connecting";
readonly CONNECTED: "connected";
readonly DISCONNECTED: "disconnected";
readonly ERRORED: "errored";
};
export declare type ADAPTER_STATUS_TYPE = typeof ADAPTER_STATUS[keyof typeof ADAPTER_STATUS];
export declare type CONNECTED_EVENT_DATA = {
adapter: string;
reconnected: boolean;
};
export interface IAdapter<T> extends SafeEventEmitter {
namespace: AdapterNamespaceType;
adapterNamespace: AdapterNamespaceType;
currentChainNamespace: ChainNamespaceType;
chainConfigProxy: CustomChainConfig | undefined;
type: ADAPTER_CATEGORY_TYPE;
ready: boolean;
connecting: boolean;
connected: boolean;
provider: SafeEventEmitterProvider;
name: string;
status: ADAPTER_STATUS_TYPE;
provider: SafeEventEmitterProvider | null;
adapterData?: unknown;
init(options?: AdapterInitOptions): Promise<void>;
connect(params?: T): Promise<SafeEventEmitterProvider | null>;
connect(params?: T): Promise<SafeEventEmitterProvider | void>;
disconnect(): Promise<void>;
getUserInfo(): Promise<Partial<UserInfo> | null>;
getUserInfo(): Promise<Partial<UserInfo>>;
setChainConfig(customChainConfig: CustomChainConfig): void;
setAdapterSettings(adapterSettings: unknown): void;
}
export declare abstract class BaseAdapter<T> extends SafeEventEmitter implements IAdapter<T> {
abstract namespace: AdapterNamespaceType;
adapterData?: unknown;
protected chainConfig: CustomChainConfig | undefined;
abstract adapterNamespace: AdapterNamespaceType;
abstract currentChainNamespace: ChainNamespaceType;
abstract type: ADAPTER_CATEGORY_TYPE;
abstract connecting: boolean;
abstract ready: boolean;
abstract connected: boolean;
abstract provider: SafeEventEmitterProvider;
abstract name: string;
abstract status: ADAPTER_STATUS_TYPE;
abstract provider: SafeEventEmitterProvider | null;
get chainConfigProxy(): CustomChainConfig | undefined;
setChainConfig(customChainConfig: CustomChainConfig): void;
checkConnectionRequirements(): void;
checkInitializationRequirements(): void;
abstract init(options?: AdapterInitOptions): Promise<void>;
abstract connect(params?: T): Promise<SafeEventEmitterProvider | null>;
abstract connect(params?: T): Promise<SafeEventEmitterProvider | void>;
abstract disconnect(): Promise<void>;
abstract getUserInfo(): Promise<Partial<UserInfo> | null>;
abstract getUserInfo(): Promise<Partial<UserInfo>>;
abstract setAdapterSettings(adapterSettings: unknown): void;
}
export interface BaseAdapterConfig {
visible?: boolean;
label: string;
showOnModal?: boolean;
showOnMobile?: boolean;
showOnDesktop?: boolean;
}
export {};
export declare type LoginMethodConfig = Record<string, {
/**
* Display Name. If not provided, we use the default for openlogin app
*/
name: string;
/**
* Description for button. If provided, it renders as a full length button. else, icon button
*/
description?: string;
/**
* Logo to be shown on mouse hover. If not provided, we use the default for openlogin app
*/
logoHover?: string;
/**
* Logo to be shown on dark background (dark theme). If not provided, we use the default for openlogin app
*/
logoLight?: string;
/**
* Logo to be shown on light background (light theme). If not provided, we use the default for openlogin app
*/
logoDark?: string;
/**
* Show login button on the main list
*/
mainOption?: boolean;
/**
* Whether to show the login button on modal or not
*/
showOnModal?: boolean;
/**
* Whether to show the login button on desktop
*/
showOnDesktop?: boolean;
/**
* Whether to show the login button on mobile
*/
showOnMobile?: boolean;
}>;
export interface WalletConnectV1Data {
uri: string;
}

@@ -29,3 +29,3 @@ export declare const CHAIN_NAMESPACES: {

*/
blockExplorer?: string;
blockExplorer: string;
/**

@@ -32,0 +32,0 @@ * Default currency ticker of the network (e.g: ETH)

@@ -28,5 +28,7 @@ import { CustomError } from "ts-custom-error";

static duplicateAdapterError(extraMessage?: string): IWeb3AuthError;
static invalidProviderConfigError(extraMessage?: string): IWeb3AuthError;
static providerNotReadyError(extraMessage?: string): IWeb3AuthError;
static rpcConnectionError(extraMessage?: string): IWeb3AuthError;
static providerNotReadyError(extraMessage?: string): IWeb3AuthError;
static invalidProviderConfigError(extraMessage?: string): IWeb3AuthError;
static invalidParams(extraMessage?: string): IWeb3AuthError;
static invalidNetwork(extraMessage?: string): IWeb3AuthError;
}

@@ -33,0 +35,0 @@ /**

export * from "./adapter/IAdapter";
export * from "./chain/config";
export * from "./chain/IChainInterface";
export * from "./errors";
export * from "./provider/IProvider";
export * from "./utils";
export * from "./wallet";

@@ -7,7 +7,7 @@ import { JRPCRequest, SafeEventEmitter } from "@toruslabs/openlogin-jrpc";

}
export declare type Maybe<T> = Partial<T> | null | undefined;
export declare type Maybe<T> = T | Partial<T> | null | undefined;
export interface SafeEventEmitterProvider extends SafeEventEmitter {
sendAsync: <T, U>(req: JRPCRequest<T>) => Promise<U>;
send: <T, U>(req: JRPCRequest<T>, callback: SendCallBack<U>) => void;
request?: <T>(args: RequestArguments) => Promise<Maybe<T>>;
request: <T>(args: RequestArguments) => Promise<Maybe<T>>;
}

@@ -14,0 +14,0 @@ export declare const PROVIDER_EVENTS: {

export declare const MULTI_CHAIN_ADAPTERS: {
OPENLOGIN: string;
CUSTOM_AUTH: string;
WALLET_CONNECT_V1: string;
WALLET_CONNECT_V2: string;
};

@@ -8,2 +10,4 @@ export declare const SOLANA_ADAPTERS: {

CUSTOM_AUTH: string;
WALLET_CONNECT_V1: string;
WALLET_CONNECT_V2: string;
TORUS_SOLANA: string;

@@ -15,2 +19,4 @@ PHANTOM: string;

CUSTOM_AUTH: string;
WALLET_CONNECT_V1: string;
WALLET_CONNECT_V2: string;
TORUS_EVM: string;

@@ -22,2 +28,4 @@ METAMASK: string;

CUSTOM_AUTH: string;
WALLET_CONNECT_V1: string;
WALLET_CONNECT_V2: string;
TORUS_SOLANA: string;

@@ -24,0 +32,0 @@ PHANTOM: string;

{
"name": "@web3auth/base",
"version": "0.0.1",
"version": "0.1.0",
"homepage": "https://github.com/Web3Auth/Web3Auth#readme",

@@ -16,4 +16,4 @@ "license": "ISC",

"test-debugger": "mocha --config ../../.mocharc.json --inspect-brk test/**.ts",
"dev": "cross-env NODE_ENV=development torus-scripts build",
"build": "cross-env NODE_ENV=production torus-scripts build",
"dev": "rimraf dist/ && cross-env NODE_ENV=development torus-scripts build",
"build": "rimraf dist/ && cross-env NODE_ENV=production torus-scripts build",
"lint": "eslint --fix 'src/**/*.ts'",

@@ -28,4 +28,4 @@ "prepack": "yarn run build",

"devDependencies": {
"@types/node": "^14.17.20",
"lint-staged": "^12.1.4"
"@types/node": "^14",
"lint-staged": "^12.1.7"
},

@@ -56,3 +56,3 @@ "peerDependencies": {

},
"gitHead": "7c4ce82770739ff686b9f4b886ff65be145b35a7"
"gitHead": "39c2430248258f030cd9274154617c04e67f91e5"
}
import { SafeEventEmitter } from "@toruslabs/openlogin-jrpc";
import { AdapterNamespaceType, ChainNamespaceType } from "../chain/IChainInterface";
import { getChainConfig } from "..";
import { AdapterNamespaceType, ChainNamespaceType, CustomChainConfig } from "../chain/IChainInterface";
import { WalletInitializationError, WalletLoginError } from "../errors";
import { SafeEventEmitterProvider } from "../provider/IProvider";
export const BASE_ADAPTER_EVENTS = {
READY: "ready",
CONNECTED: "connected",
DISCONNECTED: "disconnected",
CONNECTING: "connecting",
ERRORED: "errored",
};
export type UserInfo = {

@@ -47,6 +41,5 @@ /**

} as const;
export type ADAPTER_CATEGORY_TYPE = typeof ADAPTER_CATEGORY[keyof typeof ADAPTER_CATEGORY];
interface AdapterInitOptions {
export interface AdapterInitOptions {
/**

@@ -58,19 +51,42 @@ * Whether to auto connect to the adapter based on redirect mode or saved adapters

export const ADAPTER_STATUS = {
NOT_READY: "not_ready",
READY: "ready",
CONNECTING: "connecting",
CONNECTED: "connected",
DISCONNECTED: "disconnected",
ERRORED: "errored",
} as const;
export type ADAPTER_STATUS_TYPE = typeof ADAPTER_STATUS[keyof typeof ADAPTER_STATUS];
export type CONNECTED_EVENT_DATA = {
adapter: string;
reconnected: boolean;
};
export interface IAdapter<T> extends SafeEventEmitter {
namespace: AdapterNamespaceType;
adapterNamespace: AdapterNamespaceType;
currentChainNamespace: ChainNamespaceType;
chainConfigProxy: CustomChainConfig | undefined;
type: ADAPTER_CATEGORY_TYPE;
ready: boolean;
connecting: boolean;
connected: boolean;
provider: SafeEventEmitterProvider;
name: string;
status: ADAPTER_STATUS_TYPE;
provider: SafeEventEmitterProvider | null;
adapterData?: unknown;
init(options?: AdapterInitOptions): Promise<void>;
connect(params?: T): Promise<SafeEventEmitterProvider | null>;
connect(params?: T): Promise<SafeEventEmitterProvider | void>;
disconnect(): Promise<void>;
getUserInfo(): Promise<Partial<UserInfo> | null>;
getUserInfo(): Promise<Partial<UserInfo>>;
setChainConfig(customChainConfig: CustomChainConfig): void;
setAdapterSettings(adapterSettings: unknown): void;
}
export abstract class BaseAdapter<T> extends SafeEventEmitter implements IAdapter<T> {
public abstract namespace: AdapterNamespaceType;
public adapterData?: unknown = {};
// should be added in constructor or from setChainConfig function
// before calling init function.
protected chainConfig: CustomChainConfig | undefined;
public abstract adapterNamespace: AdapterNamespaceType;
public abstract currentChainNamespace: ChainNamespaceType;

@@ -80,20 +96,91 @@

public abstract connecting: boolean;
public abstract name: string;
public abstract ready: boolean;
public abstract status: ADAPTER_STATUS_TYPE;
public abstract connected: boolean;
public abstract provider: SafeEventEmitterProvider | null;
public abstract provider: SafeEventEmitterProvider;
get chainConfigProxy(): CustomChainConfig | undefined {
return this.chainConfig ? { ...this.chainConfig } : undefined;
}
setChainConfig(customChainConfig: CustomChainConfig): void {
if (this.status === ADAPTER_STATUS.READY) return;
if (!customChainConfig.chainNamespace) throw WalletInitializationError.notReady("ChainNamespace is required while setting chainConfig");
const defaultChainConfig = getChainConfig(this.currentChainNamespace, customChainConfig.chainId);
this.chainConfig = { ...defaultChainConfig, ...customChainConfig };
}
checkConnectionRequirements(): void {
if (this.status === ADAPTER_STATUS.CONNECTING) throw WalletLoginError.connectionError("Already pending connection");
if (this.status === ADAPTER_STATUS.CONNECTED) throw WalletLoginError.connectionError("Already connected");
if (this.status !== ADAPTER_STATUS.READY) throw WalletLoginError.connectionError("Wallet adapter is not ready yet");
}
checkInitializationRequirements(): void {
if (this.status === ADAPTER_STATUS.NOT_READY) return;
if (this.status === ADAPTER_STATUS.CONNECTING) throw WalletInitializationError.notReady("Already pending connection");
if (this.status === ADAPTER_STATUS.CONNECTED) throw WalletInitializationError.notReady("Already connected");
if (this.status === ADAPTER_STATUS.READY) throw WalletInitializationError.notReady("Adapter is already initialized");
}
abstract init(options?: AdapterInitOptions): Promise<void>;
abstract connect(params?: T): Promise<SafeEventEmitterProvider | null>;
abstract connect(params?: T): Promise<SafeEventEmitterProvider | void>;
abstract disconnect(): Promise<void>;
abstract getUserInfo(): Promise<Partial<UserInfo> | null>;
abstract getUserInfo(): Promise<Partial<UserInfo>>;
abstract setAdapterSettings(adapterSettings: unknown): void;
}
export interface BaseAdapterConfig {
visible?: boolean;
label: string;
showOnModal?: boolean;
showOnMobile?: boolean;
showOnDesktop?: boolean;
}
export type LoginMethodConfig = Record<
string,
{
/**
* Display Name. If not provided, we use the default for openlogin app
*/
name: string;
/**
* Description for button. If provided, it renders as a full length button. else, icon button
*/
description?: string;
/**
* Logo to be shown on mouse hover. If not provided, we use the default for openlogin app
*/
logoHover?: string;
/**
* Logo to be shown on dark background (dark theme). If not provided, we use the default for openlogin app
*/
logoLight?: string;
/**
* Logo to be shown on light background (light theme). If not provided, we use the default for openlogin app
*/
logoDark?: string;
/**
* Show login button on the main list
*/
mainOption?: boolean;
/**
* Whether to show the login button on modal or not
*/
showOnModal?: boolean;
/**
* Whether to show the login button on desktop
*/
showOnDesktop?: boolean;
/**
* Whether to show the login button on mobile
*/
showOnMobile?: boolean;
}
>;
export interface WalletConnectV1Data {
uri: string;
}

@@ -25,3 +25,2 @@ export const CHAIN_NAMESPACES = {

rpcTarget: string;
/**

@@ -34,3 +33,3 @@ * Display Name for the chain

*/
blockExplorer?: string;
blockExplorer: string;
/**

@@ -37,0 +36,0 @@ * Default currency ticker of the network (e.g: ETH)

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

5010: "Failed to connect with rpc url",
5011: "Invalid params passed in",
5013: "Invalid network provided",
};

@@ -67,3 +69,3 @@

public static fromCode(code: number, extraMessage = ""): IWeb3AuthError {
return new WalletInitializationError(code, `${WalletInitializationError.messages[code]}${extraMessage}`);
return new WalletInitializationError(code, `${WalletInitializationError.messages[code]}, ${extraMessage}`);
}

@@ -100,13 +102,21 @@

public static rpcConnectionError(extraMessage = ""): IWeb3AuthError {
return WalletInitializationError.fromCode(5012, extraMessage);
public static invalidProviderConfigError(extraMessage = ""): IWeb3AuthError {
return WalletInitializationError.fromCode(5008, extraMessage);
}
public static providerNotReadyError(extraMessage = ""): IWeb3AuthError {
return WalletInitializationError.fromCode(5013, extraMessage);
return WalletInitializationError.fromCode(5009, extraMessage);
}
public static invalidProviderConfigError(extraMessage = ""): IWeb3AuthError {
return WalletInitializationError.fromCode(5008, extraMessage);
public static rpcConnectionError(extraMessage = ""): IWeb3AuthError {
return WalletInitializationError.fromCode(5010, extraMessage);
}
public static invalidParams(extraMessage = ""): IWeb3AuthError {
return WalletInitializationError.fromCode(5011, extraMessage);
}
public static invalidNetwork(extraMessage = ""): IWeb3AuthError {
return WalletInitializationError.fromCode(5013, extraMessage);
}
}

@@ -121,5 +131,5 @@

5000: "Custom",
5011: "Failed to connect with wallet",
5012: "Failed to disconnect from wallet",
5013: "Wallet is not connected",
5111: "Failed to connect with wallet",
5112: "Failed to disconnect from wallet",
5113: "Wallet is not connected",
};

@@ -140,12 +150,12 @@

public static connectionError(extraMessage = ""): IWeb3AuthError {
return WalletLoginError.fromCode(5009, extraMessage);
return WalletLoginError.fromCode(5111, extraMessage);
}
public static disconnectionError(extraMessage = ""): IWeb3AuthError {
return WalletLoginError.fromCode(5010, extraMessage);
return WalletLoginError.fromCode(5112, extraMessage);
}
public static notConnectedError(extraMessage = ""): IWeb3AuthError {
return WalletLoginError.fromCode(5011, extraMessage);
return WalletLoginError.fromCode(5113, extraMessage);
}
}
export * from "./adapter/IAdapter";
export * from "./chain/config";
export * from "./chain/IChainInterface";
export * from "./errors";
export * from "./provider/IProvider";
export * from "./utils";
export * from "./wallet";

@@ -9,3 +9,3 @@ import { JRPCRequest, SafeEventEmitter } from "@toruslabs/openlogin-jrpc";

export type Maybe<T> = Partial<T> | null | undefined;
export type Maybe<T> = T | Partial<T> | null | undefined;

@@ -15,3 +15,3 @@ export interface SafeEventEmitterProvider extends SafeEventEmitter {

send: <T, U>(req: JRPCRequest<T>, callback: SendCallBack<U>) => void;
request?: <T>(args: RequestArguments) => Promise<Maybe<T>>;
request: <T>(args: RequestArguments) => Promise<Maybe<T>>;
}

@@ -18,0 +18,0 @@

export const MULTI_CHAIN_ADAPTERS = {
OPENLOGIN: "openlogin",
CUSTOM_AUTH: "custom-auth",
WALLET_CONNECT_V1: "wallet-connect-v1",
WALLET_CONNECT_V2: "wallet-connect-v2",
};

@@ -5,0 +7,0 @@

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