@dynamic-labs/sdk-react-core 2.1.0-alpha.14 → 2.1.0-alpha.16
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/CHANGELOG.md +16 -0
- package/package.cjs +3 -2
- package/package.js +3 -2
- package/package.json +13 -12
- package/src/index.cjs +1 -3
- package/src/index.d.ts +1 -3
- package/src/index.js +1 -2
- package/src/lib/components/Portal/Portal.cjs +3 -1
- package/src/lib/components/Portal/Portal.js +3 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.cjs +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.js +4 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +20 -15
- package/src/lib/context/DynamicContext/DynamicContext.js +20 -15
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +13 -5
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +14 -6
- package/src/lib/context/DynamicContext/types/index.d.ts +4 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +2 -1
- package/src/lib/context/DynamicContext/validators/validators.cjs +0 -29
- package/src/lib/context/DynamicContext/validators/validators.d.ts +0 -2
- package/src/lib/context/DynamicContext/validators/validators.js +1 -29
- package/src/lib/context/FundingContext/FundingContext.cjs +6 -6
- package/src/lib/context/FundingContext/FundingContext.js +6 -6
- package/src/lib/context/PasskeyContext/PasskeyContext.cjs +0 -1
- package/src/lib/context/PasskeyContext/PasskeyContext.js +0 -1
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- package/src/lib/data/api/api.cjs +25 -3
- package/src/lib/data/api/api.d.ts +1 -1
- package/src/lib/data/api/api.js +25 -3
- package/src/lib/data/api/chains/balances.cjs +2 -2
- package/src/lib/data/api/chains/balances.d.ts +1 -2
- package/src/lib/data/api/chains/balances.js +2 -2
- package/src/lib/data/api/email/email.cjs +2 -2
- package/src/lib/data/api/email/email.d.ts +1 -1
- package/src/lib/data/api/email/email.js +2 -2
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +23 -23
- package/src/lib/data/api/embeddedWallets/embeddedWallets.d.ts +11 -12
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +23 -23
- package/src/lib/data/api/embeddedWallets/types.d.ts +0 -6
- package/src/lib/data/api/mfa/mfa.cjs +18 -18
- package/src/lib/data/api/mfa/mfa.d.ts +9 -18
- package/src/lib/data/api/mfa/mfa.js +18 -18
- package/src/lib/data/api/oauth/oauth.cjs +4 -4
- package/src/lib/data/api/oauth/oauth.d.ts +3 -3
- package/src/lib/data/api/oauth/oauth.js +4 -4
- package/src/lib/data/api/session/session.cjs +2 -2
- package/src/lib/data/api/session/session.d.ts +1 -1
- package/src/lib/data/api/session/session.js +2 -2
- package/src/lib/data/api/sms/sms.cjs +2 -2
- package/src/lib/data/api/sms/sms.d.ts +1 -1
- package/src/lib/data/api/sms/sms.js +2 -2
- package/src/lib/data/api/user/user.cjs +8 -10
- package/src/lib/data/api/user/user.d.ts +4 -4
- package/src/lib/data/api/user/user.js +9 -11
- package/src/lib/data/api/wallets/wallets.cjs +8 -8
- package/src/lib/data/api/wallets/wallets.d.ts +4 -4
- package/src/lib/data/api/wallets/wallets.js +8 -8
- package/src/lib/locale/en/translation.cjs +18 -0
- package/src/lib/locale/en/translation.d.ts +18 -0
- package/src/lib/locale/en/translation.js +18 -0
- package/src/lib/shared/utils/classes/storage/localStorage.cjs +1 -8
- package/src/lib/shared/utils/classes/storage/localStorage.js +2 -9
- package/src/lib/shared/utils/functions/index.d.ts +0 -1
- package/src/lib/store/actions/storeActions/index.d.ts +1 -0
- package/src/lib/store/actions/storeActions/storeActions.cjs +10 -0
- package/src/lib/store/actions/storeActions/storeActions.d.ts +1 -0
- package/src/lib/store/actions/storeActions/storeActions.js +6 -0
- package/src/lib/store/actions/userActions/index.d.ts +1 -0
- package/src/lib/store/actions/userActions/userActions.cjs +10 -0
- package/src/lib/store/actions/userActions/userActions.d.ts +7 -0
- package/src/lib/store/actions/userActions/userActions.js +6 -0
- package/src/lib/store/hooks/useUser/index.d.ts +1 -0
- package/src/lib/store/hooks/useUser/useUser.cjs +12 -0
- package/src/lib/store/hooks/useUser/useUser.d.ts +1 -0
- package/src/lib/store/hooks/useUser/useUser.js +8 -0
- package/src/lib/store/index.d.ts +4 -0
- package/src/lib/store/store.cjs +24 -0
- package/src/lib/store/store.d.ts +13 -0
- package/src/lib/store/store.js +19 -0
- package/src/lib/store/types.d.ts +4 -0
- package/src/lib/store/utils/createStore/createStore.cjs +21 -0
- package/src/lib/store/utils/createStore/createStore.d.ts +16 -0
- package/src/lib/store/utils/createStore/createStore.js +17 -0
- package/src/lib/store/utils/createStore/index.d.ts +1 -0
- package/src/lib/store/utils/syncLegacyStorage/index.d.ts +1 -0
- package/src/lib/store/utils/syncLegacyStorage/syncLegacyStorage.cjs +30 -0
- package/src/lib/store/utils/syncLegacyStorage/syncLegacyStorage.d.ts +2 -0
- package/src/lib/store/utils/syncLegacyStorage/syncLegacyStorage.js +26 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +4 -2
- package/src/lib/utils/constants/localStorage.d.ts +2 -1
- package/src/lib/utils/constants/localStorage.js +3 -2
- package/src/lib/utils/functions/downloadFile/downloadFile.cjs +15 -0
- package/src/lib/utils/functions/downloadFile/downloadFile.d.ts +1 -0
- package/src/lib/utils/functions/downloadFile/downloadFile.js +11 -0
- package/src/lib/utils/functions/downloadFile/index.d.ts +1 -0
- package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.cjs +8 -4
- package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.d.ts +1 -2
- package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.js +8 -4
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.cjs +31 -0
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.d.ts +1 -0
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.js +27 -0
- package/src/lib/utils/functions/getOnboardingAuthToken/index.d.ts +1 -0
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.cjs +7 -3
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.js +7 -3
- package/src/lib/utils/functions/index.d.ts +2 -0
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +1 -1
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.cjs +2 -2
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.js +2 -2
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +4 -2
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +4 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -2
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +4 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +4 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +1 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +1 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +3 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +3 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +2 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +2 -0
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +4 -4
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +4 -4
- package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.cjs +4 -0
- package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.js +4 -0
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +4 -4
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +4 -4
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +6 -3
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.d.ts +1 -4
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +5 -2
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs +1 -3
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js +1 -3
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +1 -8
- package/src/lib/utils/hooks/useMfa/useMfa.js +1 -8
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +1 -1
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +1 -1
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +7 -3
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.d.ts +1 -4
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +6 -2
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.cjs +2 -2
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.js +2 -2
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +1 -1
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +1 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +4 -7
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +4 -7
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +11 -14
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +11 -14
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +0 -1
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +0 -1
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +1 -1
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +1 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +6 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +6 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +3 -3
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +3 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -1
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +4 -4
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +4 -4
- package/src/lib/views/CreatePasswordView/SavePasswordStep/SavePasswordStep.cjs +5 -10
- package/src/lib/views/CreatePasswordView/SavePasswordStep/SavePasswordStep.js +5 -10
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +2 -5
- package/src/lib/views/EmailUpdate/EmailUpdate.js +2 -5
- package/src/lib/views/EmailVerification/EmailVerification.cjs +3 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +3 -1
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +5 -2
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +5 -2
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.cjs +4 -2
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.js +4 -2
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs +111 -0
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.d.ts +2 -0
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js +107 -0
- package/src/lib/views/MfaDisplayBackupCodesView/index.d.ts +1 -0
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +3 -3
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +3 -3
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.cjs +0 -2
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.js +0 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +3 -3
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +3 -3
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +4 -9
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +4 -9
- package/src/lib/views/WalletList/WalletListGridTabs/WalletListGridTabs.cjs +1 -1
- package/src/lib/views/WalletList/WalletListGridTabs/WalletListGridTabs.js +1 -1
- package/src/lib/views/WalletList/hooks/useTabState.cjs +4 -1
- package/src/lib/views/WalletList/hooks/useTabState.js +4 -1
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.cjs +22 -0
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.d.ts +2 -0
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.js +18 -0
- package/src/lib/views/WalletList/utils/getInitialTabIndex/index.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/shared/utils/functions/validateType/index.d.ts +0 -1
- package/src/lib/shared/utils/functions/validateType/validateType.cjs +0 -30
- package/src/lib/shared/utils/functions/validateType/validateType.d.ts +0 -1
- package/src/lib/shared/utils/functions/validateType/validateType.js +0 -26
|
@@ -76,9 +76,9 @@ const retrySmsVerification = (_d) => __awaiter(void 0, [_d], void 0, function* (
|
|
|
76
76
|
throw new SmsVerificationError(data.error, data.code);
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
-
const verifySms = (_e
|
|
79
|
+
const verifySms = (_e) => __awaiter(void 0, [_e], void 0, function* ({ verificationToken, verificationUUID, environmentId, }) {
|
|
80
80
|
try {
|
|
81
|
-
return yield sdkApi(
|
|
81
|
+
return yield sdkApi().verifySmsVerification({
|
|
82
82
|
environmentId,
|
|
83
83
|
smsVerificationVerifyRequest: {
|
|
84
84
|
verificationToken,
|
|
@@ -19,11 +19,9 @@ require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
|
19
19
|
require('../../../shared/consts/index.cjs');
|
|
20
20
|
var api = require('../api.cjs');
|
|
21
21
|
|
|
22
|
-
const updateUserProfileFields = (
|
|
22
|
+
const updateUserProfileFields = (environmentId, fields) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
23
23
|
try {
|
|
24
|
-
|
|
25
|
-
throw new utils.DynamicError('User not authenticated');
|
|
26
|
-
const res = yield api.sdkApi(jwt).updateSelf({
|
|
24
|
+
const res = yield api.sdkApi().updateSelf({
|
|
27
25
|
environmentId,
|
|
28
26
|
userFields: fields,
|
|
29
27
|
});
|
|
@@ -49,9 +47,9 @@ const updateUserProfileFields = (jwt, environmentId, fields) => _tslib.__awaiter
|
|
|
49
47
|
throw e;
|
|
50
48
|
}
|
|
51
49
|
});
|
|
52
|
-
const mergeUserAccounts = (
|
|
50
|
+
const mergeUserAccounts = (environmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
53
51
|
try {
|
|
54
|
-
const response = yield api.sdkApi(
|
|
52
|
+
const response = yield api.sdkApi().mergeUsers({
|
|
55
53
|
environmentId,
|
|
56
54
|
});
|
|
57
55
|
return response;
|
|
@@ -61,9 +59,9 @@ const mergeUserAccounts = (userJwt, environmentId) => _tslib.__awaiter(void 0, v
|
|
|
61
59
|
throw e;
|
|
62
60
|
}
|
|
63
61
|
});
|
|
64
|
-
const verifyMergeUsers = (
|
|
62
|
+
const verifyMergeUsers = (environmentId, mergeConflictResolutions) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
65
63
|
try {
|
|
66
|
-
const response = yield api.sdkApi(
|
|
64
|
+
const response = yield api.sdkApi().verifyMergeUsers({
|
|
67
65
|
environmentId,
|
|
68
66
|
mergeUserConflictResolutions: {
|
|
69
67
|
mergeUserResolutions: mergeConflictResolutions,
|
|
@@ -76,9 +74,9 @@ const verifyMergeUsers = (userJwt, environmentId, mergeConflictResolutions) => _
|
|
|
76
74
|
throw e;
|
|
77
75
|
}
|
|
78
76
|
});
|
|
79
|
-
const refreshUserJwt = (_a
|
|
77
|
+
const refreshUserJwt = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ environmentId, }) {
|
|
80
78
|
try {
|
|
81
|
-
const { jwt, minifiedJwt } = yield api.sdkApi(
|
|
79
|
+
const { jwt, minifiedJwt } = yield api.sdkApi().refreshAuth({
|
|
82
80
|
environmentId,
|
|
83
81
|
});
|
|
84
82
|
return { jwt, minifiedJwt };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { UserFields, UpdateSelfResponse, VerifyResponse, MergeUserConflictResolution } from '@dynamic-labs/sdk-api-core';
|
|
2
|
-
export declare const updateUserProfileFields: (
|
|
3
|
-
export declare const mergeUserAccounts: (
|
|
4
|
-
export declare const verifyMergeUsers: (
|
|
2
|
+
export declare const updateUserProfileFields: (environmentId: string, fields: UserFields) => Promise<UpdateSelfResponse>;
|
|
3
|
+
export declare const mergeUserAccounts: (environmentId: string) => Promise<VerifyResponse | undefined>;
|
|
4
|
+
export declare const verifyMergeUsers: (environmentId: string, mergeConflictResolutions: MergeUserConflictResolution[]) => Promise<VerifyResponse | undefined>;
|
|
5
5
|
export declare const refreshUserJwt: ({ environmentId, }: {
|
|
6
6
|
environmentId: string;
|
|
7
|
-
}
|
|
7
|
+
}) => Promise<{
|
|
8
8
|
jwt: string;
|
|
9
9
|
minifiedJwt: string;
|
|
10
10
|
} | undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import {
|
|
3
|
+
import { EmailAlreadyExistsError, UsernameAlreadyExistsError, TooManyEmailVerificationsError, InvalidPhoneNumberError } from '@dynamic-labs/utils';
|
|
4
4
|
import '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { logger } from '../../../shared/logger.js';
|
|
6
6
|
import '@dynamic-labs/iconic';
|
|
@@ -15,11 +15,9 @@ import '../../../shared/utils/classes/storage/localStorage.js';
|
|
|
15
15
|
import '../../../shared/consts/index.js';
|
|
16
16
|
import { sdkApi } from '../api.js';
|
|
17
17
|
|
|
18
|
-
const updateUserProfileFields = (
|
|
18
|
+
const updateUserProfileFields = (environmentId, fields) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
try {
|
|
20
|
-
|
|
21
|
-
throw new DynamicError('User not authenticated');
|
|
22
|
-
const res = yield sdkApi(jwt).updateSelf({
|
|
20
|
+
const res = yield sdkApi().updateSelf({
|
|
23
21
|
environmentId,
|
|
24
22
|
userFields: fields,
|
|
25
23
|
});
|
|
@@ -45,9 +43,9 @@ const updateUserProfileFields = (jwt, environmentId, fields) => __awaiter(void 0
|
|
|
45
43
|
throw e;
|
|
46
44
|
}
|
|
47
45
|
});
|
|
48
|
-
const mergeUserAccounts = (
|
|
46
|
+
const mergeUserAccounts = (environmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
47
|
try {
|
|
50
|
-
const response = yield sdkApi(
|
|
48
|
+
const response = yield sdkApi().mergeUsers({
|
|
51
49
|
environmentId,
|
|
52
50
|
});
|
|
53
51
|
return response;
|
|
@@ -57,9 +55,9 @@ const mergeUserAccounts = (userJwt, environmentId) => __awaiter(void 0, void 0,
|
|
|
57
55
|
throw e;
|
|
58
56
|
}
|
|
59
57
|
});
|
|
60
|
-
const verifyMergeUsers = (
|
|
58
|
+
const verifyMergeUsers = (environmentId, mergeConflictResolutions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
59
|
try {
|
|
62
|
-
const response = yield sdkApi(
|
|
60
|
+
const response = yield sdkApi().verifyMergeUsers({
|
|
63
61
|
environmentId,
|
|
64
62
|
mergeUserConflictResolutions: {
|
|
65
63
|
mergeUserResolutions: mergeConflictResolutions,
|
|
@@ -72,9 +70,9 @@ const verifyMergeUsers = (userJwt, environmentId, mergeConflictResolutions) => _
|
|
|
72
70
|
throw e;
|
|
73
71
|
}
|
|
74
72
|
});
|
|
75
|
-
const refreshUserJwt = (_a
|
|
73
|
+
const refreshUserJwt = (_a) => __awaiter(void 0, [_a], void 0, function* ({ environmentId, }) {
|
|
76
74
|
try {
|
|
77
|
-
const { jwt, minifiedJwt } = yield sdkApi(
|
|
75
|
+
const { jwt, minifiedJwt } = yield sdkApi().refreshAuth({
|
|
78
76
|
environmentId,
|
|
79
77
|
});
|
|
80
78
|
return { jwt, minifiedJwt };
|
|
@@ -19,9 +19,9 @@ require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
|
19
19
|
require('../../../shared/consts/index.cjs');
|
|
20
20
|
var api = require('../api.cjs');
|
|
21
21
|
|
|
22
|
-
const storeSelectedWallet = (_a
|
|
22
|
+
const storeSelectedWallet = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ environmentId, walletId, }) {
|
|
23
23
|
try {
|
|
24
|
-
const response = yield api.sdkApi(
|
|
24
|
+
const response = yield api.sdkApi().selectUserWallet({
|
|
25
25
|
environmentId,
|
|
26
26
|
userWalletSelectionRequest: {
|
|
27
27
|
walletId,
|
|
@@ -34,7 +34,7 @@ const storeSelectedWallet = (_a, userJwt_1) => _tslib.__awaiter(void 0, [_a, use
|
|
|
34
34
|
return undefined;
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
|
-
const linkWallet = (environmentId_1, _b
|
|
37
|
+
const linkWallet = (environmentId_1, _b) => _tslib.__awaiter(void 0, [environmentId_1, _b], void 0, function* (environmentId, { messageToSign, network, signedMessage, publicWalletAddress, chain, walletName, walletProvider, additionalWalletAddresses, backup, password, passwordSource, }) {
|
|
38
38
|
const verifyRequest = sdkApiCore.VerifyRequestFromJSON({
|
|
39
39
|
additionalWalletAddresses,
|
|
40
40
|
backup,
|
|
@@ -49,7 +49,7 @@ const linkWallet = (environmentId_1, _b, userJwt_2) => _tslib.__awaiter(void 0,
|
|
|
49
49
|
walletProvider,
|
|
50
50
|
});
|
|
51
51
|
try {
|
|
52
|
-
const response = yield api.sdkApi(
|
|
52
|
+
const response = yield api.sdkApi().verifyLink({
|
|
53
53
|
environmentId,
|
|
54
54
|
verifyRequest,
|
|
55
55
|
});
|
|
@@ -72,9 +72,9 @@ const linkWallet = (environmentId_1, _b, userJwt_2) => _tslib.__awaiter(void 0,
|
|
|
72
72
|
return undefined;
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
|
-
const unlinkWallet = (_c
|
|
75
|
+
const unlinkWallet = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, }) {
|
|
76
76
|
try {
|
|
77
|
-
const response = yield api.sdkApi(
|
|
77
|
+
const response = yield api.sdkApi().verifyUnlink({
|
|
78
78
|
environmentId,
|
|
79
79
|
verifyUnlinkRequest: {
|
|
80
80
|
primaryWalletId,
|
|
@@ -87,7 +87,7 @@ const unlinkWallet = (_c, userJwt_3) => _tslib.__awaiter(void 0, [_c, userJwt_3]
|
|
|
87
87
|
return undefined;
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
-
const transferWallet = (environmentId_2, _d
|
|
90
|
+
const transferWallet = (environmentId_2, _d) => _tslib.__awaiter(void 0, [environmentId_2, _d], void 0, function* (environmentId, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck = false, }) {
|
|
91
91
|
// We should find a better way to do this than force type casting
|
|
92
92
|
const verifyRequest = {
|
|
93
93
|
chain,
|
|
@@ -100,7 +100,7 @@ const transferWallet = (environmentId_2, _d, userJwt_4) => _tslib.__awaiter(void
|
|
|
100
100
|
walletProvider,
|
|
101
101
|
};
|
|
102
102
|
try {
|
|
103
|
-
const response = yield api.sdkApi(
|
|
103
|
+
const response = yield api.sdkApi().verifyTransfer({
|
|
104
104
|
environmentId,
|
|
105
105
|
verifyRequest,
|
|
106
106
|
});
|
|
@@ -3,12 +3,12 @@ import { VerifyWallet } from '../../../shared/types';
|
|
|
3
3
|
export declare const storeSelectedWallet: ({ environmentId, walletId, }: {
|
|
4
4
|
environmentId: string;
|
|
5
5
|
walletId: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const linkWallet: (environmentId: string, { messageToSign, network, signedMessage, publicWalletAddress, chain, walletName, walletProvider, additionalWalletAddresses, backup, password, passwordSource, }: VerifyWallet
|
|
6
|
+
}) => Promise<VerifyResponse | undefined>;
|
|
7
|
+
export declare const linkWallet: (environmentId: string, { messageToSign, network, signedMessage, publicWalletAddress, chain, walletName, walletProvider, additionalWalletAddresses, backup, password, passwordSource, }: VerifyWallet) => Promise<VerifyResponse | undefined>;
|
|
8
8
|
export declare const unlinkWallet: ({ environmentId, primaryWalletId, walletId, }: {
|
|
9
9
|
environmentId: string;
|
|
10
10
|
primaryWalletId: string | undefined;
|
|
11
11
|
walletId: string;
|
|
12
|
-
}
|
|
13
|
-
export declare const transferWallet: (environmentId: string, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck, }: VerifyWallet
|
|
12
|
+
}) => Promise<VerifyResponse | undefined>;
|
|
13
|
+
export declare const transferWallet: (environmentId: string, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck, }: VerifyWallet) => Promise<VerifyResponse | undefined>;
|
|
14
14
|
export declare const verifyWallet: (environmentId: string, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, captchaToken, network, oauth, additionalWalletAddresses, }: VerifyWallet) => Promise<VerifyResponse | undefined>;
|
|
@@ -15,9 +15,9 @@ import '../../../shared/utils/classes/storage/localStorage.js';
|
|
|
15
15
|
import '../../../shared/consts/index.js';
|
|
16
16
|
import { sdkApi } from '../api.js';
|
|
17
17
|
|
|
18
|
-
const storeSelectedWallet = (_a
|
|
18
|
+
const storeSelectedWallet = (_a) => __awaiter(void 0, [_a], void 0, function* ({ environmentId, walletId, }) {
|
|
19
19
|
try {
|
|
20
|
-
const response = yield sdkApi(
|
|
20
|
+
const response = yield sdkApi().selectUserWallet({
|
|
21
21
|
environmentId,
|
|
22
22
|
userWalletSelectionRequest: {
|
|
23
23
|
walletId,
|
|
@@ -30,7 +30,7 @@ const storeSelectedWallet = (_a, userJwt_1) => __awaiter(void 0, [_a, userJwt_1]
|
|
|
30
30
|
return undefined;
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
const linkWallet = (environmentId_1, _b
|
|
33
|
+
const linkWallet = (environmentId_1, _b) => __awaiter(void 0, [environmentId_1, _b], void 0, function* (environmentId, { messageToSign, network, signedMessage, publicWalletAddress, chain, walletName, walletProvider, additionalWalletAddresses, backup, password, passwordSource, }) {
|
|
34
34
|
const verifyRequest = VerifyRequestFromJSON({
|
|
35
35
|
additionalWalletAddresses,
|
|
36
36
|
backup,
|
|
@@ -45,7 +45,7 @@ const linkWallet = (environmentId_1, _b, userJwt_2) => __awaiter(void 0, [enviro
|
|
|
45
45
|
walletProvider,
|
|
46
46
|
});
|
|
47
47
|
try {
|
|
48
|
-
const response = yield sdkApi(
|
|
48
|
+
const response = yield sdkApi().verifyLink({
|
|
49
49
|
environmentId,
|
|
50
50
|
verifyRequest,
|
|
51
51
|
});
|
|
@@ -68,9 +68,9 @@ const linkWallet = (environmentId_1, _b, userJwt_2) => __awaiter(void 0, [enviro
|
|
|
68
68
|
return undefined;
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
-
const unlinkWallet = (_c
|
|
71
|
+
const unlinkWallet = (_c) => __awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, }) {
|
|
72
72
|
try {
|
|
73
|
-
const response = yield sdkApi(
|
|
73
|
+
const response = yield sdkApi().verifyUnlink({
|
|
74
74
|
environmentId,
|
|
75
75
|
verifyUnlinkRequest: {
|
|
76
76
|
primaryWalletId,
|
|
@@ -83,7 +83,7 @@ const unlinkWallet = (_c, userJwt_3) => __awaiter(void 0, [_c, userJwt_3], void
|
|
|
83
83
|
return undefined;
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
|
-
const transferWallet = (environmentId_2, _d
|
|
86
|
+
const transferWallet = (environmentId_2, _d) => __awaiter(void 0, [environmentId_2, _d], void 0, function* (environmentId, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck = false, }) {
|
|
87
87
|
// We should find a better way to do this than force type casting
|
|
88
88
|
const verifyRequest = {
|
|
89
89
|
chain,
|
|
@@ -96,7 +96,7 @@ const transferWallet = (environmentId_2, _d, userJwt_4) => __awaiter(void 0, [en
|
|
|
96
96
|
walletProvider,
|
|
97
97
|
};
|
|
98
98
|
try {
|
|
99
|
-
const response = yield sdkApi(
|
|
99
|
+
const response = yield sdkApi().verifyTransfer({
|
|
100
100
|
environmentId,
|
|
101
101
|
verifyRequest,
|
|
102
102
|
});
|
|
@@ -846,6 +846,15 @@ const translation = {
|
|
|
846
846
|
sms_code_description:
|
|
847
847
|
'Use your preferred authenticator app such as Authy, Google Authenticator, etc.',
|
|
848
848
|
},
|
|
849
|
+
display_backup_codes_view: {
|
|
850
|
+
title: 'Back up your codes',
|
|
851
|
+
body: 'Backup codes help recover your account if you lose access to your device.',
|
|
852
|
+
warning: 'You won’t be able to see these again',
|
|
853
|
+
copy_all: 'Copy all',
|
|
854
|
+
download: 'Download',
|
|
855
|
+
checkbox: 'I have safely stored a copy of my password',
|
|
856
|
+
complete: 'Complete',
|
|
857
|
+
},
|
|
849
858
|
otp_verification_view: {
|
|
850
859
|
title: 'Confirm verification code',
|
|
851
860
|
body: 'Enter the verification code generated by your authenticator app',
|
|
@@ -867,6 +876,15 @@ const translation = {
|
|
|
867
876
|
sms_code: 'SMS code',
|
|
868
877
|
sms_code_description: 'Use your preferred authenticator app such as Authy, Google Authenticator, etc.',
|
|
869
878
|
},
|
|
879
|
+
display_backup_codes_view: {
|
|
880
|
+
title: 'Back up your codes',
|
|
881
|
+
body: 'Backup codes help recover your account if you lose access to your device.',
|
|
882
|
+
warning: 'You won’t be able to see these again',
|
|
883
|
+
copy_all: 'Copy all',
|
|
884
|
+
download: 'Download',
|
|
885
|
+
checkbox: 'I have safely stored a copy of my password',
|
|
886
|
+
complete: 'Complete',
|
|
887
|
+
},
|
|
870
888
|
otp_verification_view: {
|
|
871
889
|
title: 'Confirm verification code',
|
|
872
890
|
body: 'Enter the verification code generated by your authenticator app',
|
|
@@ -842,6 +842,15 @@ export declare const translation: {
|
|
|
842
842
|
sms_code_description:
|
|
843
843
|
'Use your preferred authenticator app such as Authy, Google Authenticator, etc.',
|
|
844
844
|
},
|
|
845
|
+
display_backup_codes_view: {
|
|
846
|
+
title: 'Back up your codes',
|
|
847
|
+
body: 'Backup codes help recover your account if you lose access to your device.',
|
|
848
|
+
warning: 'You won’t be able to see these again',
|
|
849
|
+
copy_all: 'Copy all',
|
|
850
|
+
download: 'Download',
|
|
851
|
+
checkbox: 'I have safely stored a copy of my password',
|
|
852
|
+
complete: 'Complete',
|
|
853
|
+
},
|
|
845
854
|
otp_verification_view: {
|
|
846
855
|
title: 'Confirm verification code',
|
|
847
856
|
body: 'Enter the verification code generated by your authenticator app',
|
|
@@ -863,6 +872,15 @@ export declare const translation: {
|
|
|
863
872
|
sms_code: string;
|
|
864
873
|
sms_code_description: string;
|
|
865
874
|
};
|
|
875
|
+
display_backup_codes_view: {
|
|
876
|
+
title: string;
|
|
877
|
+
body: string;
|
|
878
|
+
warning: string;
|
|
879
|
+
copy_all: string;
|
|
880
|
+
download: string;
|
|
881
|
+
checkbox: string;
|
|
882
|
+
complete: string;
|
|
883
|
+
};
|
|
866
884
|
otp_verification_view: {
|
|
867
885
|
title: string;
|
|
868
886
|
body: string;
|
|
@@ -842,6 +842,15 @@ const translation = {
|
|
|
842
842
|
sms_code_description:
|
|
843
843
|
'Use your preferred authenticator app such as Authy, Google Authenticator, etc.',
|
|
844
844
|
},
|
|
845
|
+
display_backup_codes_view: {
|
|
846
|
+
title: 'Back up your codes',
|
|
847
|
+
body: 'Backup codes help recover your account if you lose access to your device.',
|
|
848
|
+
warning: 'You won’t be able to see these again',
|
|
849
|
+
copy_all: 'Copy all',
|
|
850
|
+
download: 'Download',
|
|
851
|
+
checkbox: 'I have safely stored a copy of my password',
|
|
852
|
+
complete: 'Complete',
|
|
853
|
+
},
|
|
845
854
|
otp_verification_view: {
|
|
846
855
|
title: 'Confirm verification code',
|
|
847
856
|
body: 'Enter the verification code generated by your authenticator app',
|
|
@@ -863,6 +872,15 @@ const translation = {
|
|
|
863
872
|
sms_code: 'SMS code',
|
|
864
873
|
sms_code_description: 'Use your preferred authenticator app such as Authy, Google Authenticator, etc.',
|
|
865
874
|
},
|
|
875
|
+
display_backup_codes_view: {
|
|
876
|
+
title: 'Back up your codes',
|
|
877
|
+
body: 'Backup codes help recover your account if you lose access to your device.',
|
|
878
|
+
warning: 'You won’t be able to see these again',
|
|
879
|
+
copy_all: 'Copy all',
|
|
880
|
+
download: 'Download',
|
|
881
|
+
checkbox: 'I have safely stored a copy of my password',
|
|
882
|
+
complete: 'Complete',
|
|
883
|
+
},
|
|
866
884
|
otp_verification_view: {
|
|
867
885
|
title: 'Confirm verification code',
|
|
868
886
|
body: 'Enter the verification code generated by your authenticator app',
|
|
@@ -9,10 +9,6 @@ require('../../../../utils/constants/colors.cjs');
|
|
|
9
9
|
require('../../../../utils/constants/values.cjs');
|
|
10
10
|
var logger = require('../../../logger.cjs');
|
|
11
11
|
|
|
12
|
-
const connectedKeys = {
|
|
13
|
-
[localStorage.AUTH_TOKEN]: [localStorage.AUTH_USER],
|
|
14
|
-
[localStorage.AUTH_USER]: [localStorage.AUTH_TOKEN],
|
|
15
|
-
};
|
|
16
12
|
class LocalStorage {
|
|
17
13
|
static getDynamicLSKey(key) {
|
|
18
14
|
return `${key}${LocalStorage.getSuffix()}`;
|
|
@@ -48,10 +44,7 @@ class LocalStorage {
|
|
|
48
44
|
}
|
|
49
45
|
catch (error) {
|
|
50
46
|
logger.logger.debug(`Error while parsing ${key} from local storage`, { value });
|
|
51
|
-
|
|
52
|
-
[key]
|
|
53
|
-
.concat(connectedKeys[key] || [])
|
|
54
|
-
.forEach((_key) => LocalStorage.removeFromLS(_key));
|
|
47
|
+
LocalStorage.removeFromLS(key);
|
|
55
48
|
dynamicEvents.dynamicEvents.emit('triggerLogout');
|
|
56
49
|
}
|
|
57
50
|
return undefined;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { dynamicEvents } from '../../../../events/dynamicEvents.js';
|
|
3
|
-
import { AUTH_TOKEN
|
|
3
|
+
import { AUTH_TOKEN } from '../../../../utils/constants/localStorage.js';
|
|
4
4
|
import '../../../../utils/constants/colors.js';
|
|
5
5
|
import '../../../../utils/constants/values.js';
|
|
6
6
|
import { logger } from '../../../logger.js';
|
|
7
7
|
|
|
8
|
-
const connectedKeys = {
|
|
9
|
-
[AUTH_TOKEN]: [AUTH_USER],
|
|
10
|
-
[AUTH_USER]: [AUTH_TOKEN],
|
|
11
|
-
};
|
|
12
8
|
class LocalStorage {
|
|
13
9
|
static getDynamicLSKey(key) {
|
|
14
10
|
return `${key}${LocalStorage.getSuffix()}`;
|
|
@@ -44,10 +40,7 @@ class LocalStorage {
|
|
|
44
40
|
}
|
|
45
41
|
catch (error) {
|
|
46
42
|
logger.debug(`Error while parsing ${key} from local storage`, { value });
|
|
47
|
-
|
|
48
|
-
[key]
|
|
49
|
-
.concat(connectedKeys[key] || [])
|
|
50
|
-
.forEach((_key) => LocalStorage.removeFromLS(_key));
|
|
43
|
+
LocalStorage.removeFromLS(key);
|
|
51
44
|
dynamicEvents.emit('triggerLogout');
|
|
52
45
|
}
|
|
53
46
|
return undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { clearStore } from './storeActions';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var store = require('../../store.cjs');
|
|
7
|
+
|
|
8
|
+
const clearStore = () => store.getStore().setState(store.getStore().getInitialState());
|
|
9
|
+
|
|
10
|
+
exports.clearStore = clearStore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const clearStore: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getUser, setUser, removeUser, type GetUserAction, type RemoveUserAction, type SetUserAction, } from './userActions';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UserProfile } from '@dynamic-labs/types';
|
|
2
|
+
export type SetUserAction = (user: UserProfile) => void;
|
|
3
|
+
export type GetUserAction = () => UserProfile | undefined;
|
|
4
|
+
export type RemoveUserAction = () => void;
|
|
5
|
+
export declare const setUser: SetUserAction;
|
|
6
|
+
export declare const getUser: GetUserAction;
|
|
7
|
+
export declare const removeUser: RemoveUserAction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useUser } from './useUser';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var zustand = require('zustand');
|
|
7
|
+
var shallow = require('zustand/react/shallow');
|
|
8
|
+
var store = require('../../store.cjs');
|
|
9
|
+
|
|
10
|
+
const useUser = () => zustand.useStore(store.getStore(), shallow.useShallow((state) => state.user));
|
|
11
|
+
|
|
12
|
+
exports.useUser = useUser;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useUser: () => import("dist/packages/types/src").UserProfile | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var createStore = require('./utils/createStore/createStore.cjs');
|
|
7
|
+
var syncLegacyStorage = require('./utils/syncLegacyStorage/syncLegacyStorage.cjs');
|
|
8
|
+
|
|
9
|
+
let store;
|
|
10
|
+
const getStore = () => {
|
|
11
|
+
if (!store) {
|
|
12
|
+
throw new Error('Store not initialized');
|
|
13
|
+
}
|
|
14
|
+
return store;
|
|
15
|
+
};
|
|
16
|
+
const initializeStore = (props) => {
|
|
17
|
+
if (store) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
store = syncLegacyStorage.syncLegacyStorage(createStore.createStore(props));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.getStore = getStore;
|
|
24
|
+
exports.initializeStore = initializeStore;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CreateStoreProps } from './utils/createStore';
|
|
2
|
+
export declare const getStore: () => Omit<import("zustand").StoreApi<import("./types").Store>, "persist"> & {
|
|
3
|
+
persist: {
|
|
4
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<import("./types").Store, import("./types").Store>>) => void;
|
|
5
|
+
clearStorage: () => void;
|
|
6
|
+
rehydrate: () => void | Promise<void>;
|
|
7
|
+
hasHydrated: () => boolean;
|
|
8
|
+
onHydrate: (fn: (state: import("./types").Store) => void) => () => void;
|
|
9
|
+
onFinishHydration: (fn: (state: import("./types").Store) => void) => () => void;
|
|
10
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<import("./types").Store, import("./types").Store>>;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const initializeStore: (props?: CreateStoreProps) => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { createStore } from './utils/createStore/createStore.js';
|
|
3
|
+
import { syncLegacyStorage } from './utils/syncLegacyStorage/syncLegacyStorage.js';
|
|
4
|
+
|
|
5
|
+
let store;
|
|
6
|
+
const getStore = () => {
|
|
7
|
+
if (!store) {
|
|
8
|
+
throw new Error('Store not initialized');
|
|
9
|
+
}
|
|
10
|
+
return store;
|
|
11
|
+
};
|
|
12
|
+
const initializeStore = (props) => {
|
|
13
|
+
if (store) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
store = syncLegacyStorage(createStore(props));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { getStore, initializeStore };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var zustand = require('zustand');
|
|
7
|
+
var middleware = require('zustand/middleware');
|
|
8
|
+
var localStorage = require('../../../utils/constants/localStorage.cjs');
|
|
9
|
+
require('../../../utils/constants/colors.cjs');
|
|
10
|
+
require('../../../utils/constants/values.cjs');
|
|
11
|
+
|
|
12
|
+
const createStore = ({ storageSuffix } = {}) => zustand.createStore(middleware.persist(() => ({
|
|
13
|
+
user: undefined,
|
|
14
|
+
}), {
|
|
15
|
+
name: storageSuffix
|
|
16
|
+
? `${localStorage.STORE_STORAGE_KEY}_${storageSuffix}`
|
|
17
|
+
: localStorage.STORE_STORAGE_KEY,
|
|
18
|
+
version: 0,
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
exports.createStore = createStore;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Store } from '../../types';
|
|
2
|
+
export type CreateStoreProps = {
|
|
3
|
+
storageSuffix?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const createStore: ({ storageSuffix }?: CreateStoreProps) => Omit<import("zustand").StoreApi<Store>, "persist"> & {
|
|
6
|
+
persist: {
|
|
7
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<Store, Store>>) => void;
|
|
8
|
+
clearStorage: () => void;
|
|
9
|
+
rehydrate: () => void | Promise<void>;
|
|
10
|
+
hasHydrated: () => boolean;
|
|
11
|
+
onHydrate: (fn: (state: Store) => void) => () => void;
|
|
12
|
+
onFinishHydration: (fn: (state: Store) => void) => () => void;
|
|
13
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<Store, Store>>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type CoreStore = ReturnType<typeof createStore>;
|