@dynamic-labs/sdk-react-core 4.64.0 → 4.66.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 (77) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +13 -13
  5. package/src/index.cjs +4 -0
  6. package/src/index.d.ts +2 -1
  7. package/src/index.js +2 -0
  8. package/src/lib/Main.cjs +1 -0
  9. package/src/lib/Main.js +1 -0
  10. package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.cjs +1 -1
  11. package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.d.ts +5 -1
  12. package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.js +1 -1
  13. package/src/lib/components/ShadowDOM/ShadowDOM.cjs +6 -6
  14. package/src/lib/components/ShadowDOM/ShadowDOM.d.ts +4 -1
  15. package/src/lib/components/ShadowDOM/ShadowDOM.js +6 -6
  16. package/src/lib/context/DynamicContext/DynamicContext.cjs +4 -2
  17. package/src/lib/context/DynamicContext/DynamicContext.js +4 -2
  18. package/src/lib/context/DynamicContext/types/DynamicContextProps.d.ts +6 -0
  19. package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +1 -0
  20. package/src/lib/context/DynamicContext/types/IInternalDynamicContext.d.ts +5 -1
  21. package/src/lib/context/ThemeContext/ThemeContext.cjs +3 -3
  22. package/src/lib/context/ThemeContext/ThemeContext.d.ts +1 -0
  23. package/src/lib/context/ThemeContext/ThemeContext.js +3 -3
  24. package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.cjs +8 -2
  25. package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.d.ts +2 -2
  26. package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.js +8 -2
  27. package/src/lib/data/api/wallets/wallets.cjs +62 -11
  28. package/src/lib/data/api/wallets/wallets.d.ts +1 -0
  29. package/src/lib/data/api/wallets/wallets.js +62 -12
  30. package/src/lib/shared/types/connectionAndSignature.d.ts +2 -1
  31. package/src/lib/shared/types/wallets.d.ts +2 -1
  32. package/src/lib/utils/functions/compareChains/compareChains.cjs +1 -0
  33. package/src/lib/utils/functions/compareChains/compareChains.js +1 -0
  34. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +6 -5
  35. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +3 -1
  36. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +6 -5
  37. package/src/lib/utils/hooks/index.d.ts +3 -0
  38. package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +4 -1
  39. package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +4 -1
  40. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +5 -2
  41. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +2 -0
  42. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +5 -2
  43. package/src/lib/utils/hooks/useSignEip7702Authorization/index.d.ts +1 -0
  44. package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.cjs +162 -0
  45. package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.d.ts +78 -0
  46. package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.js +158 -0
  47. package/src/lib/utils/hooks/useStepUpAuthentication/index.d.ts +2 -0
  48. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.cjs +197 -0
  49. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.d.ts +51 -0
  50. package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.js +193 -0
  51. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +3 -1
  52. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +3 -1
  53. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +8 -3
  54. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.d.ts +1 -1
  55. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +9 -4
  56. package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.cjs +53 -1
  57. package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.d.ts +6 -0
  58. package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.js +53 -1
  59. package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs +1 -1
  60. package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js +1 -1
  61. package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.cjs +5 -21
  62. package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.js +5 -21
  63. package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.cjs +9 -1
  64. package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.js +9 -1
  65. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +17 -21
  66. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +17 -21
  67. package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.cjs +26 -5
  68. package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.js +26 -5
  69. package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.cjs +3 -2
  70. package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.d.ts +2 -0
  71. package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.js +3 -2
  72. package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.cjs +2 -2
  73. package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.d.ts +2 -0
  74. package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.js +2 -2
  75. package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.cjs +30 -22
  76. package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.d.ts +2 -1
  77. package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.js +30 -22
@@ -0,0 +1,162 @@
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 utils = require('@dynamic-labs/utils');
9
+ require('../../../context/DynamicContext/DynamicContext.cjs');
10
+ require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
11
+ require('@dynamic-labs/iconic');
12
+ require('@dynamic-labs/wallet-connector-core');
13
+ require('react/jsx-runtime');
14
+ require('../../../context/ViewContext/ViewContext.cjs');
15
+ require('../../../shared/logger.cjs');
16
+ require('@dynamic-labs/wallet-book');
17
+ require('../../constants/colors.cjs');
18
+ require('../../constants/values.cjs');
19
+ require('@dynamic-labs/sdk-api-core');
20
+ require('../../../shared/consts/index.cjs');
21
+ require('../../../events/dynamicEvents.cjs');
22
+ require('../../../context/CaptchaContext/CaptchaContext.cjs');
23
+ require('../../../context/ErrorContext/ErrorContext.cjs');
24
+ require('@dynamic-labs/multi-wallet');
25
+ require('react-international-phone');
26
+ require('../../../store/state/nonce/nonce.cjs');
27
+ require('@dynamic-labs-sdk/client/core');
28
+ require('../../../client/client.cjs');
29
+ require('@dynamic-labs-sdk/client');
30
+ require('../../../config/ApiEndpoint.cjs');
31
+ require('@dynamic-labs/locale');
32
+ require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
33
+ require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
34
+ require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
35
+ require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
36
+ require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
37
+ require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
38
+ require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
39
+ require('../../../store/state/authMode/authMode.cjs');
40
+ require('../../../context/VerificationContext/VerificationContext.cjs');
41
+ require('react-dom');
42
+ require('../../functions/compareChains/compareChains.cjs');
43
+ require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
44
+ require('../../../context/ThemeContext/ThemeContext.cjs');
45
+ require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
46
+ require('bs58');
47
+ require('@dynamic-labs/types');
48
+ require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
49
+ require('../../../context/LoadingContext/LoadingContext.cjs');
50
+ require('../../../context/WalletContext/WalletContext.cjs');
51
+ require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
52
+ require('yup');
53
+ require('../../../context/MockContext/MockContext.cjs');
54
+ require('../../../views/CollectUserDataView/useFields.cjs');
55
+ require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
56
+ require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
57
+ require('@dynamic-labs/rpc-providers');
58
+ require('../../../store/state/walletOptions/walletOptions.cjs');
59
+ require('react-i18next');
60
+ require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
61
+ require('../../../components/Alert/Alert.cjs');
62
+ require('../../../components/ShadowDOM/ShadowDOM.cjs');
63
+ require('../../../components/IconButton/IconButton.cjs');
64
+ require('../../../components/InlineWidget/InlineWidget.cjs');
65
+ require('../../../components/Input/Input.cjs');
66
+ require('../../../components/IsBrowser/IsBrowser.cjs');
67
+ require('../../../components/MenuList/Dropdown/Dropdown.cjs');
68
+ require('../../../components/OverlayCard/OverlayCard.cjs');
69
+ require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
70
+ require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
71
+ require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
72
+ require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
73
+ require('../../../components/Popper/Popper/Popper.cjs');
74
+ require('../../../components/Popper/PopperContext/PopperContext.cjs');
75
+ require('react-focus-lock');
76
+ require('qrcode');
77
+ require('formik');
78
+ require('../useSubdomainCheck/useSubdomainCheck.cjs');
79
+ require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
80
+ require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
81
+ require('../useWalletBackup/useWalletBackup.cjs');
82
+ require('../useWalletBackup/types.cjs');
83
+ require('../useWalletBackup/cloudProviders.cjs');
84
+ require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
85
+ require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
86
+ require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
87
+ require('@hcaptcha/react-hcaptcha');
88
+ require('../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.cjs');
89
+ require('../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
90
+ require('../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
91
+ require('../../../context/FooterAnimationContext/index.cjs');
92
+ require('../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
93
+ require('../../../context/PasskeyContext/PasskeyContext.cjs');
94
+ require('../../../context/OnrampContext/OnrampContext.cjs');
95
+ require('../../../store/state/sendBalances.cjs');
96
+ require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
97
+ require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
98
+ require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
99
+ require('../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
100
+ require('../../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.cjs');
101
+ require('../../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.cjs');
102
+ require('../../../../index.cjs');
103
+ require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
104
+ require('../../../store/state/tokenBalances.cjs');
105
+ require('../../../store/state/multichainBalances.cjs');
106
+ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
107
+ var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
108
+
109
+ /**
110
+ * Hook for signing EIP-7702 authorizations for ZeroDev kernel delegation.
111
+ *
112
+ * This hook provides a way to sign EIP-7702 authorizations that enable
113
+ * single-use MFA flows where the authorization signing step is separated
114
+ * from the transaction execution step.
115
+ *
116
+ * The signed authorization can be passed to kernel account client creation
117
+ * functions like `createEcdsaKernelAccountClientWith7702`.
118
+ *
119
+ * @returns An object containing the `signEip7702Authorization` function
120
+ *
121
+ * @example
122
+ * ```tsx
123
+ * import { useSignEip7702Authorization } from '@dynamic-labs/sdk-react-core';
124
+ *
125
+ * function MyComponent() {
126
+ * const { signEip7702Authorization } = useSignEip7702Authorization();
127
+ *
128
+ * const handleSign = async () => {
129
+ * try {
130
+ * const auth = await signEip7702Authorization();
131
+ * console.log('Signed authorization:', auth);
132
+ * // Use auth with kernel client creation
133
+ * } catch (error) {
134
+ * console.error('Failed to sign authorization:', error);
135
+ * }
136
+ * };
137
+ *
138
+ * return <button onClick={handleSign}>Sign Authorization</button>;
139
+ * }
140
+ * ```
141
+ */
142
+ const useSignEip7702Authorization = () => {
143
+ const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
144
+ const signEip7702Auth = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
145
+ var _a;
146
+ const { wallet: providedWallet, chainId: providedChainId } = params !== null && params !== void 0 ? params : {};
147
+ // Use provided wallet or fallback to primary wallet
148
+ const wallet = providedWallet !== null && providedWallet !== void 0 ? providedWallet : primaryWallet;
149
+ if (!wallet) {
150
+ throw new utils.DynamicError('No wallet available. Please connect a wallet first.');
151
+ }
152
+ if (((_a = wallet.connector) === null || _a === void 0 ? void 0 : _a.key) !== 'zerodev') {
153
+ throw new utils.DynamicError('The wallet connector must be a ZeroDev connector to sign EIP-7702 authorizations.');
154
+ }
155
+ return wallet.connector.signEip7702PreAuth(providedChainId);
156
+ }), [primaryWallet]);
157
+ return {
158
+ signEip7702Authorization: signEip7702Auth,
159
+ };
160
+ };
161
+
162
+ exports.useSignEip7702Authorization = useSignEip7702Authorization;
@@ -0,0 +1,78 @@
1
+ import { IZeroDevConnector, Wallet } from '@dynamic-labs/wallet-connector-core';
2
+ export type Eip7702Authorization = Awaited<ReturnType<IZeroDevConnector['signEip7702PreAuth']>>;
3
+ export type SignEip7702AuthorizationParams = {
4
+ /**
5
+ * The wallet to sign the EIP-7702 authorization with.
6
+ * If not provided, uses the primary wallet.
7
+ */
8
+ wallet?: Wallet;
9
+ /**
10
+ * The chain ID to sign the authorization for.
11
+ * If not provided, uses the wallet's current network chain ID.
12
+ */
13
+ chainId?: number;
14
+ };
15
+ export type UseSignEip7702AuthorizationReturn = {
16
+ /**
17
+ * Signs an EIP-7702 authorization for ZeroDev kernel delegation.
18
+ *
19
+ * This creates a signed authorization that allows a wallet to delegate
20
+ * its execution to the ZeroDev kernel contract. The signed authorization can then
21
+ * be passed to kernel account client creation functions.
22
+ *
23
+ * @param params - Optional parameters for signing the authorization
24
+ * @returns A promise that resolves to the signed EIP-7702 authorization
25
+ * @throws {DynamicError} If the wallet connector is not a ZeroDev connector
26
+ * @throws {DynamicError} If no wallet is available
27
+ * @throws {DynamicError} If the connector does not support EIP-7702 authorization
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * const { signEip7702Authorization } = useSignEip7702Authorization();
32
+ *
33
+ * // Sign with primary wallet and current network
34
+ * const auth = await signEip7702Authorization();
35
+ *
36
+ * // Sign with specific wallet and chain ID
37
+ * const auth = await signEip7702Authorization({
38
+ * wallet: myWallet,
39
+ * chainId: 1, // Ethereum mainnet
40
+ * });
41
+ * ```
42
+ */
43
+ signEip7702Authorization: (params?: SignEip7702AuthorizationParams) => Promise<Eip7702Authorization>;
44
+ };
45
+ /**
46
+ * Hook for signing EIP-7702 authorizations for ZeroDev kernel delegation.
47
+ *
48
+ * This hook provides a way to sign EIP-7702 authorizations that enable
49
+ * single-use MFA flows where the authorization signing step is separated
50
+ * from the transaction execution step.
51
+ *
52
+ * The signed authorization can be passed to kernel account client creation
53
+ * functions like `createEcdsaKernelAccountClientWith7702`.
54
+ *
55
+ * @returns An object containing the `signEip7702Authorization` function
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * import { useSignEip7702Authorization } from '@dynamic-labs/sdk-react-core';
60
+ *
61
+ * function MyComponent() {
62
+ * const { signEip7702Authorization } = useSignEip7702Authorization();
63
+ *
64
+ * const handleSign = async () => {
65
+ * try {
66
+ * const auth = await signEip7702Authorization();
67
+ * console.log('Signed authorization:', auth);
68
+ * // Use auth with kernel client creation
69
+ * } catch (error) {
70
+ * console.error('Failed to sign authorization:', error);
71
+ * }
72
+ * };
73
+ *
74
+ * return <button onClick={handleSign}>Sign Authorization</button>;
75
+ * }
76
+ * ```
77
+ */
78
+ export declare const useSignEip7702Authorization: () => UseSignEip7702AuthorizationReturn;
@@ -0,0 +1,158 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
+ import { useCallback } from 'react';
4
+ import { DynamicError } from '@dynamic-labs/utils';
5
+ import '../../../context/DynamicContext/DynamicContext.js';
6
+ import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
7
+ import '@dynamic-labs/iconic';
8
+ import '@dynamic-labs/wallet-connector-core';
9
+ import 'react/jsx-runtime';
10
+ import '../../../context/ViewContext/ViewContext.js';
11
+ import '../../../shared/logger.js';
12
+ import '@dynamic-labs/wallet-book';
13
+ import '../../constants/colors.js';
14
+ import '../../constants/values.js';
15
+ import '@dynamic-labs/sdk-api-core';
16
+ import '../../../shared/consts/index.js';
17
+ import '../../../events/dynamicEvents.js';
18
+ import '../../../context/CaptchaContext/CaptchaContext.js';
19
+ import '../../../context/ErrorContext/ErrorContext.js';
20
+ import '@dynamic-labs/multi-wallet';
21
+ import 'react-international-phone';
22
+ import '../../../store/state/nonce/nonce.js';
23
+ import '@dynamic-labs-sdk/client/core';
24
+ import '../../../client/client.js';
25
+ import '@dynamic-labs-sdk/client';
26
+ import '../../../config/ApiEndpoint.js';
27
+ import '@dynamic-labs/locale';
28
+ import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
29
+ import '../../../store/state/primaryWalletId/primaryWalletId.js';
30
+ import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
31
+ import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
32
+ import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
33
+ import '../../../context/AccountExistsContext/AccountExistsContext.js';
34
+ import '../../../context/UserWalletsContext/UserWalletsContext.js';
35
+ import '../../../store/state/authMode/authMode.js';
36
+ import '../../../context/VerificationContext/VerificationContext.js';
37
+ import 'react-dom';
38
+ import '../../functions/compareChains/compareChains.js';
39
+ import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
40
+ import '../../../context/ThemeContext/ThemeContext.js';
41
+ import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
42
+ import 'bs58';
43
+ import '@dynamic-labs/types';
44
+ import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
45
+ import '../../../context/LoadingContext/LoadingContext.js';
46
+ import '../../../context/WalletContext/WalletContext.js';
47
+ import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
48
+ import 'yup';
49
+ import '../../../context/MockContext/MockContext.js';
50
+ import '../../../views/CollectUserDataView/useFields.js';
51
+ import '../../../context/FieldsStateContext/FieldsStateContext.js';
52
+ import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
53
+ import '@dynamic-labs/rpc-providers';
54
+ import '../../../store/state/walletOptions/walletOptions.js';
55
+ import 'react-i18next';
56
+ import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
57
+ import '../../../components/Alert/Alert.js';
58
+ import '../../../components/ShadowDOM/ShadowDOM.js';
59
+ import '../../../components/IconButton/IconButton.js';
60
+ import '../../../components/InlineWidget/InlineWidget.js';
61
+ import '../../../components/Input/Input.js';
62
+ import '../../../components/IsBrowser/IsBrowser.js';
63
+ import '../../../components/MenuList/Dropdown/Dropdown.js';
64
+ import '../../../components/OverlayCard/OverlayCard.js';
65
+ import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
66
+ import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
67
+ import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
68
+ import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
69
+ import '../../../components/Popper/Popper/Popper.js';
70
+ import '../../../components/Popper/PopperContext/PopperContext.js';
71
+ import 'react-focus-lock';
72
+ import 'qrcode';
73
+ import 'formik';
74
+ import '../useSubdomainCheck/useSubdomainCheck.js';
75
+ import '../../../context/WalletGroupContext/WalletGroupContext.js';
76
+ import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
77
+ import '../useWalletBackup/useWalletBackup.js';
78
+ import '../useWalletBackup/types.js';
79
+ import '../useWalletBackup/cloudProviders.js';
80
+ import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
81
+ import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
82
+ import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
83
+ import '@hcaptcha/react-hcaptcha';
84
+ import '../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
85
+ import '../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
86
+ import '../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
87
+ import '../../../context/FooterAnimationContext/index.js';
88
+ import '../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
89
+ import '../../../context/PasskeyContext/PasskeyContext.js';
90
+ import '../../../context/OnrampContext/OnrampContext.js';
91
+ import '../../../store/state/sendBalances.js';
92
+ import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
93
+ import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
94
+ import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
95
+ import '../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
96
+ import '../../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
97
+ import '../../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js';
98
+ import '../../../../index.js';
99
+ import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
100
+ import '../../../store/state/tokenBalances.js';
101
+ import '../../../store/state/multichainBalances.js';
102
+ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
103
+ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
104
+
105
+ /**
106
+ * Hook for signing EIP-7702 authorizations for ZeroDev kernel delegation.
107
+ *
108
+ * This hook provides a way to sign EIP-7702 authorizations that enable
109
+ * single-use MFA flows where the authorization signing step is separated
110
+ * from the transaction execution step.
111
+ *
112
+ * The signed authorization can be passed to kernel account client creation
113
+ * functions like `createEcdsaKernelAccountClientWith7702`.
114
+ *
115
+ * @returns An object containing the `signEip7702Authorization` function
116
+ *
117
+ * @example
118
+ * ```tsx
119
+ * import { useSignEip7702Authorization } from '@dynamic-labs/sdk-react-core';
120
+ *
121
+ * function MyComponent() {
122
+ * const { signEip7702Authorization } = useSignEip7702Authorization();
123
+ *
124
+ * const handleSign = async () => {
125
+ * try {
126
+ * const auth = await signEip7702Authorization();
127
+ * console.log('Signed authorization:', auth);
128
+ * // Use auth with kernel client creation
129
+ * } catch (error) {
130
+ * console.error('Failed to sign authorization:', error);
131
+ * }
132
+ * };
133
+ *
134
+ * return <button onClick={handleSign}>Sign Authorization</button>;
135
+ * }
136
+ * ```
137
+ */
138
+ const useSignEip7702Authorization = () => {
139
+ const { primaryWallet } = useInternalDynamicContext();
140
+ const signEip7702Auth = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
141
+ var _a;
142
+ const { wallet: providedWallet, chainId: providedChainId } = params !== null && params !== void 0 ? params : {};
143
+ // Use provided wallet or fallback to primary wallet
144
+ const wallet = providedWallet !== null && providedWallet !== void 0 ? providedWallet : primaryWallet;
145
+ if (!wallet) {
146
+ throw new DynamicError('No wallet available. Please connect a wallet first.');
147
+ }
148
+ if (((_a = wallet.connector) === null || _a === void 0 ? void 0 : _a.key) !== 'zerodev') {
149
+ throw new DynamicError('The wallet connector must be a ZeroDev connector to sign EIP-7702 authorizations.');
150
+ }
151
+ return wallet.connector.signEip7702PreAuth(providedChainId);
152
+ }), [primaryWallet]);
153
+ return {
154
+ signEip7702Authorization: signEip7702Auth,
155
+ };
156
+ };
157
+
158
+ export { useSignEip7702Authorization };
@@ -0,0 +1,2 @@
1
+ export { useStepUpAuthentication } from './useStepUpAuthentication';
2
+ export type { StepUpAuthenticationState, UseStepUpAuthenticationParams, UseStepUpAuthenticationReturn, VerifyOtpParams, VerifyWalletParams, } from './useStepUpAuthentication';
@@ -0,0 +1,197 @@
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
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
10
+ require('@dynamic-labs-sdk/client/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
+ var logger = 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 useUser = require('../../../client/extension/user/useUser/useUser.cjs');
33
+ var useConnectAndSign = require('../authenticationHooks/useConnectAndSign/useConnectAndSign.cjs');
34
+ var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
35
+
36
+ const INITIAL_STATE = {
37
+ error: null,
38
+ isLoading: false,
39
+ otpVerification: null,
40
+ };
41
+ const isCountryCode = (value) => value !== undefined && value in client.supportedCountries;
42
+ const isOtpCapableCredential = (cred) => cred.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Email ||
43
+ cred.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.PhoneNumber;
44
+ const resolveTargetCredential = (credentials, credentialId) => {
45
+ var _a, _b;
46
+ if (credentialId) {
47
+ return ((_a = credentials.find((cred) => cred.id === credentialId)) !== null && _a !== void 0 ? _a : `Credential with id "${credentialId}" not found`);
48
+ }
49
+ return ((_b = credentials.find((cred) => cred.signInEnabled && isOtpCapableCredential(cred))) !== null && _b !== void 0 ? _b : 'No sign-in enabled email or SMS credential found for step-up authentication');
50
+ };
51
+ const sendEmailOtp = (credential) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
52
+ if (!credential.email) {
53
+ throw new Error('Email credential is missing email address');
54
+ }
55
+ return client.sendEmailOTP({ email: credential.email });
56
+ });
57
+ const sendSmsOtp = (credential) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
58
+ var _a;
59
+ const normalizedPhoneCountryCode = (_a = credential.phoneCountryCode) === null || _a === void 0 ? void 0 : _a.replace(/^\+/, '');
60
+ const matchedCountryCode = Object.keys(client.supportedCountries).find((key) => client.supportedCountries[key].code === normalizedPhoneCountryCode);
61
+ const isoCountryCode = isCountryCode(credential.isoCountryCode)
62
+ ? credential.isoCountryCode
63
+ : matchedCountryCode;
64
+ if (!credential.phoneNumber || !isoCountryCode) {
65
+ throw new Error('SMS credential is missing phone number or country code');
66
+ }
67
+ return client.sendSmsOTP({ isoCountryCode, phoneNumber: credential.phoneNumber });
68
+ });
69
+ const dispatchOtp = (credential) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
70
+ return credential.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Email
71
+ ? sendEmailOtp(credential)
72
+ : sendSmsOtp(credential);
73
+ });
74
+ /**
75
+ * Perform step-up authentication for an already-authenticated user via OTP.
76
+ *
77
+ * Automatically selects the first sign-in enabled email or SMS credential on
78
+ * the user, or targets a specific credential when `credentialId` is provided.
79
+ *
80
+ * @param params.credentialId - Optional id of a specific verified credential to
81
+ * use. Must be an email or SMS credential. Defaults to the first sign-in
82
+ * enabled email or SMS credential on the authenticated user.
83
+ *
84
+ * @returns `sendOtp` – sends the OTP to the resolved credential.
85
+ * @returns `verifyOtp` – verifies the OTP code supplied by the user.
86
+ * @returns `state` – current loading / error / otpVerification state.
87
+ * @returns `resetState` – resets state back to its initial value.
88
+ *
89
+ * @example
90
+ * ```tsx
91
+ * const { sendOtp, verifyOtp, state } = useStepUpAuthentication();
92
+ *
93
+ * // Step 1: send OTP
94
+ * await sendOtp();
95
+ *
96
+ * // Step 2: after the user enters the code
97
+ * const result = await verifyOtp({ verificationToken: '123456' });
98
+ * ```
99
+ */
100
+ const useStepUpAuthentication = ({ credentialId, } = {}) => {
101
+ const user = useUser.useUser();
102
+ const [state, setState] = React.useState(INITIAL_STATE);
103
+ const connectAndSign = useConnectAndSign.useConnectAndSign();
104
+ const { userWallets } = UserWalletsContext.useInternalUserWallets();
105
+ // Ref keeps the latest otpVerification available inside the verifyOtp
106
+ // callback without creating a stale closure over state.
107
+ const otpVerificationRef = React.useRef(null);
108
+ const resetState = React.useCallback(() => {
109
+ otpVerificationRef.current = null;
110
+ setState(INITIAL_STATE);
111
+ }, []);
112
+ const setError = React.useCallback((errorMessage) => {
113
+ setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
114
+ logger.logger.error(errorMessage);
115
+ }, []);
116
+ const sendOtp = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
117
+ const credentials = user === null || user === void 0 ? void 0 : user.verifiedCredentials;
118
+ if (!(credentials === null || credentials === void 0 ? void 0 : credentials.length)) {
119
+ setError('No verified credentials found for the authenticated user');
120
+ return null;
121
+ }
122
+ const result = resolveTargetCredential(credentials, credentialId);
123
+ if (typeof result === 'string') {
124
+ setError(result);
125
+ return null;
126
+ }
127
+ if (!isOtpCapableCredential(result)) {
128
+ setError(`Credential format "${result.format}" does not support OTP verification. Only email and SMS credentials are supported`);
129
+ return null;
130
+ }
131
+ setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
132
+ try {
133
+ const otpVerification = yield dispatchOtp(result);
134
+ otpVerificationRef.current = otpVerification;
135
+ setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false, otpVerification })));
136
+ return otpVerification;
137
+ }
138
+ catch (error) {
139
+ const errorMessage = error instanceof Error ? error.message : 'Failed to send OTP';
140
+ setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
141
+ logger.logger.error('Failed to send OTP for step-up authentication', { error });
142
+ return null;
143
+ }
144
+ }), [credentialId, setError, user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
145
+ const verifyOtp = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ requestedScopes, verificationToken, }) {
146
+ const otpVerification = otpVerificationRef.current;
147
+ if (!otpVerification) {
148
+ setError('OTP verification has not been initiated. Call sendOtp() first');
149
+ return null;
150
+ }
151
+ setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
152
+ try {
153
+ const response = yield client.verifyOTP({
154
+ otpVerification,
155
+ requestedScopes,
156
+ verificationToken,
157
+ });
158
+ setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
159
+ return response;
160
+ }
161
+ catch (error) {
162
+ const errorMessage = error instanceof Error ? error.message : 'Failed to verify OTP';
163
+ setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
164
+ logger.logger.error('Failed to verify OTP for step-up authentication', {
165
+ error,
166
+ });
167
+ return null;
168
+ }
169
+ }), [setError]);
170
+ const verifyWallet = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ requestedScopes }) {
171
+ setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
172
+ const wallet = userWallets.find((w) => w.id === credentialId);
173
+ if (!wallet) {
174
+ setError(`Wallet with id "${credentialId}" not found`);
175
+ return;
176
+ }
177
+ try {
178
+ yield connectAndSign({
179
+ requestedScopes,
180
+ walletConnector: wallet.connector,
181
+ });
182
+ setState((prev) => (Object.assign(Object.assign({}, prev), { isLoading: false })));
183
+ }
184
+ catch (error) {
185
+ const errorMessage = error instanceof Error
186
+ ? error.message
187
+ : 'Failed to verify wallet for step-up authentication';
188
+ setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
189
+ logger.logger.error('Failed to verify wallet for step-up authentication', {
190
+ error,
191
+ });
192
+ }
193
+ }), [connectAndSign, credentialId, setError, userWallets]);
194
+ return { resetState, sendOtp, state, verifyOtp, verifyWallet };
195
+ };
196
+
197
+ exports.useStepUpAuthentication = useStepUpAuthentication;
@@ -0,0 +1,51 @@
1
+ import type { OTPVerification } from '@dynamic-labs-sdk/client';
2
+ import { TokenScope, VerifyResponse } from '@dynamic-labs/sdk-api-core';
3
+ export type StepUpAuthenticationState = {
4
+ error: string | null;
5
+ isLoading: boolean;
6
+ otpVerification: OTPVerification | null;
7
+ };
8
+ export type VerifyOtpParams = {
9
+ requestedScopes?: TokenScope[];
10
+ verificationToken: string;
11
+ };
12
+ export type VerifyWalletParams = {
13
+ requestedScopes?: TokenScope[];
14
+ };
15
+ export type UseStepUpAuthenticationParams = {
16
+ credentialId?: string;
17
+ };
18
+ export type UseStepUpAuthenticationReturn = {
19
+ resetState: () => void;
20
+ sendOtp: () => Promise<OTPVerification | null>;
21
+ state: StepUpAuthenticationState;
22
+ verifyOtp: (params: VerifyOtpParams) => Promise<VerifyResponse | null>;
23
+ verifyWallet: (params: VerifyWalletParams) => Promise<void>;
24
+ };
25
+ /**
26
+ * Perform step-up authentication for an already-authenticated user via OTP.
27
+ *
28
+ * Automatically selects the first sign-in enabled email or SMS credential on
29
+ * the user, or targets a specific credential when `credentialId` is provided.
30
+ *
31
+ * @param params.credentialId - Optional id of a specific verified credential to
32
+ * use. Must be an email or SMS credential. Defaults to the first sign-in
33
+ * enabled email or SMS credential on the authenticated user.
34
+ *
35
+ * @returns `sendOtp` – sends the OTP to the resolved credential.
36
+ * @returns `verifyOtp` – verifies the OTP code supplied by the user.
37
+ * @returns `state` – current loading / error / otpVerification state.
38
+ * @returns `resetState` – resets state back to its initial value.
39
+ *
40
+ * @example
41
+ * ```tsx
42
+ * const { sendOtp, verifyOtp, state } = useStepUpAuthentication();
43
+ *
44
+ * // Step 1: send OTP
45
+ * await sendOtp();
46
+ *
47
+ * // Step 2: after the user enters the code
48
+ * const result = await verifyOtp({ verificationToken: '123456' });
49
+ * ```
50
+ */
51
+ export declare const useStepUpAuthentication: ({ credentialId, }?: UseStepUpAuthenticationParams) => UseStepUpAuthenticationReturn;