@getpara/react-sdk 0.1.0 → 0.2.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 (122) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/modal/ParaModal.js +48 -17
  4. package/dist/modal/components/Account/Account.js +3 -2
  5. package/dist/modal/components/AddFunds/AddFunds.js +3 -2
  6. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +3 -2
  7. package/dist/modal/components/AuthInput/AuthInput.js +12 -5
  8. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +7 -3
  9. package/dist/modal/components/Controls/Selects.js +6 -4
  10. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +3 -2
  11. package/dist/modal/components/Hero/Hero.js +3 -2
  12. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +3 -2
  13. package/dist/modal/components/ModalContent/ModalContent.js +6 -2
  14. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +3 -2
  15. package/dist/modal/components/OAuth/OAuth.js +4 -3
  16. package/dist/modal/components/OAuth/TelegramOAuthStep.js +4 -3
  17. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +4 -3
  18. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +10 -5
  19. package/dist/modal/components/WalletCard/WalletCard.js +7 -5
  20. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +3 -2
  21. package/dist/modal/hooks/useActiveWallet.js +7 -5
  22. package/dist/modal/providers/ExternalWalletContext.js +3 -2
  23. package/dist/modal/stores/index.d.ts +0 -1
  24. package/dist/modal/stores/index.js +0 -1
  25. package/dist/modal/stores/modal/actions.js +0 -1
  26. package/dist/modal/stores/modal/useModalStore.d.ts +0 -1
  27. package/dist/modal/types/modalProps.d.ts +3 -3
  28. package/dist/provider/ParaProvider.d.ts +2 -0
  29. package/dist/provider/ParaProvider.js +16 -0
  30. package/dist/provider/actions/checkIfUserExists.d.ts +9 -0
  31. package/dist/provider/actions/checkIfUserExists.js +26 -0
  32. package/dist/provider/actions/createUser.d.ts +12 -0
  33. package/dist/provider/actions/createUser.js +30 -0
  34. package/dist/provider/actions/getAccount.d.ts +7 -0
  35. package/dist/provider/actions/getAccount.js +24 -0
  36. package/dist/provider/actions/getWallet.d.ts +5 -0
  37. package/dist/provider/actions/getWallet.js +16 -0
  38. package/dist/provider/actions/initiateLogin.d.ts +4 -0
  39. package/dist/provider/actions/initiateLogin.js +23 -0
  40. package/dist/provider/actions/keepSessionAlive.d.ts +2 -0
  41. package/dist/provider/actions/keepSessionAlive.js +23 -0
  42. package/dist/provider/actions/logout.d.ts +2 -0
  43. package/dist/provider/actions/logout.js +20 -0
  44. package/dist/provider/actions/signMessage.d.ts +8 -0
  45. package/dist/provider/actions/signMessage.js +23 -0
  46. package/dist/provider/actions/signTransaction.d.ts +8 -0
  47. package/dist/provider/actions/signTransaction.js +23 -0
  48. package/dist/provider/actions/waitForAccountCreation.d.ts +2 -0
  49. package/dist/provider/actions/waitForAccountCreation.js +24 -0
  50. package/dist/provider/actions/waitForLoginAndSetup.d.ts +6 -0
  51. package/dist/provider/actions/waitForLoginAndSetup.js +27 -0
  52. package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +2 -0
  53. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +24 -0
  54. package/dist/provider/hooks/index.d.ts +3 -0
  55. package/dist/provider/hooks/index.js +3 -0
  56. package/dist/provider/hooks/mutations/index.d.ts +10 -0
  57. package/dist/provider/hooks/mutations/index.js +10 -0
  58. package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +13 -0
  59. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +23 -0
  60. package/dist/provider/hooks/mutations/useCreateUser.d.ts +13 -0
  61. package/dist/provider/hooks/mutations/useCreateUser.js +23 -0
  62. package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +14 -0
  63. package/dist/provider/hooks/mutations/useInitiateLogin.js +23 -0
  64. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +12 -0
  65. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +23 -0
  66. package/dist/provider/hooks/mutations/useLogout.d.ts +12 -0
  67. package/dist/provider/hooks/mutations/useLogout.js +33 -0
  68. package/dist/provider/hooks/mutations/useSignMessage.d.ts +15 -0
  69. package/dist/provider/hooks/mutations/useSignMessage.js +33 -0
  70. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +14 -0
  71. package/dist/provider/hooks/mutations/useSignTransaction.js +33 -0
  72. package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +12 -0
  73. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +30 -0
  74. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +14 -0
  75. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +30 -0
  76. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +13 -0
  77. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +30 -0
  78. package/dist/provider/hooks/queries/index.d.ts +2 -0
  79. package/dist/provider/hooks/queries/index.js +2 -0
  80. package/dist/provider/hooks/queries/useAccount.d.ts +10 -0
  81. package/dist/provider/hooks/queries/useAccount.js +23 -0
  82. package/dist/provider/hooks/queries/useWallet.d.ts +5 -0
  83. package/dist/provider/hooks/queries/useWallet.js +24 -0
  84. package/dist/provider/hooks/utils/index.d.ts +3 -0
  85. package/dist/provider/hooks/utils/index.js +3 -0
  86. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.d.ts +3 -0
  87. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +79 -0
  88. package/dist/provider/hooks/utils/useClient.d.ts +4 -0
  89. package/dist/provider/hooks/utils/useClient.js +8 -0
  90. package/dist/provider/hooks/utils/useEventListeners.d.ts +2 -0
  91. package/dist/provider/hooks/utils/useEventListeners.js +87 -0
  92. package/dist/provider/hooks/utils/useInternalClient.d.ts +5 -0
  93. package/dist/provider/hooks/utils/useInternalClient.js +9 -0
  94. package/dist/provider/hooks/utils/useModal.d.ts +8 -0
  95. package/dist/provider/hooks/utils/useModal.js +15 -0
  96. package/dist/provider/hooks/utils/useWalletState.d.ts +14 -0
  97. package/dist/provider/hooks/utils/useWalletState.js +33 -0
  98. package/dist/provider/index.d.ts +3 -0
  99. package/dist/provider/index.js +3 -0
  100. package/dist/provider/stores/getters.d.ts +4 -0
  101. package/dist/provider/stores/getters.js +5 -0
  102. package/dist/provider/stores/slices/client.d.ts +3 -0
  103. package/dist/provider/stores/slices/client.js +4 -0
  104. package/dist/provider/stores/slices/index.d.ts +3 -0
  105. package/dist/provider/stores/slices/index.js +3 -0
  106. package/dist/provider/stores/slices/modal.d.ts +3 -0
  107. package/dist/provider/stores/slices/modal.js +4 -0
  108. package/dist/provider/stores/slices/wallet.d.ts +3 -0
  109. package/dist/provider/stores/slices/wallet.js +6 -0
  110. package/dist/provider/stores/types.d.ts +16 -0
  111. package/dist/provider/stores/types.js +1 -0
  112. package/dist/provider/stores/useStore.d.ts +12 -0
  113. package/dist/provider/stores/useStore.js +12 -0
  114. package/dist/provider/types/provider.d.ts +26 -0
  115. package/dist/provider/types/provider.js +1 -0
  116. package/dist/provider/types/query.d.ts +3 -0
  117. package/dist/provider/types/query.js +1 -0
  118. package/dist/provider/types/utils.d.ts +6 -0
  119. package/dist/provider/types/utils.js +1 -0
  120. package/dist/provider/utils/renameMutations.d.ts +2 -0
  121. package/dist/provider/utils/renameMutations.js +19 -0
  122. package/package.json +7 -5
@@ -12,9 +12,10 @@ import { CpslCodeInput, CpslSpinner, CpslText } from '@getpara/react-components'
12
12
  import { useEffect, useRef, useState } from 'react';
13
13
  import { styled } from 'styled-components';
14
14
  import { ModalStep } from '../../utils/steps.js';
15
- import { useParaStore, useModalStore, useThemeStore, useUserInfoStore } from '../../stores/index.js';
15
+ import { useModalStore, useThemeStore, useUserInfoStore } from '../../stores/index.js';
16
16
  import { Heading, InnerStepContainer, StepContainer } from '../common.js';
17
17
  import { AuthMethod } from '@getpara/core-sdk';
18
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
18
19
  export const VerificationCodeStep = () => {
19
20
  const theme = useThemeStore(state => state.theme);
20
21
  const authInfo = useUserInfoStore(state => state.getAuthInfo());
@@ -23,7 +24,7 @@ export const VerificationCodeStep = () => {
23
24
  const setIFrameUrl = useModalStore(state => state.setIFrameUrl);
24
25
  const setIsIFrameReady = useModalStore(state => state.setIsIFrameReady);
25
26
  const isIFrameReady = useModalStore(state => state.isIFrameReady);
26
- const para = useParaStore(state => state.para);
27
+ const para = useInternalClient();
27
28
  const inputRef = useRef(null);
28
29
  const [code, setCode] = useState('');
29
30
  const [codeError, setCodeError] = useState('');
@@ -77,7 +78,9 @@ export const VerificationCodeStep = () => {
77
78
  const supportedCreateAuthMethods = yield para.getSupportedCreateAuthMethods();
78
79
  if (supportedCreateAuthMethods.has(AuthMethod.PASSWORD) && supportedCreateAuthMethods.has(AuthMethod.PASSKEY)) {
79
80
  setIsIFrameReady(false);
80
- const webAuthUrl = isEmail ? yield para.verifyEmail(code) : yield para.verifyPhone(code);
81
+ const webAuthUrl = isEmail
82
+ ? yield para.verifyEmail({ verificationCode: code })
83
+ : yield para.verifyPhone({ verificationCode: code });
81
84
  const passwordAuthUrl = yield para.getSetupPasswordURL({ authType: authInfo === null || authInfo === void 0 ? void 0 : authInfo.authType, theme });
82
85
  setWebAuthURLForCreate(yield para.shortenLoginLink(webAuthUrl));
83
86
  setIFrameUrl(yield para.shortenLoginLink(passwordAuthUrl));
@@ -86,14 +89,16 @@ export const VerificationCodeStep = () => {
86
89
  }
87
90
  else if ((yield para.getSupportedCreateAuthMethods()).has(AuthMethod.PASSWORD)) {
88
91
  setIsIFrameReady(false);
89
- isEmail ? yield para.verifyEmail(code) : yield para.verifyPhone(code);
92
+ isEmail ? yield para.verifyEmail({ verificationCode: code }) : yield para.verifyPhone({ verificationCode: code });
90
93
  const url = yield para.getSetupPasswordURL({ authType: authInfo === null || authInfo === void 0 ? void 0 : authInfo.authType, theme });
91
94
  setIFrameUrl(yield para.shortenLoginLink(url));
92
95
  setShouldRouteToStep(ModalStep.PASSWORD_CREATION);
93
96
  return;
94
97
  }
95
98
  else {
96
- const url = isEmail ? yield para.verifyEmail(code) : yield para.verifyPhone(code);
99
+ const url = isEmail
100
+ ? yield para.verifyEmail({ verificationCode: code })
101
+ : yield para.verifyPhone({ verificationCode: code });
97
102
  setWebAuthURLForCreate(yield para.shortenLoginLink(url));
98
103
  setStep(ModalStep.BIOMETRIC_CREATION);
99
104
  }
@@ -1,11 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled from 'styled-components';
3
- import { useParaStore, useModalStore, useThemeStore } from '../../stores/index.js';
3
+ import { useModalStore, useThemeStore } from '../../stores/index.js';
4
4
  import { CpslButton, CpslIdenticon, CpslText } from '@getpara/react-components';
5
5
  import { truncateAddress } from '@getpara/web-sdk';
6
6
  import { ModalStep } from '../../utils/steps.js';
7
+ import { useWalletState } from '../../../provider/index.js';
8
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
7
9
  export const ExternalWalletCard = ({ address, showAddFunds }) => {
8
- const para = useParaStore(state => state.para);
10
+ const para = useInternalClient();
9
11
  const wallet = para.externalWallets[address];
10
12
  if (!wallet) {
11
13
  return null;
@@ -14,7 +16,7 @@ export const ExternalWalletCard = ({ address, showAddFunds }) => {
14
16
  };
15
17
  export const WalletCard = ({ id, type, showAddFunds }) => {
16
18
  var _a;
17
- const para = useParaStore(state => state.para);
19
+ const para = useInternalClient();
18
20
  const appName = useThemeStore(state => state.appName);
19
21
  const wallet = para.findWallet(id, type);
20
22
  if (!wallet) {
@@ -25,12 +27,12 @@ export const WalletCard = ({ id, type, showAddFunds }) => {
25
27
  };
26
28
  const SharedWalletCard = ({ address, name, identiconHash, showAddFunds, id, type }) => {
27
29
  const onRampConfig = useModalStore(state => state.onRampConfig);
28
- const setActiveWallet = useModalStore(state => state.setActiveWallet);
30
+ const { setSelectedWallet } = useWalletState();
29
31
  const setStep = useModalStore(state => state.setStep);
30
32
  const isAddFundsEnabled = onRampConfig.isBuyEnabled || onRampConfig.isReceiveEnabled;
31
33
  const handleAddFundsClick = () => {
32
34
  if (id && type) {
33
- setActiveWallet([id, type]);
35
+ setSelectedWallet({ id, type });
34
36
  isAddFundsEnabled && setStep(onRampConfig.isBuyEnabled ? ModalStep.ADD_FUNDS_BUY : ModalStep.ADD_FUNDS_RECEIVE);
35
37
  }
36
38
  };
@@ -10,16 +10,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { CpslButton, CpslText } from '@getpara/react-components';
12
12
  import { StepContainer, InnerStepContainer, HeroIcon } from '../common.js';
13
- import { useParaStore, useModalStore, useThemeStore } from '../../stores/index.js';
13
+ import { useModalStore, useThemeStore } from '../../stores/index.js';
14
14
  import { ModalStep } from '../../utils/steps.js';
15
15
  import { WalletCard, WalletCards } from '../WalletCard/WalletCard.js';
16
16
  import styled from 'styled-components';
17
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
17
18
  export const WalletCreationDoneStep = ({ twoFactorAuthEnabled, onClose }) => {
18
19
  const hideWallets = useThemeStore(state => state.hideWallets);
19
20
  const setStep = useModalStore(state => state.setStep);
20
21
  const isLogin = useModalStore(state => state.isLogin());
21
22
  const onRampConfig = useModalStore(state => state.onRampConfig);
22
- const para = useParaStore(state => state.para);
23
+ const para = useInternalClient();
23
24
  const isOnRampConfigured = (onRampConfig === null || onRampConfig === void 0 ? void 0 : onRampConfig.isBuyEnabled) || (onRampConfig === null || onRampConfig === void 0 ? void 0 : onRampConfig.isReceiveEnabled) || (onRampConfig === null || onRampConfig === void 0 ? void 0 : onRampConfig.isWithdrawEnabled);
24
25
  const handleNext = () => __awaiter(void 0, void 0, void 0, function* () {
25
26
  if (isLogin) {
@@ -1,9 +1,11 @@
1
1
  import { useMemo } from 'react';
2
- import { useParaStore, useModalStore } from '../stores/index.js';
2
+ import { useWalletState } from '../../provider/index.js';
3
+ import { useInternalClient } from '../../provider/hooks/utils/useInternalClient.js';
4
+ // TODO: remove this hook in favor of the useAccount hook once we force the use of the ParaProvider
3
5
  export function useActiveWallet() {
4
- const para = useParaStore(state => state.para);
5
- const [activeWalletId, activeWalletType] = useModalStore(state => state.activeWallet);
6
+ const client = useInternalClient();
7
+ const { selectedWallet } = useWalletState();
6
8
  return useMemo(() => {
7
- return para.findWallet(activeWalletId, activeWalletType, { forbidPregen: true });
8
- }, [para, activeWalletId, activeWalletType]);
9
+ return client.findWallet(selectedWallet.id, selectedWallet.type, { forbidPregen: true });
10
+ }, [client, selectedWallet]);
9
11
  }
@@ -9,9 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
12
- import { useParaStore, useModalStore } from '../stores/index.js';
12
+ import { useModalStore } from '../stores/index.js';
13
13
  import { ModalStep } from '../utils/steps.js';
14
14
  import { WalletType, isIOS, isIOSWebview, isMobile, truncateAddress } from '@getpara/web-sdk';
15
+ import { useInternalClient } from '../../provider/hooks/utils/useInternalClient.js';
15
16
  export const defaultExternalWallet = {
16
17
  wallets: [],
17
18
  chains: [],
@@ -46,7 +47,7 @@ export function ExternalWalletProvider({ children, evmContext, solanaContext, co
46
47
  const setExternalWalletError = useModalStore(state => state.setExternalWalletError);
47
48
  const setIsUsingMobileConnector = useModalStore(state => state.setIsUsingMobileConnector);
48
49
  const isUsingMobileConnector = useModalStore(state => state.isUsingMobileConnector);
49
- const para = useParaStore(state => state.para);
50
+ const para = useInternalClient();
50
51
  const [qrUri, setQrUri] = useState();
51
52
  const [chainIdSwitchingTo, setChainIdSwitchingTo] = useState();
52
53
  // Filter any wallets that aren't included in the sort array, sort by the array then sort by installed extensions
@@ -1,4 +1,3 @@
1
1
  export * from './modal/useModalStore.js';
2
- export * from './para/useParaStore.js';
3
2
  export * from './userInfo/useUserInfoStore.js';
4
3
  export * from './theme/useThemeStore.js';
@@ -1,4 +1,3 @@
1
1
  export * from './modal/useModalStore.js';
2
- export * from './para/useParaStore.js';
3
2
  export * from './userInfo/useUserInfoStore.js';
4
3
  export * from './theme/useThemeStore.js';
@@ -57,7 +57,6 @@ export const getActions = (set, get) => ({
57
57
  setExternalWalletError: externalWalletError => set({ externalWalletError }),
58
58
  setIsUsingMobileConnector: isUsingMobileConnector => set({ isUsingMobileConnector }),
59
59
  setStepDirection: stepDirection => set({ stepDirection }),
60
- setActiveWallet: activeWallet => set({ activeWallet }),
61
60
  setFarcasterConnectUri: farcasterConnectUri => set({ farcasterConnectUri }),
62
61
  setBiometricLocationHints: biometricLocationHints => set({ biometricLocationHints }),
63
62
  setIFrameUrl: iFrameUrl => set({ iFrameUrl }),
@@ -60,7 +60,6 @@ export interface ModalActions {
60
60
  setIsExternalWalletConnecting: (isExternalWalletConnecting: boolean) => void;
61
61
  setExternalWalletError: (externalWalletError?: string[]) => void;
62
62
  setStepDirection: (stepDirection: 1 | -1) => void;
63
- setActiveWallet: (_: ActiveWallet | undefined) => void;
64
63
  setFarcasterConnectUri: (_: string | undefined) => void;
65
64
  setBiometricLocationHints: (_?: BiometricLocationHint[]) => void;
66
65
  setIFrameUrl: (_?: string) => void;
@@ -36,11 +36,11 @@ export interface ParaModalProps {
36
36
  /**
37
37
  * Your ParaWeb instance.
38
38
  */
39
- para: ParaWeb;
39
+ para?: ParaWeb;
40
40
  /**
41
41
  * Whether or not the modal is open.
42
42
  */
43
- isOpen: boolean;
43
+ isOpen?: boolean;
44
44
  /**
45
45
  * Whether or not to show two-factor authentication steps to users.
46
46
  * Defaults to `false`.
@@ -129,7 +129,7 @@ export interface ParaModalProps {
129
129
  /**
130
130
  * Called when the modal is closed
131
131
  */
132
- onClose: () => void;
132
+ onClose?: () => void;
133
133
  loginTransitionOverride?: (para: ParaWeb) => Promise<void>;
134
134
  createWalletOverride?: (para: ParaWeb) => Promise<{
135
135
  recoverySecret?: string;
@@ -0,0 +1,2 @@
1
+ import { ParaProviderProps } from './types/provider.js';
2
+ export declare const ParaProvider: ({ children, paraClientConfig, callbacks, config }: ParaProviderProps) => import("react").ReactNode;
@@ -0,0 +1,16 @@
1
+ import { useEffect } from 'react';
2
+ import { useStore } from './stores/useStore.js';
3
+ import { useAutoSessionKeepAlive } from './hooks/utils/useAutoSessionKeepAlive.js';
4
+ import { useEventListeners } from './hooks/utils/useEventListeners.js';
5
+ import { ParaInternal } from '@getpara/react-common';
6
+ const DEFAULT_CONFIG = { disableAutoSessionKeepAlive: false };
7
+ export const ParaProvider = ({ children, paraClientConfig, callbacks, config = DEFAULT_CONFIG }) => {
8
+ useEventListeners(callbacks);
9
+ useAutoSessionKeepAlive({ disabled: config.disableAutoSessionKeepAlive });
10
+ const setClient = useStore(state => state.setClient);
11
+ useEffect(() => {
12
+ const newClient = new ParaInternal(paraClientConfig.env, paraClientConfig.apiKey, paraClientConfig.opts);
13
+ setClient(newClient);
14
+ }, [paraClientConfig]);
15
+ return children;
16
+ };
@@ -0,0 +1,9 @@
1
+ import { CountryCallingCode } from 'libphonenumber-js';
2
+ import { CreateUserType } from './createUser.js';
3
+ import ParaWeb from '@getpara/web-sdk';
4
+ export interface CheckIfUserExistsArgs {
5
+ type: CreateUserType;
6
+ identifier: string;
7
+ countryCode?: CountryCallingCode;
8
+ }
9
+ export declare const checkIfUserExists: (para?: ParaWeb, args?: CheckIfUserExistsArgs) => Promise<boolean>;
@@ -0,0 +1,26 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { CreateUserType } from './createUser.js';
11
+ export const checkIfUserExists = (para, args) => __awaiter(void 0, void 0, void 0, function* () {
12
+ if (!para) {
13
+ throw new Error('no para instance');
14
+ }
15
+ if (!args) {
16
+ throw new Error('no valid args passed to checkIfUserExists');
17
+ }
18
+ try {
19
+ return yield (args.type === CreateUserType.EMAIL
20
+ ? para.checkIfUserExists({ email: args.identifier })
21
+ : para.checkIfUserExistsByPhone({ phone: args.identifier, countryCode: args.countryCode }));
22
+ }
23
+ catch (e) {
24
+ throw new Error(e);
25
+ }
26
+ });
@@ -0,0 +1,12 @@
1
+ import ParaWeb from '@getpara/web-sdk';
2
+ import { CountryCallingCode } from 'libphonenumber-js';
3
+ export declare enum CreateUserType {
4
+ EMAIL = "EMAIL",
5
+ PHONE = "PHONE"
6
+ }
7
+ export interface CreateUserArgs {
8
+ type: CreateUserType;
9
+ identifier: string;
10
+ countryCode?: CountryCallingCode;
11
+ }
12
+ export declare const createUser: (para?: ParaWeb, args?: CreateUserArgs) => Promise<void>;
@@ -0,0 +1,30 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export var CreateUserType;
11
+ (function (CreateUserType) {
12
+ CreateUserType["EMAIL"] = "EMAIL";
13
+ CreateUserType["PHONE"] = "PHONE";
14
+ })(CreateUserType || (CreateUserType = {}));
15
+ export const createUser = (para, args) => __awaiter(void 0, void 0, void 0, function* () {
16
+ if (!para) {
17
+ throw new Error('no para instance');
18
+ }
19
+ if (!args) {
20
+ throw new Error('no valid args passed to createUser');
21
+ }
22
+ try {
23
+ yield (args.type === CreateUserType.EMAIL
24
+ ? para.createUser({ email: args.identifier })
25
+ : para.createUserByPhone({ phone: args.identifier, countryCode: args.countryCode }));
26
+ }
27
+ catch (e) {
28
+ throw new Error(e);
29
+ }
30
+ });
@@ -0,0 +1,7 @@
1
+ import ParaWeb from '@getpara/web-sdk';
2
+ export declare const getAccount: (para?: ParaWeb) => Promise<{
3
+ isConnected: boolean;
4
+ email: any;
5
+ phone: any;
6
+ wallets: any;
7
+ }>;
@@ -0,0 +1,24 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const getAccount = (para) => __awaiter(void 0, void 0, void 0, function* () {
11
+ const isLoggedIn = yield (para === null || para === void 0 ? void 0 : para.isFullyLoggedIn());
12
+ const resp = {
13
+ isConnected: !!isLoggedIn,
14
+ email: undefined,
15
+ phone: undefined,
16
+ wallets: undefined,
17
+ };
18
+ if (para && resp.isConnected) {
19
+ resp.email = para.getEmail();
20
+ resp.phone = para.getPhoneNumber();
21
+ resp.wallets = para.getWallets();
22
+ }
23
+ return resp;
24
+ });
@@ -0,0 +1,5 @@
1
+ import ParaWeb, { WalletType } from '@getpara/web-sdk';
2
+ export declare const getWallet: (para?: ParaWeb, selectedWallet?: {
3
+ id?: string;
4
+ type?: WalletType;
5
+ }) => Promise<Omit<import("@getpara/web-sdk").Wallet, "signer">>;
@@ -0,0 +1,16 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const getWallet = (para, selectedWallet) => __awaiter(void 0, void 0, void 0, function* () {
11
+ const isLoggedIn = yield (para === null || para === void 0 ? void 0 : para.isFullyLoggedIn());
12
+ if (!para || !isLoggedIn) {
13
+ return null;
14
+ }
15
+ return para.findWallet(selectedWallet === null || selectedWallet === void 0 ? void 0 : selectedWallet.id, selectedWallet === null || selectedWallet === void 0 ? void 0 : selectedWallet.type);
16
+ });
@@ -0,0 +1,4 @@
1
+ import { Auth } from '@getpara/user-management-client';
2
+ import ParaWeb from '@getpara/web-sdk';
3
+ export type InitiateLoginArgs = Auth;
4
+ export declare const initiateLogin: (para?: ParaWeb, args?: Auth) => Promise<Set<import("@getpara/user-management-client").AuthMethod>>;
@@ -0,0 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const initiateLogin = (para, args) => __awaiter(void 0, void 0, void 0, function* () {
11
+ if (!para) {
12
+ throw new Error('no para instance');
13
+ }
14
+ if (!args) {
15
+ throw new Error('no valid args passed to initiateLogin');
16
+ }
17
+ try {
18
+ return yield para.initiateUserLoginV2(args);
19
+ }
20
+ catch (e) {
21
+ throw new Error(e);
22
+ }
23
+ });
@@ -0,0 +1,2 @@
1
+ import ParaWeb from '@getpara/web-sdk';
2
+ export declare const keepSessionAlive: (para?: ParaWeb) => Promise<void>;
@@ -0,0 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const keepSessionAlive = (para) => __awaiter(void 0, void 0, void 0, function* () {
11
+ if (!para) {
12
+ throw new Error('no para instance');
13
+ }
14
+ try {
15
+ const resp = yield para.keepSessionAlive();
16
+ if (!resp) {
17
+ throw new Error('session expired');
18
+ }
19
+ }
20
+ catch (e) {
21
+ throw new Error(e);
22
+ }
23
+ });
@@ -0,0 +1,2 @@
1
+ import ParaWeb from '@getpara/web-sdk';
2
+ export declare const logout: (para?: ParaWeb) => Promise<void>;
@@ -0,0 +1,20 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const logout = (para) => __awaiter(void 0, void 0, void 0, function* () {
11
+ if (!para) {
12
+ throw new Error('no para instance');
13
+ }
14
+ try {
15
+ yield para.logout();
16
+ }
17
+ catch (e) {
18
+ throw new Error(e);
19
+ }
20
+ });
@@ -0,0 +1,8 @@
1
+ import ParaWeb from '@getpara/web-sdk';
2
+ export interface SignMessageArgs {
3
+ walletId: string;
4
+ messageBase64: string;
5
+ timeoutMs?: number;
6
+ cosmosSignDocBase64?: string;
7
+ }
8
+ export declare const signMessage: (para?: ParaWeb, args?: SignMessageArgs) => Promise<import("@getpara/web-sdk").FullSignatureRes>;
@@ -0,0 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const signMessage = (para, args) => __awaiter(void 0, void 0, void 0, function* () {
11
+ if (!para) {
12
+ throw new Error('no para instance');
13
+ }
14
+ if (!args) {
15
+ throw new Error('no valid args passed to signMessage');
16
+ }
17
+ try {
18
+ return yield para.signMessage(args);
19
+ }
20
+ catch (e) {
21
+ throw new Error(e);
22
+ }
23
+ });
@@ -0,0 +1,8 @@
1
+ import ParaWeb from '@getpara/web-sdk';
2
+ export interface SignTransactionArgs {
3
+ walletId: string;
4
+ rlpEncodedTxBase64: string;
5
+ chainId: string;
6
+ timeoutMs?: number;
7
+ }
8
+ export declare const signTransaction: (para?: ParaWeb, args?: SignTransactionArgs) => Promise<import("@getpara/web-sdk").FullSignatureRes>;
@@ -0,0 +1,23 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const signTransaction = (para, args) => __awaiter(void 0, void 0, void 0, function* () {
11
+ if (!para) {
12
+ throw new Error('no para instance');
13
+ }
14
+ if (!args) {
15
+ throw new Error('no valid args passed to signTransaction');
16
+ }
17
+ try {
18
+ return yield para.signTransaction(args);
19
+ }
20
+ catch (e) {
21
+ throw new Error(e);
22
+ }
23
+ });
@@ -0,0 +1,2 @@
1
+ import ParaWeb from '@getpara/web-sdk';
2
+ export declare const waitForAccountCreation: (para?: ParaWeb) => Promise<true>;
@@ -0,0 +1,24 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const waitForAccountCreation = (para) => __awaiter(void 0, void 0, void 0, function* () {
11
+ if (!para) {
12
+ throw new Error('no para instance');
13
+ }
14
+ try {
15
+ const isComplete = yield para.waitForAccountCreation();
16
+ if (!isComplete) {
17
+ throw new Error('error during waitForAccountCreation');
18
+ }
19
+ return isComplete;
20
+ }
21
+ catch (e) {
22
+ throw new Error(e);
23
+ }
24
+ });
@@ -0,0 +1,6 @@
1
+ import ParaWeb from '@getpara/web-sdk';
2
+ export interface WaitForLoginAndSetupArgs {
3
+ loginWindow?: Window;
4
+ skipSessionRefresh?: boolean;
5
+ }
6
+ export declare const waitForLoginAndSetup: (para?: ParaWeb, args?: WaitForLoginAndSetupArgs) => Promise<import("@getpara/web-sdk").LoginResp>;
@@ -0,0 +1,27 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const waitForLoginAndSetup = (para, args) => __awaiter(void 0, void 0, void 0, function* () {
11
+ if (!para) {
12
+ throw new Error('no para instance');
13
+ }
14
+ if (!args) {
15
+ throw new Error('no valid args passed to waitForLoginAndSetup');
16
+ }
17
+ try {
18
+ const resp = yield para.waitForLoginAndSetup(args);
19
+ if (resp.isError) {
20
+ throw new Error('error during waitForLoginAndSetup');
21
+ }
22
+ return resp;
23
+ }
24
+ catch (e) {
25
+ throw new Error(e);
26
+ }
27
+ });
@@ -0,0 +1,2 @@
1
+ import ParaWeb from '@getpara/web-sdk';
2
+ export declare const waitForPasskeyAndCreateWallet: (para?: ParaWeb) => Promise<import("@getpara/web-sdk").AccountSetupResp>;
@@ -0,0 +1,24 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const waitForPasskeyAndCreateWallet = (para) => __awaiter(void 0, void 0, void 0, function* () {
11
+ if (!para) {
12
+ throw new Error('no para instance');
13
+ }
14
+ try {
15
+ const resp = yield para.waitForPasskeyAndCreateWallet();
16
+ if (!resp) {
17
+ throw new Error('error during waitForAccountCreation');
18
+ }
19
+ return resp;
20
+ }
21
+ catch (e) {
22
+ throw new Error(e);
23
+ }
24
+ });
@@ -0,0 +1,3 @@
1
+ export * from './utils/index.js';
2
+ export * from './queries/index.js';
3
+ export * from './mutations/index.js';
@@ -0,0 +1,3 @@
1
+ export * from './utils/index.js';
2
+ export * from './queries/index.js';
3
+ export * from './mutations/index.js';