@dynamic-labs/sdk-react-core 4.60.1 → 4.61.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.
- package/CHANGELOG.md +15 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +5 -4
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +2 -2
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +5 -4
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +6 -1
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +6 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +12 -4
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +12 -4
- package/src/lib/utils/hooks/useWalletPassword/index.d.ts +1 -0
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.cjs +152 -0
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.d.ts +30 -0
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.js +148 -0
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +11 -14
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +11 -14
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.cjs +11 -3
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.js +11 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.61.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.60.1...v4.61.0) (2026-02-10)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add unlockWallet and getWalletRecoveryState to WaaS ([#10407](https://github.com/dynamic-labs/dynamic-auth/issues/10407)) ([e0d1a28](https://github.com/dynamic-labs/dynamic-auth/commit/e0d1a2830f36eee6c6e84737011e8cf59966122d))
|
|
8
|
+
* add useWalletPassword hook for waas wallet password management ([#10399](https://github.com/dynamic-labs/dynamic-auth/issues/10399)) ([508835f](https://github.com/dynamic-labs/dynamic-auth/commit/508835fb0f4f17b7353a4378f4c254e02f0a46ff))
|
|
9
|
+
* add WaaS unlock and recovery UI to mobile demo ([#10408](https://github.com/dynamic-labs/dynamic-auth/issues/10408)) ([94cdb88](https://github.com/dynamic-labs/dynamic-auth/commit/94cdb882fca3c34d157b42d5208f56812008c43b))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* bump axios to fix high vulnerability ([#10406](https://github.com/dynamic-labs/dynamic-auth/issues/10406)) ([303e2dc](https://github.com/dynamic-labs/dynamic-auth/commit/303e2dcf1e7e8ecad4caf2d74e805ee427c1d00e))
|
|
15
|
+
* patch node-forge CVE-2025-12816 in global-wallet ([#10401](https://github.com/dynamic-labs/dynamic-auth/issues/10401)) ([46e6eb2](https://github.com/dynamic-labs/dynamic-auth/commit/46e6eb28a0add0052299eaa4ac2dcbe8b1faa98c))
|
|
16
|
+
|
|
2
17
|
### [4.60.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.60.0...v4.60.1) (2026-02-09)
|
|
3
18
|
|
|
4
19
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.61.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.864",
|
|
6
6
|
"@dynamic-labs-sdk/client": "0.8.0",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
"yup": "0.32.11",
|
|
17
17
|
"react-international-phone": "4.5.0",
|
|
18
18
|
"bs58": "5.0.0",
|
|
19
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
20
|
-
"@dynamic-labs/iconic": "4.
|
|
21
|
-
"@dynamic-labs/locale": "4.
|
|
22
|
-
"@dynamic-labs/logger": "4.
|
|
23
|
-
"@dynamic-labs/multi-wallet": "4.
|
|
24
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
25
|
-
"@dynamic-labs/store": "4.
|
|
26
|
-
"@dynamic-labs/types": "4.
|
|
27
|
-
"@dynamic-labs/utils": "4.
|
|
28
|
-
"@dynamic-labs/wallet-book": "4.
|
|
29
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
19
|
+
"@dynamic-labs/assert-package-version": "4.61.0",
|
|
20
|
+
"@dynamic-labs/iconic": "4.61.0",
|
|
21
|
+
"@dynamic-labs/locale": "4.61.0",
|
|
22
|
+
"@dynamic-labs/logger": "4.61.0",
|
|
23
|
+
"@dynamic-labs/multi-wallet": "4.61.0",
|
|
24
|
+
"@dynamic-labs/rpc-providers": "4.61.0",
|
|
25
|
+
"@dynamic-labs/store": "4.61.0",
|
|
26
|
+
"@dynamic-labs/types": "4.61.0",
|
|
27
|
+
"@dynamic-labs/utils": "4.61.0",
|
|
28
|
+
"@dynamic-labs/wallet-book": "4.61.0",
|
|
29
|
+
"@dynamic-labs/wallet-connector-core": "4.61.0",
|
|
30
30
|
"eventemitter3": "5.0.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -102,5 +102,7 @@ export { useRefreshAuth } from './useRefreshAuth';
|
|
|
102
102
|
export { useSetupPassword, PASSWORD_SETUP_CANCELLED_ERROR, } from './useSetupPassword';
|
|
103
103
|
export { useWalletUnlock } from './useWalletUnlock';
|
|
104
104
|
export type { UseWalletUnlockReturn, WalletUnlockState, } from './useWalletUnlock';
|
|
105
|
+
export { useWalletPassword } from './useWalletPassword';
|
|
106
|
+
export type { CheckWalletLockStateParams, UnlockWalletParams, UpdatePasswordParams, UseWalletPasswordReturn, WalletPasswordState, } from './useWalletPassword';
|
|
105
107
|
export { usePromptWalletUnlock } from './usePromptWalletUnlock';
|
|
106
108
|
export { useGetWalletPassword } from './useGetWalletPassword';
|
|
@@ -123,7 +123,7 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
123
123
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
124
124
|
|
|
125
125
|
const dynamicWaasKey = 'dynamicwaas';
|
|
126
|
-
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, getWalletPassword,
|
|
126
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, getWalletPassword, getSvmGasSponsorshipEnabled = () => false, }) => {
|
|
127
127
|
var _a;
|
|
128
128
|
walletConnector.setEnvironmentId(environmentId);
|
|
129
129
|
walletConnector.setBaseApiUrl((_a = (apiBaseUrl || apiUrl.DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
|
|
@@ -147,7 +147,7 @@ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl,
|
|
|
147
147
|
const isSolConnector = walletConnector.connectedChain === 'SOL';
|
|
148
148
|
const supportsSponsorshipSetting = 'setSvmGasSponsorshipEnabled' in walletConnector;
|
|
149
149
|
if (isSolConnector && supportsSponsorshipSetting) {
|
|
150
|
-
walletConnector.setSvmGasSponsorshipEnabled(
|
|
150
|
+
walletConnector.setSvmGasSponsorshipEnabled(getSvmGasSponsorshipEnabled);
|
|
151
151
|
}
|
|
152
152
|
return walletConnector;
|
|
153
153
|
};
|
|
@@ -172,6 +172,8 @@ const useDynamicWaas = () => {
|
|
|
172
172
|
const defaultWalletVersion = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.defaultWalletVersion;
|
|
173
173
|
const dynamicWaasIsEnabled = defaultWalletVersion === sdkApiCore.EmbeddedWalletVersionEnum.V3;
|
|
174
174
|
const svmGasSponsorshipEnabled = (_f = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.svmGasSponsorshipEnabled) !== null && _f !== void 0 ? _f : false;
|
|
175
|
+
const svmGasSponsorshipEnabledRef = React.useRef(svmGasSponsorshipEnabled);
|
|
176
|
+
svmGasSponsorshipEnabledRef.current = svmGasSponsorshipEnabled;
|
|
175
177
|
const authToken = getMinAuthToken.getMinAuthToken();
|
|
176
178
|
const { getSignedSessionId } = useClientSessionKeys.useClientSessionKeys();
|
|
177
179
|
const getMfaToken = useGetMfaToken.useGetMfaToken();
|
|
@@ -198,9 +200,9 @@ const useDynamicWaas = () => {
|
|
|
198
200
|
environmentId,
|
|
199
201
|
getMfaToken,
|
|
200
202
|
getSignedSessionId,
|
|
203
|
+
getSvmGasSponsorshipEnabled: () => svmGasSponsorshipEnabledRef.current,
|
|
201
204
|
getWalletPassword,
|
|
202
205
|
relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
|
|
203
|
-
svmGasSponsorshipEnabled,
|
|
204
206
|
walletConnector,
|
|
205
207
|
});
|
|
206
208
|
return configuredWalletConnector;
|
|
@@ -215,7 +217,6 @@ const useDynamicWaas = () => {
|
|
|
215
217
|
getSignedSessionId,
|
|
216
218
|
relayUrl,
|
|
217
219
|
baseClientKeysharesRelayApiUrl,
|
|
218
|
-
svmGasSponsorshipEnabled,
|
|
219
220
|
]);
|
|
220
221
|
const shouldInitializeWaas = React.useMemo(() => {
|
|
221
222
|
var _a;
|
|
@@ -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, getWalletPassword,
|
|
15
|
+
export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode, getSignedSessionId, getMfaToken, getWalletPassword, getSvmGasSponsorshipEnabled, }: {
|
|
16
16
|
walletConnector: IDynamicWaasConnector;
|
|
17
17
|
environmentId: string;
|
|
18
18
|
apiBaseUrl: string;
|
|
@@ -24,7 +24,7 @@ export declare const configWaasWalletConnector: ({ walletConnector, environmentI
|
|
|
24
24
|
mfaAction?: MFAAction;
|
|
25
25
|
}) => Promise<string | undefined>;
|
|
26
26
|
getWalletPassword?: GetWalletPasswordFn;
|
|
27
|
-
|
|
27
|
+
getSvmGasSponsorshipEnabled?: () => boolean;
|
|
28
28
|
}) => IDynamicWaasConnector;
|
|
29
29
|
export declare const useDynamicWaas: () => {
|
|
30
30
|
areWalletsReadyForSettings: () => boolean;
|
|
@@ -119,7 +119,7 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
119
119
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
120
120
|
|
|
121
121
|
const dynamicWaasKey = 'dynamicwaas';
|
|
122
|
-
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, getWalletPassword,
|
|
122
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getMfaToken, getWalletPassword, getSvmGasSponsorshipEnabled = () => false, }) => {
|
|
123
123
|
var _a;
|
|
124
124
|
walletConnector.setEnvironmentId(environmentId);
|
|
125
125
|
walletConnector.setBaseApiUrl((_a = (apiBaseUrl || DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
|
|
@@ -143,7 +143,7 @@ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl,
|
|
|
143
143
|
const isSolConnector = walletConnector.connectedChain === 'SOL';
|
|
144
144
|
const supportsSponsorshipSetting = 'setSvmGasSponsorshipEnabled' in walletConnector;
|
|
145
145
|
if (isSolConnector && supportsSponsorshipSetting) {
|
|
146
|
-
walletConnector.setSvmGasSponsorshipEnabled(
|
|
146
|
+
walletConnector.setSvmGasSponsorshipEnabled(getSvmGasSponsorshipEnabled);
|
|
147
147
|
}
|
|
148
148
|
return walletConnector;
|
|
149
149
|
};
|
|
@@ -168,6 +168,8 @@ const useDynamicWaas = () => {
|
|
|
168
168
|
const defaultWalletVersion = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.defaultWalletVersion;
|
|
169
169
|
const dynamicWaasIsEnabled = defaultWalletVersion === EmbeddedWalletVersionEnum.V3;
|
|
170
170
|
const svmGasSponsorshipEnabled = (_f = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.svmGasSponsorshipEnabled) !== null && _f !== void 0 ? _f : false;
|
|
171
|
+
const svmGasSponsorshipEnabledRef = useRef(svmGasSponsorshipEnabled);
|
|
172
|
+
svmGasSponsorshipEnabledRef.current = svmGasSponsorshipEnabled;
|
|
171
173
|
const authToken = getMinAuthToken();
|
|
172
174
|
const { getSignedSessionId } = useClientSessionKeys();
|
|
173
175
|
const getMfaToken = useGetMfaToken();
|
|
@@ -194,9 +196,9 @@ const useDynamicWaas = () => {
|
|
|
194
196
|
environmentId,
|
|
195
197
|
getMfaToken,
|
|
196
198
|
getSignedSessionId,
|
|
199
|
+
getSvmGasSponsorshipEnabled: () => svmGasSponsorshipEnabledRef.current,
|
|
197
200
|
getWalletPassword,
|
|
198
201
|
relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
|
|
199
|
-
svmGasSponsorshipEnabled,
|
|
200
202
|
walletConnector,
|
|
201
203
|
});
|
|
202
204
|
return configuredWalletConnector;
|
|
@@ -211,7 +213,6 @@ const useDynamicWaas = () => {
|
|
|
211
213
|
getSignedSessionId,
|
|
212
214
|
relayUrl,
|
|
213
215
|
baseClientKeysharesRelayApiUrl,
|
|
214
|
-
svmGasSponsorshipEnabled,
|
|
215
216
|
]);
|
|
216
217
|
const shouldInitializeWaas = useMemo(() => {
|
|
217
218
|
var _a;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var React = require('react');
|
|
6
7
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
|
-
require('react');
|
|
8
8
|
require('../../../events/dynamicEvents.cjs');
|
|
9
9
|
require('../../../../../_virtual/_tslib.cjs');
|
|
10
10
|
require('@dynamic-labs/utils');
|
|
@@ -112,11 +112,15 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
112
112
|
var useClientSessionKeys = require('../useClientSessionKeys/useClientSessionKeys.cjs');
|
|
113
113
|
|
|
114
114
|
const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSettings) => {
|
|
115
|
+
var _a, _b, _c;
|
|
115
116
|
const apiBaseUrl = dynamicContextProps.useApiBaseUrl();
|
|
116
117
|
const { registerEmbeddedWalletSessionKey, removeSessionKey } = useEmbeddedWalletSessionKeys.useEmbeddedWalletSessionKeys({ environmentId, projectSettings });
|
|
117
118
|
const { getSignedSessionId } = useClientSessionKeys.useClientSessionKeys();
|
|
118
119
|
const getMfaToken = useGetMfaToken.useGetMfaToken();
|
|
119
120
|
const isCookieAuthEnabled = projectSettings && isCookieEnabled.isCookieEnabled();
|
|
121
|
+
const svmGasSponsorshipEnabled = (_c = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.svmGasSponsorshipEnabled) !== null && _c !== void 0 ? _c : false;
|
|
122
|
+
const svmGasSponsorshipEnabledRef = React.useRef(svmGasSponsorshipEnabled);
|
|
123
|
+
svmGasSponsorshipEnabledRef.current = svmGasSponsorshipEnabled;
|
|
120
124
|
if (!(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
121
125
|
return;
|
|
122
126
|
walletOptions.forEach((walletOption) => {
|
|
@@ -132,6 +136,7 @@ const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSett
|
|
|
132
136
|
environmentId,
|
|
133
137
|
getMfaToken,
|
|
134
138
|
getSignedSessionId,
|
|
139
|
+
getSvmGasSponsorshipEnabled: () => svmGasSponsorshipEnabledRef.current,
|
|
135
140
|
relayUrl: (_e = (_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.relayUrl) !== null && _e !== void 0 ? _e : '',
|
|
136
141
|
walletConnector: walletOption.walletConnector,
|
|
137
142
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { useRef } from 'react';
|
|
2
3
|
import { isSessionKeyCompatibleWalletConnector, isDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import 'react';
|
|
4
4
|
import '../../../events/dynamicEvents.js';
|
|
5
5
|
import '../../../../../_virtual/_tslib.js';
|
|
6
6
|
import '@dynamic-labs/utils';
|
|
@@ -108,11 +108,15 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
108
108
|
import { useClientSessionKeys } from '../useClientSessionKeys/useClientSessionKeys.js';
|
|
109
109
|
|
|
110
110
|
const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSettings) => {
|
|
111
|
+
var _a, _b, _c;
|
|
111
112
|
const apiBaseUrl = useApiBaseUrl();
|
|
112
113
|
const { registerEmbeddedWalletSessionKey, removeSessionKey } = useEmbeddedWalletSessionKeys({ environmentId, projectSettings });
|
|
113
114
|
const { getSignedSessionId } = useClientSessionKeys();
|
|
114
115
|
const getMfaToken = useGetMfaToken();
|
|
115
116
|
const isCookieAuthEnabled = projectSettings && isCookieEnabled();
|
|
117
|
+
const svmGasSponsorshipEnabled = (_c = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.svmGasSponsorshipEnabled) !== null && _c !== void 0 ? _c : false;
|
|
118
|
+
const svmGasSponsorshipEnabledRef = useRef(svmGasSponsorshipEnabled);
|
|
119
|
+
svmGasSponsorshipEnabledRef.current = svmGasSponsorshipEnabled;
|
|
116
120
|
if (!(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
117
121
|
return;
|
|
118
122
|
walletOptions.forEach((walletOption) => {
|
|
@@ -128,6 +132,7 @@ const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSett
|
|
|
128
132
|
environmentId,
|
|
129
133
|
getMfaToken,
|
|
130
134
|
getSignedSessionId,
|
|
135
|
+
getSvmGasSponsorshipEnabled: () => svmGasSponsorshipEnabledRef.current,
|
|
131
136
|
relayUrl: (_e = (_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.relayUrl) !== null && _e !== void 0 ? _e : '',
|
|
132
137
|
walletConnector: walletOption.walletConnector,
|
|
133
138
|
});
|
|
@@ -31,6 +31,7 @@ require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
|
31
31
|
require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
32
32
|
require('../../../events/dynamicEvents.cjs');
|
|
33
33
|
var storeTokenAndUser = require('../../../client/extension/storeTokenAndUser/storeTokenAndUser.cjs');
|
|
34
|
+
var useProjectSettings = require('../../../client/extension/projectSettings/useProjectSettings/useProjectSettings.cjs');
|
|
34
35
|
var AccessDeniedContext = require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
35
36
|
var AccountExistsContext = require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
36
37
|
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
@@ -120,6 +121,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
120
121
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
121
122
|
const handleAuthenticatedUser = useHandleAuthenticatedUser.useHandleAuthenticatedUser();
|
|
122
123
|
const { shouldAutoCreateEmbeddedWallet, shouldPromptForKeyExport, embeddedWalletSettingVersion, } = useEmbeddedWallet.useEmbeddedWallet();
|
|
124
|
+
const projectSettings = useProjectSettings.useProjectSettings();
|
|
123
125
|
const isVerifyResponse = (response) => response.user;
|
|
124
126
|
const cancelAuth = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
125
127
|
logger.logger.debug('cancelAuth', { authMethod });
|
|
@@ -200,7 +202,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
200
202
|
setExistentAccountData,
|
|
201
203
|
]);
|
|
202
204
|
const initAuth = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ isSignIn = true, verifyFunction, onVerifySuccess, onSettled, onError, showSuccessMessage = false, skipDefaultErrorHandling = false, }) {
|
|
203
|
-
var _b;
|
|
205
|
+
var _b, _c, _d;
|
|
204
206
|
logger.logger.debug('initAuth', { authMethod, isSignIn });
|
|
205
207
|
try {
|
|
206
208
|
// TODO: change this logic to const verifiedUser = await verifyFunction();
|
|
@@ -244,7 +246,12 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
244
246
|
setCallback('authSuccess');
|
|
245
247
|
}
|
|
246
248
|
const walletVersion = embeddedWalletSettingVersion();
|
|
247
|
-
|
|
249
|
+
const shouldKeepAuthFlowOpenForPasswordSetup = walletVersion === sdkApiCore.EmbeddedWalletVersionEnum.V3 &&
|
|
250
|
+
Boolean((_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.passcodeRequired);
|
|
251
|
+
if (shouldKeepAuthFlowOpenForPasswordSetup) {
|
|
252
|
+
// Keep auth flow open so setup-password can be shown (useSyncDynamicWaas)
|
|
253
|
+
}
|
|
254
|
+
else if (walletVersion === sdkApiCore.EmbeddedWalletVersionEnum.V1 &&
|
|
248
255
|
shouldCreateWallet) {
|
|
249
256
|
setShowAuthFlow(true);
|
|
250
257
|
}
|
|
@@ -271,6 +278,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
271
278
|
embeddedWalletSettingVersion,
|
|
272
279
|
handleAuthError,
|
|
273
280
|
handleAuthenticatedUser,
|
|
281
|
+
projectSettings,
|
|
274
282
|
setCallback,
|
|
275
283
|
setLoading,
|
|
276
284
|
setMultiWalletWidgetState,
|
|
@@ -279,7 +287,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
279
287
|
shouldPromptForKeyExport,
|
|
280
288
|
walletConnectorOptions,
|
|
281
289
|
]);
|
|
282
|
-
const handleVerifyMissingFields = React.useCallback((
|
|
290
|
+
const handleVerifyMissingFields = React.useCallback((_e) => _tslib.__awaiter(void 0, [_e], void 0, function* ({ missingFields, isEmailVerificationRequired, isSmsVerificationRequired, }) {
|
|
283
291
|
if (isEmailVerificationRequired &&
|
|
284
292
|
missingFields.find((field) => field.name === 'email')) {
|
|
285
293
|
pushView('verify-email');
|
|
@@ -292,7 +300,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
292
300
|
}
|
|
293
301
|
pushView(view.type);
|
|
294
302
|
}), [pushView, view === null || view === void 0 ? void 0 : view.type]);
|
|
295
|
-
const completeAuth = React.useCallback((
|
|
303
|
+
const completeAuth = React.useCallback((_f) => _tslib.__awaiter(void 0, [_f], void 0, function* ({ completeSignInFlow, updateJwtFunction, onValidUpdatedJwt, options = {}, }) {
|
|
296
304
|
logger.logger.debug('completeAuth', { authMethod });
|
|
297
305
|
try {
|
|
298
306
|
const { updateUserProfileResponse, isSmsVerificationRequired, isEmailVerificationRequired, missingFields, } = yield updateJwtFunction();
|
|
@@ -27,6 +27,7 @@ import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
|
27
27
|
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
28
28
|
import '../../../events/dynamicEvents.js';
|
|
29
29
|
import { storeTokenAndUser } from '../../../client/extension/storeTokenAndUser/storeTokenAndUser.js';
|
|
30
|
+
import { useProjectSettings } from '../../../client/extension/projectSettings/useProjectSettings/useProjectSettings.js';
|
|
30
31
|
import { useAccessDeniedContext } from '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
31
32
|
import { useAccountExistsContext } from '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
32
33
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
@@ -116,6 +117,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
116
117
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
117
118
|
const handleAuthenticatedUser = useHandleAuthenticatedUser();
|
|
118
119
|
const { shouldAutoCreateEmbeddedWallet, shouldPromptForKeyExport, embeddedWalletSettingVersion, } = useEmbeddedWallet();
|
|
120
|
+
const projectSettings = useProjectSettings();
|
|
119
121
|
const isVerifyResponse = (response) => response.user;
|
|
120
122
|
const cancelAuth = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
123
|
logger.debug('cancelAuth', { authMethod });
|
|
@@ -196,7 +198,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
196
198
|
setExistentAccountData,
|
|
197
199
|
]);
|
|
198
200
|
const initAuth = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ isSignIn = true, verifyFunction, onVerifySuccess, onSettled, onError, showSuccessMessage = false, skipDefaultErrorHandling = false, }) {
|
|
199
|
-
var _b;
|
|
201
|
+
var _b, _c, _d;
|
|
200
202
|
logger.debug('initAuth', { authMethod, isSignIn });
|
|
201
203
|
try {
|
|
202
204
|
// TODO: change this logic to const verifiedUser = await verifyFunction();
|
|
@@ -240,7 +242,12 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
240
242
|
setCallback('authSuccess');
|
|
241
243
|
}
|
|
242
244
|
const walletVersion = embeddedWalletSettingVersion();
|
|
243
|
-
|
|
245
|
+
const shouldKeepAuthFlowOpenForPasswordSetup = walletVersion === EmbeddedWalletVersionEnum.V3 &&
|
|
246
|
+
Boolean((_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.passcodeRequired);
|
|
247
|
+
if (shouldKeepAuthFlowOpenForPasswordSetup) {
|
|
248
|
+
// Keep auth flow open so setup-password can be shown (useSyncDynamicWaas)
|
|
249
|
+
}
|
|
250
|
+
else if (walletVersion === EmbeddedWalletVersionEnum.V1 &&
|
|
244
251
|
shouldCreateWallet) {
|
|
245
252
|
setShowAuthFlow(true);
|
|
246
253
|
}
|
|
@@ -267,6 +274,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
267
274
|
embeddedWalletSettingVersion,
|
|
268
275
|
handleAuthError,
|
|
269
276
|
handleAuthenticatedUser,
|
|
277
|
+
projectSettings,
|
|
270
278
|
setCallback,
|
|
271
279
|
setLoading,
|
|
272
280
|
setMultiWalletWidgetState,
|
|
@@ -275,7 +283,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
275
283
|
shouldPromptForKeyExport,
|
|
276
284
|
walletConnectorOptions,
|
|
277
285
|
]);
|
|
278
|
-
const handleVerifyMissingFields = useCallback((
|
|
286
|
+
const handleVerifyMissingFields = useCallback((_e) => __awaiter(void 0, [_e], void 0, function* ({ missingFields, isEmailVerificationRequired, isSmsVerificationRequired, }) {
|
|
279
287
|
if (isEmailVerificationRequired &&
|
|
280
288
|
missingFields.find((field) => field.name === 'email')) {
|
|
281
289
|
pushView('verify-email');
|
|
@@ -288,7 +296,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
288
296
|
}
|
|
289
297
|
pushView(view.type);
|
|
290
298
|
}), [pushView, view === null || view === void 0 ? void 0 : view.type]);
|
|
291
|
-
const completeAuth = useCallback((
|
|
299
|
+
const completeAuth = useCallback((_f) => __awaiter(void 0, [_f], void 0, function* ({ completeSignInFlow, updateJwtFunction, onValidUpdatedJwt, options = {}, }) {
|
|
292
300
|
logger.debug('completeAuth', { authMethod });
|
|
293
301
|
try {
|
|
294
302
|
const { updateUserProfileResponse, isSmsVerificationRequired, isEmailVerificationRequired, missingFields, } = yield updateJwtFunction();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useWalletPassword';
|
|
@@ -0,0 +1,152 @@
|
|
|
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 dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
9
|
+
require('@dynamic-labs/iconic');
|
|
10
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
11
|
+
require('react/jsx-runtime');
|
|
12
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
13
|
+
var logger = require('../../../shared/logger.cjs');
|
|
14
|
+
require('@dynamic-labs/wallet-book');
|
|
15
|
+
require('@dynamic-labs/utils');
|
|
16
|
+
require('../../constants/colors.cjs');
|
|
17
|
+
require('../../constants/values.cjs');
|
|
18
|
+
require('@dynamic-labs/sdk-api-core');
|
|
19
|
+
require('../../../shared/consts/index.cjs');
|
|
20
|
+
var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
|
|
21
|
+
|
|
22
|
+
const INITIAL_STATE = {
|
|
23
|
+
error: null,
|
|
24
|
+
isLoading: false,
|
|
25
|
+
recoveryState: null,
|
|
26
|
+
};
|
|
27
|
+
const useWalletPassword = () => {
|
|
28
|
+
const { getWaasWalletConnector } = useDynamicWaas.useDynamicWaas();
|
|
29
|
+
const [state, setState] = React.useState(INITIAL_STATE);
|
|
30
|
+
const resetState = React.useCallback(() => {
|
|
31
|
+
setState(INITIAL_STATE);
|
|
32
|
+
}, []);
|
|
33
|
+
const updatePassword = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const { accountAddress, chainName, newPassword, existingPassword } = params;
|
|
35
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
36
|
+
try {
|
|
37
|
+
const connector = getWaasWalletConnector(chainName);
|
|
38
|
+
if (!connector) {
|
|
39
|
+
const errorMessage = 'Wallet connector not found';
|
|
40
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
41
|
+
logger.logger.error(errorMessage, { accountAddress, chainName });
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
yield connector.updatePassword({
|
|
45
|
+
accountAddress,
|
|
46
|
+
existingPassword,
|
|
47
|
+
newPassword,
|
|
48
|
+
});
|
|
49
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to update password';
|
|
54
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
55
|
+
logger.logger.error('Failed to update wallet password', {
|
|
56
|
+
accountAddress,
|
|
57
|
+
chainName,
|
|
58
|
+
error,
|
|
59
|
+
});
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}), [getWaasWalletConnector]);
|
|
63
|
+
const unlockWallet = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
const { accountAddress, chainName, password } = params;
|
|
65
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
66
|
+
try {
|
|
67
|
+
const connector = getWaasWalletConnector(chainName);
|
|
68
|
+
if (!connector) {
|
|
69
|
+
const errorMessage = 'Wallet connector not found';
|
|
70
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
71
|
+
logger.logger.error(errorMessage, { accountAddress, chainName });
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
dynamicEvents.dynamicEvents.emit('walletUnlockAttempt', {
|
|
75
|
+
accountAddress,
|
|
76
|
+
chainName,
|
|
77
|
+
});
|
|
78
|
+
yield connector.unlockWallet({
|
|
79
|
+
accountAddress,
|
|
80
|
+
password,
|
|
81
|
+
});
|
|
82
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
83
|
+
dynamicEvents.dynamicEvents.emit('walletUnlockCompleted', {
|
|
84
|
+
accountAddress,
|
|
85
|
+
chainName,
|
|
86
|
+
});
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to unlock wallet';
|
|
91
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
92
|
+
logger.logger.error('Failed to unlock wallet', {
|
|
93
|
+
accountAddress,
|
|
94
|
+
chainName,
|
|
95
|
+
error,
|
|
96
|
+
});
|
|
97
|
+
dynamicEvents.dynamicEvents.emit('walletUnlockFailed', {
|
|
98
|
+
accountAddress,
|
|
99
|
+
chainName,
|
|
100
|
+
error,
|
|
101
|
+
});
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}), [getWaasWalletConnector]);
|
|
105
|
+
const checkWalletLockState = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
+
const { accountAddress, chainName } = params;
|
|
107
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
108
|
+
try {
|
|
109
|
+
const connector = getWaasWalletConnector(chainName);
|
|
110
|
+
if (!connector) {
|
|
111
|
+
const errorMessage = 'Wallet connector not found';
|
|
112
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
113
|
+
logger.logger.error(errorMessage, { accountAddress, chainName });
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
const recoveryState = yield connector.getWalletRecoveryState({
|
|
117
|
+
accountAddress,
|
|
118
|
+
});
|
|
119
|
+
setState({
|
|
120
|
+
error: null,
|
|
121
|
+
isLoading: false,
|
|
122
|
+
recoveryState,
|
|
123
|
+
});
|
|
124
|
+
return recoveryState;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
const errorMessage = error instanceof Error
|
|
128
|
+
? error.message
|
|
129
|
+
: 'Failed to check wallet state';
|
|
130
|
+
setState({
|
|
131
|
+
error: errorMessage,
|
|
132
|
+
isLoading: false,
|
|
133
|
+
recoveryState: null,
|
|
134
|
+
});
|
|
135
|
+
logger.logger.error('Failed to check wallet lock state', {
|
|
136
|
+
accountAddress,
|
|
137
|
+
chainName,
|
|
138
|
+
error,
|
|
139
|
+
});
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
}), [getWaasWalletConnector]);
|
|
143
|
+
return {
|
|
144
|
+
checkWalletLockState,
|
|
145
|
+
resetState,
|
|
146
|
+
state,
|
|
147
|
+
unlockWallet,
|
|
148
|
+
updatePassword,
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
exports.useWalletPassword = useWalletPassword;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WalletRecoveryState } from '@dynamic-labs-wallet/browser-wallet-client';
|
|
2
|
+
import { ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
export type UpdatePasswordParams = {
|
|
4
|
+
accountAddress: string;
|
|
5
|
+
chainName: ChainEnum;
|
|
6
|
+
newPassword: string;
|
|
7
|
+
existingPassword?: string;
|
|
8
|
+
};
|
|
9
|
+
export type UnlockWalletParams = {
|
|
10
|
+
accountAddress: string;
|
|
11
|
+
chainName: ChainEnum;
|
|
12
|
+
password: string;
|
|
13
|
+
};
|
|
14
|
+
export type CheckWalletLockStateParams = {
|
|
15
|
+
accountAddress: string;
|
|
16
|
+
chainName: ChainEnum;
|
|
17
|
+
};
|
|
18
|
+
export type WalletPasswordState = {
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
error: string | null;
|
|
21
|
+
recoveryState: WalletRecoveryState | null;
|
|
22
|
+
};
|
|
23
|
+
export type UseWalletPasswordReturn = {
|
|
24
|
+
updatePassword: (params: UpdatePasswordParams) => Promise<boolean>;
|
|
25
|
+
unlockWallet: (params: UnlockWalletParams) => Promise<boolean>;
|
|
26
|
+
checkWalletLockState: (params: CheckWalletLockStateParams) => Promise<WalletRecoveryState | null>;
|
|
27
|
+
state: WalletPasswordState;
|
|
28
|
+
resetState: () => void;
|
|
29
|
+
};
|
|
30
|
+
export declare const useWalletPassword: () => UseWalletPasswordReturn;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useState, useCallback } from 'react';
|
|
4
|
+
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
5
|
+
import '@dynamic-labs/iconic';
|
|
6
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
9
|
+
import { logger } from '../../../shared/logger.js';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import '@dynamic-labs/utils';
|
|
12
|
+
import '../../constants/colors.js';
|
|
13
|
+
import '../../constants/values.js';
|
|
14
|
+
import '@dynamic-labs/sdk-api-core';
|
|
15
|
+
import '../../../shared/consts/index.js';
|
|
16
|
+
import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
|
|
17
|
+
|
|
18
|
+
const INITIAL_STATE = {
|
|
19
|
+
error: null,
|
|
20
|
+
isLoading: false,
|
|
21
|
+
recoveryState: null,
|
|
22
|
+
};
|
|
23
|
+
const useWalletPassword = () => {
|
|
24
|
+
const { getWaasWalletConnector } = useDynamicWaas();
|
|
25
|
+
const [state, setState] = useState(INITIAL_STATE);
|
|
26
|
+
const resetState = useCallback(() => {
|
|
27
|
+
setState(INITIAL_STATE);
|
|
28
|
+
}, []);
|
|
29
|
+
const updatePassword = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
const { accountAddress, chainName, newPassword, existingPassword } = params;
|
|
31
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
32
|
+
try {
|
|
33
|
+
const connector = getWaasWalletConnector(chainName);
|
|
34
|
+
if (!connector) {
|
|
35
|
+
const errorMessage = 'Wallet connector not found';
|
|
36
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
37
|
+
logger.error(errorMessage, { accountAddress, chainName });
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
yield connector.updatePassword({
|
|
41
|
+
accountAddress,
|
|
42
|
+
existingPassword,
|
|
43
|
+
newPassword,
|
|
44
|
+
});
|
|
45
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to update password';
|
|
50
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
51
|
+
logger.error('Failed to update wallet password', {
|
|
52
|
+
accountAddress,
|
|
53
|
+
chainName,
|
|
54
|
+
error,
|
|
55
|
+
});
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}), [getWaasWalletConnector]);
|
|
59
|
+
const unlockWallet = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
const { accountAddress, chainName, password } = params;
|
|
61
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
62
|
+
try {
|
|
63
|
+
const connector = getWaasWalletConnector(chainName);
|
|
64
|
+
if (!connector) {
|
|
65
|
+
const errorMessage = 'Wallet connector not found';
|
|
66
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
67
|
+
logger.error(errorMessage, { accountAddress, chainName });
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
dynamicEvents.emit('walletUnlockAttempt', {
|
|
71
|
+
accountAddress,
|
|
72
|
+
chainName,
|
|
73
|
+
});
|
|
74
|
+
yield connector.unlockWallet({
|
|
75
|
+
accountAddress,
|
|
76
|
+
password,
|
|
77
|
+
});
|
|
78
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
79
|
+
dynamicEvents.emit('walletUnlockCompleted', {
|
|
80
|
+
accountAddress,
|
|
81
|
+
chainName,
|
|
82
|
+
});
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to unlock wallet';
|
|
87
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
88
|
+
logger.error('Failed to unlock wallet', {
|
|
89
|
+
accountAddress,
|
|
90
|
+
chainName,
|
|
91
|
+
error,
|
|
92
|
+
});
|
|
93
|
+
dynamicEvents.emit('walletUnlockFailed', {
|
|
94
|
+
accountAddress,
|
|
95
|
+
chainName,
|
|
96
|
+
error,
|
|
97
|
+
});
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}), [getWaasWalletConnector]);
|
|
101
|
+
const checkWalletLockState = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
const { accountAddress, chainName } = params;
|
|
103
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
104
|
+
try {
|
|
105
|
+
const connector = getWaasWalletConnector(chainName);
|
|
106
|
+
if (!connector) {
|
|
107
|
+
const errorMessage = 'Wallet connector not found';
|
|
108
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
109
|
+
logger.error(errorMessage, { accountAddress, chainName });
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const recoveryState = yield connector.getWalletRecoveryState({
|
|
113
|
+
accountAddress,
|
|
114
|
+
});
|
|
115
|
+
setState({
|
|
116
|
+
error: null,
|
|
117
|
+
isLoading: false,
|
|
118
|
+
recoveryState,
|
|
119
|
+
});
|
|
120
|
+
return recoveryState;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
const errorMessage = error instanceof Error
|
|
124
|
+
? error.message
|
|
125
|
+
: 'Failed to check wallet state';
|
|
126
|
+
setState({
|
|
127
|
+
error: errorMessage,
|
|
128
|
+
isLoading: false,
|
|
129
|
+
recoveryState: null,
|
|
130
|
+
});
|
|
131
|
+
logger.error('Failed to check wallet lock state', {
|
|
132
|
+
accountAddress,
|
|
133
|
+
chainName,
|
|
134
|
+
error,
|
|
135
|
+
});
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}), [getWaasWalletConnector]);
|
|
139
|
+
return {
|
|
140
|
+
checkWalletLockState,
|
|
141
|
+
resetState,
|
|
142
|
+
state,
|
|
143
|
+
unlockWallet,
|
|
144
|
+
updatePassword,
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export { useWalletPassword };
|
package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs
CHANGED
|
@@ -114,6 +114,7 @@ require('../../../../../store/state/tokenBalances.cjs');
|
|
|
114
114
|
require('../../../../../store/state/multichainBalances.cjs');
|
|
115
115
|
require('../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
116
116
|
var useIsPasskeysMfaEnabled = require('../../../../../utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.cjs');
|
|
117
|
+
var useWalletPassword = require('../../../../../utils/hooks/useWalletPassword/useWalletPassword.cjs');
|
|
117
118
|
var useInternalDynamicContext = require('../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
118
119
|
|
|
119
120
|
const MfaSection = ({ isLoading }) => {
|
|
@@ -123,6 +124,7 @@ const MfaSection = ({ isLoading }) => {
|
|
|
123
124
|
const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
124
125
|
const { getEOAWallet } = useSmartWallets.useSmartWallets();
|
|
125
126
|
const projectSettings = useProjectSettings.useProjectSettings();
|
|
127
|
+
const { updatePassword } = useWalletPassword.useWalletPassword();
|
|
126
128
|
const isMfaEnabled = useIsMfaEnabled.useIsMfaEnabled();
|
|
127
129
|
const isTotpMfaEnabled = useIsTotpMfaEnabled.useIsTotpMfaEnabled();
|
|
128
130
|
const isPasskeyMfaEnabled = useIsPasskeysMfaEnabled.useIsPasskeysMfaEnabled();
|
|
@@ -136,24 +138,19 @@ const MfaSection = ({ isLoading }) => {
|
|
|
136
138
|
const handlePasscodeClick = React.useCallback(() => {
|
|
137
139
|
setDynamicWidgetView('setup-password', {
|
|
138
140
|
onComplete: (password) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
-
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address)) {
|
|
140
|
-
logger.logger.error('No wallet address available for password setup');
|
|
141
|
+
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
142
|
+
logger.logger.error('No wallet address or chain available for password setup');
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
logger.logger.error('Failed to update password on modal', error);
|
|
153
|
-
}
|
|
145
|
+
yield updatePassword({
|
|
146
|
+
accountAddress: wallet.address,
|
|
147
|
+
chainName: wallet.chain,
|
|
148
|
+
existingPassword: '',
|
|
149
|
+
newPassword: password,
|
|
150
|
+
});
|
|
154
151
|
}),
|
|
155
152
|
});
|
|
156
|
-
}, [setDynamicWidgetView, wallet]);
|
|
153
|
+
}, [setDynamicWidgetView, wallet, updatePassword]);
|
|
157
154
|
if (!isMfaEnabled && !isWaasWallet) {
|
|
158
155
|
return null;
|
|
159
156
|
}
|
package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js
CHANGED
|
@@ -110,6 +110,7 @@ import '../../../../../store/state/tokenBalances.js';
|
|
|
110
110
|
import '../../../../../store/state/multichainBalances.js';
|
|
111
111
|
import '../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
112
112
|
import { useIsPasskeysMfaEnabled } from '../../../../../utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.js';
|
|
113
|
+
import { useWalletPassword } from '../../../../../utils/hooks/useWalletPassword/useWalletPassword.js';
|
|
113
114
|
import { useInternalDynamicContext } from '../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
114
115
|
|
|
115
116
|
const MfaSection = ({ isLoading }) => {
|
|
@@ -119,6 +120,7 @@ const MfaSection = ({ isLoading }) => {
|
|
|
119
120
|
const { primaryWallet } = useInternalDynamicContext();
|
|
120
121
|
const { getEOAWallet } = useSmartWallets();
|
|
121
122
|
const projectSettings = useProjectSettings();
|
|
123
|
+
const { updatePassword } = useWalletPassword();
|
|
122
124
|
const isMfaEnabled = useIsMfaEnabled();
|
|
123
125
|
const isTotpMfaEnabled = useIsTotpMfaEnabled();
|
|
124
126
|
const isPasskeyMfaEnabled = useIsPasskeysMfaEnabled();
|
|
@@ -132,24 +134,19 @@ const MfaSection = ({ isLoading }) => {
|
|
|
132
134
|
const handlePasscodeClick = useCallback(() => {
|
|
133
135
|
setDynamicWidgetView('setup-password', {
|
|
134
136
|
onComplete: (password) => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
-
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address)) {
|
|
136
|
-
logger.error('No wallet address available for password setup');
|
|
137
|
+
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
138
|
+
logger.error('No wallet address or chain available for password setup');
|
|
137
139
|
return;
|
|
138
140
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
logger.error('Failed to update password on modal', error);
|
|
149
|
-
}
|
|
141
|
+
yield updatePassword({
|
|
142
|
+
accountAddress: wallet.address,
|
|
143
|
+
chainName: wallet.chain,
|
|
144
|
+
existingPassword: '',
|
|
145
|
+
newPassword: password,
|
|
146
|
+
});
|
|
150
147
|
}),
|
|
151
148
|
});
|
|
152
|
-
}, [setDynamicWidgetView, wallet]);
|
|
149
|
+
}, [setDynamicWidgetView, wallet, updatePassword]);
|
|
153
150
|
if (!isMfaEnabled && !isWaasWallet) {
|
|
154
151
|
return null;
|
|
155
152
|
}
|
|
@@ -17,7 +17,7 @@ var SetupPasswordSuccessView = require('../SetupPasswordSuccessView/SetupPasswor
|
|
|
17
17
|
var SetupPasswordTermsView = require('../SetupPasswordTermsView/SetupPasswordTermsView.cjs');
|
|
18
18
|
|
|
19
19
|
const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }) => {
|
|
20
|
-
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
20
|
+
const { setDynamicWidgetView, setIsOpen } = DynamicWidgetContext.useWidgetContext();
|
|
21
21
|
const [currentStep, setCurrentStep] = React.useState('terms');
|
|
22
22
|
const [password, setPassword] = React.useState('');
|
|
23
23
|
const goToAccountAndSecurity = React.useCallback(() => {
|
|
@@ -64,15 +64,23 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
64
64
|
const handleSuccess = React.useCallback(() => {
|
|
65
65
|
onComplete(password);
|
|
66
66
|
// Navigate to appropriate view based on where we came from:
|
|
67
|
-
// - If onCancel was provided (auto-create flow), go to wallets
|
|
67
|
+
// - If onCancel was provided (auto-create flow), go to wallets then close widget
|
|
68
68
|
// - If onCancel wasn't provided (settings flow), go to account settings
|
|
69
69
|
if (onCancel) {
|
|
70
70
|
goToWallets();
|
|
71
|
+
setIsOpen(false);
|
|
71
72
|
}
|
|
72
73
|
else {
|
|
73
74
|
goToAccountAndSecurity();
|
|
74
75
|
}
|
|
75
|
-
}, [
|
|
76
|
+
}, [
|
|
77
|
+
onComplete,
|
|
78
|
+
password,
|
|
79
|
+
onCancel,
|
|
80
|
+
goToAccountAndSecurity,
|
|
81
|
+
goToWallets,
|
|
82
|
+
setIsOpen,
|
|
83
|
+
]);
|
|
76
84
|
switch (currentStep) {
|
|
77
85
|
case 'terms':
|
|
78
86
|
return (jsxRuntime.jsx(SetupPasswordTermsView.SetupPasswordTermsView, { onContinue: handleTermsContinue, onBack: onCancel ? undefined : handleCancel }));
|
|
@@ -13,7 +13,7 @@ import { SetupPasswordSuccessView } from '../SetupPasswordSuccessView/SetupPassw
|
|
|
13
13
|
import { SetupPasswordTermsView } from '../SetupPasswordTermsView/SetupPasswordTermsView.js';
|
|
14
14
|
|
|
15
15
|
const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }) => {
|
|
16
|
-
const { setDynamicWidgetView } = useWidgetContext();
|
|
16
|
+
const { setDynamicWidgetView, setIsOpen } = useWidgetContext();
|
|
17
17
|
const [currentStep, setCurrentStep] = useState('terms');
|
|
18
18
|
const [password, setPassword] = useState('');
|
|
19
19
|
const goToAccountAndSecurity = useCallback(() => {
|
|
@@ -60,15 +60,23 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
60
60
|
const handleSuccess = useCallback(() => {
|
|
61
61
|
onComplete(password);
|
|
62
62
|
// Navigate to appropriate view based on where we came from:
|
|
63
|
-
// - If onCancel was provided (auto-create flow), go to wallets
|
|
63
|
+
// - If onCancel was provided (auto-create flow), go to wallets then close widget
|
|
64
64
|
// - If onCancel wasn't provided (settings flow), go to account settings
|
|
65
65
|
if (onCancel) {
|
|
66
66
|
goToWallets();
|
|
67
|
+
setIsOpen(false);
|
|
67
68
|
}
|
|
68
69
|
else {
|
|
69
70
|
goToAccountAndSecurity();
|
|
70
71
|
}
|
|
71
|
-
}, [
|
|
72
|
+
}, [
|
|
73
|
+
onComplete,
|
|
74
|
+
password,
|
|
75
|
+
onCancel,
|
|
76
|
+
goToAccountAndSecurity,
|
|
77
|
+
goToWallets,
|
|
78
|
+
setIsOpen,
|
|
79
|
+
]);
|
|
72
80
|
switch (currentStep) {
|
|
73
81
|
case 'terms':
|
|
74
82
|
return (jsx(SetupPasswordTermsView, { onContinue: handleTermsContinue, onBack: onCancel ? undefined : handleCancel }));
|