@web3auth/no-modal 5.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # Web3Auth Plug and Play NoModal
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@web3auth/no-modal?label=%22%22)](https://www.npmjs.com/package/@web3auth/no-modal/v/latest)
4
+ [![minzip](https://img.shields.io/bundlephobia/minzip/@web3auth/no-modal?label=%22%22)](https://bundlephobia.com/result?p=@web3auth/no-modal@latest)
5
+
6
+ > Web3Auth is where passwordless auth meets non-custodial key infrastructure for Web3 apps and wallets. By aggregating OAuth (Google, Twitter, Discord) logins, different wallets and innovative Multi Party Computation (MPC) - Web3Auth provides a seamless login experience to every user on your application.
7
+
8
+ Web3Auth Plug and Play NoModal is the main SDK that consists of the nomodal module of Web3Auth Plug and Play. This SDK gives you all the needed modules for implementing the Web3Auth features, giving you the flexibility of implementing your own UI to use all the functionalities.
9
+
10
+ ## 📖 Documentation
11
+
12
+ Checkout the official [Web3Auth Documentation](https://web3auth.io/docs/sdk/web/no-modal/) to get started.
13
+
14
+ ## 💡 Features
15
+
16
+ - Plug and Play, OAuth based Web3 Authentication Service
17
+ - Fully decentralized, non-custodial key infrastructure
18
+ - End to end Whitelabelable solution
19
+ - Threshold Cryptography based Key Reconstruction
20
+ - Multi Factor Authentication Setup & Recovery (Includes password, backup phrase, device factor editing/deletion etc)
21
+ - Support for WebAuthn & Passwordless Login
22
+ - Support for connecting to multiple wallets
23
+ - DApp Active Session Management
24
+
25
+ ...and a lot more
26
+
27
+ ## 🔗 Installation
28
+
29
+ ```shell
30
+ npm install --save @web3auth/no-modal
31
+ ```
32
+
33
+ ## ⚡ Quick Start
34
+
35
+ ### Get your Client ID from Web3Auth Dashboard
36
+
37
+ Hop on to the [Web3Auth Dashboard](https://dashboard.web3auth.io/) and create a new project. Use the Client ID of the project to start your integration.
38
+
39
+ ![Web3Auth Dashboard](https://web3auth.io/docs/assets/images/project_plug_n_play-89c39ec42ad993107bb2485b1ce64b89.png)
40
+
41
+ ### Initialize Web3Auth for your preferred blockchain
42
+
43
+ Web3Auth needs to initialise as soon as your app loads up to enable the user to log in. Preferably done within a constructor, initialisation is the step where you can pass on all the configurations for Web3Auth you want. A simple integration for Ethereum blockchain will look like this:
44
+
45
+ ```js
46
+ import { Web3AuthNoModal } from "@web3auth/no-modal";
47
+
48
+ //Initialize within your constructor
49
+ const web3auth = new Web3AuthNoModal({
50
+ clientId: "", // Get your Client ID from Web3Auth Dashboard
51
+ chainConfig: {
52
+ chainNamespace: "eip155",
53
+ chainId: "0x1",
54
+ },
55
+ });
56
+
57
+ await web3auth.init();
58
+ ```
59
+
60
+ ### Login your User
61
+
62
+ Once you're done initialising, just create a button that triggers login for your preferred social channel for the user on their request. You can further use the returned provider for making RPC calls to the blockchain.
63
+
64
+ ```js
65
+ const web3authProvider = await web3auth.connectTo("openlogin", {
66
+ loginProvider: "google",
67
+ });
68
+ ```
69
+
70
+ ## 🩹 Examples
71
+
72
+ Checkout the examples for your preferred blockchain and platform in our [examples repository](https://github.com/Web3Auth/examples/tree/master/web-core-sdk)
73
+
74
+ ## 🌐 Demo
75
+
76
+ Checkout the [Web3Auth Demo](https://demo-app.web3auth.io/) to see how Web3Auth can be used in your application.
77
+
78
+ ## 💬 Troubleshooting and Discussions
79
+
80
+ - Have a look at our [GitHub Discussions](https://github.com/Web3Auth/Web3Auth/discussions?discussions_q=sort%3Atop) to see if anyone has any questions or issues you might be having.
81
+ - Checkout our [Troubleshooting Documentation Page](https://web3auth.io/docs/troubleshooting) to know the common issues and solutions
82
+ - Join our [Discord](https://discord.gg/web3auth) to join our community and get private integration support or help with your integration.
@@ -0,0 +1,280 @@
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ "use strict";
3
+ /******/ // The require scope
4
+ /******/ var __webpack_require__ = {};
5
+ /******/
6
+ /************************************************************************/
7
+ /******/ /* webpack/runtime/compat get default export */
8
+ /******/ (() => {
9
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
10
+ /******/ __webpack_require__.n = (module) => {
11
+ /******/ var getter = module && module.__esModule ?
12
+ /******/ () => (module['default']) :
13
+ /******/ () => (module);
14
+ /******/ __webpack_require__.d(getter, { a: getter });
15
+ /******/ return getter;
16
+ /******/ };
17
+ /******/ })();
18
+ /******/
19
+ /******/ /* webpack/runtime/define property getters */
20
+ /******/ (() => {
21
+ /******/ // define getter functions for harmony exports
22
+ /******/ __webpack_require__.d = (exports, definition) => {
23
+ /******/ for(var key in definition) {
24
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
25
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
26
+ /******/ }
27
+ /******/ }
28
+ /******/ };
29
+ /******/ })();
30
+ /******/
31
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
32
+ /******/ (() => {
33
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
34
+ /******/ })();
35
+ /******/
36
+ /******/ /* webpack/runtime/make namespace object */
37
+ /******/ (() => {
38
+ /******/ // define __esModule on exports
39
+ /******/ __webpack_require__.r = (exports) => {
40
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
41
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
42
+ /******/ }
43
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
44
+ /******/ };
45
+ /******/ })();
46
+ /******/
47
+ /************************************************************************/
48
+ var __webpack_exports__ = {};
49
+ // ESM COMPAT FLAG
50
+ __webpack_require__.r(__webpack_exports__);
51
+
52
+ // EXPORTS
53
+ __webpack_require__.d(__webpack_exports__, {
54
+ "Web3AuthNoModal": () => (/* reexport */ Web3AuthNoModal)
55
+ });
56
+
57
+ ;// CONCATENATED MODULE: external "@babel/runtime/helpers/defineProperty"
58
+ const defineProperty_namespaceObject = require("@babel/runtime/helpers/defineProperty");
59
+ var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty_namespaceObject);
60
+ ;// CONCATENATED MODULE: external "@toruslabs/openlogin-jrpc"
61
+ const openlogin_jrpc_namespaceObject = require("@toruslabs/openlogin-jrpc");
62
+ ;// CONCATENATED MODULE: external "@web3auth/base"
63
+ const base_namespaceObject = require("@web3auth/base");
64
+ ;// CONCATENATED MODULE: external "@web3auth/base-plugin"
65
+ const base_plugin_namespaceObject = require("@web3auth/base-plugin");
66
+ ;// CONCATENATED MODULE: ./src/noModal.ts
67
+
68
+ 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; }
69
+ 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; }
70
+
71
+
72
+
73
+ const ADAPTER_CACHE_KEY = "Web3Auth-cachedAdapter";
74
+ class Web3AuthNoModal extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
75
+ constructor(options) {
76
+ var _options$chainConfig, _options$chainConfig2, _options$chainConfig3, _options$chainConfig4;
77
+ super();
78
+ defineProperty_default()(this, "coreOptions", void 0);
79
+ defineProperty_default()(this, "connectedAdapterName", null);
80
+ defineProperty_default()(this, "status", base_namespaceObject.ADAPTER_STATUS.NOT_READY);
81
+ defineProperty_default()(this, "cachedAdapter", null);
82
+ defineProperty_default()(this, "walletAdapters", {});
83
+ defineProperty_default()(this, "plugins", {});
84
+ defineProperty_default()(this, "storage", "localStorage");
85
+ if (!options.clientId) throw base_namespaceObject.WalletInitializationError.invalidParams("Please provide a valid clientId in constructor");
86
+ if (options.enableLogging) base_namespaceObject.log.enableAll();else base_namespaceObject.log.disableAll();
87
+ if (!((_options$chainConfig = options.chainConfig) !== null && _options$chainConfig !== void 0 && _options$chainConfig.chainNamespace) || !Object.values(base_namespaceObject.CHAIN_NAMESPACES).includes((_options$chainConfig2 = options.chainConfig) === null || _options$chainConfig2 === void 0 ? void 0 : _options$chainConfig2.chainNamespace)) throw base_namespaceObject.WalletInitializationError.invalidParams("Please provide a valid chainNamespace in chainConfig");
88
+ if (options.storageKey === "session") this.storage = "sessionStorage";
89
+ this.cachedAdapter = (0,base_namespaceObject.storageAvailable)(this.storage) ? window[this.storage].getItem(ADAPTER_CACHE_KEY) : null;
90
+ this.coreOptions = _objectSpread(_objectSpread({}, options), {}, {
91
+ chainConfig: _objectSpread(_objectSpread({}, (0,base_namespaceObject.getChainConfig)((_options$chainConfig3 = options.chainConfig) === null || _options$chainConfig3 === void 0 ? void 0 : _options$chainConfig3.chainNamespace, (_options$chainConfig4 = options.chainConfig) === null || _options$chainConfig4 === void 0 ? void 0 : _options$chainConfig4.chainId) || {}), options.chainConfig)
92
+ });
93
+ this.subscribeToAdapterEvents = this.subscribeToAdapterEvents.bind(this);
94
+ }
95
+ get provider() {
96
+ if (this.status === base_namespaceObject.ADAPTER_STATUS.CONNECTED && this.connectedAdapterName) {
97
+ const adapter = this.walletAdapters[this.connectedAdapterName];
98
+ return adapter.provider;
99
+ }
100
+ return null;
101
+ }
102
+ set provider(_) {
103
+ throw new Error("Not implemented");
104
+ }
105
+ async init() {
106
+ const initPromises = Object.keys(this.walletAdapters).map(adapterName => {
107
+ this.subscribeToAdapterEvents(this.walletAdapters[adapterName]);
108
+ // if adapter doesn't have any chain config yet thn set it based on provided namespace and chainId.
109
+ // if no chainNamespace or chainId is being provided, it will connect with mainnet.
110
+ if (!this.walletAdapters[adapterName].chainConfigProxy) {
111
+ const providedChainConfig = this.coreOptions.chainConfig;
112
+ if (!providedChainConfig.chainNamespace) throw base_namespaceObject.WalletInitializationError.invalidParams("Please provide chainNamespace in chainConfig");
113
+ this.walletAdapters[adapterName].setAdapterSettings({
114
+ chainConfig: providedChainConfig,
115
+ sessionTime: this.coreOptions.sessionTime,
116
+ clientId: this.coreOptions.clientId,
117
+ web3AuthNetwork: this.coreOptions.web3AuthNetwork,
118
+ useCoreKitKey: this.coreOptions.useCoreKitKey
119
+ });
120
+ } else {
121
+ this.walletAdapters[adapterName].setAdapterSettings({
122
+ sessionTime: this.coreOptions.sessionTime,
123
+ clientId: this.coreOptions.clientId,
124
+ web3AuthNetwork: this.coreOptions.web3AuthNetwork,
125
+ useCoreKitKey: this.coreOptions.useCoreKitKey
126
+ });
127
+ }
128
+ return this.walletAdapters[adapterName].init({
129
+ autoConnect: this.cachedAdapter === adapterName
130
+ }).catch(e => base_namespaceObject.log.error(e));
131
+ });
132
+ this.status = base_namespaceObject.ADAPTER_STATUS.READY;
133
+ await Promise.all(initPromises);
134
+ }
135
+ configureAdapter(adapter) {
136
+ this.checkInitRequirements();
137
+ const providedChainConfig = this.coreOptions.chainConfig;
138
+ if (!providedChainConfig.chainNamespace) throw base_namespaceObject.WalletInitializationError.invalidParams("Please provide chainNamespace in chainConfig");
139
+ const adapterAlreadyExists = this.walletAdapters[adapter.name];
140
+ if (adapterAlreadyExists) throw base_namespaceObject.WalletInitializationError.duplicateAdapterError(`Wallet adapter for ${adapter.name} already exists`);
141
+ if (adapter.adapterNamespace !== base_namespaceObject.ADAPTER_NAMESPACES.MULTICHAIN && adapter.adapterNamespace !== providedChainConfig.chainNamespace) throw base_namespaceObject.WalletInitializationError.incompatibleChainNameSpace(`This wallet adapter belongs to ${adapter.adapterNamespace} which is incompatible with currently used namespace: ${providedChainConfig.chainNamespace}`);
142
+ if (adapter.adapterNamespace === base_namespaceObject.ADAPTER_NAMESPACES.MULTICHAIN && adapter.currentChainNamespace && providedChainConfig.chainNamespace !== adapter.currentChainNamespace) {
143
+ // chainConfig checks are already validated in constructor so using typecast is safe here.
144
+ adapter.setAdapterSettings({
145
+ chainConfig: providedChainConfig
146
+ });
147
+ }
148
+ this.walletAdapters[adapter.name] = adapter;
149
+ return this;
150
+ }
151
+ clearCache() {
152
+ if (!(0,base_namespaceObject.storageAvailable)(this.storage)) return;
153
+ window[this.storage].removeItem(ADAPTER_CACHE_KEY);
154
+ this.cachedAdapter = null;
155
+ }
156
+ async addChain(chainConfig) {
157
+ if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw base_namespaceObject.WalletLoginError.notConnectedError(`No wallet is connected`);
158
+ return this.walletAdapters[this.connectedAdapterName].addChain(chainConfig);
159
+ }
160
+ async switchChain(params) {
161
+ if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw base_namespaceObject.WalletLoginError.notConnectedError(`No wallet is connected`);
162
+ return this.walletAdapters[this.connectedAdapterName].switchChain(params);
163
+ }
164
+
165
+ /**
166
+ * Connect to a specific wallet adapter
167
+ * @param walletName - Key of the walletAdapter to use.
168
+ */
169
+ async connectTo(walletName, loginParams) {
170
+ if (!this.walletAdapters[walletName]) throw base_namespaceObject.WalletInitializationError.notFound(`Please add wallet adapter for ${walletName} wallet, before connecting`);
171
+ const provider = await this.walletAdapters[walletName].connect(loginParams);
172
+ return provider;
173
+ }
174
+ async logout() {
175
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
176
+ cleanup: false
177
+ };
178
+ if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw base_namespaceObject.WalletLoginError.notConnectedError(`No wallet is connected`);
179
+ await this.walletAdapters[this.connectedAdapterName].disconnect(options);
180
+ }
181
+ async getUserInfo() {
182
+ base_namespaceObject.log.debug("Getting user info", this.status, this.connectedAdapterName);
183
+ if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw base_namespaceObject.WalletLoginError.notConnectedError(`No wallet is connected`);
184
+ return this.walletAdapters[this.connectedAdapterName].getUserInfo();
185
+ }
186
+ async authenticateUser() {
187
+ if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw base_namespaceObject.WalletLoginError.notConnectedError(`No wallet is connected`);
188
+ return this.walletAdapters[this.connectedAdapterName].authenticateUser();
189
+ }
190
+ async addPlugin(plugin) {
191
+ if (this.plugins[plugin.name]) throw new Error(`Plugin ${plugin.name} already exist`);
192
+ if (plugin.pluginNamespace !== base_plugin_namespaceObject.PLUGIN_NAMESPACES.MULTICHAIN && plugin.pluginNamespace !== this.coreOptions.chainConfig.chainNamespace) throw new Error(`This plugin belongs to ${plugin.pluginNamespace} namespace which is incompatible with currently used namespace: ${this.coreOptions.chainConfig.chainNamespace}`);
193
+ this.plugins[plugin.name] = plugin;
194
+ return this;
195
+ }
196
+ subscribeToAdapterEvents(walletAdapter) {
197
+ walletAdapter.on(base_namespaceObject.ADAPTER_EVENTS.CONNECTED, async data => {
198
+ this.status = base_namespaceObject.ADAPTER_STATUS.CONNECTED;
199
+ this.connectedAdapterName = data.adapter;
200
+ this.cacheWallet(data.adapter);
201
+ base_namespaceObject.log.debug("connected", this.status, this.connectedAdapterName);
202
+ Object.values(this.plugins).map(async plugin => {
203
+ try {
204
+ if (!plugin.SUPPORTED_ADAPTERS.includes(data.adapter)) {
205
+ return;
206
+ }
207
+ await plugin.initWithWeb3Auth(this);
208
+ await plugin.connect();
209
+ } catch (error) {
210
+ // swallow error if connector adapter doesn't supports this plugin.
211
+ if (error.code === 5211) {
212
+ return;
213
+ }
214
+ base_namespaceObject.log.error(error);
215
+ }
216
+ });
217
+ this.emit(base_namespaceObject.ADAPTER_EVENTS.CONNECTED, _objectSpread({}, data));
218
+ });
219
+ walletAdapter.on(base_namespaceObject.ADAPTER_EVENTS.DISCONNECTED, async data => {
220
+ // get back to ready state for rehydrating.
221
+ this.status = base_namespaceObject.ADAPTER_STATUS.READY;
222
+ if ((0,base_namespaceObject.storageAvailable)(this.storage)) {
223
+ const cachedAdapter = window[this.storage].getItem(ADAPTER_CACHE_KEY);
224
+ if (this.connectedAdapterName === cachedAdapter) {
225
+ this.clearCache();
226
+ }
227
+ }
228
+ base_namespaceObject.log.debug("disconnected", this.status, this.connectedAdapterName);
229
+ await Promise.all(Object.values(this.plugins).map(plugin => {
230
+ return plugin.disconnect().catch(error => {
231
+ // swallow error if adapter doesn't supports this plugin.
232
+ if (error.code === 5211) {
233
+ return;
234
+ }
235
+ // throw error;
236
+ base_namespaceObject.log.error(error);
237
+ });
238
+ }));
239
+ this.connectedAdapterName = null;
240
+ this.emit(base_namespaceObject.ADAPTER_EVENTS.DISCONNECTED, data);
241
+ });
242
+ walletAdapter.on(base_namespaceObject.ADAPTER_EVENTS.CONNECTING, data => {
243
+ this.status = base_namespaceObject.ADAPTER_STATUS.CONNECTING;
244
+ this.emit(base_namespaceObject.ADAPTER_EVENTS.CONNECTING, data);
245
+ base_namespaceObject.log.debug("connecting", this.status, this.connectedAdapterName);
246
+ });
247
+ walletAdapter.on(base_namespaceObject.ADAPTER_EVENTS.ERRORED, data => {
248
+ this.status = base_namespaceObject.ADAPTER_STATUS.ERRORED;
249
+ this.clearCache();
250
+ this.emit(base_namespaceObject.ADAPTER_EVENTS.ERRORED, data);
251
+ base_namespaceObject.log.debug("errored", this.status, this.connectedAdapterName);
252
+ });
253
+ walletAdapter.on(base_namespaceObject.ADAPTER_EVENTS.ADAPTER_DATA_UPDATED, data => {
254
+ base_namespaceObject.log.debug("adapter data updated", data);
255
+ this.emit(base_namespaceObject.ADAPTER_EVENTS.ADAPTER_DATA_UPDATED, data);
256
+ });
257
+ walletAdapter.on(base_namespaceObject.ADAPTER_EVENTS.CACHE_CLEAR, data => {
258
+ base_namespaceObject.log.debug("adapter cache clear", data);
259
+ if ((0,base_namespaceObject.storageAvailable)(this.storage)) {
260
+ this.clearCache();
261
+ }
262
+ });
263
+ }
264
+ checkInitRequirements() {
265
+ if (this.status === base_namespaceObject.ADAPTER_STATUS.CONNECTING) throw base_namespaceObject.WalletInitializationError.notReady("Already pending connection");
266
+ if (this.status === base_namespaceObject.ADAPTER_STATUS.CONNECTED) throw base_namespaceObject.WalletInitializationError.notReady("Already connected");
267
+ if (this.status === base_namespaceObject.ADAPTER_STATUS.READY) throw base_namespaceObject.WalletInitializationError.notReady("Adapter is already initialized");
268
+ }
269
+ cacheWallet(walletName) {
270
+ if (!(0,base_namespaceObject.storageAvailable)(this.storage)) return;
271
+ window[this.storage].setItem(ADAPTER_CACHE_KEY, walletName);
272
+ this.cachedAdapter = walletName;
273
+ }
274
+ }
275
+ ;// CONCATENATED MODULE: ./src/index.ts
276
+
277
+ module.exports = __webpack_exports__;
278
+ /******/ })()
279
+ ;
280
+ //# sourceMappingURL=noModal.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noModal.cjs.js","mappings":";;UAAA;UACA;;;;;WCDA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;ACNA,MAAM,8BAA4B;;;ACAlC,MAAM,8BAA4B;;ACAlC,MAAM,oBAA4B;;ACAlC,MAAM,2BAA4B;;;;;ACC2B;AAqBrC;AAC2C;AA6CnE,MAAMW,iBAAiB,GAAG,wBAAwB;AAC3C,MAAMC,eAAe,SAASZ,+CAAgB,CAAsB;EAezEa,WAAWA,CAACC,OAA+B,EAAE;IAAA,IAAAC,oBAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA;IAC3C,KAAK,EAAE;IAACC,wBAAA;IAAAA,wBAAA,+BAbgD,IAAI;IAAAA,wBAAA,iBAEzBhB,6CAAwB;IAAAgB,wBAAA,wBAEvB,IAA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EwE,UAAU,CAAC;IAC3D,IAAI,CAAClD,aAAa,GAAGkD,UAAU;EACjC;AACF","sources":["webpack://@web3auth/no-modal/webpack/bootstrap","webpack://@web3auth/no-modal/webpack/runtime/compat get default export","webpack://@web3auth/no-modal/webpack/runtime/define property getters","webpack://@web3auth/no-modal/webpack/runtime/hasOwnProperty shorthand","webpack://@web3auth/no-modal/webpack/runtime/make namespace object","webpack://@web3auth/no-modal/external commonjs2 \"@babel/runtime/helpers/defineProperty\"","webpack://@web3auth/no-modal/external commonjs2 \"@toruslabs/openlogin-jrpc\"","webpack://@web3auth/no-modal/external commonjs2 \"@web3auth/base\"","webpack://@web3auth/no-modal/external commonjs2 \"@web3auth/base-plugin\"","webpack://@web3auth/no-modal/./src/noModal.ts","webpack://@web3auth/no-modal/./src/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@babel/runtime/helpers/defineProperty\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@toruslabs/openlogin-jrpc\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@web3auth/base\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@web3auth/base-plugin\");","import type { OPENLOGIN_NETWORK_TYPE } from \"@toruslabs/openlogin\";\nimport { SafeEventEmitter } from \"@toruslabs/openlogin-jrpc\";\nimport {\n ADAPTER_EVENTS,\n ADAPTER_NAMESPACES,\n ADAPTER_STATUS,\n ADAPTER_STATUS_TYPE,\n CHAIN_NAMESPACES,\n CONNECTED_EVENT_DATA,\n CustomChainConfig,\n getChainConfig,\n IAdapter,\n IWeb3Auth,\n log,\n SafeEventEmitterProvider,\n storageAvailable,\n UserAuthInfo,\n UserInfo,\n WALLET_ADAPTER_TYPE,\n WalletInitializationError,\n WalletLoginError,\n Web3AuthError,\n} from \"@web3auth/base\";\nimport { IPlugin, PLUGIN_NAMESPACES } from \"@web3auth/base-plugin\";\n\nexport interface Web3AuthNoModalOptions {\n /**\n * Client id for web3auth.\n * You can obtain your client id from the web3auth developer dashboard.\n * You can set any random string for this on localhost.\n */\n clientId: string;\n /**\n * custom chain configuration for chainNamespace\n *\n * @defaultValue mainnet config of provided chainNamespace\n */\n chainConfig: Partial<CustomChainConfig> & Pick<CustomChainConfig, \"chainNamespace\">;\n\n /**\n * setting to true will enable logs\n *\n * @defaultValue false\n */\n enableLogging?: boolean;\n /**\n * setting to \"local\" will persist social login session accross browser tabs.\n *\n * @defaultValue \"local\"\n */\n storageKey?: \"session\" | \"local\";\n\n /**\n * sessionTime (in seconds) for idToken issued by Web3Auth for server side verification.\n * @defaultValue 86400\n *\n * Note: max value can be 7 days (86400 * 7) and min can be 1 day (86400)\n */\n sessionTime?: number;\n /**\n * Web3Auth Network to use for the session & the issued idToken\n * @defaultValue mainnet\n */\n web3AuthNetwork?: OPENLOGIN_NETWORK_TYPE;\n\n useCoreKitKey?: boolean;\n}\n\nconst ADAPTER_CACHE_KEY = \"Web3Auth-cachedAdapter\";\nexport class Web3AuthNoModal extends SafeEventEmitter implements IWeb3Auth {\n readonly coreOptions: Web3AuthNoModalOptions;\n\n public connectedAdapterName: WALLET_ADAPTER_TYPE | null = null;\n\n public status: ADAPTER_STATUS_TYPE = ADAPTER_STATUS.NOT_READY;\n\n public cachedAdapter: string | null = null;\n\n protected walletAdapters: Record<string, IAdapter<unknown>> = {};\n\n private plugins: Record<string, IPlugin> = {};\n\n private storage: \"sessionStorage\" | \"localStorage\" = \"localStorage\";\n\n constructor(options: Web3AuthNoModalOptions) {\n super();\n if (!options.clientId) throw WalletInitializationError.invalidParams(\"Please provide a valid clientId in constructor\");\n if (options.enableLogging) log.enableAll();\n else log.disableAll();\n if (!options.chainConfig?.chainNamespace || !Object.values(CHAIN_NAMESPACES).includes(options.chainConfig?.chainNamespace))\n throw WalletInitializationError.invalidParams(\"Please provide a valid chainNamespace in chainConfig\");\n if (options.storageKey === \"session\") this.storage = \"sessionStorage\";\n this.cachedAdapter = storageAvailable(this.storage) ? window[this.storage].getItem(ADAPTER_CACHE_KEY) : null;\n\n this.coreOptions = {\n ...options,\n chainConfig: {\n ...(getChainConfig(options.chainConfig?.chainNamespace, options.chainConfig?.chainId) || {}),\n ...options.chainConfig,\n },\n };\n this.subscribeToAdapterEvents = this.subscribeToAdapterEvents.bind(this);\n }\n\n get provider(): SafeEventEmitterProvider | null {\n if (this.status === ADAPTER_STATUS.CONNECTED && this.connectedAdapterName) {\n const adapter = this.walletAdapters[this.connectedAdapterName];\n return adapter.provider;\n }\n return null;\n }\n\n set provider(_: SafeEventEmitterProvider | null) {\n throw new Error(\"Not implemented\");\n }\n\n public async init(): Promise<void> {\n const initPromises = Object.keys(this.walletAdapters).map((adapterName) => {\n this.subscribeToAdapterEvents(this.walletAdapters[adapterName]);\n // if adapter doesn't have any chain config yet thn set it based on provided namespace and chainId.\n // if no chainNamespace or chainId is being provided, it will connect with mainnet.\n if (!this.walletAdapters[adapterName].chainConfigProxy) {\n const providedChainConfig = this.coreOptions.chainConfig;\n if (!providedChainConfig.chainNamespace) throw WalletInitializationError.invalidParams(\"Please provide chainNamespace in chainConfig\");\n this.walletAdapters[adapterName].setAdapterSettings({\n chainConfig: providedChainConfig,\n sessionTime: this.coreOptions.sessionTime,\n clientId: this.coreOptions.clientId,\n web3AuthNetwork: this.coreOptions.web3AuthNetwork,\n useCoreKitKey: this.coreOptions.useCoreKitKey,\n });\n } else {\n this.walletAdapters[adapterName].setAdapterSettings({\n sessionTime: this.coreOptions.sessionTime,\n clientId: this.coreOptions.clientId,\n web3AuthNetwork: this.coreOptions.web3AuthNetwork,\n useCoreKitKey: this.coreOptions.useCoreKitKey,\n });\n }\n\n return this.walletAdapters[adapterName].init({ autoConnect: this.cachedAdapter === adapterName }).catch((e) => log.error(e));\n });\n this.status = ADAPTER_STATUS.READY;\n await Promise.all(initPromises);\n }\n\n public configureAdapter(adapter: IAdapter<unknown>): Web3AuthNoModal {\n this.checkInitRequirements();\n const providedChainConfig = this.coreOptions.chainConfig;\n\n if (!providedChainConfig.chainNamespace) throw WalletInitializationError.invalidParams(\"Please provide chainNamespace in chainConfig\");\n\n const adapterAlreadyExists = this.walletAdapters[adapter.name];\n if (adapterAlreadyExists) throw WalletInitializationError.duplicateAdapterError(`Wallet adapter for ${adapter.name} already exists`);\n if (adapter.adapterNamespace !== ADAPTER_NAMESPACES.MULTICHAIN && adapter.adapterNamespace !== providedChainConfig.chainNamespace)\n throw WalletInitializationError.incompatibleChainNameSpace(\n `This wallet adapter belongs to ${adapter.adapterNamespace} which is incompatible with currently used namespace: ${providedChainConfig.chainNamespace}`\n );\n\n if (\n adapter.adapterNamespace === ADAPTER_NAMESPACES.MULTICHAIN &&\n adapter.currentChainNamespace &&\n providedChainConfig.chainNamespace !== adapter.currentChainNamespace\n ) {\n // chainConfig checks are already validated in constructor so using typecast is safe here.\n adapter.setAdapterSettings({ chainConfig: providedChainConfig as CustomChainConfig });\n }\n\n this.walletAdapters[adapter.name] = adapter;\n return this;\n }\n\n public clearCache() {\n if (!storageAvailable(this.storage)) return;\n window[this.storage].removeItem(ADAPTER_CACHE_KEY);\n this.cachedAdapter = null;\n }\n\n public async addChain(chainConfig: CustomChainConfig): Promise<void> {\n if (this.status !== ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw WalletLoginError.notConnectedError(`No wallet is connected`);\n return this.walletAdapters[this.connectedAdapterName].addChain(chainConfig);\n }\n\n public async switchChain(params: { chainId: string }): Promise<void> {\n if (this.status !== ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw WalletLoginError.notConnectedError(`No wallet is connected`);\n return this.walletAdapters[this.connectedAdapterName].switchChain(params);\n }\n\n /**\n * Connect to a specific wallet adapter\n * @param walletName - Key of the walletAdapter to use.\n */\n async connectTo<T>(walletName: WALLET_ADAPTER_TYPE, loginParams?: T): Promise<SafeEventEmitterProvider | null> {\n if (!this.walletAdapters[walletName])\n throw WalletInitializationError.notFound(`Please add wallet adapter for ${walletName} wallet, before connecting`);\n const provider = await this.walletAdapters[walletName].connect(loginParams);\n return provider;\n }\n\n async logout(options: { cleanup: boolean } = { cleanup: false }): Promise<void> {\n if (this.status !== ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw WalletLoginError.notConnectedError(`No wallet is connected`);\n await this.walletAdapters[this.connectedAdapterName].disconnect(options);\n }\n\n async getUserInfo(): Promise<Partial<UserInfo>> {\n log.debug(\"Getting user info\", this.status, this.connectedAdapterName);\n if (this.status !== ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw WalletLoginError.notConnectedError(`No wallet is connected`);\n return this.walletAdapters[this.connectedAdapterName].getUserInfo();\n }\n\n async authenticateUser(): Promise<UserAuthInfo> {\n if (this.status !== ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw WalletLoginError.notConnectedError(`No wallet is connected`);\n return this.walletAdapters[this.connectedAdapterName].authenticateUser();\n }\n\n public async addPlugin(plugin: IPlugin): Promise<IWeb3Auth> {\n if (this.plugins[plugin.name]) throw new Error(`Plugin ${plugin.name} already exist`);\n if (plugin.pluginNamespace !== PLUGIN_NAMESPACES.MULTICHAIN && plugin.pluginNamespace !== this.coreOptions.chainConfig.chainNamespace)\n throw new Error(\n `This plugin belongs to ${plugin.pluginNamespace} namespace which is incompatible with currently used namespace: ${this.coreOptions.chainConfig.chainNamespace}`\n );\n\n this.plugins[plugin.name] = plugin;\n return this;\n }\n\n protected subscribeToAdapterEvents(walletAdapter: IAdapter<unknown>): void {\n walletAdapter.on(ADAPTER_EVENTS.CONNECTED, async (data: CONNECTED_EVENT_DATA) => {\n this.status = ADAPTER_STATUS.CONNECTED;\n this.connectedAdapterName = data.adapter;\n this.cacheWallet(data.adapter);\n log.debug(\"connected\", this.status, this.connectedAdapterName);\n\n Object.values(this.plugins).map(async (plugin) => {\n try {\n if (!plugin.SUPPORTED_ADAPTERS.includes(data.adapter)) {\n return;\n }\n await plugin.initWithWeb3Auth(this);\n await plugin.connect();\n } catch (error: unknown) {\n // swallow error if connector adapter doesn't supports this plugin.\n if ((error as Web3AuthError).code === 5211) {\n return;\n }\n log.error(error);\n }\n });\n\n this.emit(ADAPTER_EVENTS.CONNECTED, { ...data } as CONNECTED_EVENT_DATA);\n });\n\n walletAdapter.on(ADAPTER_EVENTS.DISCONNECTED, async (data) => {\n // get back to ready state for rehydrating.\n this.status = ADAPTER_STATUS.READY;\n if (storageAvailable(this.storage)) {\n const cachedAdapter = window[this.storage].getItem(ADAPTER_CACHE_KEY);\n if (this.connectedAdapterName === cachedAdapter) {\n this.clearCache();\n }\n }\n\n log.debug(\"disconnected\", this.status, this.connectedAdapterName);\n await Promise.all(\n Object.values(this.plugins).map((plugin) => {\n return plugin.disconnect().catch((error: Web3AuthError) => {\n // swallow error if adapter doesn't supports this plugin.\n if (error.code === 5211) {\n return;\n }\n // throw error;\n log.error(error);\n });\n })\n );\n this.connectedAdapterName = null;\n this.emit(ADAPTER_EVENTS.DISCONNECTED, data);\n });\n walletAdapter.on(ADAPTER_EVENTS.CONNECTING, (data) => {\n this.status = ADAPTER_STATUS.CONNECTING;\n this.emit(ADAPTER_EVENTS.CONNECTING, data);\n log.debug(\"connecting\", this.status, this.connectedAdapterName);\n });\n walletAdapter.on(ADAPTER_EVENTS.ERRORED, (data) => {\n this.status = ADAPTER_STATUS.ERRORED;\n this.clearCache();\n this.emit(ADAPTER_EVENTS.ERRORED, data);\n log.debug(\"errored\", this.status, this.connectedAdapterName);\n });\n\n walletAdapter.on(ADAPTER_EVENTS.ADAPTER_DATA_UPDATED, (data) => {\n log.debug(\"adapter data updated\", data);\n this.emit(ADAPTER_EVENTS.ADAPTER_DATA_UPDATED, data);\n });\n\n walletAdapter.on(ADAPTER_EVENTS.CACHE_CLEAR, (data) => {\n log.debug(\"adapter cache clear\", data);\n if (storageAvailable(this.storage)) {\n this.clearCache();\n }\n });\n }\n\n protected checkInitRequirements(): void {\n if (this.status === ADAPTER_STATUS.CONNECTING) throw WalletInitializationError.notReady(\"Already pending connection\");\n if (this.status === ADAPTER_STATUS.CONNECTED) throw WalletInitializationError.notReady(\"Already connected\");\n if (this.status === ADAPTER_STATUS.READY) throw WalletInitializationError.notReady(\"Adapter is already initialized\");\n }\n\n private cacheWallet(walletName: string) {\n if (!storageAvailable(this.storage)) return;\n window[this.storage].setItem(ADAPTER_CACHE_KEY, walletName);\n this.cachedAdapter = walletName;\n }\n}\n","export * from \"./noModal\";\n"],"names":["SafeEventEmitter","ADAPTER_EVENTS","ADAPTER_NAMESPACES","ADAPTER_STATUS","CHAIN_NAMESPACES","getChainConfig","log","storageAvailable","WalletInitializationError","WalletLoginError","PLUGIN_NAMESPACES","ADAPTER_CACHE_KEY","Web3AuthNoModal","constructor","options","_options$chainConfig","_options$chainConfig2","_options$chainConfig3","_options$chainConfig4","_defineProperty","NOT_READY","clientId","invalidParams","enableLogging","enableAll","disableAll","chainConfig","chainNamespace","Object","values","includes","storageKey","storage","cachedAdapter","window","getItem","coreOptions","_objectSpread","chainId","subscribeToAdapterEvents","bind","provider","status","CONNECTED","connectedAdapterName","adapter","walletAdapters","_","Error","init","initPromises","keys","map","adapterName","chainConfigProxy","providedChainConfig","setAdapterSettings","sessionTime","web3AuthNetwork","useCoreKitKey","autoConnect","catch","e","error","READY","Promise","all","configureAdapter","checkInitRequirements","adapterAlreadyExists","name","duplicateAdapterError","adapterNamespace","MULTICHAIN","incompatibleChainNameSpace","currentChainNamespace","clearCache","removeItem","addChain","notConnectedError","switchChain","params","connectTo","walletName","loginParams","notFound","connect","logout","arguments","length","undefined","cleanup","disconnect","getUserInfo","debug","authenticateUser","addPlugin","plugin","plugins","pluginNamespace","walletAdapter","on","data","cacheWallet","SUPPORTED_ADAPTERS","initWithWeb3Auth","code","emit","DISCONNECTED","CONNECTING","ERRORED","ADAPTER_DATA_UPDATED","CACHE_CLEAR","notReady","setItem"],"sourceRoot":""}
@@ -0,0 +1,211 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import { SafeEventEmitter } from '@toruslabs/openlogin-jrpc';
3
+ import { ADAPTER_STATUS, WalletInitializationError, log, CHAIN_NAMESPACES, storageAvailable, getChainConfig, ADAPTER_NAMESPACES, WalletLoginError, ADAPTER_EVENTS } from '@web3auth/base';
4
+ import { PLUGIN_NAMESPACES } from '@web3auth/base-plugin';
5
+
6
+ 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; }
7
+ 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(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; }
8
+ const ADAPTER_CACHE_KEY = "Web3Auth-cachedAdapter";
9
+ class Web3AuthNoModal extends SafeEventEmitter {
10
+ constructor(options) {
11
+ var _options$chainConfig, _options$chainConfig2, _options$chainConfig3, _options$chainConfig4;
12
+ super();
13
+ _defineProperty(this, "coreOptions", void 0);
14
+ _defineProperty(this, "connectedAdapterName", null);
15
+ _defineProperty(this, "status", ADAPTER_STATUS.NOT_READY);
16
+ _defineProperty(this, "cachedAdapter", null);
17
+ _defineProperty(this, "walletAdapters", {});
18
+ _defineProperty(this, "plugins", {});
19
+ _defineProperty(this, "storage", "localStorage");
20
+ if (!options.clientId) throw WalletInitializationError.invalidParams("Please provide a valid clientId in constructor");
21
+ if (options.enableLogging) log.enableAll();else log.disableAll();
22
+ if (!((_options$chainConfig = options.chainConfig) !== null && _options$chainConfig !== void 0 && _options$chainConfig.chainNamespace) || !Object.values(CHAIN_NAMESPACES).includes((_options$chainConfig2 = options.chainConfig) === null || _options$chainConfig2 === void 0 ? void 0 : _options$chainConfig2.chainNamespace)) throw WalletInitializationError.invalidParams("Please provide a valid chainNamespace in chainConfig");
23
+ if (options.storageKey === "session") this.storage = "sessionStorage";
24
+ this.cachedAdapter = storageAvailable(this.storage) ? window[this.storage].getItem(ADAPTER_CACHE_KEY) : null;
25
+ this.coreOptions = _objectSpread(_objectSpread({}, options), {}, {
26
+ chainConfig: _objectSpread(_objectSpread({}, getChainConfig((_options$chainConfig3 = options.chainConfig) === null || _options$chainConfig3 === void 0 ? void 0 : _options$chainConfig3.chainNamespace, (_options$chainConfig4 = options.chainConfig) === null || _options$chainConfig4 === void 0 ? void 0 : _options$chainConfig4.chainId) || {}), options.chainConfig)
27
+ });
28
+ this.subscribeToAdapterEvents = this.subscribeToAdapterEvents.bind(this);
29
+ }
30
+ get provider() {
31
+ if (this.status === ADAPTER_STATUS.CONNECTED && this.connectedAdapterName) {
32
+ const adapter = this.walletAdapters[this.connectedAdapterName];
33
+ return adapter.provider;
34
+ }
35
+ return null;
36
+ }
37
+ set provider(_) {
38
+ throw new Error("Not implemented");
39
+ }
40
+ async init() {
41
+ const initPromises = Object.keys(this.walletAdapters).map(adapterName => {
42
+ this.subscribeToAdapterEvents(this.walletAdapters[adapterName]);
43
+ // if adapter doesn't have any chain config yet thn set it based on provided namespace and chainId.
44
+ // if no chainNamespace or chainId is being provided, it will connect with mainnet.
45
+ if (!this.walletAdapters[adapterName].chainConfigProxy) {
46
+ const providedChainConfig = this.coreOptions.chainConfig;
47
+ if (!providedChainConfig.chainNamespace) throw WalletInitializationError.invalidParams("Please provide chainNamespace in chainConfig");
48
+ this.walletAdapters[adapterName].setAdapterSettings({
49
+ chainConfig: providedChainConfig,
50
+ sessionTime: this.coreOptions.sessionTime,
51
+ clientId: this.coreOptions.clientId,
52
+ web3AuthNetwork: this.coreOptions.web3AuthNetwork,
53
+ useCoreKitKey: this.coreOptions.useCoreKitKey
54
+ });
55
+ } else {
56
+ this.walletAdapters[adapterName].setAdapterSettings({
57
+ sessionTime: this.coreOptions.sessionTime,
58
+ clientId: this.coreOptions.clientId,
59
+ web3AuthNetwork: this.coreOptions.web3AuthNetwork,
60
+ useCoreKitKey: this.coreOptions.useCoreKitKey
61
+ });
62
+ }
63
+ return this.walletAdapters[adapterName].init({
64
+ autoConnect: this.cachedAdapter === adapterName
65
+ }).catch(e => log.error(e));
66
+ });
67
+ this.status = ADAPTER_STATUS.READY;
68
+ await Promise.all(initPromises);
69
+ }
70
+ configureAdapter(adapter) {
71
+ this.checkInitRequirements();
72
+ const providedChainConfig = this.coreOptions.chainConfig;
73
+ if (!providedChainConfig.chainNamespace) throw WalletInitializationError.invalidParams("Please provide chainNamespace in chainConfig");
74
+ const adapterAlreadyExists = this.walletAdapters[adapter.name];
75
+ if (adapterAlreadyExists) throw WalletInitializationError.duplicateAdapterError(`Wallet adapter for ${adapter.name} already exists`);
76
+ if (adapter.adapterNamespace !== ADAPTER_NAMESPACES.MULTICHAIN && adapter.adapterNamespace !== providedChainConfig.chainNamespace) throw WalletInitializationError.incompatibleChainNameSpace(`This wallet adapter belongs to ${adapter.adapterNamespace} which is incompatible with currently used namespace: ${providedChainConfig.chainNamespace}`);
77
+ if (adapter.adapterNamespace === ADAPTER_NAMESPACES.MULTICHAIN && adapter.currentChainNamespace && providedChainConfig.chainNamespace !== adapter.currentChainNamespace) {
78
+ // chainConfig checks are already validated in constructor so using typecast is safe here.
79
+ adapter.setAdapterSettings({
80
+ chainConfig: providedChainConfig
81
+ });
82
+ }
83
+ this.walletAdapters[adapter.name] = adapter;
84
+ return this;
85
+ }
86
+ clearCache() {
87
+ if (!storageAvailable(this.storage)) return;
88
+ window[this.storage].removeItem(ADAPTER_CACHE_KEY);
89
+ this.cachedAdapter = null;
90
+ }
91
+ async addChain(chainConfig) {
92
+ if (this.status !== ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw WalletLoginError.notConnectedError(`No wallet is connected`);
93
+ return this.walletAdapters[this.connectedAdapterName].addChain(chainConfig);
94
+ }
95
+ async switchChain(params) {
96
+ if (this.status !== ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw WalletLoginError.notConnectedError(`No wallet is connected`);
97
+ return this.walletAdapters[this.connectedAdapterName].switchChain(params);
98
+ }
99
+ /**
100
+ * Connect to a specific wallet adapter
101
+ * @param walletName - Key of the walletAdapter to use.
102
+ */
103
+ async connectTo(walletName, loginParams) {
104
+ if (!this.walletAdapters[walletName]) throw WalletInitializationError.notFound(`Please add wallet adapter for ${walletName} wallet, before connecting`);
105
+ const provider = await this.walletAdapters[walletName].connect(loginParams);
106
+ return provider;
107
+ }
108
+ async logout() {
109
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
110
+ cleanup: false
111
+ };
112
+ if (this.status !== ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw WalletLoginError.notConnectedError(`No wallet is connected`);
113
+ await this.walletAdapters[this.connectedAdapterName].disconnect(options);
114
+ }
115
+ async getUserInfo() {
116
+ log.debug("Getting user info", this.status, this.connectedAdapterName);
117
+ if (this.status !== ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw WalletLoginError.notConnectedError(`No wallet is connected`);
118
+ return this.walletAdapters[this.connectedAdapterName].getUserInfo();
119
+ }
120
+ async authenticateUser() {
121
+ if (this.status !== ADAPTER_STATUS.CONNECTED || !this.connectedAdapterName) throw WalletLoginError.notConnectedError(`No wallet is connected`);
122
+ return this.walletAdapters[this.connectedAdapterName].authenticateUser();
123
+ }
124
+ async addPlugin(plugin) {
125
+ if (this.plugins[plugin.name]) throw new Error(`Plugin ${plugin.name} already exist`);
126
+ if (plugin.pluginNamespace !== PLUGIN_NAMESPACES.MULTICHAIN && plugin.pluginNamespace !== this.coreOptions.chainConfig.chainNamespace) throw new Error(`This plugin belongs to ${plugin.pluginNamespace} namespace which is incompatible with currently used namespace: ${this.coreOptions.chainConfig.chainNamespace}`);
127
+ this.plugins[plugin.name] = plugin;
128
+ return this;
129
+ }
130
+ subscribeToAdapterEvents(walletAdapter) {
131
+ walletAdapter.on(ADAPTER_EVENTS.CONNECTED, async data => {
132
+ this.status = ADAPTER_STATUS.CONNECTED;
133
+ this.connectedAdapterName = data.adapter;
134
+ this.cacheWallet(data.adapter);
135
+ log.debug("connected", this.status, this.connectedAdapterName);
136
+ Object.values(this.plugins).map(async plugin => {
137
+ try {
138
+ if (!plugin.SUPPORTED_ADAPTERS.includes(data.adapter)) {
139
+ return;
140
+ }
141
+ await plugin.initWithWeb3Auth(this);
142
+ await plugin.connect();
143
+ } catch (error) {
144
+ // swallow error if connector adapter doesn't supports this plugin.
145
+ if (error.code === 5211) {
146
+ return;
147
+ }
148
+ log.error(error);
149
+ }
150
+ });
151
+ this.emit(ADAPTER_EVENTS.CONNECTED, _objectSpread({}, data));
152
+ });
153
+ walletAdapter.on(ADAPTER_EVENTS.DISCONNECTED, async data => {
154
+ // get back to ready state for rehydrating.
155
+ this.status = ADAPTER_STATUS.READY;
156
+ if (storageAvailable(this.storage)) {
157
+ const cachedAdapter = window[this.storage].getItem(ADAPTER_CACHE_KEY);
158
+ if (this.connectedAdapterName === cachedAdapter) {
159
+ this.clearCache();
160
+ }
161
+ }
162
+ log.debug("disconnected", this.status, this.connectedAdapterName);
163
+ await Promise.all(Object.values(this.plugins).map(plugin => {
164
+ return plugin.disconnect().catch(error => {
165
+ // swallow error if adapter doesn't supports this plugin.
166
+ if (error.code === 5211) {
167
+ return;
168
+ }
169
+ // throw error;
170
+ log.error(error);
171
+ });
172
+ }));
173
+ this.connectedAdapterName = null;
174
+ this.emit(ADAPTER_EVENTS.DISCONNECTED, data);
175
+ });
176
+ walletAdapter.on(ADAPTER_EVENTS.CONNECTING, data => {
177
+ this.status = ADAPTER_STATUS.CONNECTING;
178
+ this.emit(ADAPTER_EVENTS.CONNECTING, data);
179
+ log.debug("connecting", this.status, this.connectedAdapterName);
180
+ });
181
+ walletAdapter.on(ADAPTER_EVENTS.ERRORED, data => {
182
+ this.status = ADAPTER_STATUS.ERRORED;
183
+ this.clearCache();
184
+ this.emit(ADAPTER_EVENTS.ERRORED, data);
185
+ log.debug("errored", this.status, this.connectedAdapterName);
186
+ });
187
+ walletAdapter.on(ADAPTER_EVENTS.ADAPTER_DATA_UPDATED, data => {
188
+ log.debug("adapter data updated", data);
189
+ this.emit(ADAPTER_EVENTS.ADAPTER_DATA_UPDATED, data);
190
+ });
191
+ walletAdapter.on(ADAPTER_EVENTS.CACHE_CLEAR, data => {
192
+ log.debug("adapter cache clear", data);
193
+ if (storageAvailable(this.storage)) {
194
+ this.clearCache();
195
+ }
196
+ });
197
+ }
198
+ checkInitRequirements() {
199
+ if (this.status === ADAPTER_STATUS.CONNECTING) throw WalletInitializationError.notReady("Already pending connection");
200
+ if (this.status === ADAPTER_STATUS.CONNECTED) throw WalletInitializationError.notReady("Already connected");
201
+ if (this.status === ADAPTER_STATUS.READY) throw WalletInitializationError.notReady("Adapter is already initialized");
202
+ }
203
+ cacheWallet(walletName) {
204
+ if (!storageAvailable(this.storage)) return;
205
+ window[this.storage].setItem(ADAPTER_CACHE_KEY, walletName);
206
+ this.cachedAdapter = walletName;
207
+ }
208
+ }
209
+
210
+ export { Web3AuthNoModal };
211
+ //# sourceMappingURL=noModal.esm.js.map