@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.
Files changed (150) hide show
  1. package/dist/lib.cjs/node_modules/style-inject/dist/style-inject.es.js +28 -0
  2. package/dist/lib.cjs/{config.js → packages/modal/src/config.js} +14 -14
  3. package/dist/lib.cjs/{index.js → packages/modal/src/index.js} +7 -0
  4. package/dist/lib.cjs/{modalManager.js → packages/modal/src/modalManager.js} +92 -92
  5. package/dist/lib.cjs/packages/modal/src/react/Web3AuthProvider.js +15 -0
  6. package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +225 -0
  7. package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3Auth.js +15 -0
  8. package/dist/lib.cjs/packages/modal/src/react/index.js +12 -0
  9. package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-dark.svg.js +7 -0
  10. package/dist/lib.cjs/packages/modal/src/ui/assets/arrow-left-light.svg.js +7 -0
  11. package/dist/lib.cjs/packages/modal/src/ui/assets/x-dark.svg.js +7 -0
  12. package/dist/lib.cjs/packages/modal/src/ui/assets/x-light.svg.js +7 -0
  13. package/dist/lib.cjs/packages/modal/src/ui/components/AdapterLoader.js +108 -0
  14. package/dist/lib.cjs/packages/modal/src/ui/components/Button/Button.js +34 -0
  15. package/dist/lib.cjs/packages/modal/src/ui/components/Button/styles.css.js +8 -0
  16. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +44 -0
  17. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +67 -0
  18. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +34 -0
  19. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +46 -0
  20. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +167 -0
  21. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallets.js +273 -0
  22. package/dist/lib.cjs/packages/modal/src/ui/components/Footer.js +20 -0
  23. package/dist/lib.cjs/packages/modal/src/ui/components/Header.js +81 -0
  24. package/dist/lib.cjs/packages/modal/src/ui/components/Icon.js +73 -0
  25. package/dist/lib.cjs/packages/modal/src/ui/components/Image.js +51 -0
  26. package/dist/lib.cjs/packages/modal/src/ui/components/Loader.js +59 -0
  27. package/dist/lib.cjs/packages/modal/src/ui/components/Modal.js +244 -0
  28. package/dist/lib.cjs/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +30 -0
  29. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginPasswordless.js +141 -0
  30. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLogins.js +148 -0
  31. package/dist/lib.cjs/packages/modal/src/ui/components/WalletConnect.js +84 -0
  32. package/dist/lib.cjs/packages/modal/src/ui/config.js +17 -0
  33. package/dist/lib.cjs/packages/modal/src/ui/context/ThemeContext.js +9 -0
  34. package/dist/lib.cjs/packages/modal/src/ui/css/web3auth.css.js +8 -0
  35. package/dist/lib.cjs/packages/modal/src/ui/i18n/dutch.json.js +84 -0
  36. package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +84 -0
  37. package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +82 -0
  38. package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +84 -0
  39. package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +84 -0
  40. package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +84 -0
  41. package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +84 -0
  42. package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +84 -0
  43. package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +84 -0
  44. package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +84 -0
  45. package/dist/lib.cjs/packages/modal/src/ui/interfaces.js +26 -0
  46. package/dist/lib.cjs/packages/modal/src/ui/localeImport.js +25 -0
  47. package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +309 -0
  48. package/dist/lib.cjs/packages/modal/src/ui/utils.js +71 -0
  49. package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +234 -0
  50. package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3Auth.js +12 -0
  51. package/dist/lib.cjs/packages/modal/src/vue/index.js +9 -0
  52. package/dist/lib.esm/node_modules/style-inject/dist/style-inject.es.js +26 -0
  53. package/dist/lib.esm/{config.js → packages/modal/src/config.js} +1 -1
  54. package/dist/lib.esm/{index.js → packages/modal/src/index.js} +1 -0
  55. package/dist/lib.esm/{modalManager.js → packages/modal/src/modalManager.js} +5 -5
  56. package/dist/lib.esm/packages/modal/src/react/Web3AuthProvider.js +13 -0
  57. package/dist/lib.esm/packages/modal/src/react/context/Web3AuthInnerContext.js +222 -0
  58. package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3Auth.js +13 -0
  59. package/dist/lib.esm/packages/modal/src/react/index.js +3 -0
  60. package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-dark.svg.js +5 -0
  61. package/dist/lib.esm/packages/modal/src/ui/assets/arrow-left-light.svg.js +5 -0
  62. package/dist/lib.esm/packages/modal/src/ui/assets/x-dark.svg.js +5 -0
  63. package/dist/lib.esm/packages/modal/src/ui/assets/x-light.svg.js +5 -0
  64. package/dist/lib.esm/packages/modal/src/ui/components/AdapterLoader.js +106 -0
  65. package/dist/lib.esm/packages/modal/src/ui/components/Button/Button.js +32 -0
  66. package/dist/lib.esm/packages/modal/src/ui/components/Button/styles.css.js +6 -0
  67. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +42 -0
  68. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +65 -0
  69. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +32 -0
  70. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +44 -0
  71. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +165 -0
  72. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallets.js +271 -0
  73. package/dist/lib.esm/packages/modal/src/ui/components/Footer.js +18 -0
  74. package/dist/lib.esm/packages/modal/src/ui/components/Header.js +79 -0
  75. package/dist/lib.esm/packages/modal/src/ui/components/Icon.js +71 -0
  76. package/dist/lib.esm/packages/modal/src/ui/components/Image.js +49 -0
  77. package/dist/lib.esm/packages/modal/src/ui/components/Loader.js +57 -0
  78. package/dist/lib.esm/packages/modal/src/ui/components/Modal.js +242 -0
  79. package/dist/lib.esm/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +28 -0
  80. package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginPasswordless.js +139 -0
  81. package/dist/lib.esm/packages/modal/src/ui/components/SocialLogins.js +146 -0
  82. package/dist/lib.esm/packages/modal/src/ui/components/WalletConnect.js +82 -0
  83. package/dist/lib.esm/packages/modal/src/ui/config.js +13 -0
  84. package/dist/lib.esm/packages/modal/src/ui/context/ThemeContext.js +7 -0
  85. package/dist/lib.esm/packages/modal/src/ui/css/web3auth.css.js +6 -0
  86. package/dist/lib.esm/packages/modal/src/ui/i18n/dutch.json.js +79 -0
  87. package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +79 -0
  88. package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +77 -0
  89. package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +79 -0
  90. package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +79 -0
  91. package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +79 -0
  92. package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +79 -0
  93. package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +79 -0
  94. package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +79 -0
  95. package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +79 -0
  96. package/dist/lib.esm/packages/modal/src/ui/interfaces.js +20 -0
  97. package/dist/lib.esm/packages/modal/src/ui/localeImport.js +23 -0
  98. package/dist/lib.esm/packages/modal/src/ui/loginModal.js +307 -0
  99. package/dist/lib.esm/packages/modal/src/ui/utils.js +65 -0
  100. package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +232 -0
  101. package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3Auth.js +10 -0
  102. package/dist/lib.esm/packages/modal/src/vue/index.js +2 -0
  103. package/dist/modal.cjs.js +5703 -420
  104. package/dist/modal.umd.min.js +1 -1
  105. package/dist/modal.umd.min.js.LICENSE.txt +54 -0
  106. package/dist/types/index.d.ts +1 -0
  107. package/dist/types/interface.d.ts +1 -1
  108. package/dist/types/modalManager.d.ts +2 -3
  109. package/dist/types/react/Web3AuthProvider.d.ts +3 -0
  110. package/dist/types/react/context/Web3AuthInnerContext.d.ts +4 -0
  111. package/dist/types/react/context/index.d.ts +1 -0
  112. package/dist/types/react/hooks/index.d.ts +1 -0
  113. package/dist/types/react/hooks/useWeb3Auth.d.ts +2 -0
  114. package/dist/types/react/index.d.ts +4 -0
  115. package/dist/types/react/interfaces.d.ts +18 -0
  116. package/dist/types/ui/components/AdapterLoader.d.ts +11 -0
  117. package/dist/types/ui/components/Button/Button.d.ts +16 -0
  118. package/dist/types/ui/components/Button/index.d.ts +1 -0
  119. package/dist/types/ui/components/ExternalWallet/ExternalWalletButton.d.ts +7 -0
  120. package/dist/types/ui/components/ExternalWallet/ExternalWalletConnect.d.ts +9 -0
  121. package/dist/types/ui/components/ExternalWallet/ExternalWalletDetails.d.ts +9 -0
  122. package/dist/types/ui/components/ExternalWallet/ExternalWalletHeader.d.ts +8 -0
  123. package/dist/types/ui/components/ExternalWallet/ExternalWalletInstall.d.ts +8 -0
  124. package/dist/types/ui/components/ExternalWallets.d.ts +17 -0
  125. package/dist/types/ui/components/Footer.d.ts +1 -0
  126. package/dist/types/ui/components/Header.d.ts +8 -0
  127. package/dist/types/ui/components/Icon.d.ts +9 -0
  128. package/dist/types/ui/components/Image.d.ts +12 -0
  129. package/dist/types/ui/components/Loader.d.ts +10 -0
  130. package/dist/types/ui/components/Modal.d.ts +16 -0
  131. package/dist/types/ui/components/SelfCustodyViaWeb3Auth.d.ts +1 -0
  132. package/dist/types/ui/components/SocialLoginPasswordless.d.ts +16 -0
  133. package/dist/types/ui/components/SocialLogins.d.ts +14 -0
  134. package/dist/types/ui/components/WalletConnect.d.ts +8 -0
  135. package/dist/types/ui/config.d.ts +4 -0
  136. package/dist/types/ui/context/ThemeContext.d.ts +3 -0
  137. package/dist/types/ui/helper/countryData.d.ts +7 -0
  138. package/dist/types/ui/i18n/index.d.ts +11 -0
  139. package/dist/types/ui/index.d.ts +4 -0
  140. package/dist/types/ui/interfaces.d.ts +106 -0
  141. package/dist/types/ui/localeImport.d.ts +3 -0
  142. package/dist/types/ui/loginModal.d.ts +27 -0
  143. package/dist/types/ui/utils.d.ts +12 -0
  144. package/dist/types/vue/Web3AuthProvider.d.ts +13 -0
  145. package/dist/types/vue/composables/index.d.ts +1 -0
  146. package/dist/types/vue/composables/useWeb3Auth.d.ts +2 -0
  147. package/dist/types/vue/index.d.ts +3 -0
  148. package/dist/types/vue/interfaces.d.ts +45 -0
  149. package/package.json +100 -43
  150. package/dist/modal.esm.js +0 -513
@@ -0,0 +1,165 @@
1
+ import Bowser from 'bowser';
2
+ import { useMemo } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import i18nInstance from '../../localeImport.js';
5
+ import Button from '../Button/Button.js';
6
+ import Image from '../Image.js';
7
+ import ExternalWalletHeader from './ExternalWalletHeader.js';
8
+ import { jsxs, jsx } from 'react/jsx-runtime';
9
+
10
+ const getBrowserExtensionUrl = (browserType, walletId) => {
11
+ if (walletId !== null && walletId !== void 0 && walletId.startsWith("https://")) return walletId;
12
+ switch (browserType) {
13
+ case "chrome":
14
+ return `https://chrome.google.com/webstore/detail/${walletId}`;
15
+ case "firefox":
16
+ return `https://addons.mozilla.org/firefox/addon/${walletId}`;
17
+ case "edge":
18
+ return `https://microsoftedge.microsoft.com/addons/detail/${walletId}`;
19
+ default:
20
+ return null;
21
+ }
22
+ };
23
+ const getMobileInstallLink = (os, appId) => {
24
+ if (appId !== null && appId !== void 0 && appId.includes("https://")) {
25
+ return appId;
26
+ }
27
+ switch (os) {
28
+ case "android":
29
+ return `https://play.google.com/store/apps/details?id=${appId}`;
30
+ case "ios":
31
+ return `https://apps.apple.com/app/safepal-wallet/${appId}`;
32
+ default:
33
+ return "";
34
+ }
35
+ };
36
+ const getOsName = os => {
37
+ switch (os) {
38
+ case "ios":
39
+ return "iOS";
40
+ case "android":
41
+ return "Android";
42
+ default:
43
+ return "";
44
+ }
45
+ };
46
+ const getBrowserName = browser => {
47
+ return browser.charAt(0).toUpperCase() + browser.slice(1);
48
+ };
49
+ function ExternalWalletInstall(props) {
50
+ const {
51
+ connectButton,
52
+ goBack,
53
+ closeModal
54
+ } = props;
55
+ const [t] = useTranslation(undefined, {
56
+ i18n: i18nInstance
57
+ });
58
+ const deviceDetails = useMemo(() => {
59
+ const browser = Bowser.getParser(window.navigator.userAgent);
60
+ return {
61
+ platform: browser.getPlatformType(),
62
+ browser: browser.getBrowserName().toLowerCase(),
63
+ os: browser.getOSName()
64
+ };
65
+ }, []);
66
+ const mobileInstallLinks = () => {
67
+ const installConfig = connectButton.walletRegistryItem.app || {};
68
+ const installLinks = Object.keys(installConfig).reduce((acc, os) => {
69
+ if (!["android", "ios"].includes(os)) return acc;
70
+ const appId = installConfig[os];
71
+ if (!appId) return acc;
72
+ const appUrl = getMobileInstallLink(os, appId);
73
+ if (!appUrl) return acc;
74
+ const logoLight = `${os}-light`;
75
+ const logoDark = `${os}-dark`;
76
+ acc.push(/*#__PURE__*/jsx("li", {
77
+ className: "w3a--w-full",
78
+ children: /*#__PURE__*/jsx("a", {
79
+ href: appUrl,
80
+ rel: "noopener noreferrer",
81
+ target: "_blank",
82
+ children: /*#__PURE__*/jsxs(Button, {
83
+ type: "button",
84
+ variant: "tertiary",
85
+ className: "w3a--w-full !w3a--justify-start w3a--flex w3a--items-center w3a--gap-2 wallet-link-btn",
86
+ children: [/*#__PURE__*/jsx(Image, {
87
+ imageId: logoLight,
88
+ darkImageId: logoDark,
89
+ hoverImageId: logoLight,
90
+ darkHoverImageId: logoDark,
91
+ height: "28",
92
+ width: "28",
93
+ isButton: true
94
+ }), /*#__PURE__*/jsx("span", {
95
+ className: "w3a--text-sm w3a--font-medium",
96
+ children: t("modal.external.install-mobile-app", {
97
+ os: getOsName(os)
98
+ })
99
+ })]
100
+ })
101
+ })
102
+ }, os));
103
+ return acc;
104
+ }, []);
105
+ return installLinks;
106
+ };
107
+ const desktopInstallLinks = () => {
108
+ // if browser is brave, use chrome extension
109
+ const browserType = deviceDetails.browser === "brave" ? "chrome" : deviceDetails.browser;
110
+ const browserExtensionConfig = connectButton.walletRegistryItem.app || {};
111
+ const extensionForCurrentBrowser = browserExtensionConfig.browser && browserExtensionConfig.browser.includes(browserType) ? browserExtensionConfig.browser : undefined;
112
+ const browserExtensionId = browserExtensionConfig[browserType] || extensionForCurrentBrowser;
113
+ const browserExtensionUrl = browserExtensionId ? getBrowserExtensionUrl(browserType, browserExtensionId) : null;
114
+ const installLink = browserExtensionUrl ? /*#__PURE__*/jsx("li", {
115
+ children: /*#__PURE__*/jsx("a", {
116
+ href: browserExtensionUrl,
117
+ rel: "noopener noreferrer",
118
+ target: "_blank",
119
+ children: /*#__PURE__*/jsxs(Button, {
120
+ type: "button",
121
+ variant: "tertiary",
122
+ className: "w3a--w-full !w3a--justify-start w3a--flex w3a--items-center w3a--gap-2 wallet-link-btn",
123
+ children: [/*#__PURE__*/jsx(Image, {
124
+ imageId: deviceDetails.browser,
125
+ darkImageId: deviceDetails.browser,
126
+ hoverImageId: deviceDetails.browser,
127
+ darkHoverImageId: deviceDetails.browser,
128
+ height: "30",
129
+ width: "30",
130
+ isButton: true
131
+ }), /*#__PURE__*/jsx("span", {
132
+ className: "w3a--text-sm w3a--font-medium",
133
+ children: t("modal.external.install-browser-extension", {
134
+ browser: getBrowserName(deviceDetails.browser)
135
+ })
136
+ })]
137
+ })
138
+ })
139
+ }, deviceDetails.browser) : null;
140
+ return [installLink, ...mobileInstallLinks()];
141
+ };
142
+ return /*#__PURE__*/jsxs("div", {
143
+ children: [/*#__PURE__*/jsx(ExternalWalletHeader, {
144
+ title: `${t("modal.external.get")} ${connectButton.displayName}`,
145
+ goBack: goBack,
146
+ closeModal: closeModal
147
+ }), /*#__PURE__*/jsx("div", {
148
+ className: "w3a--flex w3a--justify-center w3a--my-6",
149
+ children: /*#__PURE__*/jsx(Image, {
150
+ imageId: `login-${connectButton.name}`,
151
+ hoverImageId: `login-${connectButton.name}`,
152
+ fallbackImageId: "wallet",
153
+ height: "100",
154
+ width: "100",
155
+ isButton: true,
156
+ extension: connectButton.imgExtension
157
+ })
158
+ }), /*#__PURE__*/jsx("ul", {
159
+ className: "w3a--flex w3a--flex-col w3a--gap-3",
160
+ children: deviceDetails.platform === "desktop" ? desktopInstallLinks() : mobileInstallLinks()
161
+ })]
162
+ });
163
+ }
164
+
165
+ export { ExternalWalletInstall as default };
@@ -0,0 +1,271 @@
1
+ import { log, WALLET_ADAPTERS } from '@web3auth/no-modal';
2
+ import Bowser from 'bowser';
3
+ import { useState, useMemo, useEffect } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { MODAL_STATUS } from '../interfaces.js';
6
+ import i18nInstance from '../localeImport.js';
7
+ import ExternalWalletButton from './ExternalWallet/ExternalWalletButton.js';
8
+ import ExternalWalletDetail from './ExternalWallet/ExternalWalletDetails.js';
9
+ import ExternalWalletHeader from './ExternalWallet/ExternalWalletHeader.js';
10
+ import Loader from './Loader.js';
11
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
12
+
13
+ function formatIOSMobile(params) {
14
+ const encodedUri = encodeURIComponent(params.uri);
15
+ if (params.link.startsWith("http")) return `${params.link}/wc?uri=${encodedUri}`;
16
+ if (params.link) return `${params.link}wc?uri=${encodedUri}`;
17
+ return "";
18
+ }
19
+ function ExternalWallet(props) {
20
+ const {
21
+ hideExternalWallets,
22
+ handleExternalWalletClick,
23
+ closeModal,
24
+ config = {},
25
+ walletConnectUri,
26
+ showBackButton,
27
+ modalStatus,
28
+ chainNamespace,
29
+ walletRegistry
30
+ } = props;
31
+ const [externalButtons, setExternalButtons] = useState([]);
32
+ const [totalExternalWallets, setTotalExternalWallets] = useState(0);
33
+ const [selectedButton, setSelectedButton] = useState(null);
34
+ const [walletSearch, setWalletSearch] = useState("");
35
+ const [t] = useTranslation(undefined, {
36
+ i18n: i18nInstance
37
+ });
38
+ const walletDiscoverySupported = useMemo(() => {
39
+ const supported = walletRegistry && Object.keys(walletRegistry.default).length > 0 && Object.keys(walletRegistry.others).length > 0;
40
+ return supported;
41
+ }, [walletRegistry]);
42
+ const deviceDetails = useMemo(() => {
43
+ const browser = Bowser.getParser(window.navigator.userAgent);
44
+ return {
45
+ platform: browser.getPlatformType(),
46
+ os: browser.getOSName(),
47
+ browser: browser.getBrowserName().toLowerCase()
48
+ };
49
+ }, []);
50
+ const handleWalletSearch = e => {
51
+ setWalletSearch(e.target.value);
52
+ };
53
+ const adapterVisibilityMap = useMemo(() => {
54
+ const canShowMap = {};
55
+ Object.keys(config).forEach(adapter => {
56
+ const adapterConfig = config[adapter];
57
+ if (!adapterConfig.showOnModal) {
58
+ canShowMap[adapter] = false;
59
+ return;
60
+ }
61
+ if (deviceDetails.platform === "desktop" && adapterConfig.showOnDesktop) {
62
+ canShowMap[adapter] = true;
63
+ return;
64
+ }
65
+ if ((deviceDetails.platform === "mobile" || deviceDetails.platform === "tablet") && adapterConfig.showOnMobile) {
66
+ canShowMap[adapter] = true;
67
+ return;
68
+ }
69
+ canShowMap[adapter] = false;
70
+ });
71
+ log.debug("adapter visibility map", canShowMap);
72
+ return canShowMap;
73
+ }, [config, deviceDetails.platform]);
74
+ useEffect(() => {
75
+ var _config$WALLET_ADAPTE;
76
+ log.debug("loaded external wallets", config, walletConnectUri);
77
+ const wcAvailable = (((_config$WALLET_ADAPTE = config[WALLET_ADAPTERS.WALLET_CONNECT_V2]) === null || _config$WALLET_ADAPTE === void 0 ? void 0 : _config$WALLET_ADAPTE.showOnModal) || false) !== false;
78
+ if (wcAvailable && !walletConnectUri) {
79
+ handleExternalWalletClick({
80
+ adapter: WALLET_ADAPTERS.WALLET_CONNECT_V2
81
+ });
82
+ }
83
+ }, [config, handleExternalWalletClick, walletConnectUri]);
84
+ useEffect(() => {
85
+ if (walletDiscoverySupported) {
86
+ const isWalletConnectAdapterIncluded = Object.keys(config).some(adapter => adapter === WALLET_ADAPTERS.WALLET_CONNECT_V2);
87
+ const defaultButtonKeys = new Set(Object.keys(walletRegistry.default));
88
+ const generateWalletButtons = wallets => {
89
+ return Object.keys(wallets).reduce((acc, wallet) => {
90
+ var _config$wallet, _walletRegistryItem$w, _walletRegistryItem$c, _walletRegistryItem$i;
91
+ if (adapterVisibilityMap[wallet] === false) return acc;
92
+ const walletRegistryItem = wallets[wallet];
93
+ let href = "";
94
+ if (deviceDetails.platform === Bowser.PLATFORMS_MAP.mobile) {
95
+ var _walletRegistryItem$m, _walletRegistryItem$m2;
96
+ const universalLink = walletRegistryItem === null || walletRegistryItem === void 0 || (_walletRegistryItem$m = walletRegistryItem.mobile) === null || _walletRegistryItem$m === void 0 ? void 0 : _walletRegistryItem$m.universal;
97
+ const deepLink = walletRegistryItem === null || walletRegistryItem === void 0 || (_walletRegistryItem$m2 = walletRegistryItem.mobile) === null || _walletRegistryItem$m2 === void 0 ? void 0 : _walletRegistryItem$m2.native;
98
+ href = universalLink || deepLink;
99
+ }
100
+ const button = {
101
+ name: wallet,
102
+ displayName: walletRegistryItem.name,
103
+ href,
104
+ hasInjectedWallet: ((_config$wallet = config[wallet]) === null || _config$wallet === void 0 ? void 0 : _config$wallet.isInjected) || false,
105
+ hasWalletConnect: isWalletConnectAdapterIncluded && ((_walletRegistryItem$w = walletRegistryItem.walletConnect) === null || _walletRegistryItem$w === void 0 || (_walletRegistryItem$w = _walletRegistryItem$w.sdks) === null || _walletRegistryItem$w === void 0 ? void 0 : _walletRegistryItem$w.includes("sign_v2")),
106
+ hasInstallLinks: Object.keys(walletRegistryItem.app || {}).length > 0,
107
+ walletRegistryItem,
108
+ imgExtension: walletRegistryItem.imgExtension || "svg"
109
+ };
110
+ // const isBrowserExtensionAvailable = walletRegistryItem.app?.chrome || walletRegistryItem.app?.firefox || walletRegistryItem.app?.edge;
111
+ if (!button.hasInjectedWallet && !button.hasWalletConnect && !button.hasInstallLinks) return acc;
112
+ const chainNamespaces = new Set((_walletRegistryItem$c = walletRegistryItem.chains) === null || _walletRegistryItem$c === void 0 ? void 0 : _walletRegistryItem$c.map(chain => chain.split(":")[0]));
113
+ const injectedChainNamespaces = new Set((_walletRegistryItem$i = walletRegistryItem.injected) === null || _walletRegistryItem$i === void 0 ? void 0 : _walletRegistryItem$i.map(injected => injected.namespace));
114
+ if (!chainNamespaces.has(chainNamespace) && !injectedChainNamespaces.has(chainNamespace)) return acc;
115
+ acc.push(button);
116
+ return acc;
117
+ }, []);
118
+ };
119
+
120
+ // Generate buttons for default and other wallets
121
+ const defaultButtons = generateWalletButtons(walletRegistry.default);
122
+ const otherButtons = generateWalletButtons(walletRegistry.others);
123
+
124
+ // Generate custom adapter buttons
125
+ const customAdapterButtons = Object.keys(config).reduce((acc, adapter) => {
126
+ if (![WALLET_ADAPTERS.WALLET_CONNECT_V2].includes(adapter) && !config[adapter].isInjected && adapterVisibilityMap[adapter]) {
127
+ log.debug("custom adapter", adapter, config[adapter]);
128
+ acc.push({
129
+ name: adapter,
130
+ displayName: config[adapter].label || adapter,
131
+ hasInjectedWallet: false,
132
+ hasWalletConnect: false,
133
+ hasInstallLinks: false
134
+ });
135
+ }
136
+ return acc;
137
+ }, []);
138
+ const allButtons = [...defaultButtons, ...otherButtons];
139
+
140
+ // Filter and set external buttons based on search input
141
+ if (walletSearch) {
142
+ const filteredList = allButtons.concat(customAdapterButtons).filter(button => button.name.toLowerCase().includes(walletSearch.toLowerCase()));
143
+ log.debug("filteredLists", filteredList);
144
+ setExternalButtons(filteredList);
145
+ } else {
146
+ const sortedButtons = [...allButtons.filter(button => button.hasInjectedWallet && defaultButtonKeys.has(button.name)), ...customAdapterButtons, ...allButtons.filter(button => !button.hasInjectedWallet && defaultButtonKeys.has(button.name))];
147
+ setExternalButtons(sortedButtons);
148
+ }
149
+ setTotalExternalWallets(allButtons.length + customAdapterButtons.length);
150
+ log.debug("external buttons", allButtons);
151
+ } else {
152
+ const buttons = Object.keys(config).reduce((acc, adapter) => {
153
+ log.debug("external buttons", adapter, adapterVisibilityMap[adapter]);
154
+ if (![WALLET_ADAPTERS.WALLET_CONNECT_V2].includes(adapter) && adapterVisibilityMap[adapter]) {
155
+ acc.push({
156
+ name: adapter,
157
+ displayName: config[adapter].label || adapter,
158
+ hasInjectedWallet: config[adapter].isInjected,
159
+ hasWalletConnect: false,
160
+ hasInstallLinks: false
161
+ });
162
+ }
163
+ return acc;
164
+ }, []);
165
+ setExternalButtons(buttons);
166
+ setTotalExternalWallets(buttons.length);
167
+ }
168
+ }, [config, deviceDetails, adapterVisibilityMap, walletRegistry, walletSearch, chainNamespace, walletDiscoverySupported]);
169
+ const handleWalletClick = button => {
170
+ // if has injected wallet, connect to injected wallet
171
+ // if doesn't have wallet connect & doesn't have install links, must be a custom adapter
172
+ if (button.hasInjectedWallet || !button.hasWalletConnect && !button.hasInstallLinks) {
173
+ handleExternalWalletClick({
174
+ adapter: button.name
175
+ });
176
+ } else {
177
+ // else, show wallet detail
178
+ setSelectedButton(button);
179
+ }
180
+ };
181
+ return /*#__PURE__*/jsx("div", {
182
+ className: `w3ajs-external-wallet w3a-group ${totalExternalWallets === 0 ? "w3a-group-loader-height" : ""}`,
183
+ children: /*#__PURE__*/jsx("div", {
184
+ className: "w3a-external-container w3ajs-external-container",
185
+ children: totalExternalWallets === 0 ? /*#__PURE__*/jsx(Loader, {
186
+ modalStatus: MODAL_STATUS.CONNECTING,
187
+ canEmit: false
188
+ }) : modalStatus === MODAL_STATUS.INITIALIZED && (
189
+ // All wallets
190
+ !selectedButton ? /*#__PURE__*/jsxs(Fragment, {
191
+ children: [/*#__PURE__*/jsx(ExternalWalletHeader, {
192
+ disableBackButton: !showBackButton,
193
+ title: t("modal.external.connect-wallet"),
194
+ goBack: hideExternalWallets,
195
+ closeModal: closeModal
196
+ }), totalExternalWallets > 15 && /*#__PURE__*/jsx("div", {
197
+ className: "w3a--py-4",
198
+ children: /*#__PURE__*/jsx("input", {
199
+ className: "w3a--w-full w3a-text-field",
200
+ name: "passwordless-input",
201
+ required: true,
202
+ value: walletSearch,
203
+ placeholder: t("modal.external.search-wallet", {
204
+ count: totalExternalWallets
205
+ }),
206
+ onFocus: e => {
207
+ e.target.placeholder = "";
208
+ },
209
+ onBlur: e => {
210
+ e.target.placeholder = t("modal.external.search-wallet", {
211
+ count: totalExternalWallets
212
+ });
213
+ },
214
+ onChange: e => handleWalletSearch(e)
215
+ })
216
+ }), externalButtons.length === 0 ? /*#__PURE__*/jsx("div", {
217
+ className: "w3a--w-full w3a--text-center w3a--text-app-gray-400 dark:w3a--text-app-gray-500 w3a--py-6 w3a--flex w3a--justify-center w3a--items-center",
218
+ children: t("modal.external.no-wallets-found")
219
+ }) : /*#__PURE__*/jsx("div", {
220
+ className: `w3a-adapter-list-container ${totalExternalWallets < 15 ? "w3a--py-4" : ""}`,
221
+ children: /*#__PURE__*/jsxs("ul", {
222
+ className: "w3a-adapter-list w3ajs-wallet-adapters",
223
+ children: [externalButtons.map(button => {
224
+ return /*#__PURE__*/jsxs("li", {
225
+ className: "w3a-adapter-item w3a-adapter-item--full",
226
+ children: [deviceDetails.platform === "desktop" && /*#__PURE__*/jsx(ExternalWalletButton, {
227
+ button: button,
228
+ handleWalletClick: handleWalletClick
229
+ }), deviceDetails.platform !== "desktop" && (button.href && button.hasWalletConnect && !button.hasInjectedWallet ? /*#__PURE__*/jsx("a", {
230
+ href: button.href ? formatIOSMobile({
231
+ uri: walletConnectUri,
232
+ link: button.href
233
+ }) : walletConnectUri,
234
+ target: "_blank",
235
+ className: "w3a--w-full",
236
+ rel: "noreferrer noopener",
237
+ children: /*#__PURE__*/jsx(ExternalWalletButton, {
238
+ button: button,
239
+ handleWalletClick: handleWalletClick
240
+ })
241
+ }) : /*#__PURE__*/jsx(ExternalWalletButton, {
242
+ button: button,
243
+ handleWalletClick: handleWalletClick
244
+ }))]
245
+ }, button.name + button.displayName);
246
+ }), totalExternalWallets > 10 && !walletSearch && /*#__PURE__*/jsxs("li", {
247
+ className: "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-0.5 w3a--my-4 w3a--w-full w3a--mx-auto w3a-adapter-item--full",
248
+ children: [/*#__PURE__*/jsx("p", {
249
+ className: "w3a--text-xs w3a--text-app-gray-500 dark:w3a--text-app-gray-400",
250
+ children: t("modal.external.search-text")
251
+ }), /*#__PURE__*/jsx("p", {
252
+ className: "w3a--text-xs w3a--font-medium w3a--text-app-gray-900 dark:w3a--text-app-white",
253
+ children: t("modal.external.search-subtext")
254
+ })]
255
+ })]
256
+ })
257
+ })]
258
+ }) :
259
+ /*#__PURE__*/
260
+ // Wallet Detail
261
+ jsx(ExternalWalletDetail, {
262
+ connectButton: selectedButton,
263
+ goBack: () => setSelectedButton(null),
264
+ walletConnectUri: walletConnectUri,
265
+ closeModal: closeModal
266
+ }))
267
+ })
268
+ });
269
+ }
270
+
271
+ export { ExternalWallet as default };
@@ -0,0 +1,18 @@
1
+ import SelfCustodyViaWeb3Auth from './SelfCustodyViaWeb3Auth.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+
4
+ function Footer() {
5
+ return /*#__PURE__*/jsx("div", {
6
+ className: "w3a-modal__footer",
7
+ children: /*#__PURE__*/jsx("div", {
8
+ className: "w3a-footer",
9
+ children: /*#__PURE__*/jsx("div", {
10
+ children: /*#__PURE__*/jsx("div", {
11
+ children: /*#__PURE__*/jsx(SelfCustodyViaWeb3Auth, {})
12
+ })
13
+ })
14
+ })
15
+ });
16
+ }
17
+
18
+ export { Footer as default };
@@ -0,0 +1,79 @@
1
+ import { memo } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { DEFAULT_LOGO_DARK, DEFAULT_LOGO_LIGHT } from '../interfaces.js';
4
+ import i18nInstance from '../localeImport.js';
5
+ import Icon from './Icon.js';
6
+ import { jsxs, jsx } from 'react/jsx-runtime';
7
+
8
+ function Header(props) {
9
+ const {
10
+ onClose,
11
+ appLogo,
12
+ appName
13
+ } = props;
14
+ const [t] = useTranslation(undefined, {
15
+ i18n: i18nInstance
16
+ });
17
+ const headerLogo = [DEFAULT_LOGO_DARK, DEFAULT_LOGO_LIGHT].includes(appLogo) ? "" : appLogo;
18
+ const subtitle = t("modal.header-subtitle-name", {
19
+ appName
20
+ });
21
+ return /*#__PURE__*/jsxs("div", {
22
+ className: "w3a-modal__header",
23
+ children: [/*#__PURE__*/jsx("div", {
24
+ className: "w3a-header",
25
+ children: /*#__PURE__*/jsxs("div", {
26
+ children: [headerLogo && /*#__PURE__*/jsx("div", {
27
+ className: "w3a-header__logo",
28
+ children: /*#__PURE__*/jsx("img", {
29
+ src: headerLogo,
30
+ alt: ""
31
+ })
32
+ }), /*#__PURE__*/jsx("div", {
33
+ className: "w3a-header__title",
34
+ children: t("modal.header-title")
35
+ }), /*#__PURE__*/jsxs("div", {
36
+ className: "w3a-header__subtitle",
37
+ children: [subtitle, /*#__PURE__*/jsxs("div", {
38
+ className: "w3a--relative w3a--flex w3a--flex-col w3a--items-center w3a--group w3a--cursor-pointer",
39
+ children: [/*#__PURE__*/jsx(Icon, {
40
+ iconName: "information-circle-light",
41
+ darkIconName: "information-circle"
42
+ }), /*#__PURE__*/jsxs("div", {
43
+ className: "w3a--absolute w3a--top-4 w3a--z-20 w3a--flex-col w3a--items-center w3a--hidden w3a--mb-5 group-hover:w3a--flex",
44
+ children: [/*#__PURE__*/jsx("div", {
45
+ className: "w3a--w-3 w3a--h-3 w3a--ml-[3px] -w3a--mb-2 w3a--rotate-45 w3a--bg-app-gray-50 dark:w3a--bg-app-gray-600"
46
+ }), /*#__PURE__*/jsxs("div", {
47
+ className: `w3a--relative w3a--p-4 w3a--w-[270px] w3a--translate-x-[-16px] w3a--text-xs w3a--leading-none w3a--text-app-white w3a--rounded-md w3a--bg-app-gray-50 dark:w3a--bg-app-gray-600 w3a--shadow-lg ${subtitle.length > 34 ? "-w3a--ml-[100px]" : ""}`,
48
+ children: [/*#__PURE__*/jsx("div", {
49
+ className: "w3a--text-xs w3a--font-medium w3a--mb-1 w3a--text-app-gray-900 dark:w3a--text-app-white",
50
+ children: t("modal.header-tooltip-title")
51
+ }), /*#__PURE__*/jsx("div", {
52
+ className: "w3a--text-xs w3a--text-app-gray-400",
53
+ children: t("modal.header-tooltip-desc")
54
+ })]
55
+ })]
56
+ })]
57
+ })]
58
+ })]
59
+ })
60
+ }), /*#__PURE__*/jsx("button", {
61
+ type: "button",
62
+ onClick: onClose,
63
+ className: "w3a-header__button w3ajs-close-btn ",
64
+ children: /*#__PURE__*/jsx(Icon, {
65
+ iconName: "x-light",
66
+ darkIconName: "x-dark"
67
+ })
68
+ })]
69
+ });
70
+ }
71
+ const memoizedHeader = /*#__PURE__*/memo(Header, (prevProps, nextProps) => {
72
+ if (prevProps.appLogo !== nextProps.appLogo) {
73
+ return true;
74
+ }
75
+ return false;
76
+ });
77
+ memoizedHeader.displayName = "Header";
78
+
79
+ export { memoizedHeader as default };
@@ -0,0 +1,71 @@
1
+ import ArrowDark from '../assets/arrow-left-dark.svg.js';
2
+ import ArrowLight from '../assets/arrow-left-light.svg.js';
3
+ import XDark from '../assets/x-dark.svg.js';
4
+ import XLight from '../assets/x-light.svg.js';
5
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
6
+
7
+ const icons = {
8
+ "arrow-left": {
9
+ image: "https://images.web3auth.io/circle-arrow-left.svg"
10
+ },
11
+ close: {
12
+ image: "https://images.web3auth.io/close.svg"
13
+ },
14
+ "expand-light": {
15
+ image: "https://images.web3auth.io/expand-light.svg"
16
+ },
17
+ expand: {
18
+ image: "https://images.web3auth.io/expand.svg"
19
+ },
20
+ connected: {
21
+ image: "https://images.web3auth.io/connected.svg"
22
+ },
23
+ "information-circle-light": {
24
+ image: "https://images.web3auth.io/information-circle-light.svg"
25
+ },
26
+ "information-circle": {
27
+ image: "https://images.web3auth.io/information-circle.svg"
28
+ },
29
+ "arrow-left-light": {
30
+ image: ArrowLight
31
+ },
32
+ "x-light": {
33
+ image: XLight
34
+ },
35
+ "arrow-left-dark": {
36
+ image: ArrowDark
37
+ },
38
+ "x-dark": {
39
+ image: XDark
40
+ }
41
+ };
42
+ function Icon(props) {
43
+ const {
44
+ iconName,
45
+ iconTitle = "",
46
+ height = "auto",
47
+ width = "auto",
48
+ darkIconName = ""
49
+ } = props;
50
+ const h = height === "auto" ? "w3a--h-auto" : `w3a--h-[${height}px]`;
51
+ const w = width === "auto" ? "w3a--w-auto" : `w3a--w-[${width}px]`;
52
+ return /*#__PURE__*/jsxs(Fragment, {
53
+ children: [icons[iconName] && /*#__PURE__*/jsx("img", {
54
+ className: `${iconTitle ? "w3a--cursor-pointer" : ""} dark:w3a--hidden w3a--block ${h} ${w}`,
55
+ height: height,
56
+ width: width,
57
+ src: icons[iconName].image,
58
+ alt: iconName,
59
+ title: iconTitle
60
+ }), icons[darkIconName] && /*#__PURE__*/jsx("img", {
61
+ className: `${iconTitle ? "w3a--cursor-pointer" : ""} w3a--hidden dark:w3a--block ${h} ${w}`,
62
+ height: height,
63
+ width: width,
64
+ src: icons[darkIconName].image,
65
+ alt: darkIconName,
66
+ title: iconTitle
67
+ })]
68
+ });
69
+ }
70
+
71
+ export { Icon as default };
@@ -0,0 +1,49 @@
1
+ import { useContext } from 'react';
2
+ import { ThemedContext } from '../context/ThemeContext.js';
3
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
4
+
5
+ function Image(props) {
6
+ const {
7
+ hoverImageId,
8
+ darkHoverImageId,
9
+ imageId,
10
+ darkImageId,
11
+ isButton = false,
12
+ height = "auto",
13
+ width = "auto",
14
+ fallbackImageId,
15
+ extension = "svg"
16
+ } = props;
17
+ const {
18
+ isDark
19
+ } = useContext(ThemedContext);
20
+ const imgName = isDark && darkImageId ? darkImageId : imageId;
21
+ const hoverImgName = isDark && darkHoverImageId ? darkHoverImageId : hoverImageId;
22
+ return /*#__PURE__*/jsxs(Fragment, {
23
+ children: [/*#__PURE__*/jsx("img", {
24
+ src: `https://images.web3auth.io/${imgName}.${extension}`,
25
+ height: height,
26
+ width: width,
27
+ alt: imageId,
28
+ className: "image-icon w3a--object-contain w3a--rounded",
29
+ onError: ({
30
+ currentTarget
31
+ }) => {
32
+ if (fallbackImageId) {
33
+ // eslint-disable-next-line no-param-reassign
34
+ currentTarget.onerror = null; // prevents looping
35
+ // eslint-disable-next-line no-param-reassign
36
+ currentTarget.src = `https://images.web3auth.io/${fallbackImageId}.svg`;
37
+ }
38
+ }
39
+ }), isButton ? /*#__PURE__*/jsx("img", {
40
+ src: `https://images.web3auth.io/${hoverImgName}.${extension}`,
41
+ height: height,
42
+ width: width,
43
+ alt: hoverImageId,
44
+ className: "hover-icon w3a--object-contain w3a--rounded"
45
+ }) : null]
46
+ });
47
+ }
48
+
49
+ export { Image as default };