@web3auth/no-modal 8.8.0 → 8.9.1
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/dist/noModal.cjs.js +36 -26
- package/dist/noModal.esm.js +37 -27
- package/dist/noModal.umd.min.js +1 -1
- package/dist/types/noModal.d.ts +1 -0
- package/package.json +2 -2
package/dist/noModal.cjs.js
CHANGED
|
@@ -298,6 +298,12 @@ class Web3AuthNoModal extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
|
|
|
298
298
|
if (this.plugins[plugin.name]) throw base_namespaceObject.WalletInitializationError.duplicateAdapterError(`Plugin ${plugin.name} already exist`);
|
|
299
299
|
if (plugin.pluginNamespace !== base_namespaceObject.PLUGIN_NAMESPACES.MULTICHAIN && plugin.pluginNamespace !== this.coreOptions.chainConfig.chainNamespace) throw base_namespaceObject.WalletInitializationError.incompatibleChainNameSpace(`This plugin belongs to ${plugin.pluginNamespace} namespace which is incompatible with currently used namespace: ${this.coreOptions.chainConfig.chainNamespace}`);
|
|
300
300
|
this.plugins[plugin.name] = plugin;
|
|
301
|
+
if (this.status === base_namespaceObject.ADAPTER_STATUS.CONNECTED && this.connectedAdapterName) {
|
|
302
|
+
// web3auth is already connected. can initialize plugins
|
|
303
|
+
this.connectToPlugins({
|
|
304
|
+
adapter: this.connectedAdapterName
|
|
305
|
+
});
|
|
306
|
+
}
|
|
301
307
|
return this;
|
|
302
308
|
}
|
|
303
309
|
getPlugin(name) {
|
|
@@ -314,32 +320,7 @@ class Web3AuthNoModal extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
|
|
|
314
320
|
this.connectedAdapterName = data.adapter;
|
|
315
321
|
this.cacheWallet(data.adapter);
|
|
316
322
|
base_namespaceObject.log.debug("connected", this.status, this.connectedAdapterName);
|
|
317
|
-
|
|
318
|
-
try {
|
|
319
|
-
if (!plugin.SUPPORTED_ADAPTERS.includes(data.adapter)) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
const {
|
|
323
|
-
openloginInstance
|
|
324
|
-
} = this.walletAdapters[this.connectedAdapterName];
|
|
325
|
-
const {
|
|
326
|
-
options,
|
|
327
|
-
sessionId,
|
|
328
|
-
sessionNamespace
|
|
329
|
-
} = openloginInstance || {};
|
|
330
|
-
await plugin.initWithWeb3Auth(this, options.whiteLabel);
|
|
331
|
-
await plugin.connect({
|
|
332
|
-
sessionId,
|
|
333
|
-
sessionNamespace
|
|
334
|
-
});
|
|
335
|
-
} catch (error) {
|
|
336
|
-
// swallow error if connector adapter doesn't supports this plugin.
|
|
337
|
-
if (error.code === 5211) {
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
base_namespaceObject.log.error(error);
|
|
341
|
-
}
|
|
342
|
-
});
|
|
323
|
+
this.connectToPlugins(data);
|
|
343
324
|
this.emit(base_namespaceObject.ADAPTER_EVENTS.CONNECTED, objectSpread2_default()({}, data));
|
|
344
325
|
});
|
|
345
326
|
walletAdapter.on(base_namespaceObject.ADAPTER_EVENTS.DISCONNECTED, async data => {
|
|
@@ -397,6 +378,35 @@ class Web3AuthNoModal extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
|
|
|
397
378
|
window[this.storage].setItem(ADAPTER_CACHE_KEY, walletName);
|
|
398
379
|
this.cachedAdapter = walletName;
|
|
399
380
|
}
|
|
381
|
+
connectToPlugins(data) {
|
|
382
|
+
Object.values(this.plugins).map(async plugin => {
|
|
383
|
+
try {
|
|
384
|
+
if (!plugin.SUPPORTED_ADAPTERS.includes(data.adapter)) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (plugin.status === base_namespaceObject.PLUGIN_STATUS.CONNECTED) return;
|
|
388
|
+
const {
|
|
389
|
+
openloginInstance
|
|
390
|
+
} = this.walletAdapters[this.connectedAdapterName];
|
|
391
|
+
const {
|
|
392
|
+
options,
|
|
393
|
+
sessionId,
|
|
394
|
+
sessionNamespace
|
|
395
|
+
} = openloginInstance || {};
|
|
396
|
+
await plugin.initWithWeb3Auth(this, options.whiteLabel);
|
|
397
|
+
await plugin.connect({
|
|
398
|
+
sessionId,
|
|
399
|
+
sessionNamespace
|
|
400
|
+
});
|
|
401
|
+
} catch (error) {
|
|
402
|
+
// swallow error if connector adapter doesn't supports this plugin.
|
|
403
|
+
if (error.code === 5211) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
base_namespaceObject.log.error(error);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
400
410
|
}
|
|
401
411
|
;// CONCATENATED MODULE: ./src/index.ts
|
|
402
412
|
|
package/dist/noModal.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import { SafeEventEmitter } from '@toruslabs/openlogin-jrpc';
|
|
4
|
-
import { ADAPTER_STATUS, WalletInitializationError, log, CHAIN_NAMESPACES, storageAvailable, getChainConfig, fetchProjectConfig, WALLET_ADAPTERS, ADAPTER_EVENTS, ADAPTER_NAMESPACES, WalletLoginError, PLUGIN_NAMESPACES } from '@web3auth/base';
|
|
4
|
+
import { ADAPTER_STATUS, WalletInitializationError, log, CHAIN_NAMESPACES, storageAvailable, getChainConfig, fetchProjectConfig, WALLET_ADAPTERS, ADAPTER_EVENTS, ADAPTER_NAMESPACES, WalletLoginError, PLUGIN_NAMESPACES, PLUGIN_STATUS } from '@web3auth/base';
|
|
5
5
|
import { CommonJRPCProvider } from '@web3auth/base-provider';
|
|
6
6
|
import { LOGIN_PROVIDER } from '@web3auth/openlogin-adapter';
|
|
7
7
|
import clonedeep from 'lodash.clonedeep';
|
|
@@ -222,6 +222,12 @@ class Web3AuthNoModal extends SafeEventEmitter {
|
|
|
222
222
|
if (this.plugins[plugin.name]) throw WalletInitializationError.duplicateAdapterError(`Plugin ${plugin.name} already exist`);
|
|
223
223
|
if (plugin.pluginNamespace !== PLUGIN_NAMESPACES.MULTICHAIN && plugin.pluginNamespace !== this.coreOptions.chainConfig.chainNamespace) throw WalletInitializationError.incompatibleChainNameSpace(`This plugin belongs to ${plugin.pluginNamespace} namespace which is incompatible with currently used namespace: ${this.coreOptions.chainConfig.chainNamespace}`);
|
|
224
224
|
this.plugins[plugin.name] = plugin;
|
|
225
|
+
if (this.status === ADAPTER_STATUS.CONNECTED && this.connectedAdapterName) {
|
|
226
|
+
// web3auth is already connected. can initialize plugins
|
|
227
|
+
this.connectToPlugins({
|
|
228
|
+
adapter: this.connectedAdapterName
|
|
229
|
+
});
|
|
230
|
+
}
|
|
225
231
|
return this;
|
|
226
232
|
}
|
|
227
233
|
getPlugin(name) {
|
|
@@ -238,32 +244,7 @@ class Web3AuthNoModal extends SafeEventEmitter {
|
|
|
238
244
|
this.connectedAdapterName = data.adapter;
|
|
239
245
|
this.cacheWallet(data.adapter);
|
|
240
246
|
log.debug("connected", this.status, this.connectedAdapterName);
|
|
241
|
-
|
|
242
|
-
try {
|
|
243
|
-
if (!plugin.SUPPORTED_ADAPTERS.includes(data.adapter)) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
const {
|
|
247
|
-
openloginInstance
|
|
248
|
-
} = this.walletAdapters[this.connectedAdapterName];
|
|
249
|
-
const {
|
|
250
|
-
options,
|
|
251
|
-
sessionId,
|
|
252
|
-
sessionNamespace
|
|
253
|
-
} = openloginInstance || {};
|
|
254
|
-
await plugin.initWithWeb3Auth(this, options.whiteLabel);
|
|
255
|
-
await plugin.connect({
|
|
256
|
-
sessionId,
|
|
257
|
-
sessionNamespace
|
|
258
|
-
});
|
|
259
|
-
} catch (error) {
|
|
260
|
-
// swallow error if connector adapter doesn't supports this plugin.
|
|
261
|
-
if (error.code === 5211) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
log.error(error);
|
|
265
|
-
}
|
|
266
|
-
});
|
|
247
|
+
this.connectToPlugins(data);
|
|
267
248
|
this.emit(ADAPTER_EVENTS.CONNECTED, _objectSpread({}, data));
|
|
268
249
|
});
|
|
269
250
|
walletAdapter.on(ADAPTER_EVENTS.DISCONNECTED, async data => {
|
|
@@ -321,6 +302,35 @@ class Web3AuthNoModal extends SafeEventEmitter {
|
|
|
321
302
|
window[this.storage].setItem(ADAPTER_CACHE_KEY, walletName);
|
|
322
303
|
this.cachedAdapter = walletName;
|
|
323
304
|
}
|
|
305
|
+
connectToPlugins(data) {
|
|
306
|
+
Object.values(this.plugins).map(async plugin => {
|
|
307
|
+
try {
|
|
308
|
+
if (!plugin.SUPPORTED_ADAPTERS.includes(data.adapter)) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (plugin.status === PLUGIN_STATUS.CONNECTED) return;
|
|
312
|
+
const {
|
|
313
|
+
openloginInstance
|
|
314
|
+
} = this.walletAdapters[this.connectedAdapterName];
|
|
315
|
+
const {
|
|
316
|
+
options,
|
|
317
|
+
sessionId,
|
|
318
|
+
sessionNamespace
|
|
319
|
+
} = openloginInstance || {};
|
|
320
|
+
await plugin.initWithWeb3Auth(this, options.whiteLabel);
|
|
321
|
+
await plugin.connect({
|
|
322
|
+
sessionId,
|
|
323
|
+
sessionNamespace
|
|
324
|
+
});
|
|
325
|
+
} catch (error) {
|
|
326
|
+
// swallow error if connector adapter doesn't supports this plugin.
|
|
327
|
+
if (error.code === 5211) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
log.error(error);
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
}
|
|
324
334
|
}
|
|
325
335
|
|
|
326
336
|
export { Web3AuthNoModal };
|