@dynamic-labs/sdk-react-core 1.1.0-alpha.6 → 1.1.0-alpha.8
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 +29 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -11
- package/src/index.cjs +2 -0
- package/src/index.js +1 -0
- package/src/lib/components/ChainCard/ChainCard.d.ts +2 -2
- package/src/lib/components/SelectWalletChainLayout/SelectWalletChainLayout.cjs +5 -1
- package/src/lib/components/SelectWalletChainLayout/SelectWalletChainLayout.js +5 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +18 -3
- package/src/lib/context/DynamicContext/DynamicContext.js +18 -3
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.cjs +29 -7
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.d.ts +4 -4
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.js +29 -7
- package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModalWithInit/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModalWithInit/useSetShowLinkNewWalletModalWithInit.cjs +54 -0
- package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModalWithInit/useSetShowLinkNewWalletModalWithInit.d.ts +18 -0
- package/src/lib/context/DynamicContext/hooks/useSetShowLinkNewWalletModalWithInit/useSetShowLinkNewWalletModalWithInit.js +50 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/useDynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext.js +2 -1
- package/src/lib/context/FundingContext/FundingContext.cjs +4 -1
- package/src/lib/context/FundingContext/FundingContext.js +4 -1
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/locale/en/translation.cjs +20 -2
- package/src/lib/locale/en/translation.d.ts +19 -1
- package/src/lib/locale/en/translation.js +20 -2
- package/src/lib/shared/assets/alt-key.cjs +54 -0
- package/src/lib/shared/assets/alt-key.js +30 -0
- package/src/lib/shared/assets/index.d.ts +1 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/walletListBuilder/utils/filterConnectedWallets/filterConnectedWallets.cjs +13 -2
- package/src/lib/utils/functions/walletListBuilder/utils/filterConnectedWallets/filterConnectedWallets.js +13 -2
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +3 -2
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +6 -1
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +3 -2
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -1
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +18 -11
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.d.ts +1 -1
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +18 -11
- package/src/lib/utils/hooks/useWalletConnectorNetwork/index.d.ts +1 -0
- package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.cjs +42 -0
- package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.d.ts +18 -0
- package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.js +38 -0
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +19 -17
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +19 -17
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +55 -30
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.d.ts +7 -1
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +55 -31
- package/src/lib/views/LoginView/LoginView.cjs +60 -7
- package/src/lib/views/LoginView/LoginView.js +60 -7
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +3 -4
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +3 -4
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +3 -6
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +3 -6
- package/src/lib/views/WalletGroupView/WalletGroupView.cjs +70 -1
- package/src/lib/views/WalletGroupView/WalletGroupView.js +71 -2
- package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/HardwareWalletToggle.cjs +72 -0
- package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/HardwareWalletToggle.d.ts +7 -0
- package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/HardwareWalletToggle.js +68 -0
- package/src/lib/views/WalletGroupView/components/HardwareWalletToggle/index.d.ts +1 -0
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.cjs +2 -4
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.d.ts +2 -1
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.js +2 -4
- package/src/lib/views/viewToComponentMap.cjs +1 -0
- package/src/lib/views/viewToComponentMap.js +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/ActiveBitcoinWalletAddresses.cjs +76 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/ActiveBitcoinWalletAddresses.d.ts +9 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/ActiveBitcoinWalletAddresses.js +72 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveBitcoinWalletAddresses/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.cjs +67 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.d.ts +9 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.js +63 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +7 -5
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +7 -5
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.cjs +8 -6
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.js +8 -6
- package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.js +2 -2
|
@@ -6,11 +6,11 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
8
8
|
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
9
|
-
require('
|
|
10
|
-
require('../../../shared/logger.cjs');
|
|
9
|
+
var decodeJwt = require('../../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
11
10
|
require('@dynamic-labs/iconic');
|
|
12
11
|
require('@dynamic-labs/wallet-connector-core');
|
|
13
12
|
require('react/jsx-runtime');
|
|
13
|
+
require('../../../shared/logger.cjs');
|
|
14
14
|
require('@dynamic-labs/wallet-book');
|
|
15
15
|
require('../../constants/colors.cjs');
|
|
16
16
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
@@ -19,6 +19,7 @@ require('@dynamic-labs/utils');
|
|
|
19
19
|
require('../../../shared/consts/index.cjs');
|
|
20
20
|
require('@dynamic-labs/multi-wallet');
|
|
21
21
|
var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
|
|
22
|
+
require('@dynamic-labs/sdk-api');
|
|
22
23
|
var isTurnkeyEnabled = require('../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
|
|
23
24
|
var useEmbeddedWallet = require('../useEmbeddedWallet/useEmbeddedWallet.cjs');
|
|
24
25
|
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
@@ -28,7 +29,8 @@ const useEmbeddedReveal = () => {
|
|
|
28
29
|
const { projectSettings, internalSetShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
29
30
|
const { userHasEmbeddedWallet } = useEmbeddedWallet.useEmbeddedWallet();
|
|
30
31
|
const { setView } = ViewContext.useViewContext();
|
|
31
|
-
const initExportProcess = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
const initExportProcess = React.useCallback((recoveryPhrase = false) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
var _a, _b;
|
|
32
34
|
const jwt = getAuthToken.getAuthToken();
|
|
33
35
|
if (!jwt) {
|
|
34
36
|
throw new Error('User is not logged in');
|
|
@@ -39,19 +41,24 @@ const useEmbeddedReveal = () => {
|
|
|
39
41
|
if (!userHasEmbeddedWallet()) {
|
|
40
42
|
throw new Error('Passkey embedded wallet not found');
|
|
41
43
|
}
|
|
44
|
+
const decodedJwt = decodeJwt.decodeJwt(jwt);
|
|
45
|
+
const walletProperties = (_b = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
46
|
+
const turnkeyHDWalletId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
47
|
+
if (recoveryPhrase && !turnkeyHDWalletId) {
|
|
48
|
+
throw new Error('Wallet is non-HD and does not have a recovery phrase');
|
|
49
|
+
}
|
|
42
50
|
internalSetShowAuthFlow(true);
|
|
43
|
-
|
|
51
|
+
if (recoveryPhrase) {
|
|
52
|
+
setView('embedded-reveal-view');
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
setView('embedded-reveal-account-view');
|
|
56
|
+
}
|
|
44
57
|
return new Promise((resolve, reject) => {
|
|
45
58
|
dynamicEvents.dynamicEvents.once('embeddedWalletRevealCompleted', (wallet) => resolve(wallet));
|
|
46
59
|
dynamicEvents.dynamicEvents.once('embeddedWalletRevealFailed', (error) => reject(error));
|
|
47
60
|
});
|
|
48
|
-
}), [
|
|
49
|
-
dynamicEvents.dynamicEvents,
|
|
50
|
-
internalSetShowAuthFlow,
|
|
51
|
-
projectSettings,
|
|
52
|
-
setView,
|
|
53
|
-
userHasEmbeddedWallet,
|
|
54
|
-
]);
|
|
61
|
+
}), [internalSetShowAuthFlow, projectSettings, setView, userHasEmbeddedWallet]);
|
|
55
62
|
return {
|
|
56
63
|
initExportProcess,
|
|
57
64
|
};
|
|
@@ -2,11 +2,11 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
4
4
|
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
5
|
-
import '
|
|
6
|
-
import '../../../shared/logger.js';
|
|
5
|
+
import { decodeJwt } from '../../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
7
6
|
import '@dynamic-labs/iconic';
|
|
8
7
|
import '@dynamic-labs/wallet-connector-core';
|
|
9
8
|
import 'react/jsx-runtime';
|
|
9
|
+
import '../../../shared/logger.js';
|
|
10
10
|
import '@dynamic-labs/wallet-book';
|
|
11
11
|
import '../../constants/colors.js';
|
|
12
12
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
@@ -15,6 +15,7 @@ import '@dynamic-labs/utils';
|
|
|
15
15
|
import '../../../shared/consts/index.js';
|
|
16
16
|
import '@dynamic-labs/multi-wallet';
|
|
17
17
|
import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
|
|
18
|
+
import '@dynamic-labs/sdk-api';
|
|
18
19
|
import { isTurnkeyEnabled } from '../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
|
|
19
20
|
import { useEmbeddedWallet } from '../useEmbeddedWallet/useEmbeddedWallet.js';
|
|
20
21
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
@@ -24,7 +25,8 @@ const useEmbeddedReveal = () => {
|
|
|
24
25
|
const { projectSettings, internalSetShowAuthFlow } = useInternalDynamicContext();
|
|
25
26
|
const { userHasEmbeddedWallet } = useEmbeddedWallet();
|
|
26
27
|
const { setView } = useViewContext();
|
|
27
|
-
const initExportProcess = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
const initExportProcess = useCallback((recoveryPhrase = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
var _a, _b;
|
|
28
30
|
const jwt = getAuthToken();
|
|
29
31
|
if (!jwt) {
|
|
30
32
|
throw new Error('User is not logged in');
|
|
@@ -35,19 +37,24 @@ const useEmbeddedReveal = () => {
|
|
|
35
37
|
if (!userHasEmbeddedWallet()) {
|
|
36
38
|
throw new Error('Passkey embedded wallet not found');
|
|
37
39
|
}
|
|
40
|
+
const decodedJwt = decodeJwt(jwt);
|
|
41
|
+
const walletProperties = (_b = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
42
|
+
const turnkeyHDWalletId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
43
|
+
if (recoveryPhrase && !turnkeyHDWalletId) {
|
|
44
|
+
throw new Error('Wallet is non-HD and does not have a recovery phrase');
|
|
45
|
+
}
|
|
38
46
|
internalSetShowAuthFlow(true);
|
|
39
|
-
|
|
47
|
+
if (recoveryPhrase) {
|
|
48
|
+
setView('embedded-reveal-view');
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
setView('embedded-reveal-account-view');
|
|
52
|
+
}
|
|
40
53
|
return new Promise((resolve, reject) => {
|
|
41
54
|
dynamicEvents.once('embeddedWalletRevealCompleted', (wallet) => resolve(wallet));
|
|
42
55
|
dynamicEvents.once('embeddedWalletRevealFailed', (error) => reject(error));
|
|
43
56
|
});
|
|
44
|
-
}), [
|
|
45
|
-
dynamicEvents,
|
|
46
|
-
internalSetShowAuthFlow,
|
|
47
|
-
projectSettings,
|
|
48
|
-
setView,
|
|
49
|
-
userHasEmbeddedWallet,
|
|
50
|
-
]);
|
|
57
|
+
}), [internalSetShowAuthFlow, projectSettings, setView, userHasEmbeddedWallet]);
|
|
51
58
|
return {
|
|
52
59
|
initExportProcess,
|
|
53
60
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useWalletConnectorNetwork } from './useWalletConnectorNetwork';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var usePromise = require('../usePromise/usePromise.cjs');
|
|
7
|
+
require('../../../events/dynamicEvents.cjs');
|
|
8
|
+
var useWalletConnectorEvent = require('../events/useWalletConnectorEvent/useWalletConnectorEvent.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Sync wallet connector network.
|
|
12
|
+
*
|
|
13
|
+
* @param walletConnector - The WalletConnector instance to be used.
|
|
14
|
+
*
|
|
15
|
+
* @returns {{ network: string | number | undefined }} An object containing the current network state.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Example of using the useWalletConnectorNetwork hook
|
|
19
|
+
* const { network } = useWalletConnectorNetwork(walletConnector);
|
|
20
|
+
*
|
|
21
|
+
* // You can then use the 'network' state in your component
|
|
22
|
+
* return <div>Current Network: {network}</div>;
|
|
23
|
+
*/
|
|
24
|
+
const useWalletConnectorNetwork = (walletConnector) => {
|
|
25
|
+
const [network, setNetwork] = React.useState();
|
|
26
|
+
usePromise.usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), {
|
|
27
|
+
onResolve: (network) => setNetwork(network),
|
|
28
|
+
});
|
|
29
|
+
useWalletConnectorEvent.useWalletConnectorEvent(walletConnector || undefined, 'chainChange', ({ chain }) => setNetwork(chain));
|
|
30
|
+
/**
|
|
31
|
+
* Listen to disconnect event and update the network because ArgentX
|
|
32
|
+
* emits a disconnect event when the user switches network.
|
|
33
|
+
*/
|
|
34
|
+
useWalletConnectorEvent.useWalletConnectorEvent(walletConnector || undefined, 'disconnect', () => {
|
|
35
|
+
if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key) === 'argentx') {
|
|
36
|
+
walletConnector.getNetwork().then(setNetwork);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return { network };
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.useWalletConnectorNetwork = useWalletConnectorNetwork;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
/**
|
|
3
|
+
* Sync wallet connector network.
|
|
4
|
+
*
|
|
5
|
+
* @param walletConnector - The WalletConnector instance to be used.
|
|
6
|
+
*
|
|
7
|
+
* @returns {{ network: string | number | undefined }} An object containing the current network state.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Example of using the useWalletConnectorNetwork hook
|
|
11
|
+
* const { network } = useWalletConnectorNetwork(walletConnector);
|
|
12
|
+
*
|
|
13
|
+
* // You can then use the 'network' state in your component
|
|
14
|
+
* return <div>Current Network: {network}</div>;
|
|
15
|
+
*/
|
|
16
|
+
export declare const useWalletConnectorNetwork: (walletConnector: WalletConnector | null | undefined) => {
|
|
17
|
+
network: string | number | undefined;
|
|
18
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { usePromise } from '../usePromise/usePromise.js';
|
|
3
|
+
import '../../../events/dynamicEvents.js';
|
|
4
|
+
import { useWalletConnectorEvent } from '../events/useWalletConnectorEvent/useWalletConnectorEvent.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sync wallet connector network.
|
|
8
|
+
*
|
|
9
|
+
* @param walletConnector - The WalletConnector instance to be used.
|
|
10
|
+
*
|
|
11
|
+
* @returns {{ network: string | number | undefined }} An object containing the current network state.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Example of using the useWalletConnectorNetwork hook
|
|
15
|
+
* const { network } = useWalletConnectorNetwork(walletConnector);
|
|
16
|
+
*
|
|
17
|
+
* // You can then use the 'network' state in your component
|
|
18
|
+
* return <div>Current Network: {network}</div>;
|
|
19
|
+
*/
|
|
20
|
+
const useWalletConnectorNetwork = (walletConnector) => {
|
|
21
|
+
const [network, setNetwork] = useState();
|
|
22
|
+
usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), {
|
|
23
|
+
onResolve: (network) => setNetwork(network),
|
|
24
|
+
});
|
|
25
|
+
useWalletConnectorEvent(walletConnector || undefined, 'chainChange', ({ chain }) => setNetwork(chain));
|
|
26
|
+
/**
|
|
27
|
+
* Listen to disconnect event and update the network because ArgentX
|
|
28
|
+
* emits a disconnect event when the user switches network.
|
|
29
|
+
*/
|
|
30
|
+
useWalletConnectorEvent(walletConnector || undefined, 'disconnect', () => {
|
|
31
|
+
if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key) === 'argentx') {
|
|
32
|
+
walletConnector.getNetwork().then(setNetwork);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return { network };
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { useWalletConnectorNetwork };
|
|
@@ -13,7 +13,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useInte
|
|
|
13
13
|
require('@dynamic-labs/wallet-connector-core');
|
|
14
14
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
15
15
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
16
|
-
require('../../../context/ViewContext/ViewContext.cjs');
|
|
16
|
+
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
17
17
|
var decodeJwt = require('../../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
18
18
|
require('@dynamic-labs/iconic');
|
|
19
19
|
var close = require('../../../shared/assets/close.cjs');
|
|
@@ -78,17 +78,18 @@ var constants = require('../constants.cjs');
|
|
|
78
78
|
const EmbeddedRevealView = () => {
|
|
79
79
|
var _a, _b;
|
|
80
80
|
const { authToken, primaryWallet, user, setShowAuthFlow, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
81
|
+
const { view } = ViewContext.useViewContext();
|
|
81
82
|
const [acknowledgement1, setAcknowledgement1] = React.useState(false);
|
|
82
83
|
const iframeContainerRef = React.useRef(null);
|
|
83
84
|
const decodedJwt = decodeJwt.decodeJwt(authToken);
|
|
84
85
|
const walletProperties = (_b = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
85
86
|
const isTurnkeyHDWallet = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
87
|
+
const exportPrivateKey = view === null || view === void 0 ? void 0 : view.includes('account');
|
|
86
88
|
React.useEffect(() => {
|
|
89
|
+
var _a;
|
|
87
90
|
const iframeContainerElement = iframeContainerRef.current;
|
|
88
|
-
if (!iframeContainerElement
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
if (iframeContainerElement.children.length > 0) {
|
|
91
|
+
if (!iframeContainerElement ||
|
|
92
|
+
((_a = iframeContainerElement === null || iframeContainerElement === void 0 ? void 0 : iframeContainerElement.children) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
94
95
|
turnkeyExport.initExport({
|
|
@@ -105,11 +106,8 @@ const EmbeddedRevealView = () => {
|
|
|
105
106
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
106
107
|
}, []);
|
|
107
108
|
const { mutate: handleExportWallet, isLoading, error, data, } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
-
const iframeContainerElement = iframeContainerRef.current;
|
|
109
|
-
if (!iframeContainerElement) {
|
|
110
|
-
throw new utils.DynamicError('Missing iframe container');
|
|
111
|
-
}
|
|
112
109
|
return turnkeyExport.exportCredential({
|
|
110
|
+
address: exportPrivateKey ? primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address : undefined,
|
|
113
111
|
authToken,
|
|
114
112
|
environmentId,
|
|
115
113
|
userEmail: user === null || user === void 0 ? void 0 : user.email,
|
|
@@ -137,22 +135,26 @@ const EmbeddedRevealView = () => {
|
|
|
137
135
|
if (((_a = iframeContainerRef === null || iframeContainerRef === void 0 ? void 0 : iframeContainerRef.current) === null || _a === void 0 ? void 0 : _a.children) && data) {
|
|
138
136
|
// eslint-disable-next-line prefer-destructuring
|
|
139
137
|
const iframeElement = iframeContainerRef.current.children[0];
|
|
140
|
-
iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.setAttribute('style', isTurnkeyHDWallet
|
|
138
|
+
iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.setAttribute('style', !isTurnkeyHDWallet || exportPrivateKey
|
|
139
|
+
? 'height: 60px'
|
|
140
|
+
: 'height: 100px');
|
|
141
141
|
}
|
|
142
|
-
}, [iframeContainerRef, data, isTurnkeyHDWallet]);
|
|
142
|
+
}, [iframeContainerRef, data, isTurnkeyHDWallet, exportPrivateKey]);
|
|
143
143
|
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { onClick: () => setShowAuthFlow(false), type: 'button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
144
144
|
const hasInjectedCredential = !isLoading && data && !error;
|
|
145
|
-
const credentialTitle = isTurnkeyHDWallet
|
|
146
|
-
? t('dyn_embedded_reveal.
|
|
147
|
-
: t('dyn_embedded_reveal.
|
|
145
|
+
const credentialTitle = !isTurnkeyHDWallet || exportPrivateKey
|
|
146
|
+
? t('dyn_embedded_reveal.private_key_title')
|
|
147
|
+
: t('dyn_embedded_reveal.recovery_phrase_title');
|
|
148
148
|
const title = hasInjectedCredential
|
|
149
149
|
? credentialTitle
|
|
150
150
|
: t('dyn_embedded_reveal.agreement_title');
|
|
151
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsxRuntime.jsx("div", { className: 'embedded-reveal-view', children: jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body', children: [contentHeader, jsxRuntime.jsx("div", { id: constants.iframeContainerId, style: { display: data ? 'block' : 'none' }, ref: iframeContainerRef }), hasInjectedCredential ? (jsxRuntime.jsx(Button.Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', onClick: () => setShowAuthFlow(false), loading: isLoading, typographyProps: {
|
|
151
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsxRuntime.jsx("div", { className: 'embedded-reveal-view', children: jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body', children: [contentHeader, jsxRuntime.jsx("div", { id: constants.iframeContainerId, style: { display: data ? 'block' : 'none' }, ref: iframeContainerRef }), hasInjectedCredential ? (jsxRuntime.jsx(Button.Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', onClick: () => setShowAuthFlow(false), loading: isLoading, copykey: 'dyn_embedded_reveal.done_button_label', typographyProps: {
|
|
152
152
|
color: 'inherit',
|
|
153
|
-
}, children: t('dyn_embedded_reveal.done_button_label') })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__description', children: jsxRuntime.jsx(Badge.Badge, { text: t('dyn_embedded_reveal.badge_label'), className: 'embedded-reveal-view__body__badge' }) }), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card', children: [jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsxRuntime.jsx(walletV2.ReactComponent, {}) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, children: t('dyn_embedded_reveal.statement_1.title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', children: t('dyn_embedded_reveal.statement_1.description') })] })] }), jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsxRuntime.jsx(eyeOffIcon.ReactComponent, {}) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, children: t('dyn_embedded_reveal.statement_2.title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', weight: 'regular',
|
|
153
|
+
}, children: t('dyn_embedded_reveal.done_button_label') })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__description', children: jsxRuntime.jsx(Badge.Badge, { text: t('dyn_embedded_reveal.badge_label'), className: 'embedded-reveal-view__body__badge' }) }), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card', children: [jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsxRuntime.jsx(walletV2.ReactComponent, {}) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.statement_1.title', children: t('dyn_embedded_reveal.statement_1.title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', copykey: 'dyn_embedded_reveal.statement_1.description', children: t('dyn_embedded_reveal.statement_1.description') })] })] }), jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsxRuntime.jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsxRuntime.jsx(eyeOffIcon.ReactComponent, {}) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.statement_2.title', children: t('dyn_embedded_reveal.statement_2.title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', copykey: 'dyn_embedded_reveal.statement_2.description', children: t('dyn_embedded_reveal.statement_2.description', {
|
|
154
|
+
credential_type: credentialTitle === null || credentialTitle === void 0 ? void 0 : credentialTitle.toLowerCase(),
|
|
155
|
+
}) })] })] })] }), jsxRuntime.jsxs("div", { className: 'embedded-reveal-view__body__confirm_card', children: [jsxRuntime.jsxs("button", { className: 'embedded-reveal-view__body__card__acknowledgement', onClick: () => setAcknowledgement1(!acknowledgement1), children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Checkbox.Checkbox, { checked: acknowledgement1, onChange: () => setAcknowledgement1(!acknowledgement1), className: 'embedded-reveal-view__body__card__statement__checkbox', id: 'embedded-reveal-checkbox-1' }) }), jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.checkbox_label', children: t('dyn_embedded_reveal.checkbox_label') }) })] }), jsxRuntime.jsx(Button.Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', typographyProps: {
|
|
154
156
|
color: 'inherit',
|
|
155
|
-
}, onClick: () => handleExportWallet(), disabled: !acknowledgement1, loading: isLoading, dataTestId: 'embedded-reveal-button', children: t('dyn_embedded_reveal.reveal_button_label') })] })] }))] }) })] }));
|
|
157
|
+
}, onClick: () => handleExportWallet(), disabled: !acknowledgement1, loading: isLoading, dataTestId: 'embedded-reveal-button', copykey: 'dyn_embedded_reveal.reveal_button_label', children: t('dyn_embedded_reveal.reveal_button_label') })] })] }))] }) })] }));
|
|
156
158
|
};
|
|
157
159
|
|
|
158
160
|
exports.EmbeddedRevealView = EmbeddedRevealView;
|
|
@@ -9,7 +9,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useIn
|
|
|
9
9
|
import '@dynamic-labs/wallet-connector-core';
|
|
10
10
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
11
11
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
12
|
-
import '../../../context/ViewContext/ViewContext.js';
|
|
12
|
+
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
13
13
|
import { decodeJwt } from '../../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
14
14
|
import '@dynamic-labs/iconic';
|
|
15
15
|
import { ReactComponent as SvgClose } from '../../../shared/assets/close.js';
|
|
@@ -74,17 +74,18 @@ import { iframeContainerId, iframeElementId } from '../constants.js';
|
|
|
74
74
|
const EmbeddedRevealView = () => {
|
|
75
75
|
var _a, _b;
|
|
76
76
|
const { authToken, primaryWallet, user, setShowAuthFlow, environmentId } = useInternalDynamicContext();
|
|
77
|
+
const { view } = useViewContext();
|
|
77
78
|
const [acknowledgement1, setAcknowledgement1] = useState(false);
|
|
78
79
|
const iframeContainerRef = useRef(null);
|
|
79
80
|
const decodedJwt = decodeJwt(authToken);
|
|
80
81
|
const walletProperties = (_b = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
81
82
|
const isTurnkeyHDWallet = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
83
|
+
const exportPrivateKey = view === null || view === void 0 ? void 0 : view.includes('account');
|
|
82
84
|
useEffect(() => {
|
|
85
|
+
var _a;
|
|
83
86
|
const iframeContainerElement = iframeContainerRef.current;
|
|
84
|
-
if (!iframeContainerElement
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
if (iframeContainerElement.children.length > 0) {
|
|
87
|
+
if (!iframeContainerElement ||
|
|
88
|
+
((_a = iframeContainerElement === null || iframeContainerElement === void 0 ? void 0 : iframeContainerElement.children) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
91
|
initExport({
|
|
@@ -101,11 +102,8 @@ const EmbeddedRevealView = () => {
|
|
|
101
102
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
102
103
|
}, []);
|
|
103
104
|
const { mutate: handleExportWallet, isLoading, error, data, } = useMutation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
104
|
-
const iframeContainerElement = iframeContainerRef.current;
|
|
105
|
-
if (!iframeContainerElement) {
|
|
106
|
-
throw new DynamicError('Missing iframe container');
|
|
107
|
-
}
|
|
108
105
|
return exportCredential({
|
|
106
|
+
address: exportPrivateKey ? primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address : undefined,
|
|
109
107
|
authToken,
|
|
110
108
|
environmentId,
|
|
111
109
|
userEmail: user === null || user === void 0 ? void 0 : user.email,
|
|
@@ -133,22 +131,26 @@ const EmbeddedRevealView = () => {
|
|
|
133
131
|
if (((_a = iframeContainerRef === null || iframeContainerRef === void 0 ? void 0 : iframeContainerRef.current) === null || _a === void 0 ? void 0 : _a.children) && data) {
|
|
134
132
|
// eslint-disable-next-line prefer-destructuring
|
|
135
133
|
const iframeElement = iframeContainerRef.current.children[0];
|
|
136
|
-
iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.setAttribute('style', isTurnkeyHDWallet
|
|
134
|
+
iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.setAttribute('style', !isTurnkeyHDWallet || exportPrivateKey
|
|
135
|
+
? 'height: 60px'
|
|
136
|
+
: 'height: 100px');
|
|
137
137
|
}
|
|
138
|
-
}, [iframeContainerRef, data, isTurnkeyHDWallet]);
|
|
138
|
+
}, [iframeContainerRef, data, isTurnkeyHDWallet, exportPrivateKey]);
|
|
139
139
|
const closeButton = (jsx(IconButton, { onClick: () => setShowAuthFlow(false), type: 'button', children: jsx(SvgClose, {}) }));
|
|
140
140
|
const hasInjectedCredential = !isLoading && data && !error;
|
|
141
|
-
const credentialTitle = isTurnkeyHDWallet
|
|
142
|
-
? t('dyn_embedded_reveal.
|
|
143
|
-
: t('dyn_embedded_reveal.
|
|
141
|
+
const credentialTitle = !isTurnkeyHDWallet || exportPrivateKey
|
|
142
|
+
? t('dyn_embedded_reveal.private_key_title')
|
|
143
|
+
: t('dyn_embedded_reveal.recovery_phrase_title');
|
|
144
144
|
const title = hasInjectedCredential
|
|
145
145
|
? credentialTitle
|
|
146
146
|
: t('dyn_embedded_reveal.agreement_title');
|
|
147
|
-
return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: closeButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsx("div", { className: 'embedded-reveal-view', children: jsxs("div", { className: 'embedded-reveal-view__body', children: [contentHeader, jsx("div", { id: iframeContainerId, style: { display: data ? 'block' : 'none' }, ref: iframeContainerRef }), hasInjectedCredential ? (jsx(Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', onClick: () => setShowAuthFlow(false), loading: isLoading, typographyProps: {
|
|
147
|
+
return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: closeButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsx("div", { className: 'embedded-reveal-view', children: jsxs("div", { className: 'embedded-reveal-view__body', children: [contentHeader, jsx("div", { id: iframeContainerId, style: { display: data ? 'block' : 'none' }, ref: iframeContainerRef }), hasInjectedCredential ? (jsx(Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', onClick: () => setShowAuthFlow(false), loading: isLoading, copykey: 'dyn_embedded_reveal.done_button_label', typographyProps: {
|
|
148
148
|
color: 'inherit',
|
|
149
|
-
}, children: t('dyn_embedded_reveal.done_button_label') })) : (jsxs(Fragment, { children: [jsx("div", { className: 'embedded-reveal-view__body__description', children: jsx(Badge, { text: t('dyn_embedded_reveal.badge_label'), className: 'embedded-reveal-view__body__badge' }) }), errorText && jsx(ErrorContainer, { children: errorText }), jsxs("div", { className: 'embedded-reveal-view__body__card', children: [jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsx(SvgWalletV2, {}) }), jsxs("div", { children: [jsx(Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, children: t('dyn_embedded_reveal.statement_1.title') }), jsx(Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', children: t('dyn_embedded_reveal.statement_1.description') })] })] }), jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsx(SvgEyeOffIcon, {}) }), jsxs("div", { children: [jsx(Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, children: t('dyn_embedded_reveal.statement_2.title') }), jsx(Typography, { variant: 'body_small', color: 'secondary', weight: 'regular',
|
|
149
|
+
}, children: t('dyn_embedded_reveal.done_button_label') })) : (jsxs(Fragment, { children: [jsx("div", { className: 'embedded-reveal-view__body__description', children: jsx(Badge, { text: t('dyn_embedded_reveal.badge_label'), className: 'embedded-reveal-view__body__badge' }) }), errorText && jsx(ErrorContainer, { children: errorText }), jsxs("div", { className: 'embedded-reveal-view__body__card', children: [jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsx(SvgWalletV2, {}) }), jsxs("div", { children: [jsx(Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.statement_1.title', children: t('dyn_embedded_reveal.statement_1.title') }), jsx(Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', copykey: 'dyn_embedded_reveal.statement_1.description', children: t('dyn_embedded_reveal.statement_1.description') })] })] }), jsxs("div", { className: 'embedded-reveal-view__body__card__statement', children: [jsx("div", { className: 'embedded-reveal-view__body__card__icon', children: jsx(SvgEyeOffIcon, {}) }), jsxs("div", { children: [jsx(Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.statement_2.title', children: t('dyn_embedded_reveal.statement_2.title') }), jsx(Typography, { variant: 'body_small', color: 'secondary', weight: 'regular', copykey: 'dyn_embedded_reveal.statement_2.description', children: t('dyn_embedded_reveal.statement_2.description', {
|
|
150
|
+
credential_type: credentialTitle === null || credentialTitle === void 0 ? void 0 : credentialTitle.toLowerCase(),
|
|
151
|
+
}) })] })] })] }), jsxs("div", { className: 'embedded-reveal-view__body__confirm_card', children: [jsxs("button", { className: 'embedded-reveal-view__body__card__acknowledgement', onClick: () => setAcknowledgement1(!acknowledgement1), children: [jsx("div", { children: jsx(Checkbox, { checked: acknowledgement1, onChange: () => setAcknowledgement1(!acknowledgement1), className: 'embedded-reveal-view__body__card__statement__checkbox', id: 'embedded-reveal-checkbox-1' }) }), jsx("div", { children: jsx(Typography, { variant: 'body_normal', color: 'primary', style: { letterSpacing: '-0.15px' }, copykey: 'dyn_embedded_reveal.checkbox_label', children: t('dyn_embedded_reveal.checkbox_label') }) })] }), jsx(Button, { buttonPadding: 'large', buttonVariant: 'brand-primary', typographyProps: {
|
|
150
152
|
color: 'inherit',
|
|
151
|
-
}, onClick: () => handleExportWallet(), disabled: !acknowledgement1, loading: isLoading, dataTestId: 'embedded-reveal-button', children: t('dyn_embedded_reveal.reveal_button_label') })] })] }))] }) })] }));
|
|
153
|
+
}, onClick: () => handleExportWallet(), disabled: !acknowledgement1, loading: isLoading, dataTestId: 'embedded-reveal-button', copykey: 'dyn_embedded_reveal.reveal_button_label', children: t('dyn_embedded_reveal.reveal_button_label') })] })] }))] }) })] }));
|
|
152
154
|
};
|
|
153
155
|
|
|
154
156
|
export { EmbeddedRevealView };
|
|
@@ -32,8 +32,8 @@ const initExport = ({ iframeContainer, iframeElementId, wallet, }) => _tslib.__a
|
|
|
32
32
|
}
|
|
33
33
|
return turnkeyExportHandler;
|
|
34
34
|
});
|
|
35
|
-
const
|
|
36
|
-
var
|
|
35
|
+
const handleExportInitCheck = ({ authToken, userEmail, wallet, }) => {
|
|
36
|
+
var _a, _b;
|
|
37
37
|
if (!authToken) {
|
|
38
38
|
throw new utils.DynamicError('User must be logged in');
|
|
39
39
|
}
|
|
@@ -48,7 +48,7 @@ const exportCredential = ({ authToken, userEmail, wallet, environmentId, }) => _
|
|
|
48
48
|
}
|
|
49
49
|
const connector = wallet.connector;
|
|
50
50
|
connector.setEmail(userEmail);
|
|
51
|
-
const walletProperties = (
|
|
51
|
+
const walletProperties = (_b = (_a = decodedJwt.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
52
52
|
const turnkeyHDWalletId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
53
53
|
const privateKeyId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyPrivateKeyId;
|
|
54
54
|
const organizationId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeySubOrganizationId;
|
|
@@ -56,59 +56,84 @@ const exportCredential = ({ authToken, userEmail, wallet, environmentId, }) => _
|
|
|
56
56
|
(turnkeyHDWalletId === undefined && privateKeyId === undefined)) {
|
|
57
57
|
throw new utils.DynamicError('Invalid token!');
|
|
58
58
|
}
|
|
59
|
+
return {
|
|
60
|
+
connector,
|
|
61
|
+
organizationId,
|
|
62
|
+
privateKeyId,
|
|
63
|
+
turnkeyHDWalletId,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const extractExportBundle = ({ address, privateKeyId, activity, }) => {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
const exportWalletResult = address
|
|
69
|
+
? (_a = activity.result) === null || _a === void 0 ? void 0 : _a.exportWalletAccountResult
|
|
70
|
+
: (_b = activity.result) === null || _b === void 0 ? void 0 : _b.exportWalletResult;
|
|
71
|
+
const result = privateKeyId
|
|
72
|
+
? (_c = activity.result) === null || _c === void 0 ? void 0 : _c.exportPrivateKeyResult
|
|
73
|
+
: exportWalletResult;
|
|
74
|
+
return result === null || result === void 0 ? void 0 : result.exportBundle;
|
|
75
|
+
};
|
|
76
|
+
const exportCredential = ({ authToken, userEmail, wallet, environmentId, address, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
const { connector, turnkeyHDWalletId, privateKeyId, organizationId } = handleExportInitCheck({
|
|
78
|
+
authToken,
|
|
79
|
+
userEmail,
|
|
80
|
+
wallet,
|
|
81
|
+
});
|
|
59
82
|
const turnkeyExportHandler = connector.getExportHandler();
|
|
60
83
|
const targetPublicKey = turnkeyExportHandler.publicKey;
|
|
61
84
|
if (!targetPublicKey) {
|
|
62
85
|
throw new utils.DynamicError('Must initialize export first');
|
|
63
86
|
}
|
|
64
87
|
// calls turnkey export api
|
|
88
|
+
let newActivity;
|
|
65
89
|
if (turnkeyHDWalletId) {
|
|
66
|
-
|
|
90
|
+
newActivity = yield turnkeyExportHandler.exportWallet({
|
|
91
|
+
address,
|
|
67
92
|
organizationId,
|
|
68
93
|
walletId: turnkeyHDWalletId,
|
|
69
94
|
});
|
|
70
|
-
const activityId = newActivity.id;
|
|
71
|
-
const res = yield api.exportEmbeddedWallet({
|
|
72
|
-
activityId,
|
|
73
|
-
environmentId,
|
|
74
|
-
userJwt: authToken,
|
|
75
|
-
walletId: wallet.id,
|
|
76
|
-
});
|
|
77
|
-
const exportBundle = res === null || res === void 0 ? void 0 : res.exportBundle;
|
|
78
|
-
if (!exportBundle) {
|
|
79
|
-
throw new utils.DynamicError('Invalid export response');
|
|
80
|
-
}
|
|
81
|
-
const injected = yield turnkeyExportHandler.verifyExportWallet(exportBundle);
|
|
82
|
-
return injected;
|
|
83
95
|
}
|
|
84
96
|
else if (privateKeyId) {
|
|
85
|
-
|
|
97
|
+
newActivity = yield turnkeyExportHandler.exportPrivateKey({
|
|
86
98
|
organizationId,
|
|
87
99
|
privateKeyId,
|
|
88
100
|
});
|
|
89
|
-
|
|
101
|
+
}
|
|
102
|
+
const activityId = newActivity.id;
|
|
103
|
+
const activityStatus = newActivity.status;
|
|
104
|
+
let exportBundle;
|
|
105
|
+
if (activityStatus === 'ACTIVITY_STATUS_COMPLETED') {
|
|
106
|
+
exportBundle = extractExportBundle({
|
|
107
|
+
activity: newActivity,
|
|
108
|
+
address,
|
|
109
|
+
privateKeyId,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
90
113
|
const res = yield api.exportEmbeddedWallet({
|
|
91
114
|
activityId,
|
|
92
115
|
environmentId,
|
|
93
|
-
userJwt: authToken,
|
|
94
|
-
walletId: wallet.id,
|
|
116
|
+
userJwt: authToken || '',
|
|
117
|
+
walletId: (wallet === null || wallet === void 0 ? void 0 : wallet.id) || '',
|
|
95
118
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
119
|
+
exportBundle = res === null || res === void 0 ? void 0 : res.exportBundle;
|
|
120
|
+
}
|
|
121
|
+
if (!exportBundle) {
|
|
122
|
+
throw new utils.DynamicError('Invalid export response');
|
|
123
|
+
}
|
|
124
|
+
if (address || privateKeyId) {
|
|
125
|
+
return turnkeyExportHandler.verifyExportPrivateKey(exportBundle);
|
|
102
126
|
}
|
|
103
|
-
|
|
127
|
+
return turnkeyExportHandler.verifyExportWallet(exportBundle);
|
|
104
128
|
});
|
|
105
129
|
const cleanupExport = ({ wallet }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
var
|
|
130
|
+
var _b;
|
|
107
131
|
const connector = wallet === null || wallet === void 0 ? void 0 : wallet.connector;
|
|
108
132
|
// clear iframeStamper and its reference
|
|
109
|
-
(
|
|
133
|
+
(_b = connector === null || connector === void 0 ? void 0 : connector.getExportHandler()) === null || _b === void 0 ? void 0 : _b.clear();
|
|
110
134
|
});
|
|
111
135
|
|
|
112
136
|
exports.cleanupExport = cleanupExport;
|
|
113
137
|
exports.exportCredential = exportCredential;
|
|
138
|
+
exports.extractExportBundle = extractExportBundle;
|
|
114
139
|
exports.initExport = initExport;
|
|
@@ -4,11 +4,17 @@ export declare const initExport: ({ iframeContainer, iframeElementId, wallet, }:
|
|
|
4
4
|
iframeElementId: string;
|
|
5
5
|
wallet: Wallet | null;
|
|
6
6
|
}) => Promise<import("@dynamic-labs/wallet-connector-core").ExportHandler>;
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const extractExportBundle: ({ address, privateKeyId, activity, }: {
|
|
8
|
+
address?: string | undefined;
|
|
9
|
+
privateKeyId?: string | undefined;
|
|
10
|
+
activity: any;
|
|
11
|
+
}) => any;
|
|
12
|
+
export declare const exportCredential: ({ authToken, userEmail, wallet, environmentId, address, }: {
|
|
8
13
|
authToken: string | undefined;
|
|
9
14
|
userEmail: string | undefined;
|
|
10
15
|
wallet: Wallet | null;
|
|
11
16
|
environmentId: string;
|
|
17
|
+
address?: string | undefined;
|
|
12
18
|
}) => Promise<unknown>;
|
|
13
19
|
export declare const cleanupExport: ({ wallet }: {
|
|
14
20
|
wallet: Wallet | null;
|