@ledgerhq/device-core 0.1.1-nightly.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/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +12 -0
- package/LICENSE.txt +21 -0
- package/jest.config.json +13 -0
- package/lib/capabilities/isCustomLockScreenSupported.d.ts +5 -0
- package/lib/capabilities/isCustomLockScreenSupported.d.ts.map +1 -0
- package/lib/capabilities/isCustomLockScreenSupported.js +16 -0
- package/lib/capabilities/isCustomLockScreenSupported.js.map +1 -0
- package/lib/capabilities/isCustomLockScreenSupported.test.d.ts +2 -0
- package/lib/capabilities/isCustomLockScreenSupported.test.d.ts.map +1 -0
- package/lib/capabilities/isCustomLockScreenSupported.test.js +22 -0
- package/lib/capabilities/isCustomLockScreenSupported.test.js.map +1 -0
- package/lib/capabilities/isEditDeviceNameSupported.d.ts +3 -0
- package/lib/capabilities/isEditDeviceNameSupported.d.ts.map +1 -0
- package/lib/capabilities/isEditDeviceNameSupported.js +9 -0
- package/lib/capabilities/isEditDeviceNameSupported.js.map +1 -0
- package/lib/capabilities/isEditDeviceNameSupported.test.d.ts +2 -0
- package/lib/capabilities/isEditDeviceNameSupported.test.d.ts.map +1 -0
- package/lib/capabilities/isEditDeviceNameSupported.test.js +19 -0
- package/lib/capabilities/isEditDeviceNameSupported.test.js.map +1 -0
- package/lib/capabilities/isSyncOnboardingSupported.d.ts +3 -0
- package/lib/capabilities/isSyncOnboardingSupported.d.ts.map +1 -0
- package/lib/capabilities/isSyncOnboardingSupported.js +9 -0
- package/lib/capabilities/isSyncOnboardingSupported.js.map +1 -0
- package/lib/capabilities/isSyncOnboardingSupported.test.d.ts +2 -0
- package/lib/capabilities/isSyncOnboardingSupported.test.d.ts.map +1 -0
- package/lib/capabilities/isSyncOnboardingSupported.test.js +17 -0
- package/lib/capabilities/isSyncOnboardingSupported.test.js.map +1 -0
- package/lib/commands/entities/APDU.d.ts +9 -0
- package/lib/commands/entities/APDU.d.ts.map +1 -0
- package/lib/commands/entities/APDU.js +3 -0
- package/lib/commands/entities/APDU.js.map +1 -0
- package/lib/commands/entities/FirmwareInfoEntity.d.ts +16 -0
- package/lib/commands/entities/FirmwareInfoEntity.d.ts.map +1 -0
- package/lib/commands/entities/FirmwareInfoEntity.js +3 -0
- package/lib/commands/entities/FirmwareInfoEntity.js.map +1 -0
- package/lib/commands/use-cases/getDeviceName.d.ts +3 -0
- package/lib/commands/use-cases/getDeviceName.d.ts.map +1 -0
- package/lib/commands/use-cases/getDeviceName.js +48 -0
- package/lib/commands/use-cases/getDeviceName.js.map +1 -0
- package/lib/commands/use-cases/getVersion.d.ts +15 -0
- package/lib/commands/use-cases/getVersion.d.ts.map +1 -0
- package/lib/commands/use-cases/getVersion.js +31 -0
- package/lib/commands/use-cases/getVersion.js.map +1 -0
- package/lib/commands/use-cases/isBootloaderVersionSupported.d.ts +7 -0
- package/lib/commands/use-cases/isBootloaderVersionSupported.d.ts.map +1 -0
- package/lib/commands/use-cases/isBootloaderVersionSupported.js +20 -0
- package/lib/commands/use-cases/isBootloaderVersionSupported.js.map +1 -0
- package/lib/commands/use-cases/isBootloaderVersionSupported.test.d.ts +2 -0
- package/lib/commands/use-cases/isBootloaderVersionSupported.test.d.ts.map +1 -0
- package/lib/commands/use-cases/isBootloaderVersionSupported.test.js +53 -0
- package/lib/commands/use-cases/isBootloaderVersionSupported.test.js.map +1 -0
- package/lib/commands/use-cases/isDeviceLocalizationSupported.d.ts +3 -0
- package/lib/commands/use-cases/isDeviceLocalizationSupported.d.ts.map +1 -0
- package/lib/commands/use-cases/isDeviceLocalizationSupported.js +15 -0
- package/lib/commands/use-cases/isDeviceLocalizationSupported.js.map +1 -0
- package/lib/commands/use-cases/isDeviceLocalizationSupported.test.d.ts +2 -0
- package/lib/commands/use-cases/isDeviceLocalizationSupported.test.d.ts.map +1 -0
- package/lib/commands/use-cases/isDeviceLocalizationSupported.test.js +45 -0
- package/lib/commands/use-cases/isDeviceLocalizationSupported.test.js.map +1 -0
- package/lib/commands/use-cases/isHardwareVersionSupported.d.ts +7 -0
- package/lib/commands/use-cases/isHardwareVersionSupported.d.ts.map +1 -0
- package/lib/commands/use-cases/isHardwareVersionSupported.js +16 -0
- package/lib/commands/use-cases/isHardwareVersionSupported.js.map +1 -0
- package/lib/commands/use-cases/isHardwareVersionSupported.test.d.ts +2 -0
- package/lib/commands/use-cases/isHardwareVersionSupported.test.d.ts.map +1 -0
- package/lib/commands/use-cases/isHardwareVersionSupported.test.js +36 -0
- package/lib/commands/use-cases/isHardwareVersionSupported.test.js.map +1 -0
- package/lib/commands/use-cases/parseGetDeviceNameResponse.d.ts +3 -0
- package/lib/commands/use-cases/parseGetDeviceNameResponse.d.ts.map +1 -0
- package/lib/commands/use-cases/parseGetDeviceNameResponse.js +23 -0
- package/lib/commands/use-cases/parseGetDeviceNameResponse.js.map +1 -0
- package/lib/commands/use-cases/parseGetDeviceNameResponse.test.d.ts +2 -0
- package/lib/commands/use-cases/parseGetDeviceNameResponse.test.d.ts.map +1 -0
- package/lib/commands/use-cases/parseGetDeviceNameResponse.test.js +27 -0
- package/lib/commands/use-cases/parseGetDeviceNameResponse.test.js.map +1 -0
- package/lib/commands/use-cases/parseGetVersionResponse.d.ts +4 -0
- package/lib/commands/use-cases/parseGetVersionResponse.d.ts.map +1 -0
- package/lib/commands/use-cases/parseGetVersionResponse.js +108 -0
- package/lib/commands/use-cases/parseGetVersionResponse.js.map +1 -0
- package/lib/commands/use-cases/parseGetVersionResponse.test.d.ts +2 -0
- package/lib/commands/use-cases/parseGetVersionResponse.test.d.ts.map +1 -0
- package/lib/commands/use-cases/parseGetVersionResponse.test.js +105 -0
- package/lib/commands/use-cases/parseGetVersionResponse.test.js.map +1 -0
- package/lib/customLockScreen/screenSpecs.d.ts +30 -0
- package/lib/customLockScreen/screenSpecs.d.ts.map +1 -0
- package/lib/customLockScreen/screenSpecs.js +46 -0
- package/lib/customLockScreen/screenSpecs.js.map +1 -0
- package/lib/index.d.ts +23 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +56 -0
- package/lib/index.js.map +1 -0
- package/lib/managerApi/entities/AppEntity.d.ts +62 -0
- package/lib/managerApi/entities/AppEntity.d.ts.map +1 -0
- package/lib/managerApi/entities/AppEntity.js +12 -0
- package/lib/managerApi/entities/AppEntity.js.map +1 -0
- package/lib/managerApi/entities/DeviceInfoEntity.d.ts +22 -0
- package/lib/managerApi/entities/DeviceInfoEntity.d.ts.map +1 -0
- package/lib/managerApi/entities/DeviceInfoEntity.js +3 -0
- package/lib/managerApi/entities/DeviceInfoEntity.js.map +1 -0
- package/lib/managerApi/entities/DeviceVersionEntity.d.ts +17 -0
- package/lib/managerApi/entities/DeviceVersionEntity.d.ts.map +1 -0
- package/lib/managerApi/entities/DeviceVersionEntity.js +3 -0
- package/lib/managerApi/entities/DeviceVersionEntity.js.map +1 -0
- package/lib/managerApi/entities/FirmwareUpdateContextEntity.d.ts +42 -0
- package/lib/managerApi/entities/FirmwareUpdateContextEntity.d.ts.map +1 -0
- package/lib/managerApi/entities/FirmwareUpdateContextEntity.js +3 -0
- package/lib/managerApi/entities/FirmwareUpdateContextEntity.js.map +1 -0
- package/lib/managerApi/entities/Id.d.ts +2 -0
- package/lib/managerApi/entities/Id.d.ts.map +1 -0
- package/lib/managerApi/entities/Id.js +3 -0
- package/lib/managerApi/entities/Id.js.map +1 -0
- package/lib/managerApi/entities/LanguagePackageEntity.d.ts +20 -0
- package/lib/managerApi/entities/LanguagePackageEntity.d.ts.map +1 -0
- package/lib/managerApi/entities/LanguagePackageEntity.js +3 -0
- package/lib/managerApi/entities/LanguagePackageEntity.js.map +1 -0
- package/lib/managerApi/entities/mocks/aDeviceInfo.d.ts +3 -0
- package/lib/managerApi/entities/mocks/aDeviceInfo.d.ts.map +1 -0
- package/lib/managerApi/entities/mocks/aDeviceInfo.js +8 -0
- package/lib/managerApi/entities/mocks/aDeviceInfo.js.map +1 -0
- package/lib/managerApi/entities/mocks/aDeviceVersion.d.ts +3 -0
- package/lib/managerApi/entities/mocks/aDeviceVersion.d.ts.map +1 -0
- package/lib/managerApi/entities/mocks/aDeviceVersion.js +8 -0
- package/lib/managerApi/entities/mocks/aDeviceVersion.js.map +1 -0
- package/lib/managerApi/entities/mocks/aFinalFirmware.d.ts +3 -0
- package/lib/managerApi/entities/mocks/aFinalFirmware.d.ts.map +1 -0
- package/lib/managerApi/entities/mocks/aFinalFirmware.js +8 -0
- package/lib/managerApi/entities/mocks/aFinalFirmware.js.map +1 -0
- package/lib/managerApi/entities/mocks/aOsuFirmware.d.ts +19 -0
- package/lib/managerApi/entities/mocks/aOsuFirmware.d.ts.map +1 -0
- package/lib/managerApi/entities/mocks/aOsuFirmware.js +8 -0
- package/lib/managerApi/entities/mocks/aOsuFirmware.js.map +1 -0
- package/lib/managerApi/repositories/HttpManagerApiRepository.d.ts +18 -0
- package/lib/managerApi/repositories/HttpManagerApiRepository.d.ts.map +1 -0
- package/lib/managerApi/repositories/HttpManagerApiRepository.js +204 -0
- package/lib/managerApi/repositories/HttpManagerApiRepository.js.map +1 -0
- package/lib/managerApi/repositories/HttpManagerApiRepository.test.d.ts +2 -0
- package/lib/managerApi/repositories/HttpManagerApiRepository.test.d.ts.map +1 -0
- package/lib/managerApi/repositories/HttpManagerApiRepository.test.js +402 -0
- package/lib/managerApi/repositories/HttpManagerApiRepository.test.js.map +1 -0
- package/lib/managerApi/repositories/ManagerApiRepository.d.ts +54 -0
- package/lib/managerApi/repositories/ManagerApiRepository.d.ts.map +1 -0
- package/lib/managerApi/repositories/ManagerApiRepository.js +3 -0
- package/lib/managerApi/repositories/ManagerApiRepository.js.map +1 -0
- package/lib/managerApi/repositories/StubManagerApiRepository.d.ts +15 -0
- package/lib/managerApi/repositories/StubManagerApiRepository.d.ts.map +1 -0
- package/lib/managerApi/repositories/StubManagerApiRepository.js +44 -0
- package/lib/managerApi/repositories/StubManagerApiRepository.js.map +1 -0
- package/lib/managerApi/use-cases/fetchMcus.d.ts +3 -0
- package/lib/managerApi/use-cases/fetchMcus.d.ts.map +1 -0
- package/lib/managerApi/use-cases/fetchMcus.js +8 -0
- package/lib/managerApi/use-cases/fetchMcus.js.map +1 -0
- package/lib/managerApi/use-cases/getLatestFirmwareForDevice.d.ts +12 -0
- package/lib/managerApi/use-cases/getLatestFirmwareForDevice.d.ts.map +1 -0
- package/lib/managerApi/use-cases/getLatestFirmwareForDevice.js +62 -0
- package/lib/managerApi/use-cases/getLatestFirmwareForDevice.js.map +1 -0
- package/lib/managerApi/use-cases/getLatestFirmwareForDevice.test.d.ts +2 -0
- package/lib/managerApi/use-cases/getLatestFirmwareForDevice.test.d.ts.map +1 -0
- package/lib/managerApi/use-cases/getLatestFirmwareForDevice.test.js +178 -0
- package/lib/managerApi/use-cases/getLatestFirmwareForDevice.test.js.map +1 -0
- package/lib/managerApi/use-cases/getProviderIdUseCase.d.ts +7 -0
- package/lib/managerApi/use-cases/getProviderIdUseCase.d.ts.map +1 -0
- package/lib/managerApi/use-cases/getProviderIdUseCase.js +23 -0
- package/lib/managerApi/use-cases/getProviderIdUseCase.js.map +1 -0
- package/lib/managerApi/use-cases/getUserHashes.d.ts +5 -0
- package/lib/managerApi/use-cases/getUserHashes.d.ts.map +1 -0
- package/lib/managerApi/use-cases/getUserHashes.js +33 -0
- package/lib/managerApi/use-cases/getUserHashes.js.map +1 -0
- package/lib-es/capabilities/isCustomLockScreenSupported.d.ts +5 -0
- package/lib-es/capabilities/isCustomLockScreenSupported.d.ts.map +1 -0
- package/lib-es/capabilities/isCustomLockScreenSupported.js +12 -0
- package/lib-es/capabilities/isCustomLockScreenSupported.js.map +1 -0
- package/lib-es/capabilities/isCustomLockScreenSupported.test.d.ts +2 -0
- package/lib-es/capabilities/isCustomLockScreenSupported.test.d.ts.map +1 -0
- package/lib-es/capabilities/isCustomLockScreenSupported.test.js +20 -0
- package/lib-es/capabilities/isCustomLockScreenSupported.test.js.map +1 -0
- package/lib-es/capabilities/isEditDeviceNameSupported.d.ts +3 -0
- package/lib-es/capabilities/isEditDeviceNameSupported.d.ts.map +1 -0
- package/lib-es/capabilities/isEditDeviceNameSupported.js +5 -0
- package/lib-es/capabilities/isEditDeviceNameSupported.js.map +1 -0
- package/lib-es/capabilities/isEditDeviceNameSupported.test.d.ts +2 -0
- package/lib-es/capabilities/isEditDeviceNameSupported.test.d.ts.map +1 -0
- package/lib-es/capabilities/isEditDeviceNameSupported.test.js +17 -0
- package/lib-es/capabilities/isEditDeviceNameSupported.test.js.map +1 -0
- package/lib-es/capabilities/isSyncOnboardingSupported.d.ts +3 -0
- package/lib-es/capabilities/isSyncOnboardingSupported.d.ts.map +1 -0
- package/lib-es/capabilities/isSyncOnboardingSupported.js +5 -0
- package/lib-es/capabilities/isSyncOnboardingSupported.js.map +1 -0
- package/lib-es/capabilities/isSyncOnboardingSupported.test.d.ts +2 -0
- package/lib-es/capabilities/isSyncOnboardingSupported.test.d.ts.map +1 -0
- package/lib-es/capabilities/isSyncOnboardingSupported.test.js +15 -0
- package/lib-es/capabilities/isSyncOnboardingSupported.test.js.map +1 -0
- package/lib-es/commands/entities/APDU.d.ts +9 -0
- package/lib-es/commands/entities/APDU.d.ts.map +1 -0
- package/lib-es/commands/entities/APDU.js +2 -0
- package/lib-es/commands/entities/APDU.js.map +1 -0
- package/lib-es/commands/entities/FirmwareInfoEntity.d.ts +16 -0
- package/lib-es/commands/entities/FirmwareInfoEntity.d.ts.map +1 -0
- package/lib-es/commands/entities/FirmwareInfoEntity.js +2 -0
- package/lib-es/commands/entities/FirmwareInfoEntity.js.map +1 -0
- package/lib-es/commands/use-cases/getDeviceName.d.ts +3 -0
- package/lib-es/commands/use-cases/getDeviceName.d.ts.map +1 -0
- package/lib-es/commands/use-cases/getDeviceName.js +44 -0
- package/lib-es/commands/use-cases/getDeviceName.js.map +1 -0
- package/lib-es/commands/use-cases/getVersion.d.ts +15 -0
- package/lib-es/commands/use-cases/getVersion.d.ts.map +1 -0
- package/lib-es/commands/use-cases/getVersion.js +27 -0
- package/lib-es/commands/use-cases/getVersion.js.map +1 -0
- package/lib-es/commands/use-cases/isBootloaderVersionSupported.d.ts +7 -0
- package/lib-es/commands/use-cases/isBootloaderVersionSupported.d.ts.map +1 -0
- package/lib-es/commands/use-cases/isBootloaderVersionSupported.js +16 -0
- package/lib-es/commands/use-cases/isBootloaderVersionSupported.js.map +1 -0
- package/lib-es/commands/use-cases/isBootloaderVersionSupported.test.d.ts +2 -0
- package/lib-es/commands/use-cases/isBootloaderVersionSupported.test.d.ts.map +1 -0
- package/lib-es/commands/use-cases/isBootloaderVersionSupported.test.js +51 -0
- package/lib-es/commands/use-cases/isBootloaderVersionSupported.test.js.map +1 -0
- package/lib-es/commands/use-cases/isDeviceLocalizationSupported.d.ts +3 -0
- package/lib-es/commands/use-cases/isDeviceLocalizationSupported.d.ts.map +1 -0
- package/lib-es/commands/use-cases/isDeviceLocalizationSupported.js +11 -0
- package/lib-es/commands/use-cases/isDeviceLocalizationSupported.js.map +1 -0
- package/lib-es/commands/use-cases/isDeviceLocalizationSupported.test.d.ts +2 -0
- package/lib-es/commands/use-cases/isDeviceLocalizationSupported.test.d.ts.map +1 -0
- package/lib-es/commands/use-cases/isDeviceLocalizationSupported.test.js +43 -0
- package/lib-es/commands/use-cases/isDeviceLocalizationSupported.test.js.map +1 -0
- package/lib-es/commands/use-cases/isHardwareVersionSupported.d.ts +7 -0
- package/lib-es/commands/use-cases/isHardwareVersionSupported.d.ts.map +1 -0
- package/lib-es/commands/use-cases/isHardwareVersionSupported.js +12 -0
- package/lib-es/commands/use-cases/isHardwareVersionSupported.js.map +1 -0
- package/lib-es/commands/use-cases/isHardwareVersionSupported.test.d.ts +2 -0
- package/lib-es/commands/use-cases/isHardwareVersionSupported.test.d.ts.map +1 -0
- package/lib-es/commands/use-cases/isHardwareVersionSupported.test.js +34 -0
- package/lib-es/commands/use-cases/isHardwareVersionSupported.test.js.map +1 -0
- package/lib-es/commands/use-cases/parseGetDeviceNameResponse.d.ts +3 -0
- package/lib-es/commands/use-cases/parseGetDeviceNameResponse.d.ts.map +1 -0
- package/lib-es/commands/use-cases/parseGetDeviceNameResponse.js +19 -0
- package/lib-es/commands/use-cases/parseGetDeviceNameResponse.js.map +1 -0
- package/lib-es/commands/use-cases/parseGetDeviceNameResponse.test.d.ts +2 -0
- package/lib-es/commands/use-cases/parseGetDeviceNameResponse.test.d.ts.map +1 -0
- package/lib-es/commands/use-cases/parseGetDeviceNameResponse.test.js +25 -0
- package/lib-es/commands/use-cases/parseGetDeviceNameResponse.test.js.map +1 -0
- package/lib-es/commands/use-cases/parseGetVersionResponse.d.ts +4 -0
- package/lib-es/commands/use-cases/parseGetVersionResponse.d.ts.map +1 -0
- package/lib-es/commands/use-cases/parseGetVersionResponse.js +104 -0
- package/lib-es/commands/use-cases/parseGetVersionResponse.js.map +1 -0
- package/lib-es/commands/use-cases/parseGetVersionResponse.test.d.ts +2 -0
- package/lib-es/commands/use-cases/parseGetVersionResponse.test.d.ts.map +1 -0
- package/lib-es/commands/use-cases/parseGetVersionResponse.test.js +103 -0
- package/lib-es/commands/use-cases/parseGetVersionResponse.test.js.map +1 -0
- package/lib-es/customLockScreen/screenSpecs.d.ts +30 -0
- package/lib-es/customLockScreen/screenSpecs.d.ts.map +1 -0
- package/lib-es/customLockScreen/screenSpecs.js +40 -0
- package/lib-es/customLockScreen/screenSpecs.js.map +1 -0
- package/lib-es/index.d.ts +23 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +21 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/managerApi/entities/AppEntity.d.ts +62 -0
- package/lib-es/managerApi/entities/AppEntity.d.ts.map +1 -0
- package/lib-es/managerApi/entities/AppEntity.js +9 -0
- package/lib-es/managerApi/entities/AppEntity.js.map +1 -0
- package/lib-es/managerApi/entities/DeviceInfoEntity.d.ts +22 -0
- package/lib-es/managerApi/entities/DeviceInfoEntity.d.ts.map +1 -0
- package/lib-es/managerApi/entities/DeviceInfoEntity.js +2 -0
- package/lib-es/managerApi/entities/DeviceInfoEntity.js.map +1 -0
- package/lib-es/managerApi/entities/DeviceVersionEntity.d.ts +17 -0
- package/lib-es/managerApi/entities/DeviceVersionEntity.d.ts.map +1 -0
- package/lib-es/managerApi/entities/DeviceVersionEntity.js +2 -0
- package/lib-es/managerApi/entities/DeviceVersionEntity.js.map +1 -0
- package/lib-es/managerApi/entities/FirmwareUpdateContextEntity.d.ts +42 -0
- package/lib-es/managerApi/entities/FirmwareUpdateContextEntity.d.ts.map +1 -0
- package/lib-es/managerApi/entities/FirmwareUpdateContextEntity.js +2 -0
- package/lib-es/managerApi/entities/FirmwareUpdateContextEntity.js.map +1 -0
- package/lib-es/managerApi/entities/Id.d.ts +2 -0
- package/lib-es/managerApi/entities/Id.d.ts.map +1 -0
- package/lib-es/managerApi/entities/Id.js +2 -0
- package/lib-es/managerApi/entities/Id.js.map +1 -0
- package/lib-es/managerApi/entities/LanguagePackageEntity.d.ts +20 -0
- package/lib-es/managerApi/entities/LanguagePackageEntity.d.ts.map +1 -0
- package/lib-es/managerApi/entities/LanguagePackageEntity.js +2 -0
- package/lib-es/managerApi/entities/LanguagePackageEntity.js.map +1 -0
- package/lib-es/managerApi/entities/mocks/aDeviceInfo.d.ts +3 -0
- package/lib-es/managerApi/entities/mocks/aDeviceInfo.d.ts.map +1 -0
- package/lib-es/managerApi/entities/mocks/aDeviceInfo.js +4 -0
- package/lib-es/managerApi/entities/mocks/aDeviceInfo.js.map +1 -0
- package/lib-es/managerApi/entities/mocks/aDeviceVersion.d.ts +3 -0
- package/lib-es/managerApi/entities/mocks/aDeviceVersion.d.ts.map +1 -0
- package/lib-es/managerApi/entities/mocks/aDeviceVersion.js +4 -0
- package/lib-es/managerApi/entities/mocks/aDeviceVersion.js.map +1 -0
- package/lib-es/managerApi/entities/mocks/aFinalFirmware.d.ts +3 -0
- package/lib-es/managerApi/entities/mocks/aFinalFirmware.d.ts.map +1 -0
- package/lib-es/managerApi/entities/mocks/aFinalFirmware.js +4 -0
- package/lib-es/managerApi/entities/mocks/aFinalFirmware.js.map +1 -0
- package/lib-es/managerApi/entities/mocks/aOsuFirmware.d.ts +19 -0
- package/lib-es/managerApi/entities/mocks/aOsuFirmware.d.ts.map +1 -0
- package/lib-es/managerApi/entities/mocks/aOsuFirmware.js +4 -0
- package/lib-es/managerApi/entities/mocks/aOsuFirmware.js.map +1 -0
- package/lib-es/managerApi/repositories/HttpManagerApiRepository.d.ts +18 -0
- package/lib-es/managerApi/repositories/HttpManagerApiRepository.d.ts.map +1 -0
- package/lib-es/managerApi/repositories/HttpManagerApiRepository.js +197 -0
- package/lib-es/managerApi/repositories/HttpManagerApiRepository.js.map +1 -0
- package/lib-es/managerApi/repositories/HttpManagerApiRepository.test.d.ts +2 -0
- package/lib-es/managerApi/repositories/HttpManagerApiRepository.test.d.ts.map +1 -0
- package/lib-es/managerApi/repositories/HttpManagerApiRepository.test.js +400 -0
- package/lib-es/managerApi/repositories/HttpManagerApiRepository.test.js.map +1 -0
- package/lib-es/managerApi/repositories/ManagerApiRepository.d.ts +54 -0
- package/lib-es/managerApi/repositories/ManagerApiRepository.d.ts.map +1 -0
- package/lib-es/managerApi/repositories/ManagerApiRepository.js +2 -0
- package/lib-es/managerApi/repositories/ManagerApiRepository.js.map +1 -0
- package/lib-es/managerApi/repositories/StubManagerApiRepository.d.ts +15 -0
- package/lib-es/managerApi/repositories/StubManagerApiRepository.d.ts.map +1 -0
- package/lib-es/managerApi/repositories/StubManagerApiRepository.js +40 -0
- package/lib-es/managerApi/repositories/StubManagerApiRepository.js.map +1 -0
- package/lib-es/managerApi/use-cases/fetchMcus.d.ts +3 -0
- package/lib-es/managerApi/use-cases/fetchMcus.d.ts.map +1 -0
- package/lib-es/managerApi/use-cases/fetchMcus.js +4 -0
- package/lib-es/managerApi/use-cases/fetchMcus.js.map +1 -0
- package/lib-es/managerApi/use-cases/getLatestFirmwareForDevice.d.ts +12 -0
- package/lib-es/managerApi/use-cases/getLatestFirmwareForDevice.d.ts.map +1 -0
- package/lib-es/managerApi/use-cases/getLatestFirmwareForDevice.js +58 -0
- package/lib-es/managerApi/use-cases/getLatestFirmwareForDevice.js.map +1 -0
- package/lib-es/managerApi/use-cases/getLatestFirmwareForDevice.test.d.ts +2 -0
- package/lib-es/managerApi/use-cases/getLatestFirmwareForDevice.test.d.ts.map +1 -0
- package/lib-es/managerApi/use-cases/getLatestFirmwareForDevice.test.js +176 -0
- package/lib-es/managerApi/use-cases/getLatestFirmwareForDevice.test.js.map +1 -0
- package/lib-es/managerApi/use-cases/getProviderIdUseCase.d.ts +7 -0
- package/lib-es/managerApi/use-cases/getProviderIdUseCase.d.ts.map +1 -0
- package/lib-es/managerApi/use-cases/getProviderIdUseCase.js +19 -0
- package/lib-es/managerApi/use-cases/getProviderIdUseCase.js.map +1 -0
- package/lib-es/managerApi/use-cases/getUserHashes.d.ts +5 -0
- package/lib-es/managerApi/use-cases/getUserHashes.d.ts.map +1 -0
- package/lib-es/managerApi/use-cases/getUserHashes.js +26 -0
- package/lib-es/managerApi/use-cases/getUserHashes.js.map +1 -0
- package/package.json +67 -0
- package/src/capabilities/isCustomLockScreenSupported.test.ts +25 -0
- package/src/capabilities/isCustomLockScreenSupported.ts +17 -0
- package/src/capabilities/isEditDeviceNameSupported.test.ts +18 -0
- package/src/capabilities/isEditDeviceNameSupported.ts +5 -0
- package/src/capabilities/isSyncOnboardingSupported.test.ts +16 -0
- package/src/capabilities/isSyncOnboardingSupported.ts +5 -0
- package/src/commands/entities/APDU.ts +12 -0
- package/src/commands/entities/FirmwareInfoEntity.ts +14 -0
- package/src/commands/use-cases/getDeviceName.ts +38 -0
- package/src/commands/use-cases/getVersion.ts +23 -0
- package/src/commands/use-cases/isBootloaderVersionSupported.test.ts +58 -0
- package/src/commands/use-cases/isBootloaderVersionSupported.ts +24 -0
- package/src/commands/use-cases/isDeviceLocalizationSupported.test.ts +48 -0
- package/src/commands/use-cases/isDeviceLocalizationSupported.ts +20 -0
- package/src/commands/use-cases/isHardwareVersionSupported.test.ts +39 -0
- package/src/commands/use-cases/isHardwareVersionSupported.ts +20 -0
- package/src/commands/use-cases/parseGetDeviceNameResponse.test.ts +35 -0
- package/src/commands/use-cases/parseGetDeviceNameResponse.ts +20 -0
- package/src/commands/use-cases/parseGetVersionResponse.test.ts +123 -0
- package/src/commands/use-cases/parseGetVersionResponse.ts +121 -0
- package/src/customLockScreen/screenSpecs.ts +87 -0
- package/src/index.ts +33 -0
- package/src/managerApi/entities/AppEntity.ts +66 -0
- package/src/managerApi/entities/DeviceInfoEntity.ts +26 -0
- package/src/managerApi/entities/DeviceVersionEntity.ts +17 -0
- package/src/managerApi/entities/FirmwareUpdateContextEntity.ts +44 -0
- package/src/managerApi/entities/Id.ts +1 -0
- package/src/managerApi/entities/LanguagePackageEntity.ts +21 -0
- package/src/managerApi/entities/mocks/aDeviceInfo.ts +16 -0
- package/src/managerApi/entities/mocks/aDeviceVersion.ts +22 -0
- package/src/managerApi/entities/mocks/aFinalFirmware.ts +25 -0
- package/src/managerApi/entities/mocks/aOsuFirmware.ts +22 -0
- package/src/managerApi/repositories/HttpManagerApiRepository.test.ts +494 -0
- package/src/managerApi/repositories/HttpManagerApiRepository.ts +284 -0
- package/src/managerApi/repositories/ManagerApiRepository.ts +68 -0
- package/src/managerApi/repositories/StubManagerApiRepository.ts +49 -0
- package/src/managerApi/use-cases/fetchMcus.ts +5 -0
- package/src/managerApi/use-cases/getLatestFirmwareForDevice.test.ts +196 -0
- package/src/managerApi/use-cases/getLatestFirmwareForDevice.ts +66 -0
- package/src/managerApi/use-cases/getProviderIdUseCase.ts +24 -0
- package/src/managerApi/use-cases/getUserHashes.ts +30 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { makeLRUCache } from "@ledgerhq/live-network/cache";
|
|
2
|
+
import network from "@ledgerhq/live-network/network";
|
|
3
|
+
import { FirmwareNotRecognized, NetworkDown } from "@ledgerhq/errors";
|
|
4
|
+
import { getUserHashes } from "../use-cases/getUserHashes";
|
|
5
|
+
import URL from "url";
|
|
6
|
+
import { ManagerApiRepository } from "./ManagerApiRepository";
|
|
7
|
+
import { FinalFirmware, OsuFirmware } from "../entities/FirmwareUpdateContextEntity";
|
|
8
|
+
import { DeviceVersionEntity } from "../entities/DeviceVersionEntity";
|
|
9
|
+
import { ApplicationV2Entity } from "../entities/AppEntity";
|
|
10
|
+
import { DeviceInfoEntity } from "../entities/DeviceInfoEntity";
|
|
11
|
+
import {
|
|
12
|
+
LanguagePackageEntity,
|
|
13
|
+
LanguagePackageResponseEntity,
|
|
14
|
+
} from "../entities/LanguagePackageEntity";
|
|
15
|
+
import { getProviderIdUseCase } from "../use-cases/getProviderIdUseCase";
|
|
16
|
+
|
|
17
|
+
export class HttpManagerApiRepository implements ManagerApiRepository {
|
|
18
|
+
private readonly managerApiBase: string;
|
|
19
|
+
private readonly liveCommonVersion: string;
|
|
20
|
+
|
|
21
|
+
constructor(managerApiBase: string, liveCommonVersion: string) {
|
|
22
|
+
this.managerApiBase = managerApiBase;
|
|
23
|
+
this.liveCommonVersion = liveCommonVersion;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// NB: we are explicitly specifying the type because TypeScript cannot infer
|
|
27
|
+
// properly the return type of `makeLRUCache` without using `any` for the
|
|
28
|
+
// parameters.
|
|
29
|
+
readonly fetchLatestFirmware: ManagerApiRepository["fetchLatestFirmware"] = makeLRUCache(
|
|
30
|
+
async ({ current_se_firmware_final_version, device_version, providerId, userId }) => {
|
|
31
|
+
const salt = getUserHashes(userId).firmwareSalt;
|
|
32
|
+
const {
|
|
33
|
+
data,
|
|
34
|
+
}: {
|
|
35
|
+
data: {
|
|
36
|
+
result: string;
|
|
37
|
+
se_firmware_osu_version: OsuFirmware;
|
|
38
|
+
};
|
|
39
|
+
} = await network({
|
|
40
|
+
method: "POST",
|
|
41
|
+
url: URL.format({
|
|
42
|
+
pathname: `${this.managerApiBase}/get_latest_firmware`,
|
|
43
|
+
query: {
|
|
44
|
+
livecommonversion: this.liveCommonVersion,
|
|
45
|
+
salt,
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
data: {
|
|
49
|
+
current_se_firmware_final_version,
|
|
50
|
+
device_version,
|
|
51
|
+
provider: providerId,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (data.result === "null") {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return data.se_firmware_osu_version;
|
|
60
|
+
},
|
|
61
|
+
a => `${a.current_se_firmware_final_version}_${a.device_version}_${a.providerId}`,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
readonly fetchMcus: ManagerApiRepository["fetchMcus"] = makeLRUCache(
|
|
65
|
+
async () => {
|
|
66
|
+
const { data } = await network({
|
|
67
|
+
method: "GET",
|
|
68
|
+
url: URL.format({
|
|
69
|
+
pathname: `${this.managerApiBase}/mcu_versions`,
|
|
70
|
+
query: {
|
|
71
|
+
livecommonversion: this.liveCommonVersion,
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
return data;
|
|
76
|
+
},
|
|
77
|
+
() => "",
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
readonly getDeviceVersion: ManagerApiRepository["getDeviceVersion"] = makeLRUCache(
|
|
81
|
+
async ({ targetId, providerId }) => {
|
|
82
|
+
const {
|
|
83
|
+
data,
|
|
84
|
+
}: {
|
|
85
|
+
data: DeviceVersionEntity;
|
|
86
|
+
} = await network({
|
|
87
|
+
method: "POST",
|
|
88
|
+
url: URL.format({
|
|
89
|
+
pathname: `${this.managerApiBase}/get_device_version`,
|
|
90
|
+
query: {
|
|
91
|
+
livecommonversion: this.liveCommonVersion,
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
data: {
|
|
95
|
+
provider: providerId,
|
|
96
|
+
target_id: targetId,
|
|
97
|
+
},
|
|
98
|
+
}).catch(error => {
|
|
99
|
+
const status = error?.status || error?.response?.status;
|
|
100
|
+
|
|
101
|
+
if (status === 404)
|
|
102
|
+
throw new FirmwareNotRecognized("manager api did not recognize targetId=" + targetId, {
|
|
103
|
+
targetId,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
throw error;
|
|
107
|
+
});
|
|
108
|
+
return data;
|
|
109
|
+
},
|
|
110
|
+
({ targetId, providerId }) => `${targetId}_${providerId}`,
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
readonly getCurrentOSU: ManagerApiRepository["getCurrentOSU"] = makeLRUCache(
|
|
114
|
+
async input => {
|
|
115
|
+
const { data } = await network({
|
|
116
|
+
method: "POST",
|
|
117
|
+
url: URL.format({
|
|
118
|
+
pathname: `${this.managerApiBase}/get_osu_version`,
|
|
119
|
+
query: {
|
|
120
|
+
livecommonversion: this.liveCommonVersion,
|
|
121
|
+
},
|
|
122
|
+
}),
|
|
123
|
+
data: {
|
|
124
|
+
device_version: input.deviceId,
|
|
125
|
+
version_name: `${input.version}-osu`,
|
|
126
|
+
provider: input.providerId,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
return data;
|
|
130
|
+
},
|
|
131
|
+
a => `${a.version}_${a.deviceId}_${a.providerId}`,
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
readonly getCurrentFirmware: ManagerApiRepository["getCurrentFirmware"] = makeLRUCache(
|
|
135
|
+
async input => {
|
|
136
|
+
const {
|
|
137
|
+
data,
|
|
138
|
+
}: {
|
|
139
|
+
data: FinalFirmware;
|
|
140
|
+
} = await network({
|
|
141
|
+
method: "POST",
|
|
142
|
+
url: URL.format({
|
|
143
|
+
pathname: `${this.managerApiBase}/get_firmware_version`,
|
|
144
|
+
query: {
|
|
145
|
+
livecommonversion: this.liveCommonVersion,
|
|
146
|
+
},
|
|
147
|
+
}),
|
|
148
|
+
data: {
|
|
149
|
+
device_version: input.deviceId,
|
|
150
|
+
version_name: input.version,
|
|
151
|
+
provider: input.providerId,
|
|
152
|
+
},
|
|
153
|
+
}).catch(error => {
|
|
154
|
+
const status = error?.status || error?.response?.status;
|
|
155
|
+
|
|
156
|
+
if (status === 404) throw new FirmwareNotRecognized();
|
|
157
|
+
|
|
158
|
+
throw error;
|
|
159
|
+
});
|
|
160
|
+
return data;
|
|
161
|
+
},
|
|
162
|
+
a => `${a.version}_${a.deviceId}_${a.providerId}`,
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
readonly getFinalFirmwareById: ManagerApiRepository["getFinalFirmwareById"] = makeLRUCache(
|
|
166
|
+
async id => {
|
|
167
|
+
const {
|
|
168
|
+
data,
|
|
169
|
+
}: {
|
|
170
|
+
data: FinalFirmware;
|
|
171
|
+
} = await network({
|
|
172
|
+
method: "GET",
|
|
173
|
+
url: URL.format({
|
|
174
|
+
pathname: `${this.managerApiBase}/firmware_final_versions/${id}`,
|
|
175
|
+
query: {
|
|
176
|
+
livecommonversion: this.liveCommonVersion,
|
|
177
|
+
},
|
|
178
|
+
}),
|
|
179
|
+
});
|
|
180
|
+
return data;
|
|
181
|
+
},
|
|
182
|
+
id => String(id),
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
readonly getAppsByHash: ManagerApiRepository["getAppsByHash"] = makeLRUCache(
|
|
186
|
+
async hashes => {
|
|
187
|
+
const {
|
|
188
|
+
data,
|
|
189
|
+
}: {
|
|
190
|
+
data: Array<ApplicationV2Entity | null>;
|
|
191
|
+
} = await network({
|
|
192
|
+
method: "POST",
|
|
193
|
+
url: URL.format({
|
|
194
|
+
pathname: `${this.managerApiBase}/v2/apps/hash`,
|
|
195
|
+
query: {
|
|
196
|
+
livecommonversion: this.liveCommonVersion,
|
|
197
|
+
},
|
|
198
|
+
}),
|
|
199
|
+
data: hashes,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
if (!data || !Array.isArray(data)) {
|
|
203
|
+
throw new NetworkDown("");
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return data;
|
|
207
|
+
},
|
|
208
|
+
hashes => `${this.managerApiBase}_${hashes.join("-")}`,
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
readonly catalogForDevice: ManagerApiRepository["catalogForDevice"] = makeLRUCache(
|
|
212
|
+
async params => {
|
|
213
|
+
const { provider, targetId, firmwareVersion } = params;
|
|
214
|
+
const {
|
|
215
|
+
data,
|
|
216
|
+
}: {
|
|
217
|
+
data: Array<ApplicationV2Entity>;
|
|
218
|
+
} = await network({
|
|
219
|
+
method: "GET",
|
|
220
|
+
url: URL.format({
|
|
221
|
+
pathname: `${this.managerApiBase}/v2/apps/by-target`,
|
|
222
|
+
query: {
|
|
223
|
+
livecommonversion: this.liveCommonVersion,
|
|
224
|
+
provider,
|
|
225
|
+
target_id: targetId,
|
|
226
|
+
firmware_version_name: firmwareVersion,
|
|
227
|
+
},
|
|
228
|
+
}),
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
if (!data || !Array.isArray(data)) {
|
|
232
|
+
throw new NetworkDown("");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return data;
|
|
236
|
+
},
|
|
237
|
+
a => `${this.managerApiBase}_${a.provider}_${a.targetId}_${a.firmwareVersion}`,
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
readonly getLanguagePackagesForDevice = async (
|
|
241
|
+
deviceInfo: DeviceInfoEntity,
|
|
242
|
+
forceProvider?: number,
|
|
243
|
+
) => {
|
|
244
|
+
const deviceVersion = await this.getDeviceVersion({
|
|
245
|
+
targetId: deviceInfo.targetId,
|
|
246
|
+
providerId: getProviderIdUseCase({ deviceInfo, forceProvider }),
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
const seFirmwareVersion = await this.getCurrentFirmware({
|
|
250
|
+
version: deviceInfo.version,
|
|
251
|
+
deviceId: deviceVersion.id,
|
|
252
|
+
providerId: getProviderIdUseCase({ deviceInfo, forceProvider }),
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
const { data }: { data: LanguagePackageResponseEntity[] } = await network({
|
|
256
|
+
method: "GET",
|
|
257
|
+
url: URL.format({
|
|
258
|
+
pathname: `${this.managerApiBase}/language-package`,
|
|
259
|
+
query: {
|
|
260
|
+
livecommonversion: this.liveCommonVersion,
|
|
261
|
+
},
|
|
262
|
+
}),
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const allPackages: LanguagePackageEntity[] = data.reduce(
|
|
266
|
+
(acc, response) => [
|
|
267
|
+
...acc,
|
|
268
|
+
...response.language_package_version.map(p => ({
|
|
269
|
+
...p,
|
|
270
|
+
language: response.language,
|
|
271
|
+
})),
|
|
272
|
+
],
|
|
273
|
+
[] as LanguagePackageEntity[],
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
const packages = allPackages.filter(
|
|
277
|
+
pack =>
|
|
278
|
+
pack.device_versions.includes(deviceVersion.id) &&
|
|
279
|
+
pack.se_firmware_final_versions.includes(seFirmwareVersion.id),
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
return packages;
|
|
283
|
+
};
|
|
284
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { McuVersion } from "@ledgerhq/types-live";
|
|
2
|
+
import { ApplicationV2Entity } from "../entities/AppEntity";
|
|
3
|
+
import { DeviceInfoEntity } from "../entities/DeviceInfoEntity";
|
|
4
|
+
import { DeviceVersionEntity } from "../entities/DeviceVersionEntity";
|
|
5
|
+
import { FinalFirmware, OsuFirmware } from "../entities/FirmwareUpdateContextEntity";
|
|
6
|
+
import { Id } from "../entities/Id";
|
|
7
|
+
import { LanguagePackageEntity } from "../entities/LanguagePackageEntity";
|
|
8
|
+
|
|
9
|
+
export interface ManagerApiRepository {
|
|
10
|
+
fetchLatestFirmware(params: {
|
|
11
|
+
current_se_firmware_final_version: Id;
|
|
12
|
+
device_version: Id;
|
|
13
|
+
providerId: number;
|
|
14
|
+
userId: string;
|
|
15
|
+
}): Promise<OsuFirmware | null | undefined>;
|
|
16
|
+
|
|
17
|
+
fetchMcus(): Promise<McuVersion[]>;
|
|
18
|
+
|
|
19
|
+
getDeviceVersion({
|
|
20
|
+
targetId,
|
|
21
|
+
providerId,
|
|
22
|
+
}: {
|
|
23
|
+
targetId: string | number;
|
|
24
|
+
providerId: number;
|
|
25
|
+
}): Promise<DeviceVersionEntity>;
|
|
26
|
+
|
|
27
|
+
getCurrentOSU(params: {
|
|
28
|
+
deviceId: string | number;
|
|
29
|
+
providerId: string | number;
|
|
30
|
+
version: string;
|
|
31
|
+
}): Promise<OsuFirmware>;
|
|
32
|
+
|
|
33
|
+
getCurrentFirmware(params: {
|
|
34
|
+
version: string;
|
|
35
|
+
deviceId: string | number;
|
|
36
|
+
providerId: number;
|
|
37
|
+
}): Promise<FinalFirmware>;
|
|
38
|
+
|
|
39
|
+
getFinalFirmwareById(id: number): Promise<FinalFirmware>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Resolve applications details by hashes.
|
|
43
|
+
* Order of outputs matches order of inputs.
|
|
44
|
+
* If an application version is not found, a null is returned instead.
|
|
45
|
+
* If several versions match the same hash, only the latest one is returned.
|
|
46
|
+
*
|
|
47
|
+
* Given an array of hashes that we can obtain by either listInstalledApps in this same
|
|
48
|
+
* API (a websocket connection to a scriptrunner) or via direct apdus using hw/listApps.ts
|
|
49
|
+
* retrieve all the information needed from the backend for those applications.
|
|
50
|
+
*/
|
|
51
|
+
getAppsByHash(hashes: string[]): Promise<Array<ApplicationV2Entity | null>>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Return a list of App that are available for a given firmware version on a provider.
|
|
55
|
+
* Prevents the call to ManagerAPI.listApps which includes all versions of all apps and
|
|
56
|
+
* was causing slower access to the manager.
|
|
57
|
+
*/
|
|
58
|
+
catalogForDevice: (params: {
|
|
59
|
+
provider: number;
|
|
60
|
+
targetId: number | string;
|
|
61
|
+
firmwareVersion: string;
|
|
62
|
+
}) => Promise<Array<ApplicationV2Entity>>;
|
|
63
|
+
|
|
64
|
+
getLanguagePackagesForDevice: (
|
|
65
|
+
deviceInfo: DeviceInfoEntity,
|
|
66
|
+
forceProvider?: number,
|
|
67
|
+
) => Promise<LanguagePackageEntity[]>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DeviceVersionEntity } from "../entities/DeviceVersionEntity";
|
|
2
|
+
import { FinalFirmware, OsuFirmware } from "../entities/FirmwareUpdateContextEntity";
|
|
3
|
+
import { aDeviceVersionBuilder } from "../entities/mocks/aDeviceVersion";
|
|
4
|
+
import { aFinalFirmwareBuilder } from "../entities/mocks/aFinalFirmware";
|
|
5
|
+
import { aOsuFirmwareBuilder } from "../entities/mocks/aOsuFirmware";
|
|
6
|
+
import { ManagerApiRepository } from "./ManagerApiRepository";
|
|
7
|
+
|
|
8
|
+
export class StubManagerApiRepository implements ManagerApiRepository {
|
|
9
|
+
readonly fetchLatestFirmware = () => {
|
|
10
|
+
const result: OsuFirmware = aOsuFirmwareBuilder();
|
|
11
|
+
return Promise.resolve(result);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
readonly fetchMcus = () => {
|
|
15
|
+
return Promise.resolve([]);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
readonly getDeviceVersion = () => {
|
|
19
|
+
const result: DeviceVersionEntity = aDeviceVersionBuilder();
|
|
20
|
+
return Promise.resolve(result);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
readonly getCurrentOSU = () => {
|
|
24
|
+
const result: OsuFirmware = aOsuFirmwareBuilder();
|
|
25
|
+
return Promise.resolve(result);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
readonly getCurrentFirmware = () => {
|
|
29
|
+
const result: FinalFirmware = aFinalFirmwareBuilder();
|
|
30
|
+
return Promise.resolve(result);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
readonly getFinalFirmwareById = () => {
|
|
34
|
+
const result: FinalFirmware = aFinalFirmwareBuilder();
|
|
35
|
+
return Promise.resolve(result);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
readonly getAppsByHash = () => {
|
|
39
|
+
return Promise.resolve([]);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
readonly catalogForDevice = () => {
|
|
43
|
+
return Promise.resolve([]);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
readonly getLanguagePackagesForDevice = () => {
|
|
47
|
+
return Promise.resolve([]);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { getLatestFirmwareForDevice } from "./getLatestFirmwareForDevice";
|
|
2
|
+
import { ManagerApiRepository } from "../repositories/ManagerApiRepository";
|
|
3
|
+
import { DeviceVersion, FinalFirmware, McuVersion, OsuFirmware } from "@ledgerhq/types-live";
|
|
4
|
+
import { UnknownMCU } from "@ledgerhq/errors";
|
|
5
|
+
import { StubManagerApiRepository } from "../repositories/StubManagerApiRepository";
|
|
6
|
+
import { aDeviceInfoBuilder } from "../entities/mocks/aDeviceInfo";
|
|
7
|
+
|
|
8
|
+
jest.mock("../repositories/ManagerApiRepository");
|
|
9
|
+
|
|
10
|
+
describe("getLatestFirmwareForDevice", () => {
|
|
11
|
+
let mockedManagerApiRepository: ManagerApiRepository;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
// Clear the methods we are using in our test
|
|
15
|
+
jest.resetAllMocks();
|
|
16
|
+
mockedManagerApiRepository = new StubManagerApiRepository();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("throws an Error for unknown mcu", async () => {
|
|
20
|
+
// given
|
|
21
|
+
// Using a fixture builder - we could create that for all our entities
|
|
22
|
+
const deviceInfo = aDeviceInfoBuilder({ mcuVersion: "42", isOSU: true });
|
|
23
|
+
|
|
24
|
+
jest.spyOn(mockedManagerApiRepository, "fetchMcus").mockResolvedValue([]);
|
|
25
|
+
jest
|
|
26
|
+
.spyOn(mockedManagerApiRepository, "getDeviceVersion")
|
|
27
|
+
.mockResolvedValue({ id: 42 } as DeviceVersion);
|
|
28
|
+
jest.spyOn(mockedManagerApiRepository, "getCurrentOSU").mockResolvedValue({} as OsuFirmware);
|
|
29
|
+
|
|
30
|
+
const params = {
|
|
31
|
+
deviceInfo,
|
|
32
|
+
providerId: 42,
|
|
33
|
+
userId: "",
|
|
34
|
+
managerApiRepository: mockedManagerApiRepository,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// when
|
|
38
|
+
const response = getLatestFirmwareForDevice(params);
|
|
39
|
+
// then
|
|
40
|
+
expect(response).rejects.toBeInstanceOf(UnknownMCU);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("should return an update without flashing mcu", async () => {
|
|
44
|
+
// Given
|
|
45
|
+
const deviceInfo = aDeviceInfoBuilder({ isOSU: false, mcuVersion: "42" });
|
|
46
|
+
|
|
47
|
+
jest
|
|
48
|
+
.spyOn(mockedManagerApiRepository, "getDeviceVersion")
|
|
49
|
+
.mockResolvedValue({ id: 42 } as DeviceVersion);
|
|
50
|
+
jest
|
|
51
|
+
.spyOn(mockedManagerApiRepository, "fetchMcus")
|
|
52
|
+
.mockResolvedValue(Promise.resolve([{ name: "42", id: 42 } as McuVersion]));
|
|
53
|
+
jest
|
|
54
|
+
.spyOn(mockedManagerApiRepository, "getCurrentFirmware")
|
|
55
|
+
.mockResolvedValue({ se_firmware: 21 } as FinalFirmware);
|
|
56
|
+
jest
|
|
57
|
+
.spyOn(mockedManagerApiRepository, "fetchLatestFirmware")
|
|
58
|
+
.mockResolvedValue({} as OsuFirmware);
|
|
59
|
+
jest
|
|
60
|
+
.spyOn(mockedManagerApiRepository, "getFinalFirmwareById")
|
|
61
|
+
.mockResolvedValue({ mcu_versions: [42] } as FinalFirmware);
|
|
62
|
+
|
|
63
|
+
const params = {
|
|
64
|
+
deviceInfo,
|
|
65
|
+
providerId: 42,
|
|
66
|
+
userId: "",
|
|
67
|
+
managerApiRepository: mockedManagerApiRepository,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// When
|
|
71
|
+
const result = await getLatestFirmwareForDevice(params);
|
|
72
|
+
|
|
73
|
+
// Then
|
|
74
|
+
expect(result).toMatchObject({ shouldFlashMCU: false });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("shouldn't return an available update when no mcu found", async () => {
|
|
78
|
+
// Given
|
|
79
|
+
const deviceInfo = aDeviceInfoBuilder({ isOSU: false, mcuVersion: "42" });
|
|
80
|
+
|
|
81
|
+
jest
|
|
82
|
+
.spyOn(mockedManagerApiRepository, "getDeviceVersion")
|
|
83
|
+
.mockResolvedValue({ id: 42 } as DeviceVersion);
|
|
84
|
+
jest
|
|
85
|
+
.spyOn(mockedManagerApiRepository, "fetchMcus")
|
|
86
|
+
.mockResolvedValue(Promise.resolve([{ name: "42", id: 42 } as McuVersion]));
|
|
87
|
+
jest
|
|
88
|
+
.spyOn(mockedManagerApiRepository, "getCurrentFirmware")
|
|
89
|
+
.mockResolvedValue({ id: 21 } as FinalFirmware);
|
|
90
|
+
jest.spyOn(mockedManagerApiRepository, "fetchLatestFirmware").mockResolvedValue(null);
|
|
91
|
+
|
|
92
|
+
const params = {
|
|
93
|
+
deviceInfo,
|
|
94
|
+
providerId: 42,
|
|
95
|
+
userId: "",
|
|
96
|
+
managerApiRepository: mockedManagerApiRepository,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// When
|
|
100
|
+
const result = await getLatestFirmwareForDevice(params);
|
|
101
|
+
|
|
102
|
+
// Then
|
|
103
|
+
expect(result).toBeNull();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("should return an available OS update", async () => {
|
|
107
|
+
// Given
|
|
108
|
+
const deviceInfo = aDeviceInfoBuilder({ isOSU: false, mcuVersion: "42" });
|
|
109
|
+
|
|
110
|
+
jest
|
|
111
|
+
.spyOn(mockedManagerApiRepository, "getDeviceVersion")
|
|
112
|
+
.mockResolvedValue({ id: 42 } as DeviceVersion);
|
|
113
|
+
jest
|
|
114
|
+
.spyOn(mockedManagerApiRepository, "fetchMcus")
|
|
115
|
+
.mockResolvedValue(Promise.resolve([{ name: "42", id: 42 } as McuVersion]));
|
|
116
|
+
jest
|
|
117
|
+
.spyOn(mockedManagerApiRepository, "getCurrentFirmware")
|
|
118
|
+
.mockResolvedValue({ se_firmware: 21 } as FinalFirmware);
|
|
119
|
+
jest
|
|
120
|
+
.spyOn(mockedManagerApiRepository, "fetchLatestFirmware")
|
|
121
|
+
.mockResolvedValue({} as OsuFirmware);
|
|
122
|
+
jest.spyOn(mockedManagerApiRepository, "getFinalFirmwareById").mockResolvedValue({
|
|
123
|
+
name: "VERSION_UPDATE_TEST",
|
|
124
|
+
mcu_versions: [42],
|
|
125
|
+
} as FinalFirmware);
|
|
126
|
+
|
|
127
|
+
const params = {
|
|
128
|
+
deviceInfo,
|
|
129
|
+
providerId: 42,
|
|
130
|
+
userId: "",
|
|
131
|
+
managerApiRepository: mockedManagerApiRepository,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// When
|
|
135
|
+
const result = await getLatestFirmwareForDevice(params);
|
|
136
|
+
|
|
137
|
+
// Then
|
|
138
|
+
expect(result).toHaveProperty(["final"]);
|
|
139
|
+
expect(result).toHaveProperty(["osu"]);
|
|
140
|
+
expect(result).toHaveProperty(["shouldFlashMCU"]);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("should return an update with device isOSU true", async () => {
|
|
144
|
+
const deviceInfo = aDeviceInfoBuilder({ mcuVersion: "42" });
|
|
145
|
+
jest
|
|
146
|
+
.spyOn(mockedManagerApiRepository, "fetchMcus")
|
|
147
|
+
.mockResolvedValue(Promise.resolve([{ name: "42", id: 42 } as McuVersion]));
|
|
148
|
+
jest
|
|
149
|
+
.spyOn(mockedManagerApiRepository, "getDeviceVersion")
|
|
150
|
+
.mockResolvedValue({ id: 42 } as DeviceVersion);
|
|
151
|
+
jest.spyOn(mockedManagerApiRepository, "getCurrentOSU").mockResolvedValue({} as OsuFirmware);
|
|
152
|
+
jest.spyOn(mockedManagerApiRepository, "getFinalFirmwareById").mockResolvedValue({
|
|
153
|
+
name: "VERSION_UPDATE_TEST",
|
|
154
|
+
mcu_versions: [42],
|
|
155
|
+
} as FinalFirmware);
|
|
156
|
+
const params = {
|
|
157
|
+
deviceInfo,
|
|
158
|
+
providerId: 42,
|
|
159
|
+
userId: "",
|
|
160
|
+
managerApiRepository: mockedManagerApiRepository,
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// When
|
|
164
|
+
const result = await getLatestFirmwareForDevice(params);
|
|
165
|
+
|
|
166
|
+
// Then
|
|
167
|
+
expect(result).toHaveProperty(["final"]);
|
|
168
|
+
expect(result).toHaveProperty(["osu"]);
|
|
169
|
+
expect(result).toHaveProperty(["shouldFlashMCU"]);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("shouldn't return an update with device isOSU true", async () => {
|
|
173
|
+
const deviceInfo = aDeviceInfoBuilder({ mcuVersion: "42" });
|
|
174
|
+
jest
|
|
175
|
+
.spyOn(mockedManagerApiRepository, "fetchMcus")
|
|
176
|
+
.mockResolvedValue(Promise.resolve([{ name: "42", id: 42 } as McuVersion]));
|
|
177
|
+
jest
|
|
178
|
+
.spyOn(mockedManagerApiRepository, "getDeviceVersion")
|
|
179
|
+
.mockResolvedValue({ id: 42 } as DeviceVersion);
|
|
180
|
+
jest
|
|
181
|
+
.spyOn(mockedManagerApiRepository, "getCurrentOSU")
|
|
182
|
+
.mockResolvedValue(null as unknown as OsuFirmware);
|
|
183
|
+
const params = {
|
|
184
|
+
deviceInfo,
|
|
185
|
+
providerId: 42,
|
|
186
|
+
userId: "",
|
|
187
|
+
managerApiRepository: mockedManagerApiRepository,
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// When
|
|
191
|
+
const result = await getLatestFirmwareForDevice(params);
|
|
192
|
+
|
|
193
|
+
// Then
|
|
194
|
+
expect(result).toBeNull();
|
|
195
|
+
});
|
|
196
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { UnknownMCU } from "@ledgerhq/errors";
|
|
2
|
+
import { DeviceInfoEntity } from "../entities/DeviceInfoEntity";
|
|
3
|
+
import { FirmwareUpdateContextEntity } from "../entities/FirmwareUpdateContextEntity";
|
|
4
|
+
import { ManagerApiRepository } from "../repositories/ManagerApiRepository";
|
|
5
|
+
|
|
6
|
+
type GetLatestFirmwareForDeviceParams = {
|
|
7
|
+
deviceInfo: DeviceInfoEntity;
|
|
8
|
+
providerId: number;
|
|
9
|
+
userId: string;
|
|
10
|
+
managerApiRepository: ManagerApiRepository;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export async function getLatestFirmwareForDevice({
|
|
14
|
+
deviceInfo,
|
|
15
|
+
providerId,
|
|
16
|
+
userId,
|
|
17
|
+
managerApiRepository,
|
|
18
|
+
}: GetLatestFirmwareForDeviceParams): Promise<FirmwareUpdateContextEntity | null> {
|
|
19
|
+
const mcusPromise = managerApiRepository.fetchMcus();
|
|
20
|
+
|
|
21
|
+
// Gets device infos from targetId
|
|
22
|
+
const deviceVersion = await managerApiRepository.getDeviceVersion({
|
|
23
|
+
targetId: deviceInfo.targetId,
|
|
24
|
+
providerId,
|
|
25
|
+
});
|
|
26
|
+
let osu;
|
|
27
|
+
|
|
28
|
+
if (deviceInfo.isOSU) {
|
|
29
|
+
osu = await managerApiRepository.getCurrentOSU({
|
|
30
|
+
deviceId: deviceVersion.id,
|
|
31
|
+
providerId,
|
|
32
|
+
version: deviceInfo.version,
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
// Gets firmware infos with firmware name and device version
|
|
36
|
+
const seFirmwareVersion = await managerApiRepository.getCurrentFirmware({
|
|
37
|
+
version: deviceInfo.version,
|
|
38
|
+
deviceId: deviceVersion.id,
|
|
39
|
+
providerId,
|
|
40
|
+
});
|
|
41
|
+
// Fetches next possible firmware
|
|
42
|
+
osu = await managerApiRepository.fetchLatestFirmware({
|
|
43
|
+
current_se_firmware_final_version: seFirmwareVersion.id,
|
|
44
|
+
device_version: deviceVersion.id,
|
|
45
|
+
userId,
|
|
46
|
+
providerId,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!osu) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const mcus = await mcusPromise;
|
|
55
|
+
const currentMcuVersion = mcus.find(mcu => mcu.name === deviceInfo.mcuVersion);
|
|
56
|
+
|
|
57
|
+
if (!currentMcuVersion) throw new UnknownMCU();
|
|
58
|
+
|
|
59
|
+
const final = await managerApiRepository.getFinalFirmwareById(osu.next_se_firmware_final_version);
|
|
60
|
+
const shouldFlashMCU = !final.mcu_versions.includes(currentMcuVersion.id);
|
|
61
|
+
return {
|
|
62
|
+
final,
|
|
63
|
+
osu,
|
|
64
|
+
shouldFlashMCU,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DeviceInfoEntity } from "../entities/DeviceInfoEntity";
|
|
2
|
+
|
|
3
|
+
export const PROVIDERS: Record<string, number> = {
|
|
4
|
+
default: 1,
|
|
5
|
+
das: 2,
|
|
6
|
+
club: 3,
|
|
7
|
+
shitcoins: 4,
|
|
8
|
+
ee: 5,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function getProviderIdUseCase({
|
|
12
|
+
deviceInfo,
|
|
13
|
+
forceProvider,
|
|
14
|
+
}: {
|
|
15
|
+
deviceInfo: DeviceInfoEntity | undefined | null;
|
|
16
|
+
forceProvider?: number;
|
|
17
|
+
}): number {
|
|
18
|
+
if (forceProvider && forceProvider !== PROVIDERS.default) return forceProvider;
|
|
19
|
+
if (!deviceInfo) return PROVIDERS.default;
|
|
20
|
+
const { providerName } = deviceInfo;
|
|
21
|
+
const maybeProvider = providerName && PROVIDERS[providerName];
|
|
22
|
+
if (maybeProvider) return maybeProvider;
|
|
23
|
+
return 1;
|
|
24
|
+
}
|