@ledgerhq/device-management-kit 0.0.0-develop-20260813001639 → 0.0.0-develop-20260815000734
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/lib/cjs/package.json +1 -1
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +3 -3
- package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.js +1 -1
- package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.js.map +2 -2
- package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.test.js +1 -1
- package/lib/cjs/src/internal/manager-api/data/HttpManagerApiDataSource.test.js.map +2 -2
- package/lib/cjs/src/internal/manager-api/model/Firmware.js +1 -1
- package/lib/cjs/src/internal/manager-api/model/Firmware.js.map +1 -1
- package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
- package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.js.map +2 -2
- package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
- package/lib/cjs/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
- package/lib/cjs/src/internal/manager-api/service/ManagerApiService.js +1 -1
- package/lib/cjs/src/internal/manager-api/service/ManagerApiService.js.map +1 -1
- package/lib/cjs/src/internal/secure-channel/model/Errors.js +1 -1
- package/lib/cjs/src/internal/secure-channel/model/Errors.js.map +2 -2
- package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js +1 -1
- package/lib/cjs/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +3 -3
- package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js +1 -1
- package/lib/cjs/src/internal/secure-channel/service/SecureChannelService.js.map +1 -1
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.js +1 -1
- package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.js.map +2 -2
- package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.test.js +1 -1
- package/lib/esm/src/internal/manager-api/data/HttpManagerApiDataSource.test.js.map +2 -2
- package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js +1 -1
- package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.js.map +2 -2
- package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js +1 -1
- package/lib/esm/src/internal/manager-api/service/DefaultManagerApiService.test.js.map +3 -3
- package/lib/esm/src/internal/secure-channel/model/Errors.js +1 -1
- package/lib/esm/src/internal/secure-channel/model/Errors.js.map +3 -3
- package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js +1 -1
- package/lib/esm/src/internal/secure-channel/service/DefaultSecureChannelService.js.map +3 -3
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +2 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
- package/lib/types/src/api/index.d.ts +2 -0
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/data/HttpManagerApiDataSource.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/model/Firmware.d.ts +1 -0
- package/lib/types/src/internal/manager-api/model/Firmware.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/service/DefaultManagerApiService.d.ts +1 -0
- package/lib/types/src/internal/manager-api/service/DefaultManagerApiService.d.ts.map +1 -1
- package/lib/types/src/internal/manager-api/service/ManagerApiService.d.ts +6 -0
- package/lib/types/src/internal/manager-api/service/ManagerApiService.d.ts.map +1 -1
- package/lib/types/src/internal/secure-channel/model/Errors.d.ts +8 -1
- package/lib/types/src/internal/secure-channel/model/Errors.d.ts.map +1 -1
- package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts +1 -1
- package/lib/types/src/internal/secure-channel/service/DefaultSecureChannelService.d.ts.map +1 -1
- package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts +2 -2
- package/lib/types/src/internal/secure-channel/service/SecureChannelService.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +2 -2
package/lib/esm/src/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Apdu as r}from"./apdu/model/Apdu";import{APDU_MAX_PAYLOAD as p,ApduBuilder as a}from"./apdu/utils/ApduBuilder";import{ApduParser as i}from"./apdu/utils/ApduParser";export*from"./apdu/utils/AppBuilderError";import{ByteArrayBuilder as c}from"./apdu/utils/ByteArrayBuilder";import{ByteArrayParser as
|
|
1
|
+
import{Apdu as r}from"./apdu/model/Apdu";import{APDU_MAX_PAYLOAD as p,ApduBuilder as a}from"./apdu/utils/ApduBuilder";import{ApduParser as i}from"./apdu/utils/ApduParser";export*from"./apdu/utils/AppBuilderError";import{ByteArrayBuilder as c}from"./apdu/utils/ByteArrayBuilder";import{ByteArrayParser as f}from"./apdu/utils/ByteArrayParser";import{InvalidResponseFormatError as D,InvalidStatusWordError as x}from"./command/Errors";import{CommandResultFactory as l,CommandResultStatus as g,isSuccessCommandResult as y}from"./command/model/CommandResult";import{CloseAppCommand as v}from"./command/os/CloseAppCommand";import{DeleteLanguagePackCommand as L,DeleteLanguagePackCommandError as k}from"./command/os/DeleteLanguagePackCommand";import{GetAppAndVersionCommand as R}from"./command/os/GetAppAndVersionCommand";import{GetBackgroundImageSizeCommand as I,GetBackgroundImageSizeCommandError as T}from"./command/os/GetBackgroundImageSizeCommand";import{BatteryStatusType as h,GetBatteryStatusCommand as P}from"./command/os/GetBatteryStatusCommand";import{GetOsVersionCommand as O}from"./command/os/GetOsVersionCommand";import{ListAppsCommand as M}from"./command/os/ListAppsCommand";import{ListLanguagePackCommand as U,ListLanguagePackCommandError as W}from"./command/os/ListLanguagePackCommand";import{LoadCertificateCommand as _}from"./command/os/LoadCertificateCommand";import{OpenAppCommand as z}from"./command/os/OpenAppCommand";import{isCommandErrorCode as H}from"./command/utils/CommandErrors";import{CommandUtils as Q}from"./command/utils/CommandUtils";import{GLOBAL_ERRORS as Y,GlobalCommandError as j,GlobalCommandErrorHandler as J}from"./command/utils/GlobalCommandError";import{DeviceModel as $,DeviceModelId as ee,LEDGER_VENDOR_ID as oe}from"./device/DeviceModel";import{DeviceStatus as te}from"./device/DeviceStatus";import{DeviceActionStatus as ae}from"./device-action/model/DeviceActionState";import{UserInteractionRequired as ie}from"./device-action/model/UserInteractionRequired";import{CallTaskInAppDeviceAction as se}from"./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction";import{DEFAULT_UNLOCK_TIMEOUT_MS as de}from"./device-action/os/Const";import{AppAlreadyInstalledDAError as Ae,DeleteLanguagePackDAError as De,DeviceLockedError as xe,DeviceNotOnboardedError as ue,OutOfMemoryDAError as le,RefusedByUserDAError as ge,UnknownDAError as ye,UnsupportedFirmwareDAError as Ce}from"./device-action/os/Errors";import{GetDeviceMetadataDeviceAction as Se}from"./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction";import{GetDeviceStatusDeviceAction as ke}from"./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{GoToDashboardDeviceAction as Re}from"./device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{InstallLanguagePackageDeviceAction as Ie}from"./device-action/os/InstallLanguagePackage/InstallLanguagePackageDeviceAction";import{InstallOrUpdateAppsDeviceAction as Be}from"./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction";import{ListAppsDeviceAction as Pe}from"./device-action/os/ListApps/ListAppsDeviceAction";import{ListAppsWithMetadataDeviceAction as Oe}from"./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction";import{OpenAppDeviceAction as Me}from"./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{OpenAppWithDependenciesDeviceAction as Ue}from"./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction";import{SendCommandInAppDeviceAction as Ne}from"./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction";import{WaitForAppAndVersionDeviceAction as we}from"./device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction";import{GetApplicationsMetadataTaskError as qe,InvalidGetFirmwareMetadataResponseError as He}from"./device-action/task/Errors";import{XStateDeviceAction as Qe}from"./device-action/xstate-utils/XStateDeviceAction";import{StaticDeviceModelDataSource as Ye}from"./device-model/data/StaticDeviceModelDataSource";import{BleDeviceInfos as Je}from"./device-model/model/BleDeviceInfos";import{TransportDeviceModel as $e}from"./device-model/model/DeviceModel";import{ApduResponse as oo}from"./device-session/ApduResponse";export*from"./device-session/data/FramerConst";import{DeviceSessionStateType as po}from"./device-session/DeviceSessionState";import{DmkResultFactory as no,DmkResultStatus as io,isSuccessDmkResult as mo}from"./model/DmkResult";import{GenuineCheckDeviceAction as co}from"./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction";import{InstallAppDeviceAction as Ao}from"./secure-channel/device-action/InstallApp/InstallAppDeviceAction";import{ListInstalledAppsDeviceAction as xo}from"./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction";import{UninstallAppDeviceAction as lo}from"./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction";import{ConnectToSecureChannelTask as yo}from"./secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as vo}from"./secure-channel/task/types";import{SecureChannelError as Lo}from"../internal/secure-channel/model/Errors";import{defaultApduReceiverServiceStubBuilder as Eo}from"./device-session/service/DefaultApduReceiverService.stub";import{defaultApduSenderServiceStubBuilder as Go}from"./device-session/service/DefaultApduSenderService.stub";import{FramerUtils as To}from"./device-session/utils/FramerUtils";import{DeviceManagementKit as ho}from"./DeviceManagementKit";import{DeviceManagementKitBuilder as bo}from"./DeviceManagementKitBuilder";export*from"./Error";import{noopLogger as Mo,noopLoggerFactory as Vo}from"./logger-publisher/utils/noopLoggerFactory";import{LogLevel as Wo}from"./logger-subscriber/model/LogLevel";import{ConsoleLogger as _o}from"./logger-subscriber/service/ConsoleLogger";import{DefaultLogTagFormatter as zo}from"./logger-subscriber/service/DefaultLogTagFormatter";import{WebLogsExporterLogger as Ho}from"./logger-subscriber/service/WebLogsExporterLogger";import{DmkNetworkClient as Qo}from"./network/DmkNetworkClient";import{DmkNetworkClientError as Yo}from"./network/DmkNetworkClientError";import{ConnectedDevice as Jo}from"./transport/model/ConnectedDevice";import{DeviceConnectionStateMachine as $o}from"./transport/model/DeviceConnectionStateMachine";export*from"./transport/model/Errors";import{TransportConnectedDevice as rr}from"./transport/model/TransportConnectedDevice";import{connectedDeviceStubBuilder as pr}from"./transport/model/TransportConnectedDevice.stub";export*from"./types";import{formatApduReceivedLog as ir,formatApduSentLog as mr}from"./utils/apduLogs";import{ApplicationChecker as cr}from"./utils/ApplicationChecker";import{isDashboardName as fr}from"./utils/AppName";import{base64StringToBuffer as Dr,bufferToBase64String as xr,isBase64String as ur}from"./utils/Base64String";import{bufferToHexaString as gr,hexaStringToBuffer as yr,isHexaString as Cr}from"./utils/HexaString";export{p as APDU_MAX_PAYLOAD,r as Apdu,a as ApduBuilder,i as ApduParser,oo as ApduResponse,Ae as AppAlreadyInstalledDAError,cr as ApplicationChecker,h as BatteryStatusType,Je as BleDeviceInfos,c as ByteArrayBuilder,f as ByteArrayParser,se as CallTaskInAppDeviceAction,v as CloseAppCommand,l as CommandResultFactory,g as CommandResultStatus,Q as CommandUtils,yo as ConnectToSecureChannelTask,Jo as ConnectedDevice,_o as ConsoleLogger,de as DEFAULT_UNLOCK_TIMEOUT_MS,zo as DefaultLogTagFormatter,L as DeleteLanguagePackCommand,k as DeleteLanguagePackCommandError,De as DeleteLanguagePackDAError,ae as DeviceActionStatus,$o as DeviceConnectionStateMachine,xe as DeviceLockedError,ho as DeviceManagementKit,bo as DeviceManagementKitBuilder,$ as DeviceModel,ee as DeviceModelId,ue as DeviceNotOnboardedError,po as DeviceSessionStateType,te as DeviceStatus,Qo as DmkNetworkClient,Yo as DmkNetworkClientError,no as DmkResultFactory,io as DmkResultStatus,To as FramerUtils,Y as GLOBAL_ERRORS,co as GenuineCheckDeviceAction,R as GetAppAndVersionCommand,qe as GetApplicationsMetadataTaskError,I as GetBackgroundImageSizeCommand,T as GetBackgroundImageSizeCommandError,P as GetBatteryStatusCommand,Se as GetDeviceMetadataDeviceAction,ke as GetDeviceStatusDeviceAction,O as GetOsVersionCommand,j as GlobalCommandError,J as GlobalCommandErrorHandler,Re as GoToDashboardDeviceAction,Ao as InstallAppDeviceAction,Ie as InstallLanguagePackageDeviceAction,Be as InstallOrUpdateAppsDeviceAction,He as InvalidGetFirmwareMetadataResponseError,D as InvalidResponseFormatError,x as InvalidStatusWordError,oe as LEDGER_VENDOR_ID,M as ListAppsCommand,Pe as ListAppsDeviceAction,Oe as ListAppsWithMetadataDeviceAction,xo as ListInstalledAppsDeviceAction,U as ListLanguagePackCommand,W as ListLanguagePackCommandError,_ as LoadCertificateCommand,Wo as LogLevel,z as OpenAppCommand,Me as OpenAppDeviceAction,Ue as OpenAppWithDependenciesDeviceAction,le as OutOfMemoryDAError,ge as RefusedByUserDAError,Lo as SecureChannelError,vo as SecureChannelEventType,Ne as SendCommandInAppDeviceAction,Ye as StaticDeviceModelDataSource,rr as TransportConnectedDevice,$e as TransportDeviceModel,lo as UninstallAppDeviceAction,ye as UnknownDAError,Ce as UnsupportedFirmwareDAError,ie as UserInteractionRequired,we as WaitForAppAndVersionDeviceAction,Ho as WebLogsExporterLogger,Qe as XStateDeviceAction,Dr as base64StringToBuffer,xr as bufferToBase64String,gr as bufferToHexaString,pr as connectedDeviceStubBuilder,Eo as defaultApduReceiverServiceStubBuilder,Go as defaultApduSenderServiceStubBuilder,ir as formatApduReceivedLog,mr as formatApduSentLog,yr as hexaStringToBuffer,ur as isBase64String,H as isCommandErrorCode,fr as isDashboardName,Cr as isHexaString,y as isSuccessCommandResult,mo as isSuccessDmkResult,Mo as noopLogger,Vo as noopLoggerFactory};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/index.ts"],
|
|
4
|
-
"sourcesContent": ["\"use strict\";\n\nexport { Apdu } from \"@api/apdu/model/Apdu\";\nexport { APDU_MAX_PAYLOAD, ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nexport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nexport * from \"@api/apdu/utils/AppBuilderError\";\nexport { ByteArrayBuilder } from \"@api/apdu/utils/ByteArrayBuilder\";\nexport { ByteArrayParser } from \"@api/apdu/utils/ByteArrayParser\";\nexport { type Command } from \"@api/command/Command\";\nexport {\n InvalidResponseFormatError,\n InvalidStatusWordError,\n} from \"@api/command/Errors\";\nexport {\n CommandResultFactory,\n CommandResultStatus,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nexport { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nexport {\n DeleteLanguagePackCommand,\n type DeleteLanguagePackCommandArgs,\n DeleteLanguagePackCommandError,\n type DeleteLanguagePackCommandResult,\n type DeleteLanguagePackErrorCodes,\n} from \"@api/command/os/DeleteLanguagePackCommand\";\nexport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n GetBackgroundImageSizeCommand,\n GetBackgroundImageSizeCommandError,\n type GetBackgroundImageSizeCommandResult,\n type GetBackgroundImageSizeErrorCodes,\n type GetBackgroundImageSizeResponse,\n} from \"@api/command/os/GetBackgroundImageSizeCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n ListLanguagePackCommand,\n type ListLanguagePackCommandArgs,\n ListLanguagePackCommandError,\n type ListLanguagePackCommandResult,\n type ListLanguagePackErrorCodes,\n type ListLanguagePackResponse,\n} from \"@api/command/os/ListLanguagePackCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nexport {\n AppAlreadyInstalledDAError,\n DeleteLanguagePackDAError,\n DeviceLockedError,\n DeviceNotOnboardedError,\n OutOfMemoryDAError,\n RefusedByUserDAError,\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nexport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nexport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nexport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nexport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n GoToDashboardDARequiredInteraction,\n GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport { InstallLanguagePackageDeviceAction } from \"@api/device-action/os/InstallLanguagePackage/InstallLanguagePackageDeviceAction\";\nexport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nexport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nexport { ListAppsWithMetadataDeviceAction } from \"@api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction\";\nexport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nexport { OpenAppWithDependenciesDeviceAction } from \"@api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction\";\nexport { SendCommandInAppDeviceAction } from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction\";\nexport type {\n WaitForAppAndVersionDAError,\n WaitForAppAndVersionDAInput,\n WaitForAppAndVersionDAIntermediateValue,\n WaitForAppAndVersionDAOutput,\n WaitForAppAndVersionDARequiredInteraction,\n WaitForAppAndVersionDAState,\n} from \"@api/device-action/os/WaitForAppAndVersion/types\";\nexport { WaitForAppAndVersionDeviceAction } from \"@api/device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction\";\nexport {\n GetApplicationsMetadataTaskError,\n InvalidGetFirmwareMetadataResponseError,\n} from \"@api/device-action/task/Errors\";\nexport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nexport {\n DmkResultFactory,\n DmkResultStatus,\n isSuccessDmkResult,\n} from \"@api/model/DmkResult\";\nexport { GenuineCheckDeviceAction } from \"@api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction\";\nexport { InstallAppDeviceAction } from \"@api/secure-channel/device-action/InstallApp/InstallAppDeviceAction\";\nexport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nexport type { InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nexport { UninstallAppDeviceAction } from \"@api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction\";\nexport { SecureChannelError } from \"@internal/secure-channel/model/Errors\";\n// TODO: remove from exported\nexport { defaultApduReceiverServiceStubBuilder } from \"@api/device-session/service/DefaultApduReceiverService.stub\";\nexport { defaultApduSenderServiceStubBuilder } from \"@api/device-session/service/DefaultApduSenderService.stub\";\nexport { FramerUtils } from \"@api/device-session/utils/FramerUtils\";\nexport { DeviceManagementKit } from \"@api/DeviceManagementKit\";\nexport { DeviceManagementKitBuilder } from \"@api/DeviceManagementKitBuilder\";\nexport * from \"@api/Error\";\nexport {\n noopLogger,\n noopLoggerFactory,\n} from \"@api/logger-publisher/utils/noopLoggerFactory\";\nexport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { DefaultLogTagFormatter } from \"@api/logger-subscriber/service/DefaultLogTagFormatter\";\nexport { type LogTagFormatter } from \"@api/logger-subscriber/service/LogTagFormatter\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\nexport {\n DmkNetworkClient,\n type DmkNetworkClientOptions,\n type DmkNetworkResponse,\n type DmkQueryParams,\n type DmkQueryParamValue,\n type DmkRequestConfig,\n type DmkResponseType,\n} from \"@api/network/DmkNetworkClient\";\nexport { DmkNetworkClientError } from \"@api/network/DmkNetworkClientError\";\nexport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nexport {\n DeviceConnectionStateMachine,\n type DeviceConnectionStateMachineParams,\n} from \"@api/transport/model/DeviceConnectionStateMachine\";\nexport * from \"@api/transport/model/Errors\";\nexport { TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nexport { connectedDeviceStubBuilder } from \"@api/transport/model/TransportConnectedDevice.stub\";\nexport * from \"@api/types\";\nexport { formatApduReceivedLog, formatApduSentLog } from \"@api/utils/apduLogs\";\nexport { ApplicationChecker } from \"@api/utils/ApplicationChecker\";\nexport {\n type AppConfig,\n type ApplicationResolver,\n type ResolvedApp,\n} from \"@api/utils/ApplicationResolver\";\nexport { isDashboardName } from \"@api/utils/AppName\";\nexport {\n base64StringToBuffer,\n bufferToBase64String,\n isBase64String,\n} from \"@api/utils/Base64String\";\nexport {\n bufferToHexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@api/utils/HexaString\";\n"],
|
|
5
|
-
"mappings": "AAEA,OAAS,QAAAA,MAAY,uBACrB,OAAS,oBAAAC,EAAkB,eAAAC,MAAmB,8BAC9C,OAAS,cAAAC,MAAkB,6BAC3B,WAAc,kCACd,OAAS,oBAAAC,MAAwB,mCACjC,OAAS,mBAAAC,MAAuB,kCAEhC,OACE,8BAAAC,EACA,0BAAAC,MACK,sBACP,OACE,wBAAAC,EACA,uBAAAC,EACA,0BAAAC,MACK,mCACP,OAAS,mBAAAC,MAAuB,kCAChC,OACE,6BAAAC,EAEA,kCAAAC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C,GACA,mBAAAC,GACA,sBAAAC,OACK,uBACP,OAAS,4BAAAC,OAAgC,0EACzC,OAAS,0BAAAC,OAA8B,sEACvC,OAAS,iCAAAC,OAAqC,oFAE9C,OAAS,4BAAAC,OAAgC,0EACzC,OAAS,sBAAAC,OAA0B,wCAEnC,OAAS,yCAAAC,OAA6C,8DACtD,OAAS,uCAAAC,OAA2C,4DACpD,OAAS,eAAAC,OAAmB,wCAC5B,OAAS,uBAAAC,OAA2B,2BACpC,OAAS,8BAAAC,OAAkC,kCAC3C,WAAc,aACd,OACE,cAAAC,GACA,qBAAAC,OACK,gDACP,OAAS,YAAAC,OAAgB,wCACzB,OAAS,iBAAAC,OAAqB,+CAC9B,OAAS,0BAAAC,OAA8B,wDAEvC,OAAS,yBAAAC,OAA6B,uDACtC,OACE,oBAAAC,OAOK,gCACP,OAAS,yBAAAC,OAA6B,qCACtC,OAAS,mBAAAC,OAAuB,uCAChC,OACE,gCAAAC,OAEK,oDACP,WAAc,8BACd,OAAS,4BAAAC,OAAgC,gDACzC,OAAS,8BAAAC,OAAkC,qDAC3C,WAAc,aACd,OAAS,yBAAAC,GAAuB,qBAAAC,OAAyB,sBACzD,OAAS,sBAAAC,OAA0B,gCAMnC,OAAS,mBAAAC,OAAuB,qBAChC,OACE,wBAAAC,GACA,wBAAAC,GACA,kBAAAC,OACK,0BACP,OACE,sBAAAC,GACA,sBAAAC,GACA,gBAAAC,OACK",
|
|
6
|
-
"names": ["Apdu", "APDU_MAX_PAYLOAD", "ApduBuilder", "ApduParser", "ByteArrayBuilder", "ByteArrayParser", "InvalidResponseFormatError", "InvalidStatusWordError", "CommandResultFactory", "CommandResultStatus", "isSuccessCommandResult", "CloseAppCommand", "DeleteLanguagePackCommand", "DeleteLanguagePackCommandError", "GetAppAndVersionCommand", "GetBackgroundImageSizeCommand", "GetBackgroundImageSizeCommandError", "BatteryStatusType", "GetBatteryStatusCommand", "GetOsVersionCommand", "ListAppsCommand", "ListLanguagePackCommand", "ListLanguagePackCommandError", "LoadCertificateCommand", "OpenAppCommand", "isCommandErrorCode", "CommandUtils", "GLOBAL_ERRORS", "GlobalCommandError", "GlobalCommandErrorHandler", "DeviceModel", "DeviceModelId", "LEDGER_VENDOR_ID", "DeviceStatus", "DeviceActionStatus", "UserInteractionRequired", "CallTaskInAppDeviceAction", "DEFAULT_UNLOCK_TIMEOUT_MS", "AppAlreadyInstalledDAError", "DeleteLanguagePackDAError", "DeviceLockedError", "DeviceNotOnboardedError", "OutOfMemoryDAError", "RefusedByUserDAError", "UnknownDAError", "UnsupportedFirmwareDAError", "GetDeviceMetadataDeviceAction", "GetDeviceStatusDeviceAction", "GoToDashboardDeviceAction", "InstallLanguagePackageDeviceAction", "InstallOrUpdateAppsDeviceAction", "ListAppsDeviceAction", "ListAppsWithMetadataDeviceAction", "OpenAppDeviceAction", "OpenAppWithDependenciesDeviceAction", "SendCommandInAppDeviceAction", "WaitForAppAndVersionDeviceAction", "GetApplicationsMetadataTaskError", "InvalidGetFirmwareMetadataResponseError", "XStateDeviceAction", "StaticDeviceModelDataSource", "BleDeviceInfos", "TransportDeviceModel", "ApduResponse", "DeviceSessionStateType", "DmkResultFactory", "DmkResultStatus", "isSuccessDmkResult", "GenuineCheckDeviceAction", "InstallAppDeviceAction", "ListInstalledAppsDeviceAction", "UninstallAppDeviceAction", "SecureChannelError", "defaultApduReceiverServiceStubBuilder", "defaultApduSenderServiceStubBuilder", "FramerUtils", "DeviceManagementKit", "DeviceManagementKitBuilder", "noopLogger", "noopLoggerFactory", "LogLevel", "ConsoleLogger", "DefaultLogTagFormatter", "WebLogsExporterLogger", "DmkNetworkClient", "DmkNetworkClientError", "ConnectedDevice", "DeviceConnectionStateMachine", "TransportConnectedDevice", "connectedDeviceStubBuilder", "formatApduReceivedLog", "formatApduSentLog", "ApplicationChecker", "isDashboardName", "base64StringToBuffer", "bufferToBase64String", "isBase64String", "bufferToHexaString", "hexaStringToBuffer", "isHexaString"]
|
|
4
|
+
"sourcesContent": ["\"use strict\";\n\nexport { Apdu } from \"@api/apdu/model/Apdu\";\nexport { APDU_MAX_PAYLOAD, ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nexport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nexport * from \"@api/apdu/utils/AppBuilderError\";\nexport { ByteArrayBuilder } from \"@api/apdu/utils/ByteArrayBuilder\";\nexport { ByteArrayParser } from \"@api/apdu/utils/ByteArrayParser\";\nexport { type Command } from \"@api/command/Command\";\nexport {\n InvalidResponseFormatError,\n InvalidStatusWordError,\n} from \"@api/command/Errors\";\nexport {\n CommandResultFactory,\n CommandResultStatus,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nexport { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nexport {\n DeleteLanguagePackCommand,\n type DeleteLanguagePackCommandArgs,\n DeleteLanguagePackCommandError,\n type DeleteLanguagePackCommandResult,\n type DeleteLanguagePackErrorCodes,\n} from \"@api/command/os/DeleteLanguagePackCommand\";\nexport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n GetBackgroundImageSizeCommand,\n GetBackgroundImageSizeCommandError,\n type GetBackgroundImageSizeCommandResult,\n type GetBackgroundImageSizeErrorCodes,\n type GetBackgroundImageSizeResponse,\n} from \"@api/command/os/GetBackgroundImageSizeCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n ListLanguagePackCommand,\n type ListLanguagePackCommandArgs,\n ListLanguagePackCommandError,\n type ListLanguagePackCommandResult,\n type ListLanguagePackErrorCodes,\n type ListLanguagePackResponse,\n} from \"@api/command/os/ListLanguagePackCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nexport {\n AppAlreadyInstalledDAError,\n DeleteLanguagePackDAError,\n DeviceLockedError,\n DeviceNotOnboardedError,\n OutOfMemoryDAError,\n RefusedByUserDAError,\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nexport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nexport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nexport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nexport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n GoToDashboardDARequiredInteraction,\n GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport { InstallLanguagePackageDeviceAction } from \"@api/device-action/os/InstallLanguagePackage/InstallLanguagePackageDeviceAction\";\nexport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nexport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nexport { ListAppsWithMetadataDeviceAction } from \"@api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction\";\nexport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nexport { OpenAppWithDependenciesDeviceAction } from \"@api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction\";\nexport { SendCommandInAppDeviceAction } from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction\";\nexport type {\n WaitForAppAndVersionDAError,\n WaitForAppAndVersionDAInput,\n WaitForAppAndVersionDAIntermediateValue,\n WaitForAppAndVersionDAOutput,\n WaitForAppAndVersionDARequiredInteraction,\n WaitForAppAndVersionDAState,\n} from \"@api/device-action/os/WaitForAppAndVersion/types\";\nexport { WaitForAppAndVersionDeviceAction } from \"@api/device-action/os/WaitForAppAndVersion/WaitForAppAndVersionDeviceAction\";\nexport {\n GetApplicationsMetadataTaskError,\n InvalidGetFirmwareMetadataResponseError,\n} from \"@api/device-action/task/Errors\";\nexport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nexport {\n DmkResultFactory,\n DmkResultStatus,\n isSuccessDmkResult,\n} from \"@api/model/DmkResult\";\nexport { GenuineCheckDeviceAction } from \"@api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction\";\nexport { InstallAppDeviceAction } from \"@api/secure-channel/device-action/InstallApp/InstallAppDeviceAction\";\nexport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nexport type { InstalledApp } from \"@api/secure-channel/device-action/ListInstalledApps/types\";\nexport { UninstallAppDeviceAction } from \"@api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction\";\nexport { ConnectToSecureChannelTask } from \"@api/secure-channel/task/ConnectToSecureChannelTask\";\nexport { SecureChannelEventType } from \"@api/secure-channel/task/types\";\nexport { SecureChannelError } from \"@internal/secure-channel/model/Errors\";\n// TODO: remove from exported\nexport { defaultApduReceiverServiceStubBuilder } from \"@api/device-session/service/DefaultApduReceiverService.stub\";\nexport { defaultApduSenderServiceStubBuilder } from \"@api/device-session/service/DefaultApduSenderService.stub\";\nexport { FramerUtils } from \"@api/device-session/utils/FramerUtils\";\nexport { DeviceManagementKit } from \"@api/DeviceManagementKit\";\nexport { DeviceManagementKitBuilder } from \"@api/DeviceManagementKitBuilder\";\nexport * from \"@api/Error\";\nexport {\n noopLogger,\n noopLoggerFactory,\n} from \"@api/logger-publisher/utils/noopLoggerFactory\";\nexport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { DefaultLogTagFormatter } from \"@api/logger-subscriber/service/DefaultLogTagFormatter\";\nexport { type LogTagFormatter } from \"@api/logger-subscriber/service/LogTagFormatter\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\nexport {\n DmkNetworkClient,\n type DmkNetworkClientOptions,\n type DmkNetworkResponse,\n type DmkQueryParams,\n type DmkQueryParamValue,\n type DmkRequestConfig,\n type DmkResponseType,\n} from \"@api/network/DmkNetworkClient\";\nexport { DmkNetworkClientError } from \"@api/network/DmkNetworkClientError\";\nexport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nexport {\n DeviceConnectionStateMachine,\n type DeviceConnectionStateMachineParams,\n} from \"@api/transport/model/DeviceConnectionStateMachine\";\nexport * from \"@api/transport/model/Errors\";\nexport { TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nexport { connectedDeviceStubBuilder } from \"@api/transport/model/TransportConnectedDevice.stub\";\nexport * from \"@api/types\";\nexport { formatApduReceivedLog, formatApduSentLog } from \"@api/utils/apduLogs\";\nexport { ApplicationChecker } from \"@api/utils/ApplicationChecker\";\nexport {\n type AppConfig,\n type ApplicationResolver,\n type ResolvedApp,\n} from \"@api/utils/ApplicationResolver\";\nexport { isDashboardName } from \"@api/utils/AppName\";\nexport {\n base64StringToBuffer,\n bufferToBase64String,\n isBase64String,\n} from \"@api/utils/Base64String\";\nexport {\n bufferToHexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@api/utils/HexaString\";\n"],
|
|
5
|
+
"mappings": "AAEA,OAAS,QAAAA,MAAY,uBACrB,OAAS,oBAAAC,EAAkB,eAAAC,MAAmB,8BAC9C,OAAS,cAAAC,MAAkB,6BAC3B,WAAc,kCACd,OAAS,oBAAAC,MAAwB,mCACjC,OAAS,mBAAAC,MAAuB,kCAEhC,OACE,8BAAAC,EACA,0BAAAC,MACK,sBACP,OACE,wBAAAC,EACA,uBAAAC,EACA,0BAAAC,MACK,mCACP,OAAS,mBAAAC,MAAuB,kCAChC,OACE,6BAAAC,EAEA,kCAAAC,MAGK,4CACP,OACE,2BAAAC,MAEK,0CACP,OACE,iCAAAC,EACA,sCAAAC,MAIK,gDACP,OACE,qBAAAC,EAEA,2BAAAC,MAEK,0CACP,OACE,uBAAAC,MAEK,sCACP,OAEE,mBAAAC,MAGK,kCACP,OACE,2BAAAC,EAEA,gCAAAC,MAIK,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AA8B,iCACvC,OAAS,sBAAAC,OAA0B,wCAEnC,OAAS,yCAAAC,OAA6C,8DACtD,OAAS,uCAAAC,OAA2C,4DACpD,OAAS,eAAAC,OAAmB,wCAC5B,OAAS,uBAAAC,OAA2B,2BACpC,OAAS,8BAAAC,OAAkC,kCAC3C,WAAc,aACd,OACE,cAAAC,GACA,qBAAAC,OACK,gDACP,OAAS,YAAAC,OAAgB,wCACzB,OAAS,iBAAAC,OAAqB,+CAC9B,OAAS,0BAAAC,OAA8B,wDAEvC,OAAS,yBAAAC,OAA6B,uDACtC,OACE,oBAAAC,OAOK,gCACP,OAAS,yBAAAC,OAA6B,qCACtC,OAAS,mBAAAC,OAAuB,uCAChC,OACE,gCAAAC,OAEK,oDACP,WAAc,8BACd,OAAS,4BAAAC,OAAgC,gDACzC,OAAS,8BAAAC,OAAkC,qDAC3C,WAAc,aACd,OAAS,yBAAAC,GAAuB,qBAAAC,OAAyB,sBACzD,OAAS,sBAAAC,OAA0B,gCAMnC,OAAS,mBAAAC,OAAuB,qBAChC,OACE,wBAAAC,GACA,wBAAAC,GACA,kBAAAC,OACK,0BACP,OACE,sBAAAC,GACA,sBAAAC,GACA,gBAAAC,OACK",
|
|
6
|
+
"names": ["Apdu", "APDU_MAX_PAYLOAD", "ApduBuilder", "ApduParser", "ByteArrayBuilder", "ByteArrayParser", "InvalidResponseFormatError", "InvalidStatusWordError", "CommandResultFactory", "CommandResultStatus", "isSuccessCommandResult", "CloseAppCommand", "DeleteLanguagePackCommand", "DeleteLanguagePackCommandError", "GetAppAndVersionCommand", "GetBackgroundImageSizeCommand", "GetBackgroundImageSizeCommandError", "BatteryStatusType", "GetBatteryStatusCommand", "GetOsVersionCommand", "ListAppsCommand", "ListLanguagePackCommand", "ListLanguagePackCommandError", "LoadCertificateCommand", "OpenAppCommand", "isCommandErrorCode", "CommandUtils", "GLOBAL_ERRORS", "GlobalCommandError", "GlobalCommandErrorHandler", "DeviceModel", "DeviceModelId", "LEDGER_VENDOR_ID", "DeviceStatus", "DeviceActionStatus", "UserInteractionRequired", "CallTaskInAppDeviceAction", "DEFAULT_UNLOCK_TIMEOUT_MS", "AppAlreadyInstalledDAError", "DeleteLanguagePackDAError", "DeviceLockedError", "DeviceNotOnboardedError", "OutOfMemoryDAError", "RefusedByUserDAError", "UnknownDAError", "UnsupportedFirmwareDAError", "GetDeviceMetadataDeviceAction", "GetDeviceStatusDeviceAction", "GoToDashboardDeviceAction", "InstallLanguagePackageDeviceAction", "InstallOrUpdateAppsDeviceAction", "ListAppsDeviceAction", "ListAppsWithMetadataDeviceAction", "OpenAppDeviceAction", "OpenAppWithDependenciesDeviceAction", "SendCommandInAppDeviceAction", "WaitForAppAndVersionDeviceAction", "GetApplicationsMetadataTaskError", "InvalidGetFirmwareMetadataResponseError", "XStateDeviceAction", "StaticDeviceModelDataSource", "BleDeviceInfos", "TransportDeviceModel", "ApduResponse", "DeviceSessionStateType", "DmkResultFactory", "DmkResultStatus", "isSuccessDmkResult", "GenuineCheckDeviceAction", "InstallAppDeviceAction", "ListInstalledAppsDeviceAction", "UninstallAppDeviceAction", "ConnectToSecureChannelTask", "SecureChannelEventType", "SecureChannelError", "defaultApduReceiverServiceStubBuilder", "defaultApduSenderServiceStubBuilder", "FramerUtils", "DeviceManagementKit", "DeviceManagementKitBuilder", "noopLogger", "noopLoggerFactory", "LogLevel", "ConsoleLogger", "DefaultLogTagFormatter", "WebLogsExporterLogger", "DmkNetworkClient", "DmkNetworkClientError", "ConnectedDevice", "DeviceConnectionStateMachine", "TransportConnectedDevice", "connectedDeviceStubBuilder", "formatApduReceivedLog", "formatApduSentLog", "ApplicationChecker", "isDashboardName", "base64StringToBuffer", "bufferToBase64String", "isBase64String", "bufferToHexaString", "hexaStringToBuffer", "isHexaString"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var d=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var y=(n,e,r,t)=>{for(var i=t>1?void 0:t?A(e,r):e,a=n.length-1,p;a>=0;a--)(p=n[a])&&(i=(t?p(e,r,i):p(i))||i);return t&&i&&d(e,r,i),i},u=(n,e)=>(r,t)=>e(r,t,n);import{inject as _,injectable as w}from"inversify";import{EitherAsync as o,Just as D,Nothing as F}from"purify-ts";import{DmkNetworkClient as E}from"../../../api/network/DmkNetworkClient";import{DmkNetworkClientError as L}from"../../../api/network/DmkNetworkClientError";import{managerApiTypes as b}from"../../manager-api/di/managerApiTypes";import{AppType as m}from"../../manager-api/model/Application";import{DEFAULT_PROVIDER as V}from"../../manager-api/model/Const";import{DEFAULT_FIRMWARE_DISTRIBUTION_SALT as P}from"../../manager-api/model/Const";import{HttpFetchApiError as f}from"../../manager-api/model/Errors";import{AppTypeDto as c}from"./ManagerApiDto";const s=n=>n instanceof L&&n.cause!==void 0?new f(n.cause):new f(n);let l=class{http;_provider=V;_firmwareDistributionSalt=P;constructor({managerApiUrl:e,provider:r,firmwareDistributionSalt:t}){this.http=new E({baseUrl:e}),this._provider=r,this._firmwareDistributionSalt=t}setProvider(e){this._provider===e||e<1||(this._provider=e)}getProvider(){return this._provider}getAppList(e){const{targetId:r,firmwareVersionName:t}=e;return o(()=>this.http.get("/v2/apps/by-target",{params:{target_id:r,provider:this._provider,firmware_version_name:t}})).chain(i=>this.mapApplicationDtoToApplication(i)).mapLeft(s)}getMcuList(){return o(()=>this.http.get("/mcu_versions")).chain(e=>this.mapMcuDtoToMcu(e)).mapLeft(s)}getDeviceVersion(e){const{targetId:r}=e;return o(()=>this.http.get("/get_device_version",{params:{target_id:r,provider:this._provider}})).chain(t=>this.mapDeviceVersionDto(t)).mapLeft(s)}getFirmwareVersion(e){const{deviceId:r,version:t}=e;return o(()=>this.http.get("/get_firmware_version",{params:{device_version:r,version_name:t,provider:this._provider}})).chain(i=>this.mapFinalFirmwareDto(i)).mapLeft(s)}getFirmwareVersionById(e){return o(()=>this.http.get(`/firmware_final_versions/${e}`)).chain(r=>this.mapFinalFirmwareDto(r)).mapLeft(s)}getOsuFirmwareVersion(e){const{deviceId:r,version:t}=e;return o(()=>this.http.get("/get_osu_version",{params:{device_version:r,version_name:t,provider:this._provider}})).chain(i=>this.mapOsuFirmwareDto(i)).mapLeft(s)}getLatestFirmwareVersion(e){const r="34.27.0",{currentFinalFirmwareId:t,deviceId:i}=e;return o(()=>this.http.get("/get_latest_firmware",{params:{current_se_firmware_final_version:t,device_version:i,provider:this._provider,salt:this._firmwareDistributionSalt,livecommonversion:r}})).chain(a=>this.mapLatestFirmwareDto(a)).mapLeft(s)}getAppsByHash(e){const{hashes:r}=e;return o(()=>this.http.post("/v2/apps/hash",r)).chain(t=>this.mapNullableApplicationDtoToApplication(t)).mapLeft(s)}getLanguagePackages(e){const{deviceId:r,currentFinalFirmwareId:t}=e;return o(()=>this.http.get("/language-packages",{params:{device_version:r,current_se_firmware_final_version:t}})).chain(i=>this.mapLanguagesDtoToLanguages(i)).mapLeft(s)}mapAppTypeDtoToAppType(e){if(e===null)return null;switch(e){case c.currency:return m.currency;case c.plugin:return m.plugin;case c.tool:return m.tool;case c.swap:return m.swap}}mapApplicationDtoToApplication(e){return o(()=>Promise.resolve(e.map(r=>this.mapApplicationDto(r))))}mapNullableApplicationDtoToApplication(e){return o(()=>Promise.resolve(e.map(r=>r===null?null:this.mapApplicationDto(r))))}mapApplicationDto(e){if(typeof e!="object"||typeof e.versionId!="number"||typeof e.versionName!="string"||e.versionDisplayName!==null&&typeof e.versionDisplayName!="string"||typeof e.version!="string"||e.currencyId!==null&&typeof e.currencyId!="string"||e.description!==null&&typeof e.description!="string"||e.applicationType!==null&&typeof e.applicationType!="string"||typeof e.dateModified!="string"||e.icon!==null&&typeof e.icon!="string"||e.authorName!==null&&typeof e.authorName!="string"||e.supportURL!==null&&typeof e.supportURL!="string"||e.contactURL!==null&&typeof e.contactURL!="string"||e.sourceURL!==null&&typeof e.sourceURL!="string"||e.compatibleWallets!==null&&typeof e.compatibleWallets!="string"||typeof e.hash!="string"||typeof e.perso!="string"||typeof e.firmware!="string"||typeof e.firmwareKey!="string"||typeof e.delete!="string"||typeof e.deleteKey!="string"||e.bytes!==null&&typeof e.bytes!="number"||e.warning!==null&&typeof e.warning!="string"||typeof e.isDevTools!="boolean"||e.category!==null&&typeof e.category!="number"||e.parent!==null&&typeof e.parent!="number"||e.parentName!==null&&typeof e.parentName!="string")throw new Error(`Incomplete application: ${JSON.stringify(e)}`);const{applicationType:r,hash:t,perso:i,firmware:a,firmwareKey:p,delete:h,deleteKey:g,...v}=e;return{...v,hash:t,perso:i,firmware:a,firmwareKey:p,delete:h,deleteKey:g,applicationType:this.mapAppTypeDtoToAppType(r)}}mapMcuDtoToMcu(e){return o(()=>Promise.resolve(e.map(r=>{if(typeof r!="object"||typeof r.id!="number"||typeof r.name!="string"||typeof r.from_bootloader_version!="string")throw new Error(`Incomplete MCU version: ${JSON.stringify(r)}`);return{id:r.id,name:r.name,fromBootloaderVersion:r.from_bootloader_version}})))}mapDeviceVersionDto(e){return o(()=>{if(typeof e!="object"||typeof e.id!="number")throw new Error(`Incomplete device version: ${JSON.stringify(e)}`);const r={id:e.id};return Promise.resolve(r)})}mapFinalFirmwareDto(e){return o(()=>{if(typeof e!="object"||typeof e.id!="number"||typeof e.version!="string"||typeof e.perso!="string"||e.firmware!==null&&typeof e.firmware!="string"||e.firmware_key!==null&&typeof e.firmware_key!="string"||e.hash!==null&&typeof e.hash!="string"||e.bytes!==null&&typeof e.bytes!="number"||!Array.isArray(e.mcu_versions))throw new Error(`Incomplete final firmware: ${JSON.stringify(e)}`);const r={id:e.id,version:e.version,perso:e.perso,firmware:e.firmware,firmwareKey:e.firmware_key,hash:e.hash,bytes:e.bytes,mcuVersions:e.mcu_versions};return Promise.resolve(r)})}mapLatestFirmwareDto(e){return o(()=>{if(e.result==="null")return Promise.resolve(null);if(e.result!=="success"||!e.se_firmware_osu_version)throw new Error(`Latest firmware could not be retrieved: ${e.result}`);const r=e.se_firmware_osu_version;return Promise.resolve(r)}).chain(r=>r===null?o(()=>Promise.resolve(F)):this.mapOsuFirmwareDto(r).map(t=>D(t)))}mapOsuFirmwareDto(e){return o(()=>{if(typeof e!="object"||typeof e.id!="number"||e.notes!==null&&typeof e.notes!="string"||typeof e.perso!="string"||typeof e.firmware!="string"||typeof e.firmware_key!="string"||e.hash!==null&&typeof e.hash!="string"||typeof e.next_se_firmware_final_version!="number")throw new Error(`Incomplete latest firmware: ${JSON.stringify(e)}`);const r={id:e.id,notes:e.notes,perso:e.perso,firmware:e.firmware,firmwareKey:e.firmware_key,hash:e.hash,nextFinalFirmware:e.next_se_firmware_final_version};return Promise.resolve(r)})}mapLanguagesDtoToLanguages(e){return o(()=>Promise.resolve(e.map(r=>this.mapLanguageDto(r))))}mapLanguageDto(e){if(typeof e!="object"||typeof e.language!="string"||typeof e.languagePackageVersionId!="number"||typeof e.version!="string"||typeof e.language_package_id!="number"||typeof e.apdu_install_url!="string"||typeof e.apdu_uninstall_url!="string"||typeof e.bytes!="number"||typeof e.date_creation!="string"||typeof e.date_last_modified!="string")throw new Error(`Incomplete language version: ${JSON.stringify(e)}`);return{language:e.language,languagePackageVersionId:e.languagePackageVersionId,version:e.version,languagePackageId:e.language_package_id,apduInstallUrl:e.apdu_install_url,apduUninstallUrl:e.apdu_uninstall_url,bytes:e.bytes,dateCreation:e.date_creation,dateLastModified:e.date_last_modified}}};l=y([w(),u(0,_(b.DmkConfig))],l);export{l as HttpManagerApiDataSource};
|
|
1
|
+
var d=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var y=(n,e,r,t)=>{for(var i=t>1?void 0:t?A(e,r):e,a=n.length-1,p;a>=0;a--)(p=n[a])&&(i=(t?p(e,r,i):p(i))||i);return t&&i&&d(e,r,i),i},u=(n,e)=>(r,t)=>e(r,t,n);import{inject as _,injectable as w}from"inversify";import{EitherAsync as o,Just as D,Nothing as F}from"purify-ts";import{DmkNetworkClient as E}from"../../../api/network/DmkNetworkClient";import{DmkNetworkClientError as L}from"../../../api/network/DmkNetworkClientError";import{managerApiTypes as b}from"../../manager-api/di/managerApiTypes";import{AppType as m}from"../../manager-api/model/Application";import{DEFAULT_PROVIDER as V}from"../../manager-api/model/Const";import{DEFAULT_FIRMWARE_DISTRIBUTION_SALT as P}from"../../manager-api/model/Const";import{HttpFetchApiError as f}from"../../manager-api/model/Errors";import{AppTypeDto as c}from"./ManagerApiDto";const s=n=>n instanceof L&&n.cause!==void 0?new f(n.cause):new f(n);let l=class{http;_provider=V;_firmwareDistributionSalt=P;constructor({managerApiUrl:e,provider:r,firmwareDistributionSalt:t}){this.http=new E({baseUrl:e}),this._provider=r,this._firmwareDistributionSalt=t}setProvider(e){this._provider===e||e<1||(this._provider=e)}getProvider(){return this._provider}getAppList(e){const{targetId:r,firmwareVersionName:t}=e;return o(()=>this.http.get("/v2/apps/by-target",{params:{target_id:r,provider:this._provider,firmware_version_name:t}})).chain(i=>this.mapApplicationDtoToApplication(i)).mapLeft(s)}getMcuList(){return o(()=>this.http.get("/mcu_versions")).chain(e=>this.mapMcuDtoToMcu(e)).mapLeft(s)}getDeviceVersion(e){const{targetId:r}=e;return o(()=>this.http.get("/get_device_version",{params:{target_id:r,provider:this._provider}})).chain(t=>this.mapDeviceVersionDto(t)).mapLeft(s)}getFirmwareVersion(e){const{deviceId:r,version:t}=e;return o(()=>this.http.get("/get_firmware_version",{params:{device_version:r,version_name:t,provider:this._provider}})).chain(i=>this.mapFinalFirmwareDto(i)).mapLeft(s)}getFirmwareVersionById(e){return o(()=>this.http.get(`/firmware_final_versions/${e}`)).chain(r=>this.mapFinalFirmwareDto(r)).mapLeft(s)}getOsuFirmwareVersion(e){const{deviceId:r,version:t}=e;return o(()=>this.http.get("/get_osu_version",{params:{device_version:r,version_name:t,provider:this._provider}})).chain(i=>this.mapOsuFirmwareDto(i)).mapLeft(s)}getLatestFirmwareVersion(e){const r="34.27.0",{currentFinalFirmwareId:t,deviceId:i}=e;return o(()=>this.http.get("/get_latest_firmware",{params:{current_se_firmware_final_version:t,device_version:i,provider:this._provider,salt:this._firmwareDistributionSalt,livecommonversion:r}})).chain(a=>this.mapLatestFirmwareDto(a)).mapLeft(s)}getAppsByHash(e){const{hashes:r}=e;return o(()=>this.http.post("/v2/apps/hash",r)).chain(t=>this.mapNullableApplicationDtoToApplication(t)).mapLeft(s)}getLanguagePackages(e){const{deviceId:r,currentFinalFirmwareId:t}=e;return o(()=>this.http.get("/language-packages",{params:{device_version:r,current_se_firmware_final_version:t}})).chain(i=>this.mapLanguagesDtoToLanguages(i)).mapLeft(s)}mapAppTypeDtoToAppType(e){if(e===null)return null;switch(e){case c.currency:return m.currency;case c.plugin:return m.plugin;case c.tool:return m.tool;case c.swap:return m.swap}}mapApplicationDtoToApplication(e){return o(()=>Promise.resolve(e.map(r=>this.mapApplicationDto(r))))}mapNullableApplicationDtoToApplication(e){return o(()=>Promise.resolve(e.map(r=>r===null?null:this.mapApplicationDto(r))))}mapApplicationDto(e){if(typeof e!="object"||typeof e.versionId!="number"||typeof e.versionName!="string"||e.versionDisplayName!==null&&typeof e.versionDisplayName!="string"||typeof e.version!="string"||e.currencyId!==null&&typeof e.currencyId!="string"||e.description!==null&&typeof e.description!="string"||e.applicationType!==null&&typeof e.applicationType!="string"||typeof e.dateModified!="string"||e.icon!==null&&typeof e.icon!="string"||e.authorName!==null&&typeof e.authorName!="string"||e.supportURL!==null&&typeof e.supportURL!="string"||e.contactURL!==null&&typeof e.contactURL!="string"||e.sourceURL!==null&&typeof e.sourceURL!="string"||e.compatibleWallets!==null&&typeof e.compatibleWallets!="string"||typeof e.hash!="string"||typeof e.perso!="string"||typeof e.firmware!="string"||typeof e.firmwareKey!="string"||typeof e.delete!="string"||typeof e.deleteKey!="string"||e.bytes!==null&&typeof e.bytes!="number"||e.warning!==null&&typeof e.warning!="string"||typeof e.isDevTools!="boolean"||e.category!==null&&typeof e.category!="number"||e.parent!==null&&typeof e.parent!="number"||e.parentName!==null&&typeof e.parentName!="string")throw new Error(`Incomplete application: ${JSON.stringify(e)}`);const{applicationType:r,hash:t,perso:i,firmware:a,firmwareKey:p,delete:h,deleteKey:g,...v}=e;return{...v,hash:t,perso:i,firmware:a,firmwareKey:p,delete:h,deleteKey:g,applicationType:this.mapAppTypeDtoToAppType(r)}}mapMcuDtoToMcu(e){return o(()=>Promise.resolve(e.map(r=>{if(typeof r!="object"||typeof r.id!="number"||typeof r.name!="string"||typeof r.from_bootloader_version!="string")throw new Error(`Incomplete MCU version: ${JSON.stringify(r)}`);return{id:r.id,name:r.name,fromBootloaderVersion:r.from_bootloader_version,providers:r.providers}})))}mapDeviceVersionDto(e){return o(()=>{if(typeof e!="object"||typeof e.id!="number")throw new Error(`Incomplete device version: ${JSON.stringify(e)}`);const r={id:e.id};return Promise.resolve(r)})}mapFinalFirmwareDto(e){return o(()=>{if(typeof e!="object"||typeof e.id!="number"||typeof e.version!="string"||typeof e.perso!="string"||e.firmware!==null&&typeof e.firmware!="string"||e.firmware_key!==null&&typeof e.firmware_key!="string"||e.hash!==null&&typeof e.hash!="string"||e.bytes!==null&&typeof e.bytes!="number"||!Array.isArray(e.mcu_versions))throw new Error(`Incomplete final firmware: ${JSON.stringify(e)}`);const r={id:e.id,version:e.version,perso:e.perso,firmware:e.firmware,firmwareKey:e.firmware_key,hash:e.hash,bytes:e.bytes,mcuVersions:e.mcu_versions};return Promise.resolve(r)})}mapLatestFirmwareDto(e){return o(()=>{if(e.result==="null")return Promise.resolve(null);if(e.result!=="success"||!e.se_firmware_osu_version)throw new Error(`Latest firmware could not be retrieved: ${e.result}`);const r=e.se_firmware_osu_version;return Promise.resolve(r)}).chain(r=>r===null?o(()=>Promise.resolve(F)):this.mapOsuFirmwareDto(r).map(t=>D(t)))}mapOsuFirmwareDto(e){return o(()=>{if(typeof e!="object"||typeof e.id!="number"||e.notes!==null&&typeof e.notes!="string"||typeof e.perso!="string"||typeof e.firmware!="string"||typeof e.firmware_key!="string"||e.hash!==null&&typeof e.hash!="string"||typeof e.next_se_firmware_final_version!="number")throw new Error(`Incomplete latest firmware: ${JSON.stringify(e)}`);const r={id:e.id,notes:e.notes,perso:e.perso,firmware:e.firmware,firmwareKey:e.firmware_key,hash:e.hash,nextFinalFirmware:e.next_se_firmware_final_version};return Promise.resolve(r)})}mapLanguagesDtoToLanguages(e){return o(()=>Promise.resolve(e.map(r=>this.mapLanguageDto(r))))}mapLanguageDto(e){if(typeof e!="object"||typeof e.language!="string"||typeof e.languagePackageVersionId!="number"||typeof e.version!="string"||typeof e.language_package_id!="number"||typeof e.apdu_install_url!="string"||typeof e.apdu_uninstall_url!="string"||typeof e.bytes!="number"||typeof e.date_creation!="string"||typeof e.date_last_modified!="string")throw new Error(`Incomplete language version: ${JSON.stringify(e)}`);return{language:e.language,languagePackageVersionId:e.languagePackageVersionId,version:e.version,languagePackageId:e.language_package_id,apduInstallUrl:e.apdu_install_url,apduUninstallUrl:e.apdu_uninstall_url,bytes:e.bytes,dateCreation:e.date_creation,dateLastModified:e.date_last_modified}}};l=y([w(),u(0,_(b.DmkConfig))],l);export{l as HttpManagerApiDataSource};
|
|
2
2
|
//# sourceMappingURL=HttpManagerApiDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/manager-api/data/HttpManagerApiDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { EitherAsync, Just, Maybe, Nothing } from \"purify-ts\";\n\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { DmkNetworkClient } from \"@api/network/DmkNetworkClient\";\nimport { DmkNetworkClientError } from \"@api/network/DmkNetworkClientError\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport {\n type Application,\n AppType,\n} from \"@internal/manager-api/model/Application\";\nimport { DEFAULT_PROVIDER } from \"@internal/manager-api/model/Const\";\nimport { DEFAULT_FIRMWARE_DISTRIBUTION_SALT } from \"@internal/manager-api/model/Const\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\nimport type {\n FinalFirmware,\n McuFirmware,\n OsuFirmware,\n} from \"@internal/manager-api/model/Firmware\";\nimport { type LanguagePackage } from \"@internal/manager-api/model/Language\";\nimport {\n type GetAppByHashParams,\n type GetAppListParams,\n type GetDeviceVersionParams,\n type GetFirmwareVersionParams,\n type GetLanguagePackagesParams,\n type GetLatestFirmwareVersionParams,\n} from \"@internal/manager-api/model/Params\";\n\nimport { ManagerApiDataSource } from \"./ManagerApiDataSource\";\nimport {\n ApplicationDto,\n AppTypeDto,\n DeviceVersionDto,\n FirmwareFinalVersionDto,\n FirmwareOsuVersionDto,\n LanguagePackageVersionDto,\n LatestFirmwareOsuVersionResponseDto,\n McuVersionDto,\n} from \"./ManagerApiDto\";\n\nconst toHttpFetchApiError = (error: unknown): HttpFetchApiError => {\n // The network client wraps fetch errors in DmkNetworkClientError. Unwrap the\n // original cause when available so consumers (and tests) keep seeing the\n // underlying error.\n if (error instanceof DmkNetworkClientError && error.cause !== undefined) {\n return new HttpFetchApiError(error.cause);\n }\n return new HttpFetchApiError(error);\n};\n\n@injectable()\nexport class HttpManagerApiDataSource implements ManagerApiDataSource {\n private readonly http: DmkNetworkClient;\n private _provider: number = DEFAULT_PROVIDER;\n private _firmwareDistributionSalt: string =\n DEFAULT_FIRMWARE_DISTRIBUTION_SALT;\n\n constructor(\n @inject(managerApiTypes.DmkConfig)\n { managerApiUrl, provider, firmwareDistributionSalt }: DmkConfig,\n ) {\n this.http = new DmkNetworkClient({ baseUrl: managerApiUrl });\n this._provider = provider;\n this._firmwareDistributionSalt = firmwareDistributionSalt;\n }\n\n setProvider(provider: number): void {\n if (this._provider === provider || provider < 1) {\n return;\n }\n this._provider = provider;\n }\n\n getProvider(): number {\n return this._provider;\n }\n\n getAppList(\n params: GetAppListParams,\n ): EitherAsync<HttpFetchApiError, Array<Application>> {\n const { targetId, firmwareVersionName } = params;\n return EitherAsync(() =>\n this.http.get(\"/v2/apps/by-target\", {\n params: {\n target_id: targetId,\n provider: this._provider,\n firmware_version_name: firmwareVersionName,\n },\n }),\n )\n .chain((apps) =>\n this.mapApplicationDtoToApplication(apps as Array<ApplicationDto>),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getMcuList(): EitherAsync<HttpFetchApiError, Array<McuFirmware>> {\n return EitherAsync(() => this.http.get(\"/mcu_versions\"))\n .chain((mcus) => this.mapMcuDtoToMcu(mcus as Array<McuVersionDto>))\n .mapLeft(toHttpFetchApiError);\n }\n\n getDeviceVersion(\n params: GetDeviceVersionParams,\n ): EitherAsync<HttpFetchApiError, DeviceVersion> {\n const { targetId } = params;\n return EitherAsync(() =>\n this.http.get(\"/get_device_version\", {\n params: { target_id: targetId, provider: this._provider },\n }),\n )\n .chain((deviceVersion) =>\n this.mapDeviceVersionDto(deviceVersion as DeviceVersionDto),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getFirmwareVersion(\n params: GetFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, FinalFirmware> {\n const { deviceId, version } = params;\n return EitherAsync(() =>\n this.http.get(\"/get_firmware_version\", {\n params: {\n device_version: deviceId,\n version_name: version,\n provider: this._provider,\n },\n }),\n )\n .chain((finalFirmware) =>\n this.mapFinalFirmwareDto(finalFirmware as FirmwareFinalVersionDto),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getFirmwareVersionById(\n finalFirmwareId: number,\n ): EitherAsync<HttpFetchApiError, FinalFirmware> {\n return EitherAsync(() =>\n this.http.get(`/firmware_final_versions/${finalFirmwareId}`),\n )\n .chain((finalFirmware) =>\n this.mapFinalFirmwareDto(finalFirmware as FirmwareFinalVersionDto),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getOsuFirmwareVersion(\n params: GetFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, OsuFirmware> {\n const { deviceId, version } = params;\n return EitherAsync(() =>\n this.http.get(\"/get_osu_version\", {\n params: {\n device_version: deviceId,\n version_name: version,\n provider: this._provider,\n },\n }),\n )\n .chain((osuFirmware) =>\n this.mapOsuFirmwareDto(osuFirmware as FirmwareOsuVersionDto),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getLatestFirmwareVersion(\n params: GetLatestFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, Maybe<OsuFirmware>> {\n const livecommonversion = \"34.27.0\"; // Legacy parameter that should just be a too old\n const { currentFinalFirmwareId, deviceId } = params;\n return EitherAsync(() =>\n this.http.get(\"/get_latest_firmware\", {\n params: {\n current_se_firmware_final_version: currentFinalFirmwareId,\n device_version: deviceId,\n provider: this._provider,\n salt: this._firmwareDistributionSalt,\n livecommonversion,\n },\n }),\n )\n .chain((latestFirmware) =>\n this.mapLatestFirmwareDto(\n latestFirmware as LatestFirmwareOsuVersionResponseDto,\n ),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getAppsByHash(\n params: GetAppByHashParams,\n ): EitherAsync<HttpFetchApiError, Array<Application | null>> {\n const { hashes } = params;\n return EitherAsync(() => this.http.post(\"/v2/apps/hash\", hashes))\n .chain((apps) =>\n this.mapNullableApplicationDtoToApplication(\n apps as Array<ApplicationDto | null>,\n ),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getLanguagePackages(\n params: GetLanguagePackagesParams,\n ): EitherAsync<HttpFetchApiError, Array<LanguagePackage>> {\n const { deviceId, currentFinalFirmwareId } = params;\n return EitherAsync(() =>\n this.http.get(\"/language-packages\", {\n params: {\n device_version: deviceId,\n current_se_firmware_final_version: currentFinalFirmwareId,\n },\n }),\n )\n .chain((apps) =>\n this.mapLanguagesDtoToLanguages(\n apps as Array<LanguagePackageVersionDto>,\n ),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n private mapAppTypeDtoToAppType(appType: AppTypeDto | null): AppType | null {\n if (appType === null) {\n return null;\n }\n switch (appType) {\n case AppTypeDto.currency:\n return AppType.currency;\n case AppTypeDto.plugin:\n return AppType.plugin;\n case AppTypeDto.tool:\n return AppType.tool;\n case AppTypeDto.swap:\n return AppType.swap;\n }\n }\n\n private mapApplicationDtoToApplication(\n apps: Array<ApplicationDto>,\n ): EitherAsync<Error, Array<Application>> {\n return EitherAsync(() =>\n Promise.resolve(apps.map((app) => this.mapApplicationDto(app))),\n );\n }\n\n private mapNullableApplicationDtoToApplication(\n apps: Array<ApplicationDto | null>,\n ): EitherAsync<Error, Array<Application | null>> {\n return EitherAsync(() =>\n Promise.resolve(\n apps.map((app) => {\n if (app === null) {\n return null;\n }\n return this.mapApplicationDto(app);\n }),\n ),\n );\n }\n\n private mapApplicationDto(app: ApplicationDto): Application {\n if (\n typeof app !== \"object\" ||\n typeof app.versionId !== \"number\" ||\n typeof app.versionName !== \"string\" ||\n (app.versionDisplayName !== null &&\n typeof app.versionDisplayName !== \"string\") ||\n typeof app.version !== \"string\" ||\n (app.currencyId !== null && typeof app.currencyId !== \"string\") ||\n (app.description !== null && typeof app.description !== \"string\") ||\n (app.applicationType !== null &&\n typeof app.applicationType !== \"string\") ||\n typeof app.dateModified !== \"string\" ||\n (app.icon !== null && typeof app.icon !== \"string\") ||\n (app.authorName !== null && typeof app.authorName !== \"string\") ||\n (app.supportURL !== null && typeof app.supportURL !== \"string\") ||\n (app.contactURL !== null && typeof app.contactURL !== \"string\") ||\n (app.sourceURL !== null && typeof app.sourceURL !== \"string\") ||\n (app.compatibleWallets !== null &&\n typeof app.compatibleWallets !== \"string\") ||\n typeof app.hash !== \"string\" ||\n typeof app.perso !== \"string\" ||\n typeof app.firmware !== \"string\" ||\n typeof app.firmwareKey !== \"string\" ||\n typeof app.delete !== \"string\" ||\n typeof app.deleteKey !== \"string\" ||\n (app.bytes !== null && typeof app.bytes !== \"number\") ||\n (app.warning !== null && typeof app.warning !== \"string\") ||\n typeof app.isDevTools !== \"boolean\" ||\n (app.category !== null && typeof app.category !== \"number\") ||\n (app.parent !== null && typeof app.parent !== \"number\") ||\n (app.parentName !== null && typeof app.parentName !== \"string\")\n ) {\n throw new Error(`Incomplete application: ${JSON.stringify(app)}`);\n }\n const {\n applicationType,\n hash,\n perso,\n firmware,\n firmwareKey,\n delete: del,\n deleteKey,\n ...rest\n } = app;\n const ret: Application = {\n ...rest,\n hash: hash!,\n perso: perso!,\n firmware: firmware!,\n firmwareKey: firmwareKey!,\n delete: del!,\n deleteKey: deleteKey!,\n applicationType: this.mapAppTypeDtoToAppType(applicationType),\n };\n return ret;\n }\n\n private mapMcuDtoToMcu(\n mcus: Array<McuVersionDto>,\n ): EitherAsync<Error, Array<McuFirmware>> {\n return EitherAsync(() =>\n Promise.resolve(\n mcus.map((mcu) => {\n if (\n typeof mcu !== \"object\" ||\n typeof mcu.id !== \"number\" ||\n typeof mcu.name !== \"string\" ||\n typeof mcu.from_bootloader_version !== \"string\"\n ) {\n throw new Error(`Incomplete MCU version: ${JSON.stringify(mcu)}`);\n }\n const ret: McuFirmware = {\n id: mcu.id,\n name: mcu.name,\n fromBootloaderVersion: mcu.from_bootloader_version,\n };\n return ret;\n }),\n ),\n );\n }\n\n private mapDeviceVersionDto(\n deviceVersion: DeviceVersionDto,\n ): EitherAsync<Error, DeviceVersion> {\n return EitherAsync(() => {\n if (\n typeof deviceVersion !== \"object\" ||\n typeof deviceVersion.id !== \"number\"\n ) {\n throw new Error(\n `Incomplete device version: ${JSON.stringify(deviceVersion)}`,\n );\n }\n const ret: DeviceVersion = {\n id: deviceVersion.id,\n };\n return Promise.resolve(ret);\n });\n }\n\n private mapFinalFirmwareDto(\n finalFirmware: FirmwareFinalVersionDto,\n ): EitherAsync<Error, FinalFirmware> {\n return EitherAsync(() => {\n if (\n typeof finalFirmware !== \"object\" ||\n typeof finalFirmware.id !== \"number\" ||\n typeof finalFirmware.version !== \"string\" ||\n typeof finalFirmware.perso !== \"string\" ||\n (finalFirmware.firmware !== null &&\n typeof finalFirmware.firmware !== \"string\") ||\n (finalFirmware.firmware_key !== null &&\n typeof finalFirmware.firmware_key !== \"string\") ||\n (finalFirmware.hash !== null &&\n typeof finalFirmware.hash !== \"string\") ||\n (finalFirmware.bytes !== null &&\n typeof finalFirmware.bytes !== \"number\") ||\n !Array.isArray(finalFirmware.mcu_versions)\n ) {\n throw new Error(\n `Incomplete final firmware: ${JSON.stringify(finalFirmware)}`,\n );\n }\n const ret: FinalFirmware = {\n id: finalFirmware.id,\n version: finalFirmware.version,\n perso: finalFirmware.perso,\n firmware: finalFirmware.firmware,\n firmwareKey: finalFirmware.firmware_key,\n hash: finalFirmware.hash,\n bytes: finalFirmware.bytes,\n mcuVersions: finalFirmware.mcu_versions,\n };\n return Promise.resolve(ret);\n });\n }\n\n private mapLatestFirmwareDto(\n latestFirmware: LatestFirmwareOsuVersionResponseDto,\n ): EitherAsync<Error, Maybe<OsuFirmware>> {\n return EitherAsync<Error, FirmwareOsuVersionDto | null>(() => {\n /**\n * This is how we know that there is no update available.\n * See the {@link https://github.com/LedgerHQ/ledger-live/blob/develop/libs/device-core/src/managerApi/repositories/HttpManagerApiRepository.ts#L59-L61 | ledger-live implementation}.\n */\n if (latestFirmware.result === \"null\") {\n return Promise.resolve(null);\n }\n if (\n latestFirmware.result !== \"success\" ||\n !latestFirmware.se_firmware_osu_version\n ) {\n throw new Error(\n `Latest firmware could not be retrieved: ${latestFirmware.result}`,\n );\n }\n const osuDto = latestFirmware.se_firmware_osu_version;\n return Promise.resolve(osuDto);\n }).chain((osuDto) => {\n if (null === osuDto) {\n return EitherAsync(() => Promise.resolve(Nothing));\n }\n return this.mapOsuFirmwareDto(osuDto).map((osuFirmware) =>\n Just(osuFirmware),\n );\n });\n }\n\n private mapOsuFirmwareDto(\n osuDto: FirmwareOsuVersionDto,\n ): EitherAsync<Error, OsuFirmware> {\n return EitherAsync(() => {\n if (\n typeof osuDto !== \"object\" ||\n typeof osuDto.id !== \"number\" ||\n (osuDto.notes !== null && typeof osuDto.notes !== \"string\") ||\n typeof osuDto.perso !== \"string\" ||\n typeof osuDto.firmware !== \"string\" ||\n typeof osuDto.firmware_key !== \"string\" ||\n (osuDto.hash !== null && typeof osuDto.hash !== \"string\") ||\n typeof osuDto.next_se_firmware_final_version !== \"number\"\n ) {\n throw new Error(\n `Incomplete latest firmware: ${JSON.stringify(osuDto)}`,\n );\n }\n const ret: OsuFirmware = {\n id: osuDto.id,\n notes: osuDto.notes,\n perso: osuDto.perso,\n firmware: osuDto.firmware,\n firmwareKey: osuDto.firmware_key,\n hash: osuDto.hash,\n nextFinalFirmware: osuDto.next_se_firmware_final_version,\n };\n return Promise.resolve(ret);\n });\n }\n\n private mapLanguagesDtoToLanguages(\n languages: Array<LanguagePackageVersionDto>,\n ): EitherAsync<Error, Array<LanguagePackage>> {\n return EitherAsync(() =>\n Promise.resolve(\n languages.map((language) => this.mapLanguageDto(language)),\n ),\n );\n }\n\n private mapLanguageDto(language: LanguagePackageVersionDto): LanguagePackage {\n if (\n typeof language !== \"object\" ||\n typeof language.language !== \"string\" ||\n typeof language.languagePackageVersionId !== \"number\" ||\n typeof language.version !== \"string\" ||\n typeof language.language_package_id !== \"number\" ||\n typeof language.apdu_install_url !== \"string\" ||\n typeof language.apdu_uninstall_url !== \"string\" ||\n typeof language.bytes !== \"number\" ||\n typeof language.date_creation !== \"string\" ||\n typeof language.date_last_modified !== \"string\"\n ) {\n throw new Error(\n `Incomplete language version: ${JSON.stringify(language)}`,\n );\n }\n const ret: LanguagePackage = {\n language: language.language,\n languagePackageVersionId: language.languagePackageVersionId,\n version: language.version,\n languagePackageId: language.language_package_id,\n apduInstallUrl: language.apdu_install_url,\n apduUninstallUrl: language.apdu_uninstall_url,\n bytes: language.bytes,\n dateCreation: language.date_creation,\n dateLastModified: language.date_last_modified,\n };\n return ret;\n }\n}\n"],
|
|
5
|
-
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAS,eAAAC,EAAa,QAAAC,EAAa,WAAAC,MAAe,YAGlD,OAAS,oBAAAC,MAAwB,gCACjC,OAAS,yBAAAC,MAA6B,qCACtC,OAAS,mBAAAC,MAAuB,2CAChC,OAEE,WAAAC,MAC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ync, Just, Maybe, Nothing } from \"purify-ts\";\n\nimport { type DmkConfig } from \"@api/DmkConfig\";\nimport { DmkNetworkClient } from \"@api/network/DmkNetworkClient\";\nimport { DmkNetworkClientError } from \"@api/network/DmkNetworkClientError\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport {\n type Application,\n AppType,\n} from \"@internal/manager-api/model/Application\";\nimport { DEFAULT_PROVIDER } from \"@internal/manager-api/model/Const\";\nimport { DEFAULT_FIRMWARE_DISTRIBUTION_SALT } from \"@internal/manager-api/model/Const\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\nimport type {\n FinalFirmware,\n McuFirmware,\n OsuFirmware,\n} from \"@internal/manager-api/model/Firmware\";\nimport { type LanguagePackage } from \"@internal/manager-api/model/Language\";\nimport {\n type GetAppByHashParams,\n type GetAppListParams,\n type GetDeviceVersionParams,\n type GetFirmwareVersionParams,\n type GetLanguagePackagesParams,\n type GetLatestFirmwareVersionParams,\n} from \"@internal/manager-api/model/Params\";\n\nimport { ManagerApiDataSource } from \"./ManagerApiDataSource\";\nimport {\n ApplicationDto,\n AppTypeDto,\n DeviceVersionDto,\n FirmwareFinalVersionDto,\n FirmwareOsuVersionDto,\n LanguagePackageVersionDto,\n LatestFirmwareOsuVersionResponseDto,\n McuVersionDto,\n} from \"./ManagerApiDto\";\n\nconst toHttpFetchApiError = (error: unknown): HttpFetchApiError => {\n // The network client wraps fetch errors in DmkNetworkClientError. Unwrap the\n // original cause when available so consumers (and tests) keep seeing the\n // underlying error.\n if (error instanceof DmkNetworkClientError && error.cause !== undefined) {\n return new HttpFetchApiError(error.cause);\n }\n return new HttpFetchApiError(error);\n};\n\n@injectable()\nexport class HttpManagerApiDataSource implements ManagerApiDataSource {\n private readonly http: DmkNetworkClient;\n private _provider: number = DEFAULT_PROVIDER;\n private _firmwareDistributionSalt: string =\n DEFAULT_FIRMWARE_DISTRIBUTION_SALT;\n\n constructor(\n @inject(managerApiTypes.DmkConfig)\n { managerApiUrl, provider, firmwareDistributionSalt }: DmkConfig,\n ) {\n this.http = new DmkNetworkClient({ baseUrl: managerApiUrl });\n this._provider = provider;\n this._firmwareDistributionSalt = firmwareDistributionSalt;\n }\n\n setProvider(provider: number): void {\n if (this._provider === provider || provider < 1) {\n return;\n }\n this._provider = provider;\n }\n\n getProvider(): number {\n return this._provider;\n }\n\n getAppList(\n params: GetAppListParams,\n ): EitherAsync<HttpFetchApiError, Array<Application>> {\n const { targetId, firmwareVersionName } = params;\n return EitherAsync(() =>\n this.http.get(\"/v2/apps/by-target\", {\n params: {\n target_id: targetId,\n provider: this._provider,\n firmware_version_name: firmwareVersionName,\n },\n }),\n )\n .chain((apps) =>\n this.mapApplicationDtoToApplication(apps as Array<ApplicationDto>),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getMcuList(): EitherAsync<HttpFetchApiError, Array<McuFirmware>> {\n return EitherAsync(() => this.http.get(\"/mcu_versions\"))\n .chain((mcus) => this.mapMcuDtoToMcu(mcus as Array<McuVersionDto>))\n .mapLeft(toHttpFetchApiError);\n }\n\n getDeviceVersion(\n params: GetDeviceVersionParams,\n ): EitherAsync<HttpFetchApiError, DeviceVersion> {\n const { targetId } = params;\n return EitherAsync(() =>\n this.http.get(\"/get_device_version\", {\n params: { target_id: targetId, provider: this._provider },\n }),\n )\n .chain((deviceVersion) =>\n this.mapDeviceVersionDto(deviceVersion as DeviceVersionDto),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getFirmwareVersion(\n params: GetFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, FinalFirmware> {\n const { deviceId, version } = params;\n return EitherAsync(() =>\n this.http.get(\"/get_firmware_version\", {\n params: {\n device_version: deviceId,\n version_name: version,\n provider: this._provider,\n },\n }),\n )\n .chain((finalFirmware) =>\n this.mapFinalFirmwareDto(finalFirmware as FirmwareFinalVersionDto),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getFirmwareVersionById(\n finalFirmwareId: number,\n ): EitherAsync<HttpFetchApiError, FinalFirmware> {\n return EitherAsync(() =>\n this.http.get(`/firmware_final_versions/${finalFirmwareId}`),\n )\n .chain((finalFirmware) =>\n this.mapFinalFirmwareDto(finalFirmware as FirmwareFinalVersionDto),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getOsuFirmwareVersion(\n params: GetFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, OsuFirmware> {\n const { deviceId, version } = params;\n return EitherAsync(() =>\n this.http.get(\"/get_osu_version\", {\n params: {\n device_version: deviceId,\n version_name: version,\n provider: this._provider,\n },\n }),\n )\n .chain((osuFirmware) =>\n this.mapOsuFirmwareDto(osuFirmware as FirmwareOsuVersionDto),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getLatestFirmwareVersion(\n params: GetLatestFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, Maybe<OsuFirmware>> {\n const livecommonversion = \"34.27.0\"; // Legacy parameter that should just be a too old\n const { currentFinalFirmwareId, deviceId } = params;\n return EitherAsync(() =>\n this.http.get(\"/get_latest_firmware\", {\n params: {\n current_se_firmware_final_version: currentFinalFirmwareId,\n device_version: deviceId,\n provider: this._provider,\n salt: this._firmwareDistributionSalt,\n livecommonversion,\n },\n }),\n )\n .chain((latestFirmware) =>\n this.mapLatestFirmwareDto(\n latestFirmware as LatestFirmwareOsuVersionResponseDto,\n ),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getAppsByHash(\n params: GetAppByHashParams,\n ): EitherAsync<HttpFetchApiError, Array<Application | null>> {\n const { hashes } = params;\n return EitherAsync(() => this.http.post(\"/v2/apps/hash\", hashes))\n .chain((apps) =>\n this.mapNullableApplicationDtoToApplication(\n apps as Array<ApplicationDto | null>,\n ),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n getLanguagePackages(\n params: GetLanguagePackagesParams,\n ): EitherAsync<HttpFetchApiError, Array<LanguagePackage>> {\n const { deviceId, currentFinalFirmwareId } = params;\n return EitherAsync(() =>\n this.http.get(\"/language-packages\", {\n params: {\n device_version: deviceId,\n current_se_firmware_final_version: currentFinalFirmwareId,\n },\n }),\n )\n .chain((apps) =>\n this.mapLanguagesDtoToLanguages(\n apps as Array<LanguagePackageVersionDto>,\n ),\n )\n .mapLeft(toHttpFetchApiError);\n }\n\n private mapAppTypeDtoToAppType(appType: AppTypeDto | null): AppType | null {\n if (appType === null) {\n return null;\n }\n switch (appType) {\n case AppTypeDto.currency:\n return AppType.currency;\n case AppTypeDto.plugin:\n return AppType.plugin;\n case AppTypeDto.tool:\n return AppType.tool;\n case AppTypeDto.swap:\n return AppType.swap;\n }\n }\n\n private mapApplicationDtoToApplication(\n apps: Array<ApplicationDto>,\n ): EitherAsync<Error, Array<Application>> {\n return EitherAsync(() =>\n Promise.resolve(apps.map((app) => this.mapApplicationDto(app))),\n );\n }\n\n private mapNullableApplicationDtoToApplication(\n apps: Array<ApplicationDto | null>,\n ): EitherAsync<Error, Array<Application | null>> {\n return EitherAsync(() =>\n Promise.resolve(\n apps.map((app) => {\n if (app === null) {\n return null;\n }\n return this.mapApplicationDto(app);\n }),\n ),\n );\n }\n\n private mapApplicationDto(app: ApplicationDto): Application {\n if (\n typeof app !== \"object\" ||\n typeof app.versionId !== \"number\" ||\n typeof app.versionName !== \"string\" ||\n (app.versionDisplayName !== null &&\n typeof app.versionDisplayName !== \"string\") ||\n typeof app.version !== \"string\" ||\n (app.currencyId !== null && typeof app.currencyId !== \"string\") ||\n (app.description !== null && typeof app.description !== \"string\") ||\n (app.applicationType !== null &&\n typeof app.applicationType !== \"string\") ||\n typeof app.dateModified !== \"string\" ||\n (app.icon !== null && typeof app.icon !== \"string\") ||\n (app.authorName !== null && typeof app.authorName !== \"string\") ||\n (app.supportURL !== null && typeof app.supportURL !== \"string\") ||\n (app.contactURL !== null && typeof app.contactURL !== \"string\") ||\n (app.sourceURL !== null && typeof app.sourceURL !== \"string\") ||\n (app.compatibleWallets !== null &&\n typeof app.compatibleWallets !== \"string\") ||\n typeof app.hash !== \"string\" ||\n typeof app.perso !== \"string\" ||\n typeof app.firmware !== \"string\" ||\n typeof app.firmwareKey !== \"string\" ||\n typeof app.delete !== \"string\" ||\n typeof app.deleteKey !== \"string\" ||\n (app.bytes !== null && typeof app.bytes !== \"number\") ||\n (app.warning !== null && typeof app.warning !== \"string\") ||\n typeof app.isDevTools !== \"boolean\" ||\n (app.category !== null && typeof app.category !== \"number\") ||\n (app.parent !== null && typeof app.parent !== \"number\") ||\n (app.parentName !== null && typeof app.parentName !== \"string\")\n ) {\n throw new Error(`Incomplete application: ${JSON.stringify(app)}`);\n }\n const {\n applicationType,\n hash,\n perso,\n firmware,\n firmwareKey,\n delete: del,\n deleteKey,\n ...rest\n } = app;\n const ret: Application = {\n ...rest,\n hash: hash!,\n perso: perso!,\n firmware: firmware!,\n firmwareKey: firmwareKey!,\n delete: del!,\n deleteKey: deleteKey!,\n applicationType: this.mapAppTypeDtoToAppType(applicationType),\n };\n return ret;\n }\n\n private mapMcuDtoToMcu(\n mcus: Array<McuVersionDto>,\n ): EitherAsync<Error, Array<McuFirmware>> {\n return EitherAsync(() =>\n Promise.resolve(\n mcus.map((mcu) => {\n if (\n typeof mcu !== \"object\" ||\n typeof mcu.id !== \"number\" ||\n typeof mcu.name !== \"string\" ||\n typeof mcu.from_bootloader_version !== \"string\"\n ) {\n throw new Error(`Incomplete MCU version: ${JSON.stringify(mcu)}`);\n }\n const ret: McuFirmware = {\n id: mcu.id,\n name: mcu.name,\n fromBootloaderVersion: mcu.from_bootloader_version,\n providers: mcu.providers,\n };\n return ret;\n }),\n ),\n );\n }\n\n private mapDeviceVersionDto(\n deviceVersion: DeviceVersionDto,\n ): EitherAsync<Error, DeviceVersion> {\n return EitherAsync(() => {\n if (\n typeof deviceVersion !== \"object\" ||\n typeof deviceVersion.id !== \"number\"\n ) {\n throw new Error(\n `Incomplete device version: ${JSON.stringify(deviceVersion)}`,\n );\n }\n const ret: DeviceVersion = {\n id: deviceVersion.id,\n };\n return Promise.resolve(ret);\n });\n }\n\n private mapFinalFirmwareDto(\n finalFirmware: FirmwareFinalVersionDto,\n ): EitherAsync<Error, FinalFirmware> {\n return EitherAsync(() => {\n if (\n typeof finalFirmware !== \"object\" ||\n typeof finalFirmware.id !== \"number\" ||\n typeof finalFirmware.version !== \"string\" ||\n typeof finalFirmware.perso !== \"string\" ||\n (finalFirmware.firmware !== null &&\n typeof finalFirmware.firmware !== \"string\") ||\n (finalFirmware.firmware_key !== null &&\n typeof finalFirmware.firmware_key !== \"string\") ||\n (finalFirmware.hash !== null &&\n typeof finalFirmware.hash !== \"string\") ||\n (finalFirmware.bytes !== null &&\n typeof finalFirmware.bytes !== \"number\") ||\n !Array.isArray(finalFirmware.mcu_versions)\n ) {\n throw new Error(\n `Incomplete final firmware: ${JSON.stringify(finalFirmware)}`,\n );\n }\n const ret: FinalFirmware = {\n id: finalFirmware.id,\n version: finalFirmware.version,\n perso: finalFirmware.perso,\n firmware: finalFirmware.firmware,\n firmwareKey: finalFirmware.firmware_key,\n hash: finalFirmware.hash,\n bytes: finalFirmware.bytes,\n mcuVersions: finalFirmware.mcu_versions,\n };\n return Promise.resolve(ret);\n });\n }\n\n private mapLatestFirmwareDto(\n latestFirmware: LatestFirmwareOsuVersionResponseDto,\n ): EitherAsync<Error, Maybe<OsuFirmware>> {\n return EitherAsync<Error, FirmwareOsuVersionDto | null>(() => {\n /**\n * This is how we know that there is no update available.\n * See the {@link https://github.com/LedgerHQ/ledger-live/blob/develop/libs/device-core/src/managerApi/repositories/HttpManagerApiRepository.ts#L59-L61 | ledger-live implementation}.\n */\n if (latestFirmware.result === \"null\") {\n return Promise.resolve(null);\n }\n if (\n latestFirmware.result !== \"success\" ||\n !latestFirmware.se_firmware_osu_version\n ) {\n throw new Error(\n `Latest firmware could not be retrieved: ${latestFirmware.result}`,\n );\n }\n const osuDto = latestFirmware.se_firmware_osu_version;\n return Promise.resolve(osuDto);\n }).chain((osuDto) => {\n if (null === osuDto) {\n return EitherAsync(() => Promise.resolve(Nothing));\n }\n return this.mapOsuFirmwareDto(osuDto).map((osuFirmware) =>\n Just(osuFirmware),\n );\n });\n }\n\n private mapOsuFirmwareDto(\n osuDto: FirmwareOsuVersionDto,\n ): EitherAsync<Error, OsuFirmware> {\n return EitherAsync(() => {\n if (\n typeof osuDto !== \"object\" ||\n typeof osuDto.id !== \"number\" ||\n (osuDto.notes !== null && typeof osuDto.notes !== \"string\") ||\n typeof osuDto.perso !== \"string\" ||\n typeof osuDto.firmware !== \"string\" ||\n typeof osuDto.firmware_key !== \"string\" ||\n (osuDto.hash !== null && typeof osuDto.hash !== \"string\") ||\n typeof osuDto.next_se_firmware_final_version !== \"number\"\n ) {\n throw new Error(\n `Incomplete latest firmware: ${JSON.stringify(osuDto)}`,\n );\n }\n const ret: OsuFirmware = {\n id: osuDto.id,\n notes: osuDto.notes,\n perso: osuDto.perso,\n firmware: osuDto.firmware,\n firmwareKey: osuDto.firmware_key,\n hash: osuDto.hash,\n nextFinalFirmware: osuDto.next_se_firmware_final_version,\n };\n return Promise.resolve(ret);\n });\n }\n\n private mapLanguagesDtoToLanguages(\n languages: Array<LanguagePackageVersionDto>,\n ): EitherAsync<Error, Array<LanguagePackage>> {\n return EitherAsync(() =>\n Promise.resolve(\n languages.map((language) => this.mapLanguageDto(language)),\n ),\n );\n }\n\n private mapLanguageDto(language: LanguagePackageVersionDto): LanguagePackage {\n if (\n typeof language !== \"object\" ||\n typeof language.language !== \"string\" ||\n typeof language.languagePackageVersionId !== \"number\" ||\n typeof language.version !== \"string\" ||\n typeof language.language_package_id !== \"number\" ||\n typeof language.apdu_install_url !== \"string\" ||\n typeof language.apdu_uninstall_url !== \"string\" ||\n typeof language.bytes !== \"number\" ||\n typeof language.date_creation !== \"string\" ||\n typeof language.date_last_modified !== \"string\"\n ) {\n throw new Error(\n `Incomplete language version: ${JSON.stringify(language)}`,\n );\n }\n const ret: LanguagePackage = {\n language: language.language,\n languagePackageVersionId: language.languagePackageVersionId,\n version: language.version,\n languagePackageId: language.language_package_id,\n apduInstallUrl: language.apdu_install_url,\n apduUninstallUrl: language.apdu_uninstall_url,\n bytes: language.bytes,\n dateCreation: language.date_creation,\n dateLastModified: language.date_last_modified,\n };\n return ret;\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAS,eAAAC,EAAa,QAAAC,EAAa,WAAAC,MAAe,YAGlD,OAAS,oBAAAC,MAAwB,gCACjC,OAAS,yBAAAC,MAA6B,qCACtC,OAAS,mBAAAC,MAAuB,2CAChC,OAEE,WAAAC,MACK,0CACP,OAAS,oBAAAC,MAAwB,oCACjC,OAAS,sCAAAC,MAA0C,oCAEnD,OAAS,qBAAAC,MAAyB,qCAiBlC,OAEE,cAAAC,MAOK,kBAEP,MAAMC,EAAuBC,GAIvBA,aAAiBC,GAAyBD,EAAM,QAAU,OACrD,IAAIE,EAAkBF,EAAM,KAAK,EAEnC,IAAIE,EAAkBF,CAAK,EAI7B,IAAMG,EAAN,KAA+D,CACnD,KACT,UAAoBC,EACpB,0BACNC,EAEF,YAEE,CAAE,cAAAC,EAAe,SAAAC,EAAU,yBAAAC,CAAyB,EACpD,CACA,KAAK,KAAO,IAAIC,EAAiB,CAAE,QAASH,CAAc,CAAC,EAC3D,KAAK,UAAYC,EACjB,KAAK,0BAA4BC,CACnC,CAEA,YAAYD,EAAwB,CAC9B,KAAK,YAAcA,GAAYA,EAAW,IAG9C,KAAK,UAAYA,EACnB,CAEA,aAAsB,CACpB,OAAO,KAAK,SACd,CAEA,WACEG,EACoD,CACpD,KAAM,CAAE,SAAAC,EAAU,oBAAAC,CAAoB,EAAIF,EAC1C,OAAOG,EAAY,IACjB,KAAK,KAAK,IAAI,qBAAsB,CAClC,OAAQ,CACN,UAAWF,EACX,SAAU,KAAK,UACf,sBAAuBC,CACzB,CACF,CAAC,CACH,EACG,MAAOE,GACN,KAAK,+BAA+BA,CAA6B,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,QACN8B,EAAU,IAAKC,GAAa,KAAK,eAAeA,CAAQ,CAAC,CAC3D,CACF,CACF,CAEQ,eAAeA,EAAsD,CAC3E,GACE,OAAOA,GAAa,UACpB,OAAOA,EAAS,UAAa,UAC7B,OAAOA,EAAS,0BAA6B,UAC7C,OAAOA,EAAS,SAAY,UAC5B,OAAOA,EAAS,qBAAwB,UACxC,OAAOA,EAAS,kBAAqB,UACrC,OAAOA,EAAS,oBAAuB,UACvC,OAAOA,EAAS,OAAU,UAC1B,OAAOA,EAAS,eAAkB,UAClC,OAAOA,EAAS,oBAAuB,SAEvC,MAAM,IAAI,MACR,gCAAgC,KAAK,UAAUA,CAAQ,CAAC,EAC1D,EAaF,MAX6B,CAC3B,SAAUA,EAAS,SACnB,yBAA0BA,EAAS,yBACnC,QAASA,EAAS,QAClB,kBAAmBA,EAAS,oBAC5B,eAAgBA,EAAS,iBACzB,iBAAkBA,EAAS,mBAC3B,MAAOA,EAAS,MAChB,aAAcA,EAAS,cACvB,iBAAkBA,EAAS,kBAC7B,CAEF,CACF,EAtcazC,EAAN0C,EAAA,CADNC,EAAW,EAQPC,EAAA,EAAAC,EAAOC,EAAgB,SAAS,IAPxB9C",
|
|
6
6
|
"names": ["inject", "injectable", "EitherAsync", "Just", "Nothing", "DmkNetworkClient", "DmkNetworkClientError", "managerApiTypes", "AppType", "DEFAULT_PROVIDER", "DEFAULT_FIRMWARE_DISTRIBUTION_SALT", "HttpFetchApiError", "AppTypeDto", "toHttpFetchApiError", "error", "DmkNetworkClientError", "HttpFetchApiError", "HttpManagerApiDataSource", "DEFAULT_PROVIDER", "DEFAULT_FIRMWARE_DISTRIBUTION_SALT", "managerApiUrl", "provider", "firmwareDistributionSalt", "DmkNetworkClient", "params", "targetId", "firmwareVersionName", "EitherAsync", "apps", "mcus", "deviceVersion", "deviceId", "version", "finalFirmware", "finalFirmwareId", "osuFirmware", "livecommonversion", "currentFinalFirmwareId", "latestFirmware", "hashes", "appType", "AppTypeDto", "AppType", "app", "applicationType", "hash", "perso", "firmware", "firmwareKey", "del", "deleteKey", "rest", "mcu", "ret", "osuDto", "Nothing", "Just", "languages", "language", "__decorateClass", "injectable", "__decorateParam", "inject", "managerApiTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Just as h,Left as o,Nothing as u,Right as t}from"purify-ts";import{BTC_APP as d,BTC_APP_METADATA as n,CUSTOM_LOCK_SCREEN_APP as g,CUSTOM_LOCK_SCREEN_APP_METADATA as p,ETH_APP_METADATA as f}from"../../../api/device-action/__test-utils__/data";import{HttpFetchApiError as i}from"../../manager-api/model/Errors";import{HttpManagerApiDataSource as s}from"./HttpManagerApiDataSource";describe("HttpManagerApiDataSource",()=>{describe("getAppList",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return a list of applications",async()=>{const e=[n,f];vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify(e)));const a=await r.getAppList({targetId:"targetId",firmwareVersionName:"firmwareVersionName"});expect(a).toEqual(t(e))}),it("should return an error if payload don't match the dto",async()=>{const{versionId:e,...a}=n,l=[{versionId:"invalidVersion",...a}];vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify(l)));const c=await r.getAppList({targetId:"targetId",firmwareVersionName:"firmwareVersionName"});expect(c.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getAppList({targetId:"targetId",firmwareVersionName:"firmwareVersionName"});expect(a).toEqual(o(new i(e)))})}),describe("getAppsByHash",()=>{describe("success cases",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("with BTC app, should return the metadata",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([n])));const e=[d.appFullHash],a=await r.getAppsByHash({hashes:e});expect(a).toEqual(t([n]))}),it("with no apps, should return an empty list",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([])));const e=[],a=await r.getAppsByHash({hashes:e});expect(a).toEqual(t([]))}),it("with BTC app and custom lock screen, should return the metadata",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([n,p])));const e=[d.appFullHash,g.appFullHash],a=await r.getAppsByHash({hashes:e});expect(a).toEqual(t([n,p]))})}),describe("error cases",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("with BTC app, should fail if payload don't match the dto",async()=>{const{versionId:e,...a}=n;vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([{versionId:"invalidVersion",...a}])));const l=[d.appFullHash],c=await r.getAppsByHash({hashes:l});expect(c.isRight()).toEqual(!1)}),it("should throw an error if the request fails",async()=>{const e=new s({managerApiUrl:"http://localhost"}),a=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(a);const l=[d.appFullHash],c=await e.getAppsByHash({hashes:l});expect(c).toEqual(o(new i(a)))})})}),describe("getDeviceVersion",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return a complete device version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:17,target_id:"857735172"})));const e=await r.getDeviceVersion({targetId:"targetId"});expect(e).toEqual(t({id:17}))}),it("should return an error if payload don't match dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({target_id:"857735172"})));const e=await r.getDeviceVersion({targetId:"targetId"});expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getDeviceVersion({targetId:"targetId"});expect(a).toEqual(o(new i(e)))})}),describe("getFirmwareVersion",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return a complete firmware version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:361,version:"1.6.0",perso:"perso_11",firmware:null,firmware_key:"testKey",hash:"hash",bytes:194,mcu_versions:[1,5,7]})));const e=await r.getFirmwareVersion({version:"versionName",deviceId:42});expect(e).toEqual(t({id:361,version:"1.6.0",perso:"perso_11",firmware:null,firmwareKey:"testKey",hash:"hash",bytes:194,mcuVersions:[1,5,7]}))}),it("should return an error if payload don't match the dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:"invalidId",version:"1.6.0",perso:"perso_11",firmware:null,firmware_key:"testKey",hash:"hash",bytes:194,mcu_versions:[1,5,7]})));const e=await r.getFirmwareVersion({version:"versionName",deviceId:42});expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getFirmwareVersion({version:"versionName",deviceId:42});expect(a).toEqual(o(new i(e)))})}),describe("setProvider",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://fake-url.com",provider:1})}),it("should not change the provider if the new value is the same",()=>{const e=r._provider;r.setProvider(e),expect(r._provider).toBe(e)}),it("should not change the provider if the new value is less than 1",()=>{const e=r._provider;r.setProvider(0),r.setProvider(-5),expect(r._provider).toBe(e)}),it("should update the provider if a valid and different value is provided",()=>{r.setProvider(2),expect(r._provider).toBe(2)})}),describe("getFirmwareVersionById",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return a complete firmware version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:361,version:"1.6.0",perso:"perso_11",firmware:null,firmware_key:"testKey",hash:"hash",bytes:194,mcu_versions:[1,5,7]})));const e=await r.getFirmwareVersionById(42);expect(e).toEqual(t({id:361,version:"1.6.0",perso:"perso_11",firmware:null,firmwareKey:"testKey",hash:"hash",bytes:194,mcuVersions:[1,5,7]}))})}),describe("getLatestFirmwareVersion",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return the latest firmware version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({result:"success",se_firmware_osu_version:{id:361,perso:"perso_11",notes:"notes",firmware:"test",firmware_key:"testKey",hash:"hash",next_se_firmware_final_version:567}})));const e=await r.getLatestFirmwareVersion({currentFinalFirmwareId:200,deviceId:42});expect(e).toEqual(t(h({id:361,perso:"perso_11",notes:"notes",firmware:"test",firmwareKey:"testKey",hash:"hash",nextFinalFirmware:567})))}),it("should return nothing when no latest firmware version is available",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({result:"null",se_firmware_osu_version:null})));const e=await r.getLatestFirmwareVersion({currentFinalFirmwareId:200,deviceId:42});expect(e).toEqual(t(u))}),it("should return an error if result is not success",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({result:"failed",se_firmware_osu_version:null})));const e=await r.getLatestFirmwareVersion({currentFinalFirmwareId:200,deviceId:42});expect(e.isRight()).toEqual(!1)}),it("should return an error if payload don't match the dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({result:"success",se_firmware_osu_version:{id:"InvalidId",perso:"perso_11",firmware:"test",firmware_key:"testKey",hash:"hash",next_se_firmware_final_version:567}})));const e=await r.getLatestFirmwareVersion({currentFinalFirmwareId:200,deviceId:42});expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getLatestFirmwareVersion({currentFinalFirmwareId:200,deviceId:42});expect(a).toEqual(o(new i(e)))})}),describe("getOsuFirmwareVersion",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return a complete OSU firmware version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:361,perso:"perso_11",notes:"notes",firmware:"test",firmware_key:"testKey",hash:"hash",next_se_firmware_final_version:567})));const e=await r.getOsuFirmwareVersion({version:"versionName",deviceId:42});expect(e).toEqual(t({id:361,perso:"perso_11",notes:"notes",firmware:"test",firmwareKey:"testKey",hash:"hash",nextFinalFirmware:567}))}),it("should return an error if payload don't match the dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:"invalidId",perso:"perso_11",firmware:"test",firmware_key:"testKey",hash:"hash",next_se_firmware_final_version:567})));const e=await r.getOsuFirmwareVersion({version:"versionName",deviceId:42});expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getOsuFirmwareVersion({version:"versionName",deviceId:42});expect(a).toEqual(o(new i(e)))})}),describe("getLanguagePackages",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return the langage packages version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([{language:"turkish",languagePackageVersionId:474,version:"0.0.4",language_package_id:57,apdu_install_url:"https://download.languages.ledger.com/stax/turkish/bolos_1.6.2_pack_0.0.4_tr.apdu",apdu_uninstall_url:"https://download.languages.ledger.com/stax/turkish/bolos_1.6.2_pack_0.0.4_tr_del.apdu",device_versions:[17],se_firmware_final_versions:[432],bytes:20800,date_creation:"2025-03-04T10:48:27.910630Z",date_last_modified:"2025-03-04T10:48:27.910630Z"},{language:"russian",languagePackageVersionId:470,version:"0.0.4",language_package_id:56,apdu_install_url:"https://download.languages.ledger.com/stax/russian/bolos_1.6.2_pack_0.0.4_ru.apdu",apdu_uninstall_url:"https://download.languages.ledger.com/stax/russian/bolos_1.6.2_pack_0.0.4_ru_del.apdu",device_versions:[17],se_firmware_final_versions:[432],bytes:46592,date_creation:"2025-03-04T10:48:26.218729Z",date_last_modified:"2025-03-04T10:48:26.218729Z"}])));const e=await r.getLanguagePackages({deviceId:1,currentFinalFirmwareId:42});expect(e).toEqual(t([{language:"turkish",languagePackageVersionId:474,version:"0.0.4",languagePackageId:57,apduInstallUrl:"https://download.languages.ledger.com/stax/turkish/bolos_1.6.2_pack_0.0.4_tr.apdu",apduUninstallUrl:"https://download.languages.ledger.com/stax/turkish/bolos_1.6.2_pack_0.0.4_tr_del.apdu",bytes:20800,dateCreation:"2025-03-04T10:48:27.910630Z",dateLastModified:"2025-03-04T10:48:27.910630Z"},{language:"russian",languagePackageVersionId:470,version:"0.0.4",languagePackageId:56,apduInstallUrl:"https://download.languages.ledger.com/stax/russian/bolos_1.6.2_pack_0.0.4_ru.apdu",apduUninstallUrl:"https://download.languages.ledger.com/stax/russian/bolos_1.6.2_pack_0.0.4_ru_del.apdu",bytes:46592,dateCreation:"2025-03-04T10:48:26.218729Z",dateLastModified:"2025-03-04T10:48:26.218729Z"}]))}),it("should return an error if payload don't match the dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([{language:"turkish",version:"0.0.4",language_package_id:"invalid"}])));const e=await r.getLanguagePackages({deviceId:1,currentFinalFirmwareId:42});expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getLanguagePackages({deviceId:1,currentFinalFirmwareId:42});expect(a).toEqual(o(new i(e)))})}),describe("getMcuList",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return the list of MCUs",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([{id:1,mcu:1,name:"1.0",description:null,providers:[],device_versions:[1,2],from_bootloader_version:"1.0",from_bootloader_version_id:2,se_firmware_final_versions:[7,12,13,14,15],date_creation:"2018-09-20T13:30:50.156394Z",date_last_modified:"2018-09-20T13:30:50.156453Z"},{id:2,mcu:1,name:"1.1",description:null,providers:[],device_versions:[1,2],from_bootloader_version:"1.0",from_bootloader_version_id:2,se_firmware_final_versions:[7,12,13,14,15],date_creation:"2018-09-20T13:30:50.339966Z",date_last_modified:"2018-09-20T13:30:50.340031Z"}])));const e=await r.getMcuList();expect(e).toEqual(t([{id:1,name:"1.0",fromBootloaderVersion:"1.0"},{id:2,name:"1.1",fromBootloaderVersion:"1.0"}]))}),it("should return an error when the payload don't match the dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([{id:"invalid id",mcu:1,name:"1.0",description:null,providers:[],se_firmware_final_versions:[7,12,13,14,15],date_creation:"2018-09-20T13:30:50.156394Z",date_last_modified:"2018-09-20T13:30:50.156453Z"}])));const e=await r.getMcuList();expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getMcuList();expect(a).toEqual(o(new i(e)))})}),describe("getProvider",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://fake-url.com",provider:123})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return the initial provider",()=>{expect(r.getProvider()).toBe(123)}),it("should return the updated provider after setProvider is called",()=>{r.setProvider(321),expect(r.getProvider()).toBe(321)})})});
|
|
1
|
+
import{Just as h,Left as o,Nothing as u,Right as t}from"purify-ts";import{BTC_APP as d,BTC_APP_METADATA as n,CUSTOM_LOCK_SCREEN_APP as g,CUSTOM_LOCK_SCREEN_APP_METADATA as p,ETH_APP_METADATA as f}from"../../../api/device-action/__test-utils__/data";import{HttpFetchApiError as i}from"../../manager-api/model/Errors";import{HttpManagerApiDataSource as s}from"./HttpManagerApiDataSource";describe("HttpManagerApiDataSource",()=>{describe("getAppList",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return a list of applications",async()=>{const e=[n,f];vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify(e)));const a=await r.getAppList({targetId:"targetId",firmwareVersionName:"firmwareVersionName"});expect(a).toEqual(t(e))}),it("should return an error if payload don't match the dto",async()=>{const{versionId:e,...a}=n,l=[{versionId:"invalidVersion",...a}];vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify(l)));const c=await r.getAppList({targetId:"targetId",firmwareVersionName:"firmwareVersionName"});expect(c.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getAppList({targetId:"targetId",firmwareVersionName:"firmwareVersionName"});expect(a).toEqual(o(new i(e)))})}),describe("getAppsByHash",()=>{describe("success cases",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("with BTC app, should return the metadata",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([n])));const e=[d.appFullHash],a=await r.getAppsByHash({hashes:e});expect(a).toEqual(t([n]))}),it("with no apps, should return an empty list",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([])));const e=[],a=await r.getAppsByHash({hashes:e});expect(a).toEqual(t([]))}),it("with BTC app and custom lock screen, should return the metadata",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([n,p])));const e=[d.appFullHash,g.appFullHash],a=await r.getAppsByHash({hashes:e});expect(a).toEqual(t([n,p]))})}),describe("error cases",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("with BTC app, should fail if payload don't match the dto",async()=>{const{versionId:e,...a}=n;vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([{versionId:"invalidVersion",...a}])));const l=[d.appFullHash],c=await r.getAppsByHash({hashes:l});expect(c.isRight()).toEqual(!1)}),it("should throw an error if the request fails",async()=>{const e=new s({managerApiUrl:"http://localhost"}),a=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(a);const l=[d.appFullHash],c=await e.getAppsByHash({hashes:l});expect(c).toEqual(o(new i(a)))})})}),describe("getDeviceVersion",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return a complete device version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:17,target_id:"857735172"})));const e=await r.getDeviceVersion({targetId:"targetId"});expect(e).toEqual(t({id:17}))}),it("should return an error if payload don't match dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({target_id:"857735172"})));const e=await r.getDeviceVersion({targetId:"targetId"});expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getDeviceVersion({targetId:"targetId"});expect(a).toEqual(o(new i(e)))})}),describe("getFirmwareVersion",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return a complete firmware version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:361,version:"1.6.0",perso:"perso_11",firmware:null,firmware_key:"testKey",hash:"hash",bytes:194,mcu_versions:[1,5,7]})));const e=await r.getFirmwareVersion({version:"versionName",deviceId:42});expect(e).toEqual(t({id:361,version:"1.6.0",perso:"perso_11",firmware:null,firmwareKey:"testKey",hash:"hash",bytes:194,mcuVersions:[1,5,7]}))}),it("should return an error if payload don't match the dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:"invalidId",version:"1.6.0",perso:"perso_11",firmware:null,firmware_key:"testKey",hash:"hash",bytes:194,mcu_versions:[1,5,7]})));const e=await r.getFirmwareVersion({version:"versionName",deviceId:42});expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getFirmwareVersion({version:"versionName",deviceId:42});expect(a).toEqual(o(new i(e)))})}),describe("setProvider",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://fake-url.com",provider:1})}),it("should not change the provider if the new value is the same",()=>{const e=r._provider;r.setProvider(e),expect(r._provider).toBe(e)}),it("should not change the provider if the new value is less than 1",()=>{const e=r._provider;r.setProvider(0),r.setProvider(-5),expect(r._provider).toBe(e)}),it("should update the provider if a valid and different value is provided",()=>{r.setProvider(2),expect(r._provider).toBe(2)})}),describe("getFirmwareVersionById",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return a complete firmware version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:361,version:"1.6.0",perso:"perso_11",firmware:null,firmware_key:"testKey",hash:"hash",bytes:194,mcu_versions:[1,5,7]})));const e=await r.getFirmwareVersionById(42);expect(e).toEqual(t({id:361,version:"1.6.0",perso:"perso_11",firmware:null,firmwareKey:"testKey",hash:"hash",bytes:194,mcuVersions:[1,5,7]}))})}),describe("getLatestFirmwareVersion",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return the latest firmware version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({result:"success",se_firmware_osu_version:{id:361,perso:"perso_11",notes:"notes",firmware:"test",firmware_key:"testKey",hash:"hash",next_se_firmware_final_version:567}})));const e=await r.getLatestFirmwareVersion({currentFinalFirmwareId:200,deviceId:42});expect(e).toEqual(t(h({id:361,perso:"perso_11",notes:"notes",firmware:"test",firmwareKey:"testKey",hash:"hash",nextFinalFirmware:567})))}),it("should return nothing when no latest firmware version is available",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({result:"null",se_firmware_osu_version:null})));const e=await r.getLatestFirmwareVersion({currentFinalFirmwareId:200,deviceId:42});expect(e).toEqual(t(u))}),it("should return an error if result is not success",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({result:"failed",se_firmware_osu_version:null})));const e=await r.getLatestFirmwareVersion({currentFinalFirmwareId:200,deviceId:42});expect(e.isRight()).toEqual(!1)}),it("should return an error if payload don't match the dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({result:"success",se_firmware_osu_version:{id:"InvalidId",perso:"perso_11",firmware:"test",firmware_key:"testKey",hash:"hash",next_se_firmware_final_version:567}})));const e=await r.getLatestFirmwareVersion({currentFinalFirmwareId:200,deviceId:42});expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getLatestFirmwareVersion({currentFinalFirmwareId:200,deviceId:42});expect(a).toEqual(o(new i(e)))})}),describe("getOsuFirmwareVersion",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return a complete OSU firmware version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:361,perso:"perso_11",notes:"notes",firmware:"test",firmware_key:"testKey",hash:"hash",next_se_firmware_final_version:567})));const e=await r.getOsuFirmwareVersion({version:"versionName",deviceId:42});expect(e).toEqual(t({id:361,perso:"perso_11",notes:"notes",firmware:"test",firmwareKey:"testKey",hash:"hash",nextFinalFirmware:567}))}),it("should return an error if payload don't match the dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify({id:"invalidId",perso:"perso_11",firmware:"test",firmware_key:"testKey",hash:"hash",next_se_firmware_final_version:567})));const e=await r.getOsuFirmwareVersion({version:"versionName",deviceId:42});expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getOsuFirmwareVersion({version:"versionName",deviceId:42});expect(a).toEqual(o(new i(e)))})}),describe("getLanguagePackages",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return the langage packages version",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([{language:"turkish",languagePackageVersionId:474,version:"0.0.4",language_package_id:57,apdu_install_url:"https://download.languages.ledger.com/stax/turkish/bolos_1.6.2_pack_0.0.4_tr.apdu",apdu_uninstall_url:"https://download.languages.ledger.com/stax/turkish/bolos_1.6.2_pack_0.0.4_tr_del.apdu",device_versions:[17],se_firmware_final_versions:[432],bytes:20800,date_creation:"2025-03-04T10:48:27.910630Z",date_last_modified:"2025-03-04T10:48:27.910630Z"},{language:"russian",languagePackageVersionId:470,version:"0.0.4",language_package_id:56,apdu_install_url:"https://download.languages.ledger.com/stax/russian/bolos_1.6.2_pack_0.0.4_ru.apdu",apdu_uninstall_url:"https://download.languages.ledger.com/stax/russian/bolos_1.6.2_pack_0.0.4_ru_del.apdu",device_versions:[17],se_firmware_final_versions:[432],bytes:46592,date_creation:"2025-03-04T10:48:26.218729Z",date_last_modified:"2025-03-04T10:48:26.218729Z"}])));const e=await r.getLanguagePackages({deviceId:1,currentFinalFirmwareId:42});expect(e).toEqual(t([{language:"turkish",languagePackageVersionId:474,version:"0.0.4",languagePackageId:57,apduInstallUrl:"https://download.languages.ledger.com/stax/turkish/bolos_1.6.2_pack_0.0.4_tr.apdu",apduUninstallUrl:"https://download.languages.ledger.com/stax/turkish/bolos_1.6.2_pack_0.0.4_tr_del.apdu",bytes:20800,dateCreation:"2025-03-04T10:48:27.910630Z",dateLastModified:"2025-03-04T10:48:27.910630Z"},{language:"russian",languagePackageVersionId:470,version:"0.0.4",languagePackageId:56,apduInstallUrl:"https://download.languages.ledger.com/stax/russian/bolos_1.6.2_pack_0.0.4_ru.apdu",apduUninstallUrl:"https://download.languages.ledger.com/stax/russian/bolos_1.6.2_pack_0.0.4_ru_del.apdu",bytes:46592,dateCreation:"2025-03-04T10:48:26.218729Z",dateLastModified:"2025-03-04T10:48:26.218729Z"}]))}),it("should return an error if payload don't match the dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([{language:"turkish",version:"0.0.4",language_package_id:"invalid"}])));const e=await r.getLanguagePackages({deviceId:1,currentFinalFirmwareId:42});expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getLanguagePackages({deviceId:1,currentFinalFirmwareId:42});expect(a).toEqual(o(new i(e)))})}),describe("getMcuList",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://localhost"})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return the list of MCUs",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([{id:1,mcu:1,name:"1.0",description:null,providers:[1],device_versions:[1,2],from_bootloader_version:"1.0",from_bootloader_version_id:2,se_firmware_final_versions:[7,12,13,14,15],date_creation:"2018-09-20T13:30:50.156394Z",date_last_modified:"2018-09-20T13:30:50.156453Z"},{id:2,mcu:1,name:"1.1",description:null,providers:[1,2],device_versions:[1,2],from_bootloader_version:"1.0",from_bootloader_version_id:2,se_firmware_final_versions:[7,12,13,14,15],date_creation:"2018-09-20T13:30:50.339966Z",date_last_modified:"2018-09-20T13:30:50.340031Z"}])));const e=await r.getMcuList();expect(e).toEqual(t([{id:1,name:"1.0",fromBootloaderVersion:"1.0",providers:[1]},{id:2,name:"1.1",fromBootloaderVersion:"1.0",providers:[1,2]}]))}),it("should return an error when the payload don't match the dto",async()=>{vi.spyOn(globalThis,"fetch").mockResolvedValue(new Response(JSON.stringify([{id:"invalid id",mcu:1,name:"1.0",description:null,providers:[],se_firmware_final_versions:[7,12,13,14,15],date_creation:"2018-09-20T13:30:50.156394Z",date_last_modified:"2018-09-20T13:30:50.156453Z"}])));const e=await r.getMcuList();expect(e.isRight()).toEqual(!1)}),it("should return an error if the request fails",async()=>{const e=new Error("fetch error");vi.spyOn(globalThis,"fetch").mockRejectedValue(e);const a=await r.getMcuList();expect(a).toEqual(o(new i(e)))})}),describe("getProvider",()=>{let r;beforeEach(()=>{r=new s({managerApiUrl:"http://fake-url.com",provider:123})}),afterEach(()=>{vi.restoreAllMocks()}),it("should return the initial provider",()=>{expect(r.getProvider()).toBe(123)}),it("should return the updated provider after setProvider is called",()=>{r.setProvider(321),expect(r.getProvider()).toBe(321)})})});
|
|
2
2
|
//# sourceMappingURL=HttpManagerApiDataSource.test.js.map
|