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