@web3auth/modal 9.5.4 → 10.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/dist/lib.cjs/node_modules/style-inject/dist/style-inject.es.js +28 -0
- package/dist/lib.cjs/{config.js → packages/modal/src/config.js} +14 -14
- package/dist/lib.cjs/{index.js → packages/modal/src/index.js} +7 -0
- package/dist/lib.cjs/{modalManager.js → packages/modal/src/modalManager.js} +92 -92
- package/dist/lib.cjs/packages/modal/src/react/Web3AuthProvider.js +15 -0
- package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +225 -0
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3Auth.js +15 -0
- package/dist/lib.cjs/packages/modal/src/react/index.js +12 -0
- package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-dark.svg.js +7 -0
- package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-light.svg.js +7 -0
- package/dist/lib.cjs/packages/modal/src/ui/assets/x-dark.svg.js +7 -0
- package/dist/lib.cjs/packages/modal/src/ui/assets/x-light.svg.js +7 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/AdapterLoader.js +108 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Button/Button.js +34 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Button/styles.css.js +8 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +44 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +67 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +34 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +46 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +167 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallets.js +273 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Footer.js +20 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Header.js +81 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Icon.js +73 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Image.js +51 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Loader.js +59 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/Modal.js +244 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +30 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginPasswordless.js +141 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/SocialLogins.js +148 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/WalletConnect.js +84 -0
- package/dist/lib.cjs/packages/modal/src/ui/config.js +17 -0
- package/dist/lib.cjs/packages/modal/src/ui/context/ThemeContext.js +9 -0
- package/dist/lib.cjs/packages/modal/src/ui/css/web3auth.css.js +8 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/dutch.json.js +84 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +84 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +82 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +84 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +84 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +84 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +84 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +84 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +84 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +84 -0
- package/dist/lib.cjs/packages/modal/src/ui/interfaces.js +26 -0
- package/dist/lib.cjs/packages/modal/src/ui/localeImport.js +25 -0
- package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +309 -0
- package/dist/lib.cjs/packages/modal/src/ui/utils.js +71 -0
- package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +234 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3Auth.js +12 -0
- package/dist/lib.cjs/packages/modal/src/vue/index.js +9 -0
- package/dist/lib.esm/node_modules/style-inject/dist/style-inject.es.js +26 -0
- package/dist/lib.esm/{config.js → packages/modal/src/config.js} +1 -1
- package/dist/lib.esm/{index.js → packages/modal/src/index.js} +1 -0
- package/dist/lib.esm/{modalManager.js → packages/modal/src/modalManager.js} +5 -5
- package/dist/lib.esm/packages/modal/src/react/Web3AuthProvider.js +13 -0
- package/dist/lib.esm/packages/modal/src/react/context/Web3AuthInnerContext.js +222 -0
- package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3Auth.js +13 -0
- package/dist/lib.esm/packages/modal/src/react/index.js +3 -0
- package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-dark.svg.js +5 -0
- package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-light.svg.js +5 -0
- package/dist/lib.esm/packages/modal/src/ui/assets/x-dark.svg.js +5 -0
- package/dist/lib.esm/packages/modal/src/ui/assets/x-light.svg.js +5 -0
- package/dist/lib.esm/packages/modal/src/ui/components/AdapterLoader.js +106 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Button/Button.js +32 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Button/styles.css.js +6 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +42 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +65 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +32 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +44 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +165 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallets.js +271 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Footer.js +18 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Header.js +79 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Icon.js +71 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Image.js +49 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Loader.js +57 -0
- package/dist/lib.esm/packages/modal/src/ui/components/Modal.js +242 -0
- package/dist/lib.esm/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +28 -0
- package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginPasswordless.js +139 -0
- package/dist/lib.esm/packages/modal/src/ui/components/SocialLogins.js +146 -0
- package/dist/lib.esm/packages/modal/src/ui/components/WalletConnect.js +82 -0
- package/dist/lib.esm/packages/modal/src/ui/config.js +13 -0
- package/dist/lib.esm/packages/modal/src/ui/context/ThemeContext.js +7 -0
- package/dist/lib.esm/packages/modal/src/ui/css/web3auth.css.js +6 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/dutch.json.js +79 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +79 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +77 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +79 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +79 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +79 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +79 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +79 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +79 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +79 -0
- package/dist/lib.esm/packages/modal/src/ui/interfaces.js +20 -0
- package/dist/lib.esm/packages/modal/src/ui/localeImport.js +23 -0
- package/dist/lib.esm/packages/modal/src/ui/loginModal.js +307 -0
- package/dist/lib.esm/packages/modal/src/ui/utils.js +65 -0
- package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +232 -0
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3Auth.js +10 -0
- package/dist/lib.esm/packages/modal/src/vue/index.js +2 -0
- package/dist/modal.cjs.js +5703 -420
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.LICENSE.txt +54 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/interface.d.ts +1 -1
- package/dist/types/modalManager.d.ts +2 -3
- package/dist/types/react/Web3AuthProvider.d.ts +3 -0
- package/dist/types/react/context/Web3AuthInnerContext.d.ts +4 -0
- package/dist/types/react/context/index.d.ts +1 -0
- package/dist/types/react/hooks/index.d.ts +1 -0
- package/dist/types/react/hooks/useWeb3Auth.d.ts +2 -0
- package/dist/types/react/index.d.ts +4 -0
- package/dist/types/react/interfaces.d.ts +18 -0
- package/dist/types/ui/components/AdapterLoader.d.ts +11 -0
- package/dist/types/ui/components/Button/Button.d.ts +16 -0
- package/dist/types/ui/components/Button/index.d.ts +1 -0
- package/dist/types/ui/components/ExternalWallet/ExternalWalletButton.d.ts +7 -0
- package/dist/types/ui/components/ExternalWallet/ExternalWalletConnect.d.ts +9 -0
- package/dist/types/ui/components/ExternalWallet/ExternalWalletDetails.d.ts +9 -0
- package/dist/types/ui/components/ExternalWallet/ExternalWalletHeader.d.ts +8 -0
- package/dist/types/ui/components/ExternalWallet/ExternalWalletInstall.d.ts +8 -0
- package/dist/types/ui/components/ExternalWallets.d.ts +17 -0
- package/dist/types/ui/components/Footer.d.ts +1 -0
- package/dist/types/ui/components/Header.d.ts +8 -0
- package/dist/types/ui/components/Icon.d.ts +9 -0
- package/dist/types/ui/components/Image.d.ts +12 -0
- package/dist/types/ui/components/Loader.d.ts +10 -0
- package/dist/types/ui/components/Modal.d.ts +16 -0
- package/dist/types/ui/components/SelfCustodyViaWeb3Auth.d.ts +1 -0
- package/dist/types/ui/components/SocialLoginPasswordless.d.ts +16 -0
- package/dist/types/ui/components/SocialLogins.d.ts +14 -0
- package/dist/types/ui/components/WalletConnect.d.ts +8 -0
- package/dist/types/ui/config.d.ts +4 -0
- package/dist/types/ui/context/ThemeContext.d.ts +3 -0
- package/dist/types/ui/helper/countryData.d.ts +7 -0
- package/dist/types/ui/i18n/index.d.ts +11 -0
- package/dist/types/ui/index.d.ts +4 -0
- package/dist/types/ui/interfaces.d.ts +106 -0
- package/dist/types/ui/localeImport.d.ts +3 -0
- package/dist/types/ui/loginModal.d.ts +27 -0
- package/dist/types/ui/utils.d.ts +12 -0
- package/dist/types/vue/Web3AuthProvider.d.ts +13 -0
- package/dist/types/vue/composables/index.d.ts +1 -0
- package/dist/types/vue/composables/useWeb3Auth.d.ts +2 -0
- package/dist/types/vue/index.d.ts +3 -0
- package/dist/types/vue/interfaces.d.ts +45 -0
- package/package.json +100 -43
- package/dist/modal.esm.js +0 -513
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
require('./css/web3auth.css.js');
|
|
5
|
+
var auth = require('@web3auth/auth');
|
|
6
|
+
var noModal = require('@web3auth/no-modal');
|
|
7
|
+
var client = require('react-dom/client');
|
|
8
|
+
var Modal = require('./components/Modal.js');
|
|
9
|
+
var ThemeContext = require('./context/ThemeContext.js');
|
|
10
|
+
var interfaces = require('./interfaces.js');
|
|
11
|
+
var localeImport = require('./localeImport.js');
|
|
12
|
+
var utils = require('./utils.js');
|
|
13
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
14
|
+
|
|
15
|
+
function createWrapper(parentZIndex) {
|
|
16
|
+
const existingWrapper = document.getElementById("w3a-parent-container");
|
|
17
|
+
if (existingWrapper) existingWrapper.remove();
|
|
18
|
+
const parent = document.createElement("section");
|
|
19
|
+
parent.classList.add("w3a-parent-container");
|
|
20
|
+
parent.setAttribute("id", "w3a-parent-container");
|
|
21
|
+
parent.style.zIndex = parentZIndex;
|
|
22
|
+
parent.style.position = "relative";
|
|
23
|
+
const wrapper = document.createElement("section");
|
|
24
|
+
wrapper.setAttribute("id", "w3a-container");
|
|
25
|
+
parent.appendChild(wrapper);
|
|
26
|
+
document.body.appendChild(parent);
|
|
27
|
+
return wrapper;
|
|
28
|
+
}
|
|
29
|
+
class LoginModal extends auth.SafeEventEmitter {
|
|
30
|
+
constructor(_uiConfig) {
|
|
31
|
+
super();
|
|
32
|
+
_defineProperty(this, "uiConfig", void 0);
|
|
33
|
+
_defineProperty(this, "stateEmitter", void 0);
|
|
34
|
+
_defineProperty(this, "chainNamespace", void 0);
|
|
35
|
+
_defineProperty(this, "walletRegistry", void 0);
|
|
36
|
+
_defineProperty(this, "initModal", async () => {
|
|
37
|
+
const darkState = {
|
|
38
|
+
isDark: this.isDark
|
|
39
|
+
};
|
|
40
|
+
const useLang = this.uiConfig.defaultLanguage || auth.LANGUAGES.en;
|
|
41
|
+
|
|
42
|
+
// Load new language resource
|
|
43
|
+
|
|
44
|
+
if (useLang === auth.LANGUAGES.de) {
|
|
45
|
+
Promise.resolve().then(function () { return require('./i18n/german.json.js'); }).then(messages => {
|
|
46
|
+
localeImport.addResourceBundle(useLang, "translation", messages.default);
|
|
47
|
+
return localeImport.changeLanguage(useLang);
|
|
48
|
+
}).catch(error => {
|
|
49
|
+
noModal.log.error(error);
|
|
50
|
+
});
|
|
51
|
+
} else if (useLang === auth.LANGUAGES.ja) {
|
|
52
|
+
Promise.resolve().then(function () { return require('./i18n/japanese.json.js'); }).then(messages => {
|
|
53
|
+
localeImport.addResourceBundle(useLang, "translation", messages.default);
|
|
54
|
+
return localeImport.changeLanguage(useLang);
|
|
55
|
+
}).catch(error => {
|
|
56
|
+
noModal.log.error(error);
|
|
57
|
+
});
|
|
58
|
+
} else if (useLang === auth.LANGUAGES.ko) {
|
|
59
|
+
Promise.resolve().then(function () { return require('./i18n/korean.json.js'); }).then(messages => {
|
|
60
|
+
localeImport.addResourceBundle(useLang, "translation", messages.default);
|
|
61
|
+
return localeImport.changeLanguage(useLang);
|
|
62
|
+
}).catch(error => {
|
|
63
|
+
noModal.log.error(error);
|
|
64
|
+
});
|
|
65
|
+
} else if (useLang === auth.LANGUAGES.zh) {
|
|
66
|
+
Promise.resolve().then(function () { return require('./i18n/mandarin.json.js'); }).then(messages => {
|
|
67
|
+
localeImport.addResourceBundle(useLang, "translation", messages.default);
|
|
68
|
+
return localeImport.changeLanguage(useLang);
|
|
69
|
+
}).catch(error => {
|
|
70
|
+
noModal.log.error(error);
|
|
71
|
+
});
|
|
72
|
+
} else if (useLang === auth.LANGUAGES.es) {
|
|
73
|
+
Promise.resolve().then(function () { return require('./i18n/spanish.json.js'); }).then(messages => {
|
|
74
|
+
localeImport.addResourceBundle(useLang, "translation", messages.default);
|
|
75
|
+
return localeImport.changeLanguage(useLang);
|
|
76
|
+
}).catch(error => {
|
|
77
|
+
noModal.log.error(error);
|
|
78
|
+
});
|
|
79
|
+
} else if (useLang === auth.LANGUAGES.fr) {
|
|
80
|
+
Promise.resolve().then(function () { return require('./i18n/french.json.js'); }).then(messages => {
|
|
81
|
+
localeImport.addResourceBundle(useLang, "translation", messages.default);
|
|
82
|
+
return localeImport.changeLanguage(useLang);
|
|
83
|
+
}).catch(error => {
|
|
84
|
+
noModal.log.error(error);
|
|
85
|
+
});
|
|
86
|
+
} else if (useLang === auth.LANGUAGES.pt) {
|
|
87
|
+
Promise.resolve().then(function () { return require('./i18n/portuguese.json.js'); }).then(messages => {
|
|
88
|
+
localeImport.addResourceBundle(useLang, "translation", messages.default);
|
|
89
|
+
return localeImport.changeLanguage(useLang);
|
|
90
|
+
}).catch(error => {
|
|
91
|
+
noModal.log.error(error);
|
|
92
|
+
});
|
|
93
|
+
} else if (useLang === auth.LANGUAGES.nl) {
|
|
94
|
+
Promise.resolve().then(function () { return require('./i18n/dutch.json.js'); }).then(messages => {
|
|
95
|
+
localeImport.addResourceBundle(useLang, "translation", messages.default);
|
|
96
|
+
return localeImport.changeLanguage(useLang);
|
|
97
|
+
}).catch(error => {
|
|
98
|
+
noModal.log.error(error);
|
|
99
|
+
});
|
|
100
|
+
} else if (useLang === auth.LANGUAGES.tr) {
|
|
101
|
+
Promise.resolve().then(function () { return require('./i18n/turkish.json.js'); }).then(messages => {
|
|
102
|
+
localeImport.addResourceBundle(useLang, "translation", messages.default);
|
|
103
|
+
return localeImport.changeLanguage(useLang);
|
|
104
|
+
}).catch(error => {
|
|
105
|
+
noModal.log.error(error);
|
|
106
|
+
});
|
|
107
|
+
} else if (useLang === auth.LANGUAGES.en) {
|
|
108
|
+
Promise.resolve().then(function () { return require('./i18n/english.json.js'); }).then(messages => {
|
|
109
|
+
localeImport.addResourceBundle(useLang, "translation", messages.default);
|
|
110
|
+
return localeImport.changeLanguage(useLang);
|
|
111
|
+
}).catch(error => {
|
|
112
|
+
noModal.log.error(error);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return new Promise(resolve => {
|
|
116
|
+
var _this$uiConfig;
|
|
117
|
+
this.stateEmitter.once("MOUNTED", () => {
|
|
118
|
+
noModal.log.info("rendered");
|
|
119
|
+
this.setState({
|
|
120
|
+
status: interfaces.MODAL_STATUS.INITIALIZED
|
|
121
|
+
});
|
|
122
|
+
return resolve();
|
|
123
|
+
});
|
|
124
|
+
const container = createWrapper(this.uiConfig.modalZIndex);
|
|
125
|
+
if (darkState.isDark) {
|
|
126
|
+
container.classList.add("w3a--dark");
|
|
127
|
+
} else {
|
|
128
|
+
container.classList.remove("w3a--dark");
|
|
129
|
+
}
|
|
130
|
+
const root = client.createRoot(container);
|
|
131
|
+
root.render(/*#__PURE__*/jsxRuntime.jsx(ThemeContext.ThemedContext.Provider, {
|
|
132
|
+
value: darkState,
|
|
133
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Modal, {
|
|
134
|
+
closeModal: this.closeModal,
|
|
135
|
+
stateListener: this.stateEmitter,
|
|
136
|
+
handleShowExternalWallets: this.handleShowExternalWallets,
|
|
137
|
+
handleExternalWalletClick: this.handleExternalWalletClick,
|
|
138
|
+
handleSocialLoginClick: this.handleSocialLoginClick,
|
|
139
|
+
appLogo: darkState.isDark ? this.uiConfig.logoDark : this.uiConfig.logoLight,
|
|
140
|
+
appName: this.uiConfig.appName,
|
|
141
|
+
chainNamespace: this.chainNamespace,
|
|
142
|
+
walletRegistry: this.walletRegistry
|
|
143
|
+
})
|
|
144
|
+
}));
|
|
145
|
+
if ((_this$uiConfig = this.uiConfig) !== null && _this$uiConfig !== void 0 && _this$uiConfig.theme) {
|
|
146
|
+
const rootElement = document.getElementById("w3a-parent-container");
|
|
147
|
+
auth.applyWhiteLabelTheme(rootElement, this.uiConfig.theme);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
_defineProperty(this, "addSocialLogins", (adapter, loginMethods, loginMethodsOrder, uiConfig) => {
|
|
152
|
+
this.setState({
|
|
153
|
+
socialLoginsConfig: {
|
|
154
|
+
adapter,
|
|
155
|
+
loginMethods,
|
|
156
|
+
loginMethodsOrder,
|
|
157
|
+
uiConfig
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
noModal.log.info("addSocialLogins", adapter, loginMethods, loginMethodsOrder, uiConfig);
|
|
161
|
+
});
|
|
162
|
+
_defineProperty(this, "addWalletLogins", (externalWalletsConfig, options) => {
|
|
163
|
+
this.setState({
|
|
164
|
+
externalWalletsConfig,
|
|
165
|
+
externalWalletsInitialized: true,
|
|
166
|
+
showExternalWalletsOnly: !!(options !== null && options !== void 0 && options.showExternalWalletsOnly),
|
|
167
|
+
externalWalletsVisibility: true
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
_defineProperty(this, "open", () => {
|
|
171
|
+
this.setState({
|
|
172
|
+
modalVisibility: true
|
|
173
|
+
});
|
|
174
|
+
this.emit(interfaces.LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, true);
|
|
175
|
+
});
|
|
176
|
+
_defineProperty(this, "closeModal", () => {
|
|
177
|
+
this.setState({
|
|
178
|
+
modalVisibility: false,
|
|
179
|
+
externalWalletsVisibility: false
|
|
180
|
+
});
|
|
181
|
+
this.emit(interfaces.LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, false);
|
|
182
|
+
});
|
|
183
|
+
_defineProperty(this, "initExternalWalletContainer", () => {
|
|
184
|
+
this.setState({
|
|
185
|
+
hasExternalWallets: true
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
_defineProperty(this, "handleShowExternalWallets", status => {
|
|
189
|
+
this.emit(interfaces.LOGIN_MODAL_EVENTS.INIT_EXTERNAL_WALLETS, {
|
|
190
|
+
externalWalletsInitialized: status
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
_defineProperty(this, "handleExternalWalletClick", params => {
|
|
194
|
+
noModal.log.info("external wallet clicked", params);
|
|
195
|
+
const {
|
|
196
|
+
adapter
|
|
197
|
+
} = params;
|
|
198
|
+
this.emit(interfaces.LOGIN_MODAL_EVENTS.LOGIN, {
|
|
199
|
+
adapter
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
_defineProperty(this, "handleSocialLoginClick", params => {
|
|
203
|
+
noModal.log.info("social login clicked", params);
|
|
204
|
+
const {
|
|
205
|
+
adapter,
|
|
206
|
+
loginParams
|
|
207
|
+
} = params;
|
|
208
|
+
this.emit(interfaces.LOGIN_MODAL_EVENTS.LOGIN, {
|
|
209
|
+
adapter,
|
|
210
|
+
loginParams: {
|
|
211
|
+
loginProvider: loginParams.loginProvider,
|
|
212
|
+
login_hint: loginParams.login_hint,
|
|
213
|
+
name: loginParams.name
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
_defineProperty(this, "setState", newState => {
|
|
218
|
+
this.stateEmitter.emit("STATE_UPDATED", newState);
|
|
219
|
+
});
|
|
220
|
+
_defineProperty(this, "updateWalletConnect", walletConnectUri => {
|
|
221
|
+
if (!walletConnectUri) return;
|
|
222
|
+
this.setState({
|
|
223
|
+
walletConnectUri
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
_defineProperty(this, "handleAdapterData", adapterData => {
|
|
227
|
+
if (adapterData.adapterName === noModal.WALLET_ADAPTERS.WALLET_CONNECT_V2) {
|
|
228
|
+
const walletConnectData = adapterData.data;
|
|
229
|
+
this.updateWalletConnect(walletConnectData.uri);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
_defineProperty(this, "subscribeCoreEvents", listener => {
|
|
233
|
+
listener.on(noModal.ADAPTER_EVENTS.CONNECTING, data => {
|
|
234
|
+
noModal.log.info("connecting with adapter", data);
|
|
235
|
+
// don't show loader in case of wallet connect, because currently it listens for incoming for incoming
|
|
236
|
+
// connections without any user interaction.
|
|
237
|
+
if ((data === null || data === void 0 ? void 0 : data.adapter) !== noModal.WALLET_ADAPTERS.WALLET_CONNECT_V2) {
|
|
238
|
+
// const provider = data?.loginProvider || "";
|
|
239
|
+
|
|
240
|
+
this.setState({
|
|
241
|
+
status: interfaces.MODAL_STATUS.CONNECTING
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
listener.on(noModal.ADAPTER_EVENTS.CONNECTED, data => {
|
|
246
|
+
noModal.log.debug("connected with adapter", data);
|
|
247
|
+
// only show success if not being reconnected again.
|
|
248
|
+
if (!data.reconnected) {
|
|
249
|
+
this.setState({
|
|
250
|
+
status: interfaces.MODAL_STATUS.CONNECTED,
|
|
251
|
+
modalVisibility: true,
|
|
252
|
+
postLoadingMessage: "modal.post-loading.connected"
|
|
253
|
+
});
|
|
254
|
+
} else {
|
|
255
|
+
this.setState({
|
|
256
|
+
status: interfaces.MODAL_STATUS.CONNECTED
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
// TODO: send adapter name in error
|
|
261
|
+
listener.on(noModal.ADAPTER_EVENTS.ERRORED, error => {
|
|
262
|
+
noModal.log.error("error", error, error.message);
|
|
263
|
+
if (error.code === 5000) {
|
|
264
|
+
if (this.uiConfig.displayErrorsOnModal) this.setState({
|
|
265
|
+
modalVisibility: true,
|
|
266
|
+
postLoadingMessage: error.message || "modal.post-loading.something-wrong",
|
|
267
|
+
status: interfaces.MODAL_STATUS.ERRORED
|
|
268
|
+
});else this.setState({
|
|
269
|
+
modalVisibility: false
|
|
270
|
+
});
|
|
271
|
+
} else {
|
|
272
|
+
this.setState({
|
|
273
|
+
modalVisibility: true,
|
|
274
|
+
status: interfaces.MODAL_STATUS.INITIALIZED
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
listener.on(noModal.ADAPTER_EVENTS.DISCONNECTED, () => {
|
|
279
|
+
this.setState({
|
|
280
|
+
status: interfaces.MODAL_STATUS.INITIALIZED,
|
|
281
|
+
externalWalletsVisibility: false
|
|
282
|
+
});
|
|
283
|
+
// this.toggleMessage("");
|
|
284
|
+
});
|
|
285
|
+
listener.on(noModal.ADAPTER_EVENTS.ADAPTER_DATA_UPDATED, adapterData => {
|
|
286
|
+
this.handleAdapterData(adapterData);
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
this.uiConfig = _uiConfig;
|
|
290
|
+
if (!_uiConfig.logoDark) this.uiConfig.logoDark = interfaces.DEFAULT_LOGO_DARK;
|
|
291
|
+
if (!_uiConfig.logoLight) this.uiConfig.logoLight = interfaces.DEFAULT_LOGO_LIGHT;
|
|
292
|
+
if (!_uiConfig.mode) this.uiConfig.mode = "light";
|
|
293
|
+
if (!_uiConfig.modalZIndex) this.uiConfig.modalZIndex = "99998";
|
|
294
|
+
if (typeof _uiConfig.displayErrorsOnModal === "undefined") this.uiConfig.displayErrorsOnModal = true;
|
|
295
|
+
if (!_uiConfig.appName) this.uiConfig.appName = "Web3Auth";
|
|
296
|
+
if (!_uiConfig.loginGridCol) this.uiConfig.loginGridCol = 3;
|
|
297
|
+
if (!_uiConfig.primaryButton) this.uiConfig.primaryButton = "socialLogin";
|
|
298
|
+
if (!_uiConfig.defaultLanguage) this.uiConfig.defaultLanguage = utils.getUserLanguage(_uiConfig.defaultLanguage);
|
|
299
|
+
this.stateEmitter = new auth.SafeEventEmitter();
|
|
300
|
+
this.chainNamespace = _uiConfig.chainNamespace;
|
|
301
|
+
this.walletRegistry = _uiConfig.walletRegistry;
|
|
302
|
+
this.subscribeCoreEvents(this.uiConfig.adapterListener);
|
|
303
|
+
}
|
|
304
|
+
get isDark() {
|
|
305
|
+
return this.uiConfig.mode === "dark" || this.uiConfig.mode === "auto" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
exports.LoginModal = LoginModal;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
|
+
var httpHelpers = require('@toruslabs/http-helpers');
|
|
5
|
+
var auth = require('@web3auth/auth');
|
|
6
|
+
var noModal = require('@web3auth/no-modal');
|
|
7
|
+
var config = require('./config.js');
|
|
8
|
+
|
|
9
|
+
const getAdapterSocialLogins = (adapterName, loginMethodsConfig = {}) => {
|
|
10
|
+
const finalLoginMethodsConfig = {};
|
|
11
|
+
if (adapterName === noModal.WALLET_ADAPTERS.AUTH) {
|
|
12
|
+
config.AUTH_PROVIDERS.forEach(loginMethod => {
|
|
13
|
+
const currentLoginMethodConfig = loginMethodsConfig[loginMethod] || {
|
|
14
|
+
name: config.AUTH_PROVIDERS_NAMES[loginMethod],
|
|
15
|
+
showOnMobile: true,
|
|
16
|
+
showOnModal: true,
|
|
17
|
+
showOnDesktop: true
|
|
18
|
+
};
|
|
19
|
+
finalLoginMethodsConfig[loginMethod] = _objectSpread({}, currentLoginMethodConfig);
|
|
20
|
+
});
|
|
21
|
+
noModal.log.debug("auth login method ui config", finalLoginMethodsConfig);
|
|
22
|
+
} else {
|
|
23
|
+
throw noModal.WalletInitializationError.invalidParams(`${adapterName} is not a valid adapter`);
|
|
24
|
+
}
|
|
25
|
+
return finalLoginMethodsConfig;
|
|
26
|
+
};
|
|
27
|
+
const passwordlessBackendUrl = "https://api-passwordless.web3auth.io";
|
|
28
|
+
const getUserCountry = async () => {
|
|
29
|
+
try {
|
|
30
|
+
const result = await httpHelpers.get(`${passwordlessBackendUrl}/api/v3/user/location`);
|
|
31
|
+
if (result && result.data.country) return {
|
|
32
|
+
country: result.data.country,
|
|
33
|
+
dialCode: result.data.dial_code
|
|
34
|
+
};
|
|
35
|
+
return null;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
noModal.log.error("error getting user country", error);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const validatePhoneNumber = async phoneNumber => {
|
|
42
|
+
try {
|
|
43
|
+
const result = await httpHelpers.post(`${passwordlessBackendUrl}/api/v3/phone_number/validate`, {
|
|
44
|
+
phone_number: phoneNumber
|
|
45
|
+
});
|
|
46
|
+
if (result && result.success) return result.parsed_number;
|
|
47
|
+
return false;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
noModal.log.error("error validating phone number", error);
|
|
50
|
+
if (error.status === 400) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
// sending true because we don't want the user to be stuck on a flow
|
|
54
|
+
// if there is an error with the api or something went wrong.
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const getUserLanguage = defaultLanguage => {
|
|
59
|
+
let userLanguage = defaultLanguage;
|
|
60
|
+
if (!userLanguage) {
|
|
61
|
+
const browserLanguage = typeof window !== "undefined" ? window.navigator.userLanguage || window.navigator.language || "en-US" : "en-US";
|
|
62
|
+
userLanguage = browserLanguage.split("-")[0];
|
|
63
|
+
}
|
|
64
|
+
return Object.prototype.hasOwnProperty.call(auth.LANGUAGE_MAP, userLanguage) ? userLanguage : auth.LANGUAGES.en;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
exports.getAdapterSocialLogins = getAdapterSocialLogins;
|
|
68
|
+
exports.getUserCountry = getUserCountry;
|
|
69
|
+
exports.getUserLanguage = getUserLanguage;
|
|
70
|
+
exports.passwordlessBackendUrl = passwordlessBackendUrl;
|
|
71
|
+
exports.validatePhoneNumber = validatePhoneNumber;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noModal = require('@web3auth/no-modal');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
var modalManager = require('../modalManager.js');
|
|
6
|
+
|
|
7
|
+
const Web3AuthProvider = vue.defineComponent({
|
|
8
|
+
name: "Web3AuthProvider",
|
|
9
|
+
props: {
|
|
10
|
+
config: {
|
|
11
|
+
type: Object,
|
|
12
|
+
required: true
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
setup(props) {
|
|
16
|
+
const web3Auth = vue.shallowRef(null);
|
|
17
|
+
const provider = vue.ref(null);
|
|
18
|
+
const userInfo = vue.ref(null);
|
|
19
|
+
const isMFAEnabled = vue.ref(false);
|
|
20
|
+
const status = vue.ref(null);
|
|
21
|
+
const isInitializing = vue.ref(false);
|
|
22
|
+
const initError = vue.ref(null);
|
|
23
|
+
const isInitialized = vue.ref(false);
|
|
24
|
+
const isConnecting = vue.ref(false);
|
|
25
|
+
const connectError = vue.ref(null);
|
|
26
|
+
const isConnected = vue.ref(false);
|
|
27
|
+
const addPlugin = plugin => {
|
|
28
|
+
if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
|
|
29
|
+
return web3Auth.value.addPlugin(plugin);
|
|
30
|
+
};
|
|
31
|
+
const getPlugin = name => {
|
|
32
|
+
if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
|
|
33
|
+
return web3Auth.value.getPlugin(name);
|
|
34
|
+
};
|
|
35
|
+
const enableMFA = async loginParams => {
|
|
36
|
+
if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
|
|
37
|
+
if (!isConnected.value) throw noModal.WalletLoginError.notConnectedError();
|
|
38
|
+
await web3Auth.value.enableMFA(loginParams);
|
|
39
|
+
const localUserInfo = await web3Auth.value.getUserInfo();
|
|
40
|
+
userInfo.value = localUserInfo;
|
|
41
|
+
isMFAEnabled.value = localUserInfo.isMfaEnabled || false;
|
|
42
|
+
};
|
|
43
|
+
const manageMFA = async loginParams => {
|
|
44
|
+
if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
|
|
45
|
+
if (!isConnected.value) throw noModal.WalletLoginError.notConnectedError();
|
|
46
|
+
await web3Auth.value.manageMFA(loginParams);
|
|
47
|
+
};
|
|
48
|
+
const logout = async (logoutParams = {
|
|
49
|
+
cleanup: false
|
|
50
|
+
}) => {
|
|
51
|
+
if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
|
|
52
|
+
if (!isConnected.value) throw noModal.WalletLoginError.notConnectedError();
|
|
53
|
+
await web3Auth.value.logout(logoutParams);
|
|
54
|
+
};
|
|
55
|
+
const connect = async () => {
|
|
56
|
+
if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
|
|
57
|
+
try {
|
|
58
|
+
connectError.value = null;
|
|
59
|
+
isConnecting.value = true;
|
|
60
|
+
const localProvider = await web3Auth.value.connect();
|
|
61
|
+
return localProvider;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
connectError.value = error;
|
|
64
|
+
return null;
|
|
65
|
+
} finally {
|
|
66
|
+
isConnecting.value = false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const addAndSwitchChain = async chainConfig => {
|
|
70
|
+
if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
|
|
71
|
+
await web3Auth.value.addChain(chainConfig);
|
|
72
|
+
await web3Auth.value.switchChain({
|
|
73
|
+
chainId: chainConfig.chainId
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const authenticateUser = async () => {
|
|
77
|
+
if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
|
|
78
|
+
return web3Auth.value.authenticateUser();
|
|
79
|
+
};
|
|
80
|
+
const addChain = async chainConfig => {
|
|
81
|
+
if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
|
|
82
|
+
return web3Auth.value.addChain(chainConfig);
|
|
83
|
+
};
|
|
84
|
+
const switchChain = chainParams => {
|
|
85
|
+
if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
|
|
86
|
+
return web3Auth.value.switchChain(chainParams);
|
|
87
|
+
};
|
|
88
|
+
vue.watch(() => props.config, newConfig => {
|
|
89
|
+
const resetHookState = () => {
|
|
90
|
+
provider.value = null;
|
|
91
|
+
userInfo.value = null;
|
|
92
|
+
isMFAEnabled.value = false;
|
|
93
|
+
isConnected.value = false;
|
|
94
|
+
status.value = null;
|
|
95
|
+
};
|
|
96
|
+
resetHookState();
|
|
97
|
+
const {
|
|
98
|
+
web3AuthOptions,
|
|
99
|
+
adapters = [],
|
|
100
|
+
plugins = []
|
|
101
|
+
} = newConfig;
|
|
102
|
+
const web3AuthInstance = new modalManager.Web3Auth(web3AuthOptions);
|
|
103
|
+
if (adapters.length) adapters.map(adapter => web3AuthInstance.configureAdapter(adapter));
|
|
104
|
+
if (plugins.length) {
|
|
105
|
+
plugins.forEach(plugin => {
|
|
106
|
+
web3AuthInstance.addPlugin(plugin);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
web3Auth.value = web3AuthInstance;
|
|
110
|
+
}, {
|
|
111
|
+
immediate: true
|
|
112
|
+
});
|
|
113
|
+
vue.watch(web3Auth, async newWeb3Auth => {
|
|
114
|
+
if (newWeb3Auth) {
|
|
115
|
+
try {
|
|
116
|
+
initError.value = null;
|
|
117
|
+
isInitializing.value = true;
|
|
118
|
+
const {
|
|
119
|
+
modalConfig,
|
|
120
|
+
hideWalletDiscovery
|
|
121
|
+
} = props.config;
|
|
122
|
+
if (modalConfig) {
|
|
123
|
+
await newWeb3Auth.initModal({
|
|
124
|
+
modalConfig,
|
|
125
|
+
hideWalletDiscovery
|
|
126
|
+
});
|
|
127
|
+
} else {
|
|
128
|
+
await newWeb3Auth.initModal();
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
initError.value = error;
|
|
132
|
+
} finally {
|
|
133
|
+
isInitializing.value = false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
immediate: true
|
|
138
|
+
});
|
|
139
|
+
vue.watch(isConnected, newIsConnected => {
|
|
140
|
+
if (web3Auth.value) {
|
|
141
|
+
const addState = async web3AuthInstance => {
|
|
142
|
+
provider.value = web3AuthInstance.provider;
|
|
143
|
+
const userState = await web3AuthInstance.getUserInfo();
|
|
144
|
+
userInfo.value = userState;
|
|
145
|
+
isMFAEnabled.value = (userState === null || userState === void 0 ? void 0 : userState.isMfaEnabled) || false;
|
|
146
|
+
};
|
|
147
|
+
const resetState = () => {
|
|
148
|
+
provider.value = null;
|
|
149
|
+
userInfo.value = null;
|
|
150
|
+
isMFAEnabled.value = false;
|
|
151
|
+
};
|
|
152
|
+
if (newIsConnected) addState(web3Auth.value);else resetState();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
vue.watch(web3Auth, (newWeb3Auth, prevWeb3Auth) => {
|
|
156
|
+
const notReadyListener = () => {
|
|
157
|
+
status.value = web3Auth.value.status;
|
|
158
|
+
};
|
|
159
|
+
const readyListener = () => {
|
|
160
|
+
status.value = web3Auth.value.status;
|
|
161
|
+
isInitialized.value = true;
|
|
162
|
+
};
|
|
163
|
+
const connectedListener = () => {
|
|
164
|
+
status.value = web3Auth.value.status;
|
|
165
|
+
// we do this because of rehydration issues. status connected is fired first but web3auth sdk is not ready yet.
|
|
166
|
+
if (web3Auth.value.status === noModal.ADAPTER_STATUS.CONNECTED) {
|
|
167
|
+
isInitialized.value = true;
|
|
168
|
+
isConnected.value = true;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const disconnectedListener = () => {
|
|
172
|
+
status.value = web3Auth.value.status;
|
|
173
|
+
isConnected.value = false;
|
|
174
|
+
};
|
|
175
|
+
const connectingListener = () => {
|
|
176
|
+
status.value = web3Auth.value.status;
|
|
177
|
+
};
|
|
178
|
+
const errorListener = () => {
|
|
179
|
+
status.value = noModal.ADAPTER_EVENTS.ERRORED;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// unregister previous listeners
|
|
183
|
+
if (prevWeb3Auth && newWeb3Auth !== prevWeb3Auth) {
|
|
184
|
+
prevWeb3Auth.off(noModal.ADAPTER_EVENTS.NOT_READY, notReadyListener);
|
|
185
|
+
prevWeb3Auth.off(noModal.ADAPTER_EVENTS.READY, readyListener);
|
|
186
|
+
prevWeb3Auth.off(noModal.ADAPTER_EVENTS.CONNECTED, connectedListener);
|
|
187
|
+
prevWeb3Auth.off(noModal.ADAPTER_EVENTS.DISCONNECTED, disconnectedListener);
|
|
188
|
+
prevWeb3Auth.off(noModal.ADAPTER_EVENTS.CONNECTING, connectingListener);
|
|
189
|
+
prevWeb3Auth.off(noModal.ADAPTER_EVENTS.ERRORED, errorListener);
|
|
190
|
+
}
|
|
191
|
+
if (newWeb3Auth && newWeb3Auth !== prevWeb3Auth) {
|
|
192
|
+
status.value = newWeb3Auth.status;
|
|
193
|
+
// web3Auth is initialized here.
|
|
194
|
+
newWeb3Auth.on(noModal.ADAPTER_EVENTS.NOT_READY, notReadyListener);
|
|
195
|
+
newWeb3Auth.on(noModal.ADAPTER_EVENTS.READY, readyListener);
|
|
196
|
+
newWeb3Auth.on(noModal.ADAPTER_EVENTS.CONNECTED, connectedListener);
|
|
197
|
+
newWeb3Auth.on(noModal.ADAPTER_EVENTS.DISCONNECTED, disconnectedListener);
|
|
198
|
+
newWeb3Auth.on(noModal.ADAPTER_EVENTS.CONNECTING, connectingListener);
|
|
199
|
+
newWeb3Auth.on(noModal.ADAPTER_EVENTS.ERRORED, errorListener);
|
|
200
|
+
}
|
|
201
|
+
}, {
|
|
202
|
+
immediate: true
|
|
203
|
+
});
|
|
204
|
+
vue.provide(noModal.Web3AuthContextKey, {
|
|
205
|
+
web3Auth,
|
|
206
|
+
isConnected,
|
|
207
|
+
isInitialized,
|
|
208
|
+
provider,
|
|
209
|
+
userInfo,
|
|
210
|
+
isMFAEnabled,
|
|
211
|
+
status,
|
|
212
|
+
getPlugin,
|
|
213
|
+
connect,
|
|
214
|
+
enableMFA,
|
|
215
|
+
manageMFA,
|
|
216
|
+
logout,
|
|
217
|
+
addAndSwitchChain,
|
|
218
|
+
addChain,
|
|
219
|
+
addPlugin,
|
|
220
|
+
authenticateUser,
|
|
221
|
+
switchChain,
|
|
222
|
+
isInitializing,
|
|
223
|
+
isConnecting,
|
|
224
|
+
initError,
|
|
225
|
+
connectError
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
render() {
|
|
229
|
+
var _this$$slots$default;
|
|
230
|
+
return vue.h((_this$$slots$default = this.$slots.default) !== null && _this$$slots$default !== void 0 ? _this$$slots$default : "");
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
exports.Web3AuthProvider = Web3AuthProvider;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noModal = require('@web3auth/no-modal');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
|
|
6
|
+
const useWeb3Auth = () => {
|
|
7
|
+
const context = vue.inject(noModal.Web3AuthContextKey);
|
|
8
|
+
if (!context) throw noModal.WalletInitializationError.fromCode(1000, "usage of `useWeb3Auth` not wrapped in `Web3AuthProvider`.");
|
|
9
|
+
return context;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.useWeb3Auth = useWeb3Auth;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function styleInject(css, ref) {
|
|
2
|
+
if (ref === void 0) ref = {};
|
|
3
|
+
var insertAt = ref.insertAt;
|
|
4
|
+
if (!css || typeof document === 'undefined') {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
8
|
+
var style = document.createElement('style');
|
|
9
|
+
style.type = 'text/css';
|
|
10
|
+
if (insertAt === 'top') {
|
|
11
|
+
if (head.firstChild) {
|
|
12
|
+
head.insertBefore(style, head.firstChild);
|
|
13
|
+
} else {
|
|
14
|
+
head.appendChild(style);
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
head.appendChild(style);
|
|
18
|
+
}
|
|
19
|
+
if (style.styleSheet) {
|
|
20
|
+
style.styleSheet.cssText = css;
|
|
21
|
+
} else {
|
|
22
|
+
style.appendChild(document.createTextNode(css));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { styleInject as default };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { defaultEvmDappModalConfig, defaultEvmWalletModalConfig, defaultOtherModalConfig, defaultSolanaDappModalConfig, defaultSolanaWalletModalConfig, walletRegistryUrl } from './config.js';
|
|
2
2
|
export { Web3Auth } from './modalManager.js';
|
|
3
|
+
export * from '@web3auth/no-modal';
|