@dynamic-labs/sdk-react-core 4.70.0 → 4.72.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 (158) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/package.cjs +3 -3
  3. package/package.js +3 -3
  4. package/package.json +14 -14
  5. package/src/lib/client/extension/deprecated/mfa/verifyTotpMfaDevice/verifyTotpMfaDevice.d.ts +1 -1
  6. package/src/lib/client/extension/functions/generateChainingSignature/generateChainingSignature.cjs +15 -0
  7. package/src/lib/client/extension/functions/generateChainingSignature/generateChainingSignature.d.ts +1 -0
  8. package/src/lib/client/extension/functions/generateChainingSignature/generateChainingSignature.js +11 -0
  9. package/src/lib/client/extension/functions/generateSessionKeys/generateSessionKeys.cjs +11 -0
  10. package/src/lib/client/extension/functions/generateSessionKeys/generateSessionKeys.d.ts +1 -0
  11. package/src/lib/client/extension/functions/generateSessionKeys/generateSessionKeys.js +7 -0
  12. package/src/lib/client/extension/functions/getClientSessionNonceHeaders/getClientSessionNonceHeaders.cjs +33 -0
  13. package/src/lib/client/extension/functions/getClientSessionNonceHeaders/getClientSessionNonceHeaders.d.ts +16 -0
  14. package/src/lib/client/extension/functions/getClientSessionNonceHeaders/getClientSessionNonceHeaders.js +29 -0
  15. package/src/lib/client/extension/functions/getSessionKeys/getSessionKeys.d.ts +1 -0
  16. package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.cjs +5 -9
  17. package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.d.ts +4 -0
  18. package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.js +6 -10
  19. package/src/lib/client/extension/functions/migrateClientSessionKey/migrateClientSessionKey.cjs +51 -0
  20. package/src/lib/client/extension/functions/migrateClientSessionKey/migrateClientSessionKey.d.ts +1 -0
  21. package/src/lib/client/extension/functions/migrateClientSessionKey/migrateClientSessionKey.js +47 -0
  22. package/src/lib/client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.cjs +5 -6
  23. package/src/lib/client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.js +5 -6
  24. package/src/lib/client/extension/hooks/useInitializeSdkClient/syncEvents/syncEvents.cjs +12 -0
  25. package/src/lib/client/extension/hooks/useInitializeSdkClient/syncEvents/syncEvents.js +12 -0
  26. package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.cjs +2 -0
  27. package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.js +2 -0
  28. package/src/lib/client/extension/index.d.ts +4 -0
  29. package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +15 -2
  30. package/src/lib/components/SendBalanceForm/SendBalanceForm.d.ts +4 -0
  31. package/src/lib/components/SendBalanceForm/SendBalanceForm.js +15 -2
  32. package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +25 -3
  33. package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +26 -4
  34. package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.cjs +4 -1
  35. package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.js +4 -1
  36. package/src/lib/components/TransactionCard/SendBalanceTransactionCard.cjs +9 -5
  37. package/src/lib/components/TransactionCard/SendBalanceTransactionCard.js +9 -5
  38. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +2 -2
  39. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +2 -2
  40. package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +2 -2
  41. package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +2 -2
  42. package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +2 -2
  43. package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +2 -2
  44. package/src/lib/context/DynamicContext/DynamicContext.cjs +0 -3
  45. package/src/lib/context/DynamicContext/DynamicContext.js +0 -3
  46. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +3 -4
  47. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +3 -4
  48. package/src/lib/context/DynamicContext/types/DynamicContextProps.d.ts +10 -0
  49. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +0 -2
  50. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +0 -2
  51. package/src/lib/data/api/api.cjs +1 -1
  52. package/src/lib/data/api/api.js +1 -1
  53. package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +2 -4
  54. package/src/lib/data/api/embeddedWallets/embeddedWallets.js +2 -4
  55. package/src/lib/events/deviceRegistration.d.ts +4 -0
  56. package/src/lib/events/dynamicEvents.cjs +2 -0
  57. package/src/lib/events/dynamicEvents.d.ts +3 -2
  58. package/src/lib/events/dynamicEvents.js +2 -0
  59. package/src/lib/shared/utils/functions/chain/getChainIcon.cjs +1 -0
  60. package/src/lib/shared/utils/functions/chain/getChainIcon.js +2 -1
  61. package/src/lib/store/state/dynamicContextProps/defaultDynamicSettings.cjs +2 -0
  62. package/src/lib/store/state/dynamicContextProps/defaultDynamicSettings.d.ts +3 -3
  63. package/src/lib/store/state/dynamicContextProps/defaultDynamicSettings.js +2 -0
  64. package/src/lib/styles/index.shadow.cjs +1 -1
  65. package/src/lib/styles/index.shadow.js +1 -1
  66. package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.cjs +0 -88
  67. package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.d.ts +0 -25
  68. package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.js +2 -83
  69. package/src/lib/utils/functions/compareChains/compareChains.cjs +1 -0
  70. package/src/lib/utils/functions/compareChains/compareChains.js +1 -0
  71. package/src/lib/utils/functions/index.d.ts +0 -1
  72. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +0 -2
  73. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +0 -2
  74. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +0 -2
  75. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +0 -2
  76. package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +0 -2
  77. package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +0 -2
  78. package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +2 -2
  79. package/src/lib/utils/hooks/index.d.ts +0 -1
  80. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +4 -12
  81. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +4 -12
  82. package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +1 -1
  83. package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +1 -1
  84. package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.cjs +28 -36
  85. package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.d.ts +5 -2
  86. package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.js +29 -37
  87. package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs +7 -2
  88. package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.d.ts +2 -1
  89. package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js +7 -2
  90. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +2 -3
  91. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +2 -3
  92. package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.cjs +14 -14
  93. package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.js +14 -14
  94. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +3 -3
  95. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +3 -3
  96. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.cjs +14 -38
  97. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.js +14 -38
  98. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.types.d.ts +3 -2
  99. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptMfa.cjs +4 -1
  100. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptMfa.js +4 -1
  101. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptReauth.cjs +22 -6
  102. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptReauth.js +22 -6
  103. package/src/lib/utils/hooks/useSyncDeviceRegistrationFlow/useSyncDeviceRegistrationFlow.cjs +5 -1
  104. package/src/lib/utils/hooks/useSyncDeviceRegistrationFlow/useSyncDeviceRegistrationFlow.js +5 -1
  105. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +0 -2
  106. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +0 -2
  107. package/src/lib/views/BridgeSummaryView/BridgeSummaryView.cjs +1 -1
  108. package/src/lib/views/BridgeSummaryView/BridgeSummaryView.js +1 -1
  109. package/src/lib/views/EmailVerification/EmailVerification.cjs +2 -2
  110. package/src/lib/views/EmailVerification/EmailVerification.js +2 -2
  111. package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +2 -2
  112. package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +2 -2
  113. package/src/lib/views/StepUpReauthOtpView/StepUpReauthOtpView.cjs +1 -109
  114. package/src/lib/views/StepUpReauthOtpView/StepUpReauthOtpView.js +1 -109
  115. package/src/lib/views/StepUpReauthSocialView/StepUpReauthSocialView.cjs +1 -2
  116. package/src/lib/views/StepUpReauthSocialView/StepUpReauthSocialView.js +1 -2
  117. package/src/lib/views/StepUpReauthWalletView/StepUpReauthWalletView.cjs +2 -96
  118. package/src/lib/views/StepUpReauthWalletView/StepUpReauthWalletView.js +2 -96
  119. package/src/lib/views/WalletList/data.cjs +1 -0
  120. package/src/lib/views/WalletList/data.d.ts +1 -1
  121. package/src/lib/views/WalletList/data.js +1 -0
  122. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.cjs +2 -2
  123. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.d.ts +1 -0
  124. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.js +2 -2
  125. package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.cjs +1 -1
  126. package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.js +1 -1
  127. package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs +1 -1
  128. package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js +1 -1
  129. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +9 -1
  130. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +9 -1
  131. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.cjs +2 -1
  132. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.js +2 -1
  133. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +1 -1
  134. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +1 -1
  135. package/src/lib/widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.cjs +1 -1
  136. package/src/lib/widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js +1 -1
  137. package/src/lib/widgets/DynamicWidget/helpers/helpers.cjs +22 -0
  138. package/src/lib/widgets/DynamicWidget/helpers/helpers.js +22 -0
  139. package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.cjs +1 -1
  140. package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.js +1 -1
  141. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.cjs +60 -5
  142. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.js +61 -6
  143. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +12 -54
  144. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +12 -54
  145. package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +1 -1
  146. package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +1 -1
  147. package/src/lib/widgets/DynamicWidget/views/ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.cjs +1 -1
  148. package/src/lib/widgets/DynamicWidget/views/ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.js +1 -1
  149. package/src/lib/widgets/DynamicWidget/views/ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.cjs +2 -2
  150. package/src/lib/widgets/DynamicWidget/views/ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.js +2 -2
  151. package/src/lib/data/api/externalAuth/externalAuth.cjs +0 -66
  152. package/src/lib/data/api/externalAuth/externalAuth.js +0 -62
  153. package/src/lib/utils/functions/clientSessionKeys/constants.cjs +0 -8
  154. package/src/lib/utils/functions/clientSessionKeys/constants.js +0 -4
  155. package/src/lib/utils/hooks/useClientSessionKeys/index.d.ts +0 -1
  156. package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +0 -101
  157. package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.d.ts +0 -4
  158. package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +0 -97
@@ -67,6 +67,7 @@ import '../../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardT
67
67
  import '../../../../../context/WalletGroupContext/WalletGroupContext.js';
68
68
  import '../../DynamicWidgetHeader/DynamicWidgetHeader.js';
69
69
  import 'react-focus-lock';
70
+ import { roundBalance } from '../../../helpers/helpers.js';
70
71
  import '../../../context/DynamicWidgetContext.js';
71
72
  import '../../../../../components/IconButton/IconButton.js';
72
73
  import '../../../../../utils/hooks/useGetMfaToken/useGetMfaToken.js';
@@ -122,7 +123,7 @@ const TokenBalanceItem = ({ tokenBalance, }) => {
122
123
  ? currencyFormatter.format(parseFloat((_a = tokenBalance.marketValue) === null || _a === void 0 ? void 0 : _a.toFixed(2)))
123
124
  : '<$0.01';
124
125
  };
125
- return (jsxs("div", { className: 'token-balance-item', children: [jsxs("div", { className: 'token-balance-item__name', children: [tokenBalance.logoURI ? (jsx(Image, { src: tokenBalance.logoURI, alt: tokenBalance.symbol, className: 'token-balance-item__icon', dataTestId: 'token-balance-item-icon' })) : (jsx("div", { className: 'token-balance-item__skeleton-icon', "data-testid": 'token-balance-item__skeleton-icon' })), jsx("div", { children: jsx(Typography, { variant: 'body_small', className: 'token-balance-item__title', color: 'primary', children: tokenBalance.name }) })] }), jsxs("div", { className: 'flex', children: [showFiat ? (jsx(Typography, { variant: 'body_small', weight: 'bold', color: 'primary', style: { textAlign: 'right' }, children: formattedFiatValue() })) : null, jsx("div", { className: 'token-balance-item__value', children: jsxs("div", { className: 'token-balance-item__value__balance', "data-testid": 'token-balance-item-balance', children: [jsx(Typography, { variant: 'body_small', color: 'secondary', style: { marginRight: '2px' }, children: tokenBalance.balance }), jsx(Typography, { variant: 'body_small', color: 'secondary', className: 'token-balance-item__symbol', children: tokenBalance.symbol })] }) })] })] }, tokenBalance.address));
126
+ return (jsxs("div", { className: 'token-balance-item', children: [jsxs("div", { className: 'token-balance-item__name', children: [tokenBalance.logoURI ? (jsx(Image, { src: tokenBalance.logoURI, alt: tokenBalance.symbol, className: 'token-balance-item__icon', dataTestId: 'token-balance-item-icon' })) : (jsx("div", { className: 'token-balance-item__skeleton-icon', "data-testid": 'token-balance-item__skeleton-icon' })), jsx("div", { children: jsx(Typography, { variant: 'body_small', className: 'token-balance-item__title', color: 'primary', children: tokenBalance.name }) })] }), jsxs("div", { className: 'flex', children: [showFiat ? (jsx(Typography, { variant: 'body_small', weight: 'bold', color: 'primary', style: { textAlign: 'right' }, children: formattedFiatValue() })) : null, jsx("div", { className: 'token-balance-item__value', children: jsxs("div", { className: 'token-balance-item__value__balance', "data-testid": 'token-balance-item-balance', children: [jsx(Typography, { variant: 'body_small', color: 'secondary', style: { marginRight: '2px' }, children: roundBalance(String(tokenBalance.balance)) }), jsx(Typography, { variant: 'body_small', color: 'secondary', className: 'token-balance-item__symbol', children: tokenBalance.symbol })] }) })] })] }, tokenBalance.address));
126
127
  };
127
128
 
128
129
  export { TokenBalanceItem };
@@ -128,7 +128,7 @@ const DynamicWidgetWallets = () => {
128
128
  const isEmpty = secondaryWallets.length === 0;
129
129
  const addNewWallet = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
130
130
  if (authMode$1 === 'connect-and-sign' &&
131
- isStepUpRequired({ scope: sdkApiCore.TokenScope.Credentiallink })) {
131
+ (yield isStepUpRequired({ scope: sdkApiCore.TokenScope.Credentiallink }))) {
132
132
  try {
133
133
  yield promptStepUpAuth({
134
134
  requestedScopes: [sdkApiCore.TokenScope.Credentiallink],
@@ -124,7 +124,7 @@ const DynamicWidgetWallets = () => {
124
124
  const isEmpty = secondaryWallets.length === 0;
125
125
  const addNewWallet = () => __awaiter(void 0, void 0, void 0, function* () {
126
126
  if (authMode === 'connect-and-sign' &&
127
- isStepUpRequired({ scope: TokenScope.Credentiallink })) {
127
+ (yield isStepUpRequired({ scope: TokenScope.Credentiallink }))) {
128
128
  try {
129
129
  yield promptStepUpAuth({
130
130
  requestedScopes: [TokenScope.Credentiallink],
@@ -153,7 +153,7 @@ const PasskeyCard = ({ passkey, onUpdate }) => {
153
153
  {
154
154
  Icon: null,
155
155
  callback: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
156
- if (isStepUpRequired({ scope: PASSKEY_DELETE_SCOPE })) {
156
+ if (yield isStepUpRequired({ scope: PASSKEY_DELETE_SCOPE })) {
157
157
  try {
158
158
  yield promptStepUpAuth({ requestedScopes: [PASSKEY_DELETE_SCOPE] });
159
159
  }
@@ -149,7 +149,7 @@ const PasskeyCard = ({ passkey, onUpdate }) => {
149
149
  {
150
150
  Icon: null,
151
151
  callback: () => __awaiter(void 0, void 0, void 0, function* () {
152
- if (isStepUpRequired({ scope: PASSKEY_DELETE_SCOPE })) {
152
+ if (yield isStepUpRequired({ scope: PASSKEY_DELETE_SCOPE })) {
153
153
  try {
154
154
  yield promptStepUpAuth({ requestedScopes: [PASSKEY_DELETE_SCOPE] });
155
155
  }
@@ -32,6 +32,28 @@ const MAX_BALANCE_VALUE = 1000000;
32
32
  const PRECISION_FLOOR_DIVIDER = 10000;
33
33
  const roundBalance = (balanceString, decimals = 4) => {
34
34
  const clearedBalance = parseFloat(replaceAll(balanceString, '"', ''));
35
+ // Guard against NaN (e.g., when balance is undefined/null)
36
+ if (Number.isNaN(clearedBalance)) {
37
+ return '0';
38
+ }
39
+ // Handle extremely large numbers (e.g., scientific notation like 1e+24)
40
+ // These are likely data errors or testnet faucet amounts
41
+ if (clearedBalance >= 1e15) {
42
+ // For numbers >= 1 quadrillion, show in trillions
43
+ const trillions = clearedBalance / 1e12;
44
+ if (trillions >= 1000) {
45
+ return `${(trillions / 1000).toFixed(2)}Q`; // Quadrillions
46
+ }
47
+ return `${trillions.toFixed(2)}T`; // Trillions
48
+ }
49
+ if (clearedBalance >= 1e12) {
50
+ // Trillions
51
+ return `${(clearedBalance / 1e12).toFixed(2)}T`;
52
+ }
53
+ if (clearedBalance >= 1e9) {
54
+ // Billions
55
+ return `${(clearedBalance / 1e9).toFixed(2)}B`;
56
+ }
35
57
  if (clearedBalance > MAX_BALANCE_VALUE) {
36
58
  const dividedValue = Math.floor(clearedBalance);
37
59
  const roundedBalance = Math.floor((dividedValue / MAX_BALANCE_VALUE) * PRECISION_FLOOR_DIVIDER) /
@@ -28,6 +28,28 @@ const MAX_BALANCE_VALUE = 1000000;
28
28
  const PRECISION_FLOOR_DIVIDER = 10000;
29
29
  const roundBalance = (balanceString, decimals = 4) => {
30
30
  const clearedBalance = parseFloat(replaceAll(balanceString, '"', ''));
31
+ // Guard against NaN (e.g., when balance is undefined/null)
32
+ if (Number.isNaN(clearedBalance)) {
33
+ return '0';
34
+ }
35
+ // Handle extremely large numbers (e.g., scientific notation like 1e+24)
36
+ // These are likely data errors or testnet faucet amounts
37
+ if (clearedBalance >= 1e15) {
38
+ // For numbers >= 1 quadrillion, show in trillions
39
+ const trillions = clearedBalance / 1e12;
40
+ if (trillions >= 1000) {
41
+ return `${(trillions / 1000).toFixed(2)}Q`; // Quadrillions
42
+ }
43
+ return `${trillions.toFixed(2)}T`; // Trillions
44
+ }
45
+ if (clearedBalance >= 1e12) {
46
+ // Trillions
47
+ return `${(clearedBalance / 1e12).toFixed(2)}T`;
48
+ }
49
+ if (clearedBalance >= 1e9) {
50
+ // Billions
51
+ return `${(clearedBalance / 1e9).toFixed(2)}B`;
52
+ }
31
53
  if (clearedBalance > MAX_BALANCE_VALUE) {
32
54
  const dividedValue = Math.floor(clearedBalance);
33
55
  const roundedBalance = Math.floor((dividedValue / MAX_BALANCE_VALUE) * PRECISION_FLOOR_DIVIDER) /
@@ -130,7 +130,7 @@ const UnlinkWalletPopUpContent = ({ onClickCancel, }) => {
130
130
  try {
131
131
  setLoading(true);
132
132
  if (authMode$1 === 'connect-and-sign' &&
133
- isStepUpRequired({ scope: sdkApiCore.TokenScope.Credentialunlink })) {
133
+ (yield isStepUpRequired({ scope: sdkApiCore.TokenScope.Credentialunlink }))) {
134
134
  yield promptStepUpAuth({
135
135
  requestedScopes: [sdkApiCore.TokenScope.Credentialunlink],
136
136
  });
@@ -126,7 +126,7 @@ const UnlinkWalletPopUpContent = ({ onClickCancel, }) => {
126
126
  try {
127
127
  setLoading(true);
128
128
  if (authMode === 'connect-and-sign' &&
129
- isStepUpRequired({ scope: TokenScope.Credentialunlink })) {
129
+ (yield isStepUpRequired({ scope: TokenScope.Credentialunlink }))) {
130
130
  yield promptStepUpAuth({
131
131
  requestedScopes: [TokenScope.Credentialunlink],
132
132
  });
@@ -19,8 +19,9 @@ var backupArrow = require('../../../../../shared/assets/backupArrow.cjs');
19
19
  var chevronLeft = require('../../../../../shared/assets/chevron-left.cjs');
20
20
  var exportPrivateKey = require('../../../../../shared/assets/export-private-key.cjs');
21
21
  var exportRecoveryPhrase = require('../../../../../shared/assets/export-recovery-phrase.cjs');
22
+ var lock = require('../../../../../shared/assets/lock.cjs');
22
23
  var ViewContext = require('../../../../../context/ViewContext/ViewContext.cjs');
23
- require('../../../../../shared/logger.cjs');
24
+ var logger = require('../../../../../shared/logger.cjs');
24
25
  require('@dynamic-labs/wallet-book');
25
26
  require('@dynamic-labs/utils');
26
27
  require('../../../../../utils/constants/colors.cjs');
@@ -86,7 +87,7 @@ require('qrcode');
86
87
  require('formik');
87
88
  require('../../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
88
89
  require('../../../../../context/WalletGroupContext/WalletGroupContext.cjs');
89
- require('../../../context/DynamicWidgetContext.cjs');
90
+ var DynamicWidgetContext = require('../../../context/DynamicWidgetContext.cjs');
90
91
  require('../../../../../utils/hooks/useGetMfaToken/useGetMfaToken.cjs');
91
92
  var useWalletBackup = require('../../../../../utils/hooks/useWalletBackup/useWalletBackup.cjs');
92
93
  require('../../../../../utils/hooks/useWalletBackup/types.cjs');
@@ -102,6 +103,7 @@ require('../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs
102
103
  require('../../../../../context/FooterAnimationContext/index.cjs');
103
104
  require('../../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
104
105
  require('../../../../../context/PasskeyContext/PasskeyContext.cjs');
106
+ var useWalletPassword = require('../../../../../utils/hooks/useWalletPassword/useWalletPassword.cjs');
105
107
  require('../../../../../context/OnrampContext/OnrampContext.cjs');
106
108
  require('../../../../../store/state/sendBalances.cjs');
107
109
  require('../../../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
@@ -110,6 +112,7 @@ require('../../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
110
112
  require('../../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
111
113
  require('../../../components/PasskeyCard/PasskeyCard.cjs');
112
114
  var useEmbeddedReveal = require('../../../../../utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs');
115
+ var useIsPasswordEncrypted = require('../../../../../utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.cjs');
113
116
  require('../../CryptoComOnramp/CryptoComOnramp.cjs');
114
117
  require('../../../../../../index.cjs');
115
118
  require('../../ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.cjs');
@@ -118,18 +121,23 @@ require('../../ReceiveWalletFunds/ReceiveWalletFunds.cjs');
118
121
  require('../../../../../store/state/tokenBalances.cjs');
119
122
  require('../../../../../store/state/multichainBalances.cjs');
120
123
  require('../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
124
+ var useIsMfaRequiredForAction = require('../../../../../utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.cjs');
121
125
  var useInternalDynamicContext = require('../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
122
126
 
123
127
  const EmbeddedWalletExportSection = () => {
124
128
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
125
129
  const { t } = reactI18next.useTranslation();
126
130
  const { theme } = ThemeContext.useThemeContext();
131
+ const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
127
132
  const { primaryWallet, user, projectSettings, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
128
133
  const { pushView } = ViewContext.useViewContext();
129
134
  const { getEOAWallet } = useSmartWallets.useSmartWallets();
135
+ const { setPassword } = useWalletPassword.useWalletPassword();
136
+ const isPasswordEncrypted = useIsPasswordEncrypted.useIsPasswordEncrypted();
130
137
  const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery.usePasskeyRecovery();
131
138
  const { initExportProcess } = useEmbeddedReveal.useEmbeddedReveal();
132
- const { isStepUpRequired, promptStepUpAuth } = useStepUpAuthentication.useStepUpAuthentication();
139
+ const { isStepUpRequired, promptMfa, promptStepUpAuth } = useStepUpAuthentication.useStepUpAuthentication();
140
+ const isMfaRequiredForAction = useIsMfaRequiredForAction.useIsMfaRequiredForAction();
133
141
  const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
134
142
  const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
135
143
  const isEmbeddedWallet = Boolean(wallet &&
@@ -141,8 +149,34 @@ const EmbeddedWalletExportSection = () => {
141
149
  const isSessionKeyCompatible = (primaryWallet && walletConnectorCore.isSessionKeyCompatibleWallet(primaryWallet)) ||
142
150
  (eoaWallet && walletConnectorCore.isSessionKeyCompatibleWallet(eoaWallet));
143
151
  const isV3WaasWallet = Boolean(wallet && ((_h = (_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.key) === null || _h === void 0 ? void 0 : _h.startsWith('dynamicwaas')));
152
+ const shouldShowPasswordSetup = isV3WaasWallet;
153
+ const handlePasscodeClick = React.useCallback(() => {
154
+ setDynamicWidgetView('setup-password', {
155
+ onComplete: (password) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
156
+ if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
157
+ logger.logger.error('No wallet address or chain available for password setup');
158
+ return;
159
+ }
160
+ yield setPassword({
161
+ accountAddress: wallet.address,
162
+ chainName: wallet.chain,
163
+ newPassword: password,
164
+ });
165
+ }),
166
+ });
167
+ }, [setDynamicWidgetView, wallet, setPassword]);
168
+ const handleResetPasswordClick = React.useCallback(() => {
169
+ setShowAuthFlow(true, {
170
+ ignoreIfIsEmbeddedWidget: false,
171
+ performMultiWalletChecks: false,
172
+ });
173
+ pushView('reset-password-flow');
174
+ }, [setShowAuthFlow, pushView]);
144
175
  const handleExportClick = React.useCallback((recoveryPhrase) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
145
- if (isStepUpRequired({ scope: sdkApiCore.TokenScope.Walletexport })) {
176
+ const stepUpRequired = yield isStepUpRequired({
177
+ scope: sdkApiCore.TokenScope.Walletexport,
178
+ });
179
+ if (stepUpRequired) {
146
180
  try {
147
181
  yield promptStepUpAuth({
148
182
  requestedScopes: [sdkApiCore.TokenScope.Walletexport],
@@ -152,6 +186,19 @@ const EmbeddedWalletExportSection = () => {
152
186
  return;
153
187
  }
154
188
  }
189
+ else {
190
+ const isMfaRequired = yield isMfaRequiredForAction({
191
+ mfaAction: sdkApiCore.MFAAction.WalletWaasExport,
192
+ });
193
+ if (isMfaRequired) {
194
+ try {
195
+ yield promptMfa({ createMfaToken: true });
196
+ }
197
+ catch (_m) {
198
+ return;
199
+ }
200
+ }
201
+ }
155
202
  if (!isSessionKeyCompatible) {
156
203
  if (yield shouldInitRecovery()) {
157
204
  yield initPasskeyRecoveryProcess(undefined, {
@@ -163,6 +210,8 @@ const EmbeddedWalletExportSection = () => {
163
210
  }), [
164
211
  isStepUpRequired,
165
212
  promptStepUpAuth,
213
+ isMfaRequiredForAction,
214
+ promptMfa,
166
215
  shouldInitRecovery,
167
216
  initPasskeyRecoveryProcess,
168
217
  initExportProcess,
@@ -194,7 +243,13 @@ const EmbeddedWalletExportSection = () => {
194
243
  if (!isEmbeddedWallet) {
195
244
  return null;
196
245
  }
197
- return (jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [jsxRuntime.jsx("div", { className: 'settings-view__body__section__title', children: jsxRuntime.jsx(Typography.Typography, { copykey: 'dyn_settings.export_section.title', color: 'secondary', weight: 'medium', children: t('dyn_settings.export_section.title') }) }), jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'embedded-reveal-account-button', onClick: handleExportButtonClick, buttonClassName: 'settings-view__body__section__button', startSlot: exportButtonStartSlot, endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }), isTurnkeyHDWallet && !isV3WaasWallet && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'embedded-reveal-button', onClick: handleExportWithPhraseClick, buttonClassName: 'settings-view__body__section__button', startSlot: recoveryPhraseButtonStartSlot, endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), shouldShowBackupOption && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'backup-button', onClick: handleBackupClick, buttonClassName: 'settings-view__body__section__button', startSlot:
246
+ return (jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [jsxRuntime.jsx("div", { className: 'settings-view__body__section__title', children: jsxRuntime.jsx(Typography.Typography, { copykey: 'dyn_settings.wallet_security_section.title', color: 'secondary', weight: 'medium', children: t('dyn_settings.wallet_security_section.title') }) }), shouldShowPasswordSetup && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'password-setup-button', onClick: isPasswordEncrypted ? handleResetPasswordClick : handlePasscodeClick, buttonClassName: 'settings-view__body__section__button', startSlot:
247
+ // eslint-disable-next-line react/jsx-wrap-multilines
248
+ jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(lock.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: isPasswordEncrypted
249
+ ? 'dyn_settings.account_security.password.reset_button'
250
+ : 'dyn_settings.account_security.password.set_button', children: isPasswordEncrypted
251
+ ? t('dyn_settings.account_security.password.reset_button')
252
+ : t('dyn_settings.account_security.password.set_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'embedded-reveal-account-button', onClick: handleExportButtonClick, buttonClassName: 'settings-view__body__section__button', startSlot: exportButtonStartSlot, endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }), isTurnkeyHDWallet && !isV3WaasWallet && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'embedded-reveal-button', onClick: handleExportWithPhraseClick, buttonClassName: 'settings-view__body__section__button', startSlot: recoveryPhraseButtonStartSlot, endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), shouldShowBackupOption && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'backup-button', onClick: handleBackupClick, buttonClassName: 'settings-view__body__section__button', startSlot:
198
253
  // eslint-disable-next-line react/jsx-wrap-multilines
199
254
  jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(backupArrow.ReactComponent, { className: exportIconClasses }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.backup_button', children: t('dyn_settings.export_section.backup_button') })] }), endSlot: areAllWalletsBackedUp ? (jsxRuntime.jsx(Badge.Badge, { variant: 'primary', text: t('dyn_waas.backup.backed_up'), copykey: 'dyn_waas.backup.backed_up' })) : (jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' })), showInternalLoading: false }))] }));
200
255
  };
@@ -3,7 +3,7 @@ import { __awaiter } from '../../../../../../../_virtual/_tslib.js';
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { useCallback, useMemo } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
- import { TokenScope, WaasBackupOptionsEnum } from '@dynamic-labs/sdk-api-core';
6
+ import { TokenScope, MFAAction, WaasBackupOptionsEnum } from '@dynamic-labs/sdk-api-core';
7
7
  import { isSessionKeyCompatibleWallet } from '@dynamic-labs/wallet-connector-core';
8
8
  import { Badge } from '../../../../../components/Badge/Badge.js';
9
9
  import { Typography } from '../../../../../components/Typography/Typography.js';
@@ -15,8 +15,9 @@ import { ReactComponent as SvgBackupArrow } from '../../../../../shared/assets/b
15
15
  import { ReactComponent as SvgChevronLeft } from '../../../../../shared/assets/chevron-left.js';
16
16
  import { ReactComponent as SvgExportPrivateKey } from '../../../../../shared/assets/export-private-key.js';
17
17
  import { ReactComponent as SvgExportRecoveryPhrase } from '../../../../../shared/assets/export-recovery-phrase.js';
18
+ import { ReactComponent as SvgLock } from '../../../../../shared/assets/lock.js';
18
19
  import { useViewContext } from '../../../../../context/ViewContext/ViewContext.js';
19
- import '../../../../../shared/logger.js';
20
+ import { logger } from '../../../../../shared/logger.js';
20
21
  import '@dynamic-labs/wallet-book';
21
22
  import '@dynamic-labs/utils';
22
23
  import '../../../../../utils/constants/colors.js';
@@ -82,7 +83,7 @@ import 'qrcode';
82
83
  import 'formik';
83
84
  import '../../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
84
85
  import '../../../../../context/WalletGroupContext/WalletGroupContext.js';
85
- import '../../../context/DynamicWidgetContext.js';
86
+ import { useWidgetContext } from '../../../context/DynamicWidgetContext.js';
86
87
  import '../../../../../utils/hooks/useGetMfaToken/useGetMfaToken.js';
87
88
  import { useWalletBackup } from '../../../../../utils/hooks/useWalletBackup/useWalletBackup.js';
88
89
  import '../../../../../utils/hooks/useWalletBackup/types.js';
@@ -98,6 +99,7 @@ import '../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
98
99
  import '../../../../../context/FooterAnimationContext/index.js';
99
100
  import '../../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
100
101
  import '../../../../../context/PasskeyContext/PasskeyContext.js';
102
+ import { useWalletPassword } from '../../../../../utils/hooks/useWalletPassword/useWalletPassword.js';
101
103
  import '../../../../../context/OnrampContext/OnrampContext.js';
102
104
  import '../../../../../store/state/sendBalances.js';
103
105
  import '../../../../../store/state/connectorsInitializing/connectorsInitializing.js';
@@ -106,6 +108,7 @@ import '../../../components/DynamicWidgetHeader/DynamicWidgetHeader.js';
106
108
  import '../../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
107
109
  import '../../../components/PasskeyCard/PasskeyCard.js';
108
110
  import { useEmbeddedReveal } from '../../../../../utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js';
111
+ import { useIsPasswordEncrypted } from '../../../../../utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.js';
109
112
  import '../../CryptoComOnramp/CryptoComOnramp.js';
110
113
  import '../../../../../../index.js';
111
114
  import '../../ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.js';
@@ -114,18 +117,23 @@ import '../../ReceiveWalletFunds/ReceiveWalletFunds.js';
114
117
  import '../../../../../store/state/tokenBalances.js';
115
118
  import '../../../../../store/state/multichainBalances.js';
116
119
  import '../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
120
+ import { useIsMfaRequiredForAction } from '../../../../../utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.js';
117
121
  import { useInternalDynamicContext } from '../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
118
122
 
119
123
  const EmbeddedWalletExportSection = () => {
120
124
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
121
125
  const { t } = useTranslation();
122
126
  const { theme } = useThemeContext();
127
+ const { setDynamicWidgetView } = useWidgetContext();
123
128
  const { primaryWallet, user, projectSettings, setShowAuthFlow } = useInternalDynamicContext();
124
129
  const { pushView } = useViewContext();
125
130
  const { getEOAWallet } = useSmartWallets();
131
+ const { setPassword } = useWalletPassword();
132
+ const isPasswordEncrypted = useIsPasswordEncrypted();
126
133
  const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery();
127
134
  const { initExportProcess } = useEmbeddedReveal();
128
- const { isStepUpRequired, promptStepUpAuth } = useStepUpAuthentication();
135
+ const { isStepUpRequired, promptMfa, promptStepUpAuth } = useStepUpAuthentication();
136
+ const isMfaRequiredForAction = useIsMfaRequiredForAction();
129
137
  const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
130
138
  const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
131
139
  const isEmbeddedWallet = Boolean(wallet &&
@@ -137,8 +145,34 @@ const EmbeddedWalletExportSection = () => {
137
145
  const isSessionKeyCompatible = (primaryWallet && isSessionKeyCompatibleWallet(primaryWallet)) ||
138
146
  (eoaWallet && isSessionKeyCompatibleWallet(eoaWallet));
139
147
  const isV3WaasWallet = Boolean(wallet && ((_h = (_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.key) === null || _h === void 0 ? void 0 : _h.startsWith('dynamicwaas')));
148
+ const shouldShowPasswordSetup = isV3WaasWallet;
149
+ const handlePasscodeClick = useCallback(() => {
150
+ setDynamicWidgetView('setup-password', {
151
+ onComplete: (password) => __awaiter(void 0, void 0, void 0, function* () {
152
+ if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
153
+ logger.error('No wallet address or chain available for password setup');
154
+ return;
155
+ }
156
+ yield setPassword({
157
+ accountAddress: wallet.address,
158
+ chainName: wallet.chain,
159
+ newPassword: password,
160
+ });
161
+ }),
162
+ });
163
+ }, [setDynamicWidgetView, wallet, setPassword]);
164
+ const handleResetPasswordClick = useCallback(() => {
165
+ setShowAuthFlow(true, {
166
+ ignoreIfIsEmbeddedWidget: false,
167
+ performMultiWalletChecks: false,
168
+ });
169
+ pushView('reset-password-flow');
170
+ }, [setShowAuthFlow, pushView]);
140
171
  const handleExportClick = useCallback((recoveryPhrase) => __awaiter(void 0, void 0, void 0, function* () {
141
- if (isStepUpRequired({ scope: TokenScope.Walletexport })) {
172
+ const stepUpRequired = yield isStepUpRequired({
173
+ scope: TokenScope.Walletexport,
174
+ });
175
+ if (stepUpRequired) {
142
176
  try {
143
177
  yield promptStepUpAuth({
144
178
  requestedScopes: [TokenScope.Walletexport],
@@ -148,6 +182,19 @@ const EmbeddedWalletExportSection = () => {
148
182
  return;
149
183
  }
150
184
  }
185
+ else {
186
+ const isMfaRequired = yield isMfaRequiredForAction({
187
+ mfaAction: MFAAction.WalletWaasExport,
188
+ });
189
+ if (isMfaRequired) {
190
+ try {
191
+ yield promptMfa({ createMfaToken: true });
192
+ }
193
+ catch (_m) {
194
+ return;
195
+ }
196
+ }
197
+ }
151
198
  if (!isSessionKeyCompatible) {
152
199
  if (yield shouldInitRecovery()) {
153
200
  yield initPasskeyRecoveryProcess(undefined, {
@@ -159,6 +206,8 @@ const EmbeddedWalletExportSection = () => {
159
206
  }), [
160
207
  isStepUpRequired,
161
208
  promptStepUpAuth,
209
+ isMfaRequiredForAction,
210
+ promptMfa,
162
211
  shouldInitRecovery,
163
212
  initPasskeyRecoveryProcess,
164
213
  initExportProcess,
@@ -190,7 +239,13 @@ const EmbeddedWalletExportSection = () => {
190
239
  if (!isEmbeddedWallet) {
191
240
  return null;
192
241
  }
193
- return (jsxs("div", { className: 'settings-view__body__section', children: [jsx("div", { className: 'settings-view__body__section__title', children: jsx(Typography, { copykey: 'dyn_settings.export_section.title', color: 'secondary', weight: 'medium', children: t('dyn_settings.export_section.title') }) }), jsx(TypographyButton, { dataTestId: 'embedded-reveal-account-button', onClick: handleExportButtonClick, buttonClassName: 'settings-view__body__section__button', startSlot: exportButtonStartSlot, endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }), isTurnkeyHDWallet && !isV3WaasWallet && (jsx(TypographyButton, { dataTestId: 'embedded-reveal-button', onClick: handleExportWithPhraseClick, buttonClassName: 'settings-view__body__section__button', startSlot: recoveryPhraseButtonStartSlot, endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), shouldShowBackupOption && (jsx(TypographyButton, { dataTestId: 'backup-button', onClick: handleBackupClick, buttonClassName: 'settings-view__body__section__button', startSlot:
242
+ return (jsxs("div", { className: 'settings-view__body__section', children: [jsx("div", { className: 'settings-view__body__section__title', children: jsx(Typography, { copykey: 'dyn_settings.wallet_security_section.title', color: 'secondary', weight: 'medium', children: t('dyn_settings.wallet_security_section.title') }) }), shouldShowPasswordSetup && (jsx(TypographyButton, { dataTestId: 'password-setup-button', onClick: isPasswordEncrypted ? handleResetPasswordClick : handlePasscodeClick, buttonClassName: 'settings-view__body__section__button', startSlot:
243
+ // eslint-disable-next-line react/jsx-wrap-multilines
244
+ jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgLock, { className: 'settings-view__body__section__button__icon' }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: isPasswordEncrypted
245
+ ? 'dyn_settings.account_security.password.reset_button'
246
+ : 'dyn_settings.account_security.password.set_button', children: isPasswordEncrypted
247
+ ? t('dyn_settings.account_security.password.reset_button')
248
+ : t('dyn_settings.account_security.password.set_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), jsx(TypographyButton, { dataTestId: 'embedded-reveal-account-button', onClick: handleExportButtonClick, buttonClassName: 'settings-view__body__section__button', startSlot: exportButtonStartSlot, endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }), isTurnkeyHDWallet && !isV3WaasWallet && (jsx(TypographyButton, { dataTestId: 'embedded-reveal-button', onClick: handleExportWithPhraseClick, buttonClassName: 'settings-view__body__section__button', startSlot: recoveryPhraseButtonStartSlot, endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), shouldShowBackupOption && (jsx(TypographyButton, { dataTestId: 'backup-button', onClick: handleBackupClick, buttonClassName: 'settings-view__body__section__button', startSlot:
194
249
  // eslint-disable-next-line react/jsx-wrap-multilines
195
250
  jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgBackupArrow, { className: exportIconClasses }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.backup_button', children: t('dyn_settings.export_section.backup_button') })] }), endSlot: areAllWalletsBackedUp ? (jsx(Badge, { variant: 'primary', text: t('dyn_waas.backup.backed_up'), copykey: 'dyn_waas.backup.backed_up' })) : (jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' })), showInternalLoading: false }))] }));
196
251
  };
@@ -3,28 +3,29 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var _tslib = require('../../../../../../../_virtual/_tslib.cjs');
7
6
  var jsxRuntime = require('react/jsx-runtime');
8
7
  var React = require('react');
9
8
  var reactI18next = require('react-i18next');
10
9
  var Typography = require('../../../../../components/Typography/Typography.cjs');
11
10
  var TypographyButton = require('../../../../../components/TypographyButton/TypographyButton.cjs');
12
- require('../../../../../context/DynamicContext/DynamicContext.cjs');
13
- require('../../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
14
- require('@dynamic-labs/iconic');
15
- require('@dynamic-labs/wallet-connector-core');
16
11
  var chevronLeft = require('../../../../../shared/assets/chevron-left.cjs');
17
12
  var faceId = require('../../../../../shared/assets/face-id.cjs');
18
13
  var lock = require('../../../../../shared/assets/lock.cjs');
19
- var ViewContext = require('../../../../../context/ViewContext/ViewContext.cjs');
20
- var logger = require('../../../../../shared/logger.cjs');
21
- require('@dynamic-labs/wallet-book');
14
+ require('@dynamic-labs/iconic');
15
+ require('../../../../../context/ViewContext/ViewContext.cjs');
16
+ require('../../../../../events/dynamicEvents.cjs');
17
+ require('../../../../../../../_virtual/_tslib.cjs');
22
18
  require('@dynamic-labs/utils');
19
+ require('../../../../../context/DynamicContext/DynamicContext.cjs');
20
+ require('../../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
21
+ require('@dynamic-labs/wallet-connector-core');
22
+ require('../../../../../shared/logger.cjs');
23
+ require('@dynamic-labs/wallet-book');
23
24
  require('../../../../../utils/constants/colors.cjs');
24
25
  require('../../../../../utils/constants/values.cjs');
25
26
  require('@dynamic-labs/sdk-api-core');
26
27
  require('../../../../../shared/consts/index.cjs');
27
- require('../../../../../events/dynamicEvents.cjs');
28
+ require('../../../../../store/state/authMode/authMode.cjs');
28
29
  require('../../../../../context/CaptchaContext/CaptchaContext.cjs');
29
30
  require('../../../../../context/ErrorContext/ErrorContext.cjs');
30
31
  require('@dynamic-labs/multi-wallet');
@@ -42,13 +43,11 @@ require('../../../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTy
42
43
  require('../../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
43
44
  require('../../../../../context/AccountExistsContext/AccountExistsContext.cjs');
44
45
  require('../../../../../context/UserWalletsContext/UserWalletsContext.cjs');
45
- require('../../../../../store/state/authMode/authMode.cjs');
46
46
  require('../../../../../context/VerificationContext/VerificationContext.cjs');
47
47
  require('react-dom');
48
48
  require('../../../../../utils/functions/compareChains/compareChains.cjs');
49
49
  require('../../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
50
50
  require('../../../../../context/ThemeContext/ThemeContext.cjs');
51
- var useSmartWallets = require('../../../../../utils/hooks/useSmartWallets/useSmartWallets.cjs');
52
51
  require('../../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
53
52
  require('bs58');
54
53
  require('@dynamic-labs/types');
@@ -98,7 +97,6 @@ require('../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs
98
97
  require('../../../../../context/FooterAnimationContext/index.cjs');
99
98
  require('../../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
100
99
  require('../../../../../context/PasskeyContext/PasskeyContext.cjs');
101
- var useWalletPassword = require('../../../../../utils/hooks/useWalletPassword/useWalletPassword.cjs');
102
100
  require('../../../../../context/OnrampContext/OnrampContext.cjs');
103
101
  require('../../../../../store/state/sendBalances.cjs');
104
102
  require('../../../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
@@ -106,7 +104,6 @@ require('../../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCard
106
104
  require('../../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
107
105
  require('../../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
108
106
  require('../../../components/PasskeyCard/PasskeyCard.cjs');
109
- var useIsPasswordEncrypted = require('../../../../../utils/hooks/useIsPasswordEncrypted/useIsPasswordEncrypted.cjs');
110
107
  require('../../CryptoComOnramp/CryptoComOnramp.cjs');
111
108
  require('../../../../../../index.cjs');
112
109
  require('../../ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.cjs');
@@ -118,60 +115,21 @@ require('../../../../../store/state/tokenBalances.cjs');
118
115
  require('../../../../../store/state/multichainBalances.cjs');
119
116
  require('../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
120
117
  var useIsPasskeysMfaEnabled = require('../../../../../utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.cjs');
121
- var useInternalDynamicContext = require('../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
122
118
 
123
119
  const MfaSection = ({ isLoading }) => {
124
- var _a, _b;
125
120
  const { t } = reactI18next.useTranslation();
126
121
  const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
127
- const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
128
- const { pushView } = ViewContext.useViewContext();
129
- const { getEOAWallet } = useSmartWallets.useSmartWallets();
130
- const { setPassword } = useWalletPassword.useWalletPassword();
131
- const isPasswordEncrypted = useIsPasswordEncrypted.useIsPasswordEncrypted();
132
122
  const isMfaEnabled = useIsMfaEnabled.useIsMfaEnabled();
133
123
  const isTotpMfaEnabled = useIsTotpMfaEnabled.useIsTotpMfaEnabled();
134
124
  const isPasskeyMfaEnabled = useIsPasskeysMfaEnabled.useIsPasskeysMfaEnabled();
135
- const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
136
- const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
137
- const isWaasWallet = Boolean(wallet && ((_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _a === void 0 ? void 0 : _a.key) === null || _b === void 0 ? void 0 : _b.startsWith('dynamicwaas')));
138
- const shouldShowPasswordSetup = isWaasWallet;
139
125
  const handleTotpMfaClick = React.useCallback(() => setDynamicWidgetView('manage-totp-mfa'), [setDynamicWidgetView]);
140
126
  const handlePasskeyMfaClick = React.useCallback(() => setDynamicWidgetView('manage-passkeys-mfa'), [setDynamicWidgetView]);
141
- const handlePasscodeClick = React.useCallback(() => {
142
- setDynamicWidgetView('setup-password', {
143
- onComplete: (password) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
144
- if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
145
- logger.logger.error('No wallet address or chain available for password setup');
146
- return;
147
- }
148
- yield setPassword({
149
- accountAddress: wallet.address,
150
- chainName: wallet.chain,
151
- newPassword: password,
152
- });
153
- }),
154
- });
155
- }, [setDynamicWidgetView, wallet, setPassword]);
156
- const handleResetPasswordClick = React.useCallback(() => {
157
- setShowAuthFlow(true, {
158
- ignoreIfIsEmbeddedWidget: false,
159
- performMultiWalletChecks: false,
160
- });
161
- pushView('reset-password-flow');
162
- }, [setShowAuthFlow, pushView]);
163
- if (!isMfaEnabled && !isWaasWallet) {
127
+ if (!isMfaEnabled) {
164
128
  return null;
165
129
  }
166
130
  return (jsxRuntime.jsxs("div", { className: 'settings-view__body__section', children: [jsxRuntime.jsx("div", { className: 'settings-view__body__section__title', children: jsxRuntime.jsx(Typography.Typography, { copykey: 'dyn_settings.mfa_section.title', color: 'secondary', weight: 'medium', children: t('dyn_settings.mfa_section.title') }) }), isPasskeyMfaEnabled && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'manage-passkeys-mfa-button', onClick: handlePasskeyMfaClick, buttonClassName: 'settings-view__body__section__button', startSlot:
167
131
  // eslint-disable-next-line react/jsx-wrap-multilines
168
- jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(faceId.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.mfa_section.passkey_button', children: t('dyn_settings.mfa_section.passkey_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false })), shouldShowPasswordSetup && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'password-setup-button', onClick: isPasswordEncrypted ? handleResetPasswordClick : handlePasscodeClick, buttonClassName: 'settings-view__body__section__button', startSlot:
169
- // eslint-disable-next-line react/jsx-wrap-multilines
170
- jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(lock.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: isPasswordEncrypted
171
- ? 'dyn_settings.account_security.password.reset_button'
172
- : 'dyn_settings.account_security.password.set_button', children: isPasswordEncrypted
173
- ? t('dyn_settings.account_security.password.reset_button')
174
- : t('dyn_settings.account_security.password.set_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false })), isTotpMfaEnabled && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'manage-totp-mfa-button', onClick: handleTotpMfaClick, buttonClassName: 'settings-view__body__section__button', startSlot:
132
+ jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(faceId.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.mfa_section.passkey_button', children: t('dyn_settings.mfa_section.passkey_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false })), isTotpMfaEnabled && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'manage-totp-mfa-button', onClick: handleTotpMfaClick, buttonClassName: 'settings-view__body__section__button', startSlot:
175
133
  // eslint-disable-next-line react/jsx-wrap-multilines
176
134
  jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(lock.ReactComponent, { className: 'settings-view__body__section__button__icon' }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.mfa_section.totp_button', children: t('dyn_settings.mfa_section.totp_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), disabled: isLoading, showInternalLoading: false }))] }));
177
135
  };