@dynamic-labs/sdk-react-core 4.36.0 → 4.37.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 (73) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +12 -12
  5. package/src/index.cjs +2 -0
  6. package/src/index.d.ts +1 -1
  7. package/src/index.js +1 -0
  8. package/src/lib/client/extension/deprecated/mfa/verifyTotpMfaDevice/verifyTotpMfaDevice.d.ts +1 -1
  9. package/src/lib/client/extension/projectSettings/getProjectSettings/getProjectSettings.d.ts +2 -1
  10. package/src/lib/client/extension/projectSettings/useProjectSettings/useProjectSettings.d.ts +2 -1
  11. package/src/lib/client/extension/projectSettings/useRefetchProjectSettings/useRefetchProjectSettings.d.ts +2 -1
  12. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +3 -1
  13. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +3 -1
  14. package/src/lib/context/SocialRedirectContext/utils/getDynamicRedirectData/getDynamicRedirectData.d.ts +1 -0
  15. package/src/lib/context/SocialRedirectContext/utils/getDynamicRedirectDataFromUrl/getDynamicRedirectDataFromUrl.cjs +2 -1
  16. package/src/lib/context/SocialRedirectContext/utils/getDynamicRedirectDataFromUrl/getDynamicRedirectDataFromUrl.d.ts +1 -0
  17. package/src/lib/context/SocialRedirectContext/utils/getDynamicRedirectDataFromUrl/getDynamicRedirectDataFromUrl.js +2 -1
  18. package/src/lib/data/api/oauth/oauth.cjs +2 -1
  19. package/src/lib/data/api/oauth/oauth.d.ts +1 -1
  20. package/src/lib/data/api/oauth/oauth.js +2 -1
  21. package/src/lib/locale/en/translation.cjs +26 -3
  22. package/src/lib/locale/en/translation.d.ts +25 -2
  23. package/src/lib/locale/en/translation.js +26 -3
  24. package/src/lib/shared/assets/connect.cjs +57 -0
  25. package/src/lib/shared/assets/connect.js +33 -0
  26. package/src/lib/shared/assets/index.d.ts +1 -0
  27. package/src/lib/styles/index.shadow.cjs +1 -1
  28. package/src/lib/styles/index.shadow.js +1 -1
  29. package/src/lib/utils/constants/authViewLayoutChecks.cjs +1 -0
  30. package/src/lib/utils/constants/authViewLayoutChecks.js +1 -0
  31. package/src/lib/utils/constants/index.d.ts +1 -1
  32. package/src/lib/utils/constants/localStorage.cjs +3 -0
  33. package/src/lib/utils/constants/localStorage.d.ts +4 -0
  34. package/src/lib/utils/constants/localStorage.js +3 -1
  35. package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.cjs +47 -0
  36. package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.d.ts +26 -0
  37. package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.js +41 -0
  38. package/src/lib/utils/functions/getTransactionLink/getTransactionLink.cjs +5 -3
  39. package/src/lib/utils/functions/getTransactionLink/getTransactionLink.js +5 -3
  40. package/src/lib/utils/functions/socialStorage/socialStorage.d.ts +2 -0
  41. package/src/lib/utils/hooks/index.d.ts +1 -0
  42. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +5 -2
  43. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +4 -1
  44. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +5 -2
  45. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +7 -0
  46. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +7 -0
  47. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +59 -5
  48. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.d.ts +12 -1
  49. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +59 -5
  50. package/src/lib/views/WalletDelegation/WalletDelegationView/AgreementSection.cjs +28 -0
  51. package/src/lib/views/WalletDelegation/WalletDelegationView/AgreementSection.d.ts +9 -0
  52. package/src/lib/views/WalletDelegation/WalletDelegationView/AgreementSection.js +24 -0
  53. package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.cjs +144 -104
  54. package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.d.ts +7 -1
  55. package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.js +146 -106
  56. package/src/lib/views/viewToComponentMap.d.ts +3 -1
  57. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +2 -0
  58. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +4 -1
  59. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +2 -0
  60. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +1 -1
  61. package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/ConnectedAppsView.cjs +2 -6
  62. package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/ConnectedAppsView.js +2 -6
  63. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +17 -1
  64. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +17 -1
  65. package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.cjs +149 -0
  66. package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.d.ts +12 -0
  67. package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.js +144 -0
  68. package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/index.d.ts +1 -0
  69. package/src/lib/widgets/DynamicWidget/views/index.d.ts +1 -0
  70. package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/EmbeddedDelegatedSection/EmbeddedDelegatedSection.cjs +0 -34
  71. package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/EmbeddedDelegatedSection/EmbeddedDelegatedSection.d.ts +0 -2
  72. package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/EmbeddedDelegatedSection/EmbeddedDelegatedSection.js +0 -30
  73. package/src/lib/widgets/DynamicWidget/views/ConnectedAppsView/EmbeddedDelegatedSection/index.d.ts +0 -1
@@ -103,6 +103,7 @@ const viewsThatPreventModalClose = [
103
103
  'login-with-sms-verification',
104
104
  'backup-unsuccessful',
105
105
  'wallet-upgrade-flow-view',
106
+ 'wallet-delegation-view',
106
107
  ];
107
108
  /**
108
109
  * When hasPendingMfaAction returns true, user is not able to close the modal in these views at all
@@ -99,6 +99,7 @@ const viewsThatPreventModalClose = [
99
99
  'login-with-sms-verification',
100
100
  'backup-unsuccessful',
101
101
  'wallet-upgrade-flow-view',
102
+ 'wallet-delegation-view',
102
103
  ];
103
104
  /**
104
105
  * When hasPendingMfaAction returns true, user is not able to close the modal in these views at all
@@ -1,4 +1,4 @@
1
- export { STORE_STORAGE_KEY, LAST_USED_WALLET, NETWORKS_STORAGE_KEY, THEME, WALLET_PICKER_SEARCH_KEY, EXCHANGE_PICKER_SEARCH_KEY, PHANTOM_SIGNATURE_STATE, DEVICE_FINGERPRINT, } from './localStorage';
1
+ export { STORE_STORAGE_KEY, LAST_USED_WALLET, NETWORKS_STORAGE_KEY, THEME, WALLET_PICKER_SEARCH_KEY, EXCHANGE_PICKER_SEARCH_KEY, PHANTOM_SIGNATURE_STATE, DEVICE_FINGERPRINT, DELEGATION_DENIED_WALLET_IDS, DELEGATION_PROMPT_DISMISSED, DELEGATION_COMPLETED_WALLET_IDS, DELEGATION_STATE, } from './localStorage';
2
2
  export { BASE_LIGHT_1, BASE_LIGHT_2, BASE_LIGHT_3, BASE_LIGHT_4, BASE_LIGHT_5, BASE_DARK_5, TEXT_LIGHT_PRIMARY, TEXT_LIGHT_SECONDARY, TEXT_LIGHT_TERTIARY, TEXT_LIGHT_LINK, CONNECTION_LIGHT_GREEN, CONNECTION_LIGHT_ORANGE, ERROR_LIGHT_1, ERROR_LIGHT_2, OVERLAY_LIGHT, HOVER_LIGHT, LOADING_ANIMATION_GRADIENT_LIGHT, BASE_DARK_1, BASE_DARK_2, BASE_DARK_3, BASE_DARK_4, DYNAMIC_CONNECT_BUTTON_BACKGROUND, DYNAMIC_CONNECT_BUTTON_BORDER, DYNAMIC_CONNECT_BUTTON_COLOR, TEXT_DARK_PRIMARY, TEXT_DARK_SECONDARY, TEXT_DARK_TERTIARY, TEXT_DARK_LINK, BRAND_HOVER, BRAND_PRIMARY, BRAND_SECONDARY, CONNECTION_DARK_GREEN, CONNECTION_DARK_ORANGE, ERROR_DARK_1, ERROR_DARK_2, OVERLAY_DARK, HOVER_DARK, LOADING_ANIMATION_GRADIENT_DARK, SHADOW_DOWN_1, SHADOW_DOWN_2, SHADOW_DOWN_3, SHADOW_UP_1, BRAND_HOVER_COLOR, BRAND_PRIMARY_COLOR, BRAND_SECONDARY_COLOR, } from './colors';
3
3
  export { BORDER_SQUARE, BORDER_ROUNDED, BORDER_RADIUS } from './theme';
4
4
  export { TITLE, BODY_NORMAL, BODY_SMALL, BODY_MINI, BUTTON_PRIMARY, BUTTON_SECONDARY, NUMBERS_BIG, NUMBERS_MEDIUM, } from './typography';
@@ -20,6 +20,8 @@ const CAPTCHA_TOKEN = 'dynamic_captcha_token';
20
20
  * Used to identify the purpose of a signature after phantom redirects back to the app in mobile
21
21
  */
22
22
  const PHANTOM_SIGNATURE_STATE = 'phantom_verification_type';
23
+ // Wallet Delegation: unified state container for delegation flow
24
+ const DELEGATION_STATE = 'dynamic_delegation_state';
23
25
  const STORE_STORAGE_KEY = 'dynamic_store';
24
26
  const SECURE_ENCLAVE_WALLET_SESSION_KEYS = 'dynamic_secure_enclave_session_keys';
25
27
  const SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS = {
@@ -29,6 +31,7 @@ const SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS = {
29
31
  exports.BRIDGE_ONBOARDING_COMPLETED = BRIDGE_ONBOARDING_COMPLETED;
30
32
  exports.CAPTCHA_TOKEN = CAPTCHA_TOKEN;
31
33
  exports.CONNECTED_WALLET_NAME_SERVICE = CONNECTED_WALLET_NAME_SERVICE;
34
+ exports.DELEGATION_STATE = DELEGATION_STATE;
32
35
  exports.DEVICE_FINGERPRINT = DEVICE_FINGERPRINT;
33
36
  exports.DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS = DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS;
34
37
  exports.EMBEDDED_WALLET_SECURE_BANNER = EMBEDDED_WALLET_SECURE_BANNER;
@@ -27,6 +27,10 @@ export type PhantomSignatureState = {
27
27
  * Used to identify the purpose of a signature after phantom redirects back to the app in mobile
28
28
  */
29
29
  export declare const PHANTOM_SIGNATURE_STATE = "phantom_verification_type";
30
+ export declare const DELEGATION_DENIED_WALLET_IDS = "dynamic_delegation_denied_wallet_ids";
31
+ export declare const DELEGATION_PROMPT_DISMISSED = "dynamic_delegation_prompt_dismissed";
32
+ export declare const DELEGATION_COMPLETED_WALLET_IDS = "dynamic_delegation_completed_wallet_ids";
33
+ export declare const DELEGATION_STATE = "dynamic_delegation_state";
30
34
  export declare const STORE_STORAGE_KEY = "dynamic_store";
31
35
  export declare const IP_LOOKUP_STORAGE_KEY = "dynamic_ip_lookup";
32
36
  export declare const SECURE_ENCLAVE_WALLET_SESSION_KEYS = "dynamic_secure_enclave_session_keys";
@@ -16,10 +16,12 @@ const CAPTCHA_TOKEN = 'dynamic_captcha_token';
16
16
  * Used to identify the purpose of a signature after phantom redirects back to the app in mobile
17
17
  */
18
18
  const PHANTOM_SIGNATURE_STATE = 'phantom_verification_type';
19
+ // Wallet Delegation: unified state container for delegation flow
20
+ const DELEGATION_STATE = 'dynamic_delegation_state';
19
21
  const STORE_STORAGE_KEY = 'dynamic_store';
20
22
  const SECURE_ENCLAVE_WALLET_SESSION_KEYS = 'dynamic_secure_enclave_session_keys';
21
23
  const SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS = {
22
24
  priority: ['secureStorage', 'localStorage'],
23
25
  };
24
26
 
25
- export { BRIDGE_ONBOARDING_COMPLETED, CAPTCHA_TOKEN, CONNECTED_WALLET_NAME_SERVICE, DEVICE_FINGERPRINT, DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, EMBEDDED_WALLET_SECURE_BANNER, EMBEDDED_WALLET_SESSION_SETTINGS, EXCHANGE_PICKER_SEARCH_KEY, LAST_USED_WALLET, NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY, PHANTOM_SIGNATURE_STATE, PHONE_INPUT_DEFAULT_COUNTRY, SECURE_ENCLAVE_WALLET_SESSION_KEYS, SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS, STORE_STORAGE_KEY, WAGMI_LAST_SESSION_SETTINGS, WALLET_PICKER_SEARCH_KEY };
27
+ export { BRIDGE_ONBOARDING_COMPLETED, CAPTCHA_TOKEN, CONNECTED_WALLET_NAME_SERVICE, DELEGATION_STATE, DEVICE_FINGERPRINT, DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, EMBEDDED_WALLET_SECURE_BANNER, EMBEDDED_WALLET_SESSION_SETTINGS, EXCHANGE_PICKER_SEARCH_KEY, LAST_USED_WALLET, NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY, PHANTOM_SIGNATURE_STATE, PHONE_INPUT_DEFAULT_COUNTRY, SECURE_ENCLAVE_WALLET_SESSION_KEYS, SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS, STORE_STORAGE_KEY, WAGMI_LAST_SESSION_SETTINGS, WALLET_PICKER_SEARCH_KEY };
@@ -0,0 +1,47 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Block explorer URL patterns for different chains
8
+ * This mapping allows for easy configuration and extension of transaction link formats
9
+ */
10
+ /**
11
+ * Predefined patterns for known block explorers
12
+ * Add new patterns here as needed for different chains
13
+ */
14
+ const BLOCK_EXPLORER_PATTERNS = [
15
+ {
16
+ description: 'TRON - Uses hash fragment format',
17
+ domain: 'tronscan.org',
18
+ generateUrl: (baseUrl, hash) => {
19
+ const url = new URL(baseUrl);
20
+ return `${url.origin}/#/transaction/${hash}`;
21
+ },
22
+ },
23
+ ];
24
+ /**
25
+ * Default pattern for standard block explorers
26
+ * Used when no specific pattern matches
27
+ */
28
+ const DEFAULT_PATTERN = {
29
+ description: 'Standard format used by most block explorers',
30
+ domain: '*',
31
+ generateUrl: (baseUrl, hash) => {
32
+ const url = new URL(baseUrl);
33
+ url.pathname = `/tx/${hash}`;
34
+ return url.toString();
35
+ },
36
+ };
37
+ /**
38
+ * Find the appropriate pattern for a given block explorer URL
39
+ */
40
+ const findBlockExplorerPattern = (blockExplorerUrl) => {
41
+ const pattern = BLOCK_EXPLORER_PATTERNS.find((pattern) => blockExplorerUrl.includes(pattern.domain));
42
+ return pattern || DEFAULT_PATTERN;
43
+ };
44
+
45
+ exports.BLOCK_EXPLORER_PATTERNS = BLOCK_EXPLORER_PATTERNS;
46
+ exports.DEFAULT_PATTERN = DEFAULT_PATTERN;
47
+ exports.findBlockExplorerPattern = findBlockExplorerPattern;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Block explorer URL patterns for different chains
3
+ * This mapping allows for easy configuration and extension of transaction link formats
4
+ */
5
+ export interface BlockExplorerPattern {
6
+ /** Domain pattern to match against block explorer URLs */
7
+ domain: string;
8
+ /** Function to generate the transaction URL */
9
+ generateUrl: (baseUrl: string, transactionHash: string) => string;
10
+ /** Description of the pattern for documentation */
11
+ description: string;
12
+ }
13
+ /**
14
+ * Predefined patterns for known block explorers
15
+ * Add new patterns here as needed for different chains
16
+ */
17
+ export declare const BLOCK_EXPLORER_PATTERNS: BlockExplorerPattern[];
18
+ /**
19
+ * Default pattern for standard block explorers
20
+ * Used when no specific pattern matches
21
+ */
22
+ export declare const DEFAULT_PATTERN: BlockExplorerPattern;
23
+ /**
24
+ * Find the appropriate pattern for a given block explorer URL
25
+ */
26
+ export declare const findBlockExplorerPattern: (blockExplorerUrl: string) => BlockExplorerPattern;
@@ -0,0 +1,41 @@
1
+ 'use client'
2
+ /**
3
+ * Block explorer URL patterns for different chains
4
+ * This mapping allows for easy configuration and extension of transaction link formats
5
+ */
6
+ /**
7
+ * Predefined patterns for known block explorers
8
+ * Add new patterns here as needed for different chains
9
+ */
10
+ const BLOCK_EXPLORER_PATTERNS = [
11
+ {
12
+ description: 'TRON - Uses hash fragment format',
13
+ domain: 'tronscan.org',
14
+ generateUrl: (baseUrl, hash) => {
15
+ const url = new URL(baseUrl);
16
+ return `${url.origin}/#/transaction/${hash}`;
17
+ },
18
+ },
19
+ ];
20
+ /**
21
+ * Default pattern for standard block explorers
22
+ * Used when no specific pattern matches
23
+ */
24
+ const DEFAULT_PATTERN = {
25
+ description: 'Standard format used by most block explorers',
26
+ domain: '*',
27
+ generateUrl: (baseUrl, hash) => {
28
+ const url = new URL(baseUrl);
29
+ url.pathname = `/tx/${hash}`;
30
+ return url.toString();
31
+ },
32
+ };
33
+ /**
34
+ * Find the appropriate pattern for a given block explorer URL
35
+ */
36
+ const findBlockExplorerPattern = (blockExplorerUrl) => {
37
+ const pattern = BLOCK_EXPLORER_PATTERNS.find((pattern) => blockExplorerUrl.includes(pattern.domain));
38
+ return pattern || DEFAULT_PATTERN;
39
+ };
40
+
41
+ export { BLOCK_EXPLORER_PATTERNS, DEFAULT_PATTERN, findBlockExplorerPattern };
@@ -4,6 +4,7 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
+ var blockExplorerPatterns = require('./blockExplorerPatterns.cjs');
7
8
 
8
9
  const getTransactionLink = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletConnector, transactionHash, }) {
9
10
  try {
@@ -13,9 +14,10 @@ const getTransactionLink = (_a) => _tslib.__awaiter(void 0, [_a], void 0, functi
13
14
  const [blockExplorerUrl] = yield walletConnector.getBlockExplorerUrlsForCurrentNetwork();
14
15
  if (!blockExplorerUrl)
15
16
  return undefined;
16
- const url = new URL(blockExplorerUrl);
17
- url.pathname = `/tx/${transactionHash}`;
18
- return url.toString();
17
+ // Find the appropriate pattern for this block explorer
18
+ const pattern = blockExplorerPatterns.findBlockExplorerPattern(blockExplorerUrl);
19
+ // Generate the transaction URL using the pattern
20
+ return pattern.generateUrl(blockExplorerUrl, transactionHash);
19
21
  }
20
22
  catch (error) {
21
23
  return undefined;
@@ -1,5 +1,6 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
+ import { findBlockExplorerPattern } from './blockExplorerPatterns.js';
3
4
 
4
5
  const getTransactionLink = (_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, transactionHash, }) {
5
6
  try {
@@ -9,9 +10,10 @@ const getTransactionLink = (_a) => __awaiter(void 0, [_a], void 0, function* ({
9
10
  const [blockExplorerUrl] = yield walletConnector.getBlockExplorerUrlsForCurrentNetwork();
10
11
  if (!blockExplorerUrl)
11
12
  return undefined;
12
- const url = new URL(blockExplorerUrl);
13
- url.pathname = `/tx/${transactionHash}`;
14
- return url.toString();
13
+ // Find the appropriate pattern for this block explorer
14
+ const pattern = findBlockExplorerPattern(blockExplorerUrl);
15
+ // Generate the transaction URL using the pattern
16
+ return pattern.generateUrl(blockExplorerUrl, transactionHash);
15
17
  }
16
18
  catch (error) {
17
19
  return undefined;
@@ -4,6 +4,8 @@ import { PayWithDynamicProps } from '../../hooks/usePayWithDynamic/usePayWithDyn
4
4
  export declare const SOCIAL_STORAGE_KEY = "dynamic_social_storage";
5
5
  export type SocialStorageItem = {
6
6
  provider: ProviderEnum;
7
+ /** SSO provider id */
8
+ dynamicOauthSsoProviderId: string | undefined;
7
9
  /** State issued to IDP on social authentication */
8
10
  state: string;
9
11
  /** Code verifier used to generate the code challenge for PKCE */
@@ -95,3 +95,4 @@ export { usePromptMfaAuth } from './usePromptMfaAuth';
95
95
  export { useUpgradeToDynamicWaasFlow } from './useUpgradeToDynamicWaasFlow';
96
96
  export { useGetMfaToken } from './useGetMfaToken';
97
97
  export { useIsMfaRequiredForAction } from './useIsMfaRequiredForAction';
98
+ export { useWalletDelegation } from './useWalletDelegation';
@@ -207,7 +207,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
207
207
  verifyFunction: () => apiCall(),
208
208
  });
209
209
  }), [handleError, initAuth, onSettled]);
210
- const completeConnection = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, forceCreateUser = false, }) {
210
+ const completeConnection = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, forceCreateUser = false, ssoProviderId, }) {
211
211
  try {
212
212
  let sessionPublicKey = undefined;
213
213
  utils.tracing.logEvent('oauth', 'completeConnection', utils.tracing.formatObject({
@@ -245,6 +245,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
245
245
  code: authCode,
246
246
  codeVerifier: verifier,
247
247
  sessionPublicKey,
248
+ ssoProviderId,
248
249
  state,
249
250
  });
250
251
  yield signInAccount(provider, apiCall);
@@ -371,7 +372,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
371
372
  shouldRegisterSessionKeysOnSignin,
372
373
  signInAccount,
373
374
  ]);
374
- const connectSocialAccount = React.useCallback((_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ authMode, provider, validator, captchaToken, isHeadlessSocialSignIn, payingWithDynamic, triggerFundFromExchangeOnSuccess, redirectUrl, telegramAuthToken, showWidgetAfterConnection, }) {
375
+ const connectSocialAccount = React.useCallback((_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ authMode, provider, validator, captchaToken, isHeadlessSocialSignIn, payingWithDynamic, triggerFundFromExchangeOnSuccess, redirectUrl, telegramAuthToken, showWidgetAfterConnection, ssoProviderId, }) {
375
376
  var _e, _f;
376
377
  clearError();
377
378
  setIsProcessing(true);
@@ -404,6 +405,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
404
405
  socialStorage.setSocialStorageFor(provider, {
405
406
  captchaToken,
406
407
  codeVerifier: usingPkce ? verifier : undefined,
408
+ dynamicOauthSsoProviderId: ssoProviderId,
407
409
  isHeadlessSocialSignIn,
408
410
  mode: authMode,
409
411
  payingWithDynamic,
@@ -451,6 +453,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
451
453
  authMode,
452
454
  captchaToken,
453
455
  provider,
456
+ ssoProviderId,
454
457
  state,
455
458
  telegramAuthToken,
456
459
  verifier,
@@ -20,10 +20,12 @@ export type ConnectSocialAccountProps = {
20
20
  payingWithDynamic?: PayWithDynamicProps;
21
21
  /** marks the flow as initiated by headless sign-in API */
22
22
  isHeadlessSocialSignIn?: boolean;
23
+ /** SSO provider ID for social authentication */
24
+ ssoProviderId?: string;
23
25
  };
24
26
  export declare const useSocialAuth: ({ onSettled, onError, onFarcasterUrl, }: UseSocialAuthProps) => {
25
27
  readonly checkValidProvider: (provider: ProviderEnum, authMode: SocialAuthMode) => boolean;
26
- readonly completeConnection: ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, forceCreateUser, }: {
28
+ readonly completeConnection: ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, forceCreateUser, ssoProviderId, }: {
27
29
  authMode: SocialAuthMode;
28
30
  provider: ProviderEnum;
29
31
  state: string;
@@ -32,6 +34,7 @@ export declare const useSocialAuth: ({ onSettled, onError, onFarcasterUrl, }: Us
32
34
  verifier?: string | undefined;
33
35
  telegramAuthToken?: string | undefined;
34
36
  forceCreateUser?: boolean | undefined;
37
+ ssoProviderId?: string | undefined;
35
38
  }) => Promise<void>;
36
39
  readonly connectSocialAccount: (props: ConnectSocialAccountProps) => Promise<void>;
37
40
  readonly error: SocialOAuthError | undefined;
@@ -203,7 +203,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
203
203
  verifyFunction: () => apiCall(),
204
204
  });
205
205
  }), [handleError, initAuth$1, onSettled]);
206
- const completeConnection = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, forceCreateUser = false, }) {
206
+ const completeConnection = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, forceCreateUser = false, ssoProviderId, }) {
207
207
  try {
208
208
  let sessionPublicKey = undefined;
209
209
  tracing.logEvent('oauth', 'completeConnection', tracing.formatObject({
@@ -241,6 +241,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
241
241
  code: authCode,
242
242
  codeVerifier: verifier,
243
243
  sessionPublicKey,
244
+ ssoProviderId,
244
245
  state,
245
246
  });
246
247
  yield signInAccount(provider, apiCall);
@@ -367,7 +368,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
367
368
  shouldRegisterSessionKeysOnSignin,
368
369
  signInAccount,
369
370
  ]);
370
- const connectSocialAccount = useCallback((_d) => __awaiter(void 0, [_d], void 0, function* ({ authMode, provider, validator, captchaToken, isHeadlessSocialSignIn, payingWithDynamic, triggerFundFromExchangeOnSuccess, redirectUrl, telegramAuthToken, showWidgetAfterConnection, }) {
371
+ const connectSocialAccount = useCallback((_d) => __awaiter(void 0, [_d], void 0, function* ({ authMode, provider, validator, captchaToken, isHeadlessSocialSignIn, payingWithDynamic, triggerFundFromExchangeOnSuccess, redirectUrl, telegramAuthToken, showWidgetAfterConnection, ssoProviderId, }) {
371
372
  var _e, _f;
372
373
  clearError();
373
374
  setIsProcessing(true);
@@ -400,6 +401,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
400
401
  setSocialStorageFor(provider, {
401
402
  captchaToken,
402
403
  codeVerifier: usingPkce ? verifier : undefined,
404
+ dynamicOauthSsoProviderId: ssoProviderId,
403
405
  isHeadlessSocialSignIn,
404
406
  mode: authMode,
405
407
  payingWithDynamic,
@@ -447,6 +449,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
447
449
  authMode,
448
450
  captchaToken,
449
451
  provider,
452
+ ssoProviderId,
450
453
  state,
451
454
  telegramAuthToken,
452
455
  verifier,
@@ -93,6 +93,7 @@ require('../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cj
93
93
  require('../../../context/PasskeyContext/PasskeyContext.cjs');
94
94
  require('../../../context/OnrampContext/OnrampContext.cjs');
95
95
  var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
96
+ var useWalletDelegation = require('../useWalletDelegation/useWalletDelegation.cjs');
96
97
  require('../../../store/state/sendBalances.cjs');
97
98
  require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
98
99
  require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
@@ -208,6 +209,7 @@ const useSyncDynamicWaas = () => {
208
209
  const validateWalletCreation = useWalletCreationValidation();
209
210
  const { mutate: createWallets, isLoading: isCreatingWallets } = useWalletCreation();
210
211
  const { mutate: processSettings, isLoading: isProcessingSettings } = useWalletSettingsProcessor();
212
+ const { initDelegationProcess, shouldPromptWalletDelegation } = useWalletDelegation.useWalletDelegation();
211
213
  const triggeredCreate = React.useRef(false);
212
214
  const triggeredSettingsProcessing = React.useRef(false);
213
215
  useDynamicEvents.useInternalDynamicEvents('logout', () => {
@@ -264,6 +266,11 @@ const useSyncDynamicWaas = () => {
264
266
  handleWalletCreation();
265
267
  }
266
268
  }, [shouldCreateWallets, handleWalletCreation]);
269
+ React.useEffect(() => {
270
+ if (shouldPromptWalletDelegation()) {
271
+ initDelegationProcess();
272
+ }
273
+ }, [shouldPromptWalletDelegation, initDelegationProcess]);
267
274
  };
268
275
 
269
276
  exports.useSyncDynamicWaas = useSyncDynamicWaas;
@@ -89,6 +89,7 @@ import '../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js'
89
89
  import '../../../context/PasskeyContext/PasskeyContext.js';
90
90
  import '../../../context/OnrampContext/OnrampContext.js';
91
91
  import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
92
+ import { useWalletDelegation } from '../useWalletDelegation/useWalletDelegation.js';
92
93
  import '../../../store/state/sendBalances.js';
93
94
  import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
94
95
  import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
@@ -204,6 +205,7 @@ const useSyncDynamicWaas = () => {
204
205
  const validateWalletCreation = useWalletCreationValidation();
205
206
  const { mutate: createWallets, isLoading: isCreatingWallets } = useWalletCreation();
206
207
  const { mutate: processSettings, isLoading: isProcessingSettings } = useWalletSettingsProcessor();
208
+ const { initDelegationProcess, shouldPromptWalletDelegation } = useWalletDelegation();
207
209
  const triggeredCreate = useRef(false);
208
210
  const triggeredSettingsProcessing = useRef(false);
209
211
  useInternalDynamicEvents('logout', () => {
@@ -260,6 +262,11 @@ const useSyncDynamicWaas = () => {
260
262
  handleWalletCreation();
261
263
  }
262
264
  }, [shouldCreateWallets, handleWalletCreation]);
265
+ useEffect(() => {
266
+ if (shouldPromptWalletDelegation()) {
267
+ initDelegationProcess();
268
+ }
269
+ }, [shouldPromptWalletDelegation, initDelegationProcess]);
263
270
  };
264
271
 
265
272
  export { useSyncDynamicWaas };
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
7
  var React = require('react');
8
+ var utils = require('@dynamic-labs/utils');
8
9
  require('../../../context/DynamicContext/DynamicContext.cjs');
9
10
  require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
10
11
  require('@dynamic-labs/iconic');
@@ -13,7 +14,7 @@ require('react/jsx-runtime');
13
14
  var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
14
15
  require('../../../shared/logger.cjs');
15
16
  require('@dynamic-labs/wallet-book');
16
- require('@dynamic-labs/utils');
17
+ var localStorage = require('../../constants/localStorage.cjs');
17
18
  require('../../constants/colors.cjs');
18
19
  require('../../constants/values.cjs');
19
20
  require('@dynamic-labs/sdk-api-core');
@@ -29,13 +30,14 @@ require('@dynamic-labs-sdk/client/core');
29
30
  require('../../../client/client.cjs');
30
31
  require('@dynamic-labs-sdk/client');
31
32
  require('../../../config/ApiEndpoint.cjs');
33
+ var useProjectSettings = require('../../../client/extension/projectSettings/useProjectSettings/useProjectSettings.cjs');
32
34
  require('../../../locale/locale.cjs');
33
35
  require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
34
36
  require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
35
37
  require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
36
38
  require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
37
39
  require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
38
- require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
40
+ var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
39
41
  require('../../../store/state/authMode/authMode.cjs');
40
42
  require('../../../context/VerificationContext/VerificationContext.cjs');
41
43
  require('react-dom');
@@ -104,9 +106,35 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
104
106
 
105
107
  // Hook to trigger wallet delegation modal
106
108
  const useWalletDelegation = () => {
109
+ var _a, _b, _c;
107
110
  const { primaryWallet, user, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
111
+ const { userWallets } = UserWalletsContext.useInternalUserWallets();
108
112
  const { pushView } = ViewContext.useViewContext();
109
- const initDelegationProcess = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
113
+ const projectSettings = useProjectSettings.useProjectSettings();
114
+ const waasSettings = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.waas;
115
+ const delegatedAccessEnabled = (_a = waasSettings === null || waasSettings === void 0 ? void 0 : waasSettings.delegatedAccess) === null || _a === void 0 ? void 0 : _a.enabled;
116
+ const promptUsersOnSignIn = (_b = waasSettings === null || waasSettings === void 0 ? void 0 : waasSettings.delegatedAccess) === null || _b === void 0 ? void 0 : _b.promptUsersOnSignIn;
117
+ const requiresDelegation = (_c = waasSettings === null || waasSettings === void 0 ? void 0 : waasSettings.delegatedAccess) === null || _c === void 0 ? void 0 : _c.requiresDelegation;
118
+ const shouldPromptWalletDelegation = React.useCallback(() => {
119
+ var _a, _b;
120
+ if (!delegatedAccessEnabled || !promptUsersOnSignIn) {
121
+ return false;
122
+ }
123
+ // If the prompt was dismissed, do not show again until logout
124
+ // Unified state first, then legacy dismissed flag
125
+ const state = utils.StorageService.getItem(localStorage.DELEGATION_STATE);
126
+ const dismissed = state === null || state === void 0 ? void 0 : state.dismissed;
127
+ if (dismissed) {
128
+ return false;
129
+ }
130
+ const userId = (user === null || user === void 0 ? void 0 : user.userId) || 'anonymous';
131
+ const deniedForUser = new Set(((_a = state === null || state === void 0 ? void 0 : state.denied) === null || _a === void 0 ? void 0 : _a[userId]) || []);
132
+ const completedForUser = new Set(((_b = state === null || state === void 0 ? void 0 : state.completed) === null || _b === void 0 ? void 0 : _b[userId]) || []);
133
+ const waasWallets = userWallets.filter((wallet) => wallet.connector.key.startsWith('dynamicwaas'));
134
+ const hasUndeniedWaasWallet = waasWallets.some((wallet) => !deniedForUser.has(wallet.id) && !completedForUser.has(wallet.id));
135
+ return hasUndeniedWaasWallet;
136
+ }, [user === null || user === void 0 ? void 0 : user.userId, userWallets, delegatedAccessEnabled, promptUsersOnSignIn]);
137
+ const initDelegationProcess = React.useCallback((options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
110
138
  if (!primaryWallet) {
111
139
  throw new Error('No primary wallet');
112
140
  }
@@ -118,15 +146,41 @@ const useWalletDelegation = () => {
118
146
  ignoreIfIsEmbeddedWidget: false,
119
147
  performMultiWalletChecks: false,
120
148
  });
121
- // Push the wallet delegation view
122
- pushView('wallet-delegation-view', {});
149
+ // Push the wallet delegation view with optional wallets override
150
+ pushView('wallet-delegation-view', {
151
+ wallets: options === null || options === void 0 ? void 0 : options.wallets,
152
+ });
123
153
  return new Promise((resolve, reject) => {
124
154
  dynamicEvents.dynamicEvents.once('embeddedWalletDelegationCompleted', () => resolve());
125
155
  dynamicEvents.dynamicEvents.once('embeddedWalletDelegationFailed', (error) => reject(error));
126
156
  });
127
157
  }), [primaryWallet, setShowAuthFlow, pushView, user]);
158
+ const getWalletsDelegatedStatus = React.useCallback(() => {
159
+ var _a, _b;
160
+ if (!primaryWallet) {
161
+ return [];
162
+ }
163
+ const state = utils.StorageService.getItem(localStorage.DELEGATION_STATE);
164
+ const userId = (user === null || user === void 0 ? void 0 : user.userId) || 'anonymous';
165
+ const completedForUser = new Set(((_a = state === null || state === void 0 ? void 0 : state.completed) === null || _a === void 0 ? void 0 : _a[userId]) || []);
166
+ const deniedForUser = new Set(((_b = state === null || state === void 0 ? void 0 : state.denied) === null || _b === void 0 ? void 0 : _b[userId]) || []);
167
+ return userWallets.map((wallet) => {
168
+ let status = 'pending';
169
+ if (completedForUser.has(wallet.id)) {
170
+ status = 'delegated';
171
+ }
172
+ else if (deniedForUser.has(wallet.id)) {
173
+ status = 'denied';
174
+ }
175
+ return Object.assign(Object.assign({}, wallet), { status });
176
+ });
177
+ }, [primaryWallet, user === null || user === void 0 ? void 0 : user.userId, userWallets]);
128
178
  return {
179
+ delegatedAccessEnabled,
180
+ getWalletsDelegatedStatus,
129
181
  initDelegationProcess,
182
+ requiresDelegation,
183
+ shouldPromptWalletDelegation,
130
184
  };
131
185
  };
132
186
 
@@ -1,3 +1,14 @@
1
+ import { Wallet } from '../../../shared';
2
+ export type WalletDelegationStatus = 'delegated' | 'denied' | 'pending';
3
+ export type WalletWithStatus = Wallet & {
4
+ status: WalletDelegationStatus;
5
+ };
1
6
  export declare const useWalletDelegation: () => {
2
- readonly initDelegationProcess: () => Promise<void>;
7
+ readonly delegatedAccessEnabled: boolean | undefined;
8
+ readonly getWalletsDelegatedStatus: () => WalletWithStatus[];
9
+ readonly initDelegationProcess: (options?: {
10
+ wallets?: Wallet[];
11
+ }) => Promise<void>;
12
+ readonly requiresDelegation: boolean | undefined;
13
+ readonly shouldPromptWalletDelegation: () => boolean;
3
14
  };