@getpara/react-sdk 1.12.0 → 2.0.0-alpha.10
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/cli/cli.mjs +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/modal/ParaModal.js +211 -313
- package/dist/modal/components/Account/Account.js +73 -16
- package/dist/modal/components/AddFunds/AddFunds.js +5 -6
- package/dist/modal/components/AddFunds/AddFundsAsset.js +15 -13
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +16 -10
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +2 -2
- package/dist/modal/components/AddFunds/AddFundsContext.js +20 -14
- package/dist/modal/components/AddFunds/AddFundsDone.js +10 -4
- package/dist/modal/components/AddFunds/AddFundsProvider.js +11 -7
- package/dist/modal/components/AddFunds/AddFundsReceive.js +17 -13
- package/dist/modal/components/AddFunds/AddFundsSettings.js +10 -6
- package/dist/modal/components/AddFunds/common.d.ts +1 -1
- package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
- package/dist/modal/components/AuthInput/AuthInput.js +70 -91
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +4 -4
- package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +20 -7
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +54 -10
- package/dist/modal/components/AuthOptions/AuthOptions.d.ts +4 -3
- package/dist/modal/components/AuthOptions/AuthOptions.js +35 -7
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +5 -1
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +9 -4
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -3
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +25 -17
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -1
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +34 -72
- package/dist/modal/components/Body/Body.d.ts +4 -3
- package/dist/modal/components/Body/Body.js +27 -10
- package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +5 -4
- package/dist/modal/components/Controls/Controls.js +5 -2
- package/dist/modal/components/Controls/Selects.d.ts +1 -1
- package/dist/modal/components/Controls/Selects.js +30 -25
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +10 -6
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +7 -69
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +7 -6
- package/dist/modal/components/Footer/Footer.d.ts +1 -1
- package/dist/modal/components/Footer/Footer.js +6 -4
- package/dist/modal/components/Header/hooks/useStepTitle.js +7 -3
- package/dist/modal/components/Hero/Hero.js +5 -5
- package/dist/modal/components/IFrameStep/IFrameStep.js +8 -4
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +7 -4
- package/dist/modal/components/ModalContent/ModalContent.js +14 -243
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +3 -57
- package/dist/modal/components/OAuth/OAuth.d.ts +2 -2
- package/dist/modal/components/OAuth/OAuth.js +11 -85
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +11 -60
- package/dist/modal/components/OnRampComponents/AddingFunds.js +1 -1
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +10 -4
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +23 -32
- package/dist/modal/components/StripeComponents/StripeComponents.js +1 -1
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +5 -2
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +44 -60
- package/dist/modal/components/WalletCard/WalletCard.d.ts +5 -5
- package/dist/modal/components/WalletCard/WalletCard.js +8 -7
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +33 -12
- package/dist/modal/components/common.d.ts +5 -5
- package/dist/modal/components/common.js +10 -4
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/oAuthLogos.d.ts +3 -3
- package/dist/modal/hooks/useGoBack.js +6 -5
- package/dist/modal/index.d.ts +0 -3
- package/dist/modal/index.js +1 -5
- package/dist/modal/stores/index.d.ts +0 -2
- package/dist/modal/stores/index.js +0 -2
- package/dist/modal/stores/modal/actions.js +69 -16
- package/dist/modal/stores/modal/useModalStore.d.ts +26 -22
- package/dist/modal/stores/modal/useModalStore.js +9 -13
- package/dist/modal/types/commonTypes.d.ts +0 -52
- package/dist/modal/types/modalProps.d.ts +8 -32
- package/dist/modal/utils/authInputHelpers.d.ts +7 -0
- package/dist/modal/utils/authInputHelpers.js +38 -0
- package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
- package/dist/modal/{components/AuthInput → utils}/countryCodes.js +6 -3
- package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
- package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
- package/dist/modal/utils/isPasskeySupported.js +15 -0
- package/dist/modal/utils/openPopup.d.ts +2 -2
- package/dist/modal/utils/openPopup.js +2 -2
- package/dist/modal/utils/steps.d.ts +6 -0
- package/dist/modal/utils/steps.js +15 -0
- package/dist/provider/ParaProvider.d.ts +3 -1
- package/dist/provider/ParaProvider.js +69 -8
- package/dist/provider/actions/getAccount.d.ts +26 -8
- package/dist/provider/actions/getAccount.js +42 -14
- package/dist/provider/actions/getWallet.d.ts +3 -3
- package/dist/provider/actions/index.d.ts +27 -0
- package/dist/provider/actions/index.js +59 -0
- package/dist/provider/actions/utils.d.ts +3 -0
- package/dist/provider/actions/utils.js +15 -0
- package/dist/provider/components/CosmosWalletWrapper.d.ts +11 -0
- package/dist/provider/components/CosmosWalletWrapper.js +34 -0
- package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
- package/dist/provider/components/EvmWalletWrapper.js +34 -0
- package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
- package/dist/provider/components/ExternalWalletWrapper.js +139 -0
- package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
- package/dist/provider/components/SolanaWalletWrapper.js +36 -0
- package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
- package/dist/provider/external/getParaCosmosConnector.js +22 -0
- package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
- package/dist/provider/external/getParaEvmConnector.js +22 -0
- package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
- package/dist/provider/external/getParaSolanaConnector.js +22 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +12 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +18 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +21 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +8 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +14 -0
- package/dist/provider/hooks/mutations/index.d.ts +27 -11
- package/dist/provider/hooks/mutations/index.js +54 -17
- package/dist/provider/hooks/mutations/utils.d.ts +5 -0
- package/dist/provider/hooks/mutations/utils.js +59 -0
- package/dist/provider/hooks/queries/useAccount.d.ts +1 -7
- package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +1 -2
- package/dist/provider/hooks/queries/useWalletBalance.js +40 -11
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +5 -5
- package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +100 -56
- package/dist/provider/hooks/utils/useWalletState.d.ts +5 -4
- package/dist/provider/hooks/utils/useWalletState.js +24 -9
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/index.js +1 -0
- package/dist/provider/providers/AuthProvider.d.ts +35 -0
- package/dist/provider/providers/AuthProvider.js +498 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.js +66 -0
- package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/EvmExternalWalletProvider.js +74 -0
- package/dist/provider/providers/ExternalWalletProvider.d.ts +76 -0
- package/dist/{modal/providers/ExternalWalletContext.js → provider/providers/ExternalWalletProvider.js} +146 -112
- package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/SolanaExternalWalletProvider.js +66 -0
- package/dist/provider/stores/getters.d.ts +3 -3
- package/dist/provider/stores/setters.d.ts +1 -0
- package/dist/provider/stores/setters.js +7 -0
- package/dist/provider/stores/slices/config.d.ts +3 -0
- package/dist/provider/stores/slices/config.js +9 -0
- package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
- package/dist/provider/stores/slices/externalWallets.js +40 -0
- package/dist/provider/stores/slices/index.d.ts +1 -0
- package/dist/provider/stores/slices/index.js +1 -0
- package/dist/provider/stores/slices/modal.js +11 -4
- package/dist/provider/stores/types.d.ts +50 -4
- package/dist/provider/stores/useStore.js +4 -3
- package/dist/provider/types/externalWalletProviders.d.ts +12 -0
- package/dist/provider/types/externalWalletProviders.js +1 -0
- package/dist/provider/types/provider.d.ts +126 -17
- package/dist/provider/types/utils.d.ts +20 -0
- package/dist/provider/utils/constants.js +3 -4
- package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
- package/dist/provider/utils/paraConfigTypeGuards.js +13 -0
- package/dist/provider/utils/renameMutations.d.ts +3 -0
- package/dist/provider/utils/renameMutations.js +5 -3
- package/package.json +20 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -124
- package/dist/modal/hooks/useActiveWallet.d.ts +0 -1
- package/dist/modal/hooks/useActiveWallet.js +0 -15
- package/dist/modal/hooks/useCreateAccount.d.ts +0 -6
- package/dist/modal/hooks/useCreateAccount.js +0 -77
- package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -54
- package/dist/modal/hooks/useSetLoginURLs.d.ts +0 -8
- package/dist/modal/hooks/useSetLoginURLs.js +0 -49
- package/dist/modal/hooks/useWalletBalance.d.ts +0 -4
- package/dist/modal/hooks/useWalletBalance.js +0 -49
- package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +0 -42
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -38
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +0 -46
- package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -55
- package/dist/modal/providers/ExternalWalletContext.d.ts +0 -92
- package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +0 -32
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -32
- package/dist/modal/stores/externalWalletProvider/actions.d.ts +0 -3
- package/dist/modal/stores/externalWalletProvider/actions.js +0 -10
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +0 -22
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -21
- package/dist/modal/stores/theme/actions.d.ts +0 -3
- package/dist/modal/stores/theme/actions.js +0 -28
- package/dist/modal/stores/theme/useThemeStore.d.ts +0 -20
- package/dist/modal/stores/theme/useThemeStore.js +0 -21
- package/dist/modal/stores/userInfo/actions.d.ts +0 -3
- package/dist/modal/stores/userInfo/actions.js +0 -30
- package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +0 -19
- package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -17
- package/dist/provider/actions/checkIfUserExists.d.ts +0 -9
- package/dist/provider/actions/checkIfUserExists.js +0 -21
- package/dist/provider/actions/createGuestWallets.d.ts +0 -2
- package/dist/provider/actions/createGuestWallets.js +0 -13
- package/dist/provider/actions/createUser.d.ts +0 -12
- package/dist/provider/actions/createUser.js +0 -26
- package/dist/provider/actions/getWalletBalance.d.ts +0 -2
- package/dist/provider/actions/getWalletBalance.js +0 -14
- package/dist/provider/actions/initiateLogin.d.ts +0 -4
- package/dist/provider/actions/initiateLogin.js +0 -20
- package/dist/provider/actions/keepSessionAlive.d.ts +0 -2
- package/dist/provider/actions/keepSessionAlive.js +0 -20
- package/dist/provider/actions/logout.d.ts +0 -2
- package/dist/provider/actions/logout.js +0 -17
- package/dist/provider/actions/signMessage.d.ts +0 -8
- package/dist/provider/actions/signMessage.js +0 -20
- package/dist/provider/actions/signTransaction.d.ts +0 -8
- package/dist/provider/actions/signTransaction.js +0 -20
- package/dist/provider/actions/waitForAccountCreation.d.ts +0 -2
- package/dist/provider/actions/waitForAccountCreation.js +0 -21
- package/dist/provider/actions/waitForLoginAndSetup.d.ts +0 -6
- package/dist/provider/actions/waitForLoginAndSetup.js +0 -24
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +0 -2
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -21
- package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
- package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +0 -15
- package/dist/provider/hooks/mutations/useCreateGuestWallets.js +0 -23
- package/dist/provider/hooks/mutations/useCreateUser.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCreateUser.js +0 -20
- package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +0 -14
- package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
- package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +0 -12
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -20
- package/dist/provider/hooks/mutations/useLogout.d.ts +0 -12
- package/dist/provider/hooks/mutations/useLogout.js +0 -30
- package/dist/provider/hooks/mutations/useSignMessage.d.ts +0 -15
- package/dist/provider/hooks/mutations/useSignMessage.js +0 -39
- package/dist/provider/hooks/mutations/useSignTransaction.d.ts +0 -14
- package/dist/provider/hooks/mutations/useSignTransaction.js +0 -39
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +0 -12
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +0 -14
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +0 -13
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
- /package/dist/modal/{components/AuthInput → utils}/countryCodes.d.ts +0 -0
|
@@ -6,6 +6,7 @@ import { create } from "zustand";
|
|
|
6
6
|
import { persist, createJSONStorage } from "zustand/middleware";
|
|
7
7
|
import { ModalStep } from "../../utils/steps.js";
|
|
8
8
|
import { getActions } from "./actions.js";
|
|
9
|
+
import { AuthLayout } from "../../types/modalProps.js";
|
|
9
10
|
import { createRef } from "react";
|
|
10
11
|
var OnRampStep = /* @__PURE__ */ ((OnRampStep2) => {
|
|
11
12
|
OnRampStep2[OnRampStep2["SETTINGS"] = 0] = "SETTINGS";
|
|
@@ -13,38 +14,37 @@ var OnRampStep = /* @__PURE__ */ ((OnRampStep2) => {
|
|
|
13
14
|
return OnRampStep2;
|
|
14
15
|
})(OnRampStep || {});
|
|
15
16
|
const DEFAULT_MODAL_STATE = {
|
|
17
|
+
recoveryShare: null,
|
|
16
18
|
flow: void 0,
|
|
17
19
|
stepDirection: 1,
|
|
18
|
-
|
|
19
|
-
webAuthURLForCreate: void 0,
|
|
20
|
-
passwordUrlForLogin: void 0,
|
|
21
|
-
supportedAuthMethods: /* @__PURE__ */ new Set(),
|
|
20
|
+
authState: void 0,
|
|
22
21
|
onModalStepChange: void 0,
|
|
23
22
|
onRampPurchase: void 0,
|
|
24
23
|
onRampStep: 0 /* SETTINGS */,
|
|
25
24
|
isFullyLoggedIn: false,
|
|
26
25
|
accountAddFundTab: void 0,
|
|
26
|
+
guestAddFundsTab: void 0,
|
|
27
27
|
isExternalWalletConnecting: false,
|
|
28
28
|
externalWalletError: void 0,
|
|
29
29
|
activeWallet: [void 0, void 0],
|
|
30
30
|
farcasterConnectUri: void 0,
|
|
31
|
-
|
|
31
|
+
twoFactorStatus: void 0,
|
|
32
32
|
iFrameUrl: void 0,
|
|
33
33
|
isIFrameReady: void 0,
|
|
34
|
+
authLayout: [AuthLayout.AUTH_FULL, AuthLayout.EXTERNAL_FULL],
|
|
35
|
+
authStepRoute: void 0,
|
|
34
36
|
refs: {
|
|
35
37
|
popupWindow: createRef(),
|
|
36
38
|
poll: createRef(),
|
|
37
39
|
currentStep: createRef()
|
|
38
40
|
},
|
|
39
|
-
authStepRoute: void 0,
|
|
40
41
|
isPasskeySupported: true
|
|
41
42
|
};
|
|
42
43
|
const useModalStore = create()(
|
|
43
44
|
persist(
|
|
44
45
|
(set, get) => __spreadValues(__spreadValues({
|
|
45
46
|
step: ModalStep.AUTH_MAIN,
|
|
46
|
-
onRampConfig: void 0
|
|
47
|
-
activeWallet: void 0
|
|
47
|
+
onRampConfig: void 0
|
|
48
48
|
}, DEFAULT_MODAL_STATE), getActions(set, get)),
|
|
49
49
|
{
|
|
50
50
|
version: 1,
|
|
@@ -52,14 +52,10 @@ const useModalStore = create()(
|
|
|
52
52
|
storage: createJSONStorage(() => localStorage),
|
|
53
53
|
partialize: (state) => ({
|
|
54
54
|
step: state.step,
|
|
55
|
-
|
|
56
|
-
webAuthURLForCreate: state.webAuthURLForCreate,
|
|
57
|
-
passwordUrlForLogin: state.passwordUrlForLogin,
|
|
58
|
-
biometricLocationHints: state.biometricLocationHints,
|
|
55
|
+
authState: state.authState,
|
|
59
56
|
onRampPurchase: state.onRampPurchase,
|
|
60
57
|
selectedExternalWalletId: state.selectedExternalWalletId,
|
|
61
58
|
isUsingMobileConnector: state.isUsingMobileConnector,
|
|
62
|
-
supportedAuthMethods: state.supportedAuthMethods,
|
|
63
59
|
isPasskeySupported: state.isPasskeySupported
|
|
64
60
|
})
|
|
65
61
|
}
|
|
@@ -1,56 +1,4 @@
|
|
|
1
1
|
import { IconType } from '@getpara/react-components';
|
|
2
|
-
import { WalletType } from '@getpara/web-sdk';
|
|
3
|
-
export type WalletMetadata = {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
iconUrl: string;
|
|
7
|
-
rdns?: string;
|
|
8
|
-
installed?: boolean;
|
|
9
|
-
isExtension?: boolean;
|
|
10
|
-
isMobile?: boolean;
|
|
11
|
-
isWeb?: boolean;
|
|
12
|
-
downloadUrl?: string;
|
|
13
|
-
getQrUri?: () => Promise<string>;
|
|
14
|
-
downloadUrls?: {
|
|
15
|
-
android?: string;
|
|
16
|
-
ios?: string;
|
|
17
|
-
mobile?: string;
|
|
18
|
-
qrCode?: string;
|
|
19
|
-
chrome?: string;
|
|
20
|
-
edge?: string;
|
|
21
|
-
firefox?: string;
|
|
22
|
-
opera?: string;
|
|
23
|
-
safari?: string;
|
|
24
|
-
browserExtension?: string;
|
|
25
|
-
macos?: string;
|
|
26
|
-
windows?: string;
|
|
27
|
-
linux?: string;
|
|
28
|
-
desktop?: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
export type CommonWallet = {
|
|
32
|
-
connect: () => Promise<{
|
|
33
|
-
address?: string;
|
|
34
|
-
bufferAddress?: string;
|
|
35
|
-
error?: string;
|
|
36
|
-
userExists: boolean;
|
|
37
|
-
isVerified: boolean;
|
|
38
|
-
}>;
|
|
39
|
-
connectMobile: (_: {
|
|
40
|
-
isManualWalletConnect?: boolean;
|
|
41
|
-
}) => Promise<{
|
|
42
|
-
address?: string;
|
|
43
|
-
bufferAddress?: string;
|
|
44
|
-
error?: string;
|
|
45
|
-
userExists: boolean;
|
|
46
|
-
isVerified: boolean;
|
|
47
|
-
}>;
|
|
48
|
-
type: WalletType;
|
|
49
|
-
} & WalletMetadata;
|
|
50
|
-
export type CommonChain = {
|
|
51
|
-
id: string | number;
|
|
52
|
-
name: string;
|
|
53
|
-
};
|
|
54
2
|
export type Tab<T> = {
|
|
55
3
|
label: string;
|
|
56
4
|
value: T;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import ParaWeb, { CurrentWalletIds,
|
|
1
|
+
import ParaWeb, { CurrentWalletIds, TOAuthMethod } from '@getpara/web-sdk';
|
|
2
2
|
import { Theme } from '@getpara/react-components';
|
|
3
3
|
import { OnModalStepChangeValue } from '../stores/index.js';
|
|
4
4
|
import { ModalStep, ModalStepProp } from '../utils/steps.js';
|
|
5
|
-
import { TExternalWallet } from './externalWallets.js';
|
|
6
5
|
export type ParaModalHandle = {
|
|
7
6
|
/**
|
|
8
7
|
* Move the modal backward
|
|
@@ -55,7 +54,7 @@ export interface ParaModalProps {
|
|
|
55
54
|
* Which OAuth methods (if any) to show.
|
|
56
55
|
* Defaults to `true`.
|
|
57
56
|
*/
|
|
58
|
-
oAuthMethods?:
|
|
57
|
+
oAuthMethods?: TOAuthMethod[];
|
|
59
58
|
/**
|
|
60
59
|
* Whether or not to allow for email login. If true, only OAuth login will be available.
|
|
61
60
|
* Defaults to `false`.
|
|
@@ -74,21 +73,6 @@ export interface ParaModalProps {
|
|
|
74
73
|
* Logo to be shown throughout the modal.
|
|
75
74
|
*/
|
|
76
75
|
logo?: string;
|
|
77
|
-
/**
|
|
78
|
-
* App name to be shown throughout the modal.
|
|
79
|
-
*/
|
|
80
|
-
appName?: string;
|
|
81
|
-
/**
|
|
82
|
-
* Configure on-ramp providers to allow users to add funds upon signing up.
|
|
83
|
-
* @deprecated Configure on-ramps in the Para Developer Portal.
|
|
84
|
-
*/
|
|
85
|
-
onRampConfig?: deprecated__OnRampConfig;
|
|
86
|
-
/**
|
|
87
|
-
* Configures which EVM networks your app supports, an array of one or more of `["ETHEREUM", "ARBITRUM", "BASE", "OPTIMISM", and "POLYGON"]`.
|
|
88
|
-
* Defaults to `["ETHEREUM"]`.
|
|
89
|
-
* @deprecated Configure this setting in the Para Developer Portal.
|
|
90
|
-
*/
|
|
91
|
-
networks?: deprecated__NetworkProp[];
|
|
92
76
|
/**
|
|
93
77
|
* Whether or not to run configured on-ramp providers in test mode.
|
|
94
78
|
*/
|
|
@@ -110,18 +94,6 @@ export interface ParaModalProps {
|
|
|
110
94
|
*/
|
|
111
95
|
embeddedModal?: boolean;
|
|
112
96
|
className?: string;
|
|
113
|
-
/**
|
|
114
|
-
* Which external wallets to show and in what order they should be displayed.
|
|
115
|
-
*
|
|
116
|
-
* NOTE: Any wallets that are detected as installed will be sorted first, followed by those that are not detected or not installed.
|
|
117
|
-
*/
|
|
118
|
-
externalWallets?: TExternalWallet[];
|
|
119
|
-
/**
|
|
120
|
-
* Which external wallets to include full Para authentication for.
|
|
121
|
-
*
|
|
122
|
-
* These wallets should also be included in the externalWallets list in order to be displayed in the modal.
|
|
123
|
-
*/
|
|
124
|
-
externalWalletsWithParaAuth?: TExternalWallet[];
|
|
125
97
|
/**
|
|
126
98
|
* How the modal should order the components on the main auth screen.
|
|
127
99
|
* Only the first method of each type (auth or external) will be used.
|
|
@@ -129,9 +101,9 @@ export interface ParaModalProps {
|
|
|
129
101
|
*/
|
|
130
102
|
authLayout?: TAuthLayout[];
|
|
131
103
|
/**
|
|
132
|
-
*
|
|
104
|
+
* Default email or phone number (formatted like: +15555555555) to pre-populate the input field.
|
|
133
105
|
*/
|
|
134
|
-
|
|
106
|
+
defaultAuthIdentifier?: string;
|
|
135
107
|
/**
|
|
136
108
|
* Called when the modal step changes
|
|
137
109
|
*/
|
|
@@ -140,6 +112,10 @@ export interface ParaModalProps {
|
|
|
140
112
|
* Called when the modal is closed
|
|
141
113
|
*/
|
|
142
114
|
onClose?: () => void;
|
|
115
|
+
/**
|
|
116
|
+
* Whether to enable guest login. A guest user will be provisioned embedded wallets that they will then claim upon signing up through your app.
|
|
117
|
+
*/
|
|
118
|
+
isGuestModeEnabled?: boolean;
|
|
143
119
|
loginTransitionOverride?: (para: ParaWeb) => Promise<void>;
|
|
144
120
|
createWalletOverride?: (para: ParaWeb) => Promise<{
|
|
145
121
|
recoverySecret?: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import countryCodes from './countryCodes.js';
|
|
2
|
+
export declare function isCcMatch(countryCode: string, option: (typeof countryCodes)[number]): boolean;
|
|
3
|
+
export declare function validateAuth(identifier: string, countryCode?: string, type?: 'email' | 'phone'): {
|
|
4
|
+
email: string;
|
|
5
|
+
} | {
|
|
6
|
+
phone: import("@getpara/user-management-client").AuthIdentifier<"phone">;
|
|
7
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
import { EMAIL_REGEX } from "../constants/constants.js";
|
|
4
|
+
import { formatPhoneNumber } from "@getpara/web-sdk";
|
|
5
|
+
function isCcMatch(countryCode, option) {
|
|
6
|
+
return countryCode === "+1" ? option.selectedLabel === "US" : option.value === countryCode;
|
|
7
|
+
}
|
|
8
|
+
function validateAuth(identifier, countryCode, type) {
|
|
9
|
+
const isEmail = type === "email";
|
|
10
|
+
const isPhone = type === "phone";
|
|
11
|
+
let auth;
|
|
12
|
+
switch (true) {
|
|
13
|
+
case isEmail:
|
|
14
|
+
if (!EMAIL_REGEX.test(identifier)) {
|
|
15
|
+
throw new Error("Please enter a valid email!");
|
|
16
|
+
}
|
|
17
|
+
auth = { email: identifier };
|
|
18
|
+
break;
|
|
19
|
+
case isPhone:
|
|
20
|
+
if (countryCode === "+1" && identifier.slice(3, 6) === "555") {
|
|
21
|
+
auth = { phone: `${countryCode}${identifier}` };
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
const validatedPhone = formatPhoneNumber(identifier, countryCode);
|
|
25
|
+
if (!validatedPhone) {
|
|
26
|
+
throw new Error("Please enter a valid phone number!");
|
|
27
|
+
}
|
|
28
|
+
auth = { phone: validatedPhone };
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
throw new Error("Please enter a valid email or phone number!");
|
|
32
|
+
}
|
|
33
|
+
return auth;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
isCcMatch,
|
|
37
|
+
validateAuth
|
|
38
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TAuthLayout } from '../types/modalProps.js';
|
|
2
|
-
export declare const hasExternalWallet: (authLayout: TAuthLayout[]) => "AUTH:FULL" | "AUTH:CONDENSED" | "EXTERNAL:FULL" | "EXTERNAL:CONDENSED";
|
|
3
|
-
export declare const hasEmbeddedAuth: (authLayout: TAuthLayout[]) => "AUTH:FULL" | "AUTH:CONDENSED" | "EXTERNAL:FULL" | "EXTERNAL:CONDENSED";
|
|
2
|
+
export declare const hasExternalWallet: (authLayout: TAuthLayout[]) => "AUTH:FULL" | "AUTH:CONDENSED" | "EXTERNAL:FULL" | "EXTERNAL:CONDENSED" | undefined;
|
|
3
|
+
export declare const hasEmbeddedAuth: (authLayout: TAuthLayout[]) => "AUTH:FULL" | "AUTH:CONDENSED" | "EXTERNAL:FULL" | "EXTERNAL:CONDENSED" | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import "
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
3
|
import { getCountries, getCountryCallingCode } from "libphonenumber-js";
|
|
4
4
|
const excludedCountries = [
|
|
5
5
|
"AC",
|
|
@@ -27,12 +27,15 @@ const generateCountryCodes = () => {
|
|
|
27
27
|
const countryCode = getCountryCallingCode(country);
|
|
28
28
|
const countryName = new Intl.DisplayNames(["en"], { type: "region" }).of(country);
|
|
29
29
|
return {
|
|
30
|
-
label: countryName,
|
|
30
|
+
label: countryName != null ? countryName : "",
|
|
31
31
|
value: `+${countryCode}`,
|
|
32
32
|
selectedLabel: country,
|
|
33
33
|
icon: country
|
|
34
34
|
};
|
|
35
|
-
}).sort((a, b) =>
|
|
35
|
+
}).sort((a, b) => {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
return ((_a = a.label) != null ? _a : "").localeCompare((_b = b.label) != null ? _b : "");
|
|
38
|
+
});
|
|
36
39
|
return countryList;
|
|
37
40
|
};
|
|
38
41
|
const countryCodes = generateCountryCodes();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getTileButtonFlex: (index: number, totalItems: number) => "1 1 auto" | "0 0 calc(33.333333% - 5.336px)" | "0 0 calc(50% - 4px)";
|
|
1
|
+
export declare const getTileButtonFlex: (index: number, totalItems: number) => "1 1 auto" | "0 0 calc(33.333333% - 5.336px)" | "0 0 calc(50% - 4px)" | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isPasskeySupported: () => boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
import { detect } from "detect-browser";
|
|
4
|
+
const isPasskeySupported = () => {
|
|
5
|
+
const browser = detect();
|
|
6
|
+
switch (browser == null ? void 0 : browser.os) {
|
|
7
|
+
case "linux":
|
|
8
|
+
case "Chrome OS":
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
isPasskeySupported
|
|
15
|
+
};
|
|
@@ -2,5 +2,5 @@ export declare function openPopup({ url, target, type, current, }: {
|
|
|
2
2
|
url: string;
|
|
3
3
|
target: string;
|
|
4
4
|
type: 'OAUTH' | 'LOGIN_PASSKEY' | 'CREATE_PASSKEY' | 'TRANSACTION_REVIEW' | 'CREATE_PASSWORD' | 'LOGIN_PASSWORD';
|
|
5
|
-
current?: Window;
|
|
6
|
-
}): Window;
|
|
5
|
+
current?: Window | null;
|
|
6
|
+
}): Window | null;
|
|
@@ -7,7 +7,7 @@ function openPopup({
|
|
|
7
7
|
current
|
|
8
8
|
}) {
|
|
9
9
|
if (typeof window === "undefined") {
|
|
10
|
-
return;
|
|
10
|
+
return null;
|
|
11
11
|
}
|
|
12
12
|
current == null ? void 0 : current.close();
|
|
13
13
|
const popUpWidth = 560;
|
|
@@ -53,7 +53,7 @@ function openPopup({
|
|
|
53
53
|
popupWindow = window.open(url, "_blank");
|
|
54
54
|
}, 0);
|
|
55
55
|
}
|
|
56
|
-
return popupWindow;
|
|
56
|
+
return popupWindow != null ? popupWindow : null;
|
|
57
57
|
}
|
|
58
58
|
export {
|
|
59
59
|
openPopup
|
|
@@ -2,6 +2,8 @@ import { EnabledFlow } from '@getpara/web-sdk';
|
|
|
2
2
|
export declare enum ModalStep {
|
|
3
3
|
AUTH_MAIN = "AUTH_MAIN",
|
|
4
4
|
AUTH_MORE = "AUTH_MORE",
|
|
5
|
+
AUTH_GUEST_SIGNUP = "AUTH_GUEST_SIGNUP",
|
|
6
|
+
AWAITING_GUEST_WALLET_CREATION = "AWAITING_GUEST_WALLET_CREATION",
|
|
5
7
|
EX_WALLET_MORE = "EX_WALLET_MORE",
|
|
6
8
|
EX_WALLET_SELECTED = "EX_WALLET_SELECTED",
|
|
7
9
|
VERIFICATIONS = "VERIFICATIONS",
|
|
@@ -37,6 +39,7 @@ export type ModalStepPropL = Lowercase<ModalStepPropU>;
|
|
|
37
39
|
export type ModalStepProp = ModalStepPropU | ModalStepPropL;
|
|
38
40
|
declare enum AccountStep {
|
|
39
41
|
ACCOUNT_MAIN = "ACCOUNT_MAIN",
|
|
42
|
+
AUTH_GUEST_SIGNUP = "AUTH_GUEST_SIGNUP",
|
|
40
43
|
ADD_FUNDS_BUY = "ADD_FUNDS_BUY",
|
|
41
44
|
ADD_FUNDS_RECEIVE = "ADD_FUNDS_RECEIVE",
|
|
42
45
|
ADD_FUNDS_WITHDRAW = "ADD_FUNDS_WITHDRAW",
|
|
@@ -80,6 +83,9 @@ declare enum SignUpModalStep {
|
|
|
80
83
|
export declare const SignUpPreviousStep: {
|
|
81
84
|
[key in SignUpModalStep]: ModalStep | undefined;
|
|
82
85
|
};
|
|
86
|
+
export declare const GuestPreviousStep: {
|
|
87
|
+
[key in AccountStep]: ModalStep | undefined;
|
|
88
|
+
};
|
|
83
89
|
declare enum LoginModalStep {
|
|
84
90
|
AUTH_MAIN = "AUTH_MAIN",
|
|
85
91
|
AUTH_MORE = "AUTH_MORE",
|
|
@@ -3,6 +3,8 @@ import "../../chunk-MMUBH76A.js";
|
|
|
3
3
|
var ModalStep = /* @__PURE__ */ ((ModalStep2) => {
|
|
4
4
|
ModalStep2["AUTH_MAIN"] = "AUTH_MAIN";
|
|
5
5
|
ModalStep2["AUTH_MORE"] = "AUTH_MORE";
|
|
6
|
+
ModalStep2["AUTH_GUEST_SIGNUP"] = "AUTH_GUEST_SIGNUP";
|
|
7
|
+
ModalStep2["AWAITING_GUEST_WALLET_CREATION"] = "AWAITING_GUEST_WALLET_CREATION";
|
|
6
8
|
ModalStep2["EX_WALLET_MORE"] = "EX_WALLET_MORE";
|
|
7
9
|
ModalStep2["EX_WALLET_SELECTED"] = "EX_WALLET_SELECTED";
|
|
8
10
|
ModalStep2["VERIFICATIONS"] = "VERIFICATIONS";
|
|
@@ -36,6 +38,7 @@ var ModalStep = /* @__PURE__ */ ((ModalStep2) => {
|
|
|
36
38
|
})(ModalStep || {});
|
|
37
39
|
var AccountStep = /* @__PURE__ */ ((AccountStep2) => {
|
|
38
40
|
AccountStep2["ACCOUNT_MAIN"] = "ACCOUNT_MAIN";
|
|
41
|
+
AccountStep2["AUTH_GUEST_SIGNUP"] = "AUTH_GUEST_SIGNUP";
|
|
39
42
|
AccountStep2["ADD_FUNDS_BUY"] = "ADD_FUNDS_BUY";
|
|
40
43
|
AccountStep2["ADD_FUNDS_RECEIVE"] = "ADD_FUNDS_RECEIVE";
|
|
41
44
|
AccountStep2["ADD_FUNDS_WITHDRAW"] = "ADD_FUNDS_WITHDRAW";
|
|
@@ -69,6 +72,7 @@ const RESET_TO_AUTH_STEPS = [
|
|
|
69
72
|
"LOGIN_DONE" /* LOGIN_DONE */
|
|
70
73
|
];
|
|
71
74
|
const RESET_TO_ACCOUNT_STEPS = [
|
|
75
|
+
"AUTH_GUEST_SIGNUP" /* AUTH_GUEST_SIGNUP */,
|
|
72
76
|
"ADD_FUNDS_BUY" /* ADD_FUNDS_BUY */,
|
|
73
77
|
"ADD_FUNDS_RECEIVE" /* ADD_FUNDS_RECEIVE */,
|
|
74
78
|
"ADD_FUNDS_WITHDRAW" /* ADD_FUNDS_WITHDRAW */,
|
|
@@ -79,6 +83,7 @@ const RESET_TO_ACCOUNT_STEPS = [
|
|
|
79
83
|
];
|
|
80
84
|
const AccountPreviousStep = {
|
|
81
85
|
["ACCOUNT_MAIN" /* ACCOUNT_MAIN */]: void 0,
|
|
86
|
+
["AUTH_GUEST_SIGNUP" /* AUTH_GUEST_SIGNUP */]: "ACCOUNT_MAIN" /* ACCOUNT_MAIN */,
|
|
82
87
|
["ADD_FUNDS_BUY" /* ADD_FUNDS_BUY */]: "ACCOUNT_MAIN" /* ACCOUNT_MAIN */,
|
|
83
88
|
["ADD_FUNDS_WITHDRAW" /* ADD_FUNDS_WITHDRAW */]: "ACCOUNT_MAIN" /* ACCOUNT_MAIN */,
|
|
84
89
|
["ADD_FUNDS_RECEIVE" /* ADD_FUNDS_RECEIVE */]: "ACCOUNT_MAIN" /* ACCOUNT_MAIN */,
|
|
@@ -142,6 +147,15 @@ const SignUpPreviousStep = {
|
|
|
142
147
|
["ADD_FUNDS_SUCCESS" /* ADD_FUNDS_SUCCESS */]: void 0,
|
|
143
148
|
["ADD_FUNDS_FAILURE" /* ADD_FUNDS_FAILURE */]: void 0
|
|
144
149
|
};
|
|
150
|
+
const GuestPreviousStep = Object.fromEntries([
|
|
151
|
+
...Object.entries(SignUpPreviousStep).map(([key, value]) => {
|
|
152
|
+
if (value === "AUTH_MAIN" /* AUTH_MAIN */) {
|
|
153
|
+
return [key, "AUTH_GUEST_SIGNUP" /* AUTH_GUEST_SIGNUP */];
|
|
154
|
+
}
|
|
155
|
+
return [key, value];
|
|
156
|
+
}),
|
|
157
|
+
...Object.entries(AccountPreviousStep)
|
|
158
|
+
]);
|
|
145
159
|
var LoginModalStep = /* @__PURE__ */ ((LoginModalStep2) => {
|
|
146
160
|
LoginModalStep2["AUTH_MAIN"] = "AUTH_MAIN";
|
|
147
161
|
LoginModalStep2["AUTH_MORE"] = "AUTH_MORE";
|
|
@@ -221,6 +235,7 @@ function getAddFundsStep(currentTab) {
|
|
|
221
235
|
const IFrameSteps = ["PASSWORD_CREATION" /* PASSWORD_CREATION */];
|
|
222
236
|
export {
|
|
223
237
|
AccountPreviousStep,
|
|
238
|
+
GuestPreviousStep,
|
|
224
239
|
IFrameSteps,
|
|
225
240
|
LoginPreviousStep,
|
|
226
241
|
ModalStep,
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { ParaProviderProps } from './types/provider.js';
|
|
2
|
-
|
|
2
|
+
import { Chain, Transport } from 'viem';
|
|
3
|
+
import { ParaModalHandle } from '../modal/index.js';
|
|
4
|
+
export declare const ParaProvider: import("react").ForwardRefExoticComponent<ParaProviderProps<readonly [Chain, ...Chain[]], Record<number, Transport>> & import("react").RefAttributes<ParaModalHandle>>;
|
|
@@ -1,22 +1,83 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../chunk-MMUBH76A.js";
|
|
3
|
-
import {
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { forwardRef, useEffect } from "react";
|
|
4
5
|
import { useStore } from "./stores/useStore.js";
|
|
5
6
|
import { useAutoSessionKeepAlive } from "./hooks/utils/useAutoSessionKeepAlive.js";
|
|
6
7
|
import { useEventListeners } from "./hooks/utils/useEventListeners.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import { ExternalWalletWrapper } from "./components/ExternalWalletWrapper.js";
|
|
9
|
+
import { ParaModal } from "../modal/ParaModal.js";
|
|
10
|
+
import { isConfigType, isParaWeb } from "./utils/paraConfigTypeGuards.js";
|
|
11
|
+
import ParaWeb from "@getpara/web-sdk";
|
|
12
|
+
import { ExternalWallet } from "@getpara/react-common";
|
|
13
|
+
import { AuthProvider } from "./providers/AuthProvider.js";
|
|
14
|
+
const ParaProvider = forwardRef(({ children, paraClientConfig, callbacks, config, externalWalletConfig, paraModalConfig }, ref) => {
|
|
10
15
|
useEventListeners(callbacks);
|
|
11
16
|
useAutoSessionKeepAlive({ disabled: config.disableAutoSessionKeepAlive });
|
|
12
17
|
const setClient = useStore((state) => state.setClient);
|
|
18
|
+
const client = useStore((state) => state.client);
|
|
19
|
+
const setExternalWallets = useStore((state) => state.setExternalWallets);
|
|
20
|
+
const externalWallets = useStore((state) => state.externalWallets);
|
|
21
|
+
const setExternalWalletsWithFullAuth = useStore((state) => state.setExternalWalletsWithFullAuth);
|
|
22
|
+
const externalWalletsWithFullAuth = useStore((state) => state.externalWalletsWithFullAuth);
|
|
23
|
+
const setModalConfig = useStore((state) => state.setModalConfig);
|
|
24
|
+
const modalConfig = useStore((state) => state.modalConfig);
|
|
25
|
+
const setAppName = useStore((state) => state.setAppName);
|
|
26
|
+
const appName = useStore((state) => state.appName);
|
|
27
|
+
const rpcUrl = useStore((state) => state.rpcUrl);
|
|
28
|
+
const setRpcUrl = useStore((state) => state.setRpcUrl);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (rpcUrl !== config.rpcUrl) setRpcUrl(config.rpcUrl);
|
|
31
|
+
}, [config.rpcUrl]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (appName !== config.appName) setAppName(config.appName);
|
|
34
|
+
}, [config.appName]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (modalConfig !== paraModalConfig) setModalConfig(paraModalConfig);
|
|
37
|
+
}, [paraModalConfig]);
|
|
13
38
|
useEffect(() => {
|
|
14
39
|
var _a;
|
|
15
|
-
|
|
40
|
+
if (externalWallets !== (externalWalletConfig == null ? void 0 : externalWalletConfig.wallets)) {
|
|
41
|
+
setExternalWallets((_a = externalWalletConfig == null ? void 0 : externalWalletConfig.wallets) != null ? _a : Object.values(ExternalWallet));
|
|
42
|
+
}
|
|
43
|
+
}, [externalWalletConfig == null ? void 0 : externalWalletConfig.wallets]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
if (externalWalletsWithFullAuth !== (externalWalletConfig == null ? void 0 : externalWalletConfig.walletsWithParaAuth)) {
|
|
47
|
+
if (isConfigType(paraClientConfig) ? (_a = paraClientConfig.opts) == null ? void 0 : _a.externalWalletConnectionOnly : paraClientConfig.externalWalletConnectionOnly) {
|
|
48
|
+
console.warn("walletsWithParaAuth has no effect when using externalWalletConnectionOnly");
|
|
49
|
+
setExternalWalletsWithFullAuth([]);
|
|
50
|
+
} else {
|
|
51
|
+
setExternalWalletsWithFullAuth((_b = externalWalletConfig == null ? void 0 : externalWalletConfig.walletsWithParaAuth) != null ? _b : []);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}, [externalWalletConfig == null ? void 0 : externalWalletConfig.walletsWithParaAuth]);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!isConfigType(paraClientConfig) && !isParaWeb(paraClientConfig)) {
|
|
57
|
+
throw new Error("Invalid Para config");
|
|
58
|
+
}
|
|
59
|
+
const newClient = isConfigType(paraClientConfig) ? new ParaWeb(paraClientConfig.env, paraClientConfig.apiKey, paraClientConfig.opts) : paraClientConfig;
|
|
16
60
|
setClient(newClient);
|
|
17
|
-
}, [paraClientConfig
|
|
18
|
-
|
|
19
|
-
|
|
61
|
+
}, [paraClientConfig]);
|
|
62
|
+
if (!client) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return /* @__PURE__ */ jsx(
|
|
66
|
+
AuthProvider,
|
|
67
|
+
{
|
|
68
|
+
is2faEnabled: paraModalConfig == null ? void 0 : paraModalConfig.twoFactorAuthEnabled,
|
|
69
|
+
isRecoverySecretStepEnabled: paraModalConfig == null ? void 0 : paraModalConfig.recoverySecretStepEnabled,
|
|
70
|
+
overrides: {
|
|
71
|
+
login: paraModalConfig == null ? void 0 : paraModalConfig.loginTransitionOverride,
|
|
72
|
+
createWallets: paraModalConfig == null ? void 0 : paraModalConfig.createWalletOverride
|
|
73
|
+
},
|
|
74
|
+
children: /* @__PURE__ */ jsxs(ExternalWalletWrapper, { config: externalWalletConfig, children: [
|
|
75
|
+
children,
|
|
76
|
+
!config.disableEmbeddedModal && /* @__PURE__ */ jsx(ParaModal, { ref })
|
|
77
|
+
] })
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
});
|
|
20
81
|
export {
|
|
21
82
|
ParaProvider
|
|
22
83
|
};
|
|
@@ -1,8 +1,26 @@
|
|
|
1
|
-
import ParaWeb from '@getpara/web-sdk';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import ParaWeb, { CoreAuthInfo } from '@getpara/web-sdk';
|
|
2
|
+
type AccountValue = CoreAuthInfo & {
|
|
3
|
+
email?: string;
|
|
4
|
+
phone?: `+${number}`;
|
|
5
|
+
farcasterUsername?: string;
|
|
6
|
+
telegramUserId?: string;
|
|
7
|
+
externalWalletAddress?: string;
|
|
8
|
+
wallets: (typeof ParaWeb.prototype)['availableWallets'];
|
|
9
|
+
userId?: string;
|
|
10
|
+
};
|
|
11
|
+
export type Account = ({
|
|
12
|
+
isConnected: false;
|
|
13
|
+
isGuestMode?: false;
|
|
14
|
+
} & {
|
|
15
|
+
[key in keyof AccountValue]?: undefined;
|
|
16
|
+
}) | ({
|
|
17
|
+
isConnected: true;
|
|
18
|
+
isGuestMode: true;
|
|
19
|
+
} & Pick<AccountValue, 'wallets'> & {
|
|
20
|
+
[key in keyof Omit<AccountValue, 'wallets'>]?: undefined;
|
|
21
|
+
}) | ({
|
|
22
|
+
isConnected: true;
|
|
23
|
+
isGuestMode: false;
|
|
24
|
+
} & AccountValue);
|
|
25
|
+
export declare const getAccount: (para?: ParaWeb) => Promise<Account>;
|
|
26
|
+
export {};
|
|
@@ -1,22 +1,50 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
__async
|
|
3
|
+
__async,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
4
6
|
} from "../../chunk-MMUBH76A.js";
|
|
5
7
|
const getAccount = (para) => __async(void 0, null, function* () {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
wallets: void 0
|
|
13
|
-
};
|
|
14
|
-
if (para && resp.isConnected) {
|
|
15
|
-
resp.email = para.getEmail();
|
|
16
|
-
resp.phone = para.getPhoneNumber();
|
|
17
|
-
resp.wallets = para.getWallets();
|
|
8
|
+
if (!!para && para.isGuestMode) {
|
|
9
|
+
return {
|
|
10
|
+
isConnected: true,
|
|
11
|
+
isGuestMode: true,
|
|
12
|
+
wallets: para.availableWallets
|
|
13
|
+
};
|
|
18
14
|
}
|
|
19
|
-
|
|
15
|
+
const isConnected = !!para && (yield para == null ? void 0 : para.isFullyLoggedIn());
|
|
16
|
+
if (isConnected) {
|
|
17
|
+
const authInfo = para.authInfo;
|
|
18
|
+
const value = __spreadProps(__spreadValues({}, authInfo || {}), {
|
|
19
|
+
userId: para.userId,
|
|
20
|
+
wallets: para.availableWallets,
|
|
21
|
+
isConnected: true,
|
|
22
|
+
isGuestMode: false
|
|
23
|
+
});
|
|
24
|
+
if (authInfo) {
|
|
25
|
+
switch (authInfo.authType) {
|
|
26
|
+
case "email":
|
|
27
|
+
value.email = authInfo.identifier;
|
|
28
|
+
break;
|
|
29
|
+
case "phone":
|
|
30
|
+
value.phone = authInfo.identifier;
|
|
31
|
+
break;
|
|
32
|
+
case "farcaster":
|
|
33
|
+
value.farcasterUsername = authInfo.identifier;
|
|
34
|
+
break;
|
|
35
|
+
case "telegram":
|
|
36
|
+
value.telegramUserId = authInfo.identifier;
|
|
37
|
+
break;
|
|
38
|
+
case "externalWallet":
|
|
39
|
+
value.externalWalletAddress = authInfo.identifier;
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
return { isConnected: false };
|
|
20
48
|
});
|
|
21
49
|
export {
|
|
22
50
|
getAccount
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ParaWeb, {
|
|
1
|
+
import ParaWeb, { TWalletType } from '@getpara/web-sdk';
|
|
2
2
|
export declare const getWallet: (para?: ParaWeb, selectedWallet?: {
|
|
3
3
|
id?: string;
|
|
4
|
-
type?:
|
|
5
|
-
}) => Promise<Omit<import("@getpara/web-sdk").Wallet, "signer"
|
|
4
|
+
type?: TWalletType;
|
|
5
|
+
}) => Promise<Omit<import("@getpara/web-sdk").Wallet, "signer"> | null | undefined>;
|