diff --git a/src/lib/flash-helper.js b/src/lib/flash-helper.js index 42b3adc1f..2ea58c0bc 100644 --- a/src/lib/flash-helper.js +++ b/src/lib/flash-helper.js @@ -380,10 +380,11 @@ async function validateModulesForProtection({ modules, device }) { } for (const module of modules) { - const oldSystem = module.moduleFunction === ModuleInfo.FunctionType.SYSTEM_PART && - module.moduleVersion < PROTECTED_MINIMUM_SYSTEM_VERSION; - const oldBootloader = module.moduleFunction === ModuleInfo.FunctionType.BOOTLOADER && - module.moduleIndex === 0 && module.moduleVersion < PROTECTED_MINIMUM_BOOTLOADER_VERSION; + const { moduleFunction, moduleIndex, moduleVersion } = module.prefixInfo; + const oldSystem = moduleFunction === ModuleInfo.FunctionType.SYSTEM_PART && + moduleVersion < PROTECTED_MINIMUM_SYSTEM_VERSION; + const oldBootloader = moduleFunction === ModuleInfo.FunctionType.BOOTLOADER && + moduleIndex === 0 && moduleVersion < PROTECTED_MINIMUM_BOOTLOADER_VERSION; if (oldSystem || oldBootloader) { throw new Error(`Cannot downgrade Device OS below version ${PROTECTED_MINIMUM_VERSION} on a Protected Device`); diff --git a/src/lib/flash-helper.test.js b/src/lib/flash-helper.test.js index d8145301d..d4cc644de 100644 --- a/src/lib/flash-helper.test.js +++ b/src/lib/flash-helper.test.js @@ -664,27 +664,35 @@ describe('flash-helper', () => { describe('validateModulesForProtection', () => { let device; const modulesOldBootloader = [{ - moduleFunction: ModuleInfo.FunctionType.BOOTLOADER, - platformId: 12, - moduleIndex: 0, - moduleVersion: 1200, + prefixInfo: { + moduleFunction: ModuleInfo.FunctionType.BOOTLOADER, + platformId: 12, + moduleIndex: 0, + moduleVersion: 1200 + } }]; const modulesOldSystem = [{ - moduleFunction: ModuleInfo.FunctionType.SYSTEM_PART, - platformId: 12, - moduleIndex: 0, - moduleVersion: 5800, + prefixInfo: { + moduleFunction: ModuleInfo.FunctionType.SYSTEM_PART, + platformId: 12, + moduleIndex: 0, + moduleVersion: 5800 + } }]; const modulesNew = [{ - moduleFunction: ModuleInfo.FunctionType.BOOTLOADER, - platformId: 12, - moduleIndex: 0, - moduleVersion: 3000, + prefixInfo: { + moduleFunction: ModuleInfo.FunctionType.BOOTLOADER, + platformId: 12, + moduleIndex: 0, + moduleVersion: 3000 + } }, { - moduleFunction: ModuleInfo.FunctionType.SYSTEM_PART, - platformId: 12, - moduleIndex: 0, - moduleVersion: 6000, + prefixInfo: { + moduleFunction: ModuleInfo.FunctionType.SYSTEM_PART, + platformId: 12, + moduleIndex: 0, + moduleVersion: 6000 + } }]; beforeEach(() => {