@dynamic-labs/sdk-react-core 4.10.0 → 4.10.2
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 +17 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/api.d.ts +1 -0
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +1 -1
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +1 -1
- package/src/lib/components/DynamicSpinner/DynamicSpinner.d.ts +3 -0
- package/src/lib/components/DynamicSpinner/index.d.ts +1 -0
- package/src/lib/components/IconWithSpinner/IconWithSpinner.cjs +2 -5
- package/src/lib/components/IconWithSpinner/IconWithSpinner.d.ts +3 -3
- package/src/lib/components/IconWithSpinner/IconWithSpinner.js +2 -5
- package/src/lib/components/Popper/PopperContext/PopperContext.cjs +2 -2
- package/src/lib/components/Popper/PopperContext/PopperContext.d.ts +2 -1
- package/src/lib/components/Popper/PopperContext/PopperContext.js +2 -2
- package/src/lib/components/QrCodeWrapper/QrCodeWrapper.cjs +7 -7
- package/src/lib/components/QrCodeWrapper/QrCodeWrapper.js +7 -7
- package/src/lib/components/SocialSignIn/SocialSignIn.cjs +1 -1
- package/src/lib/components/SocialSignIn/SocialSignIn.js +1 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +8 -8
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +8 -8
- package/src/lib/components/Typography/Typography.cjs +1 -0
- package/src/lib/components/Typography/Typography.js +1 -0
- package/src/lib/components/Typography/Typography.types.d.ts +1 -1
- package/src/lib/components/index.d.ts +8 -7
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +4 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +4 -0
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +1 -1
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +1 -1
- package/src/lib/data/api/index.d.ts +1 -0
- package/src/lib/data/api/transactions/index.d.ts +1 -0
- package/src/lib/events/dynamicEvents.cjs +1 -0
- package/src/lib/events/dynamicEvents.d.ts +2 -2
- package/src/lib/events/dynamicEvents.js +1 -0
- package/src/lib/events/ui.d.ts +8 -0
- package/src/lib/main.global.cjs +1 -1
- package/src/lib/main.global.js +1 -1
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +8 -8
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +8 -8
- package/src/lib/shared/assets/index.d.ts +2 -1
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +6 -1
- package/src/lib/shared/types/wallets.d.ts +10 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +56 -39
- package/src/lib/utils/hooks/useMfa/useMfa.d.ts +5 -0
- package/src/lib/utils/hooks/useMfa/useMfa.js +57 -40
- package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.cjs +23 -82
- package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.js +23 -82
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +1 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +1 -1
- package/src/lib/utils/hooks/useSocialAuth/farcaster/farcaster.cjs +13 -6
- package/src/lib/utils/hooks/useSocialAuth/farcaster/farcaster.d.ts +13 -3
- package/src/lib/utils/hooks/useSocialAuth/farcaster/farcaster.js +13 -6
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +13 -12
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +13 -12
- package/src/lib/utils/hooks/useSyncEmbeddedWalletFlow/useSyncEmbeddedWalletFlow.cjs +1 -1
- package/src/lib/utils/hooks/useSyncEmbeddedWalletFlow/useSyncEmbeddedWalletFlow.js +1 -1
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.cjs +1 -1
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.js +1 -1
- package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.cjs +1 -1
- package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.js +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -1
- package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.cjs +1 -1
- package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.js +1 -1
- package/src/lib/views/MfaRecoveryView/MfaRecoveryView.cjs +1 -1
- package/src/lib/views/MfaRecoveryView/MfaRecoveryView.js +1 -1
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +4 -4
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +4 -4
- package/src/lib/views/Passkey/PasskeyRecovery/AddRecoveryEmail/AddRecoveryEmail.cjs +1 -1
- package/src/lib/views/Passkey/PasskeyRecovery/AddRecoveryEmail/AddRecoveryEmail.js +1 -1
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +1 -1
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +1 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +1 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +1 -1
- package/src/lib/views/WalletList/hooks/useTabState.cjs +29 -4
- package/src/lib/views/WalletList/hooks/useTabState.d.ts +2 -2
- package/src/lib/views/WalletList/hooks/useTabState.js +30 -5
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +1 -1
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeUserProfile/DynamicBridgeUserProfile.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeUserProfile/DynamicBridgeUserProfile.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +2 -2
|
@@ -4,5 +4,5 @@ type DynamicEventListener<E extends keyof DynamicEvents> = (...args: EventArgs<D
|
|
|
4
4
|
/** Allows us to subscribe to all dynamicEvents with a hook, even the internal ones */
|
|
5
5
|
export declare const useInternalDynamicEvents: <E extends keyof import("../../../../events/auth").AuthEvents | keyof import("../../../../events/ui").UIEvents | keyof import("../../../../events/otp").OTPEvents | keyof import("../../../../events/wallets").WalletEvents | keyof import("../../../../events/passkey").PasskeyEvents | "farcasterConnectCancelled" | keyof import("../../../../events/embeddedWallet").EmbeddedWalletEvents | keyof import("../../../../events/multiWallet").MultiWalletInternalEvents | "tokenBalancesChanged" | "userProfileUpdated" | "walletConnectedForFunding">(event: E, listener: DynamicEventListener<E>) => void;
|
|
6
6
|
/** Allows subscribing to dynamic events directly inside components with a hook */
|
|
7
|
-
export declare const useDynamicEvents: <E extends "authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "embeddedWalletCreated" | "walletConnectedForFunding">(event: E, listener: DynamicEventListener<E>) => void;
|
|
7
|
+
export declare const useDynamicEvents: <E extends "authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "walletTabSelected" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "embeddedWalletCreated" | "walletConnectedForFunding">(event: E, listener: DynamicEventListener<E>) => void;
|
|
8
8
|
export {};
|
|
@@ -55,6 +55,7 @@ require('../../../store/state/walletOptions/walletOptions.cjs');
|
|
|
55
55
|
require('react-i18next');
|
|
56
56
|
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
57
57
|
require('../../../components/Alert/Alert.cjs');
|
|
58
|
+
require('../../../context/WalletContext/WalletContext.cjs');
|
|
58
59
|
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
59
60
|
require('../../../components/IconButton/IconButton.cjs');
|
|
60
61
|
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
@@ -70,7 +71,6 @@ require('../../../components/Popper/Popper/Popper.cjs');
|
|
|
70
71
|
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
71
72
|
require('react-focus-lock');
|
|
72
73
|
require('qrcode');
|
|
73
|
-
require('../../../context/WalletContext/WalletContext.cjs');
|
|
74
74
|
require('formik');
|
|
75
75
|
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
76
76
|
require('../useSubdomainCheck/useSubdomainCheck.cjs');
|
|
@@ -109,44 +109,13 @@ const useMfa = () => {
|
|
|
109
109
|
const environmentId = dynamicContextProps.getEnvironmentId();
|
|
110
110
|
return environmentId;
|
|
111
111
|
}, []);
|
|
112
|
-
const
|
|
113
|
-
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
114
|
-
const devices = yield mfa.getUserMfaDevices({ environmentId });
|
|
115
|
-
return devices;
|
|
116
|
-
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
117
|
-
const updateUserDevice = React.useCallback((deviceId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
-
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
119
|
-
yield mfa.updateUserMfaDevice({
|
|
120
|
-
environmentId,
|
|
121
|
-
mfaDeviceId: deviceId,
|
|
122
|
-
});
|
|
123
|
-
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
124
|
-
const deleteUserDevice = React.useCallback((deviceId, mfaAuthToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
-
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
126
|
-
yield mfa.deleteMfaDevice({
|
|
127
|
-
environmentId,
|
|
128
|
-
mfaAuthToken,
|
|
129
|
-
mfaDeviceId: deviceId,
|
|
130
|
-
});
|
|
131
|
-
// Refresh the user JWT to get the updated MFA acknowledgement
|
|
132
|
-
// since if it is completed we won't show the QR code again
|
|
133
|
-
yield user$1.refreshUserJwt({ environmentId });
|
|
134
|
-
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
135
|
-
const addDevice = React.useCallback((...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* (type = sdkApiCore.MFADeviceType.Totp) {
|
|
136
|
-
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
137
|
-
const { id, secret, uri } = yield mfa.addMfaDevice({
|
|
138
|
-
environmentId,
|
|
139
|
-
type,
|
|
140
|
-
});
|
|
141
|
-
return { id, secret, uri };
|
|
142
|
-
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
143
|
-
const authDevice = React.useCallback((code_1, ...args_2) => _tslib.__awaiter(void 0, [code_1, ...args_2], void 0, function* (code, type = sdkApiCore.MFADeviceType.Totp, deviceId) {
|
|
112
|
+
const handleMfaAuth = React.useCallback((code_1, ...args_1) => _tslib.__awaiter(void 0, [code_1, ...args_1], void 0, function* (code, type = sdkApiCore.MFADeviceType.Totp, deviceId, resultHandler) {
|
|
144
113
|
try {
|
|
145
114
|
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
146
|
-
let
|
|
115
|
+
let result;
|
|
147
116
|
yield completeAuth({
|
|
148
117
|
onValidUpdatedJwt: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
-
|
|
118
|
+
// This callback is used by authDevice
|
|
150
119
|
}),
|
|
151
120
|
updateJwtFunction: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
152
121
|
const response = yield mfa.authMfaDevice({
|
|
@@ -161,22 +130,69 @@ const useMfa = () => {
|
|
|
161
130
|
dynamicEvents.dynamicEvents.emit('mfaCompletionSuccess', {
|
|
162
131
|
mfaToken: response.mfaToken,
|
|
163
132
|
});
|
|
133
|
+
result = resultHandler(response);
|
|
164
134
|
return {
|
|
165
135
|
isEmailVerificationRequired: false,
|
|
166
136
|
isSmsVerificationRequired: false,
|
|
167
137
|
missingFields: [],
|
|
168
|
-
// in the mfa flow, we only care about the user in the response
|
|
169
138
|
updateUserProfileResponse: response,
|
|
170
139
|
};
|
|
171
140
|
}),
|
|
172
141
|
});
|
|
173
|
-
return
|
|
142
|
+
return result;
|
|
174
143
|
}
|
|
175
144
|
catch (error) {
|
|
176
145
|
dynamicEvents.dynamicEvents.emit('mfaCompletionFailure', { error });
|
|
177
146
|
throw error;
|
|
178
147
|
}
|
|
179
148
|
}), [checkUserIsVerifiedAndGetEnvironmentId, completeAuth]);
|
|
149
|
+
const getUserDevices = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
150
|
+
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
151
|
+
const devices = yield mfa.getUserMfaDevices({ environmentId });
|
|
152
|
+
return devices;
|
|
153
|
+
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
154
|
+
const updateUserDevice = React.useCallback((deviceId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
+
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
156
|
+
yield mfa.updateUserMfaDevice({
|
|
157
|
+
environmentId,
|
|
158
|
+
mfaDeviceId: deviceId,
|
|
159
|
+
});
|
|
160
|
+
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
161
|
+
const deleteUserDevice = React.useCallback((deviceId, mfaAuthToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
162
|
+
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
163
|
+
yield mfa.deleteMfaDevice({
|
|
164
|
+
environmentId,
|
|
165
|
+
mfaAuthToken,
|
|
166
|
+
mfaDeviceId: deviceId,
|
|
167
|
+
});
|
|
168
|
+
// Refresh the user JWT to get the updated MFA acknowledgement
|
|
169
|
+
// since if it is completed we won't show the QR code again
|
|
170
|
+
yield user$1.refreshUserJwt({ environmentId });
|
|
171
|
+
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
172
|
+
const addDevice = React.useCallback((...args_2) => _tslib.__awaiter(void 0, [...args_2], void 0, function* (type = sdkApiCore.MFADeviceType.Totp) {
|
|
173
|
+
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
174
|
+
const { id, secret, uri } = yield mfa.addMfaDevice({
|
|
175
|
+
environmentId,
|
|
176
|
+
type,
|
|
177
|
+
});
|
|
178
|
+
return { id, secret, uri };
|
|
179
|
+
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
180
|
+
// @deprecated Use authenticateDevice instead.
|
|
181
|
+
// This function authenticates a device and returns a boolean value
|
|
182
|
+
// indicating if the authentication was successful.
|
|
183
|
+
const authDevice = React.useCallback((code_2, ...args_3) => _tslib.__awaiter(void 0, [code_2, ...args_3], void 0, function* (code, type = sdkApiCore.MFADeviceType.Totp, deviceId) {
|
|
184
|
+
let isValid = false;
|
|
185
|
+
yield handleMfaAuth(code, type, deviceId, () => {
|
|
186
|
+
isValid = true;
|
|
187
|
+
return true;
|
|
188
|
+
});
|
|
189
|
+
return isValid;
|
|
190
|
+
}), [handleMfaAuth]);
|
|
191
|
+
/**
|
|
192
|
+
* Authenticates a device and returns a single use MFA token
|
|
193
|
+
* if the authentication is successful.
|
|
194
|
+
*/
|
|
195
|
+
const authenticateDevice = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ code, type = sdkApiCore.MFADeviceType.Totp, deviceId, }) { return handleMfaAuth(code, type, deviceId, (response) => response.mfaToken); }), [handleMfaAuth]);
|
|
180
196
|
const authRecoveryCode = React.useCallback((code) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
181
197
|
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
182
198
|
let isValid = false;
|
|
@@ -203,7 +219,7 @@ const useMfa = () => {
|
|
|
203
219
|
});
|
|
204
220
|
return isValid;
|
|
205
221
|
}), [checkUserIsVerifiedAndGetEnvironmentId, completeAuth]);
|
|
206
|
-
const verifyDevice = React.useCallback((
|
|
222
|
+
const verifyDevice = React.useCallback((code_3, ...args_4) => _tslib.__awaiter(void 0, [code_3, ...args_4], void 0, function* (code, type = sdkApiCore.MFADeviceType.Totp) {
|
|
207
223
|
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
208
224
|
const device = yield mfa.verifyMfaDevice({
|
|
209
225
|
code,
|
|
@@ -215,7 +231,7 @@ const useMfa = () => {
|
|
|
215
231
|
}
|
|
216
232
|
return device;
|
|
217
233
|
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
218
|
-
const getRecoveryCodes = React.useCallback((...
|
|
234
|
+
const getRecoveryCodes = React.useCallback((...args_5) => _tslib.__awaiter(void 0, [...args_5], void 0, function* (generateNewCodes = false) {
|
|
219
235
|
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
220
236
|
const getRecoveryCodesFunc = generateNewCodes
|
|
221
237
|
? mfa.createNewRecoveryCodes
|
|
@@ -240,6 +256,7 @@ const useMfa = () => {
|
|
|
240
256
|
addDevice,
|
|
241
257
|
authDevice,
|
|
242
258
|
authRecoveryCode,
|
|
259
|
+
authenticateDevice,
|
|
243
260
|
completeAcknowledgement,
|
|
244
261
|
deleteUserDevice,
|
|
245
262
|
getRecoveryCodes,
|
|
@@ -7,6 +7,11 @@ export declare const useMfa: () => {
|
|
|
7
7
|
}>;
|
|
8
8
|
readonly authDevice: (code: string, type?: MFADeviceType, deviceId?: string) => Promise<boolean>;
|
|
9
9
|
readonly authRecoveryCode: (code: string) => Promise<boolean>;
|
|
10
|
+
readonly authenticateDevice: ({ code, type, deviceId, }: {
|
|
11
|
+
code: string;
|
|
12
|
+
type?: MFADeviceType;
|
|
13
|
+
deviceId?: string;
|
|
14
|
+
}) => Promise<string | undefined>;
|
|
10
15
|
readonly completeAcknowledgement: () => Promise<void>;
|
|
11
16
|
readonly deleteUserDevice: (deviceId: string, mfaAuthToken: string) => Promise<void>;
|
|
12
17
|
readonly getRecoveryCodes: (generateNewCodes?: boolean) => Promise<string[]>;
|
|
@@ -21,7 +21,7 @@ import '../../../store/state/projectSettings/projectSettings.js';
|
|
|
21
21
|
import { getEnvironmentId } from '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
22
22
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
23
23
|
import { getUser } from '../../../store/state/user/user.js';
|
|
24
|
-
import { getUserMfaDevices, updateUserMfaDevice, deleteMfaDevice, addMfaDevice,
|
|
24
|
+
import { authMfaDevice, getUserMfaDevices, updateUserMfaDevice, deleteMfaDevice, addMfaDevice, authMfaRecovery, verifyMfaDevice, createNewRecoveryCodes, getRecoveryCodes } from '../../../data/api/mfa/mfa.js';
|
|
25
25
|
import '../../../locale/locale.js';
|
|
26
26
|
import { refreshUserJwt } from '../../../data/api/user/user.js';
|
|
27
27
|
import { useUserAuth } from '../useUserAuth/useUserAuth.js';
|
|
@@ -51,6 +51,7 @@ import '../../../store/state/walletOptions/walletOptions.js';
|
|
|
51
51
|
import 'react-i18next';
|
|
52
52
|
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
53
53
|
import '../../../components/Alert/Alert.js';
|
|
54
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
54
55
|
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
55
56
|
import '../../../components/IconButton/IconButton.js';
|
|
56
57
|
import '../../../components/InlineWidget/InlineWidget.js';
|
|
@@ -66,7 +67,6 @@ import '../../../components/Popper/Popper/Popper.js';
|
|
|
66
67
|
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
67
68
|
import 'react-focus-lock';
|
|
68
69
|
import 'qrcode';
|
|
69
|
-
import '../../../context/WalletContext/WalletContext.js';
|
|
70
70
|
import 'formik';
|
|
71
71
|
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
72
72
|
import '../useSubdomainCheck/useSubdomainCheck.js';
|
|
@@ -105,44 +105,13 @@ const useMfa = () => {
|
|
|
105
105
|
const environmentId = getEnvironmentId();
|
|
106
106
|
return environmentId;
|
|
107
107
|
}, []);
|
|
108
|
-
const
|
|
109
|
-
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
110
|
-
const devices = yield getUserMfaDevices({ environmentId });
|
|
111
|
-
return devices;
|
|
112
|
-
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
113
|
-
const updateUserDevice = useCallback((deviceId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
114
|
-
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
115
|
-
yield updateUserMfaDevice({
|
|
116
|
-
environmentId,
|
|
117
|
-
mfaDeviceId: deviceId,
|
|
118
|
-
});
|
|
119
|
-
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
120
|
-
const deleteUserDevice = useCallback((deviceId, mfaAuthToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
-
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
122
|
-
yield deleteMfaDevice({
|
|
123
|
-
environmentId,
|
|
124
|
-
mfaAuthToken,
|
|
125
|
-
mfaDeviceId: deviceId,
|
|
126
|
-
});
|
|
127
|
-
// Refresh the user JWT to get the updated MFA acknowledgement
|
|
128
|
-
// since if it is completed we won't show the QR code again
|
|
129
|
-
yield refreshUserJwt({ environmentId });
|
|
130
|
-
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
131
|
-
const addDevice = useCallback((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (type = MFADeviceType.Totp) {
|
|
132
|
-
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
133
|
-
const { id, secret, uri } = yield addMfaDevice({
|
|
134
|
-
environmentId,
|
|
135
|
-
type,
|
|
136
|
-
});
|
|
137
|
-
return { id, secret, uri };
|
|
138
|
-
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
139
|
-
const authDevice = useCallback((code_1, ...args_2) => __awaiter(void 0, [code_1, ...args_2], void 0, function* (code, type = MFADeviceType.Totp, deviceId) {
|
|
108
|
+
const handleMfaAuth = useCallback((code_1, ...args_1) => __awaiter(void 0, [code_1, ...args_1], void 0, function* (code, type = MFADeviceType.Totp, deviceId, resultHandler) {
|
|
140
109
|
try {
|
|
141
110
|
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
142
|
-
let
|
|
111
|
+
let result;
|
|
143
112
|
yield completeAuth({
|
|
144
113
|
onValidUpdatedJwt: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
145
|
-
|
|
114
|
+
// This callback is used by authDevice
|
|
146
115
|
}),
|
|
147
116
|
updateJwtFunction: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
148
117
|
const response = yield authMfaDevice({
|
|
@@ -157,22 +126,69 @@ const useMfa = () => {
|
|
|
157
126
|
dynamicEvents.emit('mfaCompletionSuccess', {
|
|
158
127
|
mfaToken: response.mfaToken,
|
|
159
128
|
});
|
|
129
|
+
result = resultHandler(response);
|
|
160
130
|
return {
|
|
161
131
|
isEmailVerificationRequired: false,
|
|
162
132
|
isSmsVerificationRequired: false,
|
|
163
133
|
missingFields: [],
|
|
164
|
-
// in the mfa flow, we only care about the user in the response
|
|
165
134
|
updateUserProfileResponse: response,
|
|
166
135
|
};
|
|
167
136
|
}),
|
|
168
137
|
});
|
|
169
|
-
return
|
|
138
|
+
return result;
|
|
170
139
|
}
|
|
171
140
|
catch (error) {
|
|
172
141
|
dynamicEvents.emit('mfaCompletionFailure', { error });
|
|
173
142
|
throw error;
|
|
174
143
|
}
|
|
175
144
|
}), [checkUserIsVerifiedAndGetEnvironmentId, completeAuth]);
|
|
145
|
+
const getUserDevices = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
146
|
+
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
147
|
+
const devices = yield getUserMfaDevices({ environmentId });
|
|
148
|
+
return devices;
|
|
149
|
+
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
150
|
+
const updateUserDevice = useCallback((deviceId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
|
+
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
152
|
+
yield updateUserMfaDevice({
|
|
153
|
+
environmentId,
|
|
154
|
+
mfaDeviceId: deviceId,
|
|
155
|
+
});
|
|
156
|
+
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
157
|
+
const deleteUserDevice = useCallback((deviceId, mfaAuthToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
158
|
+
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
159
|
+
yield deleteMfaDevice({
|
|
160
|
+
environmentId,
|
|
161
|
+
mfaAuthToken,
|
|
162
|
+
mfaDeviceId: deviceId,
|
|
163
|
+
});
|
|
164
|
+
// Refresh the user JWT to get the updated MFA acknowledgement
|
|
165
|
+
// since if it is completed we won't show the QR code again
|
|
166
|
+
yield refreshUserJwt({ environmentId });
|
|
167
|
+
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
168
|
+
const addDevice = useCallback((...args_2) => __awaiter(void 0, [...args_2], void 0, function* (type = MFADeviceType.Totp) {
|
|
169
|
+
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
170
|
+
const { id, secret, uri } = yield addMfaDevice({
|
|
171
|
+
environmentId,
|
|
172
|
+
type,
|
|
173
|
+
});
|
|
174
|
+
return { id, secret, uri };
|
|
175
|
+
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
176
|
+
// @deprecated Use authenticateDevice instead.
|
|
177
|
+
// This function authenticates a device and returns a boolean value
|
|
178
|
+
// indicating if the authentication was successful.
|
|
179
|
+
const authDevice = useCallback((code_2, ...args_3) => __awaiter(void 0, [code_2, ...args_3], void 0, function* (code, type = MFADeviceType.Totp, deviceId) {
|
|
180
|
+
let isValid = false;
|
|
181
|
+
yield handleMfaAuth(code, type, deviceId, () => {
|
|
182
|
+
isValid = true;
|
|
183
|
+
return true;
|
|
184
|
+
});
|
|
185
|
+
return isValid;
|
|
186
|
+
}), [handleMfaAuth]);
|
|
187
|
+
/**
|
|
188
|
+
* Authenticates a device and returns a single use MFA token
|
|
189
|
+
* if the authentication is successful.
|
|
190
|
+
*/
|
|
191
|
+
const authenticateDevice = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ code, type = MFADeviceType.Totp, deviceId, }) { return handleMfaAuth(code, type, deviceId, (response) => response.mfaToken); }), [handleMfaAuth]);
|
|
176
192
|
const authRecoveryCode = useCallback((code) => __awaiter(void 0, void 0, void 0, function* () {
|
|
177
193
|
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
178
194
|
let isValid = false;
|
|
@@ -199,7 +215,7 @@ const useMfa = () => {
|
|
|
199
215
|
});
|
|
200
216
|
return isValid;
|
|
201
217
|
}), [checkUserIsVerifiedAndGetEnvironmentId, completeAuth]);
|
|
202
|
-
const verifyDevice = useCallback((
|
|
218
|
+
const verifyDevice = useCallback((code_3, ...args_4) => __awaiter(void 0, [code_3, ...args_4], void 0, function* (code, type = MFADeviceType.Totp) {
|
|
203
219
|
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
204
220
|
const device = yield verifyMfaDevice({
|
|
205
221
|
code,
|
|
@@ -211,7 +227,7 @@ const useMfa = () => {
|
|
|
211
227
|
}
|
|
212
228
|
return device;
|
|
213
229
|
}), [checkUserIsVerifiedAndGetEnvironmentId]);
|
|
214
|
-
const getRecoveryCodes$1 = useCallback((...
|
|
230
|
+
const getRecoveryCodes$1 = useCallback((...args_5) => __awaiter(void 0, [...args_5], void 0, function* (generateNewCodes = false) {
|
|
215
231
|
const environmentId = checkUserIsVerifiedAndGetEnvironmentId();
|
|
216
232
|
const getRecoveryCodesFunc = generateNewCodes
|
|
217
233
|
? createNewRecoveryCodes
|
|
@@ -236,6 +252,7 @@ const useMfa = () => {
|
|
|
236
252
|
addDevice,
|
|
237
253
|
authDevice,
|
|
238
254
|
authRecoveryCode,
|
|
255
|
+
authenticateDevice,
|
|
239
256
|
completeAcknowledgement,
|
|
240
257
|
deleteUserDevice,
|
|
241
258
|
getRecoveryCodes: getRecoveryCodes$1,
|
|
@@ -3,106 +3,47 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
7
|
var React = require('react');
|
|
7
|
-
require('
|
|
8
|
+
require('@dynamic-labs/utils');
|
|
8
9
|
require('@dynamic-labs/sdk-api-core');
|
|
10
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
11
|
+
require('../../constants/values.cjs');
|
|
12
|
+
require('@dynamic-labs/multi-wallet');
|
|
9
13
|
require('../../../shared/logger.cjs');
|
|
14
|
+
require('../../constants/colors.cjs');
|
|
15
|
+
require('react-international-phone');
|
|
10
16
|
require('@dynamic-labs/iconic');
|
|
11
17
|
require('@dynamic-labs/wallet-connector-core');
|
|
12
18
|
require('react/jsx-runtime');
|
|
13
19
|
require('../../../context/ViewContext/ViewContext.cjs');
|
|
14
20
|
require('@dynamic-labs/wallet-book');
|
|
15
|
-
require('@dynamic-labs/utils');
|
|
16
|
-
require('../../constants/colors.cjs');
|
|
17
|
-
require('../../constants/values.cjs');
|
|
18
21
|
require('../../../shared/consts/index.cjs');
|
|
19
|
-
require('../../../events/dynamicEvents.cjs');
|
|
20
|
-
require('../../../../../_virtual/_tslib.cjs');
|
|
21
|
-
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
22
|
-
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
23
|
-
require('@dynamic-labs/multi-wallet');
|
|
24
|
-
require('react-international-phone');
|
|
25
22
|
require('../../../store/state/nonce/nonce.cjs');
|
|
26
23
|
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
27
|
-
require('../../../
|
|
24
|
+
var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
25
|
+
var primaryWalletId = require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
28
26
|
require('../../../store/state/user/user.cjs');
|
|
29
27
|
require('../../../locale/locale.cjs');
|
|
30
28
|
var user = require('../../../data/api/user/user.cjs');
|
|
31
|
-
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
32
|
-
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
33
|
-
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
34
|
-
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
35
|
-
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
36
|
-
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
37
|
-
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
38
|
-
require('react-dom');
|
|
39
|
-
require('../../functions/compareChains/compareChains.cjs');
|
|
40
|
-
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
41
|
-
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
42
|
-
require('bs58');
|
|
43
|
-
require('@dynamic-labs/types');
|
|
44
|
-
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
45
|
-
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
46
|
-
require('../../../context/WalletContext/WalletContext.cjs');
|
|
47
|
-
require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
48
|
-
require('yup');
|
|
49
|
-
require('../../../context/MockContext/MockContext.cjs');
|
|
50
|
-
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
51
|
-
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
52
|
-
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
53
|
-
require('@dynamic-labs/rpc-providers');
|
|
54
|
-
require('../../../store/state/loadingAndLifecycle.cjs');
|
|
55
|
-
require('../../../store/state/walletOptions/walletOptions.cjs');
|
|
56
|
-
require('react-i18next');
|
|
57
|
-
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
58
|
-
require('../../../components/Alert/Alert.cjs');
|
|
59
|
-
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
60
|
-
require('../../../components/IconButton/IconButton.cjs');
|
|
61
|
-
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
62
|
-
require('../../../components/Input/Input.cjs');
|
|
63
|
-
require('../../../components/IsBrowser/IsBrowser.cjs');
|
|
64
|
-
require('../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
65
|
-
require('../../../components/OverlayCard/OverlayCard.cjs');
|
|
66
|
-
require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
67
|
-
require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
68
|
-
require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
69
|
-
require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
70
|
-
require('../../../components/Popper/Popper/Popper.cjs');
|
|
71
|
-
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
72
|
-
require('react-focus-lock');
|
|
73
|
-
require('qrcode');
|
|
74
|
-
require('formik');
|
|
75
|
-
require('../useSubdomainCheck/useSubdomainCheck.cjs');
|
|
76
|
-
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
77
|
-
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
78
|
-
require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
79
|
-
require('../../../context/ConnectWithOtpContext/constants.cjs');
|
|
80
|
-
require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
81
|
-
require('@hcaptcha/react-hcaptcha');
|
|
82
|
-
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
83
|
-
require('../../../context/FooterAnimationContext/index.cjs');
|
|
84
|
-
require('../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
85
|
-
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
86
|
-
require('../../../store/state/sendBalances.cjs');
|
|
87
|
-
require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
88
|
-
require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
89
|
-
require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
90
|
-
require('../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
91
|
-
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
92
|
-
require('../../../context/OnrampContext/OnrampContext.cjs');
|
|
93
|
-
require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
94
|
-
require('../../../../index.cjs');
|
|
95
|
-
require('../../../store/state/tokenBalances.cjs');
|
|
96
|
-
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
97
|
-
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
98
29
|
|
|
99
30
|
/**
|
|
100
31
|
* Refresh user state
|
|
101
32
|
* @returns A callback function that can be used to refresh the user state
|
|
102
33
|
*/
|
|
103
|
-
const useRefreshUser = () => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
34
|
+
const useRefreshUser = () => React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
var _a;
|
|
36
|
+
const user$1 = yield user.refreshUserJwt({ environmentId: dynamicContextProps.getEnvironmentId() });
|
|
37
|
+
if (!(user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials))
|
|
38
|
+
throw new Error('useRefreshUser resulted in an invalid user: no verified credentials found');
|
|
39
|
+
// Check if the primary wallet is still in this user's VCs
|
|
40
|
+
const primaryWalletInUserVCs = user$1.verifiedCredentials.some(({ id }) => id === primaryWalletId.getPrimaryWalletId());
|
|
41
|
+
if (primaryWalletInUserVCs)
|
|
42
|
+
return user$1;
|
|
43
|
+
// We need to switch primary wallet to the first wallet in the user's VCs
|
|
44
|
+
const newPrimaryWalletId = (_a = user$1.verifiedCredentials.find(({ format }) => format === 'blockchain')) === null || _a === void 0 ? void 0 : _a.id;
|
|
45
|
+
primaryWalletId.setPrimaryWalletId(newPrimaryWalletId);
|
|
46
|
+
return user$1;
|
|
47
|
+
}), []);
|
|
107
48
|
|
|
108
49
|
exports.useRefreshUser = useRefreshUser;
|
|
@@ -1,104 +1,45 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
3
|
import { useCallback } from 'react';
|
|
3
|
-
import '
|
|
4
|
+
import '@dynamic-labs/utils';
|
|
4
5
|
import '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import '../../../config/ApiEndpoint.js';
|
|
7
|
+
import '../../constants/values.js';
|
|
8
|
+
import '@dynamic-labs/multi-wallet';
|
|
5
9
|
import '../../../shared/logger.js';
|
|
10
|
+
import '../../constants/colors.js';
|
|
11
|
+
import 'react-international-phone';
|
|
6
12
|
import '@dynamic-labs/iconic';
|
|
7
13
|
import '@dynamic-labs/wallet-connector-core';
|
|
8
14
|
import 'react/jsx-runtime';
|
|
9
15
|
import '../../../context/ViewContext/ViewContext.js';
|
|
10
16
|
import '@dynamic-labs/wallet-book';
|
|
11
|
-
import '@dynamic-labs/utils';
|
|
12
|
-
import '../../constants/colors.js';
|
|
13
|
-
import '../../constants/values.js';
|
|
14
17
|
import '../../../shared/consts/index.js';
|
|
15
|
-
import '../../../events/dynamicEvents.js';
|
|
16
|
-
import '../../../../../_virtual/_tslib.js';
|
|
17
|
-
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
18
|
-
import '../../../context/ErrorContext/ErrorContext.js';
|
|
19
|
-
import '@dynamic-labs/multi-wallet';
|
|
20
|
-
import 'react-international-phone';
|
|
21
18
|
import '../../../store/state/nonce/nonce.js';
|
|
22
19
|
import '../../../store/state/projectSettings/projectSettings.js';
|
|
23
|
-
import '../../../
|
|
20
|
+
import { getEnvironmentId } from '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
21
|
+
import { getPrimaryWalletId, setPrimaryWalletId } from '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
24
22
|
import '../../../store/state/user/user.js';
|
|
25
23
|
import '../../../locale/locale.js';
|
|
26
24
|
import { refreshUserJwt } from '../../../data/api/user/user.js';
|
|
27
|
-
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
28
|
-
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
29
|
-
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
30
|
-
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
31
|
-
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
32
|
-
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
33
|
-
import '../../../context/VerificationContext/VerificationContext.js';
|
|
34
|
-
import 'react-dom';
|
|
35
|
-
import '../../functions/compareChains/compareChains.js';
|
|
36
|
-
import '../../../context/ThemeContext/ThemeContext.js';
|
|
37
|
-
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
38
|
-
import 'bs58';
|
|
39
|
-
import '@dynamic-labs/types';
|
|
40
|
-
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
41
|
-
import '../../../context/LoadingContext/LoadingContext.js';
|
|
42
|
-
import '../../../context/WalletContext/WalletContext.js';
|
|
43
|
-
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
44
|
-
import 'yup';
|
|
45
|
-
import '../../../context/MockContext/MockContext.js';
|
|
46
|
-
import '../../../views/CollectUserDataView/useFields.js';
|
|
47
|
-
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
48
|
-
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
49
|
-
import '@dynamic-labs/rpc-providers';
|
|
50
|
-
import '../../../store/state/loadingAndLifecycle.js';
|
|
51
|
-
import '../../../store/state/walletOptions/walletOptions.js';
|
|
52
|
-
import 'react-i18next';
|
|
53
|
-
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
54
|
-
import '../../../components/Alert/Alert.js';
|
|
55
|
-
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
56
|
-
import '../../../components/IconButton/IconButton.js';
|
|
57
|
-
import '../../../components/InlineWidget/InlineWidget.js';
|
|
58
|
-
import '../../../components/Input/Input.js';
|
|
59
|
-
import '../../../components/IsBrowser/IsBrowser.js';
|
|
60
|
-
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
61
|
-
import '../../../components/OverlayCard/OverlayCard.js';
|
|
62
|
-
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
63
|
-
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
64
|
-
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
65
|
-
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
66
|
-
import '../../../components/Popper/Popper/Popper.js';
|
|
67
|
-
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
68
|
-
import 'react-focus-lock';
|
|
69
|
-
import 'qrcode';
|
|
70
|
-
import 'formik';
|
|
71
|
-
import '../useSubdomainCheck/useSubdomainCheck.js';
|
|
72
|
-
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
73
|
-
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
74
|
-
import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
75
|
-
import '../../../context/ConnectWithOtpContext/constants.js';
|
|
76
|
-
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
77
|
-
import '@hcaptcha/react-hcaptcha';
|
|
78
|
-
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
79
|
-
import '../../../context/FooterAnimationContext/index.js';
|
|
80
|
-
import '../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
81
|
-
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
82
|
-
import '../../../store/state/sendBalances.js';
|
|
83
|
-
import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
84
|
-
import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
85
|
-
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
86
|
-
import '../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
87
|
-
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
88
|
-
import '../../../context/OnrampContext/OnrampContext.js';
|
|
89
|
-
import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
90
|
-
import '../../../../index.js';
|
|
91
|
-
import '../../../store/state/tokenBalances.js';
|
|
92
|
-
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
93
|
-
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
94
25
|
|
|
95
26
|
/**
|
|
96
27
|
* Refresh user state
|
|
97
28
|
* @returns A callback function that can be used to refresh the user state
|
|
98
29
|
*/
|
|
99
|
-
const useRefreshUser = () => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
30
|
+
const useRefreshUser = () => useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
var _a;
|
|
32
|
+
const user = yield refreshUserJwt({ environmentId: getEnvironmentId() });
|
|
33
|
+
if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials))
|
|
34
|
+
throw new Error('useRefreshUser resulted in an invalid user: no verified credentials found');
|
|
35
|
+
// Check if the primary wallet is still in this user's VCs
|
|
36
|
+
const primaryWalletInUserVCs = user.verifiedCredentials.some(({ id }) => id === getPrimaryWalletId());
|
|
37
|
+
if (primaryWalletInUserVCs)
|
|
38
|
+
return user;
|
|
39
|
+
// We need to switch primary wallet to the first wallet in the user's VCs
|
|
40
|
+
const newPrimaryWalletId = (_a = user.verifiedCredentials.find(({ format }) => format === 'blockchain')) === null || _a === void 0 ? void 0 : _a.id;
|
|
41
|
+
setPrimaryWalletId(newPrimaryWalletId);
|
|
42
|
+
return user;
|
|
43
|
+
}), []);
|
|
103
44
|
|
|
104
45
|
export { useRefreshUser };
|
|
@@ -57,6 +57,7 @@ require('../../../store/state/walletOptions/walletOptions.cjs');
|
|
|
57
57
|
require('react-i18next');
|
|
58
58
|
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
59
59
|
require('../../../components/Alert/Alert.cjs');
|
|
60
|
+
require('../../../context/WalletContext/WalletContext.cjs');
|
|
60
61
|
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
61
62
|
require('../../../components/IconButton/IconButton.cjs');
|
|
62
63
|
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
@@ -72,7 +73,6 @@ require('../../../components/Popper/Popper/Popper.cjs');
|
|
|
72
73
|
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
73
74
|
require('react-focus-lock');
|
|
74
75
|
require('qrcode');
|
|
75
|
-
require('../../../context/WalletContext/WalletContext.cjs');
|
|
76
76
|
require('formik');
|
|
77
77
|
require('../useSubdomainCheck/useSubdomainCheck.cjs');
|
|
78
78
|
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|