@getpara/react-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/dist/index.d.ts +5 -0
  2. package/dist/index.js +4 -0
  3. package/dist/modal/ParaModal.d.ts +2 -0
  4. package/dist/modal/ParaModal.js +250 -0
  5. package/dist/modal/components/Account/Account.d.ts +5 -0
  6. package/dist/modal/components/Account/Account.js +59 -0
  7. package/dist/modal/components/AddFunds/AddFunds.d.ts +3 -0
  8. package/dist/modal/components/AddFunds/AddFunds.js +146 -0
  9. package/dist/modal/components/AddFunds/AddFundsAwaiting.d.ts +1 -0
  10. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +64 -0
  11. package/dist/modal/components/AddFunds/AddFundsDone.d.ts +6 -0
  12. package/dist/modal/components/AddFunds/AddFundsDone.js +26 -0
  13. package/dist/modal/components/AddFunds/MoonPayEmbed.d.ts +2 -0
  14. package/dist/modal/components/AddFunds/MoonPayEmbed.js +2 -0
  15. package/dist/modal/components/AddFunds/index.d.ts +3 -0
  16. package/dist/modal/components/AddFunds/index.js +3 -0
  17. package/dist/modal/components/AuthInput/AuthInput.d.ts +6 -0
  18. package/dist/modal/components/AuthInput/AuthInput.js +214 -0
  19. package/dist/modal/components/AuthInput/countryCodes.d.ts +8 -0
  20. package/dist/modal/components/AuthInput/countryCodes.js +40 -0
  21. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +7 -0
  22. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +23 -0
  23. package/dist/modal/components/AuthInput/phoneMasks.d.ts +247 -0
  24. package/dist/modal/components/AuthInput/phoneMasks.js +247 -0
  25. package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +8 -0
  26. package/dist/modal/components/AuthMainStep/AuthMainStep.js +21 -0
  27. package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +8 -0
  28. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +89 -0
  29. package/dist/modal/components/AuthOptions/AuthOptions.d.ts +8 -0
  30. package/dist/modal/components/AuthOptions/AuthOptions.js +28 -0
  31. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.d.ts +1 -0
  32. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +7 -0
  33. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.d.ts +1 -0
  34. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +5 -0
  35. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.d.ts +1 -0
  36. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +7 -0
  37. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +1 -0
  38. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +18 -0
  39. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +4 -0
  40. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +17 -0
  41. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -0
  42. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +127 -0
  43. package/dist/modal/components/Body/AnimatedHeightWrapper.d.ts +6 -0
  44. package/dist/modal/components/Body/AnimatedHeightWrapper.js +26 -0
  45. package/dist/modal/components/Body/Body.d.ts +12 -0
  46. package/dist/modal/components/Body/Body.js +232 -0
  47. package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -0
  48. package/dist/modal/components/ChainSwitch/ChainSwitch.js +77 -0
  49. package/dist/modal/components/ChainSwitch/config.d.ts +7 -0
  50. package/dist/modal/components/ChainSwitch/config.js +11 -0
  51. package/dist/modal/components/Controls/Controls.d.ts +5 -0
  52. package/dist/modal/components/Controls/Controls.js +54 -0
  53. package/dist/modal/components/Controls/Selects.d.ts +2 -0
  54. package/dist/modal/components/Controls/Selects.js +157 -0
  55. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -0
  56. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +116 -0
  57. package/dist/modal/components/ExternalWalletStep/config.d.ts +7 -0
  58. package/dist/modal/components/ExternalWalletStep/config.js +11 -0
  59. package/dist/modal/components/ExternalWallets/ExternalWallets.d.ts +1 -0
  60. package/dist/modal/components/ExternalWallets/ExternalWallets.js +142 -0
  61. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +7 -0
  62. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +118 -0
  63. package/dist/modal/components/Footer/Footer.d.ts +1 -0
  64. package/dist/modal/components/Footer/Footer.js +71 -0
  65. package/dist/modal/components/Header/Header.d.ts +1 -0
  66. package/dist/modal/components/Header/Header.js +24 -0
  67. package/dist/modal/components/Header/hooks/useStepTitle.d.ts +3 -0
  68. package/dist/modal/components/Header/hooks/useStepTitle.js +42 -0
  69. package/dist/modal/components/Hero/Hero.d.ts +1 -0
  70. package/dist/modal/components/Hero/Hero.js +118 -0
  71. package/dist/modal/components/IFrameStep/IFrameStep.d.ts +1 -0
  72. package/dist/modal/components/IFrameStep/IFrameStep.js +41 -0
  73. package/dist/modal/components/LoginDoneStep/LoginDoneStep.d.ts +1 -0
  74. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +18 -0
  75. package/dist/modal/components/ModalContent/ModalContent.d.ts +10 -0
  76. package/dist/modal/components/ModalContent/ModalContent.js +276 -0
  77. package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +2 -0
  78. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +81 -0
  79. package/dist/modal/components/OAuth/OAuth.d.ts +6 -0
  80. package/dist/modal/components/OAuth/OAuth.js +124 -0
  81. package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +1 -0
  82. package/dist/modal/components/OAuth/TelegramOAuthStep.js +132 -0
  83. package/dist/modal/components/OnRampComponents/AddingFunds.d.ts +1 -0
  84. package/dist/modal/components/OnRampComponents/AddingFunds.js +10 -0
  85. package/dist/modal/components/OnRampComponents/OnRampProviderButton.d.ts +9 -0
  86. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +72 -0
  87. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.d.ts +6 -0
  88. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +67 -0
  89. package/dist/modal/components/Setup2FAStep/Setup2FAStep.d.ts +5 -0
  90. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +104 -0
  91. package/dist/modal/components/StripeComponents/StripeComponents.d.ts +16 -0
  92. package/dist/modal/components/StripeComponents/StripeComponents.js +78 -0
  93. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.d.ts +5 -0
  94. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +8 -0
  95. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.d.ts +1 -0
  96. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +130 -0
  97. package/dist/modal/components/Waiting/Waiting.d.ts +6 -0
  98. package/dist/modal/components/Waiting/Waiting.js +6 -0
  99. package/dist/modal/components/WalletCard/PartnerIcon.d.ts +6 -0
  100. package/dist/modal/components/WalletCard/PartnerIcon.js +29 -0
  101. package/dist/modal/components/WalletCard/WalletCard.d.ts +18 -0
  102. package/dist/modal/components/WalletCard/WalletCard.js +91 -0
  103. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.d.ts +6 -0
  104. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +49 -0
  105. package/dist/modal/components/common.d.ts +19 -0
  106. package/dist/modal/components/common.js +67 -0
  107. package/dist/modal/components/index.d.ts +1 -0
  108. package/dist/modal/components/index.js +1 -0
  109. package/dist/modal/constants/constants.d.ts +32 -0
  110. package/dist/modal/constants/constants.js +93 -0
  111. package/dist/modal/constants/defaults.d.ts +5 -0
  112. package/dist/modal/constants/defaults.js +5 -0
  113. package/dist/modal/constants/oAuthLogos.d.ts +8 -0
  114. package/dist/modal/constants/oAuthLogos.js +18 -0
  115. package/dist/modal/css/modal.css +13 -0
  116. package/dist/modal/hooks/useActiveWallet.d.ts +1 -0
  117. package/dist/modal/hooks/useActiveWallet.js +9 -0
  118. package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +1 -0
  119. package/dist/modal/hooks/useEmbeddedExternalConnection.js +46 -0
  120. package/dist/modal/hooks/useGoBack.d.ts +1 -0
  121. package/dist/modal/hooks/useGoBack.js +34 -0
  122. package/dist/modal/index.d.ts +10 -0
  123. package/dist/modal/index.js +9 -0
  124. package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +29 -0
  125. package/dist/modal/providers/CosmosExternalWalletContextStub.js +18 -0
  126. package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +33 -0
  127. package/dist/modal/providers/EvmExternalWalletContextStub.js +22 -0
  128. package/dist/modal/providers/ExternalWalletContext.d.ts +75 -0
  129. package/dist/modal/providers/ExternalWalletContext.js +252 -0
  130. package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +21 -0
  131. package/dist/modal/providers/SolanaExternalWalletContextStub.js +12 -0
  132. package/dist/modal/public/Inter-VariableFont_slnt,wght.ttf +0 -0
  133. package/dist/modal/stores/externalWalletProvider/actions.d.ts +3 -0
  134. package/dist/modal/stores/externalWalletProvider/actions.js +5 -0
  135. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +20 -0
  136. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +13 -0
  137. package/dist/modal/stores/index.d.ts +4 -0
  138. package/dist/modal/stores/index.js +4 -0
  139. package/dist/modal/stores/modal/actions.d.ts +3 -0
  140. package/dist/modal/stores/modal/actions.js +65 -0
  141. package/dist/modal/stores/modal/useModalStore.d.ts +82 -0
  142. package/dist/modal/stores/modal/useModalStore.js +41 -0
  143. package/dist/modal/stores/para/actions.d.ts +3 -0
  144. package/dist/modal/stores/para/actions.js +5 -0
  145. package/dist/modal/stores/para/useParaStore.d.ts +10 -0
  146. package/dist/modal/stores/para/useParaStore.js +3 -0
  147. package/dist/modal/stores/theme/actions.d.ts +3 -0
  148. package/dist/modal/stores/theme/actions.js +24 -0
  149. package/dist/modal/stores/theme/useThemeStore.d.ts +20 -0
  150. package/dist/modal/stores/theme/useThemeStore.js +14 -0
  151. package/dist/modal/stores/userInfo/actions.d.ts +3 -0
  152. package/dist/modal/stores/userInfo/actions.js +28 -0
  153. package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +19 -0
  154. package/dist/modal/stores/userInfo/useUserInfoStore.js +9 -0
  155. package/dist/modal/types/commonTypes.d.ts +48 -0
  156. package/dist/modal/types/commonTypes.js +1 -0
  157. package/dist/modal/types/externalWallets.d.ts +31 -0
  158. package/dist/modal/types/externalWallets.js +21 -0
  159. package/dist/modal/types/modalProps.d.ts +138 -0
  160. package/dist/modal/types/modalProps.js +7 -0
  161. package/dist/modal/utils/authLayoutHelpers.d.ts +3 -0
  162. package/dist/modal/utils/authLayoutHelpers.js +2 -0
  163. package/dist/modal/utils/getMailtoLink.d.ts +1 -0
  164. package/dist/modal/utils/getMailtoLink.js +5 -0
  165. package/dist/modal/utils/getTileButtonFlex.d.ts +1 -0
  166. package/dist/modal/utils/getTileButtonFlex.js +15 -0
  167. package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
  168. package/dist/modal/utils/isPasskeySupported.js +10 -0
  169. package/dist/modal/utils/openPopup.d.ts +1 -0
  170. package/dist/modal/utils/openPopup.js +55 -0
  171. package/dist/modal/utils/routeMobileExternalWallet.d.ts +1 -0
  172. package/dist/modal/utils/routeMobileExternalWallet.js +35 -0
  173. package/dist/modal/utils/steps.d.ts +112 -0
  174. package/dist/modal/utils/steps.js +215 -0
  175. package/dist/modal/utils/stringFormatters.d.ts +4 -0
  176. package/dist/modal/utils/stringFormatters.js +12 -0
  177. package/dist/modal/utils/validateOnRampConfig.d.ts +5 -0
  178. package/dist/modal/utils/validateOnRampConfig.js +26 -0
  179. package/package.json +51 -0
  180. package/styles.css/package.json +3 -0
@@ -0,0 +1,20 @@
1
+ import { EvmExternalWalletContextType, EvmExternalWalletProvider } from '../../providers/EvmExternalWalletContextStub.js';
2
+ import { Context } from 'react';
3
+ import { SolanaExternalWalletContextType, SolanaExternalWalletProvider } from '../../providers/SolanaExternalWalletContextStub.js';
4
+ import { CosmosExternalWalletContextType, CosmosExternalWalletProvider } from '../../providers/CosmosExternalWalletContextStub.js';
5
+ interface ExternalWalletProviderState {
6
+ EvmProvider?: typeof EvmExternalWalletProvider;
7
+ evmContext?: Context<EvmExternalWalletContextType>;
8
+ SolanaProvider?: typeof SolanaExternalWalletProvider;
9
+ solanaContext?: Context<SolanaExternalWalletContextType>;
10
+ CosmosProvider?: typeof CosmosExternalWalletProvider;
11
+ cosmosContext?: Context<CosmosExternalWalletContextType>;
12
+ connectParaEvmWallet?: () => Promise<any>;
13
+ connectParaCosmosWallet?: () => Promise<any>;
14
+ }
15
+ export interface ExternalWalletProviderActions {
16
+ updateState: (state: Partial<ExternalWalletProviderState>) => void;
17
+ }
18
+ export type ExternalWalletProviderStore = ExternalWalletProviderState & ExternalWalletProviderActions;
19
+ export declare const useExternalWalletProviderStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ExternalWalletProviderStore>>;
20
+ export {};
@@ -0,0 +1,13 @@
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))));
@@ -0,0 +1,4 @@
1
+ export * from './modal/useModalStore.js';
2
+ export * from './para/useParaStore.js';
3
+ export * from './userInfo/useUserInfoStore.js';
4
+ export * from './theme/useThemeStore.js';
@@ -0,0 +1,4 @@
1
+ export * from './modal/useModalStore.js';
2
+ export * from './para/useParaStore.js';
3
+ export * from './userInfo/useUserInfoStore.js';
4
+ export * from './theme/useThemeStore.js';
@@ -0,0 +1,3 @@
1
+ import { StoreApi } from 'zustand';
2
+ import { ModalActions, ModalStore } from './useModalStore.js';
3
+ export declare const getActions: (set: StoreApi<ModalStore>["setState"], get: StoreApi<ModalStore>["getState"]) => ModalActions;
@@ -0,0 +1,65 @@
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
+ setActiveWallet: activeWallet => set({ activeWallet }),
61
+ setFarcasterConnectUri: farcasterConnectUri => set({ farcasterConnectUri }),
62
+ setBiometricLocationHints: biometricLocationHints => set({ biometricLocationHints }),
63
+ setIFrameUrl: iFrameUrl => set({ iFrameUrl }),
64
+ setIsIFrameReady: isIFrameReady => set({ isIFrameReady }),
65
+ });
@@ -0,0 +1,82 @@
1
+ import { ModalStep } from '../../utils/steps.js';
2
+ import { OnRampConfig as OnRampConfigBase, OnRampPurchase, WalletType } from '@getpara/web-sdk';
3
+ import { Tab as AddFundsTabType } from '../../components/AddFunds/AddFunds.js';
4
+ import { AuthMethod } from '@getpara/core-sdk';
5
+ import { BiometricLocationHint } from '@getpara/user-management-client';
6
+ type Flow = 'login' | 'signUp' | 'account';
7
+ type ActiveWallet = [string | undefined, WalletType | undefined];
8
+ export type OnRampConfig = OnRampConfigBase & {
9
+ testMode?: boolean;
10
+ };
11
+ export interface OnModalStepChangeValue {
12
+ previousStep: ModalStep;
13
+ currentStep: ModalStep;
14
+ canGoBack: boolean;
15
+ }
16
+ interface ModalState {
17
+ step: ModalStep;
18
+ stepDirection: 1 | -1;
19
+ flow: Flow | undefined;
20
+ webAuthURLForLogin: string | undefined;
21
+ webAuthURLForCreate: string | undefined;
22
+ passwordUrlForLogin: string | undefined;
23
+ supportedAuthMethods: Set<AuthMethod>;
24
+ onModalStepChange: (value: OnModalStepChangeValue) => void | undefined;
25
+ onRampConfig: OnRampConfig | undefined;
26
+ onRampPurchase: Partial<OnRampPurchase> | undefined;
27
+ popupWindow: Window | undefined;
28
+ isFullyLoggedIn: boolean;
29
+ accountAddFundTab?: AddFundsTabType;
30
+ selectedExternalWalletId?: string;
31
+ isUsingMobileConnector?: boolean;
32
+ isExternalWalletConnecting?: boolean;
33
+ externalWalletError?: string[];
34
+ activeWallet: ActiveWallet | undefined;
35
+ farcasterConnectUri: string | undefined;
36
+ biometricLocationHints: BiometricLocationHint[] | undefined;
37
+ iFrameUrl: string | undefined;
38
+ isIFrameReady: boolean | undefined;
39
+ }
40
+ export interface ModalActions {
41
+ resetState: () => void;
42
+ setStep: (step: ModalStep) => void;
43
+ decrementStep: () => void;
44
+ hasPreviousStep: () => boolean;
45
+ setFlow: (flow?: Flow) => void;
46
+ isLogin: () => boolean;
47
+ isAccount: () => boolean;
48
+ setSupportedAuthMethods: (authMethods: Set<AuthMethod>) => void;
49
+ setWebAuthURLForLogin: (url?: string) => void;
50
+ setWebAuthURLForCreate: (url?: string) => void;
51
+ setPasswordUrlForLogin: (url?: string) => void;
52
+ setOnModalStepChange: (fn: (value: OnModalStepChangeValue) => void) => void;
53
+ setOnRampConfig: (_: OnRampConfig | undefined) => void;
54
+ setOnRampPurchase: (_: Partial<OnRampPurchase> | undefined) => void;
55
+ setPopupWindow: (_: Window | undefined) => void;
56
+ setIsFullyLoggedIn: (isFullyLoggedIn: boolean) => void;
57
+ setAccountAddFundTab: (accountAddFundTab: AddFundsTabType) => void;
58
+ setSelectedExternalWalletId: (id?: string) => void;
59
+ setIsUsingMobileConnector: (isUsingMobileConnector?: boolean) => void;
60
+ setIsExternalWalletConnecting: (isExternalWalletConnecting: boolean) => void;
61
+ setExternalWalletError: (externalWalletError?: string[]) => void;
62
+ setStepDirection: (stepDirection: 1 | -1) => void;
63
+ setActiveWallet: (_: ActiveWallet | undefined) => void;
64
+ setFarcasterConnectUri: (_: string | undefined) => void;
65
+ setBiometricLocationHints: (_?: BiometricLocationHint[]) => void;
66
+ setIFrameUrl: (_?: string) => void;
67
+ setIsIFrameReady: (_?: boolean) => void;
68
+ }
69
+ export type ModalStore = ModalState & ModalActions;
70
+ export declare const DEFAULT_MODAL_STATE: Omit<ModalState, 'step' | 'onRampConfig'>;
71
+ export declare const useModalStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<ModalStore>, "persist"> & {
72
+ persist: {
73
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<ModalStore, unknown>>) => void;
74
+ clearStorage: () => void;
75
+ rehydrate: () => Promise<void> | void;
76
+ hasHydrated: () => boolean;
77
+ onHydrate: (fn: (state: ModalStore) => void) => () => void;
78
+ onFinishHydration: (fn: (state: ModalStore) => void) => () => void;
79
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<ModalStore, unknown>>;
80
+ };
81
+ }>;
82
+ export {};
@@ -0,0 +1,41 @@
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
+ }));
@@ -0,0 +1,3 @@
1
+ import { StoreApi } from 'zustand';
2
+ import { ParaActions, ParaStore } from './useParaStore.js';
3
+ export declare const getActions: (set: StoreApi<ParaStore>["setState"]) => ParaActions;
@@ -0,0 +1,5 @@
1
+ export const getActions = (set) => ({
2
+ setPara: para => {
3
+ set({ para: para });
4
+ },
5
+ });
@@ -0,0 +1,10 @@
1
+ import { ParaInternal } from '@getpara/react-common';
2
+ interface ParaState {
3
+ para: ParaInternal | undefined;
4
+ }
5
+ export interface ParaActions {
6
+ setPara: (para: ParaInternal) => void;
7
+ }
8
+ export type ParaStore = ParaState & ParaActions;
9
+ export declare const useParaStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ParaStore>>;
10
+ export {};
@@ -0,0 +1,3 @@
1
+ import { create } from 'zustand';
2
+ import { getActions } from './actions.js';
3
+ export const useParaStore = create(set => (Object.assign({ para: undefined }, getActions(set))));
@@ -0,0 +1,3 @@
1
+ import { StoreApi } from 'zustand';
2
+ import { ThemeActions, ThemeStore } from './useThemeStore.js';
3
+ export declare const getActions: (set: StoreApi<ThemeStore>["setState"], get: StoreApi<ThemeStore>["getState"]) => ThemeActions;
@@ -0,0 +1,24 @@
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
+ });
@@ -0,0 +1,20 @@
1
+ import { ParaModalTheme, OAuthLogoVariantType, TAuthLayout } from '../../types/modalProps.js';
2
+ interface ThemeState {
3
+ isDark?: boolean;
4
+ logo?: string;
5
+ appName?: string;
6
+ bareModal?: boolean;
7
+ embeddedModal?: boolean;
8
+ oAuthLogoVariant?: OAuthLogoVariantType;
9
+ authLayout?: TAuthLayout[];
10
+ theme?: ParaModalTheme;
11
+ hideWallets?: boolean;
12
+ }
13
+ export interface ThemeActions {
14
+ updateState: (state: Partial<ThemeState>) => void;
15
+ getLogo: () => string | undefined;
16
+ setAuthLayout: (authLayout: TAuthLayout[]) => void;
17
+ }
18
+ export type ThemeStore = ThemeState & ThemeActions;
19
+ export declare const useThemeStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ThemeStore>>;
20
+ export {};
@@ -0,0 +1,14 @@
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))));
@@ -0,0 +1,3 @@
1
+ import { StoreApi } from 'zustand';
2
+ import { UserInfoActions, UserInfoStore } from './useUserInfoStore.js';
3
+ export declare const getActions: (set: StoreApi<UserInfoStore>["setState"], get: StoreApi<UserInfoStore>["getState"]) => UserInfoActions;
@@ -0,0 +1,28 @@
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
+ return get().auth ? Object.assign(Object.assign({}, extractAuthInfo(get().auth)), { pfpUrl: get().pfpUrl, displayName: get().displayName }) : null;
24
+ },
25
+ setRecoveryShare: recoveryShare => {
26
+ set({ recoveryShare });
27
+ },
28
+ });
@@ -0,0 +1,19 @@
1
+ import { Auth } from '@getpara/user-management-client';
2
+ import { ModalAuthInfo } from '@getpara/react-common';
3
+ type SetAuthInfo = Auth & Partial<Pick<ModalAuthInfo, 'pfpUrl' | 'displayName'>>;
4
+ type UserInfoState = {
5
+ auth: Auth | null;
6
+ pfpUrl: string | null;
7
+ displayName: string | null;
8
+ recoveryShare: string | null;
9
+ };
10
+ export interface UserInfoActions {
11
+ resetState: () => void;
12
+ setAuthInfo: (auth: SetAuthInfo) => void;
13
+ getAuthInfo: () => ModalAuthInfo | null;
14
+ setRecoveryShare: (recoveryShare: string | null) => void;
15
+ }
16
+ export type UserInfoStore = UserInfoState & UserInfoActions;
17
+ export declare const DEFAULT_USER_INFO_STATE: UserInfoState;
18
+ export declare const useUserInfoStore: import("zustand").UseBoundStore<import("zustand").StoreApi<UserInfoStore>>;
19
+ export {};
@@ -0,0 +1,9 @@
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))));
@@ -0,0 +1,48 @@
1
+ import { IconType } from '@getpara/react-components';
2
+ export type WalletMetadata = {
3
+ id: string;
4
+ name: string;
5
+ iconUrl: string;
6
+ installed?: boolean;
7
+ isExtension?: boolean;
8
+ isMobile?: boolean;
9
+ isWeb?: boolean;
10
+ downloadUrl?: string;
11
+ getQrUri?: () => Promise<string>;
12
+ downloadUrls?: {
13
+ android?: string;
14
+ ios?: string;
15
+ mobile?: string;
16
+ qrCode?: string;
17
+ chrome?: string;
18
+ edge?: string;
19
+ firefox?: string;
20
+ opera?: string;
21
+ safari?: string;
22
+ browserExtension?: string;
23
+ macos?: string;
24
+ windows?: string;
25
+ linux?: string;
26
+ desktop?: string;
27
+ };
28
+ };
29
+ export type CommonWallet = {
30
+ connect: () => Promise<{
31
+ address?: string;
32
+ error?: string;
33
+ }>;
34
+ connectMobile: (isManualWalletConnect?: boolean) => Promise<{
35
+ address?: string;
36
+ error?: string;
37
+ }>;
38
+ type: 'EVM' | 'SOLANA' | 'COSMOS';
39
+ } & WalletMetadata;
40
+ export type CommonChain = {
41
+ id: string | number;
42
+ name: string;
43
+ };
44
+ export type Tab<T> = {
45
+ label: string;
46
+ value: T;
47
+ icon: IconType;
48
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ export declare enum EvmWallet {
2
+ METAMASK = "METAMASK",
3
+ RAINBOW = "RAINBOW",
4
+ COINBASE = "COINBASE",
5
+ WALLETCONNECT = "WALLETCONNECT",
6
+ ZERION = "ZERION",
7
+ RABBY = "RABBY"
8
+ }
9
+ export declare enum SolanaWallet {
10
+ PHANTOM = "PHANTOM",
11
+ GLOW = "GLOW",
12
+ BACKPACK = "BACKPACK"
13
+ }
14
+ export declare enum CosmosWallet {
15
+ KEPLR = "KEPLR",
16
+ LEAP = "LEAP"
17
+ }
18
+ export declare const ExternalWallet: {
19
+ KEPLR: CosmosWallet.KEPLR;
20
+ LEAP: CosmosWallet.LEAP;
21
+ PHANTOM: SolanaWallet.PHANTOM;
22
+ GLOW: SolanaWallet.GLOW;
23
+ BACKPACK: SolanaWallet.BACKPACK;
24
+ METAMASK: EvmWallet.METAMASK;
25
+ RAINBOW: EvmWallet.RAINBOW;
26
+ COINBASE: EvmWallet.COINBASE;
27
+ WALLETCONNECT: EvmWallet.WALLETCONNECT;
28
+ ZERION: EvmWallet.ZERION;
29
+ RABBY: EvmWallet.RABBY;
30
+ };
31
+ export type TExternalWallet = keyof typeof ExternalWallet;
@@ -0,0 +1,21 @@
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);
@@ -0,0 +1,138 @@
1
+ import ParaWeb, { CurrentWalletIds, OAuthMethod, deprecated__NetworkProp, deprecated__OnRampConfig } from '@getpara/web-sdk';
2
+ import { Theme } from '@getpara/react-components';
3
+ import { OnModalStepChangeValue } from '../stores/index.js';
4
+ import { ModalStep, ModalStepProp } from '../utils/steps.js';
5
+ import { TExternalWallet } from './externalWallets.js';
6
+ export type ParaModalHandle = {
7
+ /**
8
+ * Move the modal backward
9
+ */
10
+ goBack: () => void;
11
+ /**
12
+ * Returns if the modal can go back
13
+ */
14
+ canGoBack: () => boolean;
15
+ /**
16
+ * Returns if the modal is expanded
17
+ */
18
+ currentStep: () => ModalStep;
19
+ /**
20
+ * Trigger the modal close handler
21
+ */
22
+ handleModalClose: () => void;
23
+ };
24
+ export type OAuthLogoVariantType = 'dark' | 'light' | 'default';
25
+ export type ParaModalTheme = Theme & {
26
+ oAuthLogoVariant?: OAuthLogoVariantType;
27
+ };
28
+ export declare enum AuthLayout {
29
+ AUTH_FULL = "AUTH:FULL",
30
+ AUTH_CONDENSED = "AUTH:CONDENSED",
31
+ EXTERNAL_FULL = "EXTERNAL:FULL",
32
+ EXTERNAL_CONDENSED = "EXTERNAL:CONDENSED"
33
+ }
34
+ export type TAuthLayout = `${AuthLayout}`;
35
+ export interface ParaModalProps {
36
+ /**
37
+ * Your ParaWeb instance.
38
+ */
39
+ para: ParaWeb;
40
+ /**
41
+ * Whether or not the modal is open.
42
+ */
43
+ isOpen: boolean;
44
+ /**
45
+ * Whether or not to show two-factor authentication steps to users.
46
+ * Defaults to `false`.
47
+ */
48
+ twoFactorAuthEnabled?: boolean;
49
+ /**
50
+ * Whether or not to show the wallet recovery to users.
51
+ * Defaults to `false`
52
+ */
53
+ recoverySecretStepEnabled?: boolean;
54
+ /**
55
+ * Which OAuth methods (if any) to show.
56
+ * Defaults to `true`.
57
+ */
58
+ oAuthMethods?: OAuthMethod[];
59
+ /**
60
+ * Whether or not to allow for email login. If true, only OAuth login will be available.
61
+ * Defaults to `false`.
62
+ */
63
+ disableEmailLogin?: boolean;
64
+ /**
65
+ * Whether or not to allow for phone login. If true, only OAuth login will be available.
66
+ * Defaults to `false`.
67
+ */
68
+ disablePhoneLogin?: boolean;
69
+ /**
70
+ * Theming to be used throughout the modal.
71
+ */
72
+ theme?: ParaModalTheme;
73
+ /**
74
+ * Logo to be shown throughout the modal.
75
+ */
76
+ 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
+ /**
93
+ * Whether or not to run configured on-ramp providers in test mode.
94
+ */
95
+ onRampTestMode?: boolean;
96
+ /**
97
+ * Whether to display information about on-chain wallets and use related terminology in the Para Modal.
98
+ */
99
+ hideWallets?: boolean;
100
+ currentStepOverride?: ModalStepProp | undefined;
101
+ /**
102
+ * Whether or not to display just the modal without the overlay component.
103
+ * Useful for rendering the modal inside a custom component
104
+ * Defaults to `false`
105
+ */
106
+ bareModal?: boolean;
107
+ /**
108
+ * Whether or not to use the embedded modal styling
109
+ * This is typically only used internally by Para and may result in unwanted styling!
110
+ */
111
+ embeddedModal?: boolean;
112
+ 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
+ * How the modal should order the components on the main auth screen.
121
+ * Only the first method of each type (auth or external) will be used.
122
+ * Default to [AuthLayout.AUTH_FULL, AuthLayout.EXTERNAL_FULL]
123
+ */
124
+ authLayout?: TAuthLayout[];
125
+ /**
126
+ * Called when the modal step changes
127
+ */
128
+ onModalStepChange?: (value: OnModalStepChangeValue) => void;
129
+ /**
130
+ * Called when the modal is closed
131
+ */
132
+ onClose: () => void;
133
+ loginTransitionOverride?: (para: ParaWeb) => Promise<void>;
134
+ createWalletOverride?: (para: ParaWeb) => Promise<{
135
+ recoverySecret?: string;
136
+ walletIds: CurrentWalletIds;
137
+ }>;
138
+ }
@@ -0,0 +1,7 @@
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 = {}));