@web3auth/no-modal 8.1.0 → 8.2.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/dist/noModal.cjs.js +6 -266
- package/dist/noModal.umd.min.js +1 -1
- package/package.json +7 -7
package/dist/noModal.cjs.js
CHANGED
|
@@ -68,274 +68,14 @@ const base_namespaceObject = require("@web3auth/base");
|
|
|
68
68
|
const base_plugin_namespaceObject = require("@web3auth/base-plugin");
|
|
69
69
|
;// CONCATENATED MODULE: external "@web3auth/base-provider"
|
|
70
70
|
const base_provider_namespaceObject = require("@web3auth/base-provider");
|
|
71
|
-
;// CONCATENATED MODULE: external "@
|
|
72
|
-
const
|
|
73
|
-
;// CONCATENATED MODULE: external "@toruslabs/openlogin"
|
|
74
|
-
const openlogin_namespaceObject = require("@toruslabs/openlogin");
|
|
75
|
-
var openlogin_default = /*#__PURE__*/__webpack_require__.n(openlogin_namespaceObject);
|
|
76
|
-
;// CONCATENATED MODULE: external "lodash.merge"
|
|
77
|
-
const external_lodash_merge_namespaceObject = require("lodash.merge");
|
|
78
|
-
var external_lodash_merge_default = /*#__PURE__*/__webpack_require__.n(external_lodash_merge_namespaceObject);
|
|
79
|
-
;// CONCATENATED MODULE: ../adapters/openlogin-adapter/dist/openloginAdapter.esm.js
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const getOpenloginDefaultOptions = () => {
|
|
88
|
-
return {
|
|
89
|
-
adapterSettings: {
|
|
90
|
-
network: openlogin_utils_namespaceObject.OPENLOGIN_NETWORK.SAPPHIRE_MAINNET,
|
|
91
|
-
clientId: "",
|
|
92
|
-
uxMode: openlogin_utils_namespaceObject.UX_MODE.POPUP
|
|
93
|
-
},
|
|
94
|
-
loginSettings: {},
|
|
95
|
-
privateKeyProvider: undefined
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
class OpenloginAdapter extends base_namespaceObject.BaseAdapter {
|
|
99
|
-
constructor() {
|
|
100
|
-
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
101
|
-
super(params);
|
|
102
|
-
defineProperty_default()(this, "name", base_namespaceObject.WALLET_ADAPTERS.OPENLOGIN);
|
|
103
|
-
defineProperty_default()(this, "adapterNamespace", base_namespaceObject.ADAPTER_NAMESPACES.MULTICHAIN);
|
|
104
|
-
defineProperty_default()(this, "type", base_namespaceObject.ADAPTER_CATEGORY.IN_APP);
|
|
105
|
-
defineProperty_default()(this, "openloginInstance", null);
|
|
106
|
-
defineProperty_default()(this, "status", base_namespaceObject.ADAPTER_STATUS.NOT_READY);
|
|
107
|
-
defineProperty_default()(this, "currentChainNamespace", base_namespaceObject.CHAIN_NAMESPACES.EIP155);
|
|
108
|
-
defineProperty_default()(this, "privateKeyProvider", null);
|
|
109
|
-
defineProperty_default()(this, "openloginOptions", void 0);
|
|
110
|
-
defineProperty_default()(this, "loginSettings", {
|
|
111
|
-
loginProvider: ""
|
|
112
|
-
});
|
|
113
|
-
this.setAdapterSettings(objectSpread2_default()(objectSpread2_default()({}, params.adapterSettings), {}, {
|
|
114
|
-
chainConfig: params.chainConfig,
|
|
115
|
-
clientId: params.clientId || "",
|
|
116
|
-
sessionTime: params.sessionTime,
|
|
117
|
-
web3AuthNetwork: params.web3AuthNetwork,
|
|
118
|
-
useCoreKitKey: params.useCoreKitKey,
|
|
119
|
-
privateKeyProvider: params.privateKeyProvider
|
|
120
|
-
}));
|
|
121
|
-
this.loginSettings = params.loginSettings || {
|
|
122
|
-
loginProvider: ""
|
|
123
|
-
};
|
|
124
|
-
this.privateKeyProvider = params.privateKeyProvider || null;
|
|
125
|
-
}
|
|
126
|
-
get chainConfigProxy() {
|
|
127
|
-
return this.chainConfig ? objectSpread2_default()({}, this.chainConfig) : null;
|
|
128
|
-
}
|
|
129
|
-
get provider() {
|
|
130
|
-
if (this.status !== base_namespaceObject.ADAPTER_STATUS.NOT_READY && this.privateKeyProvider) {
|
|
131
|
-
return this.privateKeyProvider;
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
set provider(_) {
|
|
136
|
-
throw new Error("Not implemented");
|
|
137
|
-
}
|
|
138
|
-
async init(options) {
|
|
139
|
-
super.checkInitializationRequirements();
|
|
140
|
-
if (!this.clientId) throw base_namespaceObject.WalletInitializationError.invalidParams("clientId is required before openlogin's initialization");
|
|
141
|
-
if (!this.openloginOptions) throw base_namespaceObject.WalletInitializationError.invalidParams("openloginOptions is required before openlogin's initialization");
|
|
142
|
-
const isRedirectResult = this.openloginOptions.uxMode === openlogin_utils_namespaceObject.UX_MODE.REDIRECT;
|
|
143
|
-
this.openloginOptions = objectSpread2_default()(objectSpread2_default()({}, this.openloginOptions), {}, {
|
|
144
|
-
replaceUrlOnRedirect: isRedirectResult
|
|
145
|
-
});
|
|
146
|
-
this.openloginInstance = new (openlogin_default())(objectSpread2_default()(objectSpread2_default()({}, this.openloginOptions), {}, {
|
|
147
|
-
clientId: this.clientId,
|
|
148
|
-
network: this.openloginOptions.network || this.web3AuthNetwork || openlogin_utils_namespaceObject.OPENLOGIN_NETWORK.SAPPHIRE_MAINNET
|
|
149
|
-
}));
|
|
150
|
-
base_namespaceObject.log.debug("initializing openlogin adapter init");
|
|
151
|
-
await this.openloginInstance.init();
|
|
152
|
-
if (!this.chainConfig) throw base_namespaceObject.WalletInitializationError.invalidParams("chainConfig is required before initialization");
|
|
153
|
-
this.status = base_namespaceObject.ADAPTER_STATUS.READY;
|
|
154
|
-
this.emit(base_namespaceObject.ADAPTER_EVENTS.READY, base_namespaceObject.WALLET_ADAPTERS.OPENLOGIN);
|
|
155
|
-
try {
|
|
156
|
-
base_namespaceObject.log.debug("initializing openlogin adapter");
|
|
157
|
-
const finalPrivKey = this._getFinalPrivKey();
|
|
158
|
-
// connect only if it is redirect result or if connect (adapter is cached/already connected in same session) is true
|
|
159
|
-
if (finalPrivKey && (options.autoConnect || isRedirectResult)) {
|
|
160
|
-
this.rehydrated = true;
|
|
161
|
-
await this.connect();
|
|
162
|
-
}
|
|
163
|
-
} catch (error) {
|
|
164
|
-
base_namespaceObject.log.error("Failed to connect with cached openlogin provider", error);
|
|
165
|
-
this.emit("ERRORED", error);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
async connect() {
|
|
169
|
-
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
170
|
-
loginProvider: ""
|
|
171
|
-
};
|
|
172
|
-
super.checkConnectionRequirements();
|
|
173
|
-
this.status = base_namespaceObject.ADAPTER_STATUS.CONNECTING;
|
|
174
|
-
this.emit(base_namespaceObject.ADAPTER_EVENTS.CONNECTING, objectSpread2_default()(objectSpread2_default()({}, params), {}, {
|
|
175
|
-
adapter: base_namespaceObject.WALLET_ADAPTERS.OPENLOGIN
|
|
176
|
-
}));
|
|
177
|
-
try {
|
|
178
|
-
await this.connectWithProvider(params);
|
|
179
|
-
return this.provider;
|
|
180
|
-
} catch (error) {
|
|
181
|
-
base_namespaceObject.log.error("Failed to connect with openlogin provider", error);
|
|
182
|
-
// ready again to be connected
|
|
183
|
-
this.status = base_namespaceObject.ADAPTER_STATUS.READY;
|
|
184
|
-
this.emit(base_namespaceObject.ADAPTER_EVENTS.ERRORED, error);
|
|
185
|
-
if (error !== null && error !== void 0 && error.message.includes("user closed popup")) {
|
|
186
|
-
throw base_namespaceObject.WalletLoginError.popupClosed();
|
|
187
|
-
} else if (error instanceof base_namespaceObject.Web3AuthError) {
|
|
188
|
-
throw error;
|
|
189
|
-
}
|
|
190
|
-
throw base_namespaceObject.WalletLoginError.connectionError("Failed to login with openlogin");
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
async enableMFA() {
|
|
194
|
-
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
195
|
-
loginProvider: ""
|
|
196
|
-
};
|
|
197
|
-
if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED) throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet");
|
|
198
|
-
if (!this.openloginInstance) throw base_namespaceObject.WalletInitializationError.notReady("openloginInstance is not ready");
|
|
199
|
-
try {
|
|
200
|
-
await this.openloginInstance.enableMFA(params);
|
|
201
|
-
} catch (error) {
|
|
202
|
-
base_namespaceObject.log.error("Failed to enable MFA with openlogin provider", error);
|
|
203
|
-
if (error instanceof base_namespaceObject.Web3AuthError) {
|
|
204
|
-
throw error;
|
|
205
|
-
}
|
|
206
|
-
throw base_namespaceObject.WalletLoginError.connectionError(error.message || "Failed to enable MFA with openlogin");
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
async disconnect() {
|
|
210
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
211
|
-
cleanup: false
|
|
212
|
-
};
|
|
213
|
-
if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED) throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet");
|
|
214
|
-
if (!this.openloginInstance) throw base_namespaceObject.WalletInitializationError.notReady("openloginInstance is not ready");
|
|
215
|
-
await this.openloginInstance.logout();
|
|
216
|
-
if (options.cleanup) {
|
|
217
|
-
this.status = base_namespaceObject.ADAPTER_STATUS.NOT_READY;
|
|
218
|
-
this.openloginInstance = null;
|
|
219
|
-
this.privateKeyProvider = null;
|
|
220
|
-
} else {
|
|
221
|
-
// ready to be connected again
|
|
222
|
-
this.status = base_namespaceObject.ADAPTER_STATUS.READY;
|
|
223
|
-
}
|
|
224
|
-
this.rehydrated = false;
|
|
225
|
-
this.emit(base_namespaceObject.ADAPTER_EVENTS.DISCONNECTED);
|
|
226
|
-
}
|
|
227
|
-
async authenticateUser() {
|
|
228
|
-
if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED) throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet, Please login/connect first");
|
|
229
|
-
const userInfo = await this.getUserInfo();
|
|
230
|
-
return {
|
|
231
|
-
idToken: userInfo.idToken
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
async getUserInfo() {
|
|
235
|
-
if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED) throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet");
|
|
236
|
-
if (!this.openloginInstance) throw base_namespaceObject.WalletInitializationError.notReady("openloginInstance is not ready");
|
|
237
|
-
const userInfo = this.openloginInstance.getUserInfo();
|
|
238
|
-
return userInfo;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// should be called only before initialization.
|
|
242
|
-
setAdapterSettings(adapterSettings) {
|
|
243
|
-
super.setAdapterSettings(adapterSettings);
|
|
244
|
-
const defaultOptions = getOpenloginDefaultOptions();
|
|
245
|
-
base_namespaceObject.log.info("setting adapter settings", adapterSettings);
|
|
246
|
-
this.openloginOptions = objectSpread2_default()(objectSpread2_default()(objectSpread2_default()({}, defaultOptions.adapterSettings), this.openloginOptions), adapterSettings);
|
|
247
|
-
if (adapterSettings.web3AuthNetwork) {
|
|
248
|
-
this.openloginOptions.network = adapterSettings.web3AuthNetwork;
|
|
249
|
-
}
|
|
250
|
-
if (adapterSettings.privateKeyProvider) {
|
|
251
|
-
this.privateKeyProvider = adapterSettings.privateKeyProvider;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
async addChain(chainConfig) {
|
|
255
|
-
var _this$privateKeyProvi;
|
|
256
|
-
let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
257
|
-
super.checkAddChainRequirements(chainConfig, init);
|
|
258
|
-
(_this$privateKeyProvi = this.privateKeyProvider) === null || _this$privateKeyProvi === void 0 || _this$privateKeyProvi.addChain(chainConfig);
|
|
259
|
-
this.addChainConfig(chainConfig);
|
|
260
|
-
}
|
|
261
|
-
async switchChain(params) {
|
|
262
|
-
var _this$privateKeyProvi2;
|
|
263
|
-
let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
264
|
-
super.checkSwitchChainRequirements(params, init);
|
|
265
|
-
await ((_this$privateKeyProvi2 = this.privateKeyProvider) === null || _this$privateKeyProvi2 === void 0 ? void 0 : _this$privateKeyProvi2.switchChain(params));
|
|
266
|
-
this.setAdapterSettings({
|
|
267
|
-
chainConfig: this.getChainConfig(params.chainId)
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
_getFinalPrivKey() {
|
|
271
|
-
if (!this.openloginInstance) return "";
|
|
272
|
-
let finalPrivKey = this.openloginInstance.privKey;
|
|
273
|
-
// coreKitKey is available only for custom verifiers by default
|
|
274
|
-
if (this.useCoreKitKey) {
|
|
275
|
-
// this is to check if the user has already logged in but coreKitKey is not available.
|
|
276
|
-
// when useCoreKitKey is set to true.
|
|
277
|
-
// This is to ensure that when there is no user session active, we don't throw an exception.
|
|
278
|
-
if (this.openloginInstance.privKey && !this.openloginInstance.coreKitKey) {
|
|
279
|
-
throw base_namespaceObject.WalletLoginError.coreKitKeyNotFound();
|
|
280
|
-
}
|
|
281
|
-
finalPrivKey = this.openloginInstance.coreKitKey;
|
|
282
|
-
}
|
|
283
|
-
return finalPrivKey;
|
|
284
|
-
}
|
|
285
|
-
_getFinalEd25519PrivKey() {
|
|
286
|
-
if (!this.openloginInstance) return "";
|
|
287
|
-
let finalPrivKey = this.openloginInstance.ed25519PrivKey;
|
|
288
|
-
// coreKitKey is available only for custom verifiers by default
|
|
289
|
-
if (this.useCoreKitKey) {
|
|
290
|
-
// this is to check if the user has already logged in but coreKitKey is not available.
|
|
291
|
-
// when useCoreKitKey is set to true.
|
|
292
|
-
// This is to ensure that when there is no user session active, we don't throw an exception.
|
|
293
|
-
if (this.openloginInstance.ed25519PrivKey && !this.openloginInstance.coreKitEd25519Key) {
|
|
294
|
-
throw base_namespaceObject.WalletLoginError.coreKitKeyNotFound();
|
|
295
|
-
}
|
|
296
|
-
finalPrivKey = this.openloginInstance.coreKitEd25519Key;
|
|
297
|
-
}
|
|
298
|
-
return finalPrivKey;
|
|
299
|
-
}
|
|
300
|
-
async connectWithProvider() {
|
|
301
|
-
var _params$extraLoginOpt;
|
|
302
|
-
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
303
|
-
loginProvider: ""
|
|
304
|
-
};
|
|
305
|
-
if (!this.privateKeyProvider) throw base_namespaceObject.WalletInitializationError.invalidParams("PrivateKey Provider is required before initialization");
|
|
306
|
-
if (!this.openloginInstance) throw base_namespaceObject.WalletInitializationError.notReady("openloginInstance is not ready");
|
|
307
|
-
const keyAvailable = this._getFinalPrivKey();
|
|
308
|
-
// if not logged in then login
|
|
309
|
-
if (!keyAvailable || (_params$extraLoginOpt = params.extraLoginOptions) !== null && _params$extraLoginOpt !== void 0 && _params$extraLoginOpt.id_token) {
|
|
310
|
-
var _params$extraLoginOpt2;
|
|
311
|
-
if (!this.loginSettings.curve) {
|
|
312
|
-
this.loginSettings.curve = this.currentChainNamespace === base_namespaceObject.CHAIN_NAMESPACES.SOLANA ? openlogin_utils_namespaceObject.SUPPORTED_KEY_CURVES.ED25519 : openlogin_utils_namespaceObject.SUPPORTED_KEY_CURVES.SECP256K1;
|
|
313
|
-
}
|
|
314
|
-
if (!params.loginProvider && !this.loginSettings.loginProvider) throw base_namespaceObject.WalletInitializationError.invalidParams("loginProvider is required for login");
|
|
315
|
-
await this.openloginInstance.login(external_lodash_merge_default()(this.loginSettings, params, {
|
|
316
|
-
extraLoginOptions: objectSpread2_default()(objectSpread2_default()({}, params.extraLoginOptions || {}), {}, {
|
|
317
|
-
login_hint: params.login_hint || ((_params$extraLoginOpt2 = params.extraLoginOptions) === null || _params$extraLoginOpt2 === void 0 ? void 0 : _params$extraLoginOpt2.login_hint)
|
|
318
|
-
})
|
|
319
|
-
}));
|
|
320
|
-
}
|
|
321
|
-
let finalPrivKey = this._getFinalPrivKey();
|
|
322
|
-
if (finalPrivKey) {
|
|
323
|
-
if (this.currentChainNamespace === base_namespaceObject.CHAIN_NAMESPACES.SOLANA) {
|
|
324
|
-
finalPrivKey = this._getFinalEd25519PrivKey();
|
|
325
|
-
}
|
|
326
|
-
await this.privateKeyProvider.setupProvider(finalPrivKey);
|
|
327
|
-
this.status = base_namespaceObject.ADAPTER_STATUS.CONNECTED;
|
|
328
|
-
this.emit(base_namespaceObject.ADAPTER_EVENTS.CONNECTED, {
|
|
329
|
-
adapter: base_namespaceObject.WALLET_ADAPTERS.OPENLOGIN,
|
|
330
|
-
reconnected: this.rehydrated
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
71
|
+
;// CONCATENATED MODULE: external "@web3auth/openlogin-adapter"
|
|
72
|
+
const openlogin_adapter_namespaceObject = require("@web3auth/openlogin-adapter");
|
|
336
73
|
;// CONCATENATED MODULE: external "lodash.clonedeep"
|
|
337
74
|
const external_lodash_clonedeep_namespaceObject = require("lodash.clonedeep");
|
|
338
75
|
var external_lodash_clonedeep_default = /*#__PURE__*/__webpack_require__.n(external_lodash_clonedeep_namespaceObject);
|
|
76
|
+
;// CONCATENATED MODULE: external "lodash.merge"
|
|
77
|
+
const external_lodash_merge_namespaceObject = require("lodash.merge");
|
|
78
|
+
var external_lodash_merge_default = /*#__PURE__*/__webpack_require__.n(external_lodash_merge_namespaceObject);
|
|
339
79
|
;// CONCATENATED MODULE: ./src/noModal.ts
|
|
340
80
|
|
|
341
81
|
|
|
@@ -429,7 +169,7 @@ class Web3AuthNoModal extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
|
|
|
429
169
|
if (smsOtpEnabled !== undefined) {
|
|
430
170
|
openloginAdapter.setAdapterSettings({
|
|
431
171
|
loginConfig: {
|
|
432
|
-
[
|
|
172
|
+
[openlogin_adapter_namespaceObject.LOGIN_PROVIDER.SMS_PASSWORDLESS]: {
|
|
433
173
|
showOnModal: smsOtpEnabled,
|
|
434
174
|
showOnDesktop: smsOtpEnabled,
|
|
435
175
|
showOnMobile: smsOtpEnabled,
|