@dynamic-labs/sdk-react-core 4.5.3 → 4.6.1

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 (83) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +12 -12
  5. package/src/index.cjs +2 -0
  6. package/src/index.d.ts +1 -1
  7. package/src/index.js +1 -0
  8. package/src/lib/components/UserProfile/UserProfile.cjs +8 -1
  9. package/src/lib/components/UserProfile/UserProfile.js +8 -1
  10. package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -13
  11. package/src/lib/context/DynamicContext/DynamicContext.js +3 -13
  12. package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +1 -0
  13. package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +2 -1
  14. package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
  15. package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +2 -1
  16. package/src/lib/context/OnrampContext/useEnabledOnrampProviders/useEnabledOnrampProviders.cjs +2 -1
  17. package/src/lib/context/OnrampContext/useEnabledOnrampProviders/useEnabledOnrampProviders.js +2 -1
  18. package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +31 -4
  19. package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +31 -4
  20. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +1 -1
  21. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +1 -1
  22. package/src/lib/context/UserFieldEditorContext/UserFieldEditorContext.cjs +2 -1
  23. package/src/lib/context/UserFieldEditorContext/UserFieldEditorContext.js +3 -2
  24. package/src/lib/data/api/api.cjs +3 -4
  25. package/src/lib/data/api/api.js +3 -4
  26. package/src/lib/data/api/user/user.cjs +10 -0
  27. package/src/lib/data/api/user/user.d.ts +1 -0
  28. package/src/lib/data/api/user/user.js +10 -1
  29. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +1 -1
  30. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +1 -1
  31. package/src/lib/store/internalImplementation/store.cjs +0 -2
  32. package/src/lib/store/internalImplementation/store.js +0 -2
  33. package/src/lib/store/state/projectSettings/projectSettings.cjs +15 -3
  34. package/src/lib/store/state/projectSettings/projectSettings.d.ts +3 -1
  35. package/src/lib/store/state/projectSettings/projectSettings.js +16 -5
  36. package/src/lib/utils/functions/isCookieEnabled/isCookieEnabled.cjs +6 -6
  37. package/src/lib/utils/functions/isCookieEnabled/isCookieEnabled.d.ts +2 -1
  38. package/src/lib/utils/functions/isCookieEnabled/isCookieEnabled.js +7 -7
  39. package/src/lib/utils/functions/storeAuthToken/storeAuthToken.cjs +3 -1
  40. package/src/lib/utils/functions/storeAuthToken/storeAuthToken.js +3 -1
  41. package/src/lib/utils/hooks/index.d.ts +1 -0
  42. package/src/lib/utils/hooks/useConfirmationModal/useConfirmationModal.cjs +6 -4
  43. package/src/lib/utils/hooks/useConfirmationModal/useConfirmationModal.d.ts +6 -3
  44. package/src/lib/utils/hooks/useConfirmationModal/useConfirmationModal.js +6 -4
  45. package/src/lib/utils/hooks/useDeleteUserAccount/index.d.ts +1 -0
  46. package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.cjs +119 -0
  47. package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.d.ts +7 -0
  48. package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.js +115 -0
  49. package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.cjs +9 -3
  50. package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.js +10 -4
  51. package/src/lib/utils/hooks/useFundWithWallet/utils/FilterWalletsForExternalFunding.cjs +27 -0
  52. package/src/lib/utils/hooks/useFundWithWallet/utils/FilterWalletsForExternalFunding.d.ts +2 -0
  53. package/src/lib/utils/hooks/useFundWithWallet/utils/FilterWalletsForExternalFunding.js +23 -0
  54. package/src/lib/utils/hooks/useFundWithWallet/utils/index.d.ts +1 -0
  55. package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.cjs +7 -4
  56. package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.js +7 -4
  57. package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.cjs +2 -2
  58. package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.d.ts +3 -1
  59. package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.js +2 -2
  60. package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +16 -6
  61. package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +17 -7
  62. package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.cjs +2 -0
  63. package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.js +2 -0
  64. package/src/lib/views/Passkey/PasskeyRecovery/AddRecoveryEmail/AddRecoveryEmail.cjs +1 -1
  65. package/src/lib/views/Passkey/PasskeyRecovery/AddRecoveryEmail/AddRecoveryEmail.js +1 -1
  66. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +1 -1
  67. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +1 -1
  68. package/src/lib/views/WalletList/WalletList.cjs +1 -1
  69. package/src/lib/views/WalletList/WalletList.js +1 -1
  70. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.cjs +14 -1
  71. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.js +14 -1
  72. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/getPromptAmountParams/getPromptAmountParams.cjs +25 -0
  73. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/getPromptAmountParams/getPromptAmountParams.d.ts +7 -0
  74. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/getPromptAmountParams/getPromptAmountParams.js +21 -0
  75. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/getPromptAmountParams/index.d.ts +1 -0
  76. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/useStartExternalWalletFunding.cjs +5 -23
  77. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/useStartExternalWalletFunding.js +5 -23
  78. package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/ManageMfaWidgetView.cjs +1 -1
  79. package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/ManageMfaWidgetView.js +1 -1
  80. package/src/lib/store/internalImplementation/utils/clearExpiredData/clearExpiredData.cjs +0 -24
  81. package/src/lib/store/internalImplementation/utils/clearExpiredData/clearExpiredData.d.ts +0 -3
  82. package/src/lib/store/internalImplementation/utils/clearExpiredData/clearExpiredData.js +0 -20
  83. package/src/lib/store/internalImplementation/utils/clearExpiredData/index.d.ts +0 -1
@@ -86,6 +86,15 @@ const verifyMergeUsers = (environmentId, mergeConflictResolutions) => _tslib.__a
86
86
  throw e;
87
87
  }
88
88
  });
89
+ const hardDeleteUser = (environmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
90
+ try {
91
+ yield api.sdkApi().hardDeleteUser({ environmentId });
92
+ }
93
+ catch (e) {
94
+ yield utils.logResponseError(e, 'Error hardDeleteUser');
95
+ throw e;
96
+ }
97
+ });
89
98
  const refreshUserJwt = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ environmentId, }) {
90
99
  try {
91
100
  const response = yield api.sdkApi().refreshAuth({
@@ -133,6 +142,7 @@ const getUserFieldsCheck = (_c) => _tslib.__awaiter(void 0, [_c], void 0, functi
133
142
 
134
143
  exports.getAuthenticatedUser = getAuthenticatedUser;
135
144
  exports.getUserFieldsCheck = getUserFieldsCheck;
145
+ exports.hardDeleteUser = hardDeleteUser;
136
146
  exports.mergeUserAccounts = mergeUserAccounts;
137
147
  exports.refreshUserJwt = refreshUserJwt;
138
148
  exports.updateUserProfileFields = updateUserProfileFields;
@@ -6,6 +6,7 @@ export type UpdateUserResponse = UpdateSelfResponse & {
6
6
  export declare const updateUserProfileFields: (environmentId: string, fields: UserFields) => Promise<UpdateUserResponse>;
7
7
  export declare const mergeUserAccounts: (environmentId: string) => Promise<UserProfile>;
8
8
  export declare const verifyMergeUsers: (environmentId: string, mergeConflictResolutions: MergeUserConflictResolution[]) => Promise<UserProfile>;
9
+ export declare const hardDeleteUser: (environmentId: string) => Promise<void>;
9
10
  export declare const refreshUserJwt: ({ environmentId, }: {
10
11
  environmentId: string;
11
12
  }) => Promise<UserProfile | undefined>;
@@ -82,6 +82,15 @@ const verifyMergeUsers = (environmentId, mergeConflictResolutions) => __awaiter(
82
82
  throw e;
83
83
  }
84
84
  });
85
+ const hardDeleteUser = (environmentId) => __awaiter(void 0, void 0, void 0, function* () {
86
+ try {
87
+ yield sdkApi().hardDeleteUser({ environmentId });
88
+ }
89
+ catch (e) {
90
+ yield logResponseError(e, 'Error hardDeleteUser');
91
+ throw e;
92
+ }
93
+ });
85
94
  const refreshUserJwt = (_a) => __awaiter(void 0, [_a], void 0, function* ({ environmentId, }) {
86
95
  try {
87
96
  const response = yield sdkApi().refreshAuth({
@@ -127,4 +136,4 @@ const getUserFieldsCheck = (_c) => __awaiter(void 0, [_c], void 0, function* ({
127
136
  }
128
137
  });
129
138
 
130
- export { getAuthenticatedUser, getUserFieldsCheck, mergeUserAccounts, refreshUserJwt, updateUserProfileFields, verifyMergeUsers };
139
+ export { getAuthenticatedUser, getUserFieldsCheck, hardDeleteUser, mergeUserAccounts, refreshUserJwt, updateUserProfileFields, verifyMergeUsers };
@@ -64,7 +64,6 @@ require('../../views/CollectUserDataView/useFields.cjs');
64
64
  require('../../context/FieldsStateContext/FieldsStateContext.cjs');
65
65
  require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
66
66
  require('@dynamic-labs/rpc-providers');
67
- var useEffectOnce = require('../../utils/hooks/useEffectOnce/useEffectOnce.cjs');
68
67
  require('../../store/state/loadingAndLifecycle.cjs');
69
68
  require('@dynamic-labs/store');
70
69
  require('../../store/state/walletOptions/walletOptions.cjs');
@@ -93,6 +92,7 @@ var ModalHeader = require('../../components/ModalHeader/ModalHeader.cjs');
93
92
  require('../../store/state/sendBalances.cjs');
94
93
  require('../../components/Input/Input.cjs');
95
94
  require('../../components/OverlayCard/OverlayCard.cjs');
95
+ var useEffectOnce = require('../../utils/hooks/useEffectOnce/useEffectOnce.cjs');
96
96
  require('../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
97
97
  var PasskeyContext = require('../../context/PasskeyContext/PasskeyContext.cjs');
98
98
  require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
@@ -60,7 +60,6 @@ import '../../views/CollectUserDataView/useFields.js';
60
60
  import '../../context/FieldsStateContext/FieldsStateContext.js';
61
61
  import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
62
62
  import '@dynamic-labs/rpc-providers';
63
- import { useEffectOnce } from '../../utils/hooks/useEffectOnce/useEffectOnce.js';
64
63
  import '../../store/state/loadingAndLifecycle.js';
65
64
  import '@dynamic-labs/store';
66
65
  import '../../store/state/walletOptions/walletOptions.js';
@@ -89,6 +88,7 @@ import { ModalHeader } from '../../components/ModalHeader/ModalHeader.js';
89
88
  import '../../store/state/sendBalances.js';
90
89
  import '../../components/Input/Input.js';
91
90
  import '../../components/OverlayCard/OverlayCard.js';
91
+ import { useEffectOnce } from '../../utils/hooks/useEffectOnce/useEffectOnce.js';
92
92
  import '../../views/TransactionConfirmationView/TransactionConfirmationView.js';
93
93
  import { usePasskeyContext } from '../../context/PasskeyContext/PasskeyContext.js';
94
94
  import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
@@ -10,7 +10,6 @@ require('../../utils/constants/colors.cjs');
10
10
  require('../../utils/constants/values.cjs');
11
11
  var stateConfig = require('../stateConfig.cjs');
12
12
  var version = require('../../../version.cjs');
13
- var clearExpiredData = require('./utils/clearExpiredData/clearExpiredData.cjs');
14
13
  var syncLegacyStorage = require('./utils/syncLegacyStorage/syncLegacyStorage.cjs');
15
14
 
16
15
  let store;
@@ -43,7 +42,6 @@ const initializeStore = (props) => {
43
42
  store: store$1.createStore(() => stateConfig.createInitialStates(props)),
44
43
  version: utils.formatVersion(version.VERSION, 'major.minor'),
45
44
  }));
46
- clearExpiredData.clearExpiredData(store);
47
45
  };
48
46
  const getStorage = () => {
49
47
  if (typeof localStorage === 'undefined') {
@@ -6,7 +6,6 @@ import '../../utils/constants/colors.js';
6
6
  import '../../utils/constants/values.js';
7
7
  import { transformStateForLocalStorage, createInitialStates } from '../stateConfig.js';
8
8
  import { VERSION } from '../../../version.js';
9
- import { clearExpiredData } from './utils/clearExpiredData/clearExpiredData.js';
10
9
  import { syncLegacyStorage } from './utils/syncLegacyStorage/syncLegacyStorage.js';
11
10
 
12
11
  let store;
@@ -39,7 +38,6 @@ const initializeStore = (props) => {
39
38
  store: createStore(() => createInitialStates(props)),
40
39
  version: formatVersion(VERSION, 'major.minor'),
41
40
  }));
42
- clearExpiredData(store);
43
41
  };
44
42
  const getStorage = () => {
45
43
  if (typeof localStorage === 'undefined') {
@@ -10,6 +10,7 @@ require('../../../config/ApiEndpoint.cjs');
10
10
  require('../../../utils/constants/values.cjs');
11
11
  require('@dynamic-labs/multi-wallet');
12
12
  require('../../../shared/logger.cjs');
13
+ var localStorage = require('../../../utils/constants/localStorage.cjs');
13
14
  require('../../../utils/constants/colors.cjs');
14
15
  require('react-international-phone');
15
16
  require('@dynamic-labs/iconic');
@@ -22,7 +23,7 @@ require('../../../shared/consts/index.cjs');
22
23
  require('../nonce/nonce.cjs');
23
24
  var dynamicContextProps = require('../dynamicContextProps/dynamicContextProps.cjs');
24
25
  require('../primaryWalletId/primaryWalletId.cjs');
25
- require('../user/user.cjs');
26
+ var user = require('../user/user.cjs');
26
27
  var settings = require('../../../data/api/settings/settings.cjs');
27
28
  require('../../../locale/locale.cjs');
28
29
  var useDynamicEvents = require('../../../utils/hooks/events/useDynamicEvents/useDynamicEvents.cjs');
@@ -97,9 +98,18 @@ var createStoreState = require('../../internalImplementation/utils/createStoreSt
97
98
 
98
99
  const { getProjectSettings: getProjectSettingsRaw, setProjectSettings, useProjectSettings: useProjectSettingsRaw, resetProjectSettings, } = createStoreState.createStoreState('projectSettings');
99
100
  const getProjectSettings = () => getProjectSettingsRaw().settings;
101
+ const getProjectSettingsExpireAt = () => getProjectSettingsRaw().expiresAt;
100
102
  const useProjectSettings = () => useProjectSettingsRaw().settings;
101
103
  const useFetchProjectSettings = ({ retries = 2, } = {}) => {
102
- const lsSettingsExists = Boolean(useProjectSettings());
104
+ const originalProjectSettings = getProjectSettings();
105
+ const expiresAt = getProjectSettingsExpireAt();
106
+ const isProjectSettingsPresent = Boolean(originalProjectSettings);
107
+ const didProjectSettingsExpire = expiresAt ? expiresAt < Date.now() : false;
108
+ const hasUser = user.getUser() !== undefined;
109
+ const hasConnectedWallet = (utils.StorageService.getItem(localStorage.CONNECTED_WALLETS_INFO) || []).length > 0;
110
+ const enableProjectSettingsFetch = !isProjectSettingsPresent ||
111
+ didProjectSettingsExpire ||
112
+ (hasUser === false && hasConnectedWallet === false);
103
113
  const environmentId = dynamicContextProps.useEnvironmentId();
104
114
  const { retrigger } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
105
115
  const settings$1 = yield settings.fetchProjectSettings(environmentId);
@@ -108,7 +118,7 @@ const useFetchProjectSettings = ({ retries = 2, } = {}) => {
108
118
  return settings$1;
109
119
  }), {
110
120
  deps: [environmentId],
111
- enabled: !lsSettingsExists,
121
+ enabled: enableProjectSettingsFetch,
112
122
  onResolve: (projectSettings) => {
113
123
  const expiry = new Date().getTime() + 60000 * 5;
114
124
  setProjectSettings({
@@ -119,9 +129,11 @@ const useFetchProjectSettings = ({ retries = 2, } = {}) => {
119
129
  retries,
120
130
  });
121
131
  useDynamicEvents.useDynamicEvents('logout', retrigger);
132
+ return { refetchProjectSettings: retrigger };
122
133
  };
123
134
 
124
135
  exports.getProjectSettings = getProjectSettings;
136
+ exports.getProjectSettingsExpireAt = getProjectSettingsExpireAt;
125
137
  exports.resetProjectSettings = resetProjectSettings;
126
138
  exports.setProjectSettings = setProjectSettings;
127
139
  exports.useFetchProjectSettings = useFetchProjectSettings;
@@ -8,4 +8,6 @@ export declare const useProjectSettingsExpiresAt: () => number | undefined;
8
8
  export type UseProjectSettingsProps = {
9
9
  retries?: number;
10
10
  };
11
- export declare const useFetchProjectSettings: ({ retries, }?: UseProjectSettingsProps) => void;
11
+ export declare const useFetchProjectSettings: ({ retries, }?: UseProjectSettingsProps) => {
12
+ refetchProjectSettings: () => Promise<ProjectSettings | undefined>;
13
+ };
@@ -1,11 +1,12 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
- import { DynamicError } from '@dynamic-labs/utils';
3
+ import { StorageService, DynamicError } from '@dynamic-labs/utils';
4
4
  import '@dynamic-labs/sdk-api-core';
5
5
  import '../../../config/ApiEndpoint.js';
6
6
  import '../../../utils/constants/values.js';
7
7
  import '@dynamic-labs/multi-wallet';
8
8
  import '../../../shared/logger.js';
9
+ import { CONNECTED_WALLETS_INFO } from '../../../utils/constants/localStorage.js';
9
10
  import '../../../utils/constants/colors.js';
10
11
  import 'react-international-phone';
11
12
  import '@dynamic-labs/iconic';
@@ -18,7 +19,7 @@ import '../../../shared/consts/index.js';
18
19
  import '../nonce/nonce.js';
19
20
  import { useEnvironmentId } from '../dynamicContextProps/dynamicContextProps.js';
20
21
  import '../primaryWalletId/primaryWalletId.js';
21
- import '../user/user.js';
22
+ import { getUser } from '../user/user.js';
22
23
  import { fetchProjectSettings } from '../../../data/api/settings/settings.js';
23
24
  import '../../../locale/locale.js';
24
25
  import { useDynamicEvents } from '../../../utils/hooks/events/useDynamicEvents/useDynamicEvents.js';
@@ -93,9 +94,18 @@ import { createStoreState } from '../../internalImplementation/utils/createStore
93
94
 
94
95
  const { getProjectSettings: getProjectSettingsRaw, setProjectSettings, useProjectSettings: useProjectSettingsRaw, resetProjectSettings, } = createStoreState('projectSettings');
95
96
  const getProjectSettings = () => getProjectSettingsRaw().settings;
97
+ const getProjectSettingsExpireAt = () => getProjectSettingsRaw().expiresAt;
96
98
  const useProjectSettings = () => useProjectSettingsRaw().settings;
97
99
  const useFetchProjectSettings = ({ retries = 2, } = {}) => {
98
- const lsSettingsExists = Boolean(useProjectSettings());
100
+ const originalProjectSettings = getProjectSettings();
101
+ const expiresAt = getProjectSettingsExpireAt();
102
+ const isProjectSettingsPresent = Boolean(originalProjectSettings);
103
+ const didProjectSettingsExpire = expiresAt ? expiresAt < Date.now() : false;
104
+ const hasUser = getUser() !== undefined;
105
+ const hasConnectedWallet = (StorageService.getItem(CONNECTED_WALLETS_INFO) || []).length > 0;
106
+ const enableProjectSettingsFetch = !isProjectSettingsPresent ||
107
+ didProjectSettingsExpire ||
108
+ (hasUser === false && hasConnectedWallet === false);
99
109
  const environmentId = useEnvironmentId();
100
110
  const { retrigger } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
101
111
  const settings = yield fetchProjectSettings(environmentId);
@@ -104,7 +114,7 @@ const useFetchProjectSettings = ({ retries = 2, } = {}) => {
104
114
  return settings;
105
115
  }), {
106
116
  deps: [environmentId],
107
- enabled: !lsSettingsExists,
117
+ enabled: enableProjectSettingsFetch,
108
118
  onResolve: (projectSettings) => {
109
119
  const expiry = new Date().getTime() + 60000 * 5;
110
120
  setProjectSettings({
@@ -115,6 +125,7 @@ const useFetchProjectSettings = ({ retries = 2, } = {}) => {
115
125
  retries,
116
126
  });
117
127
  useDynamicEvents('logout', retrigger);
128
+ return { refetchProjectSettings: retrigger };
118
129
  };
119
130
 
120
- export { getProjectSettings, resetProjectSettings, setProjectSettings, useFetchProjectSettings, useProjectSettings };
131
+ export { getProjectSettings, getProjectSettingsExpireAt, resetProjectSettings, setProjectSettings, useFetchProjectSettings, useProjectSettings };
@@ -5,10 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var sdkApiCore = require('@dynamic-labs/sdk-api-core');
7
7
  var utils = require('@dynamic-labs/utils');
8
- var projectSettings = require('../../../store/state/projectSettings/projectSettings.cjs');
9
8
 
10
- const isCookieEnabled = () => {
11
- var _a, _b, _c;
9
+ const isCookieEnabled = (projectSettings) => {
10
+ var _a, _b;
11
+ utils.assertDefined(projectSettings, 'projectSettings is required');
12
12
  /**
13
13
  * There is no cookie on native mobile applications
14
14
  * so this feature must be disabled for native mobile
@@ -16,13 +16,13 @@ const isCookieEnabled = () => {
16
16
  if (utils.PlatformService.isNativeMobile) {
17
17
  return false;
18
18
  }
19
- const securitySettings = (_a = projectSettings.getProjectSettings()) === null || _a === void 0 ? void 0 : _a.security;
19
+ const securitySettings = projectSettings.security;
20
20
  if (!securitySettings)
21
21
  return false;
22
22
  // client uses Dynamic cookies
23
- const dynamicCookiesEnabled = (((_b = securitySettings.auth) === null || _b === void 0 ? void 0 : _b.storage) || []).includes(sdkApiCore.AuthStorageEnum.Cookie);
23
+ const dynamicCookiesEnabled = (((_a = securitySettings.auth) === null || _a === void 0 ? void 0 : _a.storage) || []).includes(sdkApiCore.AuthStorageEnum.Cookie);
24
24
  // BYO JWT client puts their non-Dynamic JWT in a cookie
25
- const byoJwtCookieEnabled = Boolean((_c = securitySettings.externalAuth) === null || _c === void 0 ? void 0 : _c.cookieName);
25
+ const byoJwtCookieEnabled = Boolean((_b = securitySettings.externalAuth) === null || _b === void 0 ? void 0 : _b.cookieName);
26
26
  // should return true for both of these scenarios
27
27
  // because we also need to do `credentials: true` in api.ts when
28
28
  // a byo jwt client sets their named cookie for their jwt and
@@ -1 +1,2 @@
1
- export declare const isCookieEnabled: () => boolean;
1
+ import { ProjectSettings } from '@dynamic-labs/sdk-api-core';
2
+ export declare const isCookieEnabled: (projectSettings: ProjectSettings) => boolean;
@@ -1,10 +1,10 @@
1
1
  'use client'
2
2
  import { AuthStorageEnum } from '@dynamic-labs/sdk-api-core';
3
- import { PlatformService } from '@dynamic-labs/utils';
4
- import { getProjectSettings } from '../../../store/state/projectSettings/projectSettings.js';
3
+ import { assertDefined, PlatformService } from '@dynamic-labs/utils';
5
4
 
6
- const isCookieEnabled = () => {
7
- var _a, _b, _c;
5
+ const isCookieEnabled = (projectSettings) => {
6
+ var _a, _b;
7
+ assertDefined(projectSettings, 'projectSettings is required');
8
8
  /**
9
9
  * There is no cookie on native mobile applications
10
10
  * so this feature must be disabled for native mobile
@@ -12,13 +12,13 @@ const isCookieEnabled = () => {
12
12
  if (PlatformService.isNativeMobile) {
13
13
  return false;
14
14
  }
15
- const securitySettings = (_a = getProjectSettings()) === null || _a === void 0 ? void 0 : _a.security;
15
+ const securitySettings = projectSettings.security;
16
16
  if (!securitySettings)
17
17
  return false;
18
18
  // client uses Dynamic cookies
19
- const dynamicCookiesEnabled = (((_b = securitySettings.auth) === null || _b === void 0 ? void 0 : _b.storage) || []).includes(AuthStorageEnum.Cookie);
19
+ const dynamicCookiesEnabled = (((_a = securitySettings.auth) === null || _a === void 0 ? void 0 : _a.storage) || []).includes(AuthStorageEnum.Cookie);
20
20
  // BYO JWT client puts their non-Dynamic JWT in a cookie
21
- const byoJwtCookieEnabled = Boolean((_c = securitySettings.externalAuth) === null || _c === void 0 ? void 0 : _c.cookieName);
21
+ const byoJwtCookieEnabled = Boolean((_b = securitySettings.externalAuth) === null || _b === void 0 ? void 0 : _b.cookieName);
22
22
  // should return true for both of these scenarios
23
23
  // because we also need to do `credentials: true` in api.ts when
24
24
  // a byo jwt client sets their named cookie for their jwt and
@@ -8,6 +8,7 @@ var localStorage = require('../../constants/localStorage.cjs');
8
8
  var values = require('../../constants/values.cjs');
9
9
  var isCookieEnabled = require('../isCookieEnabled/isCookieEnabled.cjs');
10
10
  var storeExpiresAt = require('../storeExpiresAt/storeExpiresAt.cjs');
11
+ var projectSettings = require('../../../store/state/projectSettings/projectSettings.cjs');
11
12
 
12
13
  const storeAuthToken = ({ jwt, minifiedJwt, expiresAt, }) => {
13
14
  // expiresAt is always sent back by the backend, regardless of whether jwt/minifiedJwt are sent or not
@@ -20,7 +21,8 @@ const storeAuthToken = ({ jwt, minifiedJwt, expiresAt, }) => {
20
21
  utils.StorageService.setItem(localStorage.AUTH_MIN_TOKEN, minifiedJwt, {
21
22
  priority: ['secureStorage', 'localStorage'],
22
23
  });
23
- if (isCookieEnabled.isCookieEnabled()) {
24
+ const projectSettings$1 = projectSettings.getProjectSettings();
25
+ if (projectSettings$1 && isCookieEnabled.isCookieEnabled(projectSettings$1)) {
24
26
  // if cookie is enabled, but the backend returns a JWT, then use JS to store the cookie
25
27
  const expireDate = new Date(expiresAt * 1000).toUTCString();
26
28
  const authCookie = `${values.DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${expireDate}; path=/; SameSite=Lax`;
@@ -4,6 +4,7 @@ import { AUTH_TOKEN, AUTH_MIN_TOKEN } from '../../constants/localStorage.js';
4
4
  import { DYNAMIC_AUTH_COOKIE_NAME } from '../../constants/values.js';
5
5
  import { isCookieEnabled } from '../isCookieEnabled/isCookieEnabled.js';
6
6
  import { storeExpiresAt } from '../storeExpiresAt/storeExpiresAt.js';
7
+ import { getProjectSettings } from '../../../store/state/projectSettings/projectSettings.js';
7
8
 
8
9
  const storeAuthToken = ({ jwt, minifiedJwt, expiresAt, }) => {
9
10
  // expiresAt is always sent back by the backend, regardless of whether jwt/minifiedJwt are sent or not
@@ -16,7 +17,8 @@ const storeAuthToken = ({ jwt, minifiedJwt, expiresAt, }) => {
16
17
  StorageService.setItem(AUTH_MIN_TOKEN, minifiedJwt, {
17
18
  priority: ['secureStorage', 'localStorage'],
18
19
  });
19
- if (isCookieEnabled()) {
20
+ const projectSettings = getProjectSettings();
21
+ if (projectSettings && isCookieEnabled(projectSettings)) {
20
22
  // if cookie is enabled, but the backend returns a JWT, then use JS to store the cookie
21
23
  const expireDate = new Date(expiresAt * 1000).toUTCString();
22
24
  const authCookie = `${DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${expireDate}; path=/; SameSite=Lax`;
@@ -73,3 +73,4 @@ export { useDeviceFingerprint } from './useDeviceFingerprint';
73
73
  export * from './useEmbeddedWallet';
74
74
  export { useUpgradeEmbeddedWallet } from './useUpgradeEmbeddedWallet';
75
75
  export { useAggregateWalletEvents } from './useAggregateWalletEvents';
76
+ export { useDeleteUserAccount } from './useDeleteUserAccount';
@@ -9,12 +9,14 @@ var React = require('react');
9
9
  var reactDom = require('react-dom');
10
10
  var useElementById = require('../useElementById/useElementById.cjs');
11
11
 
12
- // eslint-disable-next-line multiline-comment-style
13
- /** Allows showing a modal for the user to confirm or cancel.
14
- * @param {string} elementId The id of the modal root, to which the modal will be portalled
15
- * @returns {ConfirmationModalHookResult} An object with a method to open a modal and a reference to the modal itself.
12
+ /**
13
+ * Allows showing a modal for the user to confirm or cancel.
14
+ *
16
15
  * The open method accepts a callback which receives a (resolve, reject) pair to be called if the user
17
16
  * confirms or cancels the operation, and must return the ReactNode for the modal to be displayed.
17
+ *
18
+ * @param {string} elementId The id of the modal root, to which the modal will be portalled
19
+ * @returns {ConfirmationModalHookResult} An object with a method to open a modal and a reference to the modal itself.
18
20
  */
19
21
  const useConfirmationModal = ({ elementId, }) => {
20
22
  const { createRootElement } = useElementById.useElementById();
@@ -1,8 +1,11 @@
1
1
  import { ConfirmationModalHookProps, ConfirmationModalHookResult } from './useConfirmationModal.types';
2
- /** Allows showing a modal for the user to confirm or cancel.
3
- * @param {string} elementId The id of the modal root, to which the modal will be portalled
4
- * @returns {ConfirmationModalHookResult} An object with a method to open a modal and a reference to the modal itself.
2
+ /**
3
+ * Allows showing a modal for the user to confirm or cancel.
4
+ *
5
5
  * The open method accepts a callback which receives a (resolve, reject) pair to be called if the user
6
6
  * confirms or cancels the operation, and must return the ReactNode for the modal to be displayed.
7
+ *
8
+ * @param {string} elementId The id of the modal root, to which the modal will be portalled
9
+ * @returns {ConfirmationModalHookResult} An object with a method to open a modal and a reference to the modal itself.
7
10
  */
8
11
  export declare const useConfirmationModal: <T, E = unknown>({ elementId, }: ConfirmationModalHookProps) => ConfirmationModalHookResult<T, E>;
@@ -5,12 +5,14 @@ import { useState, useCallback } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
  import { useElementById } from '../useElementById/useElementById.js';
7
7
 
8
- // eslint-disable-next-line multiline-comment-style
9
- /** Allows showing a modal for the user to confirm or cancel.
10
- * @param {string} elementId The id of the modal root, to which the modal will be portalled
11
- * @returns {ConfirmationModalHookResult} An object with a method to open a modal and a reference to the modal itself.
8
+ /**
9
+ * Allows showing a modal for the user to confirm or cancel.
10
+ *
12
11
  * The open method accepts a callback which receives a (resolve, reject) pair to be called if the user
13
12
  * confirms or cancels the operation, and must return the ReactNode for the modal to be displayed.
13
+ *
14
+ * @param {string} elementId The id of the modal root, to which the modal will be portalled
15
+ * @returns {ConfirmationModalHookResult} An object with a method to open a modal and a reference to the modal itself.
14
16
  */
15
17
  const useConfirmationModal = ({ elementId, }) => {
16
18
  const { createRootElement } = useElementById();
@@ -0,0 +1 @@
1
+ export * from './useDeleteUserAccount';
@@ -0,0 +1,119 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
+ var React = require('react');
8
+ require('@dynamic-labs/utils');
9
+ require('@dynamic-labs/sdk-api-core');
10
+ require('../../../config/ApiEndpoint.cjs');
11
+ require('../../constants/values.cjs');
12
+ require('@dynamic-labs/multi-wallet');
13
+ require('../../../shared/logger.cjs');
14
+ require('../../constants/colors.cjs');
15
+ require('react-international-phone');
16
+ require('@dynamic-labs/iconic');
17
+ require('@dynamic-labs/wallet-connector-core');
18
+ require('react/jsx-runtime');
19
+ require('../../../context/ViewContext/ViewContext.cjs');
20
+ require('@dynamic-labs/wallet-book');
21
+ require('../../../shared/consts/index.cjs');
22
+ require('../../../store/state/nonce/nonce.cjs');
23
+ require('../../../store/state/projectSettings/projectSettings.cjs');
24
+ var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
25
+ require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
26
+ require('../../../store/state/user/user.cjs');
27
+ require('../../../locale/locale.cjs');
28
+ var user = require('../../../data/api/user/user.cjs');
29
+ require('../../../context/DynamicContext/DynamicContext.cjs');
30
+ require('../../../events/dynamicEvents.cjs');
31
+ require('../../../context/CaptchaContext/CaptchaContext.cjs');
32
+ require('../../../context/ErrorContext/ErrorContext.cjs');
33
+ require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
34
+ require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
35
+ require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
36
+ require('../../../context/VerificationContext/VerificationContext.cjs');
37
+ require('react-dom');
38
+ require('../../functions/compareChains/compareChains.cjs');
39
+ require('../../../context/ThemeContext/ThemeContext.cjs');
40
+ require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
41
+ require('bs58');
42
+ require('@dynamic-labs/types');
43
+ require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
44
+ require('../../../context/LoadingContext/LoadingContext.cjs');
45
+ require('../../../context/WalletContext/WalletContext.cjs');
46
+ require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
47
+ require('yup');
48
+ require('../../../context/MockContext/MockContext.cjs');
49
+ require('../../../views/CollectUserDataView/useFields.cjs');
50
+ require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
51
+ require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
52
+ require('@dynamic-labs/rpc-providers');
53
+ require('../../../store/state/loadingAndLifecycle.cjs');
54
+ require('@dynamic-labs/store');
55
+ require('../../../store/state/walletOptions/walletOptions.cjs');
56
+ require('react-i18next');
57
+ require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
58
+ require('../../../components/Alert/Alert.cjs');
59
+ require('../../../components/ShadowDOM/ShadowDOM.cjs');
60
+ require('../../../components/IconButton/IconButton.cjs');
61
+ require('../../../components/InlineWidget/InlineWidget.cjs');
62
+ require('../../../components/Input/Input.cjs');
63
+ require('../../../components/IsBrowser/IsBrowser.cjs');
64
+ require('../../../components/MenuList/Dropdown/Dropdown.cjs');
65
+ require('../../../components/OverlayCard/OverlayCard.cjs');
66
+ require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
67
+ require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
68
+ require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
69
+ require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
70
+ require('../../../components/Popper/Popper/Popper.cjs');
71
+ require('../../../components/Popper/PopperContext/PopperContext.cjs');
72
+ require('react-focus-lock');
73
+ require('qrcode');
74
+ require('formik');
75
+ require('../useSubdomainCheck/useSubdomainCheck.cjs');
76
+ require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
77
+ require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
78
+ require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
79
+ require('../../../context/ConnectWithOtpContext/constants.cjs');
80
+ require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
81
+ require('@hcaptcha/react-hcaptcha');
82
+ require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
83
+ require('../../../context/FooterAnimationContext/index.cjs');
84
+ require('../../../context/PasskeyContext/PasskeyContext.cjs');
85
+ require('../../../store/state/sendBalances.cjs');
86
+ require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
87
+ require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
88
+ require('../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
89
+ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
90
+ require('../../../context/OnrampContext/OnrampContext.cjs');
91
+ require('../../../widgets/DynamicWidget/views/ReceiveExternalWalletFunds/ReceiveExternalWalletFunds.cjs');
92
+ require('../../../../index.cjs');
93
+ require('../../../store/state/tokenBalances.cjs');
94
+ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
95
+ var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
96
+
97
+ const useDeleteUserAccount = () => {
98
+ const environmentId = dynamicContextProps.useEnvironmentId();
99
+ const { handleLogOut } = useInternalDynamicContext.useInternalDynamicContext();
100
+ const [isLoading, setIsLoading] = React.useState(false);
101
+ const [error, setError] = React.useState(null);
102
+ const deleteUser = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
103
+ try {
104
+ setIsLoading(true);
105
+ setError(null);
106
+ yield user.hardDeleteUser(environmentId);
107
+ yield handleLogOut();
108
+ }
109
+ catch (err) {
110
+ setError(err);
111
+ }
112
+ finally {
113
+ setIsLoading(false);
114
+ }
115
+ });
116
+ return { deleteUser, error, isLoading };
117
+ };
118
+
119
+ exports.useDeleteUserAccount = useDeleteUserAccount;
@@ -0,0 +1,7 @@
1
+ type UseDeleteUserAccountReturn = {
2
+ deleteUser: () => Promise<void>;
3
+ error: Error | null;
4
+ isLoading: boolean;
5
+ };
6
+ export declare const useDeleteUserAccount: () => UseDeleteUserAccountReturn;
7
+ export {};