@dynamic-labs/sdk-react-core 4.46.2 → 4.47.0
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 +12 -12
- package/src/index.cjs +2 -2
- package/src/index.js +1 -1
- package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.cjs +22 -0
- package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.js +23 -1
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.cjs +2 -0
- package/src/lib/layout/DynamicUserProfileLayout/DynamicUserProfileLayout.js +2 -0
- package/src/lib/shared/assets/backup-waas.cjs +52 -0
- package/src/lib/shared/assets/backup-waas.js +28 -0
- package/src/lib/shared/assets/backupArrow.cjs +54 -0
- package/src/lib/shared/assets/backupArrow.js +30 -0
- package/src/lib/shared/assets/filled-question-mark.cjs +52 -0
- package/src/lib/shared/assets/filled-question-mark.js +28 -0
- package/src/lib/shared/assets/google-drive.cjs +75 -0
- package/src/lib/shared/assets/google-drive.js +51 -0
- package/src/lib/shared/assets/index.d.ts +4 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +3 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +5 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +3 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +3 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +3 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +4 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +4 -0
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.cjs +15 -5
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.js +15 -5
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.cjs +36 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.js +32 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.cjs +191 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.js +187 -0
- package/src/lib/widgets/DynamicWidget/views/WaasBackupView/index.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/index.d.ts +2 -0
|
@@ -159,7 +159,8 @@ const useSocialAccounts = () => {
|
|
|
159
159
|
}
|
|
160
160
|
return true;
|
|
161
161
|
}, [handleError, projectSettings]);
|
|
162
|
-
const linkSocialAccount = React.useCallback((provider_1, ...args_1) => _tslib.__awaiter(void 0, [provider_1, ...args_1], void 0, function* (provider, { redirectUrl, showWidgetAfterConnection, triggerFundFromExchangeOnSuccess, payingWithDynamic, } = {
|
|
162
|
+
const linkSocialAccount = React.useCallback((provider_1, ...args_1) => _tslib.__awaiter(void 0, [provider_1, ...args_1], void 0, function* (provider, { forcePopup, redirectUrl, showWidgetAfterConnection, triggerFundFromExchangeOnSuccess, payingWithDynamic, } = {
|
|
163
|
+
forcePopup: false,
|
|
163
164
|
payingWithDynamic: undefined,
|
|
164
165
|
redirectUrl: undefined,
|
|
165
166
|
showWidgetAfterConnection: false,
|
|
@@ -169,6 +170,7 @@ const useSocialAccounts = () => {
|
|
|
169
170
|
try {
|
|
170
171
|
yield connectSocialAccount({
|
|
171
172
|
authMode: 'link',
|
|
173
|
+
forcePopup,
|
|
172
174
|
payingWithDynamic,
|
|
173
175
|
provider,
|
|
174
176
|
redirectUrl,
|
|
@@ -10,6 +10,10 @@ type ConnectSocialProps = {
|
|
|
10
10
|
* Whether to show the widget after a connection is made
|
|
11
11
|
*/
|
|
12
12
|
showWidgetAfterConnection?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Forces popup strategy instead of redirect
|
|
15
|
+
*/
|
|
16
|
+
forcePopup?: boolean;
|
|
13
17
|
/** Exchange to be funded */
|
|
14
18
|
triggerFundFromExchangeOnSuccess?: ExchangeKeyEnum;
|
|
15
19
|
/**
|
|
@@ -25,7 +29,7 @@ export declare const useSocialAccounts: () => {
|
|
|
25
29
|
readonly isLinked: (provider: ProviderEnum) => boolean;
|
|
26
30
|
readonly isProcessing: boolean;
|
|
27
31
|
readonly isProcessingForProvider: (provider: ProviderEnum) => boolean;
|
|
28
|
-
readonly linkSocialAccount: (provider: ProviderEnum, { redirectUrl, showWidgetAfterConnection, triggerFundFromExchangeOnSuccess, payingWithDynamic, }?: ConnectSocialProps) => Promise<void>;
|
|
32
|
+
readonly linkSocialAccount: (provider: ProviderEnum, { forcePopup, redirectUrl, showWidgetAfterConnection, triggerFundFromExchangeOnSuccess, payingWithDynamic, }?: ConnectSocialProps) => Promise<void>;
|
|
29
33
|
readonly signInWithSocialAccount: (provider: ProviderEnum, { redirectUrl, payingWithDynamic, showWidgetAfterConnection, triggerFundFromExchangeOnSuccess, }?: ConnectSocialProps) => Promise<void>;
|
|
30
34
|
readonly unlinkSocialAccount: (provider: ProviderEnum, verifiedCredentialId?: string) => Promise<void>;
|
|
31
35
|
};
|
|
@@ -155,7 +155,8 @@ const useSocialAccounts = () => {
|
|
|
155
155
|
}
|
|
156
156
|
return true;
|
|
157
157
|
}, [handleError, projectSettings]);
|
|
158
|
-
const linkSocialAccount = useCallback((provider_1, ...args_1) => __awaiter(void 0, [provider_1, ...args_1], void 0, function* (provider, { redirectUrl, showWidgetAfterConnection, triggerFundFromExchangeOnSuccess, payingWithDynamic, } = {
|
|
158
|
+
const linkSocialAccount = useCallback((provider_1, ...args_1) => __awaiter(void 0, [provider_1, ...args_1], void 0, function* (provider, { forcePopup, redirectUrl, showWidgetAfterConnection, triggerFundFromExchangeOnSuccess, payingWithDynamic, } = {
|
|
159
|
+
forcePopup: false,
|
|
159
160
|
payingWithDynamic: undefined,
|
|
160
161
|
redirectUrl: undefined,
|
|
161
162
|
showWidgetAfterConnection: false,
|
|
@@ -165,6 +166,7 @@ const useSocialAccounts = () => {
|
|
|
165
166
|
try {
|
|
166
167
|
yield connectSocialAccount({
|
|
167
168
|
authMode: 'link',
|
|
169
|
+
forcePopup,
|
|
168
170
|
payingWithDynamic,
|
|
169
171
|
provider,
|
|
170
172
|
redirectUrl,
|
|
@@ -376,7 +376,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
376
376
|
shouldRegisterSessionKeysOnSignin,
|
|
377
377
|
signInAccount,
|
|
378
378
|
]);
|
|
379
|
-
const connectSocialAccount = React.useCallback((_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ authMode, provider, validator, captchaToken, isHeadlessSocialSignIn, payingWithDynamic, triggerFundFromExchangeOnSuccess, redirectUrl, telegramAuthToken, showWidgetAfterConnection, ssoProviderId, }) {
|
|
379
|
+
const connectSocialAccount = React.useCallback((_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ authMode, provider, validator, captchaToken, isHeadlessSocialSignIn, payingWithDynamic, triggerFundFromExchangeOnSuccess, redirectUrl, telegramAuthToken, showWidgetAfterConnection, forcePopup, ssoProviderId, }) {
|
|
380
380
|
var _e, _f;
|
|
381
381
|
clearError();
|
|
382
382
|
setIsProcessing(true);
|
|
@@ -432,6 +432,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
432
432
|
}
|
|
433
433
|
const isMobile = utils.isMobile();
|
|
434
434
|
try {
|
|
435
|
+
const effectiveStrategy = forcePopup ? 'popup' : strategy;
|
|
435
436
|
const authCode = yield utils.Oauth2Service.getOauthCode({
|
|
436
437
|
apiProvider: getProviderByType.getProviderByType((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _f !== void 0 ? _f : [], provider),
|
|
437
438
|
getOAuthResultFromApi: () => oauth.getOAuthResult(environmentId, provider, {
|
|
@@ -450,7 +451,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
450
451
|
redirectUrl: redirectUrl !== null && redirectUrl !== void 0 ? redirectUrl : defaultRedirectUrl,
|
|
451
452
|
setIsProcessing,
|
|
452
453
|
state,
|
|
453
|
-
strategy,
|
|
454
|
+
strategy: effectiveStrategy,
|
|
454
455
|
});
|
|
455
456
|
yield completeConnection({
|
|
456
457
|
authCode,
|
|
@@ -16,6 +16,7 @@ export type ConnectSocialAccountProps = {
|
|
|
16
16
|
redirectUrl?: string;
|
|
17
17
|
telegramAuthToken?: string;
|
|
18
18
|
showWidgetAfterConnection?: boolean;
|
|
19
|
+
forcePopup?: boolean;
|
|
19
20
|
triggerFundFromExchangeOnSuccess?: ExchangeKeyEnum;
|
|
20
21
|
payingWithDynamic?: PayWithDynamicProps;
|
|
21
22
|
/** marks the flow as initiated by headless sign-in API */
|
|
@@ -372,7 +372,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
372
372
|
shouldRegisterSessionKeysOnSignin,
|
|
373
373
|
signInAccount,
|
|
374
374
|
]);
|
|
375
|
-
const connectSocialAccount = useCallback((_d) => __awaiter(void 0, [_d], void 0, function* ({ authMode, provider, validator, captchaToken, isHeadlessSocialSignIn, payingWithDynamic, triggerFundFromExchangeOnSuccess, redirectUrl, telegramAuthToken, showWidgetAfterConnection, ssoProviderId, }) {
|
|
375
|
+
const connectSocialAccount = useCallback((_d) => __awaiter(void 0, [_d], void 0, function* ({ authMode, provider, validator, captchaToken, isHeadlessSocialSignIn, payingWithDynamic, triggerFundFromExchangeOnSuccess, redirectUrl, telegramAuthToken, showWidgetAfterConnection, forcePopup, ssoProviderId, }) {
|
|
376
376
|
var _e, _f;
|
|
377
377
|
clearError();
|
|
378
378
|
setIsProcessing(true);
|
|
@@ -428,6 +428,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
428
428
|
}
|
|
429
429
|
const isMobile$1 = isMobile();
|
|
430
430
|
try {
|
|
431
|
+
const effectiveStrategy = forcePopup ? 'popup' : strategy;
|
|
431
432
|
const authCode = yield Oauth2Service.getOauthCode({
|
|
432
433
|
apiProvider: getProviderByType((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _f !== void 0 ? _f : [], provider),
|
|
433
434
|
getOAuthResultFromApi: () => getOAuthResult(environmentId, provider, {
|
|
@@ -446,7 +447,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
446
447
|
redirectUrl: redirectUrl !== null && redirectUrl !== void 0 ? redirectUrl : defaultRedirectUrl,
|
|
447
448
|
setIsProcessing,
|
|
448
449
|
state,
|
|
449
|
-
strategy,
|
|
450
|
+
strategy: effectiveStrategy,
|
|
450
451
|
});
|
|
451
452
|
yield completeConnection({
|
|
452
453
|
authCode,
|
|
@@ -13,6 +13,8 @@ var SettingsView = require('../../views/SettingsView/SettingsView.cjs');
|
|
|
13
13
|
var AccountAndSecuritySettingsView = require('../../views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs');
|
|
14
14
|
var SessionManagementView = require('../../views/SessionManagementView/SessionManagementView.cjs');
|
|
15
15
|
var WalletsDelegatedSettingsView = require('../../views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.cjs');
|
|
16
|
+
var WaasBackupView = require('../../views/WaasBackupView/WaasBackupView.cjs');
|
|
17
|
+
var WaasBackupInfoView = require('../../views/WaasBackupView/WaasBackupInfoView.cjs');
|
|
16
18
|
var CryptoComOnramp = require('../../views/CryptoComOnramp/CryptoComOnramp.cjs');
|
|
17
19
|
var ChooseLinkedWalletView = require('../../views/ChooseLinkedWalletView/ChooseLinkedWalletView.cjs');
|
|
18
20
|
var ChooseOnrampProviderView = require('../../views/ChooseOnrampProviderView/ChooseOnrampProviderView.cjs');
|
|
@@ -52,6 +54,8 @@ const mapViewToComponent = {
|
|
|
52
54
|
'session-management-info': SessionManagementInfoView.SessionManagementInfoView,
|
|
53
55
|
'session-management-revoke-access': RevokeAccessView.RevokeAccessView,
|
|
54
56
|
settings: SettingsView.SettingsView,
|
|
57
|
+
'waas-backup': WaasBackupView.WaasBackupView,
|
|
58
|
+
'waas-backup-info': WaasBackupInfoView.WaasBackupInfoView,
|
|
55
59
|
'wallet-delegation': WalletDelegationView.WalletDelegationView,
|
|
56
60
|
wallets: WalletsView.WalletsView,
|
|
57
61
|
'wallets-delegated-settings': WalletsDelegatedSettingsView.WalletsDelegatedSettingsView,
|
|
@@ -33,6 +33,8 @@ export declare const mapViewToComponent: {
|
|
|
33
33
|
'session-management-info': import("react").FC;
|
|
34
34
|
'session-management-revoke-access': import("react").FC<import("../../views/SessionManagementView/RevokeAccessView").RevokeAccessViewProps>;
|
|
35
35
|
settings: import("react").FC;
|
|
36
|
+
'waas-backup': import("react").FC;
|
|
37
|
+
'waas-backup-info': import("react").FC;
|
|
36
38
|
'wallet-delegation': import("react").FC<{
|
|
37
39
|
wallets?: import("dist/packages/wallet-connector-core/src").Wallet<import("dist/packages/wallet-connector-core/src").WalletConnectorCore.WalletConnector>[] | undefined;
|
|
38
40
|
}>;
|
|
@@ -9,6 +9,8 @@ import { SettingsView } from '../../views/SettingsView/SettingsView.js';
|
|
|
9
9
|
import { AccountAndSecuritySettingsView } from '../../views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js';
|
|
10
10
|
import { SessionManagementView } from '../../views/SessionManagementView/SessionManagementView.js';
|
|
11
11
|
import { WalletsDelegatedSettingsView } from '../../views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.js';
|
|
12
|
+
import { WaasBackupView } from '../../views/WaasBackupView/WaasBackupView.js';
|
|
13
|
+
import { WaasBackupInfoView } from '../../views/WaasBackupView/WaasBackupInfoView.js';
|
|
12
14
|
import { CryptoComOnramp } from '../../views/CryptoComOnramp/CryptoComOnramp.js';
|
|
13
15
|
import { ChooseLinkedWalletView } from '../../views/ChooseLinkedWalletView/ChooseLinkedWalletView.js';
|
|
14
16
|
import { ChooseOnrampProviderView } from '../../views/ChooseOnrampProviderView/ChooseOnrampProviderView.js';
|
|
@@ -48,6 +50,8 @@ const mapViewToComponent = {
|
|
|
48
50
|
'session-management-info': SessionManagementInfoView,
|
|
49
51
|
'session-management-revoke-access': RevokeAccessView,
|
|
50
52
|
settings: SettingsView,
|
|
53
|
+
'waas-backup': WaasBackupView,
|
|
54
|
+
'waas-backup-info': WaasBackupInfoView,
|
|
51
55
|
'wallet-delegation': WalletDelegationView,
|
|
52
56
|
wallets: WalletsView,
|
|
53
57
|
'wallets-delegated-settings': WalletsDelegatedSettingsView,
|
|
@@ -13,7 +13,7 @@ export declare const DynamicSessionManagementViews: readonly ["session-managemen
|
|
|
13
13
|
export type DynamicSessionManagementViewsType = typeof DynamicSessionManagementViews[number];
|
|
14
14
|
export declare const DynamicTransactionsWidgetViews: readonly ["send-balance"];
|
|
15
15
|
export type DynamicTransactionsWidgetViewsType = typeof DynamicTransactionsWidgetViews[number];
|
|
16
|
-
export type DynamicWidgetViews = 'wallets' | 'profile' | 'edit-profile' | 'choose-wallet-funding-method' | 'receive-wallet-funds' | 'deposited-exchange' | 'receive-exchange-funds' | 'crypto-com-onramp' | DynamicTransactionsWidgetViewsType | DynamicPasskeyWidgetViewsType | DynamicMfaWidgetViewsType | DynamicSettingsType | DynamicGlobalWalletType | DynamicSessionManagementViewsType | 'connected-apps' | 'deposit-view' | 'confirm-exchange-transfer' | 'choose-onramp-provider' | 'choose-linked-wallet' | 'wallet-delegation' | 'wallets-delegated-settings';
|
|
16
|
+
export type DynamicWidgetViews = 'wallets' | 'profile' | 'edit-profile' | 'choose-wallet-funding-method' | 'receive-wallet-funds' | 'deposited-exchange' | 'receive-exchange-funds' | 'crypto-com-onramp' | DynamicTransactionsWidgetViewsType | DynamicPasskeyWidgetViewsType | DynamicMfaWidgetViewsType | DynamicSettingsType | DynamicGlobalWalletType | DynamicSessionManagementViewsType | 'connected-apps' | 'deposit-view' | 'confirm-exchange-transfer' | 'choose-onramp-provider' | 'choose-linked-wallet' | 'waas-backup' | 'waas-backup-info' | 'wallet-delegation' | 'wallets-delegated-settings';
|
|
17
17
|
export type DynamicWidgetViewMapConstraint = Record<DynamicWidgetViews, FC<any>>;
|
|
18
18
|
export type DynamicWidgetViewMap = typeof mapViewToComponent;
|
|
19
19
|
export type SetDynamicWidgetView = <T extends DynamicWidgetViews>(view: T, props?: ComponentProps<DynamicWidgetViewMap[T]>) => void;
|
|
@@ -7,6 +7,7 @@ var _tslib = require('../../../../../../../_virtual/_tslib.cjs');
|
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var reactI18next = require('react-i18next');
|
|
10
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
10
11
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
11
12
|
var Typography = require('../../../../../components/Typography/Typography.cjs');
|
|
12
13
|
var TypographyButton = require('../../../../../components/TypographyButton/TypographyButton.cjs');
|
|
@@ -17,12 +18,12 @@ var chevronLeft = require('../../../../../shared/assets/chevron-left.cjs');
|
|
|
17
18
|
var exportPrivateKey = require('../../../../../shared/assets/export-private-key.cjs');
|
|
18
19
|
var exportRecoveryPhrase = require('../../../../../shared/assets/export-recovery-phrase.cjs');
|
|
19
20
|
require('../../../../../context/ViewContext/ViewContext.cjs');
|
|
21
|
+
var backupArrow = require('../../../../../shared/assets/backupArrow.cjs');
|
|
20
22
|
require('../../../../../shared/logger.cjs');
|
|
21
23
|
require('@dynamic-labs/wallet-book');
|
|
22
24
|
require('@dynamic-labs/utils');
|
|
23
25
|
require('../../../../../utils/constants/colors.cjs');
|
|
24
26
|
require('../../../../../utils/constants/values.cjs');
|
|
25
|
-
require('@dynamic-labs/sdk-api-core');
|
|
26
27
|
require('../../../../../shared/consts/index.cjs');
|
|
27
28
|
require('../../../../../events/dynamicEvents.cjs');
|
|
28
29
|
require('../../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
@@ -87,7 +88,7 @@ require('../../../../../context/IpConfigurationContext/IpConfigurationContext.cj
|
|
|
87
88
|
require('../../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
88
89
|
require('../../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
89
90
|
require('@hcaptcha/react-hcaptcha');
|
|
90
|
-
require('../../../context/DynamicWidgetContext.cjs');
|
|
91
|
+
var DynamicWidgetContext = require('../../../context/DynamicWidgetContext.cjs');
|
|
91
92
|
require('../../../helpers/convertExchangeKeyAndProviderEnum.cjs');
|
|
92
93
|
require('../../../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
|
|
93
94
|
require('../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
@@ -111,10 +112,11 @@ require('../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs')
|
|
|
111
112
|
var useInternalDynamicContext = require('../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
112
113
|
|
|
113
114
|
const EmbeddedWalletExportSection = () => {
|
|
114
|
-
var _a, _b, _c, _d, _e, _f;
|
|
115
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
115
116
|
const { t } = reactI18next.useTranslation();
|
|
116
117
|
const { theme } = ThemeContext.useThemeContext();
|
|
117
|
-
const { primaryWallet, user } = useInternalDynamicContext.useInternalDynamicContext();
|
|
118
|
+
const { primaryWallet, user, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
119
|
+
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
118
120
|
const { getEOAWallet } = useSmartWallets.useSmartWallets();
|
|
119
121
|
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery.usePasskeyRecovery();
|
|
120
122
|
const { initExportProcess } = useEmbeddedReveal.useEmbeddedReveal();
|
|
@@ -146,6 +148,12 @@ const EmbeddedWalletExportSection = () => {
|
|
|
146
148
|
const handleExportButtonClick = React.useCallback(() => handleExportClick(), [handleExportClick]);
|
|
147
149
|
const handleExportWithPhraseClick = React.useCallback(() => handleExportClick(true), [handleExportClick]);
|
|
148
150
|
const exportIconClasses = React.useMemo(() => `settings-view__body__section__button__icon${theme.theme.name === 'dark' ? '__stroke' : ''}`, [theme.theme.name]);
|
|
151
|
+
const isV3WaasWallet = Boolean(wallet && ((_h = (_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.key) === null || _h === void 0 ? void 0 : _h.startsWith('dynamicwaas')));
|
|
152
|
+
const isGoogleDriveBackupEnabled = Boolean((_l = (_k = (_j = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _j === void 0 ? void 0 : _j.waas) === null || _k === void 0 ? void 0 : _k.backupOptions) === null || _l === void 0 ? void 0 : _l.includes(sdkApiCore.WaasBackupOptionsEnum.GoogleDrive));
|
|
153
|
+
const shouldShowBackupOption = isV3WaasWallet && isGoogleDriveBackupEnabled;
|
|
154
|
+
const handleBackupClick = React.useCallback(() => {
|
|
155
|
+
setDynamicWidgetView('waas-backup');
|
|
156
|
+
}, [setDynamicWidgetView]);
|
|
149
157
|
if (!isEmbeddedWallet) {
|
|
150
158
|
return null;
|
|
151
159
|
}
|
|
@@ -153,7 +161,9 @@ const EmbeddedWalletExportSection = () => {
|
|
|
153
161
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
154
162
|
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(exportPrivateKey.ReactComponent, { className: exportIconClasses }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.private_key_button', children: t('dyn_settings.export_section.private_key_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }), isTurnkeyHDWallet && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'embedded-reveal-button', onClick: handleExportWithPhraseClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
155
163
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
156
|
-
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(exportRecoveryPhrase.ReactComponent, { className: exportIconClasses }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.srp_button', children: t('dyn_settings.export_section.srp_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }))
|
|
164
|
+
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(exportRecoveryPhrase.ReactComponent, { className: exportIconClasses }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.srp_button', children: t('dyn_settings.export_section.srp_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), shouldShowBackupOption && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'backup-button', onClick: handleBackupClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
165
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
166
|
+
jsxRuntime.jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsxRuntime.jsx(backupArrow.ReactComponent, { className: exportIconClasses }), jsxRuntime.jsx(Typography.Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.backup_button', children: t('dyn_settings.export_section.backup_button') })] }), endSlot: jsxRuntime.jsx(chevronLeft.ReactComponent, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }))] }));
|
|
157
167
|
};
|
|
158
168
|
|
|
159
169
|
exports.EmbeddedWalletExportSection = EmbeddedWalletExportSection;
|
|
@@ -3,6 +3,7 @@ import { __awaiter } from '../../../../../../../_virtual/_tslib.js';
|
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { useCallback, useMemo } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { WaasBackupOptionsEnum } from '@dynamic-labs/sdk-api-core';
|
|
6
7
|
import { isSessionKeyCompatibleWallet } from '@dynamic-labs/wallet-connector-core';
|
|
7
8
|
import { Typography } from '../../../../../components/Typography/Typography.js';
|
|
8
9
|
import { TypographyButton } from '../../../../../components/TypographyButton/TypographyButton.js';
|
|
@@ -13,12 +14,12 @@ import { ReactComponent as SvgChevronLeft } from '../../../../../shared/assets/c
|
|
|
13
14
|
import { ReactComponent as SvgExportPrivateKey } from '../../../../../shared/assets/export-private-key.js';
|
|
14
15
|
import { ReactComponent as SvgExportRecoveryPhrase } from '../../../../../shared/assets/export-recovery-phrase.js';
|
|
15
16
|
import '../../../../../context/ViewContext/ViewContext.js';
|
|
17
|
+
import { ReactComponent as SvgBackupArrow } from '../../../../../shared/assets/backupArrow.js';
|
|
16
18
|
import '../../../../../shared/logger.js';
|
|
17
19
|
import '@dynamic-labs/wallet-book';
|
|
18
20
|
import '@dynamic-labs/utils';
|
|
19
21
|
import '../../../../../utils/constants/colors.js';
|
|
20
22
|
import '../../../../../utils/constants/values.js';
|
|
21
|
-
import '@dynamic-labs/sdk-api-core';
|
|
22
23
|
import '../../../../../shared/consts/index.js';
|
|
23
24
|
import '../../../../../events/dynamicEvents.js';
|
|
24
25
|
import '../../../../../context/CaptchaContext/CaptchaContext.js';
|
|
@@ -83,7 +84,7 @@ import '../../../../../context/IpConfigurationContext/IpConfigurationContext.js'
|
|
|
83
84
|
import '../../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
84
85
|
import '../../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
85
86
|
import '@hcaptcha/react-hcaptcha';
|
|
86
|
-
import '../../../context/DynamicWidgetContext.js';
|
|
87
|
+
import { useWidgetContext } from '../../../context/DynamicWidgetContext.js';
|
|
87
88
|
import '../../../helpers/convertExchangeKeyAndProviderEnum.js';
|
|
88
89
|
import '../../../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
|
|
89
90
|
import '../../../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
@@ -107,10 +108,11 @@ import '../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
107
108
|
import { useInternalDynamicContext } from '../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
108
109
|
|
|
109
110
|
const EmbeddedWalletExportSection = () => {
|
|
110
|
-
var _a, _b, _c, _d, _e, _f;
|
|
111
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
111
112
|
const { t } = useTranslation();
|
|
112
113
|
const { theme } = useThemeContext();
|
|
113
|
-
const { primaryWallet, user } = useInternalDynamicContext();
|
|
114
|
+
const { primaryWallet, user, projectSettings } = useInternalDynamicContext();
|
|
115
|
+
const { setDynamicWidgetView } = useWidgetContext();
|
|
114
116
|
const { getEOAWallet } = useSmartWallets();
|
|
115
117
|
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery();
|
|
116
118
|
const { initExportProcess } = useEmbeddedReveal();
|
|
@@ -142,6 +144,12 @@ const EmbeddedWalletExportSection = () => {
|
|
|
142
144
|
const handleExportButtonClick = useCallback(() => handleExportClick(), [handleExportClick]);
|
|
143
145
|
const handleExportWithPhraseClick = useCallback(() => handleExportClick(true), [handleExportClick]);
|
|
144
146
|
const exportIconClasses = useMemo(() => `settings-view__body__section__button__icon${theme.theme.name === 'dark' ? '__stroke' : ''}`, [theme.theme.name]);
|
|
147
|
+
const isV3WaasWallet = Boolean(wallet && ((_h = (_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.key) === null || _h === void 0 ? void 0 : _h.startsWith('dynamicwaas')));
|
|
148
|
+
const isGoogleDriveBackupEnabled = Boolean((_l = (_k = (_j = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _j === void 0 ? void 0 : _j.waas) === null || _k === void 0 ? void 0 : _k.backupOptions) === null || _l === void 0 ? void 0 : _l.includes(WaasBackupOptionsEnum.GoogleDrive));
|
|
149
|
+
const shouldShowBackupOption = isV3WaasWallet && isGoogleDriveBackupEnabled;
|
|
150
|
+
const handleBackupClick = useCallback(() => {
|
|
151
|
+
setDynamicWidgetView('waas-backup');
|
|
152
|
+
}, [setDynamicWidgetView]);
|
|
145
153
|
if (!isEmbeddedWallet) {
|
|
146
154
|
return null;
|
|
147
155
|
}
|
|
@@ -149,7 +157,9 @@ const EmbeddedWalletExportSection = () => {
|
|
|
149
157
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
150
158
|
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgExportPrivateKey, { className: exportIconClasses }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.private_key_button', children: t('dyn_settings.export_section.private_key_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }), isTurnkeyHDWallet && (jsx(TypographyButton, { dataTestId: 'embedded-reveal-button', onClick: handleExportWithPhraseClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
151
159
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
152
|
-
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgExportRecoveryPhrase, { className: exportIconClasses }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.srp_button', children: t('dyn_settings.export_section.srp_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }))
|
|
160
|
+
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgExportRecoveryPhrase, { className: exportIconClasses }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.srp_button', children: t('dyn_settings.export_section.srp_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false })), shouldShowBackupOption && (jsx(TypographyButton, { dataTestId: 'backup-button', onClick: handleBackupClick, buttonClassName: 'settings-view__body__section__button', startSlot:
|
|
161
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
162
|
+
jsxs("div", { className: 'settings-view__body__section__button__start-slot', children: [jsx(SvgBackupArrow, { className: exportIconClasses }), jsx(Typography, { color: 'primary', weight: 'medium', copykey: 'dyn_settings.export_section.backup_button', children: t('dyn_settings.export_section.backup_button') })] }), endSlot: jsx(SvgChevronLeft, { className: 'settings-view__body__section__button__icon-secondary--rotate' }), showInternalLoading: false }))] }));
|
|
153
163
|
};
|
|
154
164
|
|
|
155
165
|
export { EmbeddedWalletExportSection };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var reactI18next = require('react-i18next');
|
|
9
|
+
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
10
|
+
var TypographyButton = require('../../../../components/TypographyButton/TypographyButton.cjs');
|
|
11
|
+
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
12
|
+
var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
|
|
13
|
+
var Icon = require('../../../../components/Icon/Icon.cjs');
|
|
14
|
+
var Alert = require('../../../../components/Alert/Alert.cjs');
|
|
15
|
+
var close = require('../../../../shared/assets/close.cjs');
|
|
16
|
+
var footerInfoIcon = require('../../../../shared/assets/footer-info-icon.cjs');
|
|
17
|
+
require('@dynamic-labs/iconic');
|
|
18
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
19
|
+
var filledQuestionMark = require('../../../../shared/assets/filled-question-mark.cjs');
|
|
20
|
+
var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
|
|
21
|
+
|
|
22
|
+
const WaasBackupInfoView = () => {
|
|
23
|
+
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
24
|
+
const { t } = reactI18next.useTranslation();
|
|
25
|
+
const handleBackClick = React.useCallback(() => setDynamicWidgetView('waas-backup'), [setDynamicWidgetView]);
|
|
26
|
+
const handleCloseClick = React.useCallback(() => setDynamicWidgetView('account-and-security-settings'), [setDynamicWidgetView]);
|
|
27
|
+
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleCloseClick, "data-testid": 'close-button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
28
|
+
return (jsxRuntime.jsxs("div", { className: 'waas-backup-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx("div", { className: 'send-balance-page-layout__header-content', children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup_info.title', children: t('dyn_waas.backup_info.title', 'Why backup a share') }) }) }), jsxRuntime.jsx("div", { className: 'account-wrap', children: jsxRuntime.jsx("div", { className: 'settings-view__body', children: jsxRuntime.jsxs("div", { className: 'backup-content', children: [jsxRuntime.jsx("div", { className: 'backup-icon-container', children: jsxRuntime.jsx(Icon.Icon, { color: 'brand-primary', children: jsxRuntime.jsx(filledQuestionMark.ReactComponent, { width: 64, height: 64 }) }) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup_info.description', children: t('dyn_waas.backup_info.description', 'Your account uses strong security behind the scenes. Backing up a share adds additional security to your account by requiring the share to be retrieved if your account is used on another device.') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup_info.storage', children: t('dyn_waas.backup_info.storage', 'You can store this backup share in a secure cloud.') }), jsxRuntime.jsx(Alert.Alert, { icon:
|
|
29
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
30
|
+
jsxRuntime.jsx(Icon.Icon, { size: 'medium', children: jsxRuntime.jsx(footerInfoIcon.ReactComponent, { width: 24, height: 24 }) }), variant: 'warning', copykey: 'dyn_waas.backup_info.warning_alert', children: jsxRuntime.jsxs(Typography.Typography, { variant: 'body_small', color: 'current-color', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', copykey: 'dyn_waas.backup_info.important', style: { color: 'var(--default-alert-1, #DD8500)' }, children: t('dyn_waas.backup_info.important', 'Important') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_waas.backup_info.warning', children: t('dyn_waas.backup_info.warning', "Make sure you don't lose access to the backup share or you will not be able to restore this account!") })] }) }), jsxRuntime.jsx("div", { className: 'backup-actions', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'back-button', onClick: handleBackClick, buttonClassName: 'backup-button', typographyProps: {
|
|
31
|
+
color: 'primary',
|
|
32
|
+
weight: 'bold',
|
|
33
|
+
}, copykey: 'dyn_waas.backup_info.back', buttonPadding: 'small', children: t('dyn_waas.backup_info.back', 'Back') }) })] }) }) })] }));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.WaasBackupInfoView = WaasBackupInfoView;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
6
|
+
import { TypographyButton } from '../../../../components/TypographyButton/TypographyButton.js';
|
|
7
|
+
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
8
|
+
import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
|
|
9
|
+
import { Icon } from '../../../../components/Icon/Icon.js';
|
|
10
|
+
import { Alert } from '../../../../components/Alert/Alert.js';
|
|
11
|
+
import { ReactComponent as SvgClose } from '../../../../shared/assets/close.js';
|
|
12
|
+
import { ReactComponent as SvgFooterInfoIcon } from '../../../../shared/assets/footer-info-icon.js';
|
|
13
|
+
import '@dynamic-labs/iconic';
|
|
14
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
15
|
+
import { ReactComponent as SvgFilledQuestionMark } from '../../../../shared/assets/filled-question-mark.js';
|
|
16
|
+
import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
|
|
17
|
+
|
|
18
|
+
const WaasBackupInfoView = () => {
|
|
19
|
+
const { setDynamicWidgetView } = useWidgetContext();
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
const handleBackClick = useCallback(() => setDynamicWidgetView('waas-backup'), [setDynamicWidgetView]);
|
|
22
|
+
const handleCloseClick = useCallback(() => setDynamicWidgetView('account-and-security-settings'), [setDynamicWidgetView]);
|
|
23
|
+
const closeButton = (jsx(IconButton, { type: 'button', onClick: handleCloseClick, "data-testid": 'close-button', children: jsx(SvgClose, {}) }));
|
|
24
|
+
return (jsxs("div", { className: 'waas-backup-view', children: [jsx(ModalHeader, { trailing: closeButton, children: jsx("div", { className: 'send-balance-page-layout__header-content', children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup_info.title', children: t('dyn_waas.backup_info.title', 'Why backup a share') }) }) }), jsx("div", { className: 'account-wrap', children: jsx("div", { className: 'settings-view__body', children: jsxs("div", { className: 'backup-content', children: [jsx("div", { className: 'backup-icon-container', children: jsx(Icon, { color: 'brand-primary', children: jsx(SvgFilledQuestionMark, { width: 64, height: 64 }) }) }), jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup_info.description', children: t('dyn_waas.backup_info.description', 'Your account uses strong security behind the scenes. Backing up a share adds additional security to your account by requiring the share to be retrieved if your account is used on another device.') }), jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup_info.storage', children: t('dyn_waas.backup_info.storage', 'You can store this backup share in a secure cloud.') }), jsx(Alert, { icon:
|
|
25
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
26
|
+
jsx(Icon, { size: 'medium', children: jsx(SvgFooterInfoIcon, { width: 24, height: 24 }) }), variant: 'warning', copykey: 'dyn_waas.backup_info.warning_alert', children: jsxs(Typography, { variant: 'body_small', color: 'current-color', children: [jsx(Typography, { variant: 'body_normal', copykey: 'dyn_waas.backup_info.important', style: { color: 'var(--default-alert-1, #DD8500)' }, children: t('dyn_waas.backup_info.important', 'Important') }), jsx(Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_waas.backup_info.warning', children: t('dyn_waas.backup_info.warning', "Make sure you don't lose access to the backup share or you will not be able to restore this account!") })] }) }), jsx("div", { className: 'backup-actions', children: jsx(TypographyButton, { dataTestId: 'back-button', onClick: handleBackClick, buttonClassName: 'backup-button', typographyProps: {
|
|
27
|
+
color: 'primary',
|
|
28
|
+
weight: 'bold',
|
|
29
|
+
}, copykey: 'dyn_waas.backup_info.back', buttonPadding: 'small', children: t('dyn_waas.backup_info.back', 'Back') }) })] }) }) })] }));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { WaasBackupInfoView };
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var reactI18next = require('react-i18next');
|
|
10
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
11
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
12
|
+
require('@dynamic-labs-sdk/client/core');
|
|
13
|
+
require('../../../../client/client.cjs');
|
|
14
|
+
require('@dynamic-labs-sdk/client');
|
|
15
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
16
|
+
require('../../../../utils/constants/values.cjs');
|
|
17
|
+
require('@dynamic-labs/utils');
|
|
18
|
+
require('@dynamic-labs/multi-wallet');
|
|
19
|
+
require('react-international-phone');
|
|
20
|
+
require('../../../../utils/constants/colors.cjs');
|
|
21
|
+
require('@dynamic-labs/iconic');
|
|
22
|
+
var check = require('../../../../shared/assets/check.cjs');
|
|
23
|
+
var close = require('../../../../shared/assets/close.cjs');
|
|
24
|
+
var questionMark = require('../../../../shared/assets/question-mark.cjs');
|
|
25
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
26
|
+
var backupWaas = require('../../../../shared/assets/backup-waas.cjs');
|
|
27
|
+
var googleDrive = require('../../../../shared/assets/google-drive.cjs');
|
|
28
|
+
require('../../../../shared/logger.cjs');
|
|
29
|
+
require('@dynamic-labs/wallet-book');
|
|
30
|
+
require('../../../../shared/consts/index.cjs');
|
|
31
|
+
require('../../../../store/state/nonce/nonce.cjs');
|
|
32
|
+
require('@dynamic-labs/locale');
|
|
33
|
+
require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
34
|
+
require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
35
|
+
require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
36
|
+
require('../../../../events/dynamicEvents.cjs');
|
|
37
|
+
var useUser = require('../../../../client/extension/user/useUser/useUser.cjs');
|
|
38
|
+
var ErrorContainer = require('../../../../components/ErrorContainer/ErrorContainer.cjs');
|
|
39
|
+
var Icon = require('../../../../components/Icon/Icon.cjs');
|
|
40
|
+
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
41
|
+
var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
|
|
42
|
+
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
43
|
+
var TypographyButton = require('../../../../components/TypographyButton/TypographyButton.cjs');
|
|
44
|
+
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
45
|
+
require('../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
46
|
+
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
47
|
+
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
48
|
+
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
49
|
+
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
50
|
+
require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
51
|
+
require('../../../../store/state/authMode/authMode.cjs');
|
|
52
|
+
require('../../../../context/VerificationContext/VerificationContext.cjs');
|
|
53
|
+
require('react-dom');
|
|
54
|
+
require('../../../../utils/functions/compareChains/compareChains.cjs');
|
|
55
|
+
require('../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
56
|
+
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
57
|
+
require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
58
|
+
var utils = require('../../../../utils/hooks/useTransactionSimulation/utils/utils.cjs');
|
|
59
|
+
require('bs58');
|
|
60
|
+
var useSocialAccounts = require('../../../../utils/hooks/useSocialAccounts/useSocialAccounts.cjs');
|
|
61
|
+
require('yup');
|
|
62
|
+
require('../../../../context/MockContext/MockContext.cjs');
|
|
63
|
+
require('../../../../views/CollectUserDataView/useFields.cjs');
|
|
64
|
+
require('../../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
65
|
+
require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
66
|
+
require('@dynamic-labs/rpc-providers');
|
|
67
|
+
require('../../../../store/state/walletOptions/walletOptions.cjs');
|
|
68
|
+
require('../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
69
|
+
require('../../../../components/Alert/Alert.cjs');
|
|
70
|
+
require('../../../../context/WalletContext/WalletContext.cjs');
|
|
71
|
+
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
72
|
+
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
73
|
+
require('../../../../components/Input/Input.cjs');
|
|
74
|
+
require('../../../../components/IsBrowser/IsBrowser.cjs');
|
|
75
|
+
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
76
|
+
require('../../../../components/OverlayCard/OverlayCard.cjs');
|
|
77
|
+
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
78
|
+
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
79
|
+
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
80
|
+
require('../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
81
|
+
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
82
|
+
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
83
|
+
require('react-focus-lock');
|
|
84
|
+
require('qrcode');
|
|
85
|
+
require('formik');
|
|
86
|
+
require('../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
|
|
87
|
+
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
88
|
+
require('../../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
89
|
+
require('../../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
90
|
+
require('../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
91
|
+
require('../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
92
|
+
require('@hcaptcha/react-hcaptcha');
|
|
93
|
+
require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
94
|
+
var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
|
|
95
|
+
require('../../helpers/convertExchangeKeyAndProviderEnum.cjs');
|
|
96
|
+
require('../../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
|
|
97
|
+
require('../../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
98
|
+
require('../../../../context/FooterAnimationContext/index.cjs');
|
|
99
|
+
require('@dynamic-labs/types');
|
|
100
|
+
require('../../../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
101
|
+
require('../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
|
|
102
|
+
require('../../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
103
|
+
require('../../../../context/OnrampContext/OnrampContext.cjs');
|
|
104
|
+
var useRefreshUser = require('../../../../utils/hooks/useRefreshUser/useRefreshUser.cjs');
|
|
105
|
+
require('../../../../store/state/sendBalances.cjs');
|
|
106
|
+
require('../../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
107
|
+
require('../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
108
|
+
require('../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
109
|
+
require('../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
110
|
+
require('../../components/PasskeyCard/PasskeyCard.cjs');
|
|
111
|
+
require('../CryptoComOnramp/CryptoComOnramp.cjs');
|
|
112
|
+
require('../../../../../index.cjs');
|
|
113
|
+
require('../ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
114
|
+
require('../../../../store/state/tokenBalances.cjs');
|
|
115
|
+
require('../../../../store/state/multichainBalances.cjs');
|
|
116
|
+
require('../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
117
|
+
var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
118
|
+
|
|
119
|
+
const WaasBackupView = () => {
|
|
120
|
+
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
121
|
+
const user = useUser.useUser();
|
|
122
|
+
const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
123
|
+
const refresh = useRefreshUser.useRefreshUser();
|
|
124
|
+
const { linkSocialAccount, isLinked, isProcessingForProvider } = useSocialAccounts.useSocialAccounts();
|
|
125
|
+
const { t } = reactI18next.useTranslation();
|
|
126
|
+
const [errorMessage, setErrorMessage] = React.useState(null);
|
|
127
|
+
const isGoogleLinked = isLinked(sdkApiCore.ProviderEnum.Google);
|
|
128
|
+
const checkGoogleDriveBackup = React.useCallback(() => {
|
|
129
|
+
var _a, _b;
|
|
130
|
+
if (!user || !primaryWallet)
|
|
131
|
+
return false;
|
|
132
|
+
const walletCredential = (_a = user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find((cred) => cred.walletName === 'dynamicwaas' &&
|
|
133
|
+
cred.address === primaryWallet.address);
|
|
134
|
+
const keyShares = (_b = walletCredential === null || walletCredential === void 0 ? void 0 : walletCredential.walletProperties) === null || _b === void 0 ? void 0 : _b.keyShares;
|
|
135
|
+
if (!keyShares || !Array.isArray(keyShares))
|
|
136
|
+
return false;
|
|
137
|
+
return keyShares.some((keyShare) => keyShare &&
|
|
138
|
+
typeof keyShare === 'object' &&
|
|
139
|
+
'backupLocation' in keyShare &&
|
|
140
|
+
keyShare.backupLocation === 'googleDrive');
|
|
141
|
+
}, [user, primaryWallet]);
|
|
142
|
+
const isBackedUp = React.useMemo(() => checkGoogleDriveBackup(), [checkGoogleDriveBackup]);
|
|
143
|
+
const handleBackClick = React.useCallback(() => setDynamicWidgetView('account-and-security-settings'), [setDynamicWidgetView]);
|
|
144
|
+
const handleInfoClick = React.useCallback(() => {
|
|
145
|
+
setDynamicWidgetView('waas-backup-info');
|
|
146
|
+
}, [setDynamicWidgetView]);
|
|
147
|
+
const handleBackupWalletClick = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
148
|
+
setErrorMessage(null);
|
|
149
|
+
try {
|
|
150
|
+
if (!primaryWallet) {
|
|
151
|
+
throw new Error('No primary wallet found');
|
|
152
|
+
}
|
|
153
|
+
if (!isGoogleLinked) {
|
|
154
|
+
yield linkSocialAccount(sdkApiCore.ProviderEnum.Google, {
|
|
155
|
+
forcePopup: true,
|
|
156
|
+
showWidgetAfterConnection: false,
|
|
157
|
+
});
|
|
158
|
+
yield refresh();
|
|
159
|
+
}
|
|
160
|
+
let waasConnector;
|
|
161
|
+
if (walletConnectorCore.isDynamicWaasConnector(primaryWallet.connector)) {
|
|
162
|
+
waasConnector = primaryWallet.connector;
|
|
163
|
+
}
|
|
164
|
+
else if (utils.isZeroDevConnector(primaryWallet.connector)) {
|
|
165
|
+
const { eoaConnector } = primaryWallet.connector;
|
|
166
|
+
if (!eoaConnector || !walletConnectorCore.isDynamicWaasConnector(eoaConnector)) {
|
|
167
|
+
throw new Error('ZeroDev connector must have a WaaS EOA connector');
|
|
168
|
+
}
|
|
169
|
+
waasConnector = eoaConnector;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
throw new Error('Not a supported connector type');
|
|
173
|
+
}
|
|
174
|
+
yield waasConnector.backupKeySharesToGoogleDrive({
|
|
175
|
+
accountAddress: primaryWallet.address,
|
|
176
|
+
});
|
|
177
|
+
yield refresh();
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
setErrorMessage(t('dyn_waas.backup.error'));
|
|
181
|
+
}
|
|
182
|
+
}), [primaryWallet, refresh, isGoogleLinked, linkSocialAccount, t]);
|
|
183
|
+
const infoButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleInfoClick, "data-testid": 'info-button', children: jsxRuntime.jsx(questionMark.ReactComponent, {}) }));
|
|
184
|
+
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleBackClick, "data-testid": 'close-button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
185
|
+
return (jsxRuntime.jsxs("div", { className: 'waas-backup-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: infoButton, trailing: closeButton, children: jsxRuntime.jsx("div", { className: 'send-balance-page-layout__header-content', children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.title', children: t('dyn_waas.backup.title') }) }) }), jsxRuntime.jsx("div", { className: 'account-wrap', children: jsxRuntime.jsxs("div", { className: 'settings-view__body', children: [errorMessage && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { variant: 'error', withIcon: false, children: errorMessage })), jsxRuntime.jsxs("div", { className: 'backup-content', children: [jsxRuntime.jsx("div", { className: 'backup-icon-container', children: jsxRuntime.jsx(Icon.Icon, { color: 'brand-primary', children: jsxRuntime.jsx(backupWaas.ReactComponent, { width: 64, height: 64 }) }) }), jsxRuntime.jsx("div", { className: 'backup-subtitle', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup.subtitle', children: t('dyn_waas.backup.subtitle') }) }), jsxRuntime.jsx("div", { className: 'google-drive-section', children: jsxRuntime.jsxs("div", { className: 'google-drive-container', children: [jsxRuntime.jsxs("div", { className: 'google-drive-header', children: [jsxRuntime.jsx(googleDrive.ReactComponent, { className: 'google-drive-icon' }), jsxRuntime.jsxs("div", { className: 'google-drive-text', children: [jsxRuntime.jsxs("div", { className: 'google-drive-title-row', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', weight: 'bold', copykey: 'dyn_waas.backup.google_drive', children: t('dyn_waas.backup.google_drive') }), isBackedUp && (jsxRuntime.jsx("div", { className: 'backed-up-pill', children: jsxRuntime.jsx(Typography.Typography, { color: 'inherit', weight: 'bold', copykey: 'dyn_waas.backup.backed_up', children: t('dyn_waas.backup.backed_up') }) }))] }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', copykey: 'dyn_waas.backup.google_drive_subtitle', children: t('dyn_waas.backup.google_drive_subtitle') })] }), isBackedUp && (jsxRuntime.jsx(check.ReactComponent, { className: 'google-drive-check-icon' }))] }), !isBackedUp && (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'backup-wallet-button', onClick: handleBackupWalletClick, buttonClassName: 'backup-button', disabled: isProcessingForProvider(sdkApiCore.ProviderEnum.Google), typographyProps: {
|
|
186
|
+
color: 'primary',
|
|
187
|
+
weight: 'bold',
|
|
188
|
+
}, copykey: 'dyn_waas.backup.back_up', buttonPadding: 'small', children: t('dyn_waas.backup.back_up') }))] }) })] })] }) })] }));
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
exports.WaasBackupView = WaasBackupView;
|