@dynamic-labs/sdk-react-core 4.67.0 → 4.67.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 +21 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/index.d.ts +1 -1
- package/src/lib/client/extension/functions/getExpiresAt/getExpiresAt.cjs +10 -0
- package/src/lib/client/extension/functions/getExpiresAt/getExpiresAt.js +6 -0
- package/src/lib/components/IconWithSpinner/IconWithSpinner.cjs +1 -1
- package/src/lib/components/IconWithSpinner/IconWithSpinner.js +1 -1
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.cjs +31 -11
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.js +31 -11
- package/src/lib/shared/utils/functions/chain/getChainIcon.cjs +1 -0
- package/src/lib/shared/utils/functions/chain/getChainIcon.js +2 -1
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/values.cjs +5 -0
- package/src/lib/utils/constants/values.js +5 -0
- package/src/lib/utils/functions/compareChains/compareChains.cjs +6 -0
- package/src/lib/utils/functions/compareChains/compareChains.js +6 -0
- package/src/lib/utils/hooks/index.d.ts +1 -1
- package/src/lib/utils/hooks/useAuthenticatePasskeyMFA/useAuthenticatePasskeyMFA.d.ts +2 -1
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +6 -3
- package/src/lib/utils/hooks/useMfa/useMfa.d.ts +5 -3
- package/src/lib/utils/hooks/useMfa/useMfa.js +6 -3
- package/src/lib/utils/hooks/usePromptMfaAuth/usePromptMfaAuth.cjs +14 -185
- package/src/lib/utils/hooks/usePromptMfaAuth/usePromptMfaAuth.d.ts +15 -3
- package/src/lib/utils/hooks/usePromptMfaAuth/usePromptMfaAuth.js +14 -185
- package/src/lib/utils/hooks/useStepUpAuthentication/index.d.ts +1 -1
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.cjs +195 -24
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.d.ts +10 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.js +189 -18
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.cjs +18 -5
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.js +18 -5
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.cjs +9 -1
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.js +9 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +10 -9
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +10 -9
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +4 -3
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.d.ts +2 -0
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +4 -3
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +3 -1
- package/src/lib/views/MfaVerificationView/MfaVerificationView.d.ts +3 -2
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +3 -1
- package/src/lib/views/Passkey/ConfirmPasskeyView/ConfirmPasskeyView.cjs +2 -1
- package/src/lib/views/Passkey/ConfirmPasskeyView/ConfirmPasskeyView.d.ts +3 -1
- package/src/lib/views/Passkey/ConfirmPasskeyView/ConfirmPasskeyView.js +2 -1
- package/src/lib/views/viewToComponentMap.d.ts +3 -2
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useState, useRef, useCallback } from 'react';
|
|
4
|
-
import { verifyOTP, authenticatePasskeyMFA, authenticateTotpMfaDevice, sendEmailOTP, supportedCountries, sendSmsOTP } from '@dynamic-labs-sdk/client';
|
|
5
|
-
import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import { verifyOTP, authenticatePasskeyMFA, authenticateTotpMfaDevice, authenticateMfaRecoveryCode, onEvent, sendEmailOTP, supportedCountries, sendSmsOTP } from '@dynamic-labs-sdk/client';
|
|
5
|
+
import { MFADeviceType, JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import { DeferredPromise } from '@dynamic-labs/utils';
|
|
6
7
|
import '@dynamic-labs-sdk/client/core';
|
|
7
|
-
import '../../../client/client.js';
|
|
8
|
+
import { useDynamicClient } from '../../../client/client.js';
|
|
8
9
|
import '../../../config/ApiEndpoint.js';
|
|
9
10
|
import '@dynamic-labs/iconic';
|
|
10
11
|
import '@dynamic-labs/wallet-connector-core';
|
|
11
12
|
import 'react/jsx-runtime';
|
|
12
|
-
import '../../../context/ViewContext/ViewContext.js';
|
|
13
|
+
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
13
14
|
import { logger } from '../../../shared/logger.js';
|
|
14
15
|
import '@dynamic-labs/wallet-book';
|
|
15
|
-
import '@dynamic-labs/utils';
|
|
16
16
|
import '../../constants/colors.js';
|
|
17
17
|
import '../../constants/values.js';
|
|
18
18
|
import '../../../shared/consts/index.js';
|
|
@@ -24,11 +24,88 @@ import { useEnvironmentId } from '../../../store/state/dynamicContextProps/dynam
|
|
|
24
24
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
25
25
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
26
26
|
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
27
|
-
import '../../../events/dynamicEvents.js';
|
|
27
|
+
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
28
28
|
import { useUser } from '../../../client/extension/user/useUser/useUser.js';
|
|
29
29
|
import { hasElevatedAccessToken } from '../../../client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.js';
|
|
30
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
31
|
+
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
30
32
|
import { useConnectAndSign } from '../authenticationHooks/useConnectAndSign/useConnectAndSign.js';
|
|
33
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
34
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
35
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
31
36
|
import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
37
|
+
import '../../../store/state/authMode/authMode.js';
|
|
38
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
39
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
40
|
+
import 'react-dom';
|
|
41
|
+
import '../../functions/compareChains/compareChains.js';
|
|
42
|
+
import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
43
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
44
|
+
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
45
|
+
import 'bs58';
|
|
46
|
+
import '@dynamic-labs/types';
|
|
47
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
48
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
49
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
50
|
+
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
51
|
+
import 'yup';
|
|
52
|
+
import '../../../context/MockContext/MockContext.js';
|
|
53
|
+
import '../../../views/CollectUserDataView/useFields.js';
|
|
54
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
55
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
56
|
+
import '@dynamic-labs/rpc-providers';
|
|
57
|
+
import '../../../store/state/walletOptions/walletOptions.js';
|
|
58
|
+
import 'react-i18next';
|
|
59
|
+
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
60
|
+
import '../../../components/Alert/Alert.js';
|
|
61
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
62
|
+
import '../../../components/IconButton/IconButton.js';
|
|
63
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
64
|
+
import '../../../components/Input/Input.js';
|
|
65
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
66
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
67
|
+
import '../../../components/OverlayCard/OverlayCard.js';
|
|
68
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
69
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
70
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
71
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
72
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
73
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
74
|
+
import 'react-focus-lock';
|
|
75
|
+
import 'qrcode';
|
|
76
|
+
import 'formik';
|
|
77
|
+
import '../useSubdomainCheck/useSubdomainCheck.js';
|
|
78
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
79
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
80
|
+
import '../useWalletBackup/useWalletBackup.js';
|
|
81
|
+
import '../useWalletBackup/types.js';
|
|
82
|
+
import '../useWalletBackup/cloudProviders.js';
|
|
83
|
+
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
84
|
+
import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
85
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
86
|
+
import '@hcaptcha/react-hcaptcha';
|
|
87
|
+
import '../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
|
|
88
|
+
import '../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
|
|
89
|
+
import '../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
90
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
91
|
+
import '../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
|
|
92
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
93
|
+
import '../../../context/OnrampContext/OnrampContext.js';
|
|
94
|
+
import '../../../store/state/sendBalances.js';
|
|
95
|
+
import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
96
|
+
import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
97
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
98
|
+
import '../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
99
|
+
import '../../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
|
|
100
|
+
import '../../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js';
|
|
101
|
+
import '../../../../index.js';
|
|
102
|
+
import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
103
|
+
import '../../../store/state/tokenBalances.js';
|
|
104
|
+
import '../../../store/state/multichainBalances.js';
|
|
105
|
+
import { useGetUserMfaMethods } from '../useGetUserMfaMethods/useGetUserMfaMethods.js';
|
|
106
|
+
import { useAuthenticatePasskeyMFA } from '../useAuthenticatePasskeyMFA/useAuthenticatePasskeyMFA.js';
|
|
107
|
+
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
108
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
32
109
|
|
|
33
110
|
const INITIAL_STATE = {
|
|
34
111
|
error: null,
|
|
@@ -106,6 +183,11 @@ const useStepUpAuthentication = ({ credentialId, } = {}) => {
|
|
|
106
183
|
const [state, setState] = useState(INITIAL_STATE);
|
|
107
184
|
const connectAndSign = useConnectAndSign();
|
|
108
185
|
const { userWallets } = useInternalUserWallets();
|
|
186
|
+
const { setShowAuthFlow } = useInternalDynamicContext();
|
|
187
|
+
const { pushView } = useViewContext();
|
|
188
|
+
const getUserMfaMethods = useGetUserMfaMethods();
|
|
189
|
+
const authenticatePasskeyMFA$1 = useAuthenticatePasskeyMFA();
|
|
190
|
+
const dynamicClient = useDynamicClient();
|
|
109
191
|
// Ref keeps the latest otpVerification available inside the verifyOtp
|
|
110
192
|
// callback without creating a stale closure over state.
|
|
111
193
|
const otpVerificationRef = useRef(null);
|
|
@@ -209,18 +291,10 @@ const useStepUpAuthentication = ({ credentialId, } = {}) => {
|
|
|
209
291
|
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
210
292
|
});
|
|
211
293
|
}
|
|
212
|
-
}), [
|
|
213
|
-
connectAndSign,
|
|
214
|
-
credentialId,
|
|
215
|
-
environmentId,
|
|
216
|
-
setError,
|
|
217
|
-
user === null || user === void 0 ? void 0 : user.id,
|
|
218
|
-
userWallets,
|
|
219
|
-
]);
|
|
294
|
+
}), [connectAndSign, credentialId, environmentId, setError, user, userWallets]);
|
|
220
295
|
const verifyPasskeyMfa = useCallback((_c) => __awaiter(void 0, [_c], void 0, function* ({ requestedScopes, }) {
|
|
221
296
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
222
297
|
try {
|
|
223
|
-
// requestedScopes is available in @dynamic-labs-sdk/client >= 0.14.0
|
|
224
298
|
const response = yield authenticatePasskeyMFA({
|
|
225
299
|
requestedScopes,
|
|
226
300
|
});
|
|
@@ -235,11 +309,10 @@ const useStepUpAuthentication = ({ credentialId, } = {}) => {
|
|
|
235
309
|
logger.error('Failed to authenticate passkey for step-up authentication', { environmentId, error, userId: user === null || user === void 0 ? void 0 : user.id });
|
|
236
310
|
return null;
|
|
237
311
|
}
|
|
238
|
-
}), [environmentId, user
|
|
312
|
+
}), [environmentId, user]);
|
|
239
313
|
const verifyTotpMfa = useCallback((_d) => __awaiter(void 0, [_d], void 0, function* ({ code, deviceId, requestedScopes, }) {
|
|
240
314
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
241
315
|
try {
|
|
242
|
-
// requestedScopes is available in @dynamic-labs-sdk/client >= 0.14.0
|
|
243
316
|
const response = yield authenticateTotpMfaDevice({
|
|
244
317
|
code,
|
|
245
318
|
deviceId,
|
|
@@ -256,14 +329,112 @@ const useStepUpAuthentication = ({ credentialId, } = {}) => {
|
|
|
256
329
|
logger.error('Failed to authenticate TOTP device for step-up authentication', { environmentId, error, userId: user === null || user === void 0 ? void 0 : user.id });
|
|
257
330
|
return null;
|
|
258
331
|
}
|
|
259
|
-
}), [environmentId, user
|
|
332
|
+
}), [environmentId, user]);
|
|
333
|
+
const verifyRecoveryCode = useCallback((_e) => __awaiter(void 0, [_e], void 0, function* ({ code, requestedScopes, }) {
|
|
334
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
335
|
+
try {
|
|
336
|
+
const response = yield authenticateMfaRecoveryCode({
|
|
337
|
+
code,
|
|
338
|
+
requestedScopes,
|
|
339
|
+
});
|
|
340
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
341
|
+
return response;
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
const errorMessage = error instanceof Error
|
|
345
|
+
? error.message
|
|
346
|
+
: 'Failed to authenticate recovery code for step-up authentication';
|
|
347
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { error: errorMessage, isLoading: false })));
|
|
348
|
+
logger.error('Failed to authenticate recovery code for step-up authentication', { environmentId, error, userId: user === null || user === void 0 ? void 0 : user.id });
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
}), [environmentId, user]);
|
|
352
|
+
const promptMfa = useCallback((props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
353
|
+
var _f;
|
|
354
|
+
const methods = yield getUserMfaMethods();
|
|
355
|
+
const allMethods = [
|
|
356
|
+
...methods.passkeys.map((passkey) => (Object.assign(Object.assign({}, passkey), { type: MFADeviceType.Passkey }))),
|
|
357
|
+
...methods.devices.map((device) => (Object.assign(Object.assign({}, device), { type: MFADeviceType.Totp }))),
|
|
358
|
+
];
|
|
359
|
+
if (!methods.userHasVerifiedMfaMethods || allMethods.length === 0) {
|
|
360
|
+
setShowAuthFlow(true);
|
|
361
|
+
pushView('mfa-choose-device', {
|
|
362
|
+
createMfaToken: props === null || props === void 0 ? void 0 : props.createMfaToken,
|
|
363
|
+
requestedScopes: props === null || props === void 0 ? void 0 : props.requestedScopes,
|
|
364
|
+
});
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const lastCreatedMethod = allMethods.reduce((a, b) => {
|
|
368
|
+
if (!a)
|
|
369
|
+
return b;
|
|
370
|
+
if (!b)
|
|
371
|
+
return a;
|
|
372
|
+
if (a.createdAt && b.createdAt) {
|
|
373
|
+
return a.createdAt >= b.createdAt ? a : b;
|
|
374
|
+
}
|
|
375
|
+
if (b.createdAt) {
|
|
376
|
+
return b;
|
|
377
|
+
}
|
|
378
|
+
return a;
|
|
379
|
+
}, allMethods[0]);
|
|
380
|
+
switch (lastCreatedMethod.type) {
|
|
381
|
+
case MFADeviceType.Passkey: {
|
|
382
|
+
const createMfaTokenOptions = (props === null || props === void 0 ? void 0 : props.createMfaToken)
|
|
383
|
+
? { singleUse: true }
|
|
384
|
+
: undefined;
|
|
385
|
+
const authenticatePasskeyPromise = authenticatePasskeyMFA$1({
|
|
386
|
+
createMfaToken: createMfaTokenOptions,
|
|
387
|
+
requestedScopes: props === null || props === void 0 ? void 0 : props.requestedScopes,
|
|
388
|
+
});
|
|
389
|
+
setShowAuthFlow(true);
|
|
390
|
+
pushView('passkey-confirm', {
|
|
391
|
+
authenticatePasskeyPromise,
|
|
392
|
+
createMfaToken: props === null || props === void 0 ? void 0 : props.createMfaToken,
|
|
393
|
+
requestedScopes: props === null || props === void 0 ? void 0 : props.requestedScopes,
|
|
394
|
+
});
|
|
395
|
+
return authenticatePasskeyPromise;
|
|
396
|
+
}
|
|
397
|
+
case MFADeviceType.Totp: {
|
|
398
|
+
if ((dynamicClient === null || dynamicClient === void 0 ? void 0 : dynamicClient.mfaToken) && !((_f = props === null || props === void 0 ? void 0 : props.requestedScopes) === null || _f === void 0 ? void 0 : _f.length)) {
|
|
399
|
+
return dynamicClient === null || dynamicClient === void 0 ? void 0 : dynamicClient.mfaToken;
|
|
400
|
+
}
|
|
401
|
+
const deferred = new DeferredPromise();
|
|
402
|
+
setShowAuthFlow(true);
|
|
403
|
+
pushView('mfa-verification', {
|
|
404
|
+
createMfaToken: props === null || props === void 0 ? void 0 : props.createMfaToken,
|
|
405
|
+
requestedScopes: props === null || props === void 0 ? void 0 : props.requestedScopes,
|
|
406
|
+
});
|
|
407
|
+
const mfaCompletionSuccessOff = onEvent({
|
|
408
|
+
event: 'mfaCompletionSuccess',
|
|
409
|
+
listener: ({ mfaToken }) => deferred.resolve(mfaToken),
|
|
410
|
+
}, dynamicClient);
|
|
411
|
+
const onAuthFlowCloseHandler = () => deferred.reject(new Error('MFA view closed'));
|
|
412
|
+
dynamicEvents.on('authFlowClose', onAuthFlowCloseHandler);
|
|
413
|
+
deferred.promise.finally(() => {
|
|
414
|
+
mfaCompletionSuccessOff();
|
|
415
|
+
dynamicEvents.off('authFlowClose', onAuthFlowCloseHandler);
|
|
416
|
+
});
|
|
417
|
+
return deferred.promise;
|
|
418
|
+
}
|
|
419
|
+
default:
|
|
420
|
+
throw new Error('Error determining MFA method to use');
|
|
421
|
+
}
|
|
422
|
+
}), [
|
|
423
|
+
authenticatePasskeyMFA$1,
|
|
424
|
+
dynamicClient,
|
|
425
|
+
getUserMfaMethods,
|
|
426
|
+
pushView,
|
|
427
|
+
setShowAuthFlow,
|
|
428
|
+
]);
|
|
260
429
|
return {
|
|
261
430
|
isStepUpRequired,
|
|
431
|
+
promptMfa,
|
|
262
432
|
resetState,
|
|
263
433
|
sendOtp,
|
|
264
434
|
state,
|
|
265
435
|
verifyOtp,
|
|
266
436
|
verifyPasskeyMfa,
|
|
437
|
+
verifyRecoveryCode,
|
|
267
438
|
verifyTotpMfa,
|
|
268
439
|
verifyWallet,
|
|
269
440
|
};
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var client = require('@dynamic-labs-sdk/client');
|
|
7
8
|
require('@dynamic-labs-sdk/client/core');
|
|
8
9
|
require('@dynamic-labs/sdk-api-core');
|
|
9
10
|
require('../../../../client/client.cjs');
|
|
10
11
|
require('react');
|
|
11
|
-
require('@dynamic-labs-sdk/client');
|
|
12
12
|
require('../../../../config/ApiEndpoint.cjs');
|
|
13
13
|
require('@dynamic-labs/iconic');
|
|
14
14
|
require('@dynamic-labs/wallet-connector-core');
|
|
15
15
|
require('react/jsx-runtime');
|
|
16
16
|
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
17
|
-
require('../../../../shared/logger.cjs');
|
|
17
|
+
var logger = require('../../../../shared/logger.cjs');
|
|
18
18
|
require('@dynamic-labs/wallet-book');
|
|
19
19
|
require('@dynamic-labs/utils');
|
|
20
20
|
require('../../../constants/colors.cjs');
|
|
@@ -29,7 +29,8 @@ var primaryWalletId = require('../../../../store/state/primaryWalletId/primaryWa
|
|
|
29
29
|
var connectedWalletsInfo = require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
30
30
|
require('../../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
31
31
|
require('../../../../events/dynamicEvents.cjs');
|
|
32
|
-
var
|
|
32
|
+
var getMinAuthToken = require('../../../../client/extension/functions/getMinAuthToken/getMinAuthToken.cjs');
|
|
33
|
+
var getExpiresAt = require('../../../../client/extension/functions/getExpiresAt/getExpiresAt.cjs');
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* Detects mismatch between wallet info.
|
|
@@ -41,12 +42,24 @@ const handleWalletInfoOutOfSync = (_a) => _tslib.__awaiter(void 0, [_a], void 0,
|
|
|
41
42
|
if (!primaryWalletId$1) {
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
|
-
const user =
|
|
45
|
+
const { user } = client.getDefaultClient();
|
|
45
46
|
const connectedWallets = connectedWalletsInfo.getConnectedWalletsInfo();
|
|
47
|
+
const token = getMinAuthToken.getMinAuthToken();
|
|
48
|
+
const sessionExpiresAt = getExpiresAt.getExpiresAt();
|
|
49
|
+
const isTokenExpired = sessionExpiresAt !== null && sessionExpiresAt <= Date.now();
|
|
50
|
+
logger.logger.debug('[handleWalletInfoOutOfSync] validation check', {
|
|
51
|
+
connectedWalletsCount: connectedWallets.length,
|
|
52
|
+
hasClientUser: Boolean(user),
|
|
53
|
+
hasToken: Boolean(token),
|
|
54
|
+
isTokenExpired,
|
|
55
|
+
primaryWalletId: primaryWalletId$1,
|
|
56
|
+
sessionExpiresAt,
|
|
57
|
+
});
|
|
46
58
|
if (user || connectedWallets.length > 0) {
|
|
47
59
|
return;
|
|
48
60
|
}
|
|
49
|
-
|
|
61
|
+
const reason = token && !isTokenExpired ? 'wallet info is out of sync' : 'session expired';
|
|
62
|
+
yield logout(reason, {
|
|
50
63
|
connectedWallets,
|
|
51
64
|
primaryWalletId: primaryWalletId$1,
|
|
52
65
|
user,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { getDefaultClient } from '@dynamic-labs-sdk/client';
|
|
3
4
|
import '@dynamic-labs-sdk/client/core';
|
|
4
5
|
import '@dynamic-labs/sdk-api-core';
|
|
5
6
|
import '../../../../client/client.js';
|
|
6
7
|
import 'react';
|
|
7
|
-
import '@dynamic-labs-sdk/client';
|
|
8
8
|
import '../../../../config/ApiEndpoint.js';
|
|
9
9
|
import '@dynamic-labs/iconic';
|
|
10
10
|
import '@dynamic-labs/wallet-connector-core';
|
|
11
11
|
import 'react/jsx-runtime';
|
|
12
12
|
import '../../../../context/ViewContext/ViewContext.js';
|
|
13
|
-
import '../../../../shared/logger.js';
|
|
13
|
+
import { logger } from '../../../../shared/logger.js';
|
|
14
14
|
import '@dynamic-labs/wallet-book';
|
|
15
15
|
import '@dynamic-labs/utils';
|
|
16
16
|
import '../../../constants/colors.js';
|
|
@@ -25,7 +25,8 @@ import { getPrimaryWalletId } from '../../../../store/state/primaryWalletId/prim
|
|
|
25
25
|
import { getConnectedWalletsInfo } from '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
26
26
|
import '../../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
27
27
|
import '../../../../events/dynamicEvents.js';
|
|
28
|
-
import {
|
|
28
|
+
import { getMinAuthToken } from '../../../../client/extension/functions/getMinAuthToken/getMinAuthToken.js';
|
|
29
|
+
import { getExpiresAt } from '../../../../client/extension/functions/getExpiresAt/getExpiresAt.js';
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Detects mismatch between wallet info.
|
|
@@ -37,12 +38,24 @@ const handleWalletInfoOutOfSync = (_a) => __awaiter(void 0, [_a], void 0, functi
|
|
|
37
38
|
if (!primaryWalletId) {
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
|
-
const user =
|
|
41
|
+
const { user } = getDefaultClient();
|
|
41
42
|
const connectedWallets = getConnectedWalletsInfo();
|
|
43
|
+
const token = getMinAuthToken();
|
|
44
|
+
const sessionExpiresAt = getExpiresAt();
|
|
45
|
+
const isTokenExpired = sessionExpiresAt !== null && sessionExpiresAt <= Date.now();
|
|
46
|
+
logger.debug('[handleWalletInfoOutOfSync] validation check', {
|
|
47
|
+
connectedWalletsCount: connectedWallets.length,
|
|
48
|
+
hasClientUser: Boolean(user),
|
|
49
|
+
hasToken: Boolean(token),
|
|
50
|
+
isTokenExpired,
|
|
51
|
+
primaryWalletId,
|
|
52
|
+
sessionExpiresAt,
|
|
53
|
+
});
|
|
42
54
|
if (user || connectedWallets.length > 0) {
|
|
43
55
|
return;
|
|
44
56
|
}
|
|
45
|
-
|
|
57
|
+
const reason = token && !isTokenExpired ? 'wallet info is out of sync' : 'session expired';
|
|
58
|
+
yield logout(reason, {
|
|
46
59
|
connectedWallets,
|
|
47
60
|
primaryWalletId,
|
|
48
61
|
user,
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
7
7
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
+
var values = require('../../../../constants/values.cjs');
|
|
8
9
|
var findWalletOptionFor = require('../../../../functions/findWalletOptionFor/findWalletOptionFor.cjs');
|
|
9
10
|
var shouldManuallyReconnectOnRefresh = require('../../../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.cjs');
|
|
10
11
|
var convertLegacyPhantomLedgerConnector = require('../convertLegacyPhantomLedgerConnector/convertLegacyPhantomLedgerConnector.cjs');
|
|
@@ -50,10 +51,17 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
50
51
|
walletConnectorOptions,
|
|
51
52
|
});
|
|
52
53
|
}
|
|
54
|
+
// Prefer the chain from the account's verified credential over the
|
|
55
|
+
// connector's connectedChain. When a wallet falls back to a connector
|
|
56
|
+
// for a different chain (e.g. FallbackSolanaConnector for a SUI
|
|
57
|
+
// wallet), the connector's chain would be wrong.
|
|
58
|
+
const accountChain = account.chain
|
|
59
|
+
? values.VerifiedCredentialNameToChainEnum[account.chain]
|
|
60
|
+
: undefined;
|
|
53
61
|
return wallet.walletConnector.createWallet({
|
|
54
62
|
additionalAddresses: account.walletAdditionalAddresses,
|
|
55
63
|
address: account.address,
|
|
56
|
-
chain: wallet.walletConnector.connectedChain,
|
|
64
|
+
chain: accountChain !== null && accountChain !== void 0 ? accountChain : wallet.walletConnector.connectedChain,
|
|
57
65
|
connector: wallet.walletConnector,
|
|
58
66
|
id: account.id,
|
|
59
67
|
isAuthenticated: true,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { HardwareWalletEnum, WalletProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
3
3
|
import { isHardwareWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { VerifiedCredentialNameToChainEnum } from '../../../../constants/values.js';
|
|
4
5
|
import { findWalletOptionFor } from '../../../../functions/findWalletOptionFor/findWalletOptionFor.js';
|
|
5
6
|
import { shouldManuallyReconnectOnRefresh } from '../../../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.js';
|
|
6
7
|
import { convertLegacyPhantomLedgerConnector } from '../convertLegacyPhantomLedgerConnector/convertLegacyPhantomLedgerConnector.js';
|
|
@@ -46,10 +47,17 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
46
47
|
walletConnectorOptions,
|
|
47
48
|
});
|
|
48
49
|
}
|
|
50
|
+
// Prefer the chain from the account's verified credential over the
|
|
51
|
+
// connector's connectedChain. When a wallet falls back to a connector
|
|
52
|
+
// for a different chain (e.g. FallbackSolanaConnector for a SUI
|
|
53
|
+
// wallet), the connector's chain would be wrong.
|
|
54
|
+
const accountChain = account.chain
|
|
55
|
+
? VerifiedCredentialNameToChainEnum[account.chain]
|
|
56
|
+
: undefined;
|
|
49
57
|
return wallet.walletConnector.createWallet({
|
|
50
58
|
additionalAddresses: account.walletAdditionalAddresses,
|
|
51
59
|
address: account.address,
|
|
52
|
-
chain: wallet.walletConnector.connectedChain,
|
|
60
|
+
chain: accountChain !== null && accountChain !== void 0 ? accountChain : wallet.walletConnector.connectedChain,
|
|
53
61
|
connector: wallet.walletConnector,
|
|
54
62
|
id: account.id,
|
|
55
63
|
isAuthenticated: true,
|
|
@@ -245,15 +245,16 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
245
245
|
}
|
|
246
246
|
return baseClass;
|
|
247
247
|
};
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
248
|
+
const isEip7702SmartWallet = Boolean(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id.endsWith('-zerodev'));
|
|
249
|
+
const isErc4337SmartWallet = Boolean(primaryWallet && isSmartWallet(primaryWallet)) &&
|
|
250
|
+
!isEip7702SmartWallet;
|
|
251
|
+
const shouldShowAaWarning = isErc4337SmartWallet && !isLoading && Boolean(data) && !error;
|
|
252
|
+
const aaWarning = shouldShowAaWarning && (jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__zerodev-warning', children: [jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__zerodev-warning__title-row', children: [jsxRuntime.jsx(info.ReactComponent, { className: 'embedded-reveal-view__zerodev-warning__icon' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', copykey: 'dyn_embedded_reveal.aa_warning.title', children: t('dyn_embedded_reveal.aa_warning.title') })] }), jsxRuntime.jsxs(Typography.Typography, { variant: 'body_normal', weight: 'regular', copykey: 'dyn_embedded_reveal.aa_warning.subtitle', children: [t('dyn_embedded_reveal.aa_warning.subtitle'), jsxRuntime.jsx("button", { onClick: () => {
|
|
253
|
+
setShowAuthFlow(false);
|
|
254
|
+
setDynamicWidgetView('send-balance');
|
|
255
|
+
}, className: 'embedded-reveal-view__zerodev-warning__link-button', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'primary', className: 'underline', copykey: 'dyn_embedded_reveal.aa_warning.button', children: t('dyn_embedded_reveal.aa_warning.button') }) })] })] }));
|
|
256
|
+
const contentHeader = (jsxRuntime.jsx("div", { children: jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__description', children: !hasInjectedCredential && (jsxRuntime.jsx("div", { className: 'embedded-reveal-view__header', children: jsxRuntime.jsx("div", { className: 'embedded-reveal-view__header__hero', children: jsxRuntime.jsx(exportEmbeddedHero.ReactComponent, {}) }) })) }) }));
|
|
257
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: isPromptForExport ? null : closeButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsxRuntime.jsx("div", { className: 'embedded-reveal-view', children: jsxRuntime.jsxs("div", { className: getBodyClassName(), children: [aaWarning, (!isWaasWallet ||
|
|
257
258
|
!hasInjectedCredential ||
|
|
258
259
|
title !== credentialTitle) &&
|
|
259
260
|
contentHeader, (isTurnkeyWallet || isWaasWallet) && (jsxRuntime.jsx(EmbeddedWalletExport.EmbeddedWalletExport, { wallet: wallet, isTurnkeyWallet: isTurnkeyWallet, isWaasWallet: isWaasWallet, data: data, onIframeContainerRef: setIframeContainerRef, isVisible: !title.includes('Agree') })), hasInjectedCredential ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', onClick: () => {
|
|
@@ -241,15 +241,16 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
241
241
|
}
|
|
242
242
|
return baseClass;
|
|
243
243
|
};
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
244
|
+
const isEip7702SmartWallet = Boolean(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id.endsWith('-zerodev'));
|
|
245
|
+
const isErc4337SmartWallet = Boolean(primaryWallet && isSmartWallet(primaryWallet)) &&
|
|
246
|
+
!isEip7702SmartWallet;
|
|
247
|
+
const shouldShowAaWarning = isErc4337SmartWallet && !isLoading && Boolean(data) && !error;
|
|
248
|
+
const aaWarning = shouldShowAaWarning && (jsxs("div", { className: 'embedded-reveal-view__zerodev-warning', children: [jsxs("div", { className: 'embedded-reveal-view__zerodev-warning__title-row', children: [jsx(SvgInfo, { className: 'embedded-reveal-view__zerodev-warning__icon' }), jsx(Typography, { variant: 'body_normal', weight: 'bold', copykey: 'dyn_embedded_reveal.aa_warning.title', children: t('dyn_embedded_reveal.aa_warning.title') })] }), jsxs(Typography, { variant: 'body_normal', weight: 'regular', copykey: 'dyn_embedded_reveal.aa_warning.subtitle', children: [t('dyn_embedded_reveal.aa_warning.subtitle'), jsx("button", { onClick: () => {
|
|
249
|
+
setShowAuthFlow(false);
|
|
250
|
+
setDynamicWidgetView('send-balance');
|
|
251
|
+
}, className: 'embedded-reveal-view__zerodev-warning__link-button', children: jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'primary', className: 'underline', copykey: 'dyn_embedded_reveal.aa_warning.button', children: t('dyn_embedded_reveal.aa_warning.button') }) })] })] }));
|
|
252
|
+
const contentHeader = (jsx("div", { children: jsx("div", { className: 'embedded-reveal-view__body__description', children: !hasInjectedCredential && (jsx("div", { className: 'embedded-reveal-view__header', children: jsx("div", { className: 'embedded-reveal-view__header__hero', children: jsx(SvgExportEmbeddedHero, {}) }) })) }) }));
|
|
253
|
+
return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: isPromptForExport ? null : closeButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsx("div", { className: 'embedded-reveal-view', children: jsxs("div", { className: getBodyClassName(), children: [aaWarning, (!isWaasWallet ||
|
|
253
254
|
!hasInjectedCredential ||
|
|
254
255
|
title !== credentialTitle) &&
|
|
255
256
|
contentHeader, (isTurnkeyWallet || isWaasWallet) && (jsx(EmbeddedWalletExport, { wallet: wallet, isTurnkeyWallet: isTurnkeyWallet, isWaasWallet: isWaasWallet, data: data, onIframeContainerRef: setIframeContainerRef, isVisible: !title.includes('Agree') })), hasInjectedCredential ? (jsxs(Fragment, { children: [jsx(TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', onClick: () => {
|
|
@@ -115,7 +115,7 @@ require('../../components/IsBrowser/IsBrowser.cjs');
|
|
|
115
115
|
require('../../components/Popper/Popper/Popper.cjs');
|
|
116
116
|
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
117
117
|
|
|
118
|
-
const MfaChooseDeviceView = ({ isInitialSetup = true, createMfaToken = false, }) => {
|
|
118
|
+
const MfaChooseDeviceView = ({ isInitialSetup = true, createMfaToken = false, requestedScopes, }) => {
|
|
119
119
|
const { handleLogOut } = useDynamicContext.useDynamicContext();
|
|
120
120
|
const { t } = reactI18next.useTranslation();
|
|
121
121
|
const { pushView } = ViewContext.useViewContext();
|
|
@@ -139,14 +139,14 @@ const MfaChooseDeviceView = ({ isInitialSetup = true, createMfaToken = false, })
|
|
|
139
139
|
singleUse: true,
|
|
140
140
|
}
|
|
141
141
|
: undefined;
|
|
142
|
-
// we're calling authenticatePasskeyMFA here because we don't want
|
|
143
|
-
// it to be called twice by the usePromise in the confirmPasskey view
|
|
144
142
|
const authenticatePasskeyPromise = authenticatePasskeyMFA({
|
|
145
143
|
createMfaToken: createMfaTokenOptions,
|
|
144
|
+
requestedScopes,
|
|
146
145
|
});
|
|
147
146
|
pushView('passkey-confirm', {
|
|
148
147
|
authenticatePasskeyPromise,
|
|
149
148
|
createMfaToken,
|
|
149
|
+
requestedScopes,
|
|
150
150
|
});
|
|
151
151
|
};
|
|
152
152
|
const handleTotpClick = () => {
|
|
@@ -160,6 +160,7 @@ const MfaChooseDeviceView = ({ isInitialSetup = true, createMfaToken = false, })
|
|
|
160
160
|
pushView('mfa-verification', {
|
|
161
161
|
createMfaToken,
|
|
162
162
|
isInitialSetup,
|
|
163
|
+
requestedScopes,
|
|
163
164
|
showBackButton: true,
|
|
164
165
|
type: sdkApiCore.MFADeviceType.Totp,
|
|
165
166
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import type { TokenScope } from '@dynamic-labs/sdk-api-core';
|
|
2
3
|
export type MfaChooseDeviceViewProps = {
|
|
3
4
|
isInitialSetup?: boolean;
|
|
4
5
|
createMfaToken?: boolean;
|
|
6
|
+
requestedScopes?: TokenScope[];
|
|
5
7
|
};
|
|
6
8
|
export declare const MfaChooseDeviceView: FC<MfaChooseDeviceViewProps>;
|
|
@@ -111,7 +111,7 @@ import '../../components/IsBrowser/IsBrowser.js';
|
|
|
111
111
|
import '../../components/Popper/Popper/Popper.js';
|
|
112
112
|
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
113
113
|
|
|
114
|
-
const MfaChooseDeviceView = ({ isInitialSetup = true, createMfaToken = false, }) => {
|
|
114
|
+
const MfaChooseDeviceView = ({ isInitialSetup = true, createMfaToken = false, requestedScopes, }) => {
|
|
115
115
|
const { handleLogOut } = useDynamicContext();
|
|
116
116
|
const { t } = useTranslation();
|
|
117
117
|
const { pushView } = useViewContext();
|
|
@@ -135,14 +135,14 @@ const MfaChooseDeviceView = ({ isInitialSetup = true, createMfaToken = false, })
|
|
|
135
135
|
singleUse: true,
|
|
136
136
|
}
|
|
137
137
|
: undefined;
|
|
138
|
-
// we're calling authenticatePasskeyMFA here because we don't want
|
|
139
|
-
// it to be called twice by the usePromise in the confirmPasskey view
|
|
140
138
|
const authenticatePasskeyPromise = authenticatePasskeyMFA({
|
|
141
139
|
createMfaToken: createMfaTokenOptions,
|
|
140
|
+
requestedScopes,
|
|
142
141
|
});
|
|
143
142
|
pushView('passkey-confirm', {
|
|
144
143
|
authenticatePasskeyPromise,
|
|
145
144
|
createMfaToken,
|
|
145
|
+
requestedScopes,
|
|
146
146
|
});
|
|
147
147
|
};
|
|
148
148
|
const handleTotpClick = () => {
|
|
@@ -156,6 +156,7 @@ const MfaChooseDeviceView = ({ isInitialSetup = true, createMfaToken = false, })
|
|
|
156
156
|
pushView('mfa-verification', {
|
|
157
157
|
createMfaToken,
|
|
158
158
|
isInitialSetup,
|
|
159
|
+
requestedScopes,
|
|
159
160
|
showBackButton: true,
|
|
160
161
|
type: MFADeviceType.Totp,
|
|
161
162
|
});
|
|
@@ -112,7 +112,7 @@ require('../../components/IsBrowser/IsBrowser.cjs');
|
|
|
112
112
|
require('../../components/Popper/Popper/Popper.cjs');
|
|
113
113
|
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
114
114
|
|
|
115
|
-
const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = false, createMfaToken = false, deviceId, }) => {
|
|
115
|
+
const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = false, createMfaToken = false, deviceId, requestedScopes, }) => {
|
|
116
116
|
const { t } = reactI18next.useTranslation();
|
|
117
117
|
const { handleLogOut } = useDynamicContext.useDynamicContext();
|
|
118
118
|
const { clearStackAndPush, pushView, goBack, canGoBack } = ViewContext.useViewContext();
|
|
@@ -130,6 +130,7 @@ const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = fa
|
|
|
130
130
|
code,
|
|
131
131
|
createMfaToken: createMfaTokenOptions,
|
|
132
132
|
deviceId,
|
|
133
|
+
requestedScopes,
|
|
133
134
|
type,
|
|
134
135
|
});
|
|
135
136
|
}, {
|
|
@@ -164,6 +165,7 @@ const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = fa
|
|
|
164
165
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { MainIcon: passwordHero.ReactComponent, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: Boolean(mfaToken), onPinChange: onCodeChange, description: t('dyn_mfa.otp_verification_view.body'), onClickBack: onClickBack, disabled: isRateLimited }), !isInitialSetup && (jsxRuntime.jsxs("div", { className: 'mfa-verification-view__choose-another-method', children: [jsxRuntime.jsx(TextButton.TextButton, { className: 'mfa-verification-view__choose-another-method-button', onClick: () => pushView('mfa-choose-device', {
|
|
165
166
|
createMfaToken,
|
|
166
167
|
isInitialSetup,
|
|
168
|
+
requestedScopes,
|
|
167
169
|
}), copykey: 'dyn_mfa.otp_verification_view.choose_another_method', children: t('dyn_mfa.otp_verification_view.choose_another_method') }), jsxRuntime.jsx(TextButton.TextButton, { onClick: handleLogOut, copykey: 'dyn_mfa.otp_verification_view.logout', children: t('dyn_mfa.otp_verification_view.logout') })] }))] }));
|
|
168
170
|
};
|
|
169
171
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { MFADeviceType } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { MFADeviceType, TokenScope } from '@dynamic-labs/sdk-api-core';
|
|
3
3
|
export type MfaVerificationViewProps = {
|
|
4
4
|
deviceId?: string;
|
|
5
5
|
type?: MFADeviceType;
|
|
6
6
|
isInitialSetup?: boolean;
|
|
7
7
|
showBackButton?: boolean;
|
|
8
8
|
createMfaToken?: boolean;
|
|
9
|
+
requestedScopes?: TokenScope[];
|
|
9
10
|
};
|
|
10
|
-
export declare const MfaVerificationView: ({ type, isInitialSetup, showBackButton, createMfaToken, deviceId, }: MfaVerificationViewProps) => JSX.Element;
|
|
11
|
+
export declare const MfaVerificationView: ({ type, isInitialSetup, showBackButton, createMfaToken, deviceId, requestedScopes, }: MfaVerificationViewProps) => JSX.Element;
|