@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.
- package/CHANGELOG.md +29 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +13 -13
- package/src/index.cjs +4 -0
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -0
- package/src/lib/Main.cjs +1 -0
- package/src/lib/Main.js +1 -0
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.cjs +1 -1
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.d.ts +5 -1
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.js +1 -1
- package/src/lib/components/ShadowDOM/ShadowDOM.cjs +6 -6
- package/src/lib/components/ShadowDOM/ShadowDOM.d.ts +4 -1
- package/src/lib/components/ShadowDOM/ShadowDOM.js +6 -6
- package/src/lib/context/DynamicContext/DynamicContext.cjs +4 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +4 -2
- package/src/lib/context/DynamicContext/types/DynamicContextProps.d.ts +6 -0
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +1 -0
- package/src/lib/context/DynamicContext/types/IInternalDynamicContext.d.ts +5 -1
- package/src/lib/context/ThemeContext/ThemeContext.cjs +3 -3
- package/src/lib/context/ThemeContext/ThemeContext.d.ts +1 -0
- package/src/lib/context/ThemeContext/ThemeContext.js +3 -3
- package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.cjs +8 -2
- package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.d.ts +2 -2
- package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.js +8 -2
- package/src/lib/data/api/wallets/wallets.cjs +62 -11
- package/src/lib/data/api/wallets/wallets.d.ts +1 -0
- package/src/lib/data/api/wallets/wallets.js +62 -12
- package/src/lib/shared/types/connectionAndSignature.d.ts +2 -1
- package/src/lib/shared/types/wallets.d.ts +2 -1
- package/src/lib/utils/functions/compareChains/compareChains.cjs +1 -0
- package/src/lib/utils/functions/compareChains/compareChains.js +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +6 -5
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +3 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +6 -5
- package/src/lib/utils/hooks/index.d.ts +3 -0
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +4 -1
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +4 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +5 -2
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +5 -2
- package/src/lib/utils/hooks/useSignEip7702Authorization/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.cjs +162 -0
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.d.ts +78 -0
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.js +158 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/index.d.ts +2 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.cjs +197 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.d.ts +51 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.js +193 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +3 -1
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +3 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +8 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.d.ts +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +9 -4
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.cjs +53 -1
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.d.ts +6 -0
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.js +53 -1
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs +1 -1
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js +1 -1
- package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.cjs +5 -21
- package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.js +5 -21
- package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.cjs +9 -1
- package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.js +9 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +17 -21
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +17 -21
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.cjs +26 -5
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.js +26 -5
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.cjs +3 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.js +3 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.js +2 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.cjs +30 -22
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.d.ts +2 -1
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.js +30 -22
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useState, useRef, useCallback } from 'react';
|
|
4
|
+
import { verifyOTP, sendEmailOTP, supportedCountries, sendSmsOTP } from '@dynamic-labs-sdk/client';
|
|
5
|
+
import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import '@dynamic-labs-sdk/client/core';
|
|
7
|
+
import '../../../client/client.js';
|
|
8
|
+
import '../../../config/ApiEndpoint.js';
|
|
9
|
+
import '@dynamic-labs/iconic';
|
|
10
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
11
|
+
import 'react/jsx-runtime';
|
|
12
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
13
|
+
import { logger } from '../../../shared/logger.js';
|
|
14
|
+
import '@dynamic-labs/wallet-book';
|
|
15
|
+
import '@dynamic-labs/utils';
|
|
16
|
+
import '../../constants/colors.js';
|
|
17
|
+
import '../../constants/values.js';
|
|
18
|
+
import '../../../shared/consts/index.js';
|
|
19
|
+
import '@dynamic-labs/multi-wallet';
|
|
20
|
+
import 'react-international-phone';
|
|
21
|
+
import '../../../store/state/nonce/nonce.js';
|
|
22
|
+
import '@dynamic-labs/locale';
|
|
23
|
+
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
24
|
+
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
25
|
+
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
26
|
+
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
27
|
+
import '../../../events/dynamicEvents.js';
|
|
28
|
+
import { useUser } from '../../../client/extension/user/useUser/useUser.js';
|
|
29
|
+
import { useConnectAndSign } from '../authenticationHooks/useConnectAndSign/useConnectAndSign.js';
|
|
30
|
+
import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
31
|
+
|
|
32
|
+
const INITIAL_STATE = {
|
|
33
|
+
error: null,
|
|
34
|
+
isLoading: false,
|
|
35
|
+
otpVerification: null,
|
|
36
|
+
};
|
|
37
|
+
const isCountryCode = (value) => value !== undefined && value in supportedCountries;
|
|
38
|
+
const isOtpCapableCredential = (cred) => cred.format === JwtVerifiedCredentialFormatEnum.Email ||
|
|
39
|
+
cred.format === JwtVerifiedCredentialFormatEnum.PhoneNumber;
|
|
40
|
+
const resolveTargetCredential = (credentials, credentialId) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
if (credentialId) {
|
|
43
|
+
return ((_a = credentials.find((cred) => cred.id === credentialId)) !== null && _a !== void 0 ? _a : `Credential with id "${credentialId}" not found`);
|
|
44
|
+
}
|
|
45
|
+
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');
|
|
46
|
+
};
|
|
47
|
+
const sendEmailOtp = (credential) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
if (!credential.email) {
|
|
49
|
+
throw new Error('Email credential is missing email address');
|
|
50
|
+
}
|
|
51
|
+
return sendEmailOTP({ email: credential.email });
|
|
52
|
+
});
|
|
53
|
+
const sendSmsOtp = (credential) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
var _a;
|
|
55
|
+
const normalizedPhoneCountryCode = (_a = credential.phoneCountryCode) === null || _a === void 0 ? void 0 : _a.replace(/^\+/, '');
|
|
56
|
+
const matchedCountryCode = Object.keys(supportedCountries).find((key) => supportedCountries[key].code === normalizedPhoneCountryCode);
|
|
57
|
+
const isoCountryCode = isCountryCode(credential.isoCountryCode)
|
|
58
|
+
? credential.isoCountryCode
|
|
59
|
+
: matchedCountryCode;
|
|
60
|
+
if (!credential.phoneNumber || !isoCountryCode) {
|
|
61
|
+
throw new Error('SMS credential is missing phone number or country code');
|
|
62
|
+
}
|
|
63
|
+
return sendSmsOTP({ isoCountryCode, phoneNumber: credential.phoneNumber });
|
|
64
|
+
});
|
|
65
|
+
const dispatchOtp = (credential) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
return credential.format === JwtVerifiedCredentialFormatEnum.Email
|
|
67
|
+
? sendEmailOtp(credential)
|
|
68
|
+
: sendSmsOtp(credential);
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* Perform step-up authentication for an already-authenticated user via OTP.
|
|
72
|
+
*
|
|
73
|
+
* Automatically selects the first sign-in enabled email or SMS credential on
|
|
74
|
+
* the user, or targets a specific credential when `credentialId` is provided.
|
|
75
|
+
*
|
|
76
|
+
* @param params.credentialId - Optional id of a specific verified credential to
|
|
77
|
+
* use. Must be an email or SMS credential. Defaults to the first sign-in
|
|
78
|
+
* enabled email or SMS credential on the authenticated user.
|
|
79
|
+
*
|
|
80
|
+
* @returns `sendOtp` – sends the OTP to the resolved credential.
|
|
81
|
+
* @returns `verifyOtp` – verifies the OTP code supplied by the user.
|
|
82
|
+
* @returns `state` – current loading / error / otpVerification state.
|
|
83
|
+
* @returns `resetState` – resets state back to its initial value.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* const { sendOtp, verifyOtp, state } = useStepUpAuthentication();
|
|
88
|
+
*
|
|
89
|
+
* // Step 1: send OTP
|
|
90
|
+
* await sendOtp();
|
|
91
|
+
*
|
|
92
|
+
* // Step 2: after the user enters the code
|
|
93
|
+
* const result = await verifyOtp({ verificationToken: '123456' });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
const useStepUpAuthentication = ({ credentialId, } = {}) => {
|
|
97
|
+
const user = useUser();
|
|
98
|
+
const [state, setState] = useState(INITIAL_STATE);
|
|
99
|
+
const connectAndSign = useConnectAndSign();
|
|
100
|
+
const { userWallets } = useInternalUserWallets();
|
|
101
|
+
// Ref keeps the latest otpVerification available inside the verifyOtp
|
|
102
|
+
// callback without creating a stale closure over state.
|
|
103
|
+
const otpVerificationRef = useRef(null);
|
|
104
|
+
const resetState = useCallback(() => {
|
|
105
|
+
otpVerificationRef.current = null;
|
|
106
|
+
setState(INITIAL_STATE);
|
|
107
|
+
}, []);
|
|
108
|
+
const setError = useCallback((errorMessage) => {
|
|
109
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
110
|
+
logger.error(errorMessage);
|
|
111
|
+
}, []);
|
|
112
|
+
const sendOtp = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
+
const credentials = user === null || user === void 0 ? void 0 : user.verifiedCredentials;
|
|
114
|
+
if (!(credentials === null || credentials === void 0 ? void 0 : credentials.length)) {
|
|
115
|
+
setError('No verified credentials found for the authenticated user');
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const result = resolveTargetCredential(credentials, credentialId);
|
|
119
|
+
if (typeof result === 'string') {
|
|
120
|
+
setError(result);
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (!isOtpCapableCredential(result)) {
|
|
124
|
+
setError(`Credential format "${result.format}" does not support OTP verification. Only email and SMS credentials are supported`);
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
128
|
+
try {
|
|
129
|
+
const otpVerification = yield dispatchOtp(result);
|
|
130
|
+
otpVerificationRef.current = otpVerification;
|
|
131
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false, otpVerification })));
|
|
132
|
+
return otpVerification;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to send OTP';
|
|
136
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
137
|
+
logger.error('Failed to send OTP for step-up authentication', { error });
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}), [credentialId, setError, user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
|
|
141
|
+
const verifyOtp = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ requestedScopes, verificationToken, }) {
|
|
142
|
+
const otpVerification = otpVerificationRef.current;
|
|
143
|
+
if (!otpVerification) {
|
|
144
|
+
setError('OTP verification has not been initiated. Call sendOtp() first');
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
148
|
+
try {
|
|
149
|
+
const response = yield verifyOTP({
|
|
150
|
+
otpVerification,
|
|
151
|
+
requestedScopes,
|
|
152
|
+
verificationToken,
|
|
153
|
+
});
|
|
154
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
155
|
+
return response;
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to verify OTP';
|
|
159
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
160
|
+
logger.error('Failed to verify OTP for step-up authentication', {
|
|
161
|
+
error,
|
|
162
|
+
});
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
}), [setError]);
|
|
166
|
+
const verifyWallet = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({ requestedScopes }) {
|
|
167
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
168
|
+
const wallet = userWallets.find((w) => w.id === credentialId);
|
|
169
|
+
if (!wallet) {
|
|
170
|
+
setError(`Wallet with id "${credentialId}" not found`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
yield connectAndSign({
|
|
175
|
+
requestedScopes,
|
|
176
|
+
walletConnector: wallet.connector,
|
|
177
|
+
});
|
|
178
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { isLoading: false })));
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
const errorMessage = error instanceof Error
|
|
182
|
+
? error.message
|
|
183
|
+
: 'Failed to verify wallet for step-up authentication';
|
|
184
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
185
|
+
logger.error('Failed to verify wallet for step-up authentication', {
|
|
186
|
+
error,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}), [connectAndSign, credentialId, setError, userWallets]);
|
|
190
|
+
return { resetState, sendOtp, state, verifyOtp, verifyWallet };
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export { useStepUpAuthentication };
|
|
@@ -160,7 +160,9 @@ const useWalletCreation = () => {
|
|
|
160
160
|
try {
|
|
161
161
|
// If passcodeRequired is enabled, prompt user to set up password first
|
|
162
162
|
const password = yield setupPassword();
|
|
163
|
-
yield createWalletAccount(requirements, password
|
|
163
|
+
yield createWalletAccount(requirements, password, undefined, {
|
|
164
|
+
skipCloseAuthFlow: Boolean(password),
|
|
165
|
+
});
|
|
164
166
|
const duration = Date.now() - startTime;
|
|
165
167
|
// Log successful wallet creation to DataDog
|
|
166
168
|
logger.logger.instrument('Auto wallet creation successful', {
|
|
@@ -156,7 +156,9 @@ const useWalletCreation = () => {
|
|
|
156
156
|
try {
|
|
157
157
|
// If passcodeRequired is enabled, prompt user to set up password first
|
|
158
158
|
const password = yield setupPassword();
|
|
159
|
-
yield createWalletAccount(requirements, password
|
|
159
|
+
yield createWalletAccount(requirements, password, undefined, {
|
|
160
|
+
skipCloseAuthFlow: Boolean(password),
|
|
161
|
+
});
|
|
160
162
|
const duration = Date.now() - startTime;
|
|
161
163
|
// Log successful wallet creation to DataDog
|
|
162
164
|
logger.instrument('Auto wallet creation successful', {
|
|
@@ -134,7 +134,7 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
134
134
|
// We need this boolean to distinguish between logic for verify or linking.
|
|
135
135
|
const verifyOnly = !user;
|
|
136
136
|
const shouldFallbackToConnectOnly = enableConnectOnlyFallback && (verifyOnly || !multiWalletEnabled);
|
|
137
|
-
const generateJWT = (walletConnector, walletProvider, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
+
const generateJWT = (walletConnector, walletProvider, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, requestedScopes) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
138
138
|
const verifyArgs = yield getVerifyArgs.getVerifyArgs({
|
|
139
139
|
displaySiweStatement,
|
|
140
140
|
environmentId,
|
|
@@ -156,6 +156,11 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
156
156
|
verifyResponse = wallets.verifyWallet(environmentId, Object.assign(Object.assign({}, verifyArgs), { captchaToken,
|
|
157
157
|
oauth }));
|
|
158
158
|
}
|
|
159
|
+
else if (user && requestedScopes) {
|
|
160
|
+
verifyResponse = wallets.walletsVerify(environmentId, Object.assign(Object.assign({}, verifyArgs), { captchaToken,
|
|
161
|
+
oauth,
|
|
162
|
+
requestedScopes }));
|
|
163
|
+
}
|
|
159
164
|
else {
|
|
160
165
|
verifyResponse = wallets.linkWallet(environmentId, verifyArgs);
|
|
161
166
|
}
|
|
@@ -285,7 +290,7 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
285
290
|
setErrorMessage(e.code);
|
|
286
291
|
}
|
|
287
292
|
};
|
|
288
|
-
return (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, }) {
|
|
293
|
+
return (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, requestedScopes, }) {
|
|
289
294
|
const walletProvider = walletConnectorCore.getWalletProvider(walletConnector);
|
|
290
295
|
dynamicEvents.dynamicEvents.emit('authInit', {
|
|
291
296
|
address: publicWalletAddress,
|
|
@@ -294,7 +299,7 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
294
299
|
type: 'wallet',
|
|
295
300
|
});
|
|
296
301
|
try {
|
|
297
|
-
const { verifyFunction, verifyArgs } = yield generateJWT(walletConnector, walletProvider, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride);
|
|
302
|
+
const { verifyFunction, verifyArgs } = yield generateJWT(walletConnector, walletProvider, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, requestedScopes);
|
|
298
303
|
yield initAuth({
|
|
299
304
|
isSignIn: verifyOnly,
|
|
300
305
|
onError: (e) => {
|
|
@@ -7,5 +7,5 @@ type UseVerifyWalletArgs = {
|
|
|
7
7
|
displaySiweStatement: boolean;
|
|
8
8
|
setIsSingleWalletAccount: Dispatch<SetStateAction<boolean>>;
|
|
9
9
|
};
|
|
10
|
-
export declare const useVerifyWallet: ({ displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, }: UseVerifyWalletArgs) => ({ walletConnector, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, }: VerifyCallbackArgs) => Promise<void>;
|
|
10
|
+
export declare const useVerifyWallet: ({ displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, }: UseVerifyWalletArgs) => ({ walletConnector, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, requestedScopes, }: VerifyCallbackArgs) => Promise<void>;
|
|
11
11
|
export {};
|
|
@@ -34,7 +34,7 @@ import '../../../client/client.js';
|
|
|
34
34
|
import '@dynamic-labs-sdk/client';
|
|
35
35
|
import '../../../config/ApiEndpoint.js';
|
|
36
36
|
import '@dynamic-labs/locale';
|
|
37
|
-
import { verifyWallet, linkWallet } from '../../../data/api/wallets/wallets.js';
|
|
37
|
+
import { verifyWallet, walletsVerify, linkWallet } from '../../../data/api/wallets/wallets.js';
|
|
38
38
|
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
39
39
|
import { useAccessDeniedContext } from '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
40
40
|
import { useAccountExistsContext } from '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
@@ -130,7 +130,7 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
130
130
|
// We need this boolean to distinguish between logic for verify or linking.
|
|
131
131
|
const verifyOnly = !user;
|
|
132
132
|
const shouldFallbackToConnectOnly = enableConnectOnlyFallback && (verifyOnly || !multiWalletEnabled);
|
|
133
|
-
const generateJWT = (walletConnector, walletProvider, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride) => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
+
const generateJWT = (walletConnector, walletProvider, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, requestedScopes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
134
134
|
const verifyArgs = yield getVerifyArgs({
|
|
135
135
|
displaySiweStatement,
|
|
136
136
|
environmentId,
|
|
@@ -152,6 +152,11 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
152
152
|
verifyResponse = verifyWallet(environmentId, Object.assign(Object.assign({}, verifyArgs), { captchaToken,
|
|
153
153
|
oauth }));
|
|
154
154
|
}
|
|
155
|
+
else if (user && requestedScopes) {
|
|
156
|
+
verifyResponse = walletsVerify(environmentId, Object.assign(Object.assign({}, verifyArgs), { captchaToken,
|
|
157
|
+
oauth,
|
|
158
|
+
requestedScopes }));
|
|
159
|
+
}
|
|
155
160
|
else {
|
|
156
161
|
verifyResponse = linkWallet(environmentId, verifyArgs);
|
|
157
162
|
}
|
|
@@ -281,7 +286,7 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
281
286
|
setErrorMessage(e.code);
|
|
282
287
|
}
|
|
283
288
|
};
|
|
284
|
-
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, }) {
|
|
289
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, requestedScopes, }) {
|
|
285
290
|
const walletProvider = getWalletProvider(walletConnector);
|
|
286
291
|
dynamicEvents.emit('authInit', {
|
|
287
292
|
address: publicWalletAddress,
|
|
@@ -290,7 +295,7 @@ const useVerifyWallet = ({ displaySiweStatement, environmentId, projectSettings,
|
|
|
290
295
|
type: 'wallet',
|
|
291
296
|
});
|
|
292
297
|
try {
|
|
293
|
-
const { verifyFunction, verifyArgs } = yield generateJWT(walletConnector, walletProvider, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride);
|
|
298
|
+
const { verifyFunction, verifyArgs } = yield generateJWT(walletConnector, walletProvider, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, requestedScopes);
|
|
294
299
|
yield initAuth({
|
|
295
300
|
isSignIn: verifyOnly,
|
|
296
301
|
onError: (e) => {
|
|
@@ -18,6 +18,7 @@ require('../../constants/values.cjs');
|
|
|
18
18
|
require('@dynamic-labs/sdk-api-core');
|
|
19
19
|
require('../../../shared/consts/index.cjs');
|
|
20
20
|
var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
|
|
21
|
+
var useRefreshUser = require('../useRefreshUser/useRefreshUser.cjs');
|
|
21
22
|
|
|
22
23
|
const INITIAL_STATE = {
|
|
23
24
|
error: null,
|
|
@@ -26,10 +27,50 @@ const INITIAL_STATE = {
|
|
|
26
27
|
};
|
|
27
28
|
const useWalletPassword = () => {
|
|
28
29
|
const { getWaasWalletConnector } = useDynamicWaas.useDynamicWaas();
|
|
30
|
+
const refreshUser = useRefreshUser.useRefreshUser();
|
|
29
31
|
const [state, setState] = React.useState(INITIAL_STATE);
|
|
30
32
|
const resetState = React.useCallback(() => {
|
|
31
33
|
setState(INITIAL_STATE);
|
|
32
34
|
}, []);
|
|
35
|
+
const setPassword = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
const { accountAddress, chainName, newPassword } = params;
|
|
37
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
38
|
+
try {
|
|
39
|
+
const connector = getWaasWalletConnector(chainName);
|
|
40
|
+
if (!connector) {
|
|
41
|
+
const errorMessage = 'Wallet connector not found';
|
|
42
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
43
|
+
logger.logger.error(errorMessage, { accountAddress, chainName });
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
yield connector.setPassword({
|
|
47
|
+
accountAddress,
|
|
48
|
+
newPassword,
|
|
49
|
+
});
|
|
50
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
51
|
+
try {
|
|
52
|
+
yield refreshUser();
|
|
53
|
+
}
|
|
54
|
+
catch (refreshError) {
|
|
55
|
+
logger.logger.warn('Failed to refresh user after setting password', {
|
|
56
|
+
accountAddress,
|
|
57
|
+
chainName,
|
|
58
|
+
refreshError,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to set password';
|
|
65
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
66
|
+
logger.logger.error('Failed to set wallet password', {
|
|
67
|
+
accountAddress,
|
|
68
|
+
chainName,
|
|
69
|
+
error,
|
|
70
|
+
});
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}), [getWaasWalletConnector, refreshUser]);
|
|
33
74
|
const updatePassword = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
34
75
|
const { accountAddress, chainName, newPassword, existingPassword } = params;
|
|
35
76
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
@@ -47,6 +88,16 @@ const useWalletPassword = () => {
|
|
|
47
88
|
newPassword,
|
|
48
89
|
});
|
|
49
90
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
91
|
+
try {
|
|
92
|
+
yield refreshUser();
|
|
93
|
+
}
|
|
94
|
+
catch (refreshError) {
|
|
95
|
+
logger.logger.warn('Failed to refresh user after updating password', {
|
|
96
|
+
accountAddress,
|
|
97
|
+
chainName,
|
|
98
|
+
refreshError,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
50
101
|
return true;
|
|
51
102
|
}
|
|
52
103
|
catch (error) {
|
|
@@ -59,7 +110,7 @@ const useWalletPassword = () => {
|
|
|
59
110
|
});
|
|
60
111
|
return false;
|
|
61
112
|
}
|
|
62
|
-
}), [getWaasWalletConnector]);
|
|
113
|
+
}), [getWaasWalletConnector, refreshUser]);
|
|
63
114
|
const unlockWallet = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
115
|
const { accountAddress, chainName, password } = params;
|
|
65
116
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
@@ -143,6 +194,7 @@ const useWalletPassword = () => {
|
|
|
143
194
|
return {
|
|
144
195
|
checkWalletLockState,
|
|
145
196
|
resetState,
|
|
197
|
+
setPassword,
|
|
146
198
|
state,
|
|
147
199
|
unlockWallet,
|
|
148
200
|
updatePassword,
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { WalletRecoveryState } from '@dynamic-labs-wallet/browser-wallet-client';
|
|
2
2
|
import { ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
export type SetPasswordParams = {
|
|
4
|
+
accountAddress: string;
|
|
5
|
+
chainName: ChainEnum;
|
|
6
|
+
newPassword: string;
|
|
7
|
+
};
|
|
3
8
|
export type UpdatePasswordParams = {
|
|
4
9
|
accountAddress: string;
|
|
5
10
|
chainName: ChainEnum;
|
|
@@ -21,6 +26,7 @@ export type WalletPasswordState = {
|
|
|
21
26
|
recoveryState: WalletRecoveryState | null;
|
|
22
27
|
};
|
|
23
28
|
export type UseWalletPasswordReturn = {
|
|
29
|
+
setPassword: (params: SetPasswordParams) => Promise<boolean>;
|
|
24
30
|
updatePassword: (params: UpdatePasswordParams) => Promise<boolean>;
|
|
25
31
|
unlockWallet: (params: UnlockWalletParams) => Promise<boolean>;
|
|
26
32
|
checkWalletLockState: (params: CheckWalletLockStateParams) => Promise<WalletRecoveryState | null>;
|
|
@@ -14,6 +14,7 @@ import '../../constants/values.js';
|
|
|
14
14
|
import '@dynamic-labs/sdk-api-core';
|
|
15
15
|
import '../../../shared/consts/index.js';
|
|
16
16
|
import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
|
|
17
|
+
import { useRefreshUser } from '../useRefreshUser/useRefreshUser.js';
|
|
17
18
|
|
|
18
19
|
const INITIAL_STATE = {
|
|
19
20
|
error: null,
|
|
@@ -22,10 +23,50 @@ const INITIAL_STATE = {
|
|
|
22
23
|
};
|
|
23
24
|
const useWalletPassword = () => {
|
|
24
25
|
const { getWaasWalletConnector } = useDynamicWaas();
|
|
26
|
+
const refreshUser = useRefreshUser();
|
|
25
27
|
const [state, setState] = useState(INITIAL_STATE);
|
|
26
28
|
const resetState = useCallback(() => {
|
|
27
29
|
setState(INITIAL_STATE);
|
|
28
30
|
}, []);
|
|
31
|
+
const setPassword = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
const { accountAddress, chainName, newPassword } = params;
|
|
33
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
34
|
+
try {
|
|
35
|
+
const connector = getWaasWalletConnector(chainName);
|
|
36
|
+
if (!connector) {
|
|
37
|
+
const errorMessage = 'Wallet connector not found';
|
|
38
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
39
|
+
logger.error(errorMessage, { accountAddress, chainName });
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
yield connector.setPassword({
|
|
43
|
+
accountAddress,
|
|
44
|
+
newPassword,
|
|
45
|
+
});
|
|
46
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
47
|
+
try {
|
|
48
|
+
yield refreshUser();
|
|
49
|
+
}
|
|
50
|
+
catch (refreshError) {
|
|
51
|
+
logger.warn('Failed to refresh user after setting password', {
|
|
52
|
+
accountAddress,
|
|
53
|
+
chainName,
|
|
54
|
+
refreshError,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to set password';
|
|
61
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
62
|
+
logger.error('Failed to set wallet password', {
|
|
63
|
+
accountAddress,
|
|
64
|
+
chainName,
|
|
65
|
+
error,
|
|
66
|
+
});
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}), [getWaasWalletConnector, refreshUser]);
|
|
29
70
|
const updatePassword = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
71
|
const { accountAddress, chainName, newPassword, existingPassword } = params;
|
|
31
72
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
@@ -43,6 +84,16 @@ const useWalletPassword = () => {
|
|
|
43
84
|
newPassword,
|
|
44
85
|
});
|
|
45
86
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
87
|
+
try {
|
|
88
|
+
yield refreshUser();
|
|
89
|
+
}
|
|
90
|
+
catch (refreshError) {
|
|
91
|
+
logger.warn('Failed to refresh user after updating password', {
|
|
92
|
+
accountAddress,
|
|
93
|
+
chainName,
|
|
94
|
+
refreshError,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
46
97
|
return true;
|
|
47
98
|
}
|
|
48
99
|
catch (error) {
|
|
@@ -55,7 +106,7 @@ const useWalletPassword = () => {
|
|
|
55
106
|
});
|
|
56
107
|
return false;
|
|
57
108
|
}
|
|
58
|
-
}), [getWaasWalletConnector]);
|
|
109
|
+
}), [getWaasWalletConnector, refreshUser]);
|
|
59
110
|
const unlockWallet = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
111
|
const { accountAddress, chainName, password } = params;
|
|
61
112
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
@@ -139,6 +190,7 @@ const useWalletPassword = () => {
|
|
|
139
190
|
return {
|
|
140
191
|
checkWalletLockState,
|
|
141
192
|
resetState,
|
|
193
|
+
setPassword,
|
|
142
194
|
state,
|
|
143
195
|
unlockWallet,
|
|
144
196
|
updatePassword,
|
|
@@ -124,8 +124,8 @@ const MfaDisplayBackupCodesView = ({ regenerateCodes = false, }) => {
|
|
|
124
124
|
const { data: codes, isLoading } = usePromise.usePromise(() => getRecoveryCodes(regenerateCodes));
|
|
125
125
|
const codesAsString = (codes || []).join('\n');
|
|
126
126
|
const handleCompleteAcknowledgement = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
127
|
-
setShowAuthFlow(false);
|
|
128
127
|
yield completeAcknowledgement();
|
|
128
|
+
setShowAuthFlow(false);
|
|
129
129
|
});
|
|
130
130
|
const handleDownload = (e) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
131
131
|
e.preventDefault();
|
|
@@ -120,8 +120,8 @@ const MfaDisplayBackupCodesView = ({ regenerateCodes = false, }) => {
|
|
|
120
120
|
const { data: codes, isLoading } = usePromise(() => getRecoveryCodes(regenerateCodes));
|
|
121
121
|
const codesAsString = (codes || []).join('\n');
|
|
122
122
|
const handleCompleteAcknowledgement = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
-
setShowAuthFlow(false);
|
|
124
123
|
yield completeAcknowledgement();
|
|
124
|
+
setShowAuthFlow(false);
|
|
125
125
|
});
|
|
126
126
|
const handleDownload = (e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
127
|
e.preventDefault();
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
7
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
7
|
var React = require('react');
|
|
9
8
|
require('../../context/DynamicContext/DynamicContext.cjs');
|
|
@@ -11,7 +10,7 @@ require('../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
|
11
10
|
require('@dynamic-labs/iconic');
|
|
12
11
|
require('@dynamic-labs/wallet-connector-core');
|
|
13
12
|
require('../../context/ViewContext/ViewContext.cjs');
|
|
14
|
-
|
|
13
|
+
require('../../shared/logger.cjs');
|
|
15
14
|
require('@dynamic-labs/wallet-book');
|
|
16
15
|
require('@dynamic-labs/utils');
|
|
17
16
|
require('../../utils/constants/colors.cjs');
|
|
@@ -19,6 +18,7 @@ require('../../utils/constants/values.cjs');
|
|
|
19
18
|
require('@dynamic-labs/sdk-api-core');
|
|
20
19
|
require('../../shared/consts/index.cjs');
|
|
21
20
|
require('../../events/dynamicEvents.cjs');
|
|
21
|
+
require('../../../../_virtual/_tslib.cjs');
|
|
22
22
|
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
23
23
|
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
24
24
|
require('@dynamic-labs/multi-wallet');
|
|
@@ -42,7 +42,6 @@ require('react-dom');
|
|
|
42
42
|
require('../../utils/functions/compareChains/compareChains.cjs');
|
|
43
43
|
require('../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
44
44
|
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
45
|
-
var useSmartWallets = require('../../utils/hooks/useSmartWallets/useSmartWallets.cjs');
|
|
46
45
|
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
47
46
|
require('bs58');
|
|
48
47
|
require('@dynamic-labs/types');
|
|
@@ -92,7 +91,6 @@ require('../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
|
92
91
|
require('../../context/FooterAnimationContext/index.cjs');
|
|
93
92
|
require('../MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
|
|
94
93
|
require('../../context/PasskeyContext/PasskeyContext.cjs');
|
|
95
|
-
var useWalletPassword = require('../../utils/hooks/useWalletPassword/useWalletPassword.cjs');
|
|
96
94
|
var ResetPasswordView = require('../../widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.cjs');
|
|
97
95
|
require('../../context/OnrampContext/OnrampContext.cjs');
|
|
98
96
|
require('../../store/state/sendBalances.cjs');
|
|
@@ -110,24 +108,10 @@ require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
110
108
|
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
111
109
|
|
|
112
110
|
const ResetPasswordForSettingsView = () => {
|
|
113
|
-
const {
|
|
114
|
-
const
|
|
115
|
-
const { updatePassword } = useWalletPassword.useWalletPassword();
|
|
116
|
-
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
117
|
-
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
118
|
-
const handleComplete = React.useCallback((oldPassword, newPassword) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
-
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
120
|
-
logger.logger.error('No wallet address or chain available for password reset');
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
yield updatePassword({
|
|
124
|
-
accountAddress: wallet.address,
|
|
125
|
-
chainName: wallet.chain,
|
|
126
|
-
existingPassword: oldPassword,
|
|
127
|
-
newPassword,
|
|
128
|
-
});
|
|
111
|
+
const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
112
|
+
const handleComplete = React.useCallback(() => {
|
|
129
113
|
setShowAuthFlow(false);
|
|
130
|
-
}
|
|
114
|
+
}, [setShowAuthFlow]);
|
|
131
115
|
return jsxRuntime.jsx(ResetPasswordView.ResetPasswordView, { onComplete: handleComplete });
|
|
132
116
|
};
|
|
133
117
|
|