@dynamic-labs/sdk-react-core 4.25.4 → 4.25.5
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 +14 -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 +9 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +10 -2
- 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.d.ts +26 -0
- package/src/lib/utils/hooks/usePromptMfaAuth/index.d.ts +1 -0
- package/src/lib/utils/hooks/usePromptMfaAuth/usePromptMfaAuth.cjs +144 -0
- package/src/lib/utils/hooks/usePromptMfaAuth/usePromptMfaAuth.d.ts +1 -0
- package/src/lib/utils/hooks/usePromptMfaAuth/usePromptMfaAuth.js +140 -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 +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +6 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +6 -1
- package/src/lib/views/Passkey/SetupPasskeyView/SetupPasskeyView.cjs +16 -4
- package/src/lib/views/Passkey/SetupPasskeyView/SetupPasskeyView.js +16 -4
- 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,18 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.25.5](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.4...v4.25.5) (2025-07-27)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* 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))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* 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))
|
|
13
|
+
* 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))
|
|
14
|
+
* 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))
|
|
15
|
+
|
|
2
16
|
### [4.25.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.3...v4.25.4) (2025-07-25)
|
|
3
17
|
|
|
4
18
|
|
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.5",
|
|
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.5",
|
|
19
|
+
"@dynamic-labs/iconic": "4.25.5",
|
|
20
|
+
"@dynamic-labs/logger": "4.25.5",
|
|
21
|
+
"@dynamic-labs/multi-wallet": "4.25.5",
|
|
22
|
+
"@dynamic-labs/rpc-providers": "4.25.5",
|
|
23
|
+
"@dynamic-labs/store": "4.25.5",
|
|
24
|
+
"@dynamic-labs/types": "4.25.5",
|
|
25
|
+
"@dynamic-labs/utils": "4.25.5",
|
|
26
|
+
"@dynamic-labs/wallet-book": "4.25.5",
|
|
27
|
+
"@dynamic-labs/wallet-connector-core": "4.25.5",
|
|
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');
|
|
@@ -136,6 +137,7 @@ const useDynamicWaas = () => {
|
|
|
136
137
|
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
138
|
const embeddedWalletSettings = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk.embeddedWallets;
|
|
138
139
|
const enabledChains = (_c = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _c === void 0 ? void 0 : _c.filter((c) => c.enabled);
|
|
140
|
+
const isEmbeddedWalletEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings$1);
|
|
139
141
|
const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
|
|
140
142
|
const enabledChainNames = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.map((chain) => chain.name);
|
|
141
143
|
const automaticEmbeddedWalletCreationEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreation;
|
|
@@ -178,6 +180,9 @@ const useDynamicWaas = () => {
|
|
|
178
180
|
// If no chain names are provided, filter out chains that already have a wallet
|
|
179
181
|
// and make a wallet for each enabled chain
|
|
180
182
|
const createWalletAccount = React.useCallback((chainNames) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
183
|
+
if (!isEmbeddedWalletEnabled) {
|
|
184
|
+
throw new utils.DynamicError(constants.EMBEDDED_WALLET_NOT_ENABLED_ERROR);
|
|
185
|
+
}
|
|
181
186
|
if (!(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length)) {
|
|
182
187
|
throw new utils.DynamicError(constants.NO_ENABLED_CHAINS_ERROR);
|
|
183
188
|
}
|
|
@@ -265,11 +270,13 @@ const useDynamicWaas = () => {
|
|
|
265
270
|
setShowAuthFlow,
|
|
266
271
|
user === null || user === void 0 ? void 0 : user.verifiedCredentials,
|
|
267
272
|
addedWalletsIds,
|
|
273
|
+
isEmbeddedWalletEnabled,
|
|
268
274
|
]);
|
|
269
275
|
const needsAutoCreateWalletChains = React.useMemo(() => {
|
|
270
276
|
if (!user ||
|
|
271
277
|
!dynamicWaasIsEnabled ||
|
|
272
|
-
!automaticEmbeddedWalletCreationEnabled
|
|
278
|
+
!automaticEmbeddedWalletCreationEnabled ||
|
|
279
|
+
!isEmbeddedWalletEnabled) {
|
|
273
280
|
return [];
|
|
274
281
|
}
|
|
275
282
|
// check if user have any wallet (V1, V2, or V3/dynamicwaas) for this chain
|
|
@@ -294,6 +301,7 @@ const useDynamicWaas = () => {
|
|
|
294
301
|
automaticEmbeddedWalletCreationEnabled,
|
|
295
302
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
296
303
|
enabledChainNames,
|
|
304
|
+
isEmbeddedWalletEnabled,
|
|
297
305
|
]);
|
|
298
306
|
const importPrivateKey = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ chainName, privateKey, }) {
|
|
299
307
|
const walletConnector = getWalletConnector(chainName);
|
|
@@ -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,7 +104,7 @@ 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 { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, NO_ENABLED_CHAINS_ERROR, INVALID_CHAINS_ERROR, WALLET_CREATION_FAILED_ERROR } from './constants.js';
|
|
107
|
+
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
108
|
import '../../../store/state/tokenBalances.js';
|
|
108
109
|
import '../../../store/state/multichainBalances.js';
|
|
109
110
|
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
@@ -132,6 +133,7 @@ const useDynamicWaas = () => {
|
|
|
132
133
|
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
134
|
const embeddedWalletSettings = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets;
|
|
134
135
|
const enabledChains = (_c = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _c === void 0 ? void 0 : _c.filter((c) => c.enabled);
|
|
136
|
+
const isEmbeddedWalletEnabled = isTurnkeyEnabled(projectSettings);
|
|
135
137
|
const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
|
|
136
138
|
const enabledChainNames = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.map((chain) => chain.name);
|
|
137
139
|
const automaticEmbeddedWalletCreationEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreation;
|
|
@@ -174,6 +176,9 @@ const useDynamicWaas = () => {
|
|
|
174
176
|
// If no chain names are provided, filter out chains that already have a wallet
|
|
175
177
|
// and make a wallet for each enabled chain
|
|
176
178
|
const createWalletAccount = useCallback((chainNames) => __awaiter(void 0, void 0, void 0, function* () {
|
|
179
|
+
if (!isEmbeddedWalletEnabled) {
|
|
180
|
+
throw new DynamicError(EMBEDDED_WALLET_NOT_ENABLED_ERROR);
|
|
181
|
+
}
|
|
177
182
|
if (!(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length)) {
|
|
178
183
|
throw new DynamicError(NO_ENABLED_CHAINS_ERROR);
|
|
179
184
|
}
|
|
@@ -261,11 +266,13 @@ const useDynamicWaas = () => {
|
|
|
261
266
|
setShowAuthFlow,
|
|
262
267
|
user === null || user === void 0 ? void 0 : user.verifiedCredentials,
|
|
263
268
|
addedWalletsIds,
|
|
269
|
+
isEmbeddedWalletEnabled,
|
|
264
270
|
]);
|
|
265
271
|
const needsAutoCreateWalletChains = useMemo(() => {
|
|
266
272
|
if (!user ||
|
|
267
273
|
!dynamicWaasIsEnabled ||
|
|
268
|
-
!automaticEmbeddedWalletCreationEnabled
|
|
274
|
+
!automaticEmbeddedWalletCreationEnabled ||
|
|
275
|
+
!isEmbeddedWalletEnabled) {
|
|
269
276
|
return [];
|
|
270
277
|
}
|
|
271
278
|
// check if user have any wallet (V1, V2, or V3/dynamicwaas) for this chain
|
|
@@ -290,6 +297,7 @@ const useDynamicWaas = () => {
|
|
|
290
297
|
automaticEmbeddedWalletCreationEnabled,
|
|
291
298
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
292
299
|
enabledChainNames,
|
|
300
|
+
isEmbeddedWalletEnabled,
|
|
293
301
|
]);
|
|
294
302
|
const importPrivateKey = (_d) => __awaiter(void 0, [_d], void 0, function* ({ chainName, privateKey, }) {
|
|
295
303
|
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';
|