@dynamic-labs/sdk-react-core 4.25.4 → 4.25.6
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 +22 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.cjs +5 -8
- package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.js +6 -9
- package/src/lib/locale/en/translation.cjs +12 -0
- package/src/lib/locale/en/translation.d.ts +12 -0
- package/src/lib/locale/en/translation.js +12 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.cjs +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.d.ts +1 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.js +2 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +14 -2
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +5 -2
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +15 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +11 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +11 -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/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +80 -60
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.d.ts +1 -5
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +81 -61
- package/src/lib/utils/hooks/useGetMfaToken/index.d.ts +1 -0
- package/src/lib/utils/hooks/useGetMfaToken/useGetMfaToken.cjs +68 -0
- package/src/lib/utils/hooks/useGetMfaToken/useGetMfaToken.d.ts +26 -0
- package/src/lib/utils/hooks/useGetMfaToken/useGetMfaToken.js +64 -0
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +23 -12
- package/src/lib/utils/hooks/useMfa/useMfa.d.ts +3 -2
- package/src/lib/utils/hooks/useMfa/useMfa.js +23 -12
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.cjs +7 -1
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.js +7 -1
- package/src/lib/utils/hooks/usePromptMfaAuth/index.d.ts +1 -0
- package/src/lib/utils/hooks/usePromptMfaAuth/usePromptMfaAuth.cjs +150 -0
- package/src/lib/utils/hooks/usePromptMfaAuth/usePromptMfaAuth.d.ts +5 -0
- package/src/lib/utils/hooks/usePromptMfaAuth/usePromptMfaAuth.js +146 -0
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +3 -0
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +3 -0
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.cjs +5 -13
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.js +5 -13
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -2
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +6 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +6 -1
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +5 -2
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.d.ts +1 -0
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +5 -2
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +18 -3
- package/src/lib/views/MfaVerificationView/MfaVerificationView.d.ts +2 -1
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +18 -3
- package/src/lib/views/Passkey/ConfirmPasskeyView/ConfirmPasskeyView.cjs +15 -3
- package/src/lib/views/Passkey/ConfirmPasskeyView/ConfirmPasskeyView.d.ts +5 -1
- package/src/lib/views/Passkey/ConfirmPasskeyView/ConfirmPasskeyView.js +15 -3
- package/src/lib/views/Passkey/SetupPasskeyView/SetupPasskeyView.cjs +16 -4
- package/src/lib/views/Passkey/SetupPasskeyView/SetupPasskeyView.js +16 -4
- package/src/lib/views/viewToComponentMap.d.ts +4 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.cjs +7 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.js +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.25.6](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.5...v4.25.6) (2025-07-28)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* don't create a new user when linking a wallet to a user with no wallets ([#9252](https://github.com/dynamic-labs/dynamic-auth/issues/9252)) ([30f846e](https://github.com/dynamic-labs/dynamic-auth/commit/30f846e89f2dffd112e656201bfa1cc24b787f03))
|
|
8
|
+
* Nufi EVM wallet showing up twice in wallet list ([#9256](https://github.com/dynamic-labs/dynamic-auth/issues/9256)) ([213488e](https://github.com/dynamic-labs/dynamic-auth/commit/213488e2226ef55965e12a1a548845cb100e859f))
|
|
9
|
+
|
|
10
|
+
### [4.25.5](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.4...v4.25.5) (2025-07-27)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add pending account switch copykey ([#9219](https://github.com/dynamic-labs/dynamic-auth/issues/9219)) ([1d88bf2](https://github.com/dynamic-labs/dynamic-auth/commit/1d88bf27c685f122d94cdf66541365eae7e11a64))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* logout user if last wallet removed in connect-only ([#9234](https://github.com/dynamic-labs/dynamic-auth/issues/9234)) ([42ea1ad](https://github.com/dynamic-labs/dynamic-auth/commit/42ea1ad331cd635a1c17fac0dcbf213fa045586d))
|
|
21
|
+
* prevent waas wallet from being created when embedded wallet option is turned on and then off ([#9237](https://github.com/dynamic-labs/dynamic-auth/issues/9237)) ([004a350](https://github.com/dynamic-labs/dynamic-auth/commit/004a350eb0d88d7ad6d3ceea7eb0d889f7d4a6bf))
|
|
22
|
+
* stop generating session keys on wallet linking ([#9244](https://github.com/dynamic-labs/dynamic-auth/issues/9244)) ([7176be9](https://github.com/dynamic-labs/dynamic-auth/commit/7176be93e31ba55dda264e0365c84376272ee945))
|
|
23
|
+
|
|
2
24
|
### [4.25.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.3...v4.25.4) (2025-07-25)
|
|
3
25
|
|
|
4
26
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.25.
|
|
3
|
+
"version": "4.25.6",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.728",
|
|
6
6
|
"@dynamic-labs-sdk/client": "0.0.1-alpha.19",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"yup": "0.32.11",
|
|
16
16
|
"react-international-phone": "4.5.0",
|
|
17
17
|
"bs58": "5.0.0",
|
|
18
|
-
"@dynamic-labs/assert-package-version": "4.25.
|
|
19
|
-
"@dynamic-labs/iconic": "4.25.
|
|
20
|
-
"@dynamic-labs/logger": "4.25.
|
|
21
|
-
"@dynamic-labs/multi-wallet": "4.25.
|
|
22
|
-
"@dynamic-labs/rpc-providers": "4.25.
|
|
23
|
-
"@dynamic-labs/store": "4.25.
|
|
24
|
-
"@dynamic-labs/types": "4.25.
|
|
25
|
-
"@dynamic-labs/utils": "4.25.
|
|
26
|
-
"@dynamic-labs/wallet-book": "4.25.
|
|
27
|
-
"@dynamic-labs/wallet-connector-core": "4.25.
|
|
18
|
+
"@dynamic-labs/assert-package-version": "4.25.6",
|
|
19
|
+
"@dynamic-labs/iconic": "4.25.6",
|
|
20
|
+
"@dynamic-labs/logger": "4.25.6",
|
|
21
|
+
"@dynamic-labs/multi-wallet": "4.25.6",
|
|
22
|
+
"@dynamic-labs/rpc-providers": "4.25.6",
|
|
23
|
+
"@dynamic-labs/store": "4.25.6",
|
|
24
|
+
"@dynamic-labs/types": "4.25.6",
|
|
25
|
+
"@dynamic-labs/utils": "4.25.6",
|
|
26
|
+
"@dynamic-labs/wallet-book": "4.25.6",
|
|
27
|
+
"@dynamic-labs/wallet-connector-core": "4.25.6",
|
|
28
28
|
"eventemitter3": "5.0.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -37,10 +37,6 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, })
|
|
|
37
37
|
const { removedWalletsIds, userWallets } = UserWalletsContext.useInternalUserWallets();
|
|
38
38
|
const connectedWalletsInfo$1 = connectedWalletsInfo.useConnectedWalletsInfo();
|
|
39
39
|
const nextWalletId = React.useMemo(() => (secondaryWallets[0] ? secondaryWallets[0].id : undefined), [secondaryWallets]);
|
|
40
|
-
const onLastWalletRemoved = React.useCallback((clearStackAndPushInitialView) => {
|
|
41
|
-
primaryWalletId.resetPrimaryWalletId();
|
|
42
|
-
clearStackAndPushInitialView === null || clearStackAndPushInitialView === void 0 ? void 0 : clearStackAndPushInitialView();
|
|
43
|
-
}, []);
|
|
44
40
|
const callback = React.useCallback((walletId, clearStackAndPushInitialView) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
45
41
|
var _a;
|
|
46
42
|
const wallet = userWallets.find((w) => w.id === walletId);
|
|
@@ -76,9 +72,10 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, })
|
|
|
76
72
|
if (isUnlinkingPrimaryWallet && nextWalletId) {
|
|
77
73
|
setPrimaryWallet(nextWalletId);
|
|
78
74
|
}
|
|
79
|
-
// If there are no wallets left and no user, we need to
|
|
80
|
-
if (!nextWalletId) {
|
|
81
|
-
|
|
75
|
+
// If there are no wallets left and no user (connect-only), we need to log out
|
|
76
|
+
if (!user && !nextWalletId) {
|
|
77
|
+
handleLogOut();
|
|
78
|
+
return;
|
|
82
79
|
}
|
|
83
80
|
const numberOfWalletsWithSameConnector = userWallets.filter(({ connector }) => connector.key === wallet.connector.key).length;
|
|
84
81
|
// If there's only 1, it's the one being removed and we can kill the session
|
|
@@ -91,7 +88,7 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, })
|
|
|
91
88
|
nextWalletId,
|
|
92
89
|
removedWalletsIds,
|
|
93
90
|
setPrimaryWallet,
|
|
94
|
-
|
|
91
|
+
handleLogOut,
|
|
95
92
|
]);
|
|
96
93
|
return callback;
|
|
97
94
|
};
|
|
@@ -19,7 +19,7 @@ import '@dynamic-labs/wallet-book';
|
|
|
19
19
|
import '../../../../shared/consts/index.js';
|
|
20
20
|
import '../../../../store/state/nonce/nonce.js';
|
|
21
21
|
import { getEnvironmentId } from '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
22
|
-
import {
|
|
22
|
+
import { getPrimaryWalletId } from '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
23
23
|
import { useConnectedWalletsInfo, setConnectedWalletsInfo } from '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
24
24
|
import '../../../../events/dynamicEvents.js';
|
|
25
25
|
import '../../../../store/state/projectSettings/projectSettings.js';
|
|
@@ -33,10 +33,6 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, })
|
|
|
33
33
|
const { removedWalletsIds, userWallets } = useInternalUserWallets();
|
|
34
34
|
const connectedWalletsInfo = useConnectedWalletsInfo();
|
|
35
35
|
const nextWalletId = useMemo(() => (secondaryWallets[0] ? secondaryWallets[0].id : undefined), [secondaryWallets]);
|
|
36
|
-
const onLastWalletRemoved = useCallback((clearStackAndPushInitialView) => {
|
|
37
|
-
resetPrimaryWalletId();
|
|
38
|
-
clearStackAndPushInitialView === null || clearStackAndPushInitialView === void 0 ? void 0 : clearStackAndPushInitialView();
|
|
39
|
-
}, []);
|
|
40
36
|
const callback = useCallback((walletId, clearStackAndPushInitialView) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
37
|
var _a;
|
|
42
38
|
const wallet = userWallets.find((w) => w.id === walletId);
|
|
@@ -72,9 +68,10 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, })
|
|
|
72
68
|
if (isUnlinkingPrimaryWallet && nextWalletId) {
|
|
73
69
|
setPrimaryWallet(nextWalletId);
|
|
74
70
|
}
|
|
75
|
-
// If there are no wallets left and no user, we need to
|
|
76
|
-
if (!nextWalletId) {
|
|
77
|
-
|
|
71
|
+
// If there are no wallets left and no user (connect-only), we need to log out
|
|
72
|
+
if (!user && !nextWalletId) {
|
|
73
|
+
handleLogOut();
|
|
74
|
+
return;
|
|
78
75
|
}
|
|
79
76
|
const numberOfWalletsWithSameConnector = userWallets.filter(({ connector }) => connector.key === wallet.connector.key).length;
|
|
80
77
|
// If there's only 1, it's the one being removed and we can kill the session
|
|
@@ -87,7 +84,7 @@ const useRemoveWallet = ({ secondaryWallets, handleLogOut, setPrimaryWallet, })
|
|
|
87
84
|
nextWalletId,
|
|
88
85
|
removedWalletsIds,
|
|
89
86
|
setPrimaryWallet,
|
|
90
|
-
|
|
87
|
+
handleLogOut,
|
|
91
88
|
]);
|
|
92
89
|
return callback;
|
|
93
90
|
};
|
|
@@ -2428,6 +2428,18 @@ const translation = {
|
|
|
2428
2428
|
title: 'Transfer this wallet?'
|
|
2429
2429
|
}
|
|
2430
2430
|
*/
|
|
2431
|
+
/**
|
|
2432
|
+
* @description copy keys for pending account switch to link modal
|
|
2433
|
+
* @default
|
|
2434
|
+
* {
|
|
2435
|
+
title: 'Wallet is already linked, switch wallet in {{walletName}}',
|
|
2436
|
+
description: 'To link a new wallet, open {{walletName}} and switch to the account you want to link.',
|
|
2437
|
+
}
|
|
2438
|
+
*/
|
|
2439
|
+
dyn_pending_account_switch_to_link: {
|
|
2440
|
+
title: 'Wallet is already linked, switch wallet in {{walletName}}',
|
|
2441
|
+
description: 'To link a new wallet, open {{walletName}} and switch to the account you want to link.',
|
|
2442
|
+
},
|
|
2431
2443
|
dyn_wallet_link: {
|
|
2432
2444
|
cannot_link: {
|
|
2433
2445
|
cancel_button: 'Cancel',
|
|
@@ -2424,6 +2424,18 @@ export declare const translation: {
|
|
|
2424
2424
|
title: 'Transfer this wallet?'
|
|
2425
2425
|
}
|
|
2426
2426
|
*/
|
|
2427
|
+
/**
|
|
2428
|
+
* @description copy keys for pending account switch to link modal
|
|
2429
|
+
* @default
|
|
2430
|
+
* {
|
|
2431
|
+
title: 'Wallet is already linked, switch wallet in {{walletName}}',
|
|
2432
|
+
description: 'To link a new wallet, open {{walletName}} and switch to the account you want to link.',
|
|
2433
|
+
}
|
|
2434
|
+
*/
|
|
2435
|
+
dyn_pending_account_switch_to_link: {
|
|
2436
|
+
title: string;
|
|
2437
|
+
description: string;
|
|
2438
|
+
};
|
|
2427
2439
|
dyn_wallet_link: {
|
|
2428
2440
|
cannot_link: {
|
|
2429
2441
|
cancel_button: string;
|
|
@@ -2424,6 +2424,18 @@ const translation = {
|
|
|
2424
2424
|
title: 'Transfer this wallet?'
|
|
2425
2425
|
}
|
|
2426
2426
|
*/
|
|
2427
|
+
/**
|
|
2428
|
+
* @description copy keys for pending account switch to link modal
|
|
2429
|
+
* @default
|
|
2430
|
+
* {
|
|
2431
|
+
title: 'Wallet is already linked, switch wallet in {{walletName}}',
|
|
2432
|
+
description: 'To link a new wallet, open {{walletName}} and switch to the account you want to link.',
|
|
2433
|
+
}
|
|
2434
|
+
*/
|
|
2435
|
+
dyn_pending_account_switch_to_link: {
|
|
2436
|
+
title: 'Wallet is already linked, switch wallet in {{walletName}}',
|
|
2437
|
+
description: 'To link a new wallet, open {{walletName}} and switch to the account you want to link.',
|
|
2438
|
+
},
|
|
2427
2439
|
dyn_wallet_link: {
|
|
2428
2440
|
cannot_link: {
|
|
2429
2441
|
cancel_button: 'Cancel',
|
|
@@ -7,8 +7,10 @@ const NO_ENABLED_CHAINS_ERROR = 'No enabled embedded wallet chains. Please go to
|
|
|
7
7
|
const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = 'Dynamic Waas connector not found';
|
|
8
8
|
const INVALID_CHAINS_ERROR = 'The following chains are not enabled for embedded wallets';
|
|
9
9
|
const WALLET_CREATION_FAILED_ERROR = 'Failed to create wallet account for the following chains';
|
|
10
|
+
const EMBEDDED_WALLET_NOT_ENABLED_ERROR = 'Embedded wallet is not enabled, if this is unintended, go to the dashboard and make sure embedded wallet option is enabled.';
|
|
10
11
|
|
|
11
12
|
exports.DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR;
|
|
13
|
+
exports.EMBEDDED_WALLET_NOT_ENABLED_ERROR = EMBEDDED_WALLET_NOT_ENABLED_ERROR;
|
|
12
14
|
exports.INVALID_CHAINS_ERROR = INVALID_CHAINS_ERROR;
|
|
13
15
|
exports.NO_ENABLED_CHAINS_ERROR = NO_ENABLED_CHAINS_ERROR;
|
|
14
16
|
exports.WALLET_CREATION_FAILED_ERROR = WALLET_CREATION_FAILED_ERROR;
|
|
@@ -2,3 +2,4 @@ export declare const NO_ENABLED_CHAINS_ERROR = "No enabled embedded wallet chain
|
|
|
2
2
|
export declare const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = "Dynamic Waas connector not found";
|
|
3
3
|
export declare const INVALID_CHAINS_ERROR = "The following chains are not enabled for embedded wallets";
|
|
4
4
|
export declare const WALLET_CREATION_FAILED_ERROR = "Failed to create wallet account for the following chains";
|
|
5
|
+
export declare const EMBEDDED_WALLET_NOT_ENABLED_ERROR = "Embedded wallet is not enabled, if this is unintended, go to the dashboard and make sure embedded wallet option is enabled.";
|
|
@@ -3,5 +3,6 @@ const NO_ENABLED_CHAINS_ERROR = 'No enabled embedded wallet chains. Please go to
|
|
|
3
3
|
const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = 'Dynamic Waas connector not found';
|
|
4
4
|
const INVALID_CHAINS_ERROR = 'The following chains are not enabled for embedded wallets';
|
|
5
5
|
const WALLET_CREATION_FAILED_ERROR = 'Failed to create wallet account for the following chains';
|
|
6
|
+
const EMBEDDED_WALLET_NOT_ENABLED_ERROR = 'Embedded wallet is not enabled, if this is unintended, go to the dashboard and make sure embedded wallet option is enabled.';
|
|
6
7
|
|
|
7
|
-
export { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, INVALID_CHAINS_ERROR, NO_ENABLED_CHAINS_ERROR, WALLET_CREATION_FAILED_ERROR };
|
|
8
|
+
export { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, EMBEDDED_WALLET_NOT_ENABLED_ERROR, INVALID_CHAINS_ERROR, NO_ENABLED_CHAINS_ERROR, WALLET_CREATION_FAILED_ERROR };
|
|
@@ -24,6 +24,7 @@ require('../../../context/ViewContext/ViewContext.cjs');
|
|
|
24
24
|
require('@dynamic-labs/wallet-book');
|
|
25
25
|
require('../../../shared/consts/index.cjs');
|
|
26
26
|
require('../../../store/state/nonce/nonce.cjs');
|
|
27
|
+
var isTurnkeyEnabled = require('../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
|
|
27
28
|
var isCookieEnabled = require('../../functions/isCookieEnabled/isCookieEnabled.cjs');
|
|
28
29
|
var updatePrimaryWalletId = require('../../functions/updatePrimaryWalletId/updatePrimaryWalletId.cjs');
|
|
29
30
|
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
@@ -107,6 +108,7 @@ require('../../../../index.cjs');
|
|
|
107
108
|
var apiUrl = require('../../constants/waas/apiUrl.cjs');
|
|
108
109
|
var useClientSessionKeys = require('../useClientSessionKeys/useClientSessionKeys.cjs');
|
|
109
110
|
var useRefreshUser = require('../useRefreshUser/useRefreshUser.cjs');
|
|
111
|
+
var useGetMfaToken = require('../useGetMfaToken/useGetMfaToken.cjs');
|
|
110
112
|
var constants = require('./constants.cjs');
|
|
111
113
|
require('../../../store/state/tokenBalances.cjs');
|
|
112
114
|
require('../../../store/state/multichainBalances.cjs');
|
|
@@ -114,13 +116,14 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
114
116
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
115
117
|
|
|
116
118
|
const dynamicWaasKey = 'dynamicwaas';
|
|
117
|
-
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, getSignedSessionId, }) => {
|
|
119
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, getSignedSessionId, getMfaToken, }) => {
|
|
118
120
|
var _a;
|
|
119
121
|
walletConnector.setEnvironmentId(environmentId);
|
|
120
122
|
walletConnector.setBaseApiUrl((_a = (apiBaseUrl || apiUrl.DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
|
|
121
123
|
walletConnector.setGetAuthTokenFunction(() => authToken !== null && authToken !== void 0 ? authToken : '');
|
|
122
124
|
walletConnector.setGetSignedSessionIdFunction(getSignedSessionId);
|
|
123
125
|
walletConnector.setRelayUrl(relayUrl);
|
|
126
|
+
walletConnector.setGetMfaTokenFunction(getMfaToken);
|
|
124
127
|
return walletConnector;
|
|
125
128
|
};
|
|
126
129
|
const useDynamicWaas = () => {
|
|
@@ -136,6 +139,7 @@ const useDynamicWaas = () => {
|
|
|
136
139
|
const relayUrl = (_b = (_a = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk) === null || _a === void 0 ? void 0 : _a.waas) === null || _b === void 0 ? void 0 : _b.relayUrl;
|
|
137
140
|
const embeddedWalletSettings = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk.embeddedWallets;
|
|
138
141
|
const enabledChains = (_c = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _c === void 0 ? void 0 : _c.filter((c) => c.enabled);
|
|
142
|
+
const isEmbeddedWalletEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings$1);
|
|
139
143
|
const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
|
|
140
144
|
const enabledChainNames = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.map((chain) => chain.name);
|
|
141
145
|
const automaticEmbeddedWalletCreationEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreation;
|
|
@@ -144,6 +148,7 @@ const useDynamicWaas = () => {
|
|
|
144
148
|
const dynamicWaasIsEnabled = defaultWalletVersion === sdkApiCore.EmbeddedWalletVersionEnum.V3;
|
|
145
149
|
const authToken = getMinAuthToken.getMinAuthToken();
|
|
146
150
|
const { getSignedSessionId } = useClientSessionKeys.useClientSessionKeys();
|
|
151
|
+
const getMfaToken = useGetMfaToken.useGetMfaToken();
|
|
147
152
|
const isCookieAuthEnabled = projectSettings$1 && isCookieEnabled.isCookieEnabled(projectSettings$1);
|
|
148
153
|
const getWalletConnector = React.useCallback((chainName) => {
|
|
149
154
|
var _a;
|
|
@@ -161,6 +166,7 @@ const useDynamicWaas = () => {
|
|
|
161
166
|
apiBaseUrl: apiBaseUrl || apiUrl.DEFAULT_WAAS_API_URL,
|
|
162
167
|
authToken,
|
|
163
168
|
environmentId,
|
|
169
|
+
getMfaToken,
|
|
164
170
|
getSignedSessionId,
|
|
165
171
|
relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
|
|
166
172
|
walletConnector,
|
|
@@ -178,6 +184,9 @@ const useDynamicWaas = () => {
|
|
|
178
184
|
// If no chain names are provided, filter out chains that already have a wallet
|
|
179
185
|
// and make a wallet for each enabled chain
|
|
180
186
|
const createWalletAccount = React.useCallback((chainNames) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
187
|
+
if (!isEmbeddedWalletEnabled) {
|
|
188
|
+
throw new utils.DynamicError(constants.EMBEDDED_WALLET_NOT_ENABLED_ERROR);
|
|
189
|
+
}
|
|
181
190
|
if (!(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length)) {
|
|
182
191
|
throw new utils.DynamicError(constants.NO_ENABLED_CHAINS_ERROR);
|
|
183
192
|
}
|
|
@@ -265,11 +274,13 @@ const useDynamicWaas = () => {
|
|
|
265
274
|
setShowAuthFlow,
|
|
266
275
|
user === null || user === void 0 ? void 0 : user.verifiedCredentials,
|
|
267
276
|
addedWalletsIds,
|
|
277
|
+
isEmbeddedWalletEnabled,
|
|
268
278
|
]);
|
|
269
279
|
const needsAutoCreateWalletChains = React.useMemo(() => {
|
|
270
280
|
if (!user ||
|
|
271
281
|
!dynamicWaasIsEnabled ||
|
|
272
|
-
!automaticEmbeddedWalletCreationEnabled
|
|
282
|
+
!automaticEmbeddedWalletCreationEnabled ||
|
|
283
|
+
!isEmbeddedWalletEnabled) {
|
|
273
284
|
return [];
|
|
274
285
|
}
|
|
275
286
|
// check if user have any wallet (V1, V2, or V3/dynamicwaas) for this chain
|
|
@@ -294,6 +305,7 @@ const useDynamicWaas = () => {
|
|
|
294
305
|
automaticEmbeddedWalletCreationEnabled,
|
|
295
306
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
296
307
|
enabledChainNames,
|
|
308
|
+
isEmbeddedWalletEnabled,
|
|
297
309
|
]);
|
|
298
310
|
const importPrivateKey = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ chainName, privateKey, }) {
|
|
299
311
|
const walletConnector = getWalletConnector(chainName);
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
1
|
+
import { ChainEnum, MFAAction } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { IDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, getSignedSessionId, }: {
|
|
3
|
+
export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, getSignedSessionId, getMfaToken, }: {
|
|
4
4
|
walletConnector: IDynamicWaasConnector;
|
|
5
5
|
environmentId: string;
|
|
6
6
|
apiBaseUrl: string;
|
|
7
7
|
authToken: string | undefined;
|
|
8
8
|
relayUrl: string;
|
|
9
9
|
getSignedSessionId: () => Promise<string>;
|
|
10
|
+
getMfaToken: (props?: {
|
|
11
|
+
mfaAction?: MFAAction;
|
|
12
|
+
}) => Promise<string | undefined>;
|
|
10
13
|
}) => IDynamicWaasConnector;
|
|
11
14
|
export declare const useDynamicWaas: () => {
|
|
12
15
|
createWalletAccount: (chainNames: ChainEnum[]) => Promise<({
|
|
@@ -20,6 +20,7 @@ import '../../../context/ViewContext/ViewContext.js';
|
|
|
20
20
|
import '@dynamic-labs/wallet-book';
|
|
21
21
|
import '../../../shared/consts/index.js';
|
|
22
22
|
import '../../../store/state/nonce/nonce.js';
|
|
23
|
+
import { isTurnkeyEnabled } from '../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
|
|
23
24
|
import { isCookieEnabled } from '../../functions/isCookieEnabled/isCookieEnabled.js';
|
|
24
25
|
import { updatePrimaryWalletId } from '../../functions/updatePrimaryWalletId/updatePrimaryWalletId.js';
|
|
25
26
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
@@ -103,20 +104,22 @@ import '../../../../index.js';
|
|
|
103
104
|
import { DEFAULT_WAAS_API_URL } from '../../constants/waas/apiUrl.js';
|
|
104
105
|
import { useClientSessionKeys } from '../useClientSessionKeys/useClientSessionKeys.js';
|
|
105
106
|
import { useRefreshUser } from '../useRefreshUser/useRefreshUser.js';
|
|
106
|
-
import {
|
|
107
|
+
import { useGetMfaToken } from '../useGetMfaToken/useGetMfaToken.js';
|
|
108
|
+
import { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, EMBEDDED_WALLET_NOT_ENABLED_ERROR, NO_ENABLED_CHAINS_ERROR, INVALID_CHAINS_ERROR, WALLET_CREATION_FAILED_ERROR } from './constants.js';
|
|
107
109
|
import '../../../store/state/tokenBalances.js';
|
|
108
110
|
import '../../../store/state/multichainBalances.js';
|
|
109
111
|
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
110
112
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
111
113
|
|
|
112
114
|
const dynamicWaasKey = 'dynamicwaas';
|
|
113
|
-
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, getSignedSessionId, }) => {
|
|
115
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, getSignedSessionId, getMfaToken, }) => {
|
|
114
116
|
var _a;
|
|
115
117
|
walletConnector.setEnvironmentId(environmentId);
|
|
116
118
|
walletConnector.setBaseApiUrl((_a = (apiBaseUrl || DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
|
|
117
119
|
walletConnector.setGetAuthTokenFunction(() => authToken !== null && authToken !== void 0 ? authToken : '');
|
|
118
120
|
walletConnector.setGetSignedSessionIdFunction(getSignedSessionId);
|
|
119
121
|
walletConnector.setRelayUrl(relayUrl);
|
|
122
|
+
walletConnector.setGetMfaTokenFunction(getMfaToken);
|
|
120
123
|
return walletConnector;
|
|
121
124
|
};
|
|
122
125
|
const useDynamicWaas = () => {
|
|
@@ -132,6 +135,7 @@ const useDynamicWaas = () => {
|
|
|
132
135
|
const relayUrl = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.waas) === null || _b === void 0 ? void 0 : _b.relayUrl;
|
|
133
136
|
const embeddedWalletSettings = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets;
|
|
134
137
|
const enabledChains = (_c = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _c === void 0 ? void 0 : _c.filter((c) => c.enabled);
|
|
138
|
+
const isEmbeddedWalletEnabled = isTurnkeyEnabled(projectSettings);
|
|
135
139
|
const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
|
|
136
140
|
const enabledChainNames = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.map((chain) => chain.name);
|
|
137
141
|
const automaticEmbeddedWalletCreationEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreation;
|
|
@@ -140,6 +144,7 @@ const useDynamicWaas = () => {
|
|
|
140
144
|
const dynamicWaasIsEnabled = defaultWalletVersion === EmbeddedWalletVersionEnum.V3;
|
|
141
145
|
const authToken = getMinAuthToken();
|
|
142
146
|
const { getSignedSessionId } = useClientSessionKeys();
|
|
147
|
+
const getMfaToken = useGetMfaToken();
|
|
143
148
|
const isCookieAuthEnabled = projectSettings && isCookieEnabled(projectSettings);
|
|
144
149
|
const getWalletConnector = useCallback((chainName) => {
|
|
145
150
|
var _a;
|
|
@@ -157,6 +162,7 @@ const useDynamicWaas = () => {
|
|
|
157
162
|
apiBaseUrl: apiBaseUrl || DEFAULT_WAAS_API_URL,
|
|
158
163
|
authToken,
|
|
159
164
|
environmentId,
|
|
165
|
+
getMfaToken,
|
|
160
166
|
getSignedSessionId,
|
|
161
167
|
relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
|
|
162
168
|
walletConnector,
|
|
@@ -174,6 +180,9 @@ const useDynamicWaas = () => {
|
|
|
174
180
|
// If no chain names are provided, filter out chains that already have a wallet
|
|
175
181
|
// and make a wallet for each enabled chain
|
|
176
182
|
const createWalletAccount = useCallback((chainNames) => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
|
+
if (!isEmbeddedWalletEnabled) {
|
|
184
|
+
throw new DynamicError(EMBEDDED_WALLET_NOT_ENABLED_ERROR);
|
|
185
|
+
}
|
|
177
186
|
if (!(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length)) {
|
|
178
187
|
throw new DynamicError(NO_ENABLED_CHAINS_ERROR);
|
|
179
188
|
}
|
|
@@ -261,11 +270,13 @@ const useDynamicWaas = () => {
|
|
|
261
270
|
setShowAuthFlow,
|
|
262
271
|
user === null || user === void 0 ? void 0 : user.verifiedCredentials,
|
|
263
272
|
addedWalletsIds,
|
|
273
|
+
isEmbeddedWalletEnabled,
|
|
264
274
|
]);
|
|
265
275
|
const needsAutoCreateWalletChains = useMemo(() => {
|
|
266
276
|
if (!user ||
|
|
267
277
|
!dynamicWaasIsEnabled ||
|
|
268
|
-
!automaticEmbeddedWalletCreationEnabled
|
|
278
|
+
!automaticEmbeddedWalletCreationEnabled ||
|
|
279
|
+
!isEmbeddedWalletEnabled) {
|
|
269
280
|
return [];
|
|
270
281
|
}
|
|
271
282
|
// check if user have any wallet (V1, V2, or V3/dynamicwaas) for this chain
|
|
@@ -290,6 +301,7 @@ const useDynamicWaas = () => {
|
|
|
290
301
|
automaticEmbeddedWalletCreationEnabled,
|
|
291
302
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
292
303
|
enabledChainNames,
|
|
304
|
+
isEmbeddedWalletEnabled,
|
|
293
305
|
]);
|
|
294
306
|
const importPrivateKey = (_d) => __awaiter(void 0, [_d], void 0, function* ({ chainName, privateKey, }) {
|
|
295
307
|
const walletConnector = getWalletConnector(chainName);
|
|
@@ -47,8 +47,8 @@ require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs')
|
|
|
47
47
|
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
48
48
|
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
49
49
|
var UserWalletsContext = require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
50
|
-
var errors = require('../../../constants/errors.cjs');
|
|
51
50
|
require('../../../../store/state/authMode/authMode.cjs');
|
|
51
|
+
var errors = require('../../../constants/errors.cjs');
|
|
52
52
|
require('../../../../context/VerificationContext/VerificationContext.cjs');
|
|
53
53
|
require('react-dom');
|
|
54
54
|
var useElementById = require('../../useElementById/useElementById.cjs');
|
|
@@ -67,8 +67,8 @@ var WalletContext = require('../../../../context/WalletContext/WalletContext.cjs
|
|
|
67
67
|
var useIsTurnkeyWallet = require('../../useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
68
68
|
var turnkeyExport = require('../../../../views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs');
|
|
69
69
|
var passkeyRecovery = require('../../../../views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs');
|
|
70
|
-
var validateTurnkeyProviderEnabled = require('../../../validations/validateTurnkeyProviderEnabled/validateTurnkeyProviderEnabled.cjs');
|
|
71
70
|
var getNewVerifiedCredentialsFromDiff = require('../../../functions/getNewVerifiedCredentialsFromDiff/getNewVerifiedCredentialsFromDiff.cjs');
|
|
71
|
+
var validateTurnkeyProviderEnabled = require('../../../validations/validateTurnkeyProviderEnabled/validateTurnkeyProviderEnabled.cjs');
|
|
72
72
|
var constants = require('./constants.cjs');
|
|
73
73
|
var useTurnkey = require('./useTurnkey/useTurnkey.cjs');
|
|
74
74
|
require('yup');
|
|
@@ -436,13 +436,18 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
436
436
|
wallet: wallet,
|
|
437
437
|
});
|
|
438
438
|
}
|
|
439
|
-
catch (
|
|
439
|
+
catch (err) {
|
|
440
440
|
if (walletConnectorCore.isSessionKeyCompatibleWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector) &&
|
|
441
441
|
((_y = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _y === void 0 ? void 0 : _y.removeSessionKeys)) {
|
|
442
442
|
yield ((_z = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _z === void 0 ? void 0 : _z.removeSessionKeys());
|
|
443
443
|
yield ((_0 = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _0 === void 0 ? void 0 : _0.createOrRestoreSession({
|
|
444
444
|
ignoreRestore: true,
|
|
445
445
|
}));
|
|
446
|
+
logger.logger.error('[TK - removeSessionKeys] failed to perform revealEmbeddedWalletKey activity', {
|
|
447
|
+
address: wallet === null || wallet === void 0 ? void 0 : wallet.address,
|
|
448
|
+
err,
|
|
449
|
+
userId: user$1 === null || user$1 === void 0 ? void 0 : user$1.userId,
|
|
450
|
+
});
|
|
446
451
|
}
|
|
447
452
|
yield turnkeyExport.exportCredential({
|
|
448
453
|
address: type === 'privateKey' ? wallet === null || wallet === void 0 ? void 0 : wallet.address : undefined,
|
|
@@ -468,11 +473,11 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
468
473
|
* @returns Promise<'code_sent'>
|
|
469
474
|
*/
|
|
470
475
|
const sendOneTimeCode = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
471
|
-
var
|
|
476
|
+
var _1, _2;
|
|
472
477
|
if (!user$1) {
|
|
473
478
|
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
474
479
|
}
|
|
475
|
-
const targetTurnkeyWallet = findTurnkeyWallet.findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (
|
|
480
|
+
const targetTurnkeyWallet = findTurnkeyWallet.findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (_1 = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _1 === void 0 ? void 0 : _1.chainConfigurations, user$1.verifiedCredentials);
|
|
476
481
|
if (!targetTurnkeyWallet || !('id' in targetTurnkeyWallet)) {
|
|
477
482
|
throw new utils.DynamicError('User does not have a valid secure enclave wallet', errors.INVALID_WALLET_DATA);
|
|
478
483
|
}
|
|
@@ -483,7 +488,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
483
488
|
throw new utils.DynamicError('Session is active. No need to create a new one', errors.ACTIVE_SESSION);
|
|
484
489
|
}
|
|
485
490
|
const turnkeyAuthIframeContainerRef = createRootElement(constants.iframeContainerId);
|
|
486
|
-
const publicKey = yield turnkeyAuthenticatorHandler.initRecovery('email', turnkeyAuthIframeContainerRef.current, constants.iframeElementId, getEmbeddedWalletSessionExpiration.getEmbeddedWalletSessionExpiration((
|
|
491
|
+
const publicKey = yield turnkeyAuthenticatorHandler.initRecovery('email', turnkeyAuthIframeContainerRef.current, constants.iframeElementId, getEmbeddedWalletSessionExpiration.getEmbeddedWalletSessionExpiration((_2 = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _2 === void 0 ? void 0 : _2.sessionKeyDuration));
|
|
487
492
|
if (!publicKey) {
|
|
488
493
|
throw new utils.DynamicError(errors.ERROR_SENDING_CODE);
|
|
489
494
|
}
|
|
@@ -43,8 +43,8 @@ import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
|
43
43
|
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
44
44
|
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
45
45
|
import { useInternalUserWallets } from '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
46
|
-
import { USER_NOT_LOGGED_IN, ACTIVE_SESSION, SESSION_RESTORED, INVALID_REQUEST, INVALID_WALLET_DATA, SESSION_CREATED, ERROR_SENDING_CODE, CODE_SENT } from '../../../constants/errors.js';
|
|
47
46
|
import '../../../../store/state/authMode/authMode.js';
|
|
47
|
+
import { USER_NOT_LOGGED_IN, ACTIVE_SESSION, SESSION_RESTORED, INVALID_REQUEST, INVALID_WALLET_DATA, SESSION_CREATED, ERROR_SENDING_CODE, CODE_SENT } from '../../../constants/errors.js';
|
|
48
48
|
import '../../../../context/VerificationContext/VerificationContext.js';
|
|
49
49
|
import 'react-dom';
|
|
50
50
|
import { useElementById } from '../../useElementById/useElementById.js';
|
|
@@ -63,8 +63,8 @@ import { useWalletContext } from '../../../../context/WalletContext/WalletContex
|
|
|
63
63
|
import { useIsTurnkeyWallet } from '../../useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
64
64
|
import { cleanupExport, initExport, exportCredential } from '../../../../views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js';
|
|
65
65
|
import { canRestoreEmbeddedWalletSession, restoreEmbeddedWalletSession } from '../../../../views/Passkey/utils/passkeyRecovery/passkeyRecovery.js';
|
|
66
|
-
import { validateTurnkeyProviderEnabled } from '../../../validations/validateTurnkeyProviderEnabled/validateTurnkeyProviderEnabled.js';
|
|
67
66
|
import { getNewVerifiedCredentialsFromDiff } from '../../../functions/getNewVerifiedCredentialsFromDiff/getNewVerifiedCredentialsFromDiff.js';
|
|
67
|
+
import { validateTurnkeyProviderEnabled } from '../../../validations/validateTurnkeyProviderEnabled/validateTurnkeyProviderEnabled.js';
|
|
68
68
|
import { EmbeddedWalletVersion, iframeContainerId, iframeElementId, revealIframeElementId, revealIframeContainerId } from './constants.js';
|
|
69
69
|
import { useTurnkey } from './useTurnkey/useTurnkey.js';
|
|
70
70
|
import 'yup';
|
|
@@ -432,13 +432,18 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
432
432
|
wallet: wallet,
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
|
-
catch (
|
|
435
|
+
catch (err) {
|
|
436
436
|
if (isSessionKeyCompatibleWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector) &&
|
|
437
437
|
((_y = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _y === void 0 ? void 0 : _y.removeSessionKeys)) {
|
|
438
438
|
yield ((_z = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _z === void 0 ? void 0 : _z.removeSessionKeys());
|
|
439
439
|
yield ((_0 = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _0 === void 0 ? void 0 : _0.createOrRestoreSession({
|
|
440
440
|
ignoreRestore: true,
|
|
441
441
|
}));
|
|
442
|
+
logger.error('[TK - removeSessionKeys] failed to perform revealEmbeddedWalletKey activity', {
|
|
443
|
+
address: wallet === null || wallet === void 0 ? void 0 : wallet.address,
|
|
444
|
+
err,
|
|
445
|
+
userId: user === null || user === void 0 ? void 0 : user.userId,
|
|
446
|
+
});
|
|
442
447
|
}
|
|
443
448
|
yield exportCredential({
|
|
444
449
|
address: type === 'privateKey' ? wallet === null || wallet === void 0 ? void 0 : wallet.address : undefined,
|
|
@@ -464,11 +469,11 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
464
469
|
* @returns Promise<'code_sent'>
|
|
465
470
|
*/
|
|
466
471
|
const sendOneTimeCode = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
467
|
-
var
|
|
472
|
+
var _1, _2;
|
|
468
473
|
if (!user) {
|
|
469
474
|
throw new DynamicError(USER_NOT_LOGGED_IN);
|
|
470
475
|
}
|
|
471
|
-
const targetTurnkeyWallet = findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (
|
|
476
|
+
const targetTurnkeyWallet = findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (_1 = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _1 === void 0 ? void 0 : _1.chainConfigurations, user.verifiedCredentials);
|
|
472
477
|
if (!targetTurnkeyWallet || !('id' in targetTurnkeyWallet)) {
|
|
473
478
|
throw new DynamicError('User does not have a valid secure enclave wallet', INVALID_WALLET_DATA);
|
|
474
479
|
}
|
|
@@ -479,7 +484,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
479
484
|
throw new DynamicError('Session is active. No need to create a new one', ACTIVE_SESSION);
|
|
480
485
|
}
|
|
481
486
|
const turnkeyAuthIframeContainerRef = createRootElement(iframeContainerId);
|
|
482
|
-
const publicKey = yield turnkeyAuthenticatorHandler.initRecovery('email', turnkeyAuthIframeContainerRef.current, iframeElementId, getEmbeddedWalletSessionExpiration((
|
|
487
|
+
const publicKey = yield turnkeyAuthenticatorHandler.initRecovery('email', turnkeyAuthIframeContainerRef.current, iframeElementId, getEmbeddedWalletSessionExpiration((_2 = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _2 === void 0 ? void 0 : _2.sessionKeyDuration));
|
|
483
488
|
if (!publicKey) {
|
|
484
489
|
throw new DynamicError(ERROR_SENDING_CODE);
|
|
485
490
|
}
|
|
@@ -41,8 +41,8 @@ require('../../../../../client/client.cjs');
|
|
|
41
41
|
require('../../../../../store/state/projectSettings/projectSettings.cjs');
|
|
42
42
|
require('../../../../../config/ApiEndpoint.cjs');
|
|
43
43
|
require('../../../../../locale/locale.cjs');
|
|
44
|
-
var errors = require('../../../../constants/errors.cjs');
|
|
45
44
|
require('../../../../../store/state/authMode/authMode.cjs');
|
|
45
|
+
var errors = require('../../../../constants/errors.cjs');
|
|
46
46
|
require('../../../../../context/VerificationContext/VerificationContext.cjs');
|
|
47
47
|
require('react-dom');
|
|
48
48
|
var useCreateDynamicEmbeddedWalletMutation = require('../../../useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs');
|
|
@@ -37,8 +37,8 @@ import '../../../../../client/client.js';
|
|
|
37
37
|
import '../../../../../store/state/projectSettings/projectSettings.js';
|
|
38
38
|
import '../../../../../config/ApiEndpoint.js';
|
|
39
39
|
import '../../../../../locale/locale.js';
|
|
40
|
-
import { USER_NOT_LOGGED_IN } from '../../../../constants/errors.js';
|
|
41
40
|
import '../../../../../store/state/authMode/authMode.js';
|
|
41
|
+
import { USER_NOT_LOGGED_IN } from '../../../../constants/errors.js';
|
|
42
42
|
import '../../../../../context/VerificationContext/VerificationContext.js';
|
|
43
43
|
import 'react-dom';
|
|
44
44
|
import { useCreateDynamicEmbeddedWalletMutation } from '../../../useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js';
|