@dynamic-labs/sdk-react-core 4.79.0 → 4.79.2

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/package.cjs +3 -3
  3. package/package.js +3 -3
  4. package/package.json +14 -14
  5. package/src/index.cjs +2 -2
  6. package/src/index.js +1 -1
  7. package/src/lib/context/ViewContext/types/index.d.ts +1 -1
  8. package/src/lib/styles/index.shadow.cjs +1 -1
  9. package/src/lib/styles/index.shadow.js +1 -1
  10. package/src/lib/utils/constants/authViewLayoutChecks.cjs +2 -0
  11. package/src/lib/utils/constants/authViewLayoutChecks.js +2 -0
  12. package/src/lib/utils/functions/animationFrameTimeout/animationFrameTimeout.cjs +8 -14
  13. package/src/lib/utils/functions/animationFrameTimeout/animationFrameTimeout.js +8 -14
  14. package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs +7 -2
  15. package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.d.ts +2 -1
  16. package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js +7 -2
  17. package/src/lib/utils/hooks/useWalletBackup/useWalletBackup.cjs +1 -1
  18. package/src/lib/utils/hooks/useWalletBackup/useWalletBackup.js +1 -1
  19. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +1 -1
  20. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +1 -1
  21. package/src/lib/views/viewToComponentMap.cjs +2 -0
  22. package/src/lib/views/viewToComponentMap.d.ts +1 -0
  23. package/src/lib/views/viewToComponentMap.js +2 -0
  24. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupCloudProviderView.cjs +19 -4
  25. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupCloudProviderView.js +19 -4
  26. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupGrantAccessView.cjs +50 -0
  27. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupGrantAccessView.d.ts +2 -0
  28. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupGrantAccessView.js +46 -0
  29. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView.cjs +23 -3
  30. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView.js +23 -3
  31. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/index.d.ts +1 -0
@@ -67,6 +67,7 @@ const viewsThatHideHeader = [
67
67
  'waas-backup-info-view',
68
68
  'waas-backup-cloud-provider-view',
69
69
  'waas-backup-download-view',
70
+ 'waas-backup-grant-access-view',
70
71
  'waas-backup-progress-view',
71
72
  'waas-backup-success-view',
72
73
  'setup-password-for-wallet-creation',
@@ -159,6 +160,7 @@ const viewsThatHideCloseButton = [
159
160
  'waas-backup-info-view',
160
161
  'waas-backup-cloud-provider-view',
161
162
  'waas-backup-download-view',
163
+ 'waas-backup-grant-access-view',
162
164
  'waas-backup-progress-view',
163
165
  'waas-backup-success-view',
164
166
  'device-registration',
@@ -63,6 +63,7 @@ const viewsThatHideHeader = [
63
63
  'waas-backup-info-view',
64
64
  'waas-backup-cloud-provider-view',
65
65
  'waas-backup-download-view',
66
+ 'waas-backup-grant-access-view',
66
67
  'waas-backup-progress-view',
67
68
  'waas-backup-success-view',
68
69
  'setup-password-for-wallet-creation',
@@ -155,6 +156,7 @@ const viewsThatHideCloseButton = [
155
156
  'waas-backup-info-view',
156
157
  'waas-backup-cloud-provider-view',
157
158
  'waas-backup-download-view',
159
+ 'waas-backup-grant-access-view',
158
160
  'waas-backup-progress-view',
159
161
  'waas-backup-success-view',
160
162
  'device-registration',
@@ -3,25 +3,19 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
+ // Implemented with setTimeout rather than requestAnimationFrame: rAF is paused
7
+ // or throttled to ~1Hz when the tab is backgrounded, and is also starved by
8
+ // long-running JS, which caused modal transitions to get stuck at opacity 0.
6
9
  const animationFrameTimeout = (callback, duration) => {
7
- const startTime = performance.now();
8
10
  const canceller = { id: -1 };
9
- const tick = () => {
10
- canceller.id = requestAnimationFrame((now) => {
11
- if (now - startTime > duration) {
12
- callback();
13
- }
14
- else {
15
- tick();
16
- }
17
- });
18
- };
19
- tick();
11
+ canceller.id = window.setTimeout(callback, duration);
20
12
  return canceller;
21
13
  };
22
14
  const clearAnimationFrameTimeout = (canceller) => {
23
- if (canceller.id >= 0)
24
- cancelAnimationFrame(canceller.id);
15
+ if (canceller.id >= 0) {
16
+ clearTimeout(canceller.id);
17
+ canceller.id = -1;
18
+ }
25
19
  };
26
20
 
27
21
  exports.animationFrameTimeout = animationFrameTimeout;
@@ -1,23 +1,17 @@
1
1
  'use client'
2
+ // Implemented with setTimeout rather than requestAnimationFrame: rAF is paused
3
+ // or throttled to ~1Hz when the tab is backgrounded, and is also starved by
4
+ // long-running JS, which caused modal transitions to get stuck at opacity 0.
2
5
  const animationFrameTimeout = (callback, duration) => {
3
- const startTime = performance.now();
4
6
  const canceller = { id: -1 };
5
- const tick = () => {
6
- canceller.id = requestAnimationFrame((now) => {
7
- if (now - startTime > duration) {
8
- callback();
9
- }
10
- else {
11
- tick();
12
- }
13
- });
14
- };
15
- tick();
7
+ canceller.id = window.setTimeout(callback, duration);
16
8
  return canceller;
17
9
  };
18
10
  const clearAnimationFrameTimeout = (canceller) => {
19
- if (canceller.id >= 0)
20
- cancelAnimationFrame(canceller.id);
11
+ if (canceller.id >= 0) {
12
+ clearTimeout(canceller.id);
13
+ canceller.id = -1;
14
+ }
21
15
  };
22
16
 
23
17
  export { animationFrameTimeout, clearAnimationFrameTimeout };
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var React = require('react');
7
7
 
8
- const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tempoNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, }) => React.useMemo(() => {
9
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
8
+ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tempoNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, midnightNetworksOverrides, }) => React.useMemo(() => {
9
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
10
10
  const networks = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks;
11
11
  if (!networks)
12
12
  return {};
@@ -23,6 +23,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
23
23
  const bitcoin = networks.find((configurations) => configurations.chainName === 'bitcoin');
24
24
  const aleo = networks.find((configurations) => configurations.chainName === 'aleo');
25
25
  const tempo = networks.find((configurations) => configurations.chainName === 'tempo');
26
+ const midnight = networks.find((configurations) => configurations.chainName === 'midnight');
26
27
  let cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, Number.parseInt));
27
28
  cosmosNetworks = overrideNetworks(cosmosNetworkOverrides, cosmosNetworks);
28
29
  let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, Number.parseInt));
@@ -54,6 +55,8 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
54
55
  aleoNetworks = overrideNetworks(aleoNetworksOverrides, aleoNetworks);
55
56
  let tempoNetworks = (_o = tempo === null || tempo === void 0 ? void 0 : tempo.networks) === null || _o === void 0 ? void 0 : _o.map((net) => createNetwork(net, Number.parseInt));
56
57
  tempoNetworks = overrideNetworks(tempoNetworksOverrides, tempoNetworks);
58
+ let midnightNetworks = (_p = midnight === null || midnight === void 0 ? void 0 : midnight.networks) === null || _p === void 0 ? void 0 : _p.map((net) => createNetwork(net));
59
+ midnightNetworks = overrideNetworks(midnightNetworksOverrides, midnightNetworks);
57
60
  const networkConfigurations = {
58
61
  aleo: aleoNetworks,
59
62
  aptos: aptosNetworks,
@@ -61,6 +64,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
61
64
  cosmos: cosmosNetworks,
62
65
  eclipse: eclipseNetworks,
63
66
  evm: evmNetworks,
67
+ midnight: midnightNetworks,
64
68
  solana: solanaNetworks,
65
69
  starknet: starknetNetworks,
66
70
  stellar: stellarNetworks,
@@ -76,6 +80,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
76
80
  cosmosNetworkOverrides,
77
81
  evmNetworksOverrides,
78
82
  solanaNetworksOverrides,
83
+ midnightNetworksOverrides,
79
84
  tronNetworksOverrides,
80
85
  aptosNetworksOverrides,
81
86
  tempoNetworksOverrides,
@@ -12,6 +12,7 @@ type UseNetworkConfigurationsFromProjectSettingsProps = {
12
12
  tempoNetworksOverrides?: NetworksOverrides;
13
13
  tonNetworksOverrides?: NetworksOverrides;
14
14
  bitcoinNetworksOverrides?: NetworksOverrides;
15
+ midnightNetworksOverrides?: NetworksOverrides;
15
16
  };
16
- export declare const useNetworkConfigurationsFromProjectSettings: ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tempoNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, }: UseNetworkConfigurationsFromProjectSettingsProps) => {};
17
+ export declare const useNetworkConfigurationsFromProjectSettings: ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tempoNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, midnightNetworksOverrides, }: UseNetworkConfigurationsFromProjectSettingsProps) => {};
17
18
  export {};
@@ -1,8 +1,8 @@
1
1
  'use client'
2
2
  import { useMemo } from 'react';
3
3
 
4
- const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tempoNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, }) => useMemo(() => {
5
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
4
+ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetworksOverrides, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, tronNetworksOverrides, aptosNetworksOverrides, stellarNetworksOverrides, tempoNetworksOverrides, tonNetworksOverrides, bitcoinNetworksOverrides, midnightNetworksOverrides, }) => useMemo(() => {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
6
6
  const networks = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks;
7
7
  if (!networks)
8
8
  return {};
@@ -19,6 +19,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
19
19
  const bitcoin = networks.find((configurations) => configurations.chainName === 'bitcoin');
20
20
  const aleo = networks.find((configurations) => configurations.chainName === 'aleo');
21
21
  const tempo = networks.find((configurations) => configurations.chainName === 'tempo');
22
+ const midnight = networks.find((configurations) => configurations.chainName === 'midnight');
22
23
  let cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, Number.parseInt));
23
24
  cosmosNetworks = overrideNetworks(cosmosNetworkOverrides, cosmosNetworks);
24
25
  let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, Number.parseInt));
@@ -50,6 +51,8 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
50
51
  aleoNetworks = overrideNetworks(aleoNetworksOverrides, aleoNetworks);
51
52
  let tempoNetworks = (_o = tempo === null || tempo === void 0 ? void 0 : tempo.networks) === null || _o === void 0 ? void 0 : _o.map((net) => createNetwork(net, Number.parseInt));
52
53
  tempoNetworks = overrideNetworks(tempoNetworksOverrides, tempoNetworks);
54
+ let midnightNetworks = (_p = midnight === null || midnight === void 0 ? void 0 : midnight.networks) === null || _p === void 0 ? void 0 : _p.map((net) => createNetwork(net));
55
+ midnightNetworks = overrideNetworks(midnightNetworksOverrides, midnightNetworks);
53
56
  const networkConfigurations = {
54
57
  aleo: aleoNetworks,
55
58
  aptos: aptosNetworks,
@@ -57,6 +60,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
57
60
  cosmos: cosmosNetworks,
58
61
  eclipse: eclipseNetworks,
59
62
  evm: evmNetworks,
63
+ midnight: midnightNetworks,
60
64
  solana: solanaNetworks,
61
65
  starknet: starknetNetworks,
62
66
  stellar: stellarNetworks,
@@ -72,6 +76,7 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, aleoNetw
72
76
  cosmosNetworkOverrides,
73
77
  evmNetworksOverrides,
74
78
  solanaNetworksOverrides,
79
+ midnightNetworksOverrides,
75
80
  tronNetworksOverrides,
76
81
  aptosNetworksOverrides,
77
82
  tempoNetworksOverrides,
@@ -79,6 +79,7 @@ require('../useSubdomainCheck/useSubdomainCheck.cjs');
79
79
  require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
80
80
  require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
81
81
  var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
82
+ var useRefreshAuth = require('../useRefreshAuth/useRefreshAuth.cjs');
82
83
  var types = require('./types.cjs');
83
84
  var cloudProviders = require('./cloudProviders.cjs');
84
85
  require('@dynamic-labs/types');
@@ -96,7 +97,6 @@ require('../../../context/FooterAnimationContext/index.cjs');
96
97
  require('../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
97
98
  require('../../../context/PasskeyContext/PasskeyContext.cjs');
98
99
  require('../../../context/OnrampContext/OnrampContext.cjs');
99
- var useRefreshAuth = require('../useRefreshAuth/useRefreshAuth.cjs');
100
100
  require('../../../store/state/sendBalances.cjs');
101
101
  require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
102
102
  require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
@@ -75,6 +75,7 @@ import '../useSubdomainCheck/useSubdomainCheck.js';
75
75
  import '../../../context/WalletGroupContext/WalletGroupContext.js';
76
76
  import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
77
77
  import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
78
+ import { useRefreshAuth } from '../useRefreshAuth/useRefreshAuth.js';
78
79
  import { CloudBackupProvider } from './types.js';
79
80
  import { getSupportedProviders, CLOUD_PROVIDER_CONFIGS } from './cloudProviders.js';
80
81
  import '@dynamic-labs/types';
@@ -92,7 +93,6 @@ import '../../../context/FooterAnimationContext/index.js';
92
93
  import '../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
93
94
  import '../../../context/PasskeyContext/PasskeyContext.js';
94
95
  import '../../../context/OnrampContext/OnrampContext.js';
95
- import { useRefreshAuth } from '../useRefreshAuth/useRefreshAuth.js';
96
96
  import '../../../store/state/sendBalances.js';
97
97
  import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
98
98
  import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
@@ -83,6 +83,7 @@ require('../useSubdomainCheck/useSubdomainCheck.cjs');
83
83
  require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
84
84
  require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
85
85
  var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
86
+ var useRefreshAuth = require('../useRefreshAuth/useRefreshAuth.cjs');
86
87
  require('../useWalletBackup/useWalletBackup.cjs');
87
88
  require('../useWalletBackup/types.cjs');
88
89
  require('../useWalletBackup/cloudProviders.cjs');
@@ -98,7 +99,6 @@ require('../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cj
98
99
  require('../../../context/PasskeyContext/PasskeyContext.cjs');
99
100
  require('../../../context/OnrampContext/OnrampContext.cjs');
100
101
  var waas = require('../../../data/api/waas/waas.cjs');
101
- var useRefreshAuth = require('../useRefreshAuth/useRefreshAuth.cjs');
102
102
  require('../../../store/state/sendBalances.cjs');
103
103
  require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
104
104
  require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
@@ -79,6 +79,7 @@ import '../useSubdomainCheck/useSubdomainCheck.js';
79
79
  import '../../../context/WalletGroupContext/WalletGroupContext.js';
80
80
  import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
81
81
  import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
82
+ import { useRefreshAuth } from '../useRefreshAuth/useRefreshAuth.js';
82
83
  import '../useWalletBackup/useWalletBackup.js';
83
84
  import '../useWalletBackup/types.js';
84
85
  import '../useWalletBackup/cloudProviders.js';
@@ -94,7 +95,6 @@ import '../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js'
94
95
  import '../../../context/PasskeyContext/PasskeyContext.js';
95
96
  import '../../../context/OnrampContext/OnrampContext.js';
96
97
  import { updateWaasWalletSettings } from '../../../data/api/waas/waas.js';
97
- import { useRefreshAuth } from '../useRefreshAuth/useRefreshAuth.js';
98
98
  import '../../../store/state/sendBalances.js';
99
99
  import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
100
100
  import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
@@ -10,6 +10,7 @@ require('@dynamic-labs/iconic');
10
10
  require('../context/ViewContext/ViewContext.cjs');
11
11
  var WaasBackupCloudProviderView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupCloudProviderView.cjs');
12
12
  var WaasBackupDownloadView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupDownloadView.cjs');
13
+ var WaasBackupGrantAccessView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupGrantAccessView.cjs');
13
14
  var WaasBackupInfoView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.cjs');
14
15
  var WaasBackupProgressView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView.cjs');
15
16
  var WaasBackupSuccessView = require('../widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView.cjs');
@@ -272,6 +273,7 @@ const viewToComponentMap = {
272
273
  'verify-sms': SmsVerification.SmsVerification,
273
274
  'waas-backup-cloud-provider-view': WaasBackupCloudProviderView.WaasBackupCloudProviderView,
274
275
  'waas-backup-download-view': WaasBackupDownloadView.WaasBackupDownloadView,
276
+ 'waas-backup-grant-access-view': WaasBackupGrantAccessView.WaasBackupGrantAccessView,
275
277
  'waas-backup-info-view': WaasBackupInfoView.WaasBackupInfoView,
276
278
  'waas-backup-progress-view': WaasBackupProgressView.WaasBackupProgressView,
277
279
  'waas-backup-success-view': WaasBackupSuccessView.WaasBackupSuccessView,
@@ -119,6 +119,7 @@ export declare const viewToComponentMap: {
119
119
  'verify-sms': import("react").FC;
120
120
  'waas-backup-cloud-provider-view': import("react").FC;
121
121
  'waas-backup-download-view': import("react").FC;
122
+ 'waas-backup-grant-access-view': import("react").FC;
122
123
  'waas-backup-info-view': import("react").FC;
123
124
  'waas-backup-progress-view': import("react").FC<import("../widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView").WaasBackupProgressViewProps>;
124
125
  'waas-backup-success-view': import("react").FC<import("../widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView").WaasBackupSuccessViewProps>;
@@ -6,6 +6,7 @@ import '@dynamic-labs/iconic';
6
6
  import '../context/ViewContext/ViewContext.js';
7
7
  import { WaasBackupCloudProviderView } from '../widgets/DynamicWidget/views/WaasBackupView/WaasBackupCloudProviderView.js';
8
8
  import { WaasBackupDownloadView } from '../widgets/DynamicWidget/views/WaasBackupView/WaasBackupDownloadView.js';
9
+ import { WaasBackupGrantAccessView } from '../widgets/DynamicWidget/views/WaasBackupView/WaasBackupGrantAccessView.js';
9
10
  import { WaasBackupInfoView } from '../widgets/DynamicWidget/views/WaasBackupView/WaasBackupInfoView.js';
10
11
  import { WaasBackupProgressView } from '../widgets/DynamicWidget/views/WaasBackupView/WaasBackupProgressView.js';
11
12
  import { WaasBackupSuccessView } from '../widgets/DynamicWidget/views/WaasBackupView/WaasBackupSuccessView.js';
@@ -268,6 +269,7 @@ const viewToComponentMap = {
268
269
  'verify-sms': SmsVerification,
269
270
  'waas-backup-cloud-provider-view': WaasBackupCloudProviderView,
270
271
  'waas-backup-download-view': WaasBackupDownloadView,
272
+ 'waas-backup-grant-access-view': WaasBackupGrantAccessView,
271
273
  'waas-backup-info-view': WaasBackupInfoView,
272
274
  'waas-backup-progress-view': WaasBackupProgressView,
273
275
  'waas-backup-success-view': WaasBackupSuccessView,
@@ -15,9 +15,10 @@ var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
15
15
  var chevronLeft = require('../../../../shared/assets/chevron-left.cjs');
16
16
  var questionMark = require('../../../../shared/assets/question-mark.cjs');
17
17
  require('@dynamic-labs/iconic');
18
+ var useGoogleDriveBackupReadiness = require('../../../../utils/hooks/useGoogleDriveBackupReadiness/useGoogleDriveBackupReadiness.cjs');
18
19
  var useSocialAccounts = require('../../../../utils/hooks/useSocialAccounts/useSocialAccounts.cjs');
19
20
  var useWalletBackup = require('../../../../utils/hooks/useWalletBackup/useWalletBackup.cjs');
20
- require('../../../../utils/hooks/useWalletBackup/types.cjs');
21
+ var types = require('../../../../utils/hooks/useWalletBackup/types.cjs');
21
22
  var BackupStepper = require('./BackupStepper.cjs');
22
23
 
23
24
  const WaasBackupCloudProviderView = () => {
@@ -26,6 +27,7 @@ const WaasBackupCloudProviderView = () => {
26
27
  const { t } = reactI18next.useTranslation();
27
28
  const { isProcessingForProvider, error: socialError } = useSocialAccounts.useSocialAccounts();
28
29
  const { ensureProviderLinked, getSupportedProviders } = useWalletBackup.useWalletBackup();
30
+ const { check: checkDriveReadiness, isChecking: isCheckingDriveReadiness } = useGoogleDriveBackupReadiness.useGoogleDriveBackupReadiness();
29
31
  const [errorMessage, setErrorMessage] = React.useState(null);
30
32
  const providers = getSupportedProviders();
31
33
  const handleBackClick = React.useCallback(() => goBack(), [goBack]);
@@ -44,13 +46,26 @@ const WaasBackupCloudProviderView = () => {
44
46
  return;
45
47
  }
46
48
  }
49
+ if (provider === types.CloudBackupProvider.GoogleDrive) {
50
+ const readiness = yield checkDriveReadiness();
51
+ if (readiness.status === 'needs-access') {
52
+ pushView('waas-backup-grant-access-view');
53
+ return;
54
+ }
55
+ if (readiness.status === 'error') {
56
+ setErrorMessage(t('dyn_waas.backup.error'));
57
+ return;
58
+ }
59
+ }
47
60
  pushView('waas-backup-progress-view', { provider });
48
- }), [ensureProviderLinked, pushView, providers, t]);
61
+ }), [checkDriveReadiness, ensureProviderLinked, pushView, providers, t]);
49
62
  const backButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleBackClick, "data-testid": 'back-button', children: jsxRuntime.jsx(chevronLeft.ReactComponent, {}) }));
50
63
  const infoButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleInfoClick, "data-testid": 'info-button', children: jsxRuntime.jsx(questionMark.ReactComponent, {}) }));
51
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, trailing: infoButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.title', children: t('dyn_waas.backup.title') }) }), jsxRuntime.jsx("div", { className: 'waas-backup-view', children: jsxRuntime.jsxs("div", { className: 'waas-backup-view__body', children: [jsxRuntime.jsx(BackupStepper.BackupStepper, { currentStep: 0, completedSteps: 0 }), (errorMessage || socialError) && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { variant: 'error', withIcon: false, children: (_a = socialError === null || socialError === void 0 ? void 0 : socialError.message) !== null && _a !== void 0 ? _a : errorMessage })), jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.cloud_backup_title', className: 'waas-backup-view__cloud-title', children: t('dyn_waas.backup.cloud_backup_title', '1. Cloud Backup') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_waas.backup.cloud_backup_subtitle', className: 'waas-backup-view__cloud-subtitle', children: t('dyn_waas.backup.cloud_backup_subtitle', 'Back up your first key share to a cloud provider') }), providers.map((providerConfig) => (jsxRuntime.jsxs("button", { type: 'button', className: 'waas-backup-view__provider-button', onClick: () => handleProviderClick(providerConfig.id), disabled: providerConfig.requiresOAuth &&
64
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, trailing: infoButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.title', children: t('dyn_waas.backup.title') }) }), jsxRuntime.jsx("div", { className: 'waas-backup-view', children: jsxRuntime.jsxs("div", { className: 'waas-backup-view__body', children: [jsxRuntime.jsx(BackupStepper.BackupStepper, { currentStep: 0, completedSteps: 0 }), (errorMessage || socialError) && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { variant: 'error', withIcon: false, children: (_a = socialError === null || socialError === void 0 ? void 0 : socialError.message) !== null && _a !== void 0 ? _a : errorMessage })), jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.cloud_backup_title', className: 'waas-backup-view__cloud-title', children: t('dyn_waas.backup.cloud_backup_title', '1. Cloud Backup') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_waas.backup.cloud_backup_subtitle', className: 'waas-backup-view__cloud-subtitle', children: t('dyn_waas.backup.cloud_backup_subtitle', 'Back up your first key share to a cloud provider') }), providers.map((providerConfig) => (jsxRuntime.jsxs("button", { type: 'button', className: 'waas-backup-view__provider-button', onClick: () => handleProviderClick(providerConfig.id), disabled: (providerConfig.requiresOAuth &&
52
65
  providerConfig.oauthProvider &&
53
- isProcessingForProvider(providerConfig.oauthProvider), "data-testid": `${providerConfig.id}-button`, children: [providerConfig.icon, jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', children: t(`dyn_waas.backup.backup_to_${providerConfig.id}`, `Backup to ${providerConfig.name}`) })] }, providerConfig.id)))] }) })] }));
66
+ isProcessingForProvider(providerConfig.oauthProvider)) ||
67
+ (providerConfig.id === types.CloudBackupProvider.GoogleDrive &&
68
+ isCheckingDriveReadiness), "data-testid": `${providerConfig.id}-button`, children: [providerConfig.icon, jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', children: t(`dyn_waas.backup.backup_to_${providerConfig.id}`, `Backup to ${providerConfig.name}`) })] }, providerConfig.id)))] }) })] }));
54
69
  };
55
70
 
56
71
  exports.WaasBackupCloudProviderView = WaasBackupCloudProviderView;
@@ -11,9 +11,10 @@ import { useViewContext } from '../../../../context/ViewContext/ViewContext.js';
11
11
  import { ReactComponent as SvgChevronLeft } from '../../../../shared/assets/chevron-left.js';
12
12
  import { ReactComponent as SvgQuestionMark } from '../../../../shared/assets/question-mark.js';
13
13
  import '@dynamic-labs/iconic';
14
+ import { useGoogleDriveBackupReadiness } from '../../../../utils/hooks/useGoogleDriveBackupReadiness/useGoogleDriveBackupReadiness.js';
14
15
  import { useSocialAccounts } from '../../../../utils/hooks/useSocialAccounts/useSocialAccounts.js';
15
16
  import { useWalletBackup } from '../../../../utils/hooks/useWalletBackup/useWalletBackup.js';
16
- import '../../../../utils/hooks/useWalletBackup/types.js';
17
+ import { CloudBackupProvider } from '../../../../utils/hooks/useWalletBackup/types.js';
17
18
  import { BackupStepper } from './BackupStepper.js';
18
19
 
19
20
  const WaasBackupCloudProviderView = () => {
@@ -22,6 +23,7 @@ const WaasBackupCloudProviderView = () => {
22
23
  const { t } = useTranslation();
23
24
  const { isProcessingForProvider, error: socialError } = useSocialAccounts();
24
25
  const { ensureProviderLinked, getSupportedProviders } = useWalletBackup();
26
+ const { check: checkDriveReadiness, isChecking: isCheckingDriveReadiness } = useGoogleDriveBackupReadiness();
25
27
  const [errorMessage, setErrorMessage] = useState(null);
26
28
  const providers = getSupportedProviders();
27
29
  const handleBackClick = useCallback(() => goBack(), [goBack]);
@@ -40,13 +42,26 @@ const WaasBackupCloudProviderView = () => {
40
42
  return;
41
43
  }
42
44
  }
45
+ if (provider === CloudBackupProvider.GoogleDrive) {
46
+ const readiness = yield checkDriveReadiness();
47
+ if (readiness.status === 'needs-access') {
48
+ pushView('waas-backup-grant-access-view');
49
+ return;
50
+ }
51
+ if (readiness.status === 'error') {
52
+ setErrorMessage(t('dyn_waas.backup.error'));
53
+ return;
54
+ }
55
+ }
43
56
  pushView('waas-backup-progress-view', { provider });
44
- }), [ensureProviderLinked, pushView, providers, t]);
57
+ }), [checkDriveReadiness, ensureProviderLinked, pushView, providers, t]);
45
58
  const backButton = (jsx(IconButton, { type: 'button', onClick: handleBackClick, "data-testid": 'back-button', children: jsx(SvgChevronLeft, {}) }));
46
59
  const infoButton = (jsx(IconButton, { type: 'button', onClick: handleInfoClick, "data-testid": 'info-button', children: jsx(SvgQuestionMark, {}) }));
47
- return (jsxs(Fragment, { children: [jsx(ModalHeader, { leading: backButton, trailing: infoButton, children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.title', children: t('dyn_waas.backup.title') }) }), jsx("div", { className: 'waas-backup-view', children: jsxs("div", { className: 'waas-backup-view__body', children: [jsx(BackupStepper, { currentStep: 0, completedSteps: 0 }), (errorMessage || socialError) && (jsx(ErrorContainer, { variant: 'error', withIcon: false, children: (_a = socialError === null || socialError === void 0 ? void 0 : socialError.message) !== null && _a !== void 0 ? _a : errorMessage })), jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.cloud_backup_title', className: 'waas-backup-view__cloud-title', children: t('dyn_waas.backup.cloud_backup_title', '1. Cloud Backup') }), jsx(Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_waas.backup.cloud_backup_subtitle', className: 'waas-backup-view__cloud-subtitle', children: t('dyn_waas.backup.cloud_backup_subtitle', 'Back up your first key share to a cloud provider') }), providers.map((providerConfig) => (jsxs("button", { type: 'button', className: 'waas-backup-view__provider-button', onClick: () => handleProviderClick(providerConfig.id), disabled: providerConfig.requiresOAuth &&
60
+ return (jsxs(Fragment, { children: [jsx(ModalHeader, { leading: backButton, trailing: infoButton, children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.title', children: t('dyn_waas.backup.title') }) }), jsx("div", { className: 'waas-backup-view', children: jsxs("div", { className: 'waas-backup-view__body', children: [jsx(BackupStepper, { currentStep: 0, completedSteps: 0 }), (errorMessage || socialError) && (jsx(ErrorContainer, { variant: 'error', withIcon: false, children: (_a = socialError === null || socialError === void 0 ? void 0 : socialError.message) !== null && _a !== void 0 ? _a : errorMessage })), jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.cloud_backup_title', className: 'waas-backup-view__cloud-title', children: t('dyn_waas.backup.cloud_backup_title', '1. Cloud Backup') }), jsx(Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_waas.backup.cloud_backup_subtitle', className: 'waas-backup-view__cloud-subtitle', children: t('dyn_waas.backup.cloud_backup_subtitle', 'Back up your first key share to a cloud provider') }), providers.map((providerConfig) => (jsxs("button", { type: 'button', className: 'waas-backup-view__provider-button', onClick: () => handleProviderClick(providerConfig.id), disabled: (providerConfig.requiresOAuth &&
48
61
  providerConfig.oauthProvider &&
49
- isProcessingForProvider(providerConfig.oauthProvider), "data-testid": `${providerConfig.id}-button`, children: [providerConfig.icon, jsx(Typography, { variant: 'body_normal', color: 'primary', children: t(`dyn_waas.backup.backup_to_${providerConfig.id}`, `Backup to ${providerConfig.name}`) })] }, providerConfig.id)))] }) })] }));
62
+ isProcessingForProvider(providerConfig.oauthProvider)) ||
63
+ (providerConfig.id === CloudBackupProvider.GoogleDrive &&
64
+ isCheckingDriveReadiness), "data-testid": `${providerConfig.id}-button`, children: [providerConfig.icon, jsx(Typography, { variant: 'body_normal', color: 'primary', children: t(`dyn_waas.backup.backup_to_${providerConfig.id}`, `Backup to ${providerConfig.name}`) })] }, providerConfig.id)))] }) })] }));
50
65
  };
51
66
 
52
67
  export { WaasBackupCloudProviderView };
@@ -0,0 +1,50 @@
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 ErrorContainer = require('../../../../components/ErrorContainer/ErrorContainer.cjs');
11
+ var IconButton = require('../../../../components/IconButton/IconButton.cjs');
12
+ var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
13
+ var Typography = require('../../../../components/Typography/Typography.cjs');
14
+ var TypographyButton = require('../../../../components/TypographyButton/TypographyButton.cjs');
15
+ var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
16
+ var chevronLeft = require('../../../../shared/assets/chevron-left.cjs');
17
+ var questionMark = require('../../../../shared/assets/question-mark.cjs');
18
+ require('@dynamic-labs/iconic');
19
+ var dynamicContextProps = require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
20
+ var useGoogleDriveBackupReadiness = require('../../../../utils/hooks/useGoogleDriveBackupReadiness/useGoogleDriveBackupReadiness.cjs');
21
+ var types = require('../../../../utils/hooks/useWalletBackup/types.cjs');
22
+ var BackupStepper = require('./BackupStepper.cjs');
23
+
24
+ const WaasBackupGrantAccessView = () => {
25
+ const { pushView, goBack } = ViewContext.useViewContext();
26
+ const { t } = reactI18next.useTranslation();
27
+ const { appName } = dynamicContextProps.useDynamicSettings();
28
+ const { requestAccess, isChecking } = useGoogleDriveBackupReadiness.useGoogleDriveBackupReadiness();
29
+ const [showError, setShowError] = React.useState(false);
30
+ const handleBackClick = React.useCallback(() => goBack(), [goBack]);
31
+ const handleInfoClick = React.useCallback(() => {
32
+ pushView('waas-backup-info-view');
33
+ }, [pushView]);
34
+ const handleGrantClick = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
35
+ setShowError(false);
36
+ const result = yield requestAccess();
37
+ if (result.status === 'ready') {
38
+ pushView('waas-backup-progress-view', {
39
+ provider: types.CloudBackupProvider.GoogleDrive,
40
+ });
41
+ return;
42
+ }
43
+ setShowError(true);
44
+ }), [pushView, requestAccess]);
45
+ const backButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleBackClick, "data-testid": 'back-button', children: jsxRuntime.jsx(chevronLeft.ReactComponent, {}) }));
46
+ const infoButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleInfoClick, "data-testid": 'info-button', children: jsxRuntime.jsx(questionMark.ReactComponent, {}) }));
47
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, trailing: infoButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.title', children: t('dyn_waas.backup.title') }) }), jsxRuntime.jsx("div", { className: 'waas-backup-view', children: jsxRuntime.jsxs("div", { className: 'waas-backup-view__body', children: [jsxRuntime.jsx(BackupStepper.BackupStepper, { currentStep: 0, completedSteps: 0 }), showError && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { variant: 'error', withIcon: false, children: t('dyn_waas.backup.gdrive_grant_access_error') })), jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.gdrive_grant_access_title', className: 'waas-backup-view__cloud-title', children: t('dyn_waas.backup.gdrive_grant_access_title') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_waas.backup.gdrive_grant_access_subtitle', className: 'waas-backup-view__cloud-subtitle', children: t('dyn_waas.backup.gdrive_grant_access_subtitle', { appName }) }), jsxRuntime.jsxs("div", { className: 'waas-backup-view__grant-access-actions', children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'grant-access-cancel-button', onClick: handleBackClick, disabled: isChecking, copykey: 'dyn_waas.backup.gdrive_grant_access_cancel', buttonVariant: 'primary', typographyProps: { color: 'inherit' }, children: t('dyn_waas.backup.gdrive_grant_access_cancel') }), jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'grant-access-button', onClick: handleGrantClick, disabled: isChecking, copykey: 'dyn_waas.backup.gdrive_grant_access_cta', buttonVariant: 'brand-primary', typographyProps: { color: 'inherit' }, children: t('dyn_waas.backup.gdrive_grant_access_cta') })] })] }) })] }));
48
+ };
49
+
50
+ exports.WaasBackupGrantAccessView = WaasBackupGrantAccessView;
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const WaasBackupGrantAccessView: FC;
@@ -0,0 +1,46 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../../../_virtual/_tslib.js';
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import { useState, useCallback } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import { ErrorContainer } from '../../../../components/ErrorContainer/ErrorContainer.js';
7
+ import { IconButton } from '../../../../components/IconButton/IconButton.js';
8
+ import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
9
+ import { Typography } from '../../../../components/Typography/Typography.js';
10
+ import { TypographyButton } from '../../../../components/TypographyButton/TypographyButton.js';
11
+ import { useViewContext } from '../../../../context/ViewContext/ViewContext.js';
12
+ import { ReactComponent as SvgChevronLeft } from '../../../../shared/assets/chevron-left.js';
13
+ import { ReactComponent as SvgQuestionMark } from '../../../../shared/assets/question-mark.js';
14
+ import '@dynamic-labs/iconic';
15
+ import { useDynamicSettings } from '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
16
+ import { useGoogleDriveBackupReadiness } from '../../../../utils/hooks/useGoogleDriveBackupReadiness/useGoogleDriveBackupReadiness.js';
17
+ import { CloudBackupProvider } from '../../../../utils/hooks/useWalletBackup/types.js';
18
+ import { BackupStepper } from './BackupStepper.js';
19
+
20
+ const WaasBackupGrantAccessView = () => {
21
+ const { pushView, goBack } = useViewContext();
22
+ const { t } = useTranslation();
23
+ const { appName } = useDynamicSettings();
24
+ const { requestAccess, isChecking } = useGoogleDriveBackupReadiness();
25
+ const [showError, setShowError] = useState(false);
26
+ const handleBackClick = useCallback(() => goBack(), [goBack]);
27
+ const handleInfoClick = useCallback(() => {
28
+ pushView('waas-backup-info-view');
29
+ }, [pushView]);
30
+ const handleGrantClick = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
31
+ setShowError(false);
32
+ const result = yield requestAccess();
33
+ if (result.status === 'ready') {
34
+ pushView('waas-backup-progress-view', {
35
+ provider: CloudBackupProvider.GoogleDrive,
36
+ });
37
+ return;
38
+ }
39
+ setShowError(true);
40
+ }), [pushView, requestAccess]);
41
+ const backButton = (jsx(IconButton, { type: 'button', onClick: handleBackClick, "data-testid": 'back-button', children: jsx(SvgChevronLeft, {}) }));
42
+ const infoButton = (jsx(IconButton, { type: 'button', onClick: handleInfoClick, "data-testid": 'info-button', children: jsx(SvgQuestionMark, {}) }));
43
+ return (jsxs(Fragment, { children: [jsx(ModalHeader, { leading: backButton, trailing: infoButton, children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.title', children: t('dyn_waas.backup.title') }) }), jsx("div", { className: 'waas-backup-view', children: jsxs("div", { className: 'waas-backup-view__body', children: [jsx(BackupStepper, { currentStep: 0, completedSteps: 0 }), showError && (jsx(ErrorContainer, { variant: 'error', withIcon: false, children: t('dyn_waas.backup.gdrive_grant_access_error') })), jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_waas.backup.gdrive_grant_access_title', className: 'waas-backup-view__cloud-title', children: t('dyn_waas.backup.gdrive_grant_access_title') }), jsx(Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_waas.backup.gdrive_grant_access_subtitle', className: 'waas-backup-view__cloud-subtitle', children: t('dyn_waas.backup.gdrive_grant_access_subtitle', { appName }) }), jsxs("div", { className: 'waas-backup-view__grant-access-actions', children: [jsx(TypographyButton, { dataTestId: 'grant-access-cancel-button', onClick: handleBackClick, disabled: isChecking, copykey: 'dyn_waas.backup.gdrive_grant_access_cancel', buttonVariant: 'primary', typographyProps: { color: 'inherit' }, children: t('dyn_waas.backup.gdrive_grant_access_cancel') }), jsx(TypographyButton, { dataTestId: 'grant-access-button', onClick: handleGrantClick, disabled: isChecking, copykey: 'dyn_waas.backup.gdrive_grant_access_cta', buttonVariant: 'brand-primary', typographyProps: { color: 'inherit' }, children: t('dyn_waas.backup.gdrive_grant_access_cta') })] })] }) })] }));
44
+ };
45
+
46
+ export { WaasBackupGrantAccessView };
@@ -15,15 +15,18 @@ var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
15
15
  var chevronLeft = require('../../../../shared/assets/chevron-left.cjs');
16
16
  var exclamation = require('../../../../shared/assets/exclamation.cjs');
17
17
  require('@dynamic-labs/iconic');
18
+ var useGoogleDriveBackupReadiness = require('../../../../utils/hooks/useGoogleDriveBackupReadiness/useGoogleDriveBackupReadiness.cjs');
18
19
  var useWalletBackup = require('../../../../utils/hooks/useWalletBackup/useWalletBackup.cjs');
19
20
  var types = require('../../../../utils/hooks/useWalletBackup/types.cjs');
21
+ var googleDriveBackupErrors = require('../../../../utils/hooks/useWalletBackup/googleDriveBackupErrors.cjs');
20
22
  var cloudProviders = require('../../../../utils/hooks/useWalletBackup/cloudProviders.cjs');
21
23
 
22
24
  const WaasBackupProgressView = ({ provider = types.CloudBackupProvider.GoogleDrive, }) => {
23
25
  const { goBack, pushView } = ViewContext.useViewContext();
24
26
  const { t } = reactI18next.useTranslation();
25
27
  const providerConfig = cloudProviders.CLOUD_PROVIDER_CONFIGS[provider];
26
- const { getWalletsToBackup, showICloudAuth, checkICloudAuth, hideICloudAuth, } = useWalletBackup.useWalletBackup();
28
+ const { getWalletsToBackup, showICloudAuth, checkICloudAuth, hideICloudAuth, lastBackupError, clearBackupError, } = useWalletBackup.useWalletBackup();
29
+ const { requestAccess: requestDriveAccess, isChecking: isRequestingDriveAccess, } = useGoogleDriveBackupReadiness.useGoogleDriveBackupReadiness();
27
30
  const [displayContainer, setDisplayContainer] = React.useState(null);
28
31
  const [authState, setAuthState] = React.useState('pending');
29
32
  const [authError, setAuthError] = React.useState(null);
@@ -130,6 +133,15 @@ const WaasBackupProgressView = ({ provider = types.CloudBackupProvider.GoogleDri
130
133
  retry();
131
134
  }
132
135
  }, [providerConfig.requiresIframe, retry]);
136
+ const handleGrantDriveAccessAndRetry = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
137
+ clearBackupError();
138
+ const result = yield requestDriveAccess();
139
+ if (result.status === 'ready') {
140
+ retry();
141
+ }
142
+ }), [clearBackupError, requestDriveAccess, retry]);
143
+ const isDriveScopesError = provider === types.CloudBackupProvider.GoogleDrive &&
144
+ googleDriveBackupErrors.isInsufficientGoogleDriveScopesError(lastBackupError);
133
145
  const getProgressText = () => {
134
146
  if (isComplete) {
135
147
  return t('dyn_waas.backup.progress_complete');
@@ -144,9 +156,17 @@ const WaasBackupProgressView = ({ provider = types.CloudBackupProvider.GoogleDri
144
156
  };
145
157
  const renderProgressContent = () => {
146
158
  if (hasError || authState === 'failed') {
147
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_waas.backup.error_title', className: 'waas-backup-view__progress-title', children: authError || t('dyn_waas.backup.error_title') }), jsxRuntime.jsx("div", { className: 'waas-backup-view__progress-actions', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'retry-backup-button', onClick: handleRetry, copykey: 'dyn_waas.backup.error_try_again', buttonVariant: 'brand-primary', typographyProps: {
159
+ const titleCopykey = isDriveScopesError
160
+ ? 'dyn_waas.backup.gdrive_post_flight_title'
161
+ : 'dyn_waas.backup.error_title';
162
+ const titleText = isDriveScopesError
163
+ ? t('dyn_waas.backup.gdrive_post_flight_title')
164
+ : authError || t('dyn_waas.backup.error_title');
165
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: titleCopykey, className: 'waas-backup-view__progress-title', children: titleText }), jsxRuntime.jsx("div", { className: 'waas-backup-view__progress-actions', children: isDriveScopesError ? (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'grant-drive-access-button', onClick: handleGrantDriveAccessAndRetry, disabled: isRequestingDriveAccess, copykey: 'dyn_waas.backup.gdrive_grant_access_cta', buttonVariant: 'brand-primary', typographyProps: {
166
+ color: 'inherit',
167
+ }, expanded: true, children: t('dyn_waas.backup.gdrive_grant_access_cta') })) : (jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'retry-backup-button', onClick: handleRetry, copykey: 'dyn_waas.backup.error_try_again', buttonVariant: 'brand-primary', typographyProps: {
148
168
  color: 'inherit',
149
- }, expanded: true, children: t('dyn_waas.backup.error_try_again') }) })] }));
169
+ }, expanded: true, children: t('dyn_waas.backup.error_try_again') })) })] }));
150
170
  }
151
171
  if (providerConfig.requiresIframe &&
152
172
  authState === 'shown' &&