@getpara/react-sdk 1.7.0 → 1.8.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/index.js +6 -6657
- package/dist/modal/ParaModal.js +362 -0
- package/dist/modal/components/Account/Account.js +77 -0
- package/dist/modal/components/AddFunds/AddFunds.js +220 -0
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +72 -0
- package/dist/modal/components/AddFunds/AddFundsDone.js +43 -0
- package/dist/{MoonPayEmbed-Q2HP2BFI.js → modal/components/AddFunds/MoonPayEmbed.js} +1 -3
- package/dist/modal/components/AddFunds/index.js +4 -0
- package/dist/modal/components/AuthInput/AuthInput.js +283 -0
- package/dist/modal/components/AuthInput/countryCodes.js +42 -0
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +33 -0
- package/dist/modal/components/AuthInput/phoneMasks.js +253 -0
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +37 -0
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +113 -0
- package/dist/modal/components/AuthOptions/AuthOptions.js +33 -0
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +18 -0
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +10 -0
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +18 -0
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +44 -0
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +55 -0
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +93 -0
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +29 -0
- package/dist/modal/components/Body/Body.js +308 -0
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +94 -0
- package/dist/modal/components/ChainSwitch/config.js +17 -0
- package/dist/modal/components/Controls/Controls.js +74 -0
- package/dist/modal/components/Controls/Selects.js +234 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +140 -0
- package/dist/modal/components/ExternalWalletStep/config.js +17 -0
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +96 -0
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +172 -0
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +124 -0
- package/dist/modal/components/Footer/Footer.js +93 -0
- package/dist/modal/components/Header/Header.js +43 -0
- package/dist/modal/components/Header/hooks/useStepTitle.js +50 -0
- package/dist/modal/components/Hero/Hero.js +116 -0
- package/dist/modal/components/IFrameStep/IFrameStep.js +55 -0
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +28 -0
- package/dist/modal/components/ModalContent/ModalContent.js +324 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +81 -0
- package/dist/modal/components/OAuth/OAuth.js +153 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +139 -0
- package/dist/modal/components/OnRampComponents/AddingFunds.js +23 -0
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +77 -0
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +101 -0
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +141 -0
- package/dist/modal/components/StripeComponents/StripeComponents.js +88 -0
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +24 -0
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +159 -0
- package/dist/modal/components/Waiting/Waiting.js +17 -0
- package/dist/modal/components/WalletCard/PartnerIcon.js +34 -0
- package/dist/modal/components/WalletCard/WalletCard.js +127 -0
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +52 -0
- package/dist/modal/components/common.d.ts +6 -6
- package/dist/modal/components/common.js +96 -0
- package/dist/modal/components/index.js +2 -0
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/constants.js +111 -0
- package/dist/modal/constants/defaults.js +10 -0
- package/dist/modal/constants/oAuthLogos.js +24 -0
- package/dist/modal/hooks/useActiveWallet.js +15 -0
- package/dist/modal/hooks/useCreateAccount.js +72 -0
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +54 -0
- package/dist/modal/hooks/useGoBack.js +42 -0
- package/dist/modal/hooks/useSetLoginURLs.js +49 -0
- package/dist/modal/hooks/useWalletBalance.d.ts +4 -0
- package/dist/modal/hooks/useWalletBalance.js +47 -0
- package/dist/modal/index.js +33 -0
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +38 -0
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +2 -0
- package/dist/modal/providers/EvmExternalWalletContextStub.js +55 -0
- package/dist/modal/providers/ExternalWalletContext.d.ts +3 -0
- package/dist/modal/providers/ExternalWalletContext.js +394 -0
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +32 -0
- package/dist/modal/stores/externalWalletProvider/actions.js +10 -0
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +21 -0
- package/dist/modal/stores/index.js +4 -0
- package/dist/modal/stores/modal/actions.js +70 -0
- package/dist/modal/stores/modal/useModalStore.js +65 -0
- package/dist/modal/stores/theme/actions.js +28 -0
- package/dist/modal/stores/theme/useThemeStore.js +21 -0
- package/dist/modal/stores/userInfo/actions.js +30 -0
- package/dist/modal/stores/userInfo/useUserInfoStore.js +17 -0
- package/dist/modal/types/commonTypes.js +1 -0
- package/dist/modal/types/externalWallets.js +32 -0
- package/dist/modal/types/modalProps.d.ts +4 -0
- package/dist/modal/types/modalProps.js +12 -0
- package/dist/modal/utils/authLayoutHelpers.js +8 -0
- package/dist/modal/utils/getMailtoLink.js +10 -0
- package/dist/modal/utils/getTileButtonFlex.js +20 -0
- package/dist/modal/utils/openPopup.js +60 -0
- package/dist/modal/utils/routeMobileExternalWallet.js +31 -0
- package/dist/modal/utils/steps.js +232 -0
- package/dist/modal/utils/stringFormatters.d.ts +1 -0
- package/dist/modal/utils/stringFormatters.js +19 -0
- package/dist/modal/utils/validateOnRampConfig.js +32 -0
- package/dist/package.json +3 -1
- package/dist/provider/ParaProvider.js +22 -0
- package/dist/provider/actions/checkIfUserExists.js +21 -0
- package/dist/provider/actions/createUser.js +26 -0
- package/dist/provider/actions/getAccount.js +22 -0
- package/dist/provider/actions/getWallet.js +14 -0
- package/dist/provider/actions/getWalletBalance.d.ts +2 -0
- package/dist/provider/actions/getWalletBalance.js +14 -0
- package/dist/provider/actions/initiateLogin.js +20 -0
- package/dist/provider/actions/keepSessionAlive.js +20 -0
- package/dist/provider/actions/logout.js +17 -0
- package/dist/provider/actions/signMessage.js +20 -0
- package/dist/provider/actions/signTransaction.js +20 -0
- package/dist/provider/actions/waitForAccountCreation.js +21 -0
- package/dist/provider/actions/waitForLoginAndSetup.js +24 -0
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +21 -0
- package/dist/provider/hooks/index.js +4 -0
- package/dist/provider/hooks/mutations/index.js +24 -0
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +23 -0
- package/dist/provider/hooks/mutations/useCreateUser.js +20 -0
- package/dist/provider/hooks/mutations/useInitiateLogin.js +23 -0
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +20 -0
- package/dist/provider/hooks/mutations/useLogout.js +30 -0
- package/dist/provider/hooks/mutations/useSignMessage.js +39 -0
- package/dist/provider/hooks/mutations/useSignTransaction.js +39 -0
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +30 -0
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +30 -0
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +30 -0
- package/dist/provider/hooks/queries/index.d.ts +1 -0
- package/dist/provider/hooks/queries/index.js +10 -0
- package/dist/provider/hooks/queries/useAccount.js +21 -0
- package/dist/provider/hooks/queries/useWallet.js +22 -0
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +7 -0
- package/dist/provider/hooks/queries/useWalletBalance.js +26 -0
- package/dist/provider/hooks/utils/index.js +10 -0
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +74 -0
- package/dist/provider/hooks/utils/useClient.js +10 -0
- package/dist/provider/hooks/utils/useEventListeners.js +105 -0
- package/dist/provider/hooks/utils/useInternalClient.js +10 -0
- package/dist/provider/hooks/utils/useModal.js +17 -0
- package/dist/provider/hooks/utils/useWalletState.js +33 -0
- package/dist/provider/index.js +8 -0
- package/dist/provider/stores/getters.js +13 -0
- package/dist/provider/stores/slices/client.js +9 -0
- package/dist/provider/stores/slices/index.js +4 -0
- package/dist/provider/stores/slices/modal.js +9 -0
- package/dist/provider/stores/slices/wallet.js +13 -0
- package/dist/provider/stores/types.d.ts +2 -0
- package/dist/provider/stores/types.js +1 -0
- package/dist/provider/stores/useStore.js +27 -0
- package/dist/provider/types/provider.js +1 -0
- package/dist/provider/types/query.js +1 -0
- package/dist/provider/types/utils.js +1 -0
- package/dist/provider/utils/constants.js +11 -0
- package/dist/provider/utils/renameMutations.js +16 -0
- package/package.json +5 -5
- package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
- package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
- package/dist/chunk-MMUBH76A.js.br +0 -0
- package/dist/chunk-MMUBH76A.js.gz +0 -0
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
7
|
+
import { useModalStore, useUserInfoStore } from "../stores/index.js";
|
|
8
|
+
import { ModalStep } from "../utils/steps.js";
|
|
9
|
+
import { AuthMethod, WalletType, isIOS, isIOSWebview, isMobile, truncateAddress } from "@getpara/web-sdk";
|
|
10
|
+
import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
|
|
11
|
+
import { getExternalWalletDisplayName } from "@getpara/react-common";
|
|
12
|
+
import { useSetLoginURLs } from "../hooks/useSetLoginURLs.js";
|
|
13
|
+
const defaultExternalWallet = {
|
|
14
|
+
wallets: [],
|
|
15
|
+
chains: [],
|
|
16
|
+
chainId: void 0,
|
|
17
|
+
wallet: void 0,
|
|
18
|
+
qrUri: void 0,
|
|
19
|
+
chainIdSwitchingTo: void 0,
|
|
20
|
+
walletDisplayHelpers: {
|
|
21
|
+
showExtension: false,
|
|
22
|
+
showMobile: false,
|
|
23
|
+
isSolanaMobileIOS: false,
|
|
24
|
+
isCosmosMobileWallet: false
|
|
25
|
+
},
|
|
26
|
+
username: void 0,
|
|
27
|
+
avatar: void 0,
|
|
28
|
+
balance: void 0,
|
|
29
|
+
connectExternalWallet: () => {
|
|
30
|
+
},
|
|
31
|
+
disconnectExternalWallet: () => Promise.resolve(),
|
|
32
|
+
switchChain: () => Promise.resolve(),
|
|
33
|
+
setChainIdSwitchingTo: () => {
|
|
34
|
+
},
|
|
35
|
+
verifyWalletSignature: () => Promise.resolve({})
|
|
36
|
+
};
|
|
37
|
+
const ExternalWalletContext = createContext(defaultExternalWallet);
|
|
38
|
+
function ExternalWalletProvider({
|
|
39
|
+
children,
|
|
40
|
+
evmContext,
|
|
41
|
+
solanaContext,
|
|
42
|
+
cosmosContext,
|
|
43
|
+
walletSort,
|
|
44
|
+
externalWalletsWithFullAuth
|
|
45
|
+
}) {
|
|
46
|
+
const {
|
|
47
|
+
wallets: evmWallets,
|
|
48
|
+
disconnect: evmDisconnect,
|
|
49
|
+
chains: evmChains,
|
|
50
|
+
chainId: evmChainId,
|
|
51
|
+
switchChain: evmSwitchChain,
|
|
52
|
+
username: evmUsername,
|
|
53
|
+
avatar: evmAvatar,
|
|
54
|
+
balance: evmBalance,
|
|
55
|
+
signVerificationMessage: evmSignVerificationMessage
|
|
56
|
+
} = useContext(evmContext);
|
|
57
|
+
const {
|
|
58
|
+
wallets: solanaWallets,
|
|
59
|
+
disconnect: solanaDisconnect,
|
|
60
|
+
signVerificationMessage: solanaSignVerificationMessage
|
|
61
|
+
} = useContext(solanaContext);
|
|
62
|
+
const {
|
|
63
|
+
wallets: cosmosWallets,
|
|
64
|
+
disconnect: cosmosDisconnect,
|
|
65
|
+
chains: cosmosChains,
|
|
66
|
+
chainId: cosmosChainId,
|
|
67
|
+
switchChain: cosmosSwitchChain,
|
|
68
|
+
signVerificationMessage: cosmosSignVerificationMessage
|
|
69
|
+
} = useContext(cosmosContext);
|
|
70
|
+
const setStep = useModalStore((state) => state.setStep);
|
|
71
|
+
const setFlow = useModalStore((state) => state.setFlow);
|
|
72
|
+
const setSupportedAuthMethods = useModalStore((state) => state.setSupportedAuthMethods);
|
|
73
|
+
const setBiometricLocationHints = useModalStore((state) => state.setBiometricLocationHints);
|
|
74
|
+
const setStepDirection = useModalStore((state) => state.setStepDirection);
|
|
75
|
+
const setIsExternalWalletConnecting = useModalStore((state) => state.setIsExternalWalletConnecting);
|
|
76
|
+
const isExternalWalletConnecting = useModalStore((state) => state.isExternalWalletConnecting);
|
|
77
|
+
const setSelectedExternalWalletId = useModalStore((state) => state.setSelectedExternalWalletId);
|
|
78
|
+
const selectedExternalWalletId = useModalStore((state) => state.selectedExternalWalletId);
|
|
79
|
+
const setExternalWalletError = useModalStore((state) => state.setExternalWalletError);
|
|
80
|
+
const setIsUsingMobileConnector = useModalStore((state) => state.setIsUsingMobileConnector);
|
|
81
|
+
const isUsingMobileConnector = useModalStore((state) => state.isUsingMobileConnector);
|
|
82
|
+
const para = useInternalClient();
|
|
83
|
+
const setAuthInfo = useUserInfoStore((state) => state.setAuthInfo);
|
|
84
|
+
const setLoginURLs = useSetLoginURLs();
|
|
85
|
+
const [qrUri, setQrUri] = useState();
|
|
86
|
+
const [chainIdSwitchingTo, setChainIdSwitchingTo] = useState();
|
|
87
|
+
const wallets = [...evmWallets, ...solanaWallets, ...cosmosWallets].filter((w) => walletSort.includes(w.id.toUpperCase())).sort(
|
|
88
|
+
(a, b) => walletSort.indexOf(a.id.toUpperCase()) - walletSort.indexOf(b.id.toUpperCase())
|
|
89
|
+
).sort((a, b) => a.installed === b.installed ? 0 : a.installed ? -1 : 1);
|
|
90
|
+
const wallet = useMemo(() => wallets.find((w) => w.id === selectedExternalWalletId), [wallets, selectedExternalWalletId]);
|
|
91
|
+
const updateQrUri = () => __async(this, null, function* () {
|
|
92
|
+
var _a;
|
|
93
|
+
const uri = yield (_a = wallet == null ? void 0 : wallet.getQrUri) == null ? void 0 : _a.call(wallet);
|
|
94
|
+
setQrUri(uri);
|
|
95
|
+
});
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (wallet) {
|
|
98
|
+
if (!qrUri) {
|
|
99
|
+
updateQrUri();
|
|
100
|
+
}
|
|
101
|
+
} else if (qrUri) {
|
|
102
|
+
setQrUri(void 0);
|
|
103
|
+
}
|
|
104
|
+
}, [wallet]);
|
|
105
|
+
const balance = useMemo(() => {
|
|
106
|
+
var _a;
|
|
107
|
+
const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
|
|
108
|
+
switch (walletType) {
|
|
109
|
+
case WalletType.EVM: {
|
|
110
|
+
return evmBalance;
|
|
111
|
+
}
|
|
112
|
+
default: {
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}, [evmBalance, selectedExternalWalletId]);
|
|
117
|
+
const chains = useMemo(() => {
|
|
118
|
+
var _a;
|
|
119
|
+
const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
|
|
120
|
+
switch (walletType) {
|
|
121
|
+
case WalletType.COSMOS: {
|
|
122
|
+
return cosmosChains;
|
|
123
|
+
}
|
|
124
|
+
case WalletType.EVM: {
|
|
125
|
+
return evmChains;
|
|
126
|
+
}
|
|
127
|
+
default: {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}, [cosmosChains, evmChains, selectedExternalWalletId]);
|
|
132
|
+
const chainId = useMemo(() => {
|
|
133
|
+
var _a;
|
|
134
|
+
const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
|
|
135
|
+
switch (walletType) {
|
|
136
|
+
case WalletType.COSMOS: {
|
|
137
|
+
return cosmosChainId;
|
|
138
|
+
}
|
|
139
|
+
case WalletType.EVM: {
|
|
140
|
+
return evmChainId == null ? void 0 : evmChainId.toString();
|
|
141
|
+
}
|
|
142
|
+
default: {
|
|
143
|
+
return void 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, [cosmosChains, evmChains, selectedExternalWalletId]);
|
|
147
|
+
const switchChain = useCallback(
|
|
148
|
+
(chainId2) => __async(this, null, function* () {
|
|
149
|
+
var _a;
|
|
150
|
+
const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
|
|
151
|
+
if (walletType) {
|
|
152
|
+
let resp;
|
|
153
|
+
setExternalWalletError();
|
|
154
|
+
setChainIdSwitchingTo(chainId2);
|
|
155
|
+
switch (walletType) {
|
|
156
|
+
case WalletType.COSMOS: {
|
|
157
|
+
setStep(ModalStep.CHAIN_SWITCH);
|
|
158
|
+
resp = yield cosmosSwitchChain(chainId2);
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
case WalletType.EVM: {
|
|
162
|
+
setStep(ModalStep.CHAIN_SWITCH);
|
|
163
|
+
resp = yield evmSwitchChain(parseInt(chainId2));
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
default: {
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (resp.error) {
|
|
171
|
+
setExternalWalletError(resp.error);
|
|
172
|
+
} else {
|
|
173
|
+
setChainIdSwitchingTo(void 0);
|
|
174
|
+
setStepDirection(-1);
|
|
175
|
+
setStep(ModalStep.ACCOUNT_MAIN);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}),
|
|
179
|
+
[evmSwitchChain, cosmosSwitchChain]
|
|
180
|
+
);
|
|
181
|
+
const verifyWalletSignature = useCallback(() => __async(this, null, function* () {
|
|
182
|
+
var _a;
|
|
183
|
+
setExternalWalletError();
|
|
184
|
+
const walletType = (_a = Object.values(para.externalWallets)[0]) == null ? void 0 : _a.type;
|
|
185
|
+
if (walletType) {
|
|
186
|
+
const resp = {
|
|
187
|
+
address: "",
|
|
188
|
+
signature: "",
|
|
189
|
+
cosmosPublicKeyHex: "",
|
|
190
|
+
cosmosSigner: ""
|
|
191
|
+
};
|
|
192
|
+
switch (walletType) {
|
|
193
|
+
case WalletType.COSMOS: {
|
|
194
|
+
const { signature, error, cosmosPublicKeyHex, cosmosSigner, address } = yield cosmosSignVerificationMessage();
|
|
195
|
+
if (error) {
|
|
196
|
+
setExternalWalletError([error]);
|
|
197
|
+
} else if (signature) {
|
|
198
|
+
resp.address = address;
|
|
199
|
+
resp.signature = signature;
|
|
200
|
+
resp.cosmosPublicKeyHex = cosmosPublicKeyHex;
|
|
201
|
+
resp.cosmosSigner = cosmosSigner;
|
|
202
|
+
}
|
|
203
|
+
return resp;
|
|
204
|
+
}
|
|
205
|
+
case WalletType.EVM: {
|
|
206
|
+
const { signature, error, address } = yield evmSignVerificationMessage();
|
|
207
|
+
if (error) {
|
|
208
|
+
setExternalWalletError([error]);
|
|
209
|
+
} else if (signature && address) {
|
|
210
|
+
resp.address = address;
|
|
211
|
+
resp.signature = signature;
|
|
212
|
+
}
|
|
213
|
+
return resp;
|
|
214
|
+
}
|
|
215
|
+
case WalletType.SOLANA: {
|
|
216
|
+
const { signature, error, address } = yield solanaSignVerificationMessage();
|
|
217
|
+
if (error) {
|
|
218
|
+
setExternalWalletError([error]);
|
|
219
|
+
} else if (signature && address) {
|
|
220
|
+
resp.address = address;
|
|
221
|
+
resp.signature = signature;
|
|
222
|
+
}
|
|
223
|
+
return resp;
|
|
224
|
+
}
|
|
225
|
+
default: {
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}), [evmSwitchChain, cosmosSwitchChain]);
|
|
231
|
+
const completeFullAuth = (address, type, userExists, isVerified, bufferAddress) => __async(this, null, function* () {
|
|
232
|
+
setAuthInfo({
|
|
233
|
+
displayName: getExternalWalletDisplayName({
|
|
234
|
+
address,
|
|
235
|
+
type
|
|
236
|
+
}),
|
|
237
|
+
externalWalletAddress: bufferAddress != null ? bufferAddress : address
|
|
238
|
+
});
|
|
239
|
+
if (userExists && isVerified) {
|
|
240
|
+
const supportedAuthMethods = yield para.supportedAuthMethods({
|
|
241
|
+
externalWalletAddress: bufferAddress != null ? bufferAddress : address
|
|
242
|
+
});
|
|
243
|
+
if (!supportedAuthMethods.size) {
|
|
244
|
+
setFlow("signUp");
|
|
245
|
+
setStep(ModalStep.EXTERNAL_WALLET_VERIFICATION);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
yield para.initiateUserLoginV2({
|
|
249
|
+
externalWalletAddress: bufferAddress != null ? bufferAddress : address
|
|
250
|
+
});
|
|
251
|
+
const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY) ? yield para.getUserBiometricLocationHints() : [];
|
|
252
|
+
yield setLoginURLs({ supportedAuthMethods, authType: "externalWallet" });
|
|
253
|
+
setFlow("login");
|
|
254
|
+
setStep(ModalStep.BIOMETRIC_LOGIN);
|
|
255
|
+
setSupportedAuthMethods(supportedAuthMethods);
|
|
256
|
+
setBiometricLocationHints(biometricLocationHints);
|
|
257
|
+
} else {
|
|
258
|
+
setFlow("signUp");
|
|
259
|
+
setStep(ModalStep.EXTERNAL_WALLET_VERIFICATION);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
const connectExternalWallet = useCallback(
|
|
263
|
+
(wallet2, isMobileConnect, isManualWalletConnect, isResetAfterManualWalletConnect) => __async(this, null, function* () {
|
|
264
|
+
if (isExternalWalletConnecting && isManualWalletConnect) {
|
|
265
|
+
yield evmDisconnect();
|
|
266
|
+
yield solanaDisconnect();
|
|
267
|
+
yield cosmosDisconnect();
|
|
268
|
+
setQrUri(void 0);
|
|
269
|
+
setIsExternalWalletConnecting(false);
|
|
270
|
+
}
|
|
271
|
+
if (isResetAfterManualWalletConnect || isManualWalletConnect || !isExternalWalletConnecting) {
|
|
272
|
+
setExternalWalletError();
|
|
273
|
+
setIsExternalWalletConnecting(true);
|
|
274
|
+
setIsUsingMobileConnector(isMobileConnect);
|
|
275
|
+
const { address, bufferAddress, error, userExists, isVerified } = yield isMobileConnect ? wallet2.connectMobile({ isManualWalletConnect }) : wallet2.connect();
|
|
276
|
+
if (error) {
|
|
277
|
+
setExternalWalletError([error]);
|
|
278
|
+
setIsUsingMobileConnector();
|
|
279
|
+
if (isManualWalletConnect && error === "Connection request rejected") {
|
|
280
|
+
setExternalWalletError();
|
|
281
|
+
yield connectExternalWallet(wallet2, false, false, true);
|
|
282
|
+
yield updateQrUri();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
} else if (address) {
|
|
286
|
+
if (externalWalletsWithFullAuth == null ? void 0 : externalWalletsWithFullAuth.includes(wallet2.id.toUpperCase())) {
|
|
287
|
+
yield completeFullAuth(address, wallet2.type, userExists, isVerified, bufferAddress);
|
|
288
|
+
} else {
|
|
289
|
+
setStep(ModalStep.LOGIN_DONE);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
setIsExternalWalletConnecting(false);
|
|
293
|
+
}
|
|
294
|
+
}),
|
|
295
|
+
[isExternalWalletConnecting, externalWalletsWithFullAuth]
|
|
296
|
+
);
|
|
297
|
+
const disconnectExternalWallet = () => __async(this, null, function* () {
|
|
298
|
+
yield para.logout();
|
|
299
|
+
yield evmDisconnect();
|
|
300
|
+
yield cosmosDisconnect();
|
|
301
|
+
setSelectedExternalWalletId();
|
|
302
|
+
yield solanaDisconnect();
|
|
303
|
+
});
|
|
304
|
+
const walletDisplayHelpers = {
|
|
305
|
+
// Show the extension screen if on web and the wallet is an extension and installed or the wallet isn't a mobile wallet
|
|
306
|
+
// Also show the extension connection if on desktop for a solana wallet (no walletConnect)
|
|
307
|
+
showExtension: !isMobile() && ((wallet == null ? void 0 : wallet.isExtension) && (wallet == null ? void 0 : wallet.installed) || !(wallet == null ? void 0 : wallet.isMobile) || (wallet == null ? void 0 : wallet.type) === WalletType.SOLANA),
|
|
308
|
+
// Show the mobile screen if on mobile and the wallet is a mobile wallet or if on desktop and the wallet isn't installed
|
|
309
|
+
showMobile: isMobile() && (wallet == null ? void 0 : wallet.isMobile) || !isMobile() && !(wallet == null ? void 0 : wallet.installed),
|
|
310
|
+
isSolanaMobileIOS: isIOS() && isMobile() && !isIOSWebview() && (wallet == null ? void 0 : wallet.type) === WalletType.SOLANA,
|
|
311
|
+
isCosmosMobileWallet: (wallet == null ? void 0 : wallet.type) === WalletType.COSMOS && isUsingMobileConnector
|
|
312
|
+
};
|
|
313
|
+
const username = useMemo(() => {
|
|
314
|
+
let username2;
|
|
315
|
+
const storedExternalWallet = Object.values(para.externalWallets || {})[0];
|
|
316
|
+
if (storedExternalWallet) {
|
|
317
|
+
const walletType = storedExternalWallet == null ? void 0 : storedExternalWallet.type;
|
|
318
|
+
switch (walletType) {
|
|
319
|
+
case WalletType.EVM: {
|
|
320
|
+
username2 = evmUsername ? evmUsername.startsWith("0x") ? truncateAddress(evmUsername, "EVM") : evmUsername : void 0;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
default: {
|
|
324
|
+
username2 = storedExternalWallet.address ? truncateAddress(storedExternalWallet.address, storedExternalWallet.type) : void 0;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return username2;
|
|
330
|
+
}, [evmUsername, wallet]);
|
|
331
|
+
const avatar = useMemo(() => {
|
|
332
|
+
var _a;
|
|
333
|
+
const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
|
|
334
|
+
if (walletType) {
|
|
335
|
+
switch (walletType) {
|
|
336
|
+
case WalletType.EVM: {
|
|
337
|
+
return evmAvatar;
|
|
338
|
+
}
|
|
339
|
+
default: {
|
|
340
|
+
return void 0;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}, [evmAvatar, wallet]);
|
|
345
|
+
return /* @__PURE__ */ jsx(
|
|
346
|
+
ExternalWalletContext.Provider,
|
|
347
|
+
{
|
|
348
|
+
value: useMemo(
|
|
349
|
+
() => ({
|
|
350
|
+
wallets,
|
|
351
|
+
chains,
|
|
352
|
+
chainId,
|
|
353
|
+
wallet,
|
|
354
|
+
qrUri,
|
|
355
|
+
walletDisplayHelpers,
|
|
356
|
+
chainIdSwitchingTo,
|
|
357
|
+
username,
|
|
358
|
+
avatar,
|
|
359
|
+
balance,
|
|
360
|
+
connectExternalWallet,
|
|
361
|
+
disconnectExternalWallet,
|
|
362
|
+
switchChain,
|
|
363
|
+
setChainIdSwitchingTo,
|
|
364
|
+
verifyWalletSignature
|
|
365
|
+
}),
|
|
366
|
+
[
|
|
367
|
+
wallets,
|
|
368
|
+
chains,
|
|
369
|
+
chainId,
|
|
370
|
+
wallet,
|
|
371
|
+
qrUri,
|
|
372
|
+
walletDisplayHelpers,
|
|
373
|
+
chainIdSwitchingTo,
|
|
374
|
+
username,
|
|
375
|
+
avatar,
|
|
376
|
+
balance,
|
|
377
|
+
disconnectExternalWallet,
|
|
378
|
+
connectExternalWallet,
|
|
379
|
+
switchChain,
|
|
380
|
+
setChainIdSwitchingTo,
|
|
381
|
+
verifyWalletSignature
|
|
382
|
+
]
|
|
383
|
+
),
|
|
384
|
+
children
|
|
385
|
+
}
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
const useExternalWallets = () => useContext(ExternalWalletContext);
|
|
389
|
+
export {
|
|
390
|
+
ExternalWalletContext,
|
|
391
|
+
ExternalWalletProvider,
|
|
392
|
+
defaultExternalWallet,
|
|
393
|
+
useExternalWallets
|
|
394
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createContext, useMemo } from "react";
|
|
5
|
+
const defaultSolanaExternalWallet = {
|
|
6
|
+
wallets: [],
|
|
7
|
+
disconnect: () => Promise.resolve(),
|
|
8
|
+
signMessage: () => Promise.resolve({}),
|
|
9
|
+
signVerificationMessage: () => Promise.resolve({})
|
|
10
|
+
};
|
|
11
|
+
const SolanaExternalWalletContext = createContext(defaultSolanaExternalWallet);
|
|
12
|
+
function SolanaExternalWalletProvider({ children }) {
|
|
13
|
+
const wallets = [];
|
|
14
|
+
const disconnect = () => Promise.resolve();
|
|
15
|
+
const signMessage = () => Promise.resolve({});
|
|
16
|
+
const signVerificationMessage = () => Promise.resolve({});
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
SolanaExternalWalletContext.Provider,
|
|
19
|
+
{
|
|
20
|
+
value: useMemo(
|
|
21
|
+
() => ({ wallets, disconnect, signMessage, signVerificationMessage }),
|
|
22
|
+
[wallets, disconnect, signMessage, signVerificationMessage]
|
|
23
|
+
),
|
|
24
|
+
children
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
SolanaExternalWalletContext,
|
|
30
|
+
SolanaExternalWalletProvider,
|
|
31
|
+
defaultSolanaExternalWallet
|
|
32
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { create } from "zustand";
|
|
6
|
+
import { getActions } from "./actions.js";
|
|
7
|
+
const DEFAULT_EX_WALLET_PROVIDER_STATE = {
|
|
8
|
+
EvmProvider: void 0,
|
|
9
|
+
evmContext: void 0,
|
|
10
|
+
SolanaProvider: void 0,
|
|
11
|
+
solanaContext: void 0,
|
|
12
|
+
CosmosProvider: void 0,
|
|
13
|
+
cosmosContext: void 0,
|
|
14
|
+
connectParaEvmWallet: void 0,
|
|
15
|
+
connectParaCosmosWallet: void 0,
|
|
16
|
+
fullAuthWallets: []
|
|
17
|
+
};
|
|
18
|
+
const useExternalWalletProviderStore = create((set) => __spreadValues(__spreadValues({}, DEFAULT_EX_WALLET_PROVIDER_STATE), getActions(set)));
|
|
19
|
+
export {
|
|
20
|
+
useExternalWalletProviderStore
|
|
21
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { DEFAULT_MODAL_STATE } from "./useModalStore.js";
|
|
6
|
+
import { AccountPreviousStep, LoginPreviousStep, ModalStep, SignUpPreviousStep } from "../../utils/steps.js";
|
|
7
|
+
const getActions = (set, get) => ({
|
|
8
|
+
resetState: () => set(DEFAULT_MODAL_STATE),
|
|
9
|
+
setOnModalStepChange: (onModalStepChange) => set({ onModalStepChange }),
|
|
10
|
+
setStep: (step) => {
|
|
11
|
+
const onModalStepChange = get().onModalStepChange;
|
|
12
|
+
const previousStep = get().step;
|
|
13
|
+
set({ step });
|
|
14
|
+
onModalStepChange == null ? void 0 : onModalStepChange({ previousStep, currentStep: step, canGoBack: get().hasPreviousStep() });
|
|
15
|
+
},
|
|
16
|
+
decrementStep: () => {
|
|
17
|
+
var _a;
|
|
18
|
+
const onModalStepChange = get().onModalStepChange;
|
|
19
|
+
const isLogin = get().flow === "login";
|
|
20
|
+
const isAccount = get().flow === "account";
|
|
21
|
+
const currentStep = get().step;
|
|
22
|
+
const webAuthURLForCreate = get().webAuthURLForCreate;
|
|
23
|
+
const iFrameUrl = get().iFrameUrl;
|
|
24
|
+
const refs = get().refs;
|
|
25
|
+
let prevStep = (isAccount ? AccountPreviousStep : isLogin ? LoginPreviousStep : SignUpPreviousStep)[currentStep];
|
|
26
|
+
if (currentStep === ModalStep.PASSWORD_CREATION && iFrameUrl && !webAuthURLForCreate) {
|
|
27
|
+
prevStep = ModalStep.AUTH_MAIN;
|
|
28
|
+
}
|
|
29
|
+
if (currentStep === ModalStep.EX_WALLET_SELECTED) {
|
|
30
|
+
set({ selectedExternalWalletId: void 0, isExternalWalletConnecting: false, externalWalletError: void 0 });
|
|
31
|
+
}
|
|
32
|
+
if (prevStep) {
|
|
33
|
+
set({ step: prevStep, stepDirection: -1 });
|
|
34
|
+
onModalStepChange == null ? void 0 : onModalStepChange({ previousStep: currentStep, currentStep: prevStep, canGoBack: get().hasPreviousStep() });
|
|
35
|
+
}
|
|
36
|
+
(_a = refs.popupWindow.current) == null ? void 0 : _a.close();
|
|
37
|
+
refs.popupWindow.current = void 0;
|
|
38
|
+
},
|
|
39
|
+
hasPreviousStep: () => {
|
|
40
|
+
const isLogin = get().flow === "login";
|
|
41
|
+
const isAccount = get().flow === "account";
|
|
42
|
+
const currentStep = get().step;
|
|
43
|
+
return !!(isAccount ? AccountPreviousStep[currentStep] : isLogin ? LoginPreviousStep[currentStep] : SignUpPreviousStep[currentStep]);
|
|
44
|
+
},
|
|
45
|
+
setFlow: (flow) => set({ flow }),
|
|
46
|
+
isLogin: () => get().flow === "login",
|
|
47
|
+
isAccount: () => get().flow === "account",
|
|
48
|
+
setWebAuthURLForLogin: (url) => set({ webAuthURLForLogin: url }),
|
|
49
|
+
setWebAuthURLForCreate: (url) => set({ webAuthURLForCreate: url }),
|
|
50
|
+
setPasswordUrlForLogin: (url) => set({ passwordUrlForLogin: url }),
|
|
51
|
+
setSupportedAuthMethods: (supportedAuthMethods) => set({ supportedAuthMethods }),
|
|
52
|
+
setOnRampPurchase: (onRampPurchase) => set((state) => ({ onRampPurchase: __spreadValues(__spreadValues({}, state.onRampPurchase || {}), onRampPurchase) })),
|
|
53
|
+
setOnRampConfig: (onRampConfig) => set({ onRampConfig }),
|
|
54
|
+
setIsFullyLoggedIn: (isFullyLoggedIn) => set({ isFullyLoggedIn }),
|
|
55
|
+
setAccountAddFundTab: (accountAddFundTab) => set({ accountAddFundTab }),
|
|
56
|
+
setSelectedExternalWalletId: (selectedExternalWalletId) => set({ selectedExternalWalletId }),
|
|
57
|
+
setIsExternalWalletConnecting: (isExternalWalletConnecting) => set({ isExternalWalletConnecting }),
|
|
58
|
+
setExternalWalletError: (externalWalletError) => set({ externalWalletError }),
|
|
59
|
+
setIsUsingMobileConnector: (isUsingMobileConnector) => set({ isUsingMobileConnector }),
|
|
60
|
+
setStepDirection: (stepDirection) => set({ stepDirection }),
|
|
61
|
+
setFarcasterConnectUri: (farcasterConnectUri) => set({ farcasterConnectUri }),
|
|
62
|
+
setBiometricLocationHints: (biometricLocationHints) => set({ biometricLocationHints }),
|
|
63
|
+
setIFrameUrl: (iFrameUrl) => set({ iFrameUrl }),
|
|
64
|
+
setIsIFrameReady: (isIFrameReady) => set({ isIFrameReady }),
|
|
65
|
+
setAuthStepRoute: (authStepRoute) => set({ authStepRoute }),
|
|
66
|
+
setIsPasskeySupported: (isPasskeySupported) => set({ isPasskeySupported })
|
|
67
|
+
});
|
|
68
|
+
export {
|
|
69
|
+
getActions
|
|
70
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { create } from "zustand";
|
|
6
|
+
import { persist, createJSONStorage } from "zustand/middleware";
|
|
7
|
+
import { ModalStep } from "../../utils/steps.js";
|
|
8
|
+
import { getActions } from "./actions.js";
|
|
9
|
+
import { createRef } from "react";
|
|
10
|
+
const DEFAULT_MODAL_STATE = {
|
|
11
|
+
flow: void 0,
|
|
12
|
+
stepDirection: 1,
|
|
13
|
+
webAuthURLForLogin: void 0,
|
|
14
|
+
webAuthURLForCreate: void 0,
|
|
15
|
+
passwordUrlForLogin: void 0,
|
|
16
|
+
supportedAuthMethods: /* @__PURE__ */ new Set(),
|
|
17
|
+
onModalStepChange: void 0,
|
|
18
|
+
onRampPurchase: void 0,
|
|
19
|
+
isFullyLoggedIn: false,
|
|
20
|
+
accountAddFundTab: void 0,
|
|
21
|
+
isExternalWalletConnecting: false,
|
|
22
|
+
externalWalletError: void 0,
|
|
23
|
+
activeWallet: [void 0, void 0],
|
|
24
|
+
farcasterConnectUri: void 0,
|
|
25
|
+
biometricLocationHints: void 0,
|
|
26
|
+
iFrameUrl: void 0,
|
|
27
|
+
isIFrameReady: void 0,
|
|
28
|
+
refs: {
|
|
29
|
+
popupWindow: createRef(),
|
|
30
|
+
poll: createRef(),
|
|
31
|
+
currentStep: createRef()
|
|
32
|
+
},
|
|
33
|
+
authStepRoute: void 0,
|
|
34
|
+
isPasskeySupported: true
|
|
35
|
+
};
|
|
36
|
+
const useModalStore = create()(
|
|
37
|
+
persist(
|
|
38
|
+
(set, get) => __spreadValues(__spreadValues({
|
|
39
|
+
step: ModalStep.AUTH_MAIN,
|
|
40
|
+
onRampConfig: void 0,
|
|
41
|
+
activeWallet: void 0
|
|
42
|
+
}, DEFAULT_MODAL_STATE), getActions(set, get)),
|
|
43
|
+
{
|
|
44
|
+
version: 1,
|
|
45
|
+
name: "@PARA/modalState",
|
|
46
|
+
storage: createJSONStorage(() => localStorage),
|
|
47
|
+
partialize: (state) => ({
|
|
48
|
+
step: state.step,
|
|
49
|
+
webAuthURLForLogin: state.webAuthURLForLogin,
|
|
50
|
+
webAuthURLForCreate: state.webAuthURLForCreate,
|
|
51
|
+
passwordUrlForLogin: state.passwordUrlForLogin,
|
|
52
|
+
biometricLocationHints: state.biometricLocationHints,
|
|
53
|
+
onRampPurchase: state.onRampPurchase,
|
|
54
|
+
selectedExternalWalletId: state.selectedExternalWalletId,
|
|
55
|
+
isUsingMobileConnector: state.isUsingMobileConnector,
|
|
56
|
+
supportedAuthMethods: state.supportedAuthMethods,
|
|
57
|
+
isPasskeySupported: state.isPasskeySupported
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
export {
|
|
63
|
+
DEFAULT_MODAL_STATE,
|
|
64
|
+
useModalStore
|
|
65
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
const getActions = (set, get) => ({
|
|
4
|
+
updateState: (state) => {
|
|
5
|
+
set(state);
|
|
6
|
+
},
|
|
7
|
+
getLogo: () => {
|
|
8
|
+
var _a;
|
|
9
|
+
return (_a = get().logo) != null ? _a : void 0;
|
|
10
|
+
},
|
|
11
|
+
setAuthLayout: (authLayout) => {
|
|
12
|
+
const types = [];
|
|
13
|
+
const uniqueLayouts = [];
|
|
14
|
+
authLayout.map((layout) => {
|
|
15
|
+
const type = layout.split(":")[0];
|
|
16
|
+
if (!types.includes(type)) {
|
|
17
|
+
uniqueLayouts.push(layout);
|
|
18
|
+
types.push(type);
|
|
19
|
+
} else {
|
|
20
|
+
console.warn(`${layout} is a duplicate ${type} layout type. Please remove the duplicate type from your config.`);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
set({ authLayout: uniqueLayouts });
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export {
|
|
27
|
+
getActions
|
|
28
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { create } from "zustand";
|
|
6
|
+
import { getActions } from "./actions.js";
|
|
7
|
+
import { AuthLayout } from "../../types/modalProps.js";
|
|
8
|
+
const DEFAULT_THEME = {
|
|
9
|
+
isDark: false,
|
|
10
|
+
logo: void 0,
|
|
11
|
+
appName: void 0,
|
|
12
|
+
bareModal: false,
|
|
13
|
+
embeddedModal: false,
|
|
14
|
+
oAuthLogoVariant: void 0,
|
|
15
|
+
authLayout: [AuthLayout.AUTH_FULL, AuthLayout.EXTERNAL_FULL],
|
|
16
|
+
hideWallets: false
|
|
17
|
+
};
|
|
18
|
+
const useThemeStore = create((set, get) => __spreadValues(__spreadValues({}, DEFAULT_THEME), getActions(set, get)));
|
|
19
|
+
export {
|
|
20
|
+
useThemeStore
|
|
21
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
7
|
+
import { DEFAULT_USER_INFO_STATE } from "./useUserInfoStore.js";
|
|
8
|
+
import { extractAuthInfo } from "@getpara/user-management-client";
|
|
9
|
+
const getActions = (set, get) => ({
|
|
10
|
+
resetState: () => {
|
|
11
|
+
set(DEFAULT_USER_INFO_STATE);
|
|
12
|
+
},
|
|
13
|
+
setAuthInfo: (_a) => {
|
|
14
|
+
var _b = _a, { pfpUrl, displayName } = _b, auth = __objRest(_b, ["pfpUrl", "displayName"]);
|
|
15
|
+
set({ auth, pfpUrl: pfpUrl || null, displayName: displayName || null });
|
|
16
|
+
},
|
|
17
|
+
getAuthInfo: () => {
|
|
18
|
+
try {
|
|
19
|
+
return get().auth ? __spreadProps(__spreadValues({}, extractAuthInfo(get().auth, { isRequired: true })), { pfpUrl: get().pfpUrl, displayName: get().displayName }) : null;
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
setRecoveryShare: (recoveryShare) => {
|
|
25
|
+
set({ recoveryShare });
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
export {
|
|
29
|
+
getActions
|
|
30
|
+
};
|