@dynamic-labs/sdk-react-core 4.57.1 → 4.58.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 (140) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +12 -12
  5. package/src/index.cjs +2 -0
  6. package/src/index.d.ts +1 -1
  7. package/src/index.js +1 -0
  8. package/src/lib/components/ToggleVisibilityButton/ToggleVisibilityButton.cjs +127 -0
  9. package/src/lib/components/ToggleVisibilityButton/ToggleVisibilityButton.d.ts +1 -1
  10. package/src/lib/components/ToggleVisibilityButton/ToggleVisibilityButton.js +123 -0
  11. package/src/lib/components/Typography/Typography.cjs +1 -0
  12. package/src/lib/components/Typography/Typography.js +1 -0
  13. package/src/lib/components/Typography/Typography.types.d.ts +1 -1
  14. package/src/lib/context/ViewContext/types/index.d.ts +1 -1
  15. package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.cjs +6 -0
  16. package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.js +6 -0
  17. package/src/lib/modals/SendBalanceModal/SendBalanceModal.cjs +1 -1
  18. package/src/lib/modals/SendBalanceModal/SendBalanceModal.js +1 -1
  19. package/src/lib/shared/assets/check-circle-filled.cjs +60 -0
  20. package/src/lib/shared/assets/check-circle-filled.js +36 -0
  21. package/src/lib/shared/assets/index.d.ts +16 -12
  22. package/src/lib/shared/assets/knowledge-check-icon.cjs +57 -0
  23. package/src/lib/shared/assets/knowledge-check-icon.js +33 -0
  24. package/src/lib/shared/assets/password-lock-icon.cjs +54 -0
  25. package/src/lib/shared/assets/password-lock-icon.js +30 -0
  26. package/src/lib/shared/assets/secure-action.cjs +54 -0
  27. package/src/lib/shared/assets/secure-action.js +30 -0
  28. package/src/lib/shared/assets/warning-circle-orange.cjs +57 -0
  29. package/src/lib/shared/assets/warning-circle-orange.js +33 -0
  30. package/src/lib/styles/index.shadow.cjs +1 -1
  31. package/src/lib/styles/index.shadow.js +1 -1
  32. package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.cjs +4 -1
  33. package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.d.ts +5 -1
  34. package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.js +4 -1
  35. package/src/lib/utils/functions/reconcilePrimaryWallet/index.d.ts +1 -0
  36. package/src/lib/utils/functions/reconcilePrimaryWallet/reconcilePrimaryWallet.cjs +26 -0
  37. package/src/lib/utils/functions/reconcilePrimaryWallet/reconcilePrimaryWallet.d.ts +2 -0
  38. package/src/lib/utils/functions/reconcilePrimaryWallet/reconcilePrimaryWallet.js +22 -0
  39. package/src/lib/utils/hooks/index.d.ts +1 -0
  40. package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +30 -17
  41. package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.d.ts +0 -1
  42. package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +32 -19
  43. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +21 -12
  44. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +2 -1
  45. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +21 -12
  46. package/src/lib/utils/hooks/useRefreshAuth/index.d.ts +1 -0
  47. package/src/lib/utils/hooks/useRefreshAuth/useRefreshAuth.cjs +49 -0
  48. package/src/lib/utils/hooks/useRefreshAuth/useRefreshAuth.d.ts +8 -0
  49. package/src/lib/utils/hooks/useRefreshAuth/useRefreshAuth.js +45 -0
  50. package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.cjs +13 -23
  51. package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.js +12 -22
  52. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +12 -10
  53. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +13 -11
  54. package/src/lib/utils/hooks/useWalletBackup/cloudProviders.cjs +2 -2
  55. package/src/lib/utils/hooks/useWalletBackup/cloudProviders.js +2 -2
  56. package/src/lib/utils/hooks/useWalletBackup/useWalletBackup.cjs +2 -2
  57. package/src/lib/utils/hooks/useWalletBackup/useWalletBackup.js +2 -2
  58. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +2 -2
  59. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +2 -2
  60. package/src/lib/views/BackupUnsuccessfulView/BackupUnsuccessfulView.cjs +1 -1
  61. package/src/lib/views/BackupUnsuccessfulView/BackupUnsuccessfulView.js +1 -1
  62. package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +1 -1
  63. package/src/lib/views/CollectUserDataView/CollectUserDataView.js +1 -1
  64. package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.cjs +1 -1
  65. package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.js +1 -1
  66. package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
  67. package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
  68. package/src/lib/views/ExportSharesView/ExportSharesView.cjs +1 -1
  69. package/src/lib/views/ExportSharesView/ExportSharesView.js +1 -1
  70. package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +1 -1
  71. package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +1 -1
  72. package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +1 -1
  73. package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +1 -1
  74. package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +1 -1
  75. package/src/lib/views/MfaVerificationView/MfaVerificationView.js +1 -1
  76. package/src/lib/views/Passkey/ConfirmPasskeyView/ConfirmPasskeyView.cjs +1 -1
  77. package/src/lib/views/Passkey/ConfirmPasskeyView/ConfirmPasskeyView.js +1 -1
  78. package/src/lib/views/Passkey/SetupPasskeyView/SetupPasskeyView.cjs +1 -1
  79. package/src/lib/views/Passkey/SetupPasskeyView/SetupPasskeyView.js +1 -1
  80. package/src/lib/views/SmsVerification/SmsVerification.cjs +1 -1
  81. package/src/lib/views/SmsVerification/SmsVerification.js +1 -1
  82. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +6 -5
  83. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +6 -5
  84. package/src/lib/views/WaasUpgradeView/WaasUpgradeView.cjs +1 -1
  85. package/src/lib/views/WaasUpgradeView/WaasUpgradeView.js +1 -1
  86. package/src/lib/views/WalletLockedView/WalletLockedView.cjs +1 -1
  87. package/src/lib/views/WalletLockedView/WalletLockedView.js +1 -1
  88. package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.cjs +2 -2
  89. package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.js +2 -2
  90. package/src/lib/views/viewToComponentMap.cjs +2 -0
  91. package/src/lib/views/viewToComponentMap.d.ts +1 -0
  92. package/src/lib/views/viewToComponentMap.js +2 -0
  93. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +1 -1
  94. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +1 -1
  95. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +15 -3
  96. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +6 -0
  97. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +15 -3
  98. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +1 -1
  99. package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.cjs +1 -1
  100. package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.js +1 -1
  101. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.cjs +2 -2
  102. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.js +2 -2
  103. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +31 -10
  104. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +31 -10
  105. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +1 -1
  106. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +1 -1
  107. package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.cjs +54 -0
  108. package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.d.ts +7 -0
  109. package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.js +50 -0
  110. package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/index.d.ts +2 -0
  111. package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/PasswordRequirement.cjs +15 -0
  112. package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/PasswordRequirement.d.ts +6 -0
  113. package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/PasswordRequirement.js +11 -0
  114. package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/SetupPasswordEnterView.cjs +57 -0
  115. package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/SetupPasswordEnterView.d.ts +6 -0
  116. package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/SetupPasswordEnterView.js +53 -0
  117. package/src/lib/widgets/DynamicWidget/views/SetupPasswordEnterView/index.d.ts +4 -0
  118. package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.cjs +83 -0
  119. package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.d.ts +7 -0
  120. package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.js +79 -0
  121. package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/index.d.ts +2 -0
  122. package/src/lib/widgets/DynamicWidget/views/SetupPasswordSuccessView/SetupPasswordSuccessView.cjs +27 -0
  123. package/src/lib/widgets/DynamicWidget/views/SetupPasswordSuccessView/SetupPasswordSuccessView.d.ts +5 -0
  124. package/src/lib/widgets/DynamicWidget/views/SetupPasswordSuccessView/SetupPasswordSuccessView.js +23 -0
  125. package/src/lib/widgets/DynamicWidget/views/SetupPasswordSuccessView/index.d.ts +2 -0
  126. package/src/lib/widgets/DynamicWidget/views/SetupPasswordTermsView/SetupPasswordTermsView.cjs +37 -0
  127. package/src/lib/widgets/DynamicWidget/views/SetupPasswordTermsView/SetupPasswordTermsView.d.ts +6 -0
  128. package/src/lib/widgets/DynamicWidget/views/SetupPasswordTermsView/SetupPasswordTermsView.js +33 -0
  129. package/src/lib/widgets/DynamicWidget/views/SetupPasswordTermsView/index.d.ts +2 -0
  130. package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.cjs +76 -0
  131. package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.d.ts +6 -0
  132. package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.js +72 -0
  133. package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/index.d.ts +2 -0
  134. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.cjs +1 -1
  135. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.js +1 -1
  136. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView.cjs +1 -1
  137. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView.js +1 -1
  138. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.cjs +1 -1
  139. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.js +1 -1
  140. package/src/lib/widgets/DynamicWidget/views/index.d.ts +6 -0
@@ -19,7 +19,7 @@ const getMobileOauthUrl = (provider, loginData) => {
19
19
  }
20
20
  return provider.redirectUrl.replace('redirect', 'authorizeHtml');
21
21
  };
22
- const getOauthLoginUrl = (providers, providerType) => {
22
+ const getOauthLoginUrl = (providers, providerType, options) => {
23
23
  var _a, _b, _c;
24
24
  const provider = getProviderByType.getProviderByType(providers, providerType);
25
25
  if (!(provider === null || provider === void 0 ? void 0 : provider.clientId)) {
@@ -56,6 +56,9 @@ const getOauthLoginUrl = (providers, providerType) => {
56
56
  }
57
57
  if (providerType === sdkApiCore.ProviderEnum.Google) {
58
58
  baseProps.access_type = 'offline';
59
+ if (options === null || options === void 0 ? void 0 : options.isGoogleDriveBackupEnabled) {
60
+ baseProps.prompt = 'consent';
61
+ }
59
62
  }
60
63
  if (provider.scopes) {
61
64
  baseProps.scope = provider.scopes;
@@ -1,2 +1,6 @@
1
1
  import { Provider, ProviderEnum } from '@dynamic-labs/sdk-api-core';
2
- export declare const getOauthLoginUrl: (providers: Provider[], providerType: ProviderEnum) => string;
2
+ type GetOauthLoginUrlOptions = {
3
+ isGoogleDriveBackupEnabled?: boolean;
4
+ };
5
+ export declare const getOauthLoginUrl: (providers: Provider[], providerType: ProviderEnum, options?: GetOauthLoginUrlOptions) => string;
6
+ export {};
@@ -15,7 +15,7 @@ const getMobileOauthUrl = (provider, loginData) => {
15
15
  }
16
16
  return provider.redirectUrl.replace('redirect', 'authorizeHtml');
17
17
  };
18
- const getOauthLoginUrl = (providers, providerType) => {
18
+ const getOauthLoginUrl = (providers, providerType, options) => {
19
19
  var _a, _b, _c;
20
20
  const provider = getProviderByType(providers, providerType);
21
21
  if (!(provider === null || provider === void 0 ? void 0 : provider.clientId)) {
@@ -52,6 +52,9 @@ const getOauthLoginUrl = (providers, providerType) => {
52
52
  }
53
53
  if (providerType === ProviderEnum.Google) {
54
54
  baseProps.access_type = 'offline';
55
+ if (options === null || options === void 0 ? void 0 : options.isGoogleDriveBackupEnabled) {
56
+ baseProps.prompt = 'consent';
57
+ }
55
58
  }
56
59
  if (provider.scopes) {
57
60
  baseProps.scope = provider.scopes;
@@ -0,0 +1 @@
1
+ export { reconcilePrimaryWallet } from './reconcilePrimaryWallet';
@@ -0,0 +1,26 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var primaryWalletId = require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
7
+ var findPrimaryWalletVCForUser = require('../findPrimaryWalletVCForUser/findPrimaryWalletVCForUser.cjs');
8
+ var updatePrimaryWalletId = require('../updatePrimaryWalletId/updatePrimaryWalletId.cjs');
9
+
10
+ const reconcilePrimaryWallet = (user) => {
11
+ // Check if the primary wallet is still in this user's VCs
12
+ const primaryWalletInUserVCs = user.verifiedCredentials.some(({ id }) => id === primaryWalletId.getPrimaryWalletId());
13
+ if (primaryWalletInUserVCs)
14
+ return;
15
+ // Try to set primary wallet ID from available wallets (AA or embedded)
16
+ const primaryWalletVC = findPrimaryWalletVCForUser.findPrimaryWalletVCForUser(user);
17
+ if (primaryWalletVC) {
18
+ updatePrimaryWalletId.updatePrimaryWalletId(primaryWalletVC.id);
19
+ }
20
+ else {
21
+ // No wallet VCs found, unset the primary wallet
22
+ primaryWalletId.setPrimaryWalletId(undefined);
23
+ }
24
+ };
25
+
26
+ exports.reconcilePrimaryWallet = reconcilePrimaryWallet;
@@ -0,0 +1,2 @@
1
+ import { UserProfile } from '@dynamic-labs/types';
2
+ export declare const reconcilePrimaryWallet: (user: UserProfile) => void;
@@ -0,0 +1,22 @@
1
+ 'use client'
2
+ import { getPrimaryWalletId, setPrimaryWalletId } from '../../../store/state/primaryWalletId/primaryWalletId.js';
3
+ import { findPrimaryWalletVCForUser } from '../findPrimaryWalletVCForUser/findPrimaryWalletVCForUser.js';
4
+ import { updatePrimaryWalletId } from '../updatePrimaryWalletId/updatePrimaryWalletId.js';
5
+
6
+ const reconcilePrimaryWallet = (user) => {
7
+ // Check if the primary wallet is still in this user's VCs
8
+ const primaryWalletInUserVCs = user.verifiedCredentials.some(({ id }) => id === getPrimaryWalletId());
9
+ if (primaryWalletInUserVCs)
10
+ return;
11
+ // Try to set primary wallet ID from available wallets (AA or embedded)
12
+ const primaryWalletVC = findPrimaryWalletVCForUser(user);
13
+ if (primaryWalletVC) {
14
+ updatePrimaryWalletId(primaryWalletVC.id);
15
+ }
16
+ else {
17
+ // No wallet VCs found, unset the primary wallet
18
+ setPrimaryWalletId(undefined);
19
+ }
20
+ };
21
+
22
+ export { reconcilePrimaryWallet };
@@ -98,3 +98,4 @@ export { useIsMfaRequiredForAction } from './useIsMfaRequiredForAction';
98
98
  export { useWalletDelegation } from './useWalletDelegation';
99
99
  export { CloudBackupProvider, isWalletBackedUp, useBackupWallets, useWalletBackup, } from './useWalletBackup';
100
100
  export type { WalletBackupStatus, WalletOperationState, WalletToBackup, WalletWithBackupStatus, } from './useWalletBackup';
101
+ export { useRefreshAuth } from './useRefreshAuth';
@@ -31,38 +31,51 @@ var getClientSessionKeys = require('../../functions/clientSessionKeys/getClientS
31
31
  require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
32
32
  require('../../../events/dynamicEvents.cjs');
33
33
  var useOnboardingCompleteUser = require('../../../client/extension/user/useOnboardingCompleteUser/useOnboardingCompleteUser.cjs');
34
- var usePromise = require('../usePromise/usePromise.cjs');
35
34
 
36
35
  const useClientSessionKeys = () => {
37
36
  const user = useOnboardingCompleteUser.useOnboardingCompleteUser();
38
37
  const sessionPublicKey = getClientSessionKeys.getClientSessionPublicKey();
38
+ // Use refs to capture latest values without causing function reference changes
39
+ const userRef = React.useRef(user);
40
+ const sessionPublicKeyRef = React.useRef(sessionPublicKey);
41
+ // Update refs on every render
42
+ userRef.current = user;
43
+ sessionPublicKeyRef.current = sessionPublicKey;
44
+ /**
45
+ * Get a signed session ID with nonce for replay protection.
46
+ * Returns signature in format: `${signedSessionId}/${signedNonce}/${nonce}`
47
+ *
48
+ * This is a lazy function - nonce API is only called when this function is invoked.
49
+ */
39
50
  const getSignedSessionId = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
40
- if (!(user === null || user === void 0 ? void 0 : user.sessionId) || !sessionPublicKey) {
51
+ const currentUser = userRef.current;
52
+ const currentPublicKey = sessionPublicKeyRef.current;
53
+ if (!(currentUser === null || currentUser === void 0 ? void 0 : currentUser.sessionId) || !currentPublicKey) {
41
54
  throw new Error('Session ID and public key are required');
42
55
  }
43
- const result = yield getClientSessionKeys.getClientSessionSignature({
44
- sessionId: user === null || user === void 0 ? void 0 : user.sessionId,
56
+ const { sessionSignature: signedSessionId } = yield getClientSessionKeys.getClientSessionSignature({
57
+ sessionId: currentUser.sessionId,
45
58
  });
59
+ const { nonce, nonceSignature } = yield getClientSessionKeys.getClientSessionNonceSignature({
60
+ environmentId: currentUser.projectEnvironmentId,
61
+ });
62
+ const sessionSignature = `${signedSessionId}/${nonceSignature}/${nonce}`;
46
63
  logger.logger.instrument('[SessionChaining] Generated session signature', {
47
- environmentId: user.projectEnvironmentId,
64
+ environmentId: currentUser.projectEnvironmentId,
48
65
  key: 'generated_session_signature',
49
- sessionId: user.sessionId,
50
- sessionPublicKey,
51
- sessionSignature: result.sessionSignature,
66
+ nonce,
67
+ nonceSignature,
68
+ sessionId: currentUser.sessionId,
69
+ sessionPublicKey: currentPublicKey,
70
+ sessionSignature,
71
+ signedSessionId,
52
72
  time: 0,
53
73
  });
54
- return result.sessionSignature;
55
- }), [user === null || user === void 0 ? void 0 : user.sessionId, sessionPublicKey]);
56
- const { data: sessionSignatureResult } = usePromise.usePromise(getSignedSessionId, {
57
- deps: [user === null || user === void 0 ? void 0 : user.sessionId, sessionPublicKey],
58
- enabled: Boolean(user === null || user === void 0 ? void 0 : user.sessionId) && Boolean(sessionPublicKey),
59
- initialData: undefined,
60
- retries: 2,
61
- });
74
+ return sessionSignature;
75
+ }), []);
62
76
  return {
63
77
  getSignedSessionId,
64
78
  sessionPublicKey,
65
- sessionSignature: sessionSignatureResult,
66
79
  };
67
80
  };
68
81
 
@@ -1,5 +1,4 @@
1
1
  export declare const useClientSessionKeys: () => {
2
2
  getSignedSessionId: () => Promise<string>;
3
3
  sessionPublicKey: string | undefined;
4
- sessionSignature: string | undefined;
5
4
  };
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
- import { useCallback } from 'react';
3
+ import { useRef, useCallback } from 'react';
4
4
  import '@dynamic-labs-sdk/client/core';
5
5
  import '@dynamic-labs/sdk-api-core';
6
6
  import '../../../client/client.js';
@@ -23,42 +23,55 @@ import '@dynamic-labs/locale';
23
23
  import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
24
24
  import '../../../store/state/primaryWalletId/primaryWalletId.js';
25
25
  import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
26
- import { getClientSessionPublicKey, getClientSessionSignature } from '../../functions/clientSessionKeys/getClientSessionKeys.js';
26
+ import { getClientSessionPublicKey, getClientSessionSignature, getClientSessionNonceSignature } from '../../functions/clientSessionKeys/getClientSessionKeys.js';
27
27
  import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
28
28
  import '../../../events/dynamicEvents.js';
29
29
  import { useOnboardingCompleteUser } from '../../../client/extension/user/useOnboardingCompleteUser/useOnboardingCompleteUser.js';
30
- import { usePromise } from '../usePromise/usePromise.js';
31
30
 
32
31
  const useClientSessionKeys = () => {
33
32
  const user = useOnboardingCompleteUser();
34
33
  const sessionPublicKey = getClientSessionPublicKey();
34
+ // Use refs to capture latest values without causing function reference changes
35
+ const userRef = useRef(user);
36
+ const sessionPublicKeyRef = useRef(sessionPublicKey);
37
+ // Update refs on every render
38
+ userRef.current = user;
39
+ sessionPublicKeyRef.current = sessionPublicKey;
40
+ /**
41
+ * Get a signed session ID with nonce for replay protection.
42
+ * Returns signature in format: `${signedSessionId}/${signedNonce}/${nonce}`
43
+ *
44
+ * This is a lazy function - nonce API is only called when this function is invoked.
45
+ */
35
46
  const getSignedSessionId = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
36
- if (!(user === null || user === void 0 ? void 0 : user.sessionId) || !sessionPublicKey) {
47
+ const currentUser = userRef.current;
48
+ const currentPublicKey = sessionPublicKeyRef.current;
49
+ if (!(currentUser === null || currentUser === void 0 ? void 0 : currentUser.sessionId) || !currentPublicKey) {
37
50
  throw new Error('Session ID and public key are required');
38
51
  }
39
- const result = yield getClientSessionSignature({
40
- sessionId: user === null || user === void 0 ? void 0 : user.sessionId,
52
+ const { sessionSignature: signedSessionId } = yield getClientSessionSignature({
53
+ sessionId: currentUser.sessionId,
41
54
  });
55
+ const { nonce, nonceSignature } = yield getClientSessionNonceSignature({
56
+ environmentId: currentUser.projectEnvironmentId,
57
+ });
58
+ const sessionSignature = `${signedSessionId}/${nonceSignature}/${nonce}`;
42
59
  logger.instrument('[SessionChaining] Generated session signature', {
43
- environmentId: user.projectEnvironmentId,
60
+ environmentId: currentUser.projectEnvironmentId,
44
61
  key: 'generated_session_signature',
45
- sessionId: user.sessionId,
46
- sessionPublicKey,
47
- sessionSignature: result.sessionSignature,
62
+ nonce,
63
+ nonceSignature,
64
+ sessionId: currentUser.sessionId,
65
+ sessionPublicKey: currentPublicKey,
66
+ sessionSignature,
67
+ signedSessionId,
48
68
  time: 0,
49
69
  });
50
- return result.sessionSignature;
51
- }), [user === null || user === void 0 ? void 0 : user.sessionId, sessionPublicKey]);
52
- const { data: sessionSignatureResult } = usePromise(getSignedSessionId, {
53
- deps: [user === null || user === void 0 ? void 0 : user.sessionId, sessionPublicKey],
54
- enabled: Boolean(user === null || user === void 0 ? void 0 : user.sessionId) && Boolean(sessionPublicKey),
55
- initialData: undefined,
56
- retries: 2,
57
- });
70
+ return sessionSignature;
71
+ }), []);
58
72
  return {
59
73
  getSignedSessionId,
60
74
  sessionPublicKey,
61
- sessionSignature: sessionSignatureResult,
62
75
  };
63
76
  };
64
77
 
@@ -101,7 +101,7 @@ require('../../../context/FooterAnimationContext/index.cjs');
101
101
  require('../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
102
102
  require('../../../context/PasskeyContext/PasskeyContext.cjs');
103
103
  require('../../../context/OnrampContext/OnrampContext.cjs');
104
- var useRefreshUser = require('../useRefreshUser/useRefreshUser.cjs');
104
+ var useRefreshAuth = require('../useRefreshAuth/useRefreshAuth.cjs');
105
105
  var apiUrl = require('../../constants/waas/apiUrl.cjs');
106
106
  var useClientSessionKeys = require('../useClientSessionKeys/useClientSessionKeys.cjs');
107
107
  var useGetMfaToken = require('../useGetMfaToken/useGetMfaToken.cjs');
@@ -122,7 +122,7 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
122
122
  var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
123
123
 
124
124
  const dynamicWaasKey = 'dynamicwaas';
125
- const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, }) => {
125
+ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, svmGasSponsorshipEnabled = false, }) => {
126
126
  var _a;
127
127
  walletConnector.setEnvironmentId(environmentId);
128
128
  walletConnector.setBaseApiUrl((_a = (apiBaseUrl || apiUrl.DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
@@ -138,10 +138,16 @@ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl,
138
138
  walletConnector.setRelayUrl(relayUrl);
139
139
  walletConnector.setGetMfaTokenFunction(getMfaToken);
140
140
  walletConnector.setBaseClientKeysharesRelayApiUrl(baseClientKeysharesRelayApiUrl);
141
+ // Sync SVM gas sponsorship setting for SOL connectors
142
+ const isSolConnector = walletConnector.connectedChain === 'SOL';
143
+ const supportsSponsorshipSetting = 'setSvmGasSponsorshipEnabled' in walletConnector;
144
+ if (isSolConnector && supportsSponsorshipSetting) {
145
+ walletConnector.setSvmGasSponsorshipEnabled(svmGasSponsorshipEnabled);
146
+ }
141
147
  return walletConnector;
142
148
  };
143
149
  const useDynamicWaas = () => {
144
- var _a, _b, _c, _d, _e, _f;
150
+ var _a, _b, _c, _d, _e, _f, _g;
145
151
  const { setShowAuthFlow, primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
146
152
  const { addedWalletsIds, userWallets } = UserWalletsContext.useInternalUserWallets();
147
153
  const user = useUser.useUser();
@@ -149,7 +155,7 @@ const useDynamicWaas = () => {
149
155
  const projectSettings = useProjectSettings.useProjectSettings();
150
156
  const environmentId = dynamicContextProps.useEnvironmentId();
151
157
  const walletConnectorOptions = walletOptions.useWalletConnectorOptions();
152
- const refresh = useRefreshUser.useRefreshUser();
158
+ const refresh = useRefreshAuth.useRefreshAuth();
153
159
  const relayUrl = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.waas) === null || _b === void 0 ? void 0 : _b.relayUrl;
154
160
  const baseClientKeysharesRelayApiUrl = (_d = (_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.waas) === null || _d === void 0 ? void 0 : _d.customKeyshareRelayBaseUrl;
155
161
  const embeddedWalletSettings = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets;
@@ -160,6 +166,7 @@ const useDynamicWaas = () => {
160
166
  const automaticEmbeddedWalletCreationForExternalEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreationForExternal;
161
167
  const defaultWalletVersion = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.defaultWalletVersion;
162
168
  const dynamicWaasIsEnabled = defaultWalletVersion === sdkApiCore.EmbeddedWalletVersionEnum.V3;
169
+ const svmGasSponsorshipEnabled = (_f = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.svmGasSponsorshipEnabled) !== null && _f !== void 0 ? _f : false;
163
170
  const authToken = getMinAuthToken.getMinAuthToken();
164
171
  const { getSignedSessionId } = useClientSessionKeys.useClientSessionKeys();
165
172
  const getMfaToken = useGetMfaToken.useGetMfaToken();
@@ -185,6 +192,7 @@ const useDynamicWaas = () => {
185
192
  getMfaToken,
186
193
  getSignedSessionId,
187
194
  relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
195
+ svmGasSponsorshipEnabled,
188
196
  walletConnector,
189
197
  });
190
198
  return configuredWalletConnector;
@@ -198,6 +206,7 @@ const useDynamicWaas = () => {
198
206
  getSignedSessionId,
199
207
  relayUrl,
200
208
  baseClientKeysharesRelayApiUrl,
209
+ svmGasSponsorshipEnabled,
201
210
  ]);
202
211
  const shouldInitializeWaas = React.useMemo(() => {
203
212
  var _a;
@@ -213,7 +222,7 @@ const useDynamicWaas = () => {
213
222
  }, [
214
223
  user === null || user === void 0 ? void 0 : user.id,
215
224
  user === null || user === void 0 ? void 0 : user.sessionId,
216
- (_f = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _f === void 0 ? void 0 : _f.length,
225
+ (_g = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _g === void 0 ? void 0 : _g.length,
217
226
  dynamicWaasIsEnabled,
218
227
  enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length,
219
228
  walletConnectorOptions.length,
@@ -223,7 +232,6 @@ const useDynamicWaas = () => {
223
232
  return;
224
233
  try {
225
234
  const initializationStart = new Date().getTime();
226
- const sessionSignature = yield getSignedSessionId();
227
235
  yield Promise.all((enabledChainNames || []).map((chain) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
228
236
  const walletConnector = getWaasWalletConnector(chain);
229
237
  if (!walletConnector)
@@ -264,10 +272,11 @@ const useDynamicWaas = () => {
264
272
  walletAddress: wallet.address,
265
273
  });
266
274
  const keyshareRestorationStart = new Date().getTime();
275
+ const signedSessionId = yield getSignedSessionId();
267
276
  yield client.getWallet({
268
277
  accountAddress: wallet.address,
269
- signedSessionId: sessionSignature,
270
- walletOperation: 'SIGN_MESSAGE',
278
+ signedSessionId,
279
+ walletOperation: 'RECOVER',
271
280
  });
272
281
  const keyshareRestorationEnd = new Date().getTime();
273
282
  const keyshareRestorationTime = keyshareRestorationEnd - keyshareRestorationStart;
@@ -483,7 +492,7 @@ const useDynamicWaas = () => {
483
492
  automaticEmbeddedWalletCreationForExternalEnabled,
484
493
  enabledChainNames,
485
494
  ]);
486
- const importPrivateKey = (_g) => _tslib.__awaiter(void 0, [_g], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, }) {
495
+ const importPrivateKey = (_h) => _tslib.__awaiter(void 0, [_h], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, }) {
487
496
  const walletConnector = getWaasWalletConnector(chainName);
488
497
  if (!walletConnector)
489
498
  return;
@@ -495,7 +504,7 @@ const useDynamicWaas = () => {
495
504
  });
496
505
  yield refresh();
497
506
  });
498
- const upgradeToDynamicWaas = React.useCallback((_h) => _tslib.__awaiter(void 0, [_h], void 0, function* ({ privateKey, wallet, }) {
507
+ const upgradeToDynamicWaas = React.useCallback((_j) => _tslib.__awaiter(void 0, [_j], void 0, function* ({ privateKey, wallet, }) {
499
508
  isUpgrading.current = true;
500
509
  if (!primaryWallet) {
501
510
  throw new utils.DynamicError('Primary wallet not found');
@@ -574,14 +583,14 @@ const useDynamicWaas = () => {
574
583
  values.VerifiedCredentialNameToChainEnum[cred.chain]);
575
584
  }, [user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
576
585
  const processSignOnWalletSettings = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
577
- var _j;
586
+ var _k;
578
587
  if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials)) {
579
588
  return;
580
589
  }
581
590
  const waasWallets = user.verifiedCredentials.filter((vc) => { var _a; return vc.walletName === 'dynamicwaas' && ((_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings); });
582
591
  for (const wallet of waasWallets) {
583
592
  try {
584
- const settings = (_j = wallet.walletProperties) === null || _j === void 0 ? void 0 : _j.settings;
593
+ const settings = (_k = wallet.walletProperties) === null || _k === void 0 ? void 0 : _k.settings;
585
594
  const { address, chain } = wallet;
586
595
  if (!settings || !address || !chain) {
587
596
  continue;
@@ -12,7 +12,7 @@ export type WalletCreationRequirement = {
12
12
  network?: string;
13
13
  };
14
14
  };
15
- export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode, getSignedSessionId, getMfaToken, }: {
15
+ export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode, getSignedSessionId, getMfaToken, svmGasSponsorshipEnabled, }: {
16
16
  walletConnector: IDynamicWaasConnector;
17
17
  environmentId: string;
18
18
  apiBaseUrl: string;
@@ -23,6 +23,7 @@ export declare const configWaasWalletConnector: ({ walletConnector, environmentI
23
23
  getMfaToken: (props?: {
24
24
  mfaAction?: MFAAction;
25
25
  }) => Promise<string | undefined>;
26
+ svmGasSponsorshipEnabled?: boolean;
26
27
  }) => IDynamicWaasConnector;
27
28
  export declare const useDynamicWaas: () => {
28
29
  createWalletAccount: (requirementsOrChainNames: WalletCreationRequirement[] | ChainEnum[], password?: string, bitcoinConfig?: {
@@ -97,7 +97,7 @@ import '../../../context/FooterAnimationContext/index.js';
97
97
  import '../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
98
98
  import '../../../context/PasskeyContext/PasskeyContext.js';
99
99
  import '../../../context/OnrampContext/OnrampContext.js';
100
- import { useRefreshUser } from '../useRefreshUser/useRefreshUser.js';
100
+ import { useRefreshAuth } from '../useRefreshAuth/useRefreshAuth.js';
101
101
  import { DEFAULT_WAAS_API_URL } from '../../constants/waas/apiUrl.js';
102
102
  import { useClientSessionKeys } from '../useClientSessionKeys/useClientSessionKeys.js';
103
103
  import { useGetMfaToken } from '../useGetMfaToken/useGetMfaToken.js';
@@ -118,7 +118,7 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
118
118
  import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
119
119
 
120
120
  const dynamicWaasKey = 'dynamicwaas';
121
- const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, }) => {
121
+ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, svmGasSponsorshipEnabled = false, }) => {
122
122
  var _a;
123
123
  walletConnector.setEnvironmentId(environmentId);
124
124
  walletConnector.setBaseApiUrl((_a = (apiBaseUrl || DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
@@ -134,10 +134,16 @@ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl,
134
134
  walletConnector.setRelayUrl(relayUrl);
135
135
  walletConnector.setGetMfaTokenFunction(getMfaToken);
136
136
  walletConnector.setBaseClientKeysharesRelayApiUrl(baseClientKeysharesRelayApiUrl);
137
+ // Sync SVM gas sponsorship setting for SOL connectors
138
+ const isSolConnector = walletConnector.connectedChain === 'SOL';
139
+ const supportsSponsorshipSetting = 'setSvmGasSponsorshipEnabled' in walletConnector;
140
+ if (isSolConnector && supportsSponsorshipSetting) {
141
+ walletConnector.setSvmGasSponsorshipEnabled(svmGasSponsorshipEnabled);
142
+ }
137
143
  return walletConnector;
138
144
  };
139
145
  const useDynamicWaas = () => {
140
- var _a, _b, _c, _d, _e, _f;
146
+ var _a, _b, _c, _d, _e, _f, _g;
141
147
  const { setShowAuthFlow, primaryWallet } = useInternalDynamicContext();
142
148
  const { addedWalletsIds, userWallets } = useInternalUserWallets();
143
149
  const user = useUser();
@@ -145,7 +151,7 @@ const useDynamicWaas = () => {
145
151
  const projectSettings = useProjectSettings();
146
152
  const environmentId = useEnvironmentId();
147
153
  const walletConnectorOptions = useWalletConnectorOptions();
148
- const refresh = useRefreshUser();
154
+ const refresh = useRefreshAuth();
149
155
  const relayUrl = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.waas) === null || _b === void 0 ? void 0 : _b.relayUrl;
150
156
  const baseClientKeysharesRelayApiUrl = (_d = (_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.waas) === null || _d === void 0 ? void 0 : _d.customKeyshareRelayBaseUrl;
151
157
  const embeddedWalletSettings = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets;
@@ -156,6 +162,7 @@ const useDynamicWaas = () => {
156
162
  const automaticEmbeddedWalletCreationForExternalEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreationForExternal;
157
163
  const defaultWalletVersion = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.defaultWalletVersion;
158
164
  const dynamicWaasIsEnabled = defaultWalletVersion === EmbeddedWalletVersionEnum.V3;
165
+ const svmGasSponsorshipEnabled = (_f = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.svmGasSponsorshipEnabled) !== null && _f !== void 0 ? _f : false;
159
166
  const authToken = getMinAuthToken();
160
167
  const { getSignedSessionId } = useClientSessionKeys();
161
168
  const getMfaToken = useGetMfaToken();
@@ -181,6 +188,7 @@ const useDynamicWaas = () => {
181
188
  getMfaToken,
182
189
  getSignedSessionId,
183
190
  relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
191
+ svmGasSponsorshipEnabled,
184
192
  walletConnector,
185
193
  });
186
194
  return configuredWalletConnector;
@@ -194,6 +202,7 @@ const useDynamicWaas = () => {
194
202
  getSignedSessionId,
195
203
  relayUrl,
196
204
  baseClientKeysharesRelayApiUrl,
205
+ svmGasSponsorshipEnabled,
197
206
  ]);
198
207
  const shouldInitializeWaas = useMemo(() => {
199
208
  var _a;
@@ -209,7 +218,7 @@ const useDynamicWaas = () => {
209
218
  }, [
210
219
  user === null || user === void 0 ? void 0 : user.id,
211
220
  user === null || user === void 0 ? void 0 : user.sessionId,
212
- (_f = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _f === void 0 ? void 0 : _f.length,
221
+ (_g = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _g === void 0 ? void 0 : _g.length,
213
222
  dynamicWaasIsEnabled,
214
223
  enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length,
215
224
  walletConnectorOptions.length,
@@ -219,7 +228,6 @@ const useDynamicWaas = () => {
219
228
  return;
220
229
  try {
221
230
  const initializationStart = new Date().getTime();
222
- const sessionSignature = yield getSignedSessionId();
223
231
  yield Promise.all((enabledChainNames || []).map((chain) => __awaiter(void 0, void 0, void 0, function* () {
224
232
  const walletConnector = getWaasWalletConnector(chain);
225
233
  if (!walletConnector)
@@ -260,10 +268,11 @@ const useDynamicWaas = () => {
260
268
  walletAddress: wallet.address,
261
269
  });
262
270
  const keyshareRestorationStart = new Date().getTime();
271
+ const signedSessionId = yield getSignedSessionId();
263
272
  yield client.getWallet({
264
273
  accountAddress: wallet.address,
265
- signedSessionId: sessionSignature,
266
- walletOperation: 'SIGN_MESSAGE',
274
+ signedSessionId,
275
+ walletOperation: 'RECOVER',
267
276
  });
268
277
  const keyshareRestorationEnd = new Date().getTime();
269
278
  const keyshareRestorationTime = keyshareRestorationEnd - keyshareRestorationStart;
@@ -479,7 +488,7 @@ const useDynamicWaas = () => {
479
488
  automaticEmbeddedWalletCreationForExternalEnabled,
480
489
  enabledChainNames,
481
490
  ]);
482
- const importPrivateKey = (_g) => __awaiter(void 0, [_g], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, }) {
491
+ const importPrivateKey = (_h) => __awaiter(void 0, [_h], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, }) {
483
492
  const walletConnector = getWaasWalletConnector(chainName);
484
493
  if (!walletConnector)
485
494
  return;
@@ -491,7 +500,7 @@ const useDynamicWaas = () => {
491
500
  });
492
501
  yield refresh();
493
502
  });
494
- const upgradeToDynamicWaas = useCallback((_h) => __awaiter(void 0, [_h], void 0, function* ({ privateKey, wallet, }) {
503
+ const upgradeToDynamicWaas = useCallback((_j) => __awaiter(void 0, [_j], void 0, function* ({ privateKey, wallet, }) {
495
504
  isUpgrading.current = true;
496
505
  if (!primaryWallet) {
497
506
  throw new DynamicError('Primary wallet not found');
@@ -570,14 +579,14 @@ const useDynamicWaas = () => {
570
579
  VerifiedCredentialNameToChainEnum[cred.chain]);
571
580
  }, [user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
572
581
  const processSignOnWalletSettings = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
573
- var _j;
582
+ var _k;
574
583
  if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials)) {
575
584
  return;
576
585
  }
577
586
  const waasWallets = user.verifiedCredentials.filter((vc) => { var _a; return vc.walletName === 'dynamicwaas' && ((_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings); });
578
587
  for (const wallet of waasWallets) {
579
588
  try {
580
- const settings = (_j = wallet.walletProperties) === null || _j === void 0 ? void 0 : _j.settings;
589
+ const settings = (_k = wallet.walletProperties) === null || _k === void 0 ? void 0 : _k.settings;
581
590
  const { address, chain } = wallet;
582
591
  if (!settings || !address || !chain) {
583
592
  continue;
@@ -0,0 +1 @@
1
+ export { useRefreshAuth } from './useRefreshAuth';
@@ -0,0 +1,49 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
+ var React = require('react');
8
+ var client = require('@dynamic-labs-sdk/client');
9
+ require('@dynamic-labs-sdk/client/core');
10
+ require('@dynamic-labs/sdk-api-core');
11
+ require('../../../client/client.cjs');
12
+ require('../../../config/ApiEndpoint.cjs');
13
+ require('@dynamic-labs/iconic');
14
+ require('@dynamic-labs/wallet-connector-core');
15
+ require('react/jsx-runtime');
16
+ require('../../../context/ViewContext/ViewContext.cjs');
17
+ require('../../../shared/logger.cjs');
18
+ require('@dynamic-labs/wallet-book');
19
+ require('@dynamic-labs/utils');
20
+ require('../../constants/colors.cjs');
21
+ require('../../constants/values.cjs');
22
+ require('../../../shared/consts/index.cjs');
23
+ require('@dynamic-labs/multi-wallet');
24
+ require('react-international-phone');
25
+ require('../../../store/state/nonce/nonce.cjs');
26
+ require('@dynamic-labs/locale');
27
+ require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
28
+ require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
29
+ require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
30
+ require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
31
+ require('../../../events/dynamicEvents.cjs');
32
+ var getUserProfile = require('../../../client/extension/user/getUserProfile/getUserProfile.cjs');
33
+ var reconcilePrimaryWallet = require('../../functions/reconcilePrimaryWallet/reconcilePrimaryWallet.cjs');
34
+
35
+ /**
36
+ * Refresh auth state
37
+ * @returns A callback function that can be used to refresh the auth state
38
+ */
39
+ const useRefreshAuth = () => React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
40
+ yield client.refreshAuth();
41
+ const user = getUserProfile.getUserProfile();
42
+ if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials)) {
43
+ throw new Error('useRefreshAuth resulted in an invalid user: no verified credentials found');
44
+ }
45
+ reconcilePrimaryWallet.reconcilePrimaryWallet(user);
46
+ return user;
47
+ }), []);
48
+
49
+ exports.useRefreshAuth = useRefreshAuth;
@@ -0,0 +1,8 @@
1
+ import { UserProfile } from '@dynamic-labs/types';
2
+ type RefreshAuthCallback = () => Promise<UserProfile | undefined>;
3
+ /**
4
+ * Refresh auth state
5
+ * @returns A callback function that can be used to refresh the auth state
6
+ */
7
+ export declare const useRefreshAuth: () => RefreshAuthCallback;
8
+ export {};