@web3auth/metamask-adapter
Advanced tools
Comparing version 0.11.0-alpha.0 to 1.0.0-alpha.0
@@ -1,111 +0,49 @@ | ||
module.exports = | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ (() => { // webpackBootstrap | ||
/******/ "use strict"; | ||
/******/ // The require scope | ||
/******/ var __webpack_require__ = {}; | ||
/******/ | ||
/************************************************************************/ | ||
/******/ /* webpack/runtime/compat get default export */ | ||
/******/ (() => { | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = (module) => { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ () => (module['default']) : | ||
/******/ () => (module); | ||
/******/ __webpack_require__.d(getter, { a: getter }); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 3); | ||
/******/ }) | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/define property getters */ | ||
/******/ (() => { | ||
/******/ // define getter functions for harmony exports | ||
/******/ __webpack_require__.d = (exports, definition) => { | ||
/******/ for(var key in definition) { | ||
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | ||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | ||
/******/ } | ||
/******/ } | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/hasOwnProperty shorthand */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/make namespace object */ | ||
/******/ (() => { | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = (exports) => { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("@web3auth/base"); | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("@babel/runtime/helpers/defineProperty"); | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("@metamask/detect-provider"); | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
var __webpack_exports__ = {}; | ||
// ESM COMPAT FLAG | ||
@@ -115,21 +53,20 @@ __webpack_require__.r(__webpack_exports__); | ||
// EXPORTS | ||
__webpack_require__.d(__webpack_exports__, "MetamaskAdapter", function() { return /* reexport */ metamaskAdapter_MetamaskAdapter; }); | ||
__webpack_require__.d(__webpack_exports__, { | ||
"MetamaskAdapter": () => (/* reexport */ MetamaskAdapter) | ||
}); | ||
// EXTERNAL MODULE: external "@babel/runtime/helpers/defineProperty" | ||
var defineProperty_ = __webpack_require__(1); | ||
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty_); | ||
;// CONCATENATED MODULE: external "@babel/runtime/helpers/defineProperty" | ||
const defineProperty_namespaceObject = require("@babel/runtime/helpers/defineProperty"); | ||
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty_namespaceObject); | ||
;// CONCATENATED MODULE: external "@metamask/detect-provider" | ||
const detect_provider_namespaceObject = require("@metamask/detect-provider"); | ||
var detect_provider_default = /*#__PURE__*/__webpack_require__.n(detect_provider_namespaceObject); | ||
;// CONCATENATED MODULE: external "@web3auth/base" | ||
const base_namespaceObject = require("@web3auth/base"); | ||
;// CONCATENATED MODULE: ./src/metamaskAdapter.ts | ||
// EXTERNAL MODULE: external "@metamask/detect-provider" | ||
var detect_provider_ = __webpack_require__(2); | ||
var detect_provider_default = /*#__PURE__*/__webpack_require__.n(detect_provider_); | ||
// EXTERNAL MODULE: external "@web3auth/base" | ||
var base_ = __webpack_require__(0); | ||
// CONCATENATED MODULE: ./src/metamaskAdapter.ts | ||
class metamaskAdapter_MetamaskAdapter extends base_["BaseAdapter"] { | ||
class MetamaskAdapter extends base_namespaceObject.BaseAdapter { | ||
constructor() { | ||
@@ -139,11 +76,11 @@ let adapterOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
defineProperty_default()(this, "adapterNamespace", base_["ADAPTER_NAMESPACES"].EIP155); | ||
defineProperty_default()(this, "adapterNamespace", base_namespaceObject.ADAPTER_NAMESPACES.EIP155); | ||
defineProperty_default()(this, "currentChainNamespace", base_["CHAIN_NAMESPACES"].EIP155); | ||
defineProperty_default()(this, "currentChainNamespace", base_namespaceObject.CHAIN_NAMESPACES.EIP155); | ||
defineProperty_default()(this, "type", base_["ADAPTER_CATEGORY"].EXTERNAL); | ||
defineProperty_default()(this, "type", base_namespaceObject.ADAPTER_CATEGORY.EXTERNAL); | ||
defineProperty_default()(this, "name", base_["WALLET_ADAPTERS"].METAMASK); | ||
defineProperty_default()(this, "name", base_namespaceObject.WALLET_ADAPTERS.METAMASK); | ||
defineProperty_default()(this, "status", base_["ADAPTER_STATUS"].NOT_READY); | ||
defineProperty_default()(this, "status", base_namespaceObject.ADAPTER_STATUS.NOT_READY); | ||
@@ -158,3 +95,3 @@ defineProperty_default()(this, "rehydrated", false); | ||
get provider() { | ||
if (this.status === base_["ADAPTER_STATUS"].CONNECTED && this.metamaskProvider) { | ||
if (this.status === base_namespaceObject.ADAPTER_STATUS.CONNECTED && this.metamaskProvider) { | ||
return this.metamaskProvider; | ||
@@ -175,7 +112,9 @@ } | ||
}); | ||
if (!this.metamaskProvider) throw base_["WalletInitializationError"].notInstalled("Metamask extension is not installed"); | ||
this.status = base_["ADAPTER_STATUS"].READY; | ||
this.emit(base_["ADAPTER_EVENTS"].READY, base_["WALLET_ADAPTERS"].METAMASK); | ||
if (!this.metamaskProvider) throw base_namespaceObject.WalletInitializationError.notInstalled("Metamask extension is not installed"); | ||
this.status = base_namespaceObject.ADAPTER_STATUS.READY; | ||
this.emit(base_namespaceObject.ADAPTER_EVENTS.READY, base_namespaceObject.WALLET_ADAPTERS.METAMASK); | ||
try { | ||
base_namespaceObject.log.debug("initializing metamask adapter"); | ||
if (options.autoConnect) { | ||
@@ -186,3 +125,3 @@ this.rehydrated = true; | ||
} catch (error) { | ||
this.emit(base_["ADAPTER_EVENTS"].ERRORED, error); | ||
this.emit(base_namespaceObject.ADAPTER_EVENTS.ERRORED, error); | ||
} | ||
@@ -196,8 +135,8 @@ } | ||
if (!this.chainConfig) this.chainConfig = Object(base_["getChainConfig"])(base_["CHAIN_NAMESPACES"].EIP155, 1); | ||
this.status = base_["ADAPTER_STATUS"].CONNECTING; | ||
this.emit(base_["ADAPTER_EVENTS"].CONNECTING, { | ||
adapter: base_["WALLET_ADAPTERS"].METAMASK | ||
if (!this.chainConfig) this.chainConfig = (0,base_namespaceObject.getChainConfig)(base_namespaceObject.CHAIN_NAMESPACES.EIP155, 1); | ||
this.status = base_namespaceObject.ADAPTER_STATUS.CONNECTING; | ||
this.emit(base_namespaceObject.ADAPTER_EVENTS.CONNECTING, { | ||
adapter: base_namespaceObject.WALLET_ADAPTERS.METAMASK | ||
}); | ||
if (!this.metamaskProvider) throw base_["WalletLoginError"].notConnectedError("Not able to connect with metamask"); | ||
if (!this.metamaskProvider) throw base_namespaceObject.WalletLoginError.notConnectedError("Not able to connect with metamask"); | ||
@@ -216,4 +155,4 @@ try { | ||
this.status = base_["ADAPTER_STATUS"].CONNECTED; | ||
if (!this.provider) throw base_["WalletLoginError"].notConnectedError("Failed to connect with provider"); | ||
this.status = base_namespaceObject.ADAPTER_STATUS.CONNECTED; | ||
if (!this.provider) throw base_namespaceObject.WalletLoginError.notConnectedError("Failed to connect with provider"); | ||
this.provider.once("disconnect", () => { | ||
@@ -223,4 +162,4 @@ // ready to be connected again | ||
}); | ||
this.emit(base_["ADAPTER_EVENTS"].CONNECTED, { | ||
adapter: base_["WALLET_ADAPTERS"].METAMASK, | ||
this.emit(base_namespaceObject.ADAPTER_EVENTS.CONNECTED, { | ||
adapter: base_namespaceObject.WALLET_ADAPTERS.METAMASK, | ||
reconnected: this.rehydrated | ||
@@ -231,6 +170,6 @@ }); | ||
// ready again to be connected | ||
this.status = base_["ADAPTER_STATUS"].READY; | ||
this.status = base_namespaceObject.ADAPTER_STATUS.READY; | ||
this.rehydrated = false; | ||
this.emit(base_["ADAPTER_EVENTS"].ERRORED, error); | ||
throw base_["WalletLoginError"].connectionError("Failed to login with metamask wallet"); | ||
this.emit(base_namespaceObject.ADAPTER_EVENTS.ERRORED, error); | ||
throw base_namespaceObject.WalletLoginError.connectionError("Failed to login with metamask wallet"); | ||
} | ||
@@ -245,19 +184,19 @@ } | ||
}; | ||
if (this.status !== base_["ADAPTER_STATUS"].CONNECTED) throw base_["WalletLoginError"].disconnectionError("Not connected with wallet"); | ||
if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED) throw base_namespaceObject.WalletLoginError.disconnectionError("Not connected with wallet"); | ||
(_this$provider = this.provider) === null || _this$provider === void 0 ? void 0 : _this$provider.removeAllListeners(); | ||
if (options.cleanup) { | ||
this.status = base_["ADAPTER_STATUS"].NOT_READY; | ||
this.status = base_namespaceObject.ADAPTER_STATUS.NOT_READY; | ||
this.metamaskProvider = null; | ||
} else { | ||
// ready to be connected again | ||
this.status = base_["ADAPTER_STATUS"].READY; | ||
this.status = base_namespaceObject.ADAPTER_STATUS.READY; | ||
} | ||
this.rehydrated = false; | ||
this.emit(base_["ADAPTER_EVENTS"].DISCONNECTED); | ||
this.emit(base_namespaceObject.ADAPTER_EVENTS.DISCONNECTED); | ||
} | ||
async getUserInfo() { | ||
if (this.status !== base_["ADAPTER_STATUS"].CONNECTED) throw base_["WalletLoginError"].notConnectedError("Not connected with wallet, Please login/connect first"); | ||
if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED) throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet, Please login/connect first"); | ||
return {}; | ||
@@ -267,3 +206,3 @@ } | ||
async switchChain(chainConfig) { | ||
if (!this.metamaskProvider) throw base_["WalletLoginError"].notConnectedError("Not connected with wallet"); | ||
if (!this.metamaskProvider) throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet"); | ||
@@ -297,7 +236,7 @@ try { | ||
// CONCATENATED MODULE: ./src/index.ts | ||
;// CONCATENATED MODULE: ./src/index.ts | ||
/***/ }) | ||
/******/ ]); | ||
module.exports.MetamaskAdapter = __webpack_exports__; | ||
/******/ })() | ||
; | ||
//# sourceMappingURL=metamaskAdapter.cjs.js.map |
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import detectEthereumProvider from '@metamask/detect-provider'; | ||
import { BaseAdapter, ADAPTER_NAMESPACES, CHAIN_NAMESPACES, ADAPTER_CATEGORY, WALLET_ADAPTERS, ADAPTER_STATUS, WalletInitializationError, ADAPTER_EVENTS, getChainConfig, WalletLoginError } from '@web3auth/base'; | ||
import { BaseAdapter, ADAPTER_NAMESPACES, CHAIN_NAMESPACES, ADAPTER_CATEGORY, WALLET_ADAPTERS, ADAPTER_STATUS, WalletInitializationError, ADAPTER_EVENTS, log, getChainConfig, WalletLoginError } from '@web3auth/base'; | ||
@@ -49,2 +49,4 @@ class MetamaskAdapter extends BaseAdapter { | ||
try { | ||
log.debug("initializing metamask adapter"); | ||
if (options.autoConnect) { | ||
@@ -51,0 +53,0 @@ this.rehydrated = true; |
{ | ||
"name": "@web3auth/metamask-adapter", | ||
"version": "0.11.0-alpha.0", | ||
"version": "1.0.0-alpha.0", | ||
"description": "metamask wallet adapter for web3auth", | ||
@@ -24,4 +24,4 @@ "keywords": [ | ||
"test-debugger": "mocha --config ../../../.mocharc.json --inspect-brk test/**.ts", | ||
"dev": "rimraf dist/ && torus-scripts start", | ||
"build": "rimraf dist/ && torus-scripts build", | ||
"dev": "torus-scripts start", | ||
"build": "torus-scripts build", | ||
"lint": "eslint --fix 'src/**/*.ts'", | ||
@@ -39,7 +39,7 @@ "prepack": "yarn run build", | ||
"devDependencies": { | ||
"lint-staged": "^12.4.0" | ||
"lint-staged": "^12.4.1" | ||
}, | ||
"dependencies": { | ||
"@metamask/detect-provider": "^1.2.0", | ||
"@web3auth/base": "^0.11.0-alpha.0" | ||
"@web3auth/base": "^1.0.0-alpha.0" | ||
}, | ||
@@ -62,3 +62,3 @@ "lint-staged": { | ||
}, | ||
"gitHead": "d591b3e53ba8ebdfb0e50ef3f37f0f9ed1e31c74" | ||
"gitHead": "ceaa4b9164dcd94af53ba4c3f005cf88b90ae3a1" | ||
} |
@@ -17,2 +17,3 @@ import detectEthereumProvider from "@metamask/detect-provider"; | ||
getChainConfig, | ||
log, | ||
SafeEventEmitterProvider, | ||
@@ -72,2 +73,3 @@ UserInfo, | ||
try { | ||
log.debug("initializing metamask adapter"); | ||
if (options.autoConnect) { | ||
@@ -74,0 +76,0 @@ this.rehydrated = true; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13
628049
1
80
899
+ Added@toruslabs/http-helpers@3.4.0(transitive)
+ Added@toruslabs/openlogin-jrpc@2.13.0(transitive)
+ Added@toruslabs/openlogin-utils@2.13.0(transitive)
+ Added@web3auth/base@1.2.0(transitive)
+ Addedjwt-decode@3.1.2(transitive)
+ Addedlodash.merge@4.6.2(transitive)
- Removed@toruslabs/openlogin-jrpc@1.7.3(transitive)
- Removed@toruslabs/openlogin-utils@1.7.0(transitive)
- Removed@web3auth/base@0.11.0-alpha.0(transitive)