Skip to content

Commit

Permalink
feat(suite, suite-common): allow disabling entropy check via message …
Browse files Browse the repository at this point in the history
…system
  • Loading branch information
komret committed Feb 4, 2025
1 parent b0039a0 commit b9e3796
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/suite/src/actions/settings/deviceSettingsActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FIRMWARE_MODULE_PREFIX } from '@suite-common/firmware';
import { Feature, selectIsFeatureDisabled } from '@suite-common/message-system';
import { createThunk } from '@suite-common/redux-utils';
import * as deviceUtils from '@suite-common/suite-utils';
import { notificationsActions } from '@suite-common/toast-notifications';
Expand Down Expand Up @@ -154,7 +155,10 @@ export const resetDevice =
async (dispatch: Dispatch, getState: GetState) => {
const device = selectSelectedDevice(getState());
const isEntropyCheckEnabled = selectIsEntropyCheckEnabled(getState());

const isEntropyCheckDisabledByMessageSystem = selectIsFeatureDisabled(
getState(),
Feature.entropyCheck,
);
if (!device || !device.features) return;

const defaults = {
Expand All @@ -169,7 +173,7 @@ export const resetDevice =
},
...defaults,
...params,
entropy_check: isEntropyCheckEnabled,
entropy_check: isEntropyCheckEnabled && !isEntropyCheckDisabledByMessageSystem,
});

if (!result.success) {
Expand Down
7 changes: 6 additions & 1 deletion packages/suite/src/components/suite/Preloader/Preloader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export const Preloader = ({ children }: PropsWithChildren) => {
selectIsFirmwareAuthenticityCheckDismissed,
);
const isEntropyCheckEnabled = useSelector(selectIsEntropyCheckEnabled);
// Entropy check won't be performed if disabled but we also have to check it here to avoid showing the UI when the failed state is stored in database.
const isEntropyCheckDisabledByMessageSystem = useSelector(state =>
selectIsFeatureDisabled(state, Feature.entropyCheck),
);
const isEntropyCheckFailed = useSelector(selectIsEntropyCheckFailed);

// report firmware authenticity failures even when the UI is disabled
Expand Down Expand Up @@ -98,7 +102,8 @@ export const Preloader = ({ children }: PropsWithChildren) => {
return <InitialLoading timeout={90} />;
}

const isEntropyCheckEnabledAndFailed = isEntropyCheckEnabled && isEntropyCheckFailed;
const isEntropyCheckEnabledAndFailed =
isEntropyCheckEnabled && !isEntropyCheckDisabledByMessageSystem && isEntropyCheckFailed;

if (
(router.route?.app === undefined ||
Expand Down
3 changes: 2 additions & 1 deletion suite-common/message-system/src/messageSystemTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export const Feature = {
ethStake: 'eth.staking.stake',
ethUnstake: 'eth.staking.unstake',
ethClaim: 'eth.staking.claim',
firmwareRevisionCheck: 'security.firmware.check',
firmwareRevisionCheck: 'security.firmware.revisionCheck',
firmwareHashCheck: 'security.firmware.hashCheck',
entropyCheck: 'security.entropyCheck',
// FW update feature flag implemented only for mobile app
firmwareUpdate: 'device.firmware.update',
} as const;
Expand Down

0 comments on commit b9e3796

Please sign in to comment.