@dynamic-labs/sdk-react-core 4.79.2 → 4.80.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 (72) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +13 -13
  5. package/src/lib/Main.cjs +2 -2
  6. package/src/lib/Main.js +2 -2
  7. package/src/lib/client/extension/deprecated/mfa/verifyTotpMfaDevice/verifyTotpMfaDevice.d.ts +1 -1
  8. package/src/lib/components/LogoutButton/LogoutButton.cjs +2 -2
  9. package/src/lib/components/LogoutButton/LogoutButton.js +2 -2
  10. package/src/lib/context/DynamicContext/DynamicContext.cjs +6 -4
  11. package/src/lib/context/DynamicContext/DynamicContext.js +6 -4
  12. package/src/lib/context/DynamicContext/hooks/useHandleLogout/index.d.ts +1 -0
  13. package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +9 -0
  14. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +25 -12
  15. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.d.ts +5 -3
  16. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +24 -11
  17. package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.cjs +3 -3
  18. package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.d.ts +3 -2
  19. package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.js +3 -3
  20. package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +2 -0
  21. package/src/lib/context/DynamicContext/types/IInternalDynamicContext.d.ts +8 -1
  22. package/src/lib/events/auth.d.ts +2 -1
  23. package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.cjs +2 -2
  24. package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.js +2 -2
  25. package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +1 -1
  26. package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +1 -1
  27. package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +3 -3
  28. package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +3 -3
  29. package/src/lib/utils/hooks/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.cjs +1 -1
  30. package/src/lib/utils/hooks/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.d.ts +2 -1
  31. package/src/lib/utils/hooks/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.js +1 -1
  32. package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.cjs +3 -1
  33. package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.d.ts +2 -2
  34. package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.js +3 -1
  35. package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +3 -3
  36. package/src/lib/utils/hooks/useValidateSession/useValidateSession.d.ts +3 -3
  37. package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +3 -3
  38. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +2 -2
  39. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +3 -2
  40. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +2 -2
  41. package/src/lib/views/BackupUnsuccessfulView/BackupUnsuccessfulView.cjs +5 -5
  42. package/src/lib/views/BackupUnsuccessfulView/BackupUnsuccessfulView.js +5 -5
  43. package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +2 -2
  44. package/src/lib/views/CollectUserDataView/CollectUserDataView.js +2 -2
  45. package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.cjs +2 -2
  46. package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.js +2 -2
  47. package/src/lib/views/DeviceRegistrationView/DeviceRegistrationView.cjs +2 -2
  48. package/src/lib/views/DeviceRegistrationView/DeviceRegistrationView.js +2 -2
  49. package/src/lib/views/EmailVerification/EmailVerification.cjs +2 -2
  50. package/src/lib/views/EmailVerification/EmailVerification.js +2 -2
  51. package/src/lib/views/EmbeddedDeleteView/EmbeddedDeleteView.cjs +2 -2
  52. package/src/lib/views/EmbeddedDeleteView/EmbeddedDeleteView.js +2 -2
  53. package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +7 -7
  54. package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +7 -7
  55. package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +7 -7
  56. package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +7 -7
  57. package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +5 -5
  58. package/src/lib/views/MfaVerificationView/MfaVerificationView.js +5 -5
  59. package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +2 -2
  60. package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +2 -2
  61. package/src/lib/views/SmsVerification/SmsVerification.cjs +2 -2
  62. package/src/lib/views/SmsVerification/SmsVerification.js +2 -2
  63. package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.cjs +2 -2
  64. package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.js +2 -2
  65. package/src/lib/views/WalletLockedView/WalletLockedView.cjs +2 -2
  66. package/src/lib/views/WalletLockedView/WalletLockedView.js +2 -2
  67. package/src/lib/views/WalletUsedView/WalletUsedView.cjs +2 -2
  68. package/src/lib/views/WalletUsedView/WalletUsedView.js +2 -2
  69. package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.cjs +2 -2
  70. package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.js +2 -2
  71. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +2 -2
  72. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +2 -2
package/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
1
 
2
+ ## [4.80.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.79.2...v4.80.0) (2026-05-05)
3
+
4
+
5
+ ### Features
6
+
7
+ * **aleo:** Aleo wallet connectors + send/shield token registries + UI transaction type ([#11101](https://github.com/dynamic-labs/dynamic-auth/issues/11101)) ([5478d9c](https://github.com/dynamic-labs/dynamic-auth/commit/5478d9c21ee065e2e6c8e96d37ab17b74c5aa0f8))
8
+ * **midnight:** add address query methods and getProvider to InjectedWalletBase ([#11082](https://github.com/dynamic-labs/dynamic-auth/issues/11082)) ([9b6a870](https://github.com/dynamic-labs/dynamic-auth/commit/9b6a8709f83d04673e9dbe23bb0caae5827b036c))
9
+ * **ton:** recognize v3R1/v3R2/v4 wallets in TonConnect proof verification ([#11130](https://github.com/dynamic-labs/dynamic-auth/issues/11130)) ([6c40ab1](https://github.com/dynamic-labs/dynamic-auth/commit/6c40ab11e56d56e278aeb5ee2ae982a42767b5cb))
10
+
2
11
  ### [4.79.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.79.1...v4.79.2) (2026-05-04)
3
12
 
4
13
 
package/package.cjs CHANGED
@@ -3,9 +3,9 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.79.2";
6
+ var version = "4.80.0";
7
7
  var dependencies = {
8
- "@dynamic-labs/sdk-api-core": "0.0.958",
8
+ "@dynamic-labs/sdk-api-core": "0.0.964",
9
9
  "@dynamic-labs-sdk/client": "0.26.9",
10
10
  "@dynamic-labs-wallet/browser-wallet-client": "0.0.325",
11
11
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use client'
2
- var version = "4.79.2";
2
+ var version = "4.80.0";
3
3
  var dependencies = {
4
- "@dynamic-labs/sdk-api-core": "0.0.958",
4
+ "@dynamic-labs/sdk-api-core": "0.0.964",
5
5
  "@dynamic-labs-sdk/client": "0.26.9",
6
6
  "@dynamic-labs-wallet/browser-wallet-client": "0.0.325",
7
7
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "4.79.2",
3
+ "version": "4.80.0",
4
4
  "dependencies": {
5
- "@dynamic-labs/sdk-api-core": "0.0.958",
5
+ "@dynamic-labs/sdk-api-core": "0.0.964",
6
6
  "@dynamic-labs-sdk/client": "0.26.9",
7
7
  "@dynamic-labs-wallet/browser-wallet-client": "0.0.325",
8
8
  "@hcaptcha/react-hcaptcha": "1.4.4",
@@ -16,17 +16,17 @@
16
16
  "yup": "0.32.11",
17
17
  "react-international-phone": "4.5.0",
18
18
  "bs58": "5.0.0",
19
- "@dynamic-labs/assert-package-version": "4.79.2",
20
- "@dynamic-labs/iconic": "4.79.2",
21
- "@dynamic-labs/locale": "4.79.2",
22
- "@dynamic-labs/logger": "4.79.2",
23
- "@dynamic-labs/multi-wallet": "4.79.2",
24
- "@dynamic-labs/rpc-providers": "4.79.2",
25
- "@dynamic-labs/store": "4.79.2",
26
- "@dynamic-labs/types": "4.79.2",
27
- "@dynamic-labs/utils": "4.79.2",
28
- "@dynamic-labs/wallet-book": "4.79.2",
29
- "@dynamic-labs/wallet-connector-core": "4.79.2",
19
+ "@dynamic-labs/assert-package-version": "4.80.0",
20
+ "@dynamic-labs/iconic": "4.80.0",
21
+ "@dynamic-labs/locale": "4.80.0",
22
+ "@dynamic-labs/logger": "4.80.0",
23
+ "@dynamic-labs/multi-wallet": "4.80.0",
24
+ "@dynamic-labs/rpc-providers": "4.80.0",
25
+ "@dynamic-labs/store": "4.80.0",
26
+ "@dynamic-labs/types": "4.80.0",
27
+ "@dynamic-labs/utils": "4.80.0",
28
+ "@dynamic-labs/wallet-book": "4.80.0",
29
+ "@dynamic-labs/wallet-connector-core": "4.80.0",
30
30
  "eventemitter3": "5.0.1"
31
31
  },
32
32
  "devDependencies": {
package/src/lib/Main.cjs CHANGED
@@ -120,7 +120,7 @@ const viewsToDisableCloseOnOverlayClick = [
120
120
  'mfa-display-backup-codes',
121
121
  ];
122
122
  const Main = () => {
123
- const { selectedWalletConnector, linkedWallets, projectSettings, setShowAuthFlow, showAuthFlow, walletConnectorOptions, clearStatesOnBackClick, user, disconnectWallet, connectedWallets, handleLogOut, } = useInternalDynamicContext.useInternalDynamicContext();
123
+ const { selectedWalletConnector, linkedWallets, projectSettings, setShowAuthFlow, showAuthFlow, walletConnectorOptions, clearStatesOnBackClick, user, disconnectWallet, connectedWallets, handleLogOutWithReason, } = useInternalDynamicContext.useInternalDynamicContext();
124
124
  const { view, clearStackAndPushInitialView } = ViewContext.useViewContext();
125
125
  const { setDeniedAddress, setDeniedOauthProvider } = AccessDeniedContext.useAccessDeniedContext();
126
126
  const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
@@ -138,7 +138,7 @@ const Main = () => {
138
138
  if ((view.type === 'network-not-supported' ||
139
139
  view.type === 'network-not-supported-manual') &&
140
140
  userWallets.length === 1) {
141
- yield handleLogOut();
141
+ yield handleLogOutWithReason('network-unsupported');
142
142
  }
143
143
  if (view.type === 'farcaster-connect-view') {
144
144
  setSocialProvider(undefined);
package/src/lib/Main.js CHANGED
@@ -116,7 +116,7 @@ const viewsToDisableCloseOnOverlayClick = [
116
116
  'mfa-display-backup-codes',
117
117
  ];
118
118
  const Main = () => {
119
- const { selectedWalletConnector, linkedWallets, projectSettings, setShowAuthFlow, showAuthFlow, walletConnectorOptions, clearStatesOnBackClick, user, disconnectWallet, connectedWallets, handleLogOut, } = useInternalDynamicContext();
119
+ const { selectedWalletConnector, linkedWallets, projectSettings, setShowAuthFlow, showAuthFlow, walletConnectorOptions, clearStatesOnBackClick, user, disconnectWallet, connectedWallets, handleLogOutWithReason, } = useInternalDynamicContext();
120
120
  const { view, clearStackAndPushInitialView } = useViewContext();
121
121
  const { setDeniedAddress, setDeniedOauthProvider } = useAccessDeniedContext();
122
122
  const { setExistentAccountData } = useAccountExistsContext();
@@ -134,7 +134,7 @@ const Main = () => {
134
134
  if ((view.type === 'network-not-supported' ||
135
135
  view.type === 'network-not-supported-manual') &&
136
136
  userWallets.length === 1) {
137
- yield handleLogOut();
137
+ yield handleLogOutWithReason('network-unsupported');
138
138
  }
139
139
  if (view.type === 'farcaster-connect-view') {
140
140
  setSocialProvider(undefined);
@@ -1,3 +1,3 @@
1
1
  export declare const verifyTotpMfaDevice: ({ code }: {
2
2
  code: string;
3
- }) => Promise<import("@dynamic-labs/sdk-api-core").MFADevice>;
3
+ }) => Promise<import("@dynamic-labs-sdk/client").MFADevice>;
@@ -114,11 +114,11 @@ var useInternalDynamicContext = require('../../context/DynamicContext/useDynamic
114
114
 
115
115
  const LogoutButton = ({ buttonClassName = '', isTextButton = false, }) => {
116
116
  const [loading, setLoading] = React.useState(false);
117
- const { handleLogOut } = useInternalDynamicContext.useInternalDynamicContext();
117
+ const { handleLogOutWithReason } = useInternalDynamicContext.useInternalDynamicContext();
118
118
  const onLogOutClick = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
119
119
  try {
120
120
  setLoading(true);
121
- yield handleLogOut();
121
+ yield handleLogOutWithReason('user-intent');
122
122
  }
123
123
  catch (e) {
124
124
  logger.logger.error(e);
@@ -110,11 +110,11 @@ import { useInternalDynamicContext } from '../../context/DynamicContext/useDynam
110
110
 
111
111
  const LogoutButton = ({ buttonClassName = '', isTextButton = false, }) => {
112
112
  const [loading, setLoading] = useState(false);
113
- const { handleLogOut } = useInternalDynamicContext();
113
+ const { handleLogOutWithReason } = useInternalDynamicContext();
114
114
  const onLogOutClick = () => __awaiter(void 0, void 0, void 0, function* () {
115
115
  try {
116
116
  setLoading(true);
117
- yield handleLogOut();
117
+ yield handleLogOutWithReason('user-intent');
118
118
  }
119
119
  catch (e) {
120
120
  logger.error(e);
@@ -374,7 +374,7 @@ const InnerDynamicContextProvider = (props) => {
374
374
  }
375
375
  });
376
376
  };
377
- const handleLogOut = useHandleLogout.useHandleLogout({
377
+ const { handleLogOut, handleLogOutWithReason } = useHandleLogout.useHandleLogout({
378
378
  bridgeChains,
379
379
  clearAllWalletConnectSessions,
380
380
  connectedWallets,
@@ -396,7 +396,7 @@ const InnerDynamicContextProvider = (props) => {
396
396
  });
397
397
  useValidateSession.useValidateSession({
398
398
  environmentId,
399
- handleLogOut,
399
+ handleLogOutWithReason,
400
400
  });
401
401
  // For some reason, calling useNonce in useGlobalLoading causes errors
402
402
  const nonce$1 = nonce.useNonce();
@@ -422,7 +422,7 @@ const InnerDynamicContextProvider = (props) => {
422
422
  // Listen for wallet deep link returns and emit events (mobile only)
423
423
  useWalletReturnRoute.useWalletReturnRoute();
424
424
  const removeWallet = useRemoveWallet.useRemoveWallet({
425
- handleLogOut,
425
+ handleLogOutWithReason,
426
426
  secondaryWallets,
427
427
  setPrimaryWallet,
428
428
  });
@@ -437,7 +437,7 @@ const InnerDynamicContextProvider = (props) => {
437
437
  useWalletEventListeners.useWalletEventListeners({
438
438
  detectNewWalletsForLinking,
439
439
  disconnectWallet,
440
- handleLogOut,
440
+ handleLogOutWithReason,
441
441
  multiWallet,
442
442
  multiWalletWidgetState,
443
443
  primaryWallet,
@@ -538,6 +538,7 @@ const InnerDynamicContextProvider = (props) => {
538
538
  getConnectedWalletById,
539
539
  getNameService,
540
540
  handleLogOut,
541
+ handleLogOutWithReason,
541
542
  handlers,
542
543
  i18nSDKInstance,
543
544
  isBridgeFlow,
@@ -653,6 +654,7 @@ const InnerDynamicContextProvider = (props) => {
653
654
  getConnectedWalletById,
654
655
  getNameService,
655
656
  handleLogOut,
657
+ handleLogOutWithReason,
656
658
  removeWallet,
657
659
  handlers,
658
660
  i18nSDKInstance,
@@ -370,7 +370,7 @@ const InnerDynamicContextProvider = (props) => {
370
370
  }
371
371
  });
372
372
  };
373
- const handleLogOut = useHandleLogout({
373
+ const { handleLogOut, handleLogOutWithReason } = useHandleLogout({
374
374
  bridgeChains,
375
375
  clearAllWalletConnectSessions,
376
376
  connectedWallets,
@@ -392,7 +392,7 @@ const InnerDynamicContextProvider = (props) => {
392
392
  });
393
393
  useValidateSession({
394
394
  environmentId,
395
- handleLogOut,
395
+ handleLogOutWithReason,
396
396
  });
397
397
  // For some reason, calling useNonce in useGlobalLoading causes errors
398
398
  const nonce = useNonce();
@@ -418,7 +418,7 @@ const InnerDynamicContextProvider = (props) => {
418
418
  // Listen for wallet deep link returns and emit events (mobile only)
419
419
  useWalletReturnRoute();
420
420
  const removeWallet = useRemoveWallet({
421
- handleLogOut,
421
+ handleLogOutWithReason,
422
422
  secondaryWallets,
423
423
  setPrimaryWallet,
424
424
  });
@@ -433,7 +433,7 @@ const InnerDynamicContextProvider = (props) => {
433
433
  useWalletEventListeners({
434
434
  detectNewWalletsForLinking,
435
435
  disconnectWallet,
436
- handleLogOut,
436
+ handleLogOutWithReason,
437
437
  multiWallet,
438
438
  multiWalletWidgetState,
439
439
  primaryWallet,
@@ -534,6 +534,7 @@ const InnerDynamicContextProvider = (props) => {
534
534
  getConnectedWalletById,
535
535
  getNameService,
536
536
  handleLogOut,
537
+ handleLogOutWithReason,
537
538
  handlers,
538
539
  i18nSDKInstance,
539
540
  isBridgeFlow,
@@ -649,6 +650,7 @@ const InnerDynamicContextProvider = (props) => {
649
650
  getConnectedWalletById,
650
651
  getNameService,
651
652
  handleLogOut,
653
+ handleLogOutWithReason,
652
654
  removeWallet,
653
655
  handlers,
654
656
  i18nSDKInstance,
@@ -1 +1,2 @@
1
1
  export * from './useHandleLogout';
2
+ export type { SdkLogoutReason } from './types';
@@ -1,4 +1,5 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
+ import { LogoutReason } from '@dynamic-labs-sdk/client';
2
3
  import { AuthMode, UserProfile } from '@dynamic-labs/types';
3
4
  import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
4
5
  import { DynamicEventsCallbacks, Wallet } from '../../../../shared';
@@ -6,6 +7,14 @@ import { MultiWalletWidgetStateSetter } from '../../../../utils/hooks/multiWalle
6
7
  import { ChainsToConnect } from '../../types';
7
8
  import { SetShowAuthFlow } from '../useShowAuthFlow';
8
9
  import { SetSelectedWalletConnectorKey } from '../useSelectedWalletConnector/SetSelectedWalletConnectorKey.type';
10
+ /**
11
+ * Diagnostic reason tag for a logout. Widens the official LogoutReason union
12
+ * from @dynamic-labs-sdk/client with SDK-invented strings so each internal
13
+ * logout call site can be attributed in Datadog. Cast to LogoutReason at the
14
+ * boundary inside handleLogOutWithReason (the client SDK forwards unknown
15
+ * strings through to Datadog as-is).
16
+ */
17
+ export type SdkLogoutReason = LogoutReason | 'auth-cancelled' | 'last-wallet-removed' | 'network-unsupported' | 'wallet-info-out-of-sync' | 'token-expired-validate-session' | 'embedded-wallet-session-key-invalid' | 'storage-parse-failure' | 'mfa-verification-cancelled' | 'mfa-choose-device-cancelled' | 'mfa-secure-device-cancelled' | 'backup-unsuccessful' | 'user-data-collection-cancelled' | 'store-environment-mismatch' | 'primary-wallet-disconnected';
9
18
  export type UseHandleLogoutParams = {
10
19
  clearAllWalletConnectSessions: () => void;
11
20
  bridgeChains: ChainsToConnect[] | undefined;
@@ -5,7 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../../../_virtual/_tslib.cjs');
7
7
  var React = require('react');
8
- var client = require('@dynamic-labs-sdk/client');
8
+ var client$1 = require('@dynamic-labs-sdk/client');
9
+ var core = require('@dynamic-labs-sdk/client/core');
9
10
  var utils = require('@dynamic-labs/utils');
10
11
  require('@dynamic-labs/iconic');
11
12
  require('@dynamic-labs/wallet-connector-core');
@@ -29,8 +30,7 @@ require('../../../ErrorContext/ErrorContext.cjs');
29
30
  require('@dynamic-labs/multi-wallet');
30
31
  require('react-international-phone');
31
32
  require('../../../../store/state/nonce/nonce.cjs');
32
- require('@dynamic-labs-sdk/client/core');
33
- require('eventemitter3');
33
+ var client = require('../../../../client/client.cjs');
34
34
  require('../../../../config/ApiEndpoint.cjs');
35
35
  require('../../../../events/dynamicEvents.cjs');
36
36
  require('@dynamic-labs/locale');
@@ -111,6 +111,8 @@ require('../../../../store/state/multichainBalances.cjs');
111
111
  require('@dynamic-labs/store');
112
112
  require('../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
113
113
 
114
+ const PUBLIC_LOGOUT_REASON = 'user-intent';
115
+ const STORAGE_PARSE_FAILURE_REASON = 'storage-parse-failure';
114
116
  const useHandleLogout = (params) => {
115
117
  const paramsRef = React.useRef(params);
116
118
  paramsRef.current = params;
@@ -124,8 +126,9 @@ const useHandleLogout = (params) => {
124
126
  ];
125
127
  logger.logger.logVerboseTroubleshootingMessage('useHandleLogout called', {
126
128
  params: paramsRef.current,
129
+ reason,
127
130
  });
128
- utils.tracing.logEvent('logout', 'useHandleLogout called');
131
+ utils.tracing.logEvent('logout', `useHandleLogout called (reason=${reason})`);
129
132
  p.setSelectedWalletConnectorKey(null);
130
133
  p.clearAllWalletConnectSessions();
131
134
  p.setShowDynamicUserProfile(false);
@@ -149,13 +152,23 @@ const useHandleLogout = (params) => {
149
152
  primaryWalletId.resetPrimaryWalletId();
150
153
  p.removeConnectedNameService();
151
154
  p.removeSessionStorageSessionKeys();
152
- yield Promise.all(activeConnectors.map((connector) => connector.endSession(reason)));
155
+ yield Promise.all(
156
+ // Narrow to the client-SDK LogoutReason at the connector boundary. SDK-invented
157
+ // reasons flow through untyped; connectors ignore values they don't recognize.
158
+ activeConnectors.map((connector) => connector.endSession(reason)));
153
159
  }), []);
154
- const logout = React.useCallback((reason) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
155
- yield client.logout();
160
+ const handleLogOutWithReason = React.useCallback((reason) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
161
+ if (typeof reason !== 'string') {
162
+ throw new Error('Invalid reason');
163
+ }
164
+ // Cast to LogoutReason here — this is the one place unsound widening meets
165
+ // the client SDK's narrow union. The client SDK forwards the string to
166
+ // Datadog as-is; unknown values are logged, not parsed.
167
+ yield core.logoutWithReason({ reason: reason }, client.getDynamicClient());
156
168
  yield logoutReactSdk(reason);
157
169
  }), [logoutReactSdk]);
158
- React.useEffect(() => client.onEvent({
170
+ const handleLogOut = React.useCallback(() => handleLogOutWithReason(PUBLIC_LOGOUT_REASON), [handleLogOutWithReason]);
171
+ React.useEffect(() => client$1.onEvent({
159
172
  event: 'logout',
160
173
  listener: (metadata) => {
161
174
  logoutReactSdk(metadata === null || metadata === void 0 ? void 0 : metadata.reason);
@@ -163,15 +176,15 @@ const useHandleLogout = (params) => {
163
176
  }), [logoutReactSdk]);
164
177
  /** Trigger a logout when the SDK failed to load data from storage */
165
178
  React.useEffect(() => {
166
- const handler = () => logout();
179
+ const handler = () => handleLogOutWithReason(STORAGE_PARSE_FAILURE_REASON);
167
180
  utils.StorageService.events.on('parseFailure', handler);
168
181
  return () => {
169
182
  utils.StorageService.events.off('parseFailure', handler);
170
183
  };
171
- }, [logout]);
184
+ }, [handleLogOutWithReason]);
172
185
  /** Allows triggering a logout from anywhere in the code */
173
- useDynamicEvents.useInternalDynamicEvents('triggerLogout', () => logout());
174
- return logout;
186
+ useDynamicEvents.useInternalDynamicEvents('triggerLogout', (reason) => handleLogOutWithReason(reason));
187
+ return { handleLogOut, handleLogOutWithReason };
175
188
  };
176
189
 
177
190
  exports.useHandleLogout = useHandleLogout;
@@ -1,3 +1,5 @@
1
- import { LogoutReason } from '@dynamic-labs-sdk/client';
2
- import { UseHandleLogoutParams } from './types';
3
- export declare const useHandleLogout: (params: UseHandleLogoutParams) => (reason?: LogoutReason) => Promise<void>;
1
+ import { SdkLogoutReason, UseHandleLogoutParams } from './types';
2
+ export declare const useHandleLogout: (params: UseHandleLogoutParams) => {
3
+ handleLogOut: () => Promise<void>;
4
+ handleLogOutWithReason: (reason: SdkLogoutReason) => Promise<void>;
5
+ };
@@ -1,7 +1,8 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../../_virtual/_tslib.js';
3
3
  import { useRef, useCallback, useEffect } from 'react';
4
- import { logout, onEvent } from '@dynamic-labs-sdk/client';
4
+ import { onEvent } from '@dynamic-labs-sdk/client';
5
+ import { logoutWithReason } from '@dynamic-labs-sdk/client/core';
5
6
  import { tracing, StorageService } from '@dynamic-labs/utils';
6
7
  import '@dynamic-labs/iconic';
7
8
  import '@dynamic-labs/wallet-connector-core';
@@ -25,8 +26,7 @@ import '../../../ErrorContext/ErrorContext.js';
25
26
  import '@dynamic-labs/multi-wallet';
26
27
  import 'react-international-phone';
27
28
  import '../../../../store/state/nonce/nonce.js';
28
- import '@dynamic-labs-sdk/client/core';
29
- import 'eventemitter3';
29
+ import { getDynamicClient } from '../../../../client/client.js';
30
30
  import '../../../../config/ApiEndpoint.js';
31
31
  import '../../../../events/dynamicEvents.js';
32
32
  import '@dynamic-labs/locale';
@@ -107,6 +107,8 @@ import '../../../../store/state/multichainBalances.js';
107
107
  import '@dynamic-labs/store';
108
108
  import '../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
109
109
 
110
+ const PUBLIC_LOGOUT_REASON = 'user-intent';
111
+ const STORAGE_PARSE_FAILURE_REASON = 'storage-parse-failure';
110
112
  const useHandleLogout = (params) => {
111
113
  const paramsRef = useRef(params);
112
114
  paramsRef.current = params;
@@ -120,8 +122,9 @@ const useHandleLogout = (params) => {
120
122
  ];
121
123
  logger.logVerboseTroubleshootingMessage('useHandleLogout called', {
122
124
  params: paramsRef.current,
125
+ reason,
123
126
  });
124
- tracing.logEvent('logout', 'useHandleLogout called');
127
+ tracing.logEvent('logout', `useHandleLogout called (reason=${reason})`);
125
128
  p.setSelectedWalletConnectorKey(null);
126
129
  p.clearAllWalletConnectSessions();
127
130
  p.setShowDynamicUserProfile(false);
@@ -145,12 +148,22 @@ const useHandleLogout = (params) => {
145
148
  resetPrimaryWalletId();
146
149
  p.removeConnectedNameService();
147
150
  p.removeSessionStorageSessionKeys();
148
- yield Promise.all(activeConnectors.map((connector) => connector.endSession(reason)));
151
+ yield Promise.all(
152
+ // Narrow to the client-SDK LogoutReason at the connector boundary. SDK-invented
153
+ // reasons flow through untyped; connectors ignore values they don't recognize.
154
+ activeConnectors.map((connector) => connector.endSession(reason)));
149
155
  }), []);
150
- const logout$1 = useCallback((reason) => __awaiter(void 0, void 0, void 0, function* () {
151
- yield logout();
156
+ const handleLogOutWithReason = useCallback((reason) => __awaiter(void 0, void 0, void 0, function* () {
157
+ if (typeof reason !== 'string') {
158
+ throw new Error('Invalid reason');
159
+ }
160
+ // Cast to LogoutReason here — this is the one place unsound widening meets
161
+ // the client SDK's narrow union. The client SDK forwards the string to
162
+ // Datadog as-is; unknown values are logged, not parsed.
163
+ yield logoutWithReason({ reason: reason }, getDynamicClient());
152
164
  yield logoutReactSdk(reason);
153
165
  }), [logoutReactSdk]);
166
+ const handleLogOut = useCallback(() => handleLogOutWithReason(PUBLIC_LOGOUT_REASON), [handleLogOutWithReason]);
154
167
  useEffect(() => onEvent({
155
168
  event: 'logout',
156
169
  listener: (metadata) => {
@@ -159,15 +172,15 @@ const useHandleLogout = (params) => {
159
172
  }), [logoutReactSdk]);
160
173
  /** Trigger a logout when the SDK failed to load data from storage */
161
174
  useEffect(() => {
162
- const handler = () => logout$1();
175
+ const handler = () => handleLogOutWithReason(STORAGE_PARSE_FAILURE_REASON);
163
176
  StorageService.events.on('parseFailure', handler);
164
177
  return () => {
165
178
  StorageService.events.off('parseFailure', handler);
166
179
  };
167
- }, [logout$1]);
180
+ }, [handleLogOutWithReason]);
168
181
  /** Allows triggering a logout from anywhere in the code */
169
- useInternalDynamicEvents('triggerLogout', () => logout$1());
170
- return logout$1;
182
+ useInternalDynamicEvents('triggerLogout', (reason) => handleLogOutWithReason(reason));
183
+ return { handleLogOut, handleLogOutWithReason };
171
184
  };
172
185
 
173
186
  export { useHandleLogout };
@@ -33,7 +33,7 @@ var wallets = require('../../../../data/api/wallets/wallets.cjs');
33
33
  var authMode = require('../../../../store/state/authMode/authMode.cjs');
34
34
  var UserWalletsContext = require('../../../UserWalletsContext/UserWalletsContext.cjs');
35
35
 
36
- const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, }) => {
36
+ const useRemoveWallet = ({ secondaryWallets, handleLogOutWithReason, setPrimaryWallet, }) => {
37
37
  const { removedWalletsIds, userWallets } = UserWalletsContext.useInternalUserWallets();
38
38
  const connectedWalletsInfo$1 = connectedWalletsInfo.useConnectedWalletsInfo();
39
39
  const nextWalletId = React.useMemo(() => (secondaryWallets[0] ? secondaryWallets[0].id : undefined), [secondaryWallets]);
@@ -74,7 +74,7 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, })
74
74
  }
75
75
  // If there are no wallets left and no user (connect-only), we need to log out
76
76
  if (!user && !nextWalletId) {
77
- handleLogOut();
77
+ yield handleLogOutWithReason('last-wallet-removed');
78
78
  return;
79
79
  }
80
80
  const numberOfWalletsWithSameConnector = userWallets.filter(({ connector }) => connector.key === wallet.connector.key).length;
@@ -88,7 +88,7 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, })
88
88
  nextWalletId,
89
89
  removedWalletsIds,
90
90
  setPrimaryWallet,
91
- handleLogOut,
91
+ handleLogOutWithReason,
92
92
  ]);
93
93
  return callback;
94
94
  };
@@ -1,7 +1,8 @@
1
1
  import { Wallet } from '../../../../shared/types/wallets';
2
+ import { SdkLogoutReason } from '../useHandleLogout';
2
3
  export type UseRemoveWalletProps = {
3
4
  secondaryWallets: Wallet[];
4
- handleLogOut: () => void;
5
+ handleLogOutWithReason: (reason: SdkLogoutReason) => Promise<void>;
5
6
  setPrimaryWallet: (walletId: string) => void;
6
7
  };
7
- export declare const useRemoveWallet: ({ secondaryWallets, handleLogOut, setPrimaryWallet, }: UseRemoveWalletProps) => (walletId: string, clearStackAndPushInitialView?: () => void) => Promise<void>;
8
+ export declare const useRemoveWallet: ({ secondaryWallets, handleLogOutWithReason, setPrimaryWallet, }: UseRemoveWalletProps) => (walletId: string, clearStackAndPushInitialView?: () => void) => Promise<void>;
@@ -29,7 +29,7 @@ import { unlinkWallet } from '../../../../data/api/wallets/wallets.js';
29
29
  import { getAuthMode } from '../../../../store/state/authMode/authMode.js';
30
30
  import { useInternalUserWallets } from '../../../UserWalletsContext/UserWalletsContext.js';
31
31
 
32
- const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, }) => {
32
+ const useRemoveWallet = ({ secondaryWallets, handleLogOutWithReason, setPrimaryWallet, }) => {
33
33
  const { removedWalletsIds, userWallets } = useInternalUserWallets();
34
34
  const connectedWalletsInfo = useConnectedWalletsInfo();
35
35
  const nextWalletId = useMemo(() => (secondaryWallets[0] ? secondaryWallets[0].id : undefined), [secondaryWallets]);
@@ -70,7 +70,7 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, })
70
70
  }
71
71
  // If there are no wallets left and no user (connect-only), we need to log out
72
72
  if (!user && !nextWalletId) {
73
- handleLogOut();
73
+ yield handleLogOutWithReason('last-wallet-removed');
74
74
  return;
75
75
  }
76
76
  const numberOfWalletsWithSameConnector = userWallets.filter(({ connector }) => connector.key === wallet.connector.key).length;
@@ -84,7 +84,7 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, })
84
84
  nextWalletId,
85
85
  removedWalletsIds,
86
86
  setPrimaryWallet,
87
- handleLogOut,
87
+ handleLogOutWithReason,
88
88
  ]);
89
89
  return callback;
90
90
  };
@@ -13,6 +13,7 @@ import { ConnectWalletOptions } from '../../../utils/hooks/useConnectWallet/useC
13
13
  import { ThemeData, ThemeSetting } from '../../ThemeContext';
14
14
  import { DisplayOrder, SetDisplayOrderPriority, SetShowAuthFlow } from '../hooks';
15
15
  import { SetCallbackType } from '../useCustomerCallbacks';
16
+ import { SdkLogoutReason } from '../hooks/useHandleLogout/types';
16
17
  import { SetSelectedWalletConnectorKey } from '../hooks/useSelectedWalletConnector/SetSelectedWalletConnectorKey.type';
17
18
  import { SettingsOverrides } from './SettingsOverrides';
18
19
  import { SocialSettings } from './SocialSettings';
@@ -64,6 +65,7 @@ export interface IDynamicContext {
64
65
  getConnectedWalletById: (walletId: string) => Wallet | undefined;
65
66
  getNameService: (address?: string) => Promise<NameServiceData | undefined>;
66
67
  handleLogOut: () => Promise<void>;
68
+ handleLogOutWithReason: (reason: SdkLogoutReason) => Promise<void>;
67
69
  removeWallet: (walletId: string, clearStackAndPushInitialView?: () => void) => Promise<void>;
68
70
  handlers?: DynamicHandlers;
69
71
  isBridgeFlow: boolean;
@@ -1,9 +1,16 @@
1
+ import { SdkLogoutReason } from '../hooks/useHandleLogout';
1
2
  import { IDynamicContext } from './IDynamicContext';
2
3
  /**
3
4
  * Allows deprecating specific methods that we should avoid using internally
4
5
  * without deprecating them publicly as well.
5
6
  */
6
- export type IInternalDynamicContext = Omit<IDynamicContext, 'user' | 'cspNonce' | 'cssOverrides' | 'accessDeniedButton' | 'accessDeniedMessagePrimary' | 'accessDeniedMessageSecondary' | 'appLogoUrl' | 'appName' | 'bridgeChains' | 'customPrivacyPolicy' | 'customTermsOfServices' | 'debugError' | 'defaultNumberOfWalletsToShow' | 'defaultPhoneInputIso2' | 'detectNewWalletsForLinking' | 'displaySiweStatement' | 'enableConnectOnlyFallback' | 'events' | 'handlers' | 'mobileExperience' | 'networkValidationMode' | 'newToWeb3WalletChainMap' | 'notInTheListImageUrl' | 'onboardingImageUrl' | 'overrides' | 'policiesConsentInnerComponent' | 'privacyPolicyUrl' | 'recommendedWallets' | 'redirectUrl' | 'shadowDOMEnabled' | 'showLockedWalletView' | 'siweStatement' | 'socialMediaIconUrl' | 'socialMediaLinkText' | 'socialMediaUrl' | 'socialProvidersFilter' | 'termsOfServiceUrl' | 'theme' | 'walletsFilter'> & {
7
+ export type IInternalDynamicContext = Omit<IDynamicContext, 'handleLogOut' | 'user' | 'cspNonce' | 'cssOverrides' | 'accessDeniedButton' | 'accessDeniedMessagePrimary' | 'accessDeniedMessageSecondary' | 'appLogoUrl' | 'appName' | 'bridgeChains' | 'customPrivacyPolicy' | 'customTermsOfServices' | 'debugError' | 'defaultNumberOfWalletsToShow' | 'defaultPhoneInputIso2' | 'detectNewWalletsForLinking' | 'displaySiweStatement' | 'enableConnectOnlyFallback' | 'events' | 'handlers' | 'mobileExperience' | 'networkValidationMode' | 'newToWeb3WalletChainMap' | 'notInTheListImageUrl' | 'onboardingImageUrl' | 'overrides' | 'policiesConsentInnerComponent' | 'privacyPolicyUrl' | 'recommendedWallets' | 'redirectUrl' | 'shadowDOMEnabled' | 'showLockedWalletView' | 'siweStatement' | 'socialMediaIconUrl' | 'socialMediaLinkText' | 'socialMediaUrl' | 'socialProvidersFilter' | 'termsOfServiceUrl' | 'theme' | 'walletsFilter'> & {
8
+ /**
9
+ * Reason-tagged logout for internal SDK call sites. Every internal logout
10
+ * must carry a reason so Datadog can attribute it. The no-arg public
11
+ * `handleLogOut` is intentionally omitted from this view.
12
+ */
13
+ handleLogOutWithReason: (reason: SdkLogoutReason) => Promise<void>;
7
14
  /**
8
15
  * @deprecated please call useOnboardingCompleteUser() OR useUser() instead.
9
16
  * | `useOnboardingCompleteUser` only returns the user if it's not missing KYC or MFA.
@@ -1,5 +1,6 @@
1
1
  import type { LogoutEventMetadata } from '@dynamic-labs-sdk/client';
2
2
  import { AuthEventPayload } from '@dynamic-labs/types';
3
+ import { SdkLogoutReason } from '../context/DynamicContext/hooks/useHandleLogout';
3
4
  export type AuthEvents = {
4
5
  /**
5
6
  * Informs an auth attempt failed.
@@ -15,7 +16,7 @@ export type AuthEvents = {
15
16
  authInit: (method: AuthEventPayload) => void;
16
17
  logout: (metadata?: LogoutEventMetadata) => void;
17
18
  /** This event is used to trigger logout to be called, DO NOT listen to it. Listen to "logout" instead */
18
- triggerLogout: () => void;
19
+ triggerLogout: (reason: SdkLogoutReason) => void;
19
20
  /**
20
21
  * Emitted when the user succesfully completes an MFA challenge
21
22
  */
@@ -113,7 +113,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
113
113
 
114
114
  const useDeleteUserAccount = () => {
115
115
  const environmentId = dynamicContextProps.useEnvironmentId();
116
- const { handleLogOut } = useInternalDynamicContext.useInternalDynamicContext();
116
+ const { handleLogOutWithReason } = useInternalDynamicContext.useInternalDynamicContext();
117
117
  const [isLoading, setIsLoading] = React.useState(false);
118
118
  const [error, setError] = React.useState(null);
119
119
  const deleteUser = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
@@ -121,7 +121,7 @@ const useDeleteUserAccount = () => {
121
121
  setIsLoading(true);
122
122
  setError(null);
123
123
  yield user.hardDeleteUser(environmentId);
124
- yield handleLogOut();
124
+ yield handleLogOutWithReason('user-deleted');
125
125
  }
126
126
  catch (err) {
127
127
  setError(err);
@@ -109,7 +109,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
109
109
 
110
110
  const useDeleteUserAccount = () => {
111
111
  const environmentId = useEnvironmentId();
112
- const { handleLogOut } = useInternalDynamicContext();
112
+ const { handleLogOutWithReason } = useInternalDynamicContext();
113
113
  const [isLoading, setIsLoading] = useState(false);
114
114
  const [error, setError] = useState(null);
115
115
  const deleteUser = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -117,7 +117,7 @@ const useDeleteUserAccount = () => {
117
117
  setIsLoading(true);
118
118
  setError(null);
119
119
  yield hardDeleteUser(environmentId);
120
- yield handleLogOut();
120
+ yield handleLogOutWithReason('user-deleted');
121
121
  }
122
122
  catch (err) {
123
123
  setError(err);