@getpara/react-sdk 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/dist/MoonPayEmbed-GAWXP6V7.js +2 -0
  2. package/dist/MoonPayEmbed-GAWXP6V7.js.br +0 -0
  3. package/dist/MoonPayEmbed-GAWXP6V7.js.gz +0 -0
  4. package/dist/index.js +675 -5
  5. package/dist/index.js.br +0 -0
  6. package/dist/index.js.gz +0 -0
  7. package/package.json +8 -7
  8. package/dist/modal/ParaModal.js +0 -281
  9. package/dist/modal/components/Account/Account.js +0 -60
  10. package/dist/modal/components/AddFunds/AddFunds.js +0 -147
  11. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -65
  12. package/dist/modal/components/AddFunds/AddFundsDone.js +0 -26
  13. package/dist/modal/components/AddFunds/MoonPayEmbed.js +0 -2
  14. package/dist/modal/components/AddFunds/index.js +0 -3
  15. package/dist/modal/components/AuthInput/AuthInput.js +0 -221
  16. package/dist/modal/components/AuthInput/countryCodes.js +0 -40
  17. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -23
  18. package/dist/modal/components/AuthInput/phoneMasks.js +0 -247
  19. package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -21
  20. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -89
  21. package/dist/modal/components/AuthOptions/AuthOptions.js +0 -28
  22. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -7
  23. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -5
  24. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -7
  25. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -18
  26. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -17
  27. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -131
  28. package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -26
  29. package/dist/modal/components/Body/Body.js +0 -232
  30. package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -77
  31. package/dist/modal/components/ChainSwitch/config.js +0 -11
  32. package/dist/modal/components/Controls/Controls.js +0 -54
  33. package/dist/modal/components/Controls/Selects.js +0 -159
  34. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -116
  35. package/dist/modal/components/ExternalWalletStep/config.js +0 -11
  36. package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -142
  37. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -119
  38. package/dist/modal/components/Footer/Footer.js +0 -71
  39. package/dist/modal/components/Header/Header.js +0 -24
  40. package/dist/modal/components/Header/hooks/useStepTitle.js +0 -42
  41. package/dist/modal/components/Hero/Hero.js +0 -119
  42. package/dist/modal/components/IFrameStep/IFrameStep.js +0 -41
  43. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -19
  44. package/dist/modal/components/ModalContent/ModalContent.js +0 -282
  45. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
  46. package/dist/modal/components/OAuth/OAuth.js +0 -125
  47. package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -133
  48. package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -10
  49. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -72
  50. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -67
  51. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -105
  52. package/dist/modal/components/StripeComponents/StripeComponents.js +0 -78
  53. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -8
  54. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -135
  55. package/dist/modal/components/Waiting/Waiting.js +0 -6
  56. package/dist/modal/components/WalletCard/PartnerIcon.js +0 -29
  57. package/dist/modal/components/WalletCard/WalletCard.js +0 -93
  58. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -50
  59. package/dist/modal/components/common.js +0 -67
  60. package/dist/modal/components/index.js +0 -1
  61. package/dist/modal/constants/constants.js +0 -93
  62. package/dist/modal/constants/defaults.js +0 -5
  63. package/dist/modal/constants/oAuthLogos.js +0 -18
  64. package/dist/modal/hooks/useActiveWallet.js +0 -11
  65. package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -46
  66. package/dist/modal/hooks/useGoBack.js +0 -34
  67. package/dist/modal/index.js +0 -9
  68. package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -18
  69. package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -22
  70. package/dist/modal/providers/ExternalWalletContext.js +0 -253
  71. package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -12
  72. package/dist/modal/stores/externalWalletProvider/actions.js +0 -5
  73. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -13
  74. package/dist/modal/stores/index.js +0 -3
  75. package/dist/modal/stores/modal/actions.js +0 -64
  76. package/dist/modal/stores/modal/useModalStore.js +0 -41
  77. package/dist/modal/stores/para/actions.js +0 -5
  78. package/dist/modal/stores/para/useParaStore.js +0 -3
  79. package/dist/modal/stores/theme/actions.js +0 -24
  80. package/dist/modal/stores/theme/useThemeStore.js +0 -14
  81. package/dist/modal/stores/userInfo/actions.js +0 -34
  82. package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -9
  83. package/dist/modal/types/commonTypes.js +0 -1
  84. package/dist/modal/types/externalWallets.js +0 -21
  85. package/dist/modal/types/modalProps.js +0 -7
  86. package/dist/modal/utils/authLayoutHelpers.js +0 -2
  87. package/dist/modal/utils/getMailtoLink.js +0 -5
  88. package/dist/modal/utils/getTileButtonFlex.js +0 -15
  89. package/dist/modal/utils/isPasskeySupported.js +0 -10
  90. package/dist/modal/utils/openPopup.js +0 -55
  91. package/dist/modal/utils/routeMobileExternalWallet.js +0 -35
  92. package/dist/modal/utils/steps.js +0 -215
  93. package/dist/modal/utils/stringFormatters.js +0 -12
  94. package/dist/modal/utils/validateOnRampConfig.js +0 -26
  95. package/dist/provider/ParaProvider.js +0 -17
  96. package/dist/provider/actions/checkIfUserExists.js +0 -26
  97. package/dist/provider/actions/createUser.js +0 -30
  98. package/dist/provider/actions/getAccount.js +0 -24
  99. package/dist/provider/actions/getWallet.js +0 -16
  100. package/dist/provider/actions/initiateLogin.js +0 -23
  101. package/dist/provider/actions/keepSessionAlive.js +0 -23
  102. package/dist/provider/actions/logout.js +0 -20
  103. package/dist/provider/actions/signMessage.js +0 -23
  104. package/dist/provider/actions/signTransaction.js +0 -23
  105. package/dist/provider/actions/waitForAccountCreation.js +0 -24
  106. package/dist/provider/actions/waitForLoginAndSetup.js +0 -27
  107. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -24
  108. package/dist/provider/hooks/index.js +0 -3
  109. package/dist/provider/hooks/mutations/index.js +0 -10
  110. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
  111. package/dist/provider/hooks/mutations/useCreateUser.js +0 -23
  112. package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
  113. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -23
  114. package/dist/provider/hooks/mutations/useLogout.js +0 -33
  115. package/dist/provider/hooks/mutations/useSignMessage.js +0 -33
  116. package/dist/provider/hooks/mutations/useSignTransaction.js +0 -33
  117. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
  118. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
  119. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
  120. package/dist/provider/hooks/queries/index.js +0 -2
  121. package/dist/provider/hooks/queries/useAccount.js +0 -23
  122. package/dist/provider/hooks/queries/useWallet.js +0 -24
  123. package/dist/provider/hooks/utils/index.js +0 -3
  124. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -79
  125. package/dist/provider/hooks/utils/useClient.js +0 -8
  126. package/dist/provider/hooks/utils/useEventListeners.js +0 -87
  127. package/dist/provider/hooks/utils/useInternalClient.js +0 -9
  128. package/dist/provider/hooks/utils/useModal.js +0 -15
  129. package/dist/provider/hooks/utils/useWalletState.js +0 -33
  130. package/dist/provider/index.js +0 -3
  131. package/dist/provider/stores/getters.js +0 -5
  132. package/dist/provider/stores/slices/client.js +0 -4
  133. package/dist/provider/stores/slices/index.js +0 -3
  134. package/dist/provider/stores/slices/modal.js +0 -4
  135. package/dist/provider/stores/slices/wallet.js +0 -6
  136. package/dist/provider/stores/types.js +0 -1
  137. package/dist/provider/stores/useStore.js +0 -14
  138. package/dist/provider/types/provider.js +0 -1
  139. package/dist/provider/types/query.js +0 -1
  140. package/dist/provider/types/utils.js +0 -1
  141. package/dist/provider/utils/renameMutations.js +0 -19
  142. /package/dist/{modal/css → css}/modal.css +0 -0
  143. /package/dist/{modal/public → public}/Inter-VariableFont_slnt,wght.ttf +0 -0
@@ -1,253 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { jsx as _jsx } from "react/jsx-runtime";
11
- import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
12
- import { useModalStore } from '../stores/index.js';
13
- import { ModalStep } from '../utils/steps.js';
14
- import { WalletType, isIOS, isIOSWebview, isMobile, truncateAddress } from '@getpara/web-sdk';
15
- import { useInternalClient } from '../../provider/hooks/utils/useInternalClient.js';
16
- export const defaultExternalWallet = {
17
- wallets: [],
18
- chains: [],
19
- chainId: undefined,
20
- wallet: undefined,
21
- qrUri: undefined,
22
- chainIdSwitchingTo: undefined,
23
- walletDisplayHelpers: {
24
- showExtension: false,
25
- showMobile: false,
26
- isSolanaMobileIOS: false,
27
- isCosmosMobileWallet: false,
28
- },
29
- username: undefined,
30
- avatar: undefined,
31
- connectExternalWallet: () => { },
32
- disconnectExternalWallet: () => Promise.resolve(),
33
- switchChain: () => Promise.resolve(),
34
- setChainIdSwitchingTo: () => { },
35
- };
36
- export const ExternalWalletContext = createContext(defaultExternalWallet);
37
- export function ExternalWalletProvider({ children, evmContext, solanaContext, cosmosContext, walletSort, }) {
38
- const { wallets: evmWallets, disconnect: evmDisconnect, chains: evmChains, chainId: evmChainId, switchChain: evmSwitchChain, username: evmUsername, avatar: evmAvatar, } = useContext(evmContext);
39
- const { wallets: solanaWallets, disconnect: solanaDisconnect } = useContext(solanaContext);
40
- const { wallets: cosmosWallets, disconnect: cosmosDisconnect, chains: cosmosChains, chainId: cosmosChainId, switchChain: cosmosSwitchChain, } = useContext(cosmosContext);
41
- const setStep = useModalStore(state => state.setStep);
42
- const setStepDirection = useModalStore(state => state.setStepDirection);
43
- const setIsExternalWalletConnecting = useModalStore(state => state.setIsExternalWalletConnecting);
44
- const isExternalWalletConnecting = useModalStore(state => state.isExternalWalletConnecting);
45
- const setSelectedExternalWalletId = useModalStore(state => state.setSelectedExternalWalletId);
46
- const selectedExternalWalletId = useModalStore(state => state.selectedExternalWalletId);
47
- const setExternalWalletError = useModalStore(state => state.setExternalWalletError);
48
- const setIsUsingMobileConnector = useModalStore(state => state.setIsUsingMobileConnector);
49
- const isUsingMobileConnector = useModalStore(state => state.isUsingMobileConnector);
50
- const para = useInternalClient();
51
- const [qrUri, setQrUri] = useState();
52
- const [chainIdSwitchingTo, setChainIdSwitchingTo] = useState();
53
- // Filter any wallets that aren't included in the sort array, sort by the array then sort by installed extensions
54
- const wallets = [...evmWallets, ...solanaWallets, ...cosmosWallets]
55
- .filter(w => walletSort.includes(w.id.toUpperCase()))
56
- .sort((a, b) => walletSort.indexOf(a.id.toUpperCase()) -
57
- walletSort.indexOf(b.id.toUpperCase()))
58
- .sort((a, b) => (a.installed === b.installed ? 0 : a.installed ? -1 : 1));
59
- const wallet = useMemo(() => wallets.find(w => w.id === selectedExternalWalletId), [wallets, selectedExternalWalletId]);
60
- const updateQrUri = () => __awaiter(this, void 0, void 0, function* () {
61
- var _a;
62
- const uri = yield ((_a = wallet === null || wallet === void 0 ? void 0 : wallet.getQrUri) === null || _a === void 0 ? void 0 : _a.call(wallet));
63
- setQrUri(uri);
64
- });
65
- useEffect(() => {
66
- if (wallet) {
67
- if (!qrUri) {
68
- updateQrUri();
69
- }
70
- }
71
- else if (qrUri) {
72
- setQrUri(undefined);
73
- }
74
- }, [wallet]);
75
- const chains = useMemo(() => {
76
- var _a, _b, _c;
77
- const walletType = (_c = para.externalWallets[(_b = (_a = para.currentExternalWalletAddresses) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '']) === null || _c === void 0 ? void 0 : _c.type;
78
- switch (walletType) {
79
- case WalletType.COSMOS: {
80
- return cosmosChains;
81
- }
82
- case WalletType.EVM: {
83
- return evmChains;
84
- }
85
- default: {
86
- return [];
87
- }
88
- }
89
- }, [cosmosChains, evmChains, selectedExternalWalletId]);
90
- const chainId = useMemo(() => {
91
- var _a, _b, _c;
92
- const walletType = (_c = para.externalWallets[(_b = (_a = para.currentExternalWalletAddresses) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '']) === null || _c === void 0 ? void 0 : _c.type;
93
- switch (walletType) {
94
- case WalletType.COSMOS: {
95
- return cosmosChainId;
96
- }
97
- case WalletType.EVM: {
98
- return evmChainId === null || evmChainId === void 0 ? void 0 : evmChainId.toString();
99
- }
100
- default: {
101
- return undefined;
102
- }
103
- }
104
- }, [cosmosChains, evmChains, selectedExternalWalletId]);
105
- const switchChain = useCallback((chainId) => __awaiter(this, void 0, void 0, function* () {
106
- var _a, _b, _c;
107
- const walletType = (_c = para.externalWallets[(_b = (_a = para.currentExternalWalletAddresses) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '']) === null || _c === void 0 ? void 0 : _c.type;
108
- if (walletType) {
109
- let resp;
110
- setExternalWalletError();
111
- setChainIdSwitchingTo(chainId);
112
- switch (walletType) {
113
- case WalletType.COSMOS: {
114
- setStep(ModalStep.CHAIN_SWITCH);
115
- resp = yield cosmosSwitchChain(chainId);
116
- break;
117
- }
118
- case WalletType.EVM: {
119
- setStep(ModalStep.CHAIN_SWITCH);
120
- resp = yield evmSwitchChain(parseInt(chainId));
121
- break;
122
- }
123
- default: {
124
- break;
125
- }
126
- }
127
- if (resp.error) {
128
- setExternalWalletError(resp.error);
129
- }
130
- else {
131
- setChainIdSwitchingTo(undefined);
132
- setStepDirection(-1);
133
- setStep(ModalStep.ACCOUNT_MAIN);
134
- }
135
- }
136
- }), [evmSwitchChain, cosmosSwitchChain]);
137
- const connectExternalWallet = useCallback((wallet, isMobileConnect, isManualWalletConnect, isResetAfterManualWalletConnect) => __awaiter(this, void 0, void 0, function* () {
138
- // If triggering the WC modal manually from desktop, disconnect the current connection attempt to trigger the mobile connection attempt
139
- if (isExternalWalletConnecting && isManualWalletConnect) {
140
- yield evmDisconnect();
141
- yield solanaDisconnect();
142
- yield cosmosDisconnect();
143
- setQrUri(undefined);
144
- setIsExternalWalletConnecting(false);
145
- }
146
- if (isResetAfterManualWalletConnect || isManualWalletConnect || !isExternalWalletConnecting) {
147
- setExternalWalletError();
148
- setIsExternalWalletConnecting(true);
149
- setIsUsingMobileConnector(isMobileConnect);
150
- const { address, error } = yield (isMobileConnect ? wallet.connectMobile(isManualWalletConnect) : wallet.connect());
151
- if (error) {
152
- setExternalWalletError([error]);
153
- setIsUsingMobileConnector();
154
- // If triggering the WC modal manually from desktop, attempt desktop reconnect on connection rejection
155
- if (isManualWalletConnect && error === 'Connection request rejected') {
156
- setExternalWalletError();
157
- yield connectExternalWallet(wallet, false, false, true);
158
- yield updateQrUri();
159
- return;
160
- }
161
- }
162
- else if (address) {
163
- setStep(ModalStep.LOGIN_DONE);
164
- }
165
- setIsExternalWalletConnecting(false);
166
- }
167
- }), [isExternalWalletConnecting]);
168
- const disconnectExternalWallet = () => __awaiter(this, void 0, void 0, function* () {
169
- yield evmDisconnect();
170
- yield solanaDisconnect();
171
- yield cosmosDisconnect();
172
- setSelectedExternalWalletId();
173
- });
174
- const walletDisplayHelpers = {
175
- // Show the extension screen if on web and the wallet is an extension and installed or the wallet isn't a mobile wallet
176
- // Also show the extension connection if on desktop for a solana wallet (no walletConnect)
177
- showExtension: !isMobile() && (((wallet === null || wallet === void 0 ? void 0 : wallet.isExtension) && (wallet === null || wallet === void 0 ? void 0 : wallet.installed)) || !(wallet === null || wallet === void 0 ? void 0 : wallet.isMobile) || (wallet === null || wallet === void 0 ? void 0 : wallet.type) === WalletType.SOLANA),
178
- // Show the mobile screen if on mobile and the wallet is a mobile wallet or if on desktop and the wallet isn't installed
179
- showMobile: (isMobile() && (wallet === null || wallet === void 0 ? void 0 : wallet.isMobile)) || (!isMobile() && !(wallet === null || wallet === void 0 ? void 0 : wallet.installed)),
180
- isSolanaMobileIOS: isIOS() && isMobile() && !isIOSWebview() && (wallet === null || wallet === void 0 ? void 0 : wallet.type) === WalletType.SOLANA,
181
- isCosmosMobileWallet: (wallet === null || wallet === void 0 ? void 0 : wallet.type) === WalletType.COSMOS && isUsingMobileConnector,
182
- };
183
- const username = useMemo(() => {
184
- var _a, _b;
185
- let username;
186
- const storedExternalWallet = para.externalWallets[(_b = (_a = para.currentExternalWalletAddresses) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : ''];
187
- if (storedExternalWallet) {
188
- const walletType = storedExternalWallet === null || storedExternalWallet === void 0 ? void 0 : storedExternalWallet.type;
189
- switch (walletType) {
190
- case WalletType.EVM: {
191
- // If evmUsername is an EVM address, format it, else return it since it should be an ENS name
192
- username = evmUsername
193
- ? evmUsername.startsWith('0x')
194
- ? truncateAddress(evmUsername, 'EVM')
195
- : evmUsername
196
- : undefined;
197
- break;
198
- }
199
- default: {
200
- username = storedExternalWallet.address
201
- ? truncateAddress(storedExternalWallet.address, storedExternalWallet.type)
202
- : undefined;
203
- break;
204
- }
205
- }
206
- }
207
- return username;
208
- }, [evmUsername, wallet]);
209
- const avatar = useMemo(() => {
210
- var _a, _b, _c;
211
- const walletType = (_c = para.externalWallets[(_b = (_a = para.currentExternalWalletAddresses) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '']) === null || _c === void 0 ? void 0 : _c.type;
212
- if (walletType) {
213
- switch (walletType) {
214
- case WalletType.EVM: {
215
- return evmAvatar;
216
- }
217
- default: {
218
- return undefined;
219
- }
220
- }
221
- }
222
- }, [evmAvatar, wallet]);
223
- return (_jsx(ExternalWalletContext.Provider, { value: useMemo(() => ({
224
- wallets,
225
- chains,
226
- chainId,
227
- wallet,
228
- qrUri,
229
- walletDisplayHelpers,
230
- chainIdSwitchingTo,
231
- username,
232
- avatar,
233
- connectExternalWallet,
234
- disconnectExternalWallet,
235
- switchChain,
236
- setChainIdSwitchingTo,
237
- }), [
238
- wallets,
239
- chains,
240
- chainId,
241
- wallet,
242
- qrUri,
243
- walletDisplayHelpers,
244
- chainIdSwitchingTo,
245
- username,
246
- avatar,
247
- disconnectExternalWallet,
248
- connectExternalWallet,
249
- switchChain,
250
- setChainIdSwitchingTo,
251
- ]), children: children }));
252
- }
253
- export const useExternalWallets = () => useContext(ExternalWalletContext);
@@ -1,12 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useMemo } from 'react';
3
- export const defaultSolanaExternalWallet = {
4
- wallets: [],
5
- disconnect: () => Promise.resolve(),
6
- };
7
- export const SolanaExternalWalletContext = createContext(defaultSolanaExternalWallet);
8
- export function SolanaExternalWalletProvider({ children }) {
9
- const wallets = [];
10
- const disconnect = () => Promise.resolve();
11
- return (_jsx(SolanaExternalWalletContext.Provider, { value: useMemo(() => ({ wallets, disconnect }), [wallets, disconnect]), children: children }));
12
- }
@@ -1,5 +0,0 @@
1
- export const getActions = (set) => ({
2
- updateState: state => {
3
- set(state);
4
- },
5
- });
@@ -1,13 +0,0 @@
1
- import { create } from 'zustand';
2
- import { getActions } from './actions.js';
3
- const DEFAULT_EX_WALLET_PROVIDER_STATE = {
4
- EvmProvider: undefined,
5
- evmContext: undefined,
6
- SolanaProvider: undefined,
7
- solanaContext: undefined,
8
- CosmosProvider: undefined,
9
- cosmosContext: undefined,
10
- connectParaEvmWallet: undefined,
11
- connectParaCosmosWallet: undefined,
12
- };
13
- export const useExternalWalletProviderStore = create(set => (Object.assign(Object.assign({}, DEFAULT_EX_WALLET_PROVIDER_STATE), getActions(set))));
@@ -1,3 +0,0 @@
1
- export * from './modal/useModalStore.js';
2
- export * from './userInfo/useUserInfoStore.js';
3
- export * from './theme/useThemeStore.js';
@@ -1,64 +0,0 @@
1
- import { DEFAULT_MODAL_STATE } from './useModalStore.js';
2
- import { AccountPreviousStep, LoginPreviousStep, ModalStep, SignUpPreviousStep } from '../../utils/steps.js';
3
- export const getActions = (set, get) => ({
4
- resetState: () => set(DEFAULT_MODAL_STATE),
5
- setOnModalStepChange: onModalStepChange => set({ onModalStepChange }),
6
- setStep: step => {
7
- const onModalStepChange = get().onModalStepChange;
8
- const previousStep = get().step;
9
- set({ step });
10
- onModalStepChange === null || onModalStepChange === void 0 ? void 0 : onModalStepChange({ previousStep, currentStep: step, canGoBack: get().hasPreviousStep() });
11
- },
12
- decrementStep: () => {
13
- const onModalStepChange = get().onModalStepChange;
14
- const isLogin = get().flow === 'login';
15
- const isAccount = get().flow === 'account';
16
- const currentStep = get().step;
17
- const webAuthURLForCreate = get().webAuthURLForCreate;
18
- const iFrameUrl = get().iFrameUrl;
19
- let prevStep = (isAccount ? AccountPreviousStep : isLogin ? LoginPreviousStep : SignUpPreviousStep)[currentStep];
20
- if (currentStep === ModalStep.PASSWORD_CREATION && iFrameUrl && !webAuthURLForCreate) {
21
- prevStep = ModalStep.AUTH_MAIN;
22
- }
23
- if (currentStep === ModalStep.EX_WALLET_SELECTED) {
24
- set({ selectedExternalWalletId: undefined, isExternalWalletConnecting: false, externalWalletError: undefined });
25
- }
26
- if (prevStep) {
27
- set({ step: prevStep, stepDirection: -1 });
28
- onModalStepChange === null || onModalStepChange === void 0 ? void 0 : onModalStepChange({ previousStep: currentStep, currentStep: prevStep, canGoBack: get().hasPreviousStep() });
29
- }
30
- },
31
- hasPreviousStep: () => {
32
- const isLogin = get().flow === 'login';
33
- const isAccount = get().flow === 'account';
34
- const currentStep = get().step;
35
- return !!(isAccount
36
- ? AccountPreviousStep[currentStep]
37
- : isLogin
38
- ? LoginPreviousStep[currentStep]
39
- : SignUpPreviousStep[currentStep]);
40
- },
41
- setPopupWindow: popupWindow => {
42
- set({ popupWindow });
43
- },
44
- setFlow: flow => set({ flow }),
45
- isLogin: () => get().flow === 'login',
46
- isAccount: () => get().flow === 'account',
47
- setWebAuthURLForLogin: url => set({ webAuthURLForLogin: url }),
48
- setWebAuthURLForCreate: url => set({ webAuthURLForCreate: url }),
49
- setPasswordUrlForLogin: url => set({ passwordUrlForLogin: url }),
50
- setSupportedAuthMethods: supportedAuthMethods => set({ supportedAuthMethods }),
51
- setOnRampPurchase: onRampPurchase => set(state => ({ onRampPurchase: Object.assign(Object.assign({}, (state.onRampPurchase || {})), onRampPurchase) })),
52
- setOnRampConfig: onRampConfig => set({ onRampConfig }),
53
- setIsFullyLoggedIn: isFullyLoggedIn => set({ isFullyLoggedIn }),
54
- setAccountAddFundTab: accountAddFundTab => set({ accountAddFundTab }),
55
- setSelectedExternalWalletId: selectedExternalWalletId => set({ selectedExternalWalletId }),
56
- setIsExternalWalletConnecting: isExternalWalletConnecting => set({ isExternalWalletConnecting }),
57
- setExternalWalletError: externalWalletError => set({ externalWalletError }),
58
- setIsUsingMobileConnector: isUsingMobileConnector => set({ isUsingMobileConnector }),
59
- setStepDirection: stepDirection => set({ stepDirection }),
60
- setFarcasterConnectUri: farcasterConnectUri => set({ farcasterConnectUri }),
61
- setBiometricLocationHints: biometricLocationHints => set({ biometricLocationHints }),
62
- setIFrameUrl: iFrameUrl => set({ iFrameUrl }),
63
- setIsIFrameReady: isIFrameReady => set({ isIFrameReady }),
64
- });
@@ -1,41 +0,0 @@
1
- import { create } from 'zustand';
2
- import { persist, createJSONStorage } from 'zustand/middleware';
3
- import { ModalStep } from '../../utils/steps.js';
4
- import { getActions } from './actions.js';
5
- // Omitting step from default here since it's set dynamically when the modal opens and closes
6
- export const DEFAULT_MODAL_STATE = {
7
- flow: undefined,
8
- stepDirection: 1,
9
- webAuthURLForLogin: undefined,
10
- webAuthURLForCreate: undefined,
11
- passwordUrlForLogin: undefined,
12
- supportedAuthMethods: new Set(),
13
- onModalStepChange: undefined,
14
- onRampPurchase: undefined,
15
- popupWindow: undefined,
16
- isFullyLoggedIn: false,
17
- accountAddFundTab: undefined,
18
- isExternalWalletConnecting: false,
19
- externalWalletError: undefined,
20
- activeWallet: [undefined, undefined],
21
- farcasterConnectUri: undefined,
22
- biometricLocationHints: undefined,
23
- iFrameUrl: undefined,
24
- isIFrameReady: undefined,
25
- };
26
- export const useModalStore = create()(persist((set, get) => (Object.assign(Object.assign({ step: ModalStep.AUTH_MAIN, onRampConfig: undefined, activeWallet: undefined }, DEFAULT_MODAL_STATE), getActions(set, get))), {
27
- version: 1,
28
- name: '@CAPSULE/modalState',
29
- storage: createJSONStorage(() => sessionStorage),
30
- partialize: state => ({
31
- step: state.step,
32
- webAuthURLForLogin: state.webAuthURLForLogin,
33
- webAuthURLForCreate: state.webAuthURLForCreate,
34
- passwordUrlForLogin: state.passwordUrlForLogin,
35
- biometricLocationHints: state.biometricLocationHints,
36
- onRampPurchase: state.onRampPurchase,
37
- selectedExternalWalletId: state.selectedExternalWalletId,
38
- isUsingMobileConnector: state.isUsingMobileConnector,
39
- supportedAuthMethods: state.supportedAuthMethods,
40
- }),
41
- }));
@@ -1,5 +0,0 @@
1
- export const getActions = (set) => ({
2
- setPara: para => {
3
- set({ para: para });
4
- },
5
- });
@@ -1,3 +0,0 @@
1
- import { create } from 'zustand';
2
- import { getActions } from './actions.js';
3
- export const useParaStore = create(set => (Object.assign({ para: undefined }, getActions(set))));
@@ -1,24 +0,0 @@
1
- export const getActions = (set, get) => ({
2
- updateState: state => {
3
- set(state);
4
- },
5
- getLogo: () => {
6
- var _a;
7
- return (_a = get().logo) !== null && _a !== void 0 ? _a : undefined;
8
- },
9
- setAuthLayout: authLayout => {
10
- const types = [];
11
- const uniqueLayouts = [];
12
- authLayout.map(layout => {
13
- const type = layout.split(':')[0];
14
- if (!types.includes(type)) {
15
- uniqueLayouts.push(layout);
16
- types.push(type);
17
- }
18
- else {
19
- console.warn(`${layout} is a duplicate ${type} layout type. Please remove the duplicate type from your config.`);
20
- }
21
- });
22
- set({ authLayout: uniqueLayouts });
23
- },
24
- });
@@ -1,14 +0,0 @@
1
- import { create } from 'zustand';
2
- import { getActions } from './actions.js';
3
- import { AuthLayout } from '../../types/modalProps.js';
4
- const DEFAULT_THEME = {
5
- isDark: false,
6
- logo: undefined,
7
- appName: undefined,
8
- bareModal: false,
9
- embeddedModal: false,
10
- oAuthLogoVariant: undefined,
11
- authLayout: [AuthLayout.AUTH_FULL, AuthLayout.EXTERNAL_FULL],
12
- hideWallets: false,
13
- };
14
- export const useThemeStore = create((set, get) => (Object.assign(Object.assign({}, DEFAULT_THEME), getActions(set, get))));
@@ -1,34 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { DEFAULT_USER_INFO_STATE } from './useUserInfoStore.js';
13
- import { extractAuthInfo } from '@getpara/user-management-client';
14
- export const getActions = (set, get) => ({
15
- resetState: () => {
16
- set(DEFAULT_USER_INFO_STATE);
17
- },
18
- setAuthInfo: (_a) => {
19
- var { pfpUrl, displayName } = _a, auth = __rest(_a, ["pfpUrl", "displayName"]);
20
- set({ auth, pfpUrl: pfpUrl || null, displayName: displayName || null });
21
- },
22
- getAuthInfo: () => {
23
- try {
24
- return get().auth
25
- ? Object.assign(Object.assign({}, extractAuthInfo(get().auth, { isRequired: true })), { pfpUrl: get().pfpUrl, displayName: get().displayName }) : null;
26
- }
27
- catch (e) {
28
- return null;
29
- }
30
- },
31
- setRecoveryShare: recoveryShare => {
32
- set({ recoveryShare });
33
- },
34
- });
@@ -1,9 +0,0 @@
1
- import { create } from 'zustand';
2
- import { getActions } from './actions.js';
3
- export const DEFAULT_USER_INFO_STATE = {
4
- auth: null,
5
- recoveryShare: null,
6
- pfpUrl: null,
7
- displayName: null,
8
- };
9
- export const useUserInfoStore = create((set, get) => (Object.assign(Object.assign({}, DEFAULT_USER_INFO_STATE), getActions(set, get))));
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- export var EvmWallet;
2
- (function (EvmWallet) {
3
- EvmWallet["METAMASK"] = "METAMASK";
4
- EvmWallet["RAINBOW"] = "RAINBOW";
5
- EvmWallet["COINBASE"] = "COINBASE";
6
- EvmWallet["WALLETCONNECT"] = "WALLETCONNECT";
7
- EvmWallet["ZERION"] = "ZERION";
8
- EvmWallet["RABBY"] = "RABBY";
9
- })(EvmWallet || (EvmWallet = {}));
10
- export var SolanaWallet;
11
- (function (SolanaWallet) {
12
- SolanaWallet["PHANTOM"] = "PHANTOM";
13
- SolanaWallet["GLOW"] = "GLOW";
14
- SolanaWallet["BACKPACK"] = "BACKPACK";
15
- })(SolanaWallet || (SolanaWallet = {}));
16
- export var CosmosWallet;
17
- (function (CosmosWallet) {
18
- CosmosWallet["KEPLR"] = "KEPLR";
19
- CosmosWallet["LEAP"] = "LEAP";
20
- })(CosmosWallet || (CosmosWallet = {}));
21
- export const ExternalWallet = Object.assign(Object.assign(Object.assign({}, EvmWallet), SolanaWallet), CosmosWallet);
@@ -1,7 +0,0 @@
1
- export var AuthLayout;
2
- (function (AuthLayout) {
3
- AuthLayout["AUTH_FULL"] = "AUTH:FULL";
4
- AuthLayout["AUTH_CONDENSED"] = "AUTH:CONDENSED";
5
- AuthLayout["EXTERNAL_FULL"] = "EXTERNAL:FULL";
6
- AuthLayout["EXTERNAL_CONDENSED"] = "EXTERNAL:CONDENSED";
7
- })(AuthLayout || (AuthLayout = {}));
@@ -1,2 +0,0 @@
1
- export const hasExternalWallet = (authLayout) => authLayout.find(layout => layout.includes('EXTERNAL'));
2
- export const hasEmbeddedAuth = (authLayout) => authLayout.find(layout => layout.includes('AUTH'));
@@ -1,5 +0,0 @@
1
- export function getMailtoLink(email, recoveryShare) {
2
- const emailBody = `Hello,%0D%0DBelow is your Para Recovery Secret. Keep this safe!%0D%0D${recoveryShare}%0D%0DPlease get in touch via support@getpara.com if you have any questions`;
3
- const mailText = `mailto:${email}?subject=Para%20Recovery%20Secret&body=${emailBody}`;
4
- return mailText;
5
- }
@@ -1,15 +0,0 @@
1
- export const getTileButtonFlex = (index, totalItems) => {
2
- const gapOffset = 8 - 8 * 0.333;
3
- if (totalItems < 2) {
4
- return '1 1 auto';
5
- }
6
- if (totalItems % 3 === 0) {
7
- return `0 0 calc(33.333333% - ${gapOffset}px)`;
8
- }
9
- if (totalItems % 3 === 1) {
10
- return index < 4 ? '0 0 calc(50% - 4px)' : `0 0 calc(33.333333% - ${gapOffset}px)`;
11
- }
12
- if (totalItems % 3 === 2) {
13
- return index < 2 ? '0 0 calc(50% - 4px)' : `0 0 calc(33.333333% - ${gapOffset}px)`;
14
- }
15
- };
@@ -1,10 +0,0 @@
1
- import { detect } from 'detect-browser';
2
- export const isPasskeySupported = () => {
3
- const browser = detect();
4
- switch (browser.os) {
5
- case 'linux':
6
- case 'Chrome OS':
7
- return false;
8
- }
9
- return true;
10
- };
@@ -1,55 +0,0 @@
1
- export function openPopup(popupUrl, target, type) {
2
- const popUpWidth = 560;
3
- let popUpHeight;
4
- switch (type) {
5
- case 'LOGIN_PASSWORD': {
6
- popUpHeight = 460;
7
- break;
8
- }
9
- case 'LOGIN_PASSKEY': {
10
- popUpHeight = 798;
11
- break;
12
- }
13
- case 'CREATE_PASSWORD': {
14
- popUpHeight = 400;
15
- break;
16
- }
17
- case 'CREATE_PASSKEY': {
18
- popUpHeight = 464;
19
- break;
20
- }
21
- case 'TRANSACTION_REVIEW': {
22
- popUpHeight = 480;
23
- break;
24
- }
25
- case 'OAUTH':
26
- default: {
27
- popUpHeight = 768;
28
- break;
29
- }
30
- }
31
- // Fixes position when using multiple monitors
32
- const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
33
- const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
34
- const width = window.innerWidth
35
- ? window.innerWidth
36
- : document.documentElement.clientWidth
37
- ? document.documentElement.clientWidth
38
- : screen.width;
39
- const height = window.innerHeight
40
- ? window.innerHeight
41
- : document.documentElement.clientHeight
42
- ? document.documentElement.clientHeight
43
- : screen.height;
44
- const left = (width - popUpWidth) / 2 + dualScreenLeft;
45
- const top = (height - popUpHeight) / 2 + dualScreenTop;
46
- const windowFeatures = `toolbar=no, menubar=no, width=${popUpWidth},
47
- height=${popUpHeight}, top=${top}, left=${left}`;
48
- let popupWindow = window.open(popupUrl, target, windowFeatures);
49
- if (!popupWindow) {
50
- setTimeout(() => {
51
- popupWindow = window.open(popupUrl, '_blank');
52
- }, 0);
53
- }
54
- return popupWindow;
55
- }
@@ -1,35 +0,0 @@
1
- import { isAndroid, isMobile, isTelegram } from '@getpara/web-sdk';
2
- export const routeMobileExternalWallet = (qrUri) => {
3
- if (isMobile()) {
4
- if (!qrUri)
5
- return;
6
- if (!isTelegram() && qrUri.startsWith('http')) {
7
- // Workaround for https://github.com/rainbow-me/rainbowkit/issues/524.
8
- // Using 'window.open' causes issues on iOS in non-Safari browsers and
9
- // WebViews where a blank tab is left behind after connecting.
10
- // This is especially bad in some WebView scenarios (e.g. following a
11
- // link from Twitter) where the user doesn't have any mechanism for
12
- // closing the blank tab.
13
- // For whatever reason, links with a target of "_blank" don't suffer
14
- // from this problem, and programmatically clicking a detached link
15
- // element with the same attributes also avoids the issue.
16
- const link = document.createElement('a');
17
- link.href = qrUri;
18
- link.target = '_blank';
19
- link.rel = 'noreferrer noopener';
20
- link.click();
21
- }
22
- else {
23
- if (isTelegram()) {
24
- let href = qrUri;
25
- if (isAndroid()) {
26
- href = encodeURI(qrUri);
27
- }
28
- window.open(href, '_blank', 'noreferrer noopener');
29
- }
30
- else {
31
- window.location.href = qrUri;
32
- }
33
- }
34
- }
35
- };