@dynamic-labs/sdk-react-core 2.1.0-alpha.24 → 2.1.0-alpha.26
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 +20 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/lib/components/QrCodeWrapper/QrCodeContainer/QrCodeContainer.cjs +1 -2
- package/src/lib/components/QrCodeWrapper/QrCodeContainer/QrCodeContainer.js +1 -2
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -5
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -5
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +0 -1
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +2 -2
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +2 -2
- package/src/lib/context/DynamicContext/validators/validators.d.ts +2 -2
- package/src/lib/context/PasskeyContext/PasskeyContext.cjs +1 -1
- package/src/lib/context/PasskeyContext/PasskeyContext.js +2 -2
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +30 -14
- package/src/lib/data/api/embeddedWallets/embeddedWallets.d.ts +3 -2
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +30 -14
- package/src/lib/data/api/mfa/mfa.cjs +10 -5
- package/src/lib/data/api/mfa/mfa.d.ts +1 -1
- package/src/lib/data/api/mfa/mfa.js +10 -5
- package/src/lib/data/api/wallets/wallets.cjs +6 -3
- package/src/lib/data/api/wallets/wallets.d.ts +1 -1
- package/src/lib/data/api/wallets/wallets.js +6 -3
- package/src/lib/events/embeddedWallet.d.ts +2 -1
- package/src/lib/locale/en/translation.cjs +2 -2
- package/src/lib/locale/en/translation.d.ts +1 -1
- package/src/lib/locale/en/translation.js +2 -2
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +1 -1
- package/src/lib/shared/types/localStorage.d.ts +0 -13
- package/src/lib/store/actions/networkConfigurationsActions/index.d.ts +1 -0
- package/src/lib/store/actions/networkConfigurationsActions/networkConfigurationsActions.cjs +10 -0
- package/src/lib/store/actions/networkConfigurationsActions/networkConfigurationsActions.d.ts +7 -0
- package/src/lib/store/actions/networkConfigurationsActions/networkConfigurationsActions.js +6 -0
- package/src/lib/store/hooks/useNetworkConfigurations/index.d.ts +1 -0
- package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.cjs +139 -0
- package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.d.ts +12 -0
- package/src/lib/store/hooks/useNetworkConfigurations/useNetworkConfigurations.js +135 -0
- package/src/lib/store/index.d.ts +3 -1
- package/src/lib/store/store.cjs +1 -0
- package/src/lib/store/store.js +1 -0
- package/src/lib/store/types.d.ts +6 -1
- package/src/lib/store/utils/clearExpiredData/clearExpiredData.cjs +4 -1
- package/src/lib/store/utils/clearExpiredData/clearExpiredData.js +4 -1
- package/src/lib/utils/constants/localStorage.cjs +0 -2
- package/src/lib/utils/constants/localStorage.js +1 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +12 -15
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +12 -15
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +3 -3
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +3 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +11 -10
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +11 -10
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +5 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +5 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +1 -1
- package/src/lib/utils/hooks/useInitEmbeddedWalletAuthMethod/useInitEmbeddedWalletAuthMethod.cjs +2 -6
- package/src/lib/utils/hooks/useInitEmbeddedWalletAuthMethod/useInitEmbeddedWalletAuthMethod.js +2 -6
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +1 -4
- package/src/lib/utils/hooks/useMfa/useMfa.js +1 -4
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +29 -21
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +29 -21
- 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.cjs +13 -4
- package/src/lib/utils/hooks/useSocialAuth/farcaster.d.ts +2 -0
- package/src/lib/utils/hooks/useSocialAuth/farcaster.js +13 -4
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +4 -4
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +7 -6
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +5 -5
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +3 -5
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +3 -5
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +4 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +5 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +2 -2
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +2 -2
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.cjs +5 -4
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.js +5 -4
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +5 -6
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.d.ts +1 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +5 -6
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +8 -18
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.d.ts +4 -12
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +8 -18
- package/src/lib/components/MockedQrCode/MockedQrCode.cjs +0 -89
- package/src/lib/components/MockedQrCode/MockedQrCode.d.ts +0 -2
- package/src/lib/components/MockedQrCode/MockedQrCode.js +0 -85
- package/src/lib/components/MockedQrCode/index.d.ts +0 -1
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/index.d.ts +0 -1
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.cjs +0 -117
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.d.ts +0 -14
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/useProcessNetworkConfigurations.js +0 -113
|
@@ -17,8 +17,8 @@ import '../../../shared/consts/index.js';
|
|
|
17
17
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
18
18
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
19
19
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
|
+
import { USER_NOT_LOGGED_IN } from '../../constants/errors.js';
|
|
20
21
|
import '@dynamic-labs/multi-wallet';
|
|
21
|
-
import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
|
|
22
22
|
import 'react-international-phone';
|
|
23
23
|
import { isTurnkeyEnabled } from '../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
|
|
24
24
|
import { getEnabledEmbeddedWalletsAuthenticators } from '../../functions/getEnabledEmbeddedWalletsAuthenticators/getEnabledEmbeddedWalletsAuthenticators.js';
|
|
@@ -29,7 +29,6 @@ import '../../../config/ApiEndpoint.js';
|
|
|
29
29
|
import '@dynamic-labs/store';
|
|
30
30
|
import '../../../locale/locale.js';
|
|
31
31
|
import { updateUserProfileFields } from '../../../data/api/user/user.js';
|
|
32
|
-
import { updateJWTAndCreateUserProfile } from '../../functions/updateJWTAndCreateUserProfile/updateJWTAndCreateUserProfile.js';
|
|
33
32
|
import { getEmbeddedWalletSessionExpiration } from '../../functions/getEmbeddedWalletSessionExpiration/getEmbeddedWalletSessionExpiration.js';
|
|
34
33
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
35
34
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
@@ -90,7 +89,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
90
89
|
// Hook exposed to customers and used internally to trigger passkey recovery
|
|
91
90
|
const usePasskeyRecovery = () => {
|
|
92
91
|
var _a, _b;
|
|
93
|
-
const { environmentId, primaryWallet, projectSettings, setShowAuthFlow, user,
|
|
92
|
+
const { environmentId, primaryWallet, projectSettings, setShowAuthFlow, user, } = useInternalDynamicContext();
|
|
94
93
|
const { createRootElement } = useElementById();
|
|
95
94
|
const iframeContainerRef = createRootElement(iframeContainerId);
|
|
96
95
|
const { userHasEmbeddedWallet } = useEmbeddedWallet();
|
|
@@ -141,17 +140,30 @@ const usePasskeyRecovery = () => {
|
|
|
141
140
|
}), [wallet, isTurnkeyWalletWithoutAuthenticator, isSessionRestored]);
|
|
142
141
|
const initPasskeyRecoveryProcess = useCallback((authenticatorType, currentAction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
142
|
var _e;
|
|
143
|
+
const validateRecoveryRequest = () => {
|
|
144
|
+
if (!user) {
|
|
145
|
+
throw new Error(USER_NOT_LOGGED_IN);
|
|
146
|
+
}
|
|
147
|
+
if (!isTurnkeyEnabled(projectSettings)) {
|
|
148
|
+
throw new Error('Dynamic embedded wallet is not enabled. Go to the dashboard and make sure to have both Dynamic embedded wallet and at least one EVM network enabled. Also, check if EthereumWalletConnectors is in the DynamicContextProvider > settings > walletConnectors.');
|
|
149
|
+
}
|
|
150
|
+
if (!userHasEmbeddedWallet()) {
|
|
151
|
+
throw new Error('Dynamic embedded wallet not found');
|
|
152
|
+
}
|
|
153
|
+
if (wallet && !isPasskeyWalletConnector(wallet.connector)) {
|
|
154
|
+
throw new Error('Dynamic embedded wallet not found.');
|
|
155
|
+
}
|
|
156
|
+
};
|
|
144
157
|
validateRecoveryRequest();
|
|
145
158
|
const turnkeyRecoveryHandler = (wallet === null || wallet === void 0 ? void 0 : wallet.connector).getAuthenticatorHandler();
|
|
146
159
|
// email auth - session is still up, so create passkey authenticator usign the same session
|
|
147
160
|
if (authenticatorType === 'passkey' &&
|
|
148
161
|
turnkeyRecoveryHandler.isSessionActive()) {
|
|
149
|
-
|
|
162
|
+
yield addNewPasskeyAuthenticator({
|
|
150
163
|
environmentId,
|
|
151
164
|
user,
|
|
152
165
|
wallet,
|
|
153
166
|
});
|
|
154
|
-
setUser(updateJWTAndCreateUserProfile(passkeyRecoveryResponse.jwt, passkeyRecoveryResponse.minifiedJwt));
|
|
155
167
|
setShowAuthFlow(false);
|
|
156
168
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
157
169
|
return wallet;
|
|
@@ -194,22 +206,18 @@ const usePasskeyRecovery = () => {
|
|
|
194
206
|
dynamicEvents.once('passkeyRecoveryCompleted', (wallet) => resolve(wallet));
|
|
195
207
|
dynamicEvents.once('passkeyRecoveryFailed', (error) => reject(error));
|
|
196
208
|
});
|
|
197
|
-
}), [
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (wallet && !isPasskeyWalletConnector(wallet.connector)) {
|
|
210
|
-
throw new Error('Passkey embedded wallet not found.');
|
|
211
|
-
}
|
|
212
|
-
};
|
|
209
|
+
}), [
|
|
210
|
+
wallet,
|
|
211
|
+
projectSettings,
|
|
212
|
+
hasRecoveryEmail,
|
|
213
|
+
userHasEmbeddedWallet,
|
|
214
|
+
environmentId,
|
|
215
|
+
user,
|
|
216
|
+
setShowAuthFlow,
|
|
217
|
+
setView,
|
|
218
|
+
initAuthMethod,
|
|
219
|
+
iframeContainerRef,
|
|
220
|
+
]);
|
|
213
221
|
const addRecoveryEmail = (emailInput) => __awaiter(void 0, void 0, void 0, function* () {
|
|
214
222
|
try {
|
|
215
223
|
let updatedUser = user;
|
|
@@ -31,9 +31,9 @@ var isSocialKycEnabled = require('../../functions/isSocialKycEnabled/isSocialKyc
|
|
|
31
31
|
require('viem');
|
|
32
32
|
require('viem/chains');
|
|
33
33
|
require('../../../config/ApiEndpoint.cjs');
|
|
34
|
+
require('@dynamic-labs/store');
|
|
34
35
|
var oauth = require('../../../data/api/oauth/oauth.cjs');
|
|
35
36
|
require('../../../locale/locale.cjs');
|
|
36
|
-
require('@dynamic-labs/store');
|
|
37
37
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
38
38
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
39
39
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -27,9 +27,9 @@ import { isSocialKycEnabled } from '../../functions/isSocialKycEnabled/isSocialK
|
|
|
27
27
|
import 'viem';
|
|
28
28
|
import 'viem/chains';
|
|
29
29
|
import '../../../config/ApiEndpoint.js';
|
|
30
|
+
import '@dynamic-labs/store';
|
|
30
31
|
import { unlinkOAuth } from '../../../data/api/oauth/oauth.js';
|
|
31
32
|
import '../../../locale/locale.js';
|
|
32
|
-
import '@dynamic-labs/store';
|
|
33
33
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
34
34
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
35
35
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
8
|
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
8
9
|
require('@dynamic-labs/sdk-api-core');
|
|
9
10
|
var logger = require('../../../shared/logger.cjs');
|
|
@@ -16,7 +17,6 @@ require('@dynamic-labs/wallet-book');
|
|
|
16
17
|
require('../../constants/colors.cjs');
|
|
17
18
|
require('../../constants/values.cjs');
|
|
18
19
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
|
-
require('@dynamic-labs/utils');
|
|
20
20
|
require('../../../shared/consts/index.cjs');
|
|
21
21
|
|
|
22
22
|
const CONNECT_URL = 'https://relay.farcaster.xyz/v1/channel';
|
|
@@ -25,7 +25,7 @@ const STATUS_TIMEOUT = 300000;
|
|
|
25
25
|
const STATUS_INTERVAL = 1000;
|
|
26
26
|
const connect = (connectRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
27
27
|
try {
|
|
28
|
-
const response = yield fetch(CONNECT_URL, {
|
|
28
|
+
const response = yield utils.FetchService.fetch(CONNECT_URL, {
|
|
29
29
|
body: JSON.stringify(connectRequest),
|
|
30
30
|
headers: {
|
|
31
31
|
'Content-Type': 'application/json',
|
|
@@ -44,7 +44,7 @@ const connect = (connectRequest) => _tslib.__awaiter(void 0, void 0, void 0, fun
|
|
|
44
44
|
});
|
|
45
45
|
const status = (connectStatusRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
46
46
|
try {
|
|
47
|
-
const response = yield fetch(STATUS_URL, {
|
|
47
|
+
const response = yield utils.FetchService.fetch(STATUS_URL, {
|
|
48
48
|
headers: {
|
|
49
49
|
Authorization: `Bearer ${connectStatusRequest.channelToken}`,
|
|
50
50
|
'Content-Type': 'application/json',
|
|
@@ -64,9 +64,18 @@ const status = (connectStatusRequest) => _tslib.__awaiter(void 0, void 0, void 0
|
|
|
64
64
|
const watchStatus = (connectStatusRequest_1, ...args_1) => _tslib.__awaiter(void 0, [connectStatusRequest_1, ...args_1], void 0, function* (connectStatusRequest, { timeout = STATUS_TIMEOUT, interval = STATUS_INTERVAL } = {}) {
|
|
65
65
|
const deadline = Date.now() + timeout;
|
|
66
66
|
let shouldPoll = true;
|
|
67
|
+
let storedResolve = undefined;
|
|
68
|
+
// When we cancel, immediately resolve the current timeout promise and abort status watch
|
|
67
69
|
dynamicEvents.dynamicEvents.on('farcasterConnectCancelled', () => {
|
|
68
70
|
shouldPoll = false;
|
|
71
|
+
storedResolve === null || storedResolve === void 0 ? void 0 : storedResolve();
|
|
72
|
+
storedResolve = undefined;
|
|
69
73
|
});
|
|
74
|
+
// Declaring the promise callback outside of loop to avoid unnecessary garbage generation
|
|
75
|
+
const timeoutCallback = (resolve) => {
|
|
76
|
+
storedResolve = resolve;
|
|
77
|
+
setTimeout(resolve, interval);
|
|
78
|
+
};
|
|
70
79
|
while (shouldPoll && Date.now() < deadline) {
|
|
71
80
|
const response = yield status(connectStatusRequest);
|
|
72
81
|
if (!response) {
|
|
@@ -75,7 +84,7 @@ const watchStatus = (connectStatusRequest_1, ...args_1) => _tslib.__awaiter(void
|
|
|
75
84
|
if (response.state === 'completed') {
|
|
76
85
|
return response;
|
|
77
86
|
}
|
|
78
|
-
yield new Promise(
|
|
87
|
+
yield new Promise(timeoutCallback);
|
|
79
88
|
}
|
|
80
89
|
if (!shouldPoll) {
|
|
81
90
|
return 'cancelled';
|
|
@@ -8,7 +8,9 @@ interface FarcasterConnectRequest {
|
|
|
8
8
|
redirectUrl?: string;
|
|
9
9
|
}
|
|
10
10
|
interface FarcasterConnectResponse {
|
|
11
|
+
/** Connect relay channel token UUID */
|
|
11
12
|
channelToken: string;
|
|
13
|
+
/** Sign in With Farcaster URL to present to the user */
|
|
12
14
|
url: string;
|
|
13
15
|
}
|
|
14
16
|
interface FarcasterConnectStatusRequest {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { FetchService } from '@dynamic-labs/utils';
|
|
3
4
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
4
5
|
import '@dynamic-labs/sdk-api-core';
|
|
5
6
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -12,7 +13,6 @@ import '@dynamic-labs/wallet-book';
|
|
|
12
13
|
import '../../constants/colors.js';
|
|
13
14
|
import '../../constants/values.js';
|
|
14
15
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
15
|
-
import '@dynamic-labs/utils';
|
|
16
16
|
import '../../../shared/consts/index.js';
|
|
17
17
|
|
|
18
18
|
const CONNECT_URL = 'https://relay.farcaster.xyz/v1/channel';
|
|
@@ -21,7 +21,7 @@ const STATUS_TIMEOUT = 300000;
|
|
|
21
21
|
const STATUS_INTERVAL = 1000;
|
|
22
22
|
const connect = (connectRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
23
|
try {
|
|
24
|
-
const response = yield fetch(CONNECT_URL, {
|
|
24
|
+
const response = yield FetchService.fetch(CONNECT_URL, {
|
|
25
25
|
body: JSON.stringify(connectRequest),
|
|
26
26
|
headers: {
|
|
27
27
|
'Content-Type': 'application/json',
|
|
@@ -40,7 +40,7 @@ const connect = (connectRequest) => __awaiter(void 0, void 0, void 0, function*
|
|
|
40
40
|
});
|
|
41
41
|
const status = (connectStatusRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
42
|
try {
|
|
43
|
-
const response = yield fetch(STATUS_URL, {
|
|
43
|
+
const response = yield FetchService.fetch(STATUS_URL, {
|
|
44
44
|
headers: {
|
|
45
45
|
Authorization: `Bearer ${connectStatusRequest.channelToken}`,
|
|
46
46
|
'Content-Type': 'application/json',
|
|
@@ -60,9 +60,18 @@ const status = (connectStatusRequest) => __awaiter(void 0, void 0, void 0, funct
|
|
|
60
60
|
const watchStatus = (connectStatusRequest_1, ...args_1) => __awaiter(void 0, [connectStatusRequest_1, ...args_1], void 0, function* (connectStatusRequest, { timeout = STATUS_TIMEOUT, interval = STATUS_INTERVAL } = {}) {
|
|
61
61
|
const deadline = Date.now() + timeout;
|
|
62
62
|
let shouldPoll = true;
|
|
63
|
+
let storedResolve = undefined;
|
|
64
|
+
// When we cancel, immediately resolve the current timeout promise and abort status watch
|
|
63
65
|
dynamicEvents.on('farcasterConnectCancelled', () => {
|
|
64
66
|
shouldPoll = false;
|
|
67
|
+
storedResolve === null || storedResolve === void 0 ? void 0 : storedResolve();
|
|
68
|
+
storedResolve = undefined;
|
|
65
69
|
});
|
|
70
|
+
// Declaring the promise callback outside of loop to avoid unnecessary garbage generation
|
|
71
|
+
const timeoutCallback = (resolve) => {
|
|
72
|
+
storedResolve = resolve;
|
|
73
|
+
setTimeout(resolve, interval);
|
|
74
|
+
};
|
|
66
75
|
while (shouldPoll && Date.now() < deadline) {
|
|
67
76
|
const response = yield status(connectStatusRequest);
|
|
68
77
|
if (!response) {
|
|
@@ -71,7 +80,7 @@ const watchStatus = (connectStatusRequest_1, ...args_1) => __awaiter(void 0, [co
|
|
|
71
80
|
if (response.state === 'completed') {
|
|
72
81
|
return response;
|
|
73
82
|
}
|
|
74
|
-
yield new Promise(
|
|
83
|
+
yield new Promise(timeoutCallback);
|
|
75
84
|
}
|
|
76
85
|
if (!shouldPoll) {
|
|
77
86
|
return 'cancelled';
|
|
@@ -33,9 +33,9 @@ var stringifyURIQuery = require('../../functions/stringifyURIQuery/stringifyURIQ
|
|
|
33
33
|
require('viem');
|
|
34
34
|
require('viem/chains');
|
|
35
35
|
require('../../../config/ApiEndpoint.cjs');
|
|
36
|
+
require('@dynamic-labs/store');
|
|
36
37
|
var oauth = require('../../../data/api/oauth/oauth.cjs');
|
|
37
38
|
require('../../../locale/locale.cjs');
|
|
38
|
-
require('@dynamic-labs/store');
|
|
39
39
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
40
40
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
41
41
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -213,7 +213,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
213
213
|
type: 'social',
|
|
214
214
|
});
|
|
215
215
|
if (provider === sdkApiCore.ProviderEnum.Farcaster)
|
|
216
|
-
return connectWithFarcaster(authMode, captchaToken);
|
|
216
|
+
return connectWithFarcaster(authMode, { captchaToken });
|
|
217
217
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
218
218
|
const state = randomString.randomString(8);
|
|
219
219
|
const verifier = randomString.randomString(43);
|
|
@@ -368,7 +368,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
368
368
|
}), authWindowTimeout);
|
|
369
369
|
}
|
|
370
370
|
});
|
|
371
|
-
const connectWithFarcaster = (
|
|
371
|
+
const connectWithFarcaster = (authMode_1, _g) => _tslib.__awaiter(void 0, [authMode_1, _g], void 0, function* (authMode, { captchaToken }) {
|
|
372
372
|
const dynamicNonce = consumeNonce();
|
|
373
373
|
const domain = window.location.host;
|
|
374
374
|
const data = yield farcaster.connect({
|
|
@@ -383,7 +383,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
383
383
|
}
|
|
384
384
|
// If on mobile, we want to redirect to the Warpcast app.
|
|
385
385
|
if (utils.isMobile()) {
|
|
386
|
-
|
|
386
|
+
yield utils.PlatformService.openURL(data.url);
|
|
387
387
|
}
|
|
388
388
|
else {
|
|
389
389
|
setShowAuthFlow(true);
|
|
@@ -8,14 +8,15 @@ type UseSocialAuthProps = {
|
|
|
8
8
|
onError?: () => void;
|
|
9
9
|
onFarcasterUrl?: (url: string) => void;
|
|
10
10
|
};
|
|
11
|
+
export type ConnectSocialAccountProps = {
|
|
12
|
+
authMode: SocialAuthMode;
|
|
13
|
+
provider: ProviderEnum;
|
|
14
|
+
validator?: (provider: ProviderEnum) => boolean;
|
|
15
|
+
captchaToken?: string;
|
|
16
|
+
};
|
|
11
17
|
export declare const useSocialAuth: ({ sessionTimeout, onSettled, onError, onFarcasterUrl, }: UseSocialAuthProps) => {
|
|
12
18
|
readonly checkValidProvider: (provider: ProviderEnum, authMode: SocialAuthMode) => boolean;
|
|
13
|
-
readonly connectSocialAccount: ({ authMode, provider, validator, captchaToken, }:
|
|
14
|
-
authMode: SocialAuthMode;
|
|
15
|
-
provider: ProviderEnum;
|
|
16
|
-
validator?: (provider: ProviderEnum) => boolean;
|
|
17
|
-
captchaToken?: string;
|
|
18
|
-
}) => Promise<void>;
|
|
19
|
+
readonly connectSocialAccount: ({ authMode, provider, validator, captchaToken, }: ConnectSocialAccountProps) => Promise<void>;
|
|
19
20
|
readonly error: SocialOAuthError | undefined;
|
|
20
21
|
readonly handleError: (provider: ProviderEnum | undefined, code: SocialOAuthErrorCode, message: string, options?: {
|
|
21
22
|
raiseAuthFailure?: boolean | undefined;
|
|
@@ -3,7 +3,7 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { useState, useRef } from 'react';
|
|
4
4
|
import { ProviderEnum, OauthResultStatus } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { SocialOAuthErrorCode } from '@dynamic-labs/types';
|
|
6
|
-
import { isMobile, SocialAccountAlreadyExistsError } from '@dynamic-labs/utils';
|
|
6
|
+
import { isMobile, PlatformService, SocialAccountAlreadyExistsError } from '@dynamic-labs/utils';
|
|
7
7
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
8
8
|
import { logger } from '../../../shared/logger.js';
|
|
9
9
|
import '@dynamic-labs/iconic';
|
|
@@ -29,9 +29,9 @@ import { stringifyURIQuery } from '../../functions/stringifyURIQuery/stringifyUR
|
|
|
29
29
|
import 'viem';
|
|
30
30
|
import 'viem/chains';
|
|
31
31
|
import '../../../config/ApiEndpoint.js';
|
|
32
|
+
import '@dynamic-labs/store';
|
|
32
33
|
import { getOAuthResult, signInOAuth, farcasterSignIn, verifyOAuth } from '../../../data/api/oauth/oauth.js';
|
|
33
34
|
import '../../../locale/locale.js';
|
|
34
|
-
import '@dynamic-labs/store';
|
|
35
35
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
36
36
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
37
37
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -209,7 +209,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
209
209
|
type: 'social',
|
|
210
210
|
});
|
|
211
211
|
if (provider === ProviderEnum.Farcaster)
|
|
212
|
-
return connectWithFarcaster(authMode, captchaToken);
|
|
212
|
+
return connectWithFarcaster(authMode, { captchaToken });
|
|
213
213
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
214
214
|
const state = randomString(8);
|
|
215
215
|
const verifier = randomString(43);
|
|
@@ -364,7 +364,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
364
364
|
}), authWindowTimeout);
|
|
365
365
|
}
|
|
366
366
|
});
|
|
367
|
-
const connectWithFarcaster = (
|
|
367
|
+
const connectWithFarcaster = (authMode_1, _g) => __awaiter(void 0, [authMode_1, _g], void 0, function* (authMode, { captchaToken }) {
|
|
368
368
|
const dynamicNonce = consumeNonce();
|
|
369
369
|
const domain = window.location.host;
|
|
370
370
|
const data = yield connect({
|
|
@@ -379,7 +379,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
379
379
|
}
|
|
380
380
|
// If on mobile, we want to redirect to the Warpcast app.
|
|
381
381
|
if (isMobile()) {
|
|
382
|
-
|
|
382
|
+
yield PlatformService.openURL(data.url);
|
|
383
383
|
}
|
|
384
384
|
else {
|
|
385
385
|
setShowAuthFlow(true);
|
|
@@ -28,7 +28,7 @@ var getVerifyArgs = require('../../functions/getVerifyArgs/getVerifyArgs.cjs');
|
|
|
28
28
|
require('viem');
|
|
29
29
|
require('viem/chains');
|
|
30
30
|
require('../../../config/ApiEndpoint.cjs');
|
|
31
|
-
|
|
31
|
+
require('@dynamic-labs/store');
|
|
32
32
|
require('../../../locale/locale.cjs');
|
|
33
33
|
var wallets = require('../../../data/api/wallets/wallets.cjs');
|
|
34
34
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
@@ -47,7 +47,6 @@ require('../../../context/MockContext/MockContext.cjs');
|
|
|
47
47
|
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
48
48
|
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
49
49
|
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
50
|
-
require('@dynamic-labs/store');
|
|
51
50
|
require('@dynamic-labs/rpc-providers');
|
|
52
51
|
require('react-i18next');
|
|
53
52
|
require('../../../components/Alert/Alert.cjs');
|
|
@@ -117,11 +116,10 @@ const useTransferWallet = () => {
|
|
|
117
116
|
// and if props doesn't have nonce, that means it has messageToSignOverride and signedMessageOverride
|
|
118
117
|
nonce: '', siweStatement: props.overrideSiweStatement, walletProvider: getWalletProvider.getWalletProvider(walletConnector) });
|
|
119
118
|
const verifyArgs = yield getVerifyArgs.getVerifyArgs(args);
|
|
120
|
-
const
|
|
121
|
-
if (!
|
|
119
|
+
const userProfile = yield wallets.transferWallet(environmentId, verifyArgs);
|
|
120
|
+
if (!userProfile) {
|
|
122
121
|
throw new utils.DynamicError('Error transferring wallet.');
|
|
123
122
|
}
|
|
124
|
-
const userProfile = storeAuthTokenAndUser.storeAuthTokenAndUser(response);
|
|
125
123
|
updatePrimaryWalletId(walletConnector, userProfile);
|
|
126
124
|
const walletId = userProfile.lastVerifiedCredentialId;
|
|
127
125
|
if (walletId) {
|
|
@@ -24,7 +24,7 @@ import { getVerifyArgs } from '../../functions/getVerifyArgs/getVerifyArgs.js';
|
|
|
24
24
|
import 'viem';
|
|
25
25
|
import 'viem/chains';
|
|
26
26
|
import '../../../config/ApiEndpoint.js';
|
|
27
|
-
import
|
|
27
|
+
import '@dynamic-labs/store';
|
|
28
28
|
import '../../../locale/locale.js';
|
|
29
29
|
import { transferWallet } from '../../../data/api/wallets/wallets.js';
|
|
30
30
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
@@ -43,7 +43,6 @@ import '../../../context/MockContext/MockContext.js';
|
|
|
43
43
|
import '../../../views/CollectUserDataView/useFields.js';
|
|
44
44
|
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
45
45
|
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
46
|
-
import '@dynamic-labs/store';
|
|
47
46
|
import '@dynamic-labs/rpc-providers';
|
|
48
47
|
import 'react-i18next';
|
|
49
48
|
import '../../../components/Alert/Alert.js';
|
|
@@ -113,11 +112,10 @@ const useTransferWallet = () => {
|
|
|
113
112
|
// and if props doesn't have nonce, that means it has messageToSignOverride and signedMessageOverride
|
|
114
113
|
nonce: '', siweStatement: props.overrideSiweStatement, walletProvider: getWalletProvider(walletConnector) });
|
|
115
114
|
const verifyArgs = yield getVerifyArgs(args);
|
|
116
|
-
const
|
|
117
|
-
if (!
|
|
115
|
+
const userProfile = yield transferWallet(environmentId, verifyArgs);
|
|
116
|
+
if (!userProfile) {
|
|
118
117
|
throw new DynamicError('Error transferring wallet.');
|
|
119
118
|
}
|
|
120
|
-
const userProfile = storeAuthTokenAndUser(response);
|
|
121
119
|
updatePrimaryWalletId(walletConnector, userProfile);
|
|
122
120
|
const walletId = userProfile.lastVerifiedCredentialId;
|
|
123
121
|
if (walletId) {
|
|
@@ -27,8 +27,8 @@ require('react-international-phone');
|
|
|
27
27
|
require('viem');
|
|
28
28
|
require('viem/chains');
|
|
29
29
|
require('../../../config/ApiEndpoint.cjs');
|
|
30
|
-
var mfa = require('../../../data/api/mfa/mfa.cjs');
|
|
31
30
|
var storeAuthTokenAndUser = require('../../../store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.cjs');
|
|
31
|
+
var mfa = require('../../../data/api/mfa/mfa.cjs');
|
|
32
32
|
require('../../../locale/locale.cjs');
|
|
33
33
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
34
34
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -178,6 +178,9 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
178
178
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
179
179
|
});
|
|
180
180
|
const handleError = (error, { options = {}, onError, }) => {
|
|
181
|
+
if (error instanceof utils.MfaInvalidOtpError) {
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
181
184
|
// these get caught in onboarding form and handled there
|
|
182
185
|
if (error instanceof utils.EmailAlreadyExistsError ||
|
|
183
186
|
error instanceof utils.CustomFieldNotUniqueError ||
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { DynamicError, EmailAlreadyExistsError, CustomFieldNotUniqueError, UsernameAlreadyExistsError, TooManyEmailVerificationsError, InvalidPhoneNumberError, NoAccessError, AccountExistsError, UserHasAccountWithEmailError, sleep } from '@dynamic-labs/utils';
|
|
3
|
+
import { DynamicError, MfaInvalidOtpError, EmailAlreadyExistsError, CustomFieldNotUniqueError, UsernameAlreadyExistsError, TooManyEmailVerificationsError, InvalidPhoneNumberError, NoAccessError, AccountExistsError, UserHasAccountWithEmailError, sleep } from '@dynamic-labs/utils';
|
|
4
4
|
import { useAccountExistsContext } from '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
5
5
|
import 'react';
|
|
6
6
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
@@ -23,8 +23,8 @@ import 'react-international-phone';
|
|
|
23
23
|
import 'viem';
|
|
24
24
|
import 'viem/chains';
|
|
25
25
|
import '../../../config/ApiEndpoint.js';
|
|
26
|
-
import { getUserMfaDevices } from '../../../data/api/mfa/mfa.js';
|
|
27
26
|
import { storeAuthTokenAndUser } from '../../../store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.js';
|
|
27
|
+
import { getUserMfaDevices } from '../../../data/api/mfa/mfa.js';
|
|
28
28
|
import '../../../locale/locale.js';
|
|
29
29
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
30
30
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -174,6 +174,9 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
174
174
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
175
175
|
});
|
|
176
176
|
const handleError = (error, { options = {}, onError, }) => {
|
|
177
|
+
if (error instanceof MfaInvalidOtpError) {
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
177
180
|
// these get caught in onboarding form and handled there
|
|
178
181
|
if (error instanceof EmailAlreadyExistsError ||
|
|
179
182
|
error instanceof CustomFieldNotUniqueError ||
|
|
@@ -184,7 +184,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
184
184
|
id: embeddedWalletVerifiedCredential.id,
|
|
185
185
|
};
|
|
186
186
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
187
|
-
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt);
|
|
187
|
+
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt, user);
|
|
188
188
|
}
|
|
189
189
|
if (isUsingPregeneratedWallets || isManualMode) {
|
|
190
190
|
setShowAuthFlow(false);
|
|
@@ -180,7 +180,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
180
180
|
id: embeddedWalletVerifiedCredential.id,
|
|
181
181
|
};
|
|
182
182
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
183
|
-
dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt);
|
|
183
|
+
dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt, user);
|
|
184
184
|
}
|
|
185
185
|
if (isUsingPregeneratedWallets || isManualMode) {
|
|
186
186
|
setShowAuthFlow(false);
|
|
@@ -15,8 +15,8 @@ require('../../shared/logger.cjs');
|
|
|
15
15
|
require('@dynamic-labs/iconic');
|
|
16
16
|
require('@dynamic-labs/wallet-connector-core');
|
|
17
17
|
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
18
|
-
var footerInfoIcon = require('../../shared/assets/footer-info-icon.cjs');
|
|
19
18
|
var link = require('../../shared/assets/link.cjs');
|
|
19
|
+
var passwordHero = require('../../shared/assets/password-hero.cjs');
|
|
20
20
|
require('@dynamic-labs/wallet-book');
|
|
21
21
|
require('../../utils/constants/colors.cjs');
|
|
22
22
|
require('../../utils/constants/values.cjs');
|
|
@@ -100,7 +100,7 @@ const MfaSecureDeviceView = ({ type }) => {
|
|
|
100
100
|
onBackClick: onMfaVerificationBackClick,
|
|
101
101
|
});
|
|
102
102
|
};
|
|
103
|
-
return (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsxRuntime.jsx(Typography.Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsxRuntime.jsx(spinner.Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsxRuntime.jsx(QRCode.QRCode, { Icon: jsxRuntime.jsx(
|
|
103
|
+
return (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsxRuntime.jsx(Typography.Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsxRuntime.jsx(spinner.Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsxRuntime.jsx(QRCode.QRCode, { Icon: jsxRuntime.jsx(passwordHero.ReactComponent, {}), value: data.uri, logoSize: 50 }), jsxRuntime.jsx("div", { className: 'button-container', children: jsxRuntime.jsx(CopyButton.CopyButton, { variant: 'button', textToCopy: data.uri, buttonClassName: 'qr-code-button', copykey: 'dyn_qr_code.copy_button', startSlot:
|
|
104
104
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
105
105
|
jsxRuntime.jsx(Icon.Icon, { size: 'mini', color: 'text-tertiary', children: jsxRuntime.jsx(link.ReactComponent, {}) }), children: t('dyn_qr_code.copy_button') }) })] })), jsxRuntime.jsx(TypographyButton.TypographyButton, { className: 'mfa-secure-device-view__button', expanded: true, onClick: onContinue, children: t('dyn_mfa.secure_device_view.continue') })] }));
|
|
106
106
|
};
|
|
@@ -11,8 +11,8 @@ import '../../shared/logger.js';
|
|
|
11
11
|
import '@dynamic-labs/iconic';
|
|
12
12
|
import '@dynamic-labs/wallet-connector-core';
|
|
13
13
|
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
14
|
-
import { ReactComponent as SvgFooterInfoIcon } from '../../shared/assets/footer-info-icon.js';
|
|
15
14
|
import { ReactComponent as SvgLink } from '../../shared/assets/link.js';
|
|
15
|
+
import { ReactComponent as SvgPasswordHero } from '../../shared/assets/password-hero.js';
|
|
16
16
|
import '@dynamic-labs/wallet-book';
|
|
17
17
|
import '../../utils/constants/colors.js';
|
|
18
18
|
import '../../utils/constants/values.js';
|
|
@@ -96,7 +96,7 @@ const MfaSecureDeviceView = ({ type }) => {
|
|
|
96
96
|
onBackClick: onMfaVerificationBackClick,
|
|
97
97
|
});
|
|
98
98
|
};
|
|
99
|
-
return (jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsx(Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsx(Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsx(QRCode, { Icon: jsx(
|
|
99
|
+
return (jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsx(Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsx(Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsx(QRCode, { Icon: jsx(SvgPasswordHero, {}), value: data.uri, logoSize: 50 }), jsx("div", { className: 'button-container', children: jsx(CopyButton, { variant: 'button', textToCopy: data.uri, buttonClassName: 'qr-code-button', copykey: 'dyn_qr_code.copy_button', startSlot:
|
|
100
100
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
101
101
|
jsx(Icon, { size: 'mini', color: 'text-tertiary', children: jsx(SvgLink, {}) }), children: t('dyn_qr_code.copy_button') }) })] })), jsx(TypographyButton, { className: 'mfa-secure-device-view__button', expanded: true, onClick: onContinue, children: t('dyn_mfa.secure_device_view.continue') })] }));
|
|
102
102
|
};
|
|
@@ -32,7 +32,6 @@ var getEOAWallet = require('../../../../utils/functions/getEOAWallet/getEOAWalle
|
|
|
32
32
|
require('../../../../config/ApiEndpoint.cjs');
|
|
33
33
|
require('@dynamic-labs/store');
|
|
34
34
|
require('../../../../locale/locale.cjs');
|
|
35
|
-
var updateJWTAndCreateUserProfile = require('../../../../utils/functions/updateJWTAndCreateUserProfile/updateJWTAndCreateUserProfile.cjs');
|
|
36
35
|
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
37
36
|
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
38
37
|
require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -91,18 +90,20 @@ require('../../../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInS
|
|
|
91
90
|
require('../../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
92
91
|
|
|
93
92
|
const PasskeyCompleteRecovery = () => {
|
|
94
|
-
const { primaryWallet, environmentId, user, setShowAuthFlow,
|
|
93
|
+
const { primaryWallet, environmentId, user, setShowAuthFlow, setPasskeySuccessPopup, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
95
94
|
const { isTurnkeyWalletWithoutAuthenticator } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
96
95
|
const { t } = reactI18next.useTranslation();
|
|
97
96
|
const { mutate: completeRecovery, isLoading, error, } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
98
97
|
const wallet = getEOAWallet.getEOAWallet(primaryWallet, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
99
|
-
const
|
|
98
|
+
const updatedUser = yield passkeyRecovery.completePasskeyRecovery({
|
|
100
99
|
environmentId,
|
|
101
100
|
user,
|
|
102
101
|
wallet,
|
|
103
102
|
});
|
|
103
|
+
if (!updatedUser) {
|
|
104
|
+
throw new utils.DynamicError('Error completing passkey recovery');
|
|
105
|
+
}
|
|
104
106
|
dynamicEvents.dynamicEvents.emit('passkeyRecoveryCompleted', primaryWallet);
|
|
105
|
-
setUser(updateJWTAndCreateUserProfile.updateJWTAndCreateUserProfile(passkeyRecoveryResponse.jwt, passkeyRecoveryResponse.minifiedJwt));
|
|
106
107
|
setShowAuthFlow(false);
|
|
107
108
|
setPasskeySuccessPopup(PasskeyCreatedSuccessBanner.PasskeySuccessEnum.CREATED);
|
|
108
109
|
}), {
|
|
@@ -28,7 +28,6 @@ import { getEOAWallet } from '../../../../utils/functions/getEOAWallet/getEOAWal
|
|
|
28
28
|
import '../../../../config/ApiEndpoint.js';
|
|
29
29
|
import '@dynamic-labs/store';
|
|
30
30
|
import '../../../../locale/locale.js';
|
|
31
|
-
import { updateJWTAndCreateUserProfile } from '../../../../utils/functions/updateJWTAndCreateUserProfile/updateJWTAndCreateUserProfile.js';
|
|
32
31
|
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
33
32
|
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
34
33
|
import '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -87,18 +86,20 @@ import '../../../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSe
|
|
|
87
86
|
import '../../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
88
87
|
|
|
89
88
|
const PasskeyCompleteRecovery = () => {
|
|
90
|
-
const { primaryWallet, environmentId, user, setShowAuthFlow,
|
|
89
|
+
const { primaryWallet, environmentId, user, setShowAuthFlow, setPasskeySuccessPopup, } = useInternalDynamicContext();
|
|
91
90
|
const { isTurnkeyWalletWithoutAuthenticator } = useIsTurnkeyWallet();
|
|
92
91
|
const { t } = useTranslation();
|
|
93
92
|
const { mutate: completeRecovery, isLoading, error, } = useMutation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
93
|
const wallet = getEOAWallet(primaryWallet, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
95
|
-
const
|
|
94
|
+
const updatedUser = yield completePasskeyRecovery({
|
|
96
95
|
environmentId,
|
|
97
96
|
user,
|
|
98
97
|
wallet,
|
|
99
98
|
});
|
|
99
|
+
if (!updatedUser) {
|
|
100
|
+
throw new DynamicError('Error completing passkey recovery');
|
|
101
|
+
}
|
|
100
102
|
dynamicEvents.emit('passkeyRecoveryCompleted', primaryWallet);
|
|
101
|
-
setUser(updateJWTAndCreateUserProfile(passkeyRecoveryResponse.jwt, passkeyRecoveryResponse.minifiedJwt));
|
|
102
103
|
setShowAuthFlow(false);
|
|
103
104
|
setPasskeySuccessPopup(PasskeySuccessEnum.CREATED);
|
|
104
105
|
}), {
|