@ledgerhq/device-management-kit 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +79 -0
  2. package/lib/cjs/package.json +1 -1
  3. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  4. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  5. package/lib/cjs/src/api/index.js +1 -1
  6. package/lib/cjs/src/api/index.js.map +3 -3
  7. package/lib/cjs/src/api/logger-subscriber/model/LogSubscriberOptions.js +1 -1
  8. package/lib/cjs/src/api/logger-subscriber/model/LogSubscriberOptions.js.map +1 -1
  9. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
  10. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js.map +2 -2
  11. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.test.js +1 -1
  12. package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
  13. package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.js +2 -0
  14. package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.js.map +7 -0
  15. package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js +2 -0
  16. package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js.map +7 -0
  17. package/lib/cjs/src/api/logger-subscriber/service/LogTagFormatter.js +2 -0
  18. package/lib/cjs/src/api/logger-subscriber/service/LogTagFormatter.js.map +7 -0
  19. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  20. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +2 -2
  21. package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js +2 -0
  22. package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js.map +7 -0
  23. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  24. package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  25. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js +1 -1
  26. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js.map +3 -3
  27. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
  28. package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +3 -3
  29. package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.js +2 -0
  30. package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.js.map +7 -0
  31. package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.test.js +2 -0
  32. package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.test.js.map +7 -0
  33. package/lib/esm/package.json +1 -1
  34. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  35. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  36. package/lib/esm/src/api/index.js +1 -1
  37. package/lib/esm/src/api/index.js.map +3 -3
  38. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
  39. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js.map +2 -2
  40. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.test.js +1 -1
  41. package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
  42. package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.js +2 -0
  43. package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.js.map +7 -0
  44. package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js +2 -0
  45. package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js.map +7 -0
  46. package/lib/esm/src/api/logger-subscriber/service/LogTagFormatter.js +1 -0
  47. package/lib/esm/src/api/logger-subscriber/service/LogTagFormatter.js.map +7 -0
  48. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  49. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +2 -2
  50. package/lib/esm/src/internal/device-session/model/DeviceSession.test.js +2 -0
  51. package/lib/esm/src/internal/device-session/model/DeviceSession.test.js.map +7 -0
  52. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
  53. package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
  54. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js +1 -1
  55. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js.map +3 -3
  56. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
  57. package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +3 -3
  58. package/lib/esm/src/internal/logger-publisher/service/sanitiseData.js +2 -0
  59. package/lib/esm/src/internal/logger-publisher/service/sanitiseData.js.map +7 -0
  60. package/lib/esm/src/internal/logger-publisher/service/sanitiseData.test.js +2 -0
  61. package/lib/esm/src/internal/logger-publisher/service/sanitiseData.test.js.map +7 -0
  62. package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts +4 -0
  63. package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts.map +1 -1
  64. package/lib/types/src/api/index.d.ts +2 -0
  65. package/lib/types/src/api/index.d.ts.map +1 -1
  66. package/lib/types/src/api/logger-subscriber/model/LogSubscriberOptions.d.ts +1 -0
  67. package/lib/types/src/api/logger-subscriber/model/LogSubscriberOptions.d.ts.map +1 -1
  68. package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.d.ts +10 -0
  69. package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.d.ts.map +1 -0
  70. package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.d.ts +2 -0
  71. package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.d.ts.map +1 -0
  72. package/lib/types/src/api/logger-subscriber/service/LogTagFormatter.d.ts +9 -0
  73. package/lib/types/src/api/logger-subscriber/service/LogTagFormatter.d.ts.map +1 -0
  74. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  75. package/lib/types/src/internal/device-session/model/DeviceSession.test.d.ts +2 -0
  76. package/lib/types/src/internal/device-session/model/DeviceSession.test.d.ts.map +1 -0
  77. package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
  78. package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.d.ts +5 -2
  79. package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.d.ts.map +1 -1
  80. package/lib/types/src/internal/logger-publisher/service/sanitiseData.d.ts +6 -0
  81. package/lib/types/src/internal/logger-publisher/service/sanitiseData.d.ts.map +1 -0
  82. package/lib/types/src/internal/logger-publisher/service/sanitiseData.test.d.ts +2 -0
  83. package/lib/types/src/internal/logger-publisher/service/sanitiseData.test.d.ts.map +1 -0
  84. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  85. package/package.json +4 -4
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/model/DeviceSession.ts"],
4
- "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { BehaviorSubject, type Observable } from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { formatApduSendingLog } from \"@api/utils/apduLogs\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { MutexService } from \"@internal/device-session/service/MutexService\";\nimport { RefresherService } from \"@internal/device-session/service/RefresherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DevicePinger } from \"./DevicePinger\";\nimport {\n DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"./DeviceSessionEventDispatcher\";\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceSessionStateHandler } from \"./DeviceSessionStateHandler\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\nexport type DeviceSessionRefresherOptions = {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n abortTimeout?: number;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n private readonly _refresherOptions: DeviceSessionRefresherOptions;\n private _pinger: DevicePinger;\n private _deviceSessionRefresher: DeviceSessionRefresher;\n private readonly _refresherService: RefresherService;\n private _commandMutex = new MutexService();\n private _sessionEventDispatcher = new DeviceSessionEventDispatcher();\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n deviceSessionRefresherOptions: DeviceSessionRefresherOptions | undefined,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._logger = loggerModuleFactory(\"device-session\");\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\n this._refresherOptions = {\n ...DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n ...deviceSessionRefresherOptions,\n };\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n\n this._pinger = new DevicePinger(\n loggerModuleFactory,\n connectedDevice,\n this._sessionEventDispatcher,\n (command, abortTimeout) => this.sendCommand(command, abortTimeout),\n );\n this._deviceSessionRefresher = new DeviceSessionRefresher(\n loggerModuleFactory,\n this._refresherOptions,\n this._sessionEventDispatcher,\n this._connectedDevice,\n );\n new DeviceSessionStateHandler(\n loggerModuleFactory,\n this._sessionEventDispatcher,\n this._connectedDevice,\n this._deviceState,\n (state) => this.setDeviceSessionState(state),\n );\n\n this._refresherService = new RefresherService(loggerModuleFactory, {\n start: () => this._deviceSessionRefresher.restartRefresher(),\n stop: () => this._deviceSessionRefresher.stopRefresher(),\n });\n }\n\n public async initialiseSession(): Promise<void> {\n try {\n await this._pinger.ping();\n } catch (error) {\n this._logger.error(\"Error while initialising session\", {\n data: { error },\n });\n throw error;\n } finally {\n if (!this._refresherOptions.isRefresherDisabled) {\n this._deviceSessionRefresher.startRefresher();\n }\n }\n }\n\n public get id(): DeviceSessionId {\n return this._id;\n }\n\n public get connectedDevice(): TransportConnectedDevice {\n return this._connectedDevice;\n }\n\n public get state(): Observable<DeviceSessionState> {\n return this._deviceState.asObservable();\n }\n\n public getDeviceSessionState(): DeviceSessionState {\n return this._deviceState.getValue();\n }\n\n public setDeviceSessionState(state: DeviceSessionState): void {\n this._deviceState.next(state);\n }\n\n public async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const release = await this._commandMutex.lock();\n\n try {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_BUSY,\n });\n\n this._logger.debug(formatApduSendingLog(rawApdu));\n const result = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n options.abortTimeout,\n );\n\n result\n .ifRight((response: ApduResponse) => {\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_LOCKED,\n });\n } else {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n }\n })\n .ifLeft(() => {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n });\n return result;\n } finally {\n release();\n }\n }\n\n public async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n this._logger.debug(`[sendCommand] ${command.name}`);\n const apdu = command.getApdu();\n\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n abortTimeout,\n });\n\n return response.caseOf({\n Left: (err) => {\n this._logger.error(\"[sendCommand] error\", { data: { err } });\n throw err;\n },\n Right: (r) => {\n const result = command.parseResponse(\n r,\n this._connectedDevice.deviceModel.id,\n );\n this._logger.debug(\"[sendCommand] result\", { data: { result } });\n return result;\n },\n });\n }\n\n public executeDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendApdu: async (apdu: Uint8Array) => this.sendApdu(apdu),\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n abortTimeout?: number,\n ) => this.sendCommand(command, abortTimeout),\n getDeviceModel: () => this._connectedDevice.deviceModel,\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n disableRefresher: (blockerId: string) =>\n this._refresherService.disableRefresher(blockerId),\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n return { observable, cancel };\n }\n\n public close(): void {\n this._updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._deviceSessionRefresher.stopRefresher();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\n }\n\n private _updateDeviceStatus(deviceStatus: DeviceStatus): void {\n const state = this._deviceState.getValue();\n this._deviceState.next({ ...state, deviceStatus });\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAiD,gBACjDC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAKPC,EAAqC,+BACrCC,EAAyD,qEACzDC,EAA6B,yDAC7BC,EAAiC,6DAIjCC,EAA6B,0BAC7BC,EAGO,0CACPC,EAAuC,oCACvCC,EAA0C,uCAqBnC,MAAMd,CAAc,CACR,IACA,iBACA,aACA,mBACA,sBACA,QACA,kBACT,QACA,wBACS,kBACT,cAAgB,IAAI,eACpB,wBAA0B,IAAI,+BAEtC,YACE,CAAE,gBAAAe,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjCC,EACAC,EACAC,EACAC,EACA,CACA,KAAK,IAAML,EACX,KAAK,iBAAmBD,EACx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,EACxD,YAAa,MACXT,EACAC,IACG,KAAK,YAAYD,EAASC,CAAY,EAC3C,eAAgB,IAAM,KAAK,iBAAiB,YAC5C,sBAAuB,IAAM,KAAK,aAAa,SAAS,EACxD,gCAAiC,IAAM,KAAK,MAC5C,sBAAwBC,IACtB,KAAK,sBAAsBA,CAAK,EACzB,KAAK,aAAa,SAAS,GAEpC,iBAAmBY,GACjB,KAAK,kBAAkB,iBAAiBA,CAAS,EACnD,qBAAsB,IAAM,KAAK,mBACjC,wBAAyB,IAAM,KAAK,qBACtC,CAAC,EACD,MAAO,CAAE,WAAAF,EAAY,OAAAC,CAAO,CAC9B,CAEO,OAAc,CACnB,KAAK,oBAAoB,eAAa,aAAa,EACnD,KAAK,aAAa,SAAS,EAC3B,KAAK,wBAAwB,cAAc,CAC7C,CAEO,iBAAiBnB,EAAwB,CAC9C,OAAO,KAAK,kBAAkB,iBAAiBA,CAAE,CACnD,CAEQ,oBAAoBqB,EAAkC,CAC5D,MAAMb,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,aAAa,KAAK,CAAE,GAAGA,EAAO,aAAAa,CAAa,CAAC,CACnD,CACF",
4
+ "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { BehaviorSubject, type Observable } from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { formatApduSendingLog } from \"@api/utils/apduLogs\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { MutexService } from \"@internal/device-session/service/MutexService\";\nimport { RefresherService } from \"@internal/device-session/service/RefresherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DevicePinger } from \"./DevicePinger\";\nimport {\n DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"./DeviceSessionEventDispatcher\";\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceSessionStateHandler } from \"./DeviceSessionStateHandler\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\nexport type DeviceSessionRefresherOptions = {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n abortTimeout?: number;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n private readonly _refresherOptions: DeviceSessionRefresherOptions;\n private _pinger: DevicePinger;\n private _deviceSessionRefresher: DeviceSessionRefresher;\n private readonly _refresherService: RefresherService;\n private _commandMutex = new MutexService();\n private _sessionEventDispatcher = new DeviceSessionEventDispatcher();\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n deviceSessionRefresherOptions: DeviceSessionRefresherOptions | undefined,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._logger = loggerModuleFactory(\"device-session\");\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\n this._refresherOptions = {\n ...DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n ...deviceSessionRefresherOptions,\n };\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n\n this._pinger = new DevicePinger(\n loggerModuleFactory,\n connectedDevice,\n this._sessionEventDispatcher,\n (command, abortTimeout) => this.sendCommand(command, abortTimeout),\n );\n this._deviceSessionRefresher = new DeviceSessionRefresher(\n loggerModuleFactory,\n this._refresherOptions,\n this._sessionEventDispatcher,\n this._connectedDevice,\n );\n new DeviceSessionStateHandler(\n loggerModuleFactory,\n this._sessionEventDispatcher,\n this._connectedDevice,\n this._deviceState,\n (state) => this.setDeviceSessionState(state),\n );\n\n this._refresherService = new RefresherService(loggerModuleFactory, {\n start: () => this._deviceSessionRefresher.restartRefresher(),\n stop: () => this._deviceSessionRefresher.stopRefresher(),\n });\n }\n\n public async initialiseSession(): Promise<void> {\n try {\n await this._pinger.ping();\n } catch (error) {\n this._logger.error(\"Error while initialising session\", {\n data: { error },\n });\n throw error;\n } finally {\n if (!this._refresherOptions.isRefresherDisabled) {\n this._deviceSessionRefresher.startRefresher();\n }\n }\n }\n\n public get id(): DeviceSessionId {\n return this._id;\n }\n\n public get connectedDevice(): TransportConnectedDevice {\n return this._connectedDevice;\n }\n\n public get state(): Observable<DeviceSessionState> {\n return this._deviceState.asObservable();\n }\n\n public getDeviceSessionState(): DeviceSessionState {\n return this._deviceState.getValue();\n }\n\n public setDeviceSessionState(state: DeviceSessionState): void {\n this._deviceState.next(state);\n }\n\n public async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const release = await this._commandMutex.lock();\n\n try {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_BUSY,\n });\n\n this._logger.debug(formatApduSendingLog(rawApdu));\n const result = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n options.abortTimeout,\n );\n\n result\n .ifRight((response: ApduResponse) => {\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_LOCKED,\n });\n } else {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n }\n })\n .ifLeft(() => {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n });\n return result;\n } finally {\n release();\n }\n }\n\n public async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n this._logger.debug(`[sendCommand] ${command.name}`);\n const apdu = command.getApdu();\n\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n abortTimeout,\n });\n\n return response.caseOf({\n Left: (err) => {\n this._logger.error(\"[sendCommand] error\", { data: { err } });\n throw err;\n },\n Right: (r) => {\n const result = command.parseResponse(\n r,\n this._connectedDevice.deviceModel.id,\n );\n this._logger.debug(\"[sendCommand] result\", { data: { result } });\n return result;\n },\n });\n }\n\n public executeDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendApdu: async (apdu: Uint8Array) => this.sendApdu(apdu),\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n abortTimeout?: number,\n ) => this.sendCommand(command, abortTimeout),\n getDeviceModel: () => this._connectedDevice.deviceModel,\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n disableRefresher: (blockerId: string) =>\n this._refresherService.disableRefresher(blockerId),\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n return { observable, cancel };\n }\n\n public close(): void {\n this._updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._deviceSessionRefresher.stopRefresher();\n this._pinger.unsubscribe();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\n }\n\n private _updateDeviceStatus(deviceStatus: DeviceStatus): void {\n const state = this._deviceState.getValue();\n this._deviceState.next({ ...state, deviceStatus });\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAiD,gBACjDC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAKPC,EAAqC,+BACrCC,EAAyD,qEACzDC,EAA6B,yDAC7BC,EAAiC,6DAIjCC,EAA6B,0BAC7BC,EAGO,0CACPC,EAAuC,oCACvCC,EAA0C,uCAqBnC,MAAMd,CAAc,CACR,IACA,iBACA,aACA,mBACA,sBACA,QACA,kBACT,QACA,wBACS,kBACT,cAAgB,IAAI,eACpB,wBAA0B,IAAI,+BAEtC,YACE,CAAE,gBAAAe,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjCC,EACAC,EACAC,EACAC,EACA,CACA,KAAK,IAAML,EACX,KAAK,iBAAmBD,EACxB,KAAK,QAAUG,EAAoB,gBAAgB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KAAK,YAAYD,EAASC,CAAY,EAC3C,eAAgB,IAAM,KAAK,iBAAiB,YAC5C,sBAAuB,IAAM,KAAK,aAAa,SAAS,EACxD,gCAAiC,IAAM,KAAK,MAC5C,sBAAwBC,IACtB,KAAK,sBAAsBA,CAAK,EACzB,KAAK,aAAa,SAAS,GAEpC,iBAAmBY,GACjB,KAAK,kBAAkB,iBAAiBA,CAAS,EACnD,qBAAsB,IAAM,KAAK,mBACjC,wBAAyB,IAAM,KAAK,qBACtC,CAAC,EACD,MAAO,CAAE,WAAAF,EAAY,OAAAC,CAAO,CAC9B,CAEO,OAAc,CACnB,KAAK,oBAAoB,eAAa,aAAa,EACnD,KAAK,aAAa,SAAS,EAC3B,KAAK,wBAAwB,cAAc,EAC3C,KAAK,QAAQ,YAAY,CAC3B,CAEO,iBAAiBnB,EAAwB,CAC9C,OAAO,KAAK,kBAAkB,iBAAiBA,CAAE,CACnD,CAEQ,oBAAoBqB,EAAkC,CAC5D,MAAMb,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,aAAa,KAAK,CAAE,GAAGA,EAAO,aAAAa,CAAa,CAAC,CACnD,CACF",
6
6
  "names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_apduLogs", "import_DeviceSessionRefresherConst", "import_MutexService", "import_RefresherService", "import_DevicePinger", "import_DeviceSessionEventDispatcher", "import_DeviceSessionRefresher", "import_DeviceSessionStateHandler", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "secureChannelService", "deviceSessionRefresherOptions", "command", "abortTimeout", "state", "error", "rawApdu", "options", "release", "result", "response", "apdu", "err", "deviceAction", "observable", "cancel", "blockerId", "deviceStatus"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=require("../../../api/index"),n=require("../../device-session/data/DeviceSessionRefresherConst"),r=require("../../logger-publisher/service/DefaultLoggerPublisherService"),i=require("../../manager-api/data/AxiosManagerApiDataSource"),s=require("../../manager-api/service/DefaultManagerApiService"),c=require("../../secure-channel/data/DefaultSecureChannelDataSource"),t=require("../../secure-channel/service/DefaultSecureChannelService"),a=require("./DeviceSession");describe("DeviceSession",()=>{it("should unsubscribe pinger from event subscriber when session is closed",()=>{const m=new r.DefaultLoggerPublisherService([],"DeviceSession"),u=new i.AxiosManagerApiDataSource({}),p=new s.DefaultManagerApiService(u),S=new c.DefaultSecureChannelDataSource({}),f=new t.DefaultSecureChannelService(S),D=n.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,e=new a.DeviceSession({connectedDevice:(0,o.connectedDeviceStubBuilder)()},()=>m,p,f,D),l=vi.spyOn(e._pinger,"unsubscribe").mockImplementation(()=>{});e.close(),expect(l).toHaveBeenCalled()})});
2
+ //# sourceMappingURL=DeviceSession.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/internal/device-session/model/DeviceSession.test.ts"],
4
+ "sourcesContent": ["import { type DmkConfig } from \"@api/DmkConfig\";\nimport { connectedDeviceStubBuilder } from \"@api/index\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\nimport { AxiosManagerApiDataSource } from \"@internal/manager-api/data/AxiosManagerApiDataSource\";\nimport { DefaultManagerApiService } from \"@internal/manager-api/service/DefaultManagerApiService\";\nimport { DefaultSecureChannelDataSource } from \"@internal/secure-channel/data/DefaultSecureChannelDataSource\";\nimport { DefaultSecureChannelService } from \"@internal/secure-channel/service/DefaultSecureChannelService\";\n\nimport { DeviceSession } from \"./DeviceSession\";\n\ndescribe(\"DeviceSession\", () => {\n it(\"should unsubscribe pinger from event subscriber when session is closed\", () => {\n // ARRANGE\n const logger = new DefaultLoggerPublisherService([], \"DeviceSession\");\n const managerApiDataSource = new AxiosManagerApiDataSource({} as DmkConfig);\n const managerApi = new DefaultManagerApiService(managerApiDataSource);\n const secureChannelDataSource = new DefaultSecureChannelDataSource(\n {} as DmkConfig,\n );\n const secureChannel = new DefaultSecureChannelService(\n secureChannelDataSource,\n );\n const deviceSessionRefresherOptions =\n DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS;\n const deviceSession = new DeviceSession(\n { connectedDevice: connectedDeviceStubBuilder() },\n () => logger,\n managerApi,\n secureChannel,\n deviceSessionRefresherOptions,\n );\n const unsubscribe = vi\n .spyOn(deviceSession[\"_pinger\"], \"unsubscribe\")\n .mockImplementation(() => {});\n\n // ACT\n deviceSession.close();\n\n // ASSERT\n expect(unsubscribe).toHaveBeenCalled();\n });\n});\n"],
5
+ "mappings": "aACA,IAAAA,EAA2C,sBAC3CC,EAAyD,qEACzDC,EAA8C,4EAC9CC,EAA0C,gEAC1CC,EAAyC,kEACzCC,EAA+C,wEAC/CC,EAA4C,wEAE5CC,EAA8B,2BAE9B,SAAS,gBAAiB,IAAM,CAC9B,GAAG,yEAA0E,IAAM,CAEjF,MAAMC,EAAS,IAAI,gCAA8B,CAAC,EAAG,eAAe,EAC9DC,EAAuB,IAAI,4BAA0B,CAAC,CAAc,EACpEC,EAAa,IAAI,2BAAyBD,CAAoB,EAC9DE,EAA0B,IAAI,iCAClC,CAAC,CACH,EACMC,EAAgB,IAAI,8BACxBD,CACF,EACME,EACJ,2CACIC,EAAgB,IAAI,gBACxB,CAAE,mBAAiB,8BAA2B,CAAE,EAChD,IAAMN,EACNE,EACAE,EACAC,CACF,EACME,EAAc,GACjB,MAAMD,EAAc,QAAY,aAAa,EAC7C,mBAAmB,IAAM,CAAC,CAAC,EAG9BA,EAAc,MAAM,EAGpB,OAAOC,CAAW,EAAE,iBAAiB,CACvC,CAAC,CACH,CAAC",
6
+ "names": ["import_api", "import_DeviceSessionRefresherConst", "import_DefaultLoggerPublisherService", "import_AxiosManagerApiDataSource", "import_DefaultManagerApiService", "import_DefaultSecureChannelDataSource", "import_DefaultSecureChannelService", "import_DeviceSession", "logger", "managerApiDataSource", "managerApi", "secureChannelDataSource", "secureChannel", "deviceSessionRefresherOptions", "deviceSession", "unsubscribe"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(n,e)=>{for(var s in e)p(n,s,{get:e[s],enumerable:!0})},T=(n,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _(e))!A.call(n,i)&&i!==s&&p(n,i,{get:()=>e[i],enumerable:!(r=S(e,i))||r.enumerable});return n};var I=n=>T(p({},"__esModule",{value:!0}),n),g=(n,e,s,r)=>{for(var i=r>1?void 0:r?S(e,s):e,o=n.length-1,t;o>=0;o--)(t=n[o])&&(i=(r?t(e,s,i):t(i))||i);return r&&i&&p(e,s,i),i},a=(n,e)=>(s,r)=>e(s,r,n);var E={};C(E,{ConnectUseCase:()=>v});module.exports=I(E);var c=require("inversify"),m=require("purify-ts"),h=require("../../../api/transport/model/Errors"),d=require("../../device-session/di/deviceSessionTypes"),l=require("../../device-session/model/DeviceSession"),f=require("../../logger-publisher/di/loggerTypes"),D=require("../../manager-api/di/managerApiTypes"),y=require("../../secure-channel/di/secureChannelTypes"),u=require("../../transport/di/transportDiTypes");let v=class{_transportService;_sessionService;_loggerFactory;_managerApi;_secureChannel;_logger;constructor(e,s,r,i,o){this._sessionService=s,this._transportService=e,this._loggerFactory=r,this._logger=r("ConnectUseCase"),this._managerApi=i,this._secureChannel=o}handleDeviceDisconnect(e){this._sessionService.getDeviceSessionsByDeviceId(e).ifRight(s=>{s.forEach(r=>{this._sessionService.removeDeviceSession(r.id),this._logger.info("Session removed",{data:{deviceId:e,sessionId:r.id}})})})}async execute({device:e,sessionRefresherOptions:s}){const r=this._transportService.getTransport(e.transport),i="sessionId"in e?e.sessionId:void 0;return m.EitherAsync.liftEither(r.toEither(new h.TransportNotSupportedError(new Error("Unknown transport")))).chain(async o=>o.connect({deviceId:e.id,onDisconnect:t=>this.handleDeviceDisconnect(t)})).ifLeft(o=>{this._logger.error("Error connecting to device",{data:{deviceId:e.id,error:o}})}).map(async o=>{const t=new l.DeviceSession({connectedDevice:o,id:i},this._loggerFactory,this._managerApi,this._secureChannel,s);return this._sessionService.addDeviceSession(t),await t.initialiseSession(),t.id}).caseOf({Left:o=>{throw o},Right:o=>o})}};v=g([(0,c.injectable)(),a(0,(0,c.inject)(u.transportDiTypes.TransportService)),a(1,(0,c.inject)(d.deviceSessionTypes.DeviceSessionService)),a(2,(0,c.inject)(f.loggerTypes.LoggerPublisherServiceFactory)),a(3,(0,c.inject)(D.managerApiTypes.ManagerApiService)),a(4,(0,c.inject)(y.secureChannelTypes.SecureChannelService))],v);0&&(module.exports={ConnectUseCase});
1
+ "use strict";var p=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(n,e)=>{for(var s in e)p(n,s,{get:e[s],enumerable:!0})},T=(n,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _(e))!A.call(n,i)&&i!==s&&p(n,i,{get:()=>e[i],enumerable:!(r=S(e,i))||r.enumerable});return n};var I=n=>T(p({},"__esModule",{value:!0}),n),g=(n,e,s,r)=>{for(var i=r>1?void 0:r?S(e,s):e,o=n.length-1,t;o>=0;o--)(t=n[o])&&(i=(r?t(e,s,i):t(i))||i);return r&&i&&p(e,s,i),i},a=(n,e)=>(s,r)=>e(s,r,n);var E={};C(E,{ConnectUseCase:()=>v});module.exports=I(E);var c=require("inversify"),m=require("purify-ts"),h=require("../../../api/transport/model/Errors"),l=require("../../device-session/di/deviceSessionTypes"),d=require("../../device-session/model/DeviceSession"),f=require("../../logger-publisher/di/loggerTypes"),D=require("../../manager-api/di/managerApiTypes"),y=require("../../secure-channel/di/secureChannelTypes"),u=require("../../transport/di/transportDiTypes");let v=class{_transportService;_sessionService;_loggerFactory;_managerApi;_secureChannel;_logger;constructor(e,s,r,i,o){this._sessionService=s,this._transportService=e,this._loggerFactory=r,this._logger=r("ConnectUseCase"),this._managerApi=i,this._secureChannel=o}handleDeviceDisconnect(e){this._sessionService.getDeviceSessionsByDeviceId(e).ifRight(s=>{s.forEach(r=>{this._sessionService.removeDeviceSession(r.id),this._logger.info("Session removed",{data:{deviceId:e,sessionId:r.id}})})})}async execute({device:e,sessionRefresherOptions:s}){const r=this._transportService.getTransport(e.transport),i="sessionId"in e?e.sessionId:void 0;return m.EitherAsync.liftEither(r.toEither(new h.TransportNotSupportedError(new Error("Unknown transport")))).chain(async o=>o.connect({deviceId:e.id,onDisconnect:t=>this.handleDeviceDisconnect(t)})).ifLeft(o=>{this._logger.error("Error connecting to device")}).map(async o=>{const t=new d.DeviceSession({connectedDevice:o,id:i},this._loggerFactory,this._managerApi,this._secureChannel,s);return this._sessionService.addDeviceSession(t),await t.initialiseSession(),t.id}).caseOf({Left:o=>{throw o},Right:o=>o})}};v=g([(0,c.injectable)(),a(0,(0,c.inject)(u.transportDiTypes.TransportService)),a(1,(0,c.inject)(l.deviceSessionTypes.DeviceSessionService)),a(2,(0,c.inject)(f.loggerTypes.LoggerPublisherServiceFactory)),a(3,(0,c.inject)(D.managerApiTypes.ManagerApiService)),a(4,(0,c.inject)(y.secureChannelTypes.SecureChannelService))],v);0&&(module.exports={ConnectUseCase});
2
2
  //# sourceMappingURL=ConnectUseCase.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/discovery/use-case/ConnectUseCase.ts"],
4
- "sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { EitherAsync } from \"purify-ts\";\n\nimport { DeviceSessionId } from \"@api/device-session/types\";\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport { DiscoveredDevice } from \"@api/transport/model/DiscoveredDevice\";\nimport { TransportNotSupportedError } from \"@api/transport/model/Errors\";\nimport { DeviceId } from \"@api/types\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport {\n DeviceSession,\n DeviceSessionRefresherOptions,\n} from \"@internal/device-session/model/DeviceSession\";\nimport type { DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport type { ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { secureChannelTypes } from \"@internal/secure-channel/di/secureChannelTypes\";\nimport type { SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\n\n/**\n * The arguments for the ConnectUseCase.\n */\nexport type ConnectUseCaseArgs = {\n /**\n * Discovered device or connected device.\n */\n device: DiscoveredDevice | ConnectedDevice;\n\n /**\n * sessionRefresherOptions - optional\n * isRefresherDisabled - whether the refresher is disabled\n * pollingInterval - optional - the refresh interval in milliseconds\n */\n sessionRefresherOptions?: DeviceSessionRefresherOptions;\n};\n\n/**\n * Connects to a discovered device.\n */\n@injectable()\nexport class ConnectUseCase {\n private readonly _transportService: TransportService;\n private readonly _sessionService: DeviceSessionService;\n private readonly _loggerFactory: (tag: string) => LoggerPublisherService;\n private readonly _managerApi: ManagerApiService;\n private readonly _secureChannel: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n\n constructor(\n @inject(transportDiTypes.TransportService)\n transportService: TransportService,\n @inject(deviceSessionTypes.DeviceSessionService)\n sessionService: DeviceSessionService,\n @inject(loggerTypes.LoggerPublisherServiceFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n @inject(managerApiTypes.ManagerApiService)\n managerApi: ManagerApiService,\n @inject(secureChannelTypes.SecureChannelService)\n secureChannel: SecureChannelService,\n ) {\n this._sessionService = sessionService;\n this._transportService = transportService;\n this._loggerFactory = loggerFactory;\n this._logger = loggerFactory(\"ConnectUseCase\");\n this._managerApi = managerApi;\n this._secureChannel = secureChannel;\n }\n\n private handleDeviceDisconnect(deviceId: DeviceId) {\n this._sessionService\n .getDeviceSessionsByDeviceId(deviceId)\n .ifRight((deviceSessions) => {\n deviceSessions.forEach((deviceSession) => {\n this._sessionService.removeDeviceSession(deviceSession.id);\n this._logger.info(\"Session removed\", {\n data: { deviceId, sessionId: deviceSession.id },\n });\n });\n });\n }\n\n async execute({\n device,\n sessionRefresherOptions,\n }: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n const transport = this._transportService.getTransport(device.transport);\n // In case of a connected device, we reconnect using the same session id.\n // If not provided, a new device session id will be generated.\n const deviceSessionId =\n \"sessionId\" in device ? device.sessionId : undefined;\n\n return EitherAsync.liftEither(\n transport.toEither(\n new TransportNotSupportedError(new Error(\"Unknown transport\")),\n ),\n )\n .chain(async (t) => {\n return t.connect({\n deviceId: device.id,\n onDisconnect: (dId) => this.handleDeviceDisconnect(dId),\n });\n })\n .ifLeft((error) => {\n this._logger.error(\"Error connecting to device\", {\n data: { deviceId: device.id, error },\n });\n })\n .map(async (connectedDevice) => {\n const deviceSession = new DeviceSession(\n { connectedDevice, id: deviceSessionId },\n this._loggerFactory,\n this._managerApi,\n this._secureChannel,\n sessionRefresherOptions,\n );\n this._sessionService.addDeviceSession(deviceSession);\n await deviceSession.initialiseSession();\n return deviceSession.id;\n })\n .caseOf({\n Left: (error) => {\n throw error;\n },\n Right: (s) => s,\n });\n }\n}\n"],
5
- "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBACnCC,EAA4B,qBAM5BC,EAA2C,uCAE3CC,EAAmC,0DACnCC,EAGO,wDAEPC,EAA4B,qDAC5BC,EAAgC,oDAEhCC,EAAmC,0DAEnCC,EAAiC,mDAwB1B,IAAMC,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,CACN,KAAOO,GAAU,CACf,MAAMA,CACR,EACA,MAAQE,GAAMA,CAChB,CAAC,CACL,CACF,EAtFajB,EAANkB,EAAA,IADN,cAAW,EAUPC,EAAA,eAAO,mBAAiB,gBAAgB,GAExCA,EAAA,eAAO,qBAAmB,oBAAoB,GAE9CA,EAAA,eAAO,cAAY,6BAA6B,GAEhDA,EAAA,eAAO,kBAAgB,iBAAiB,GAExCA,EAAA,eAAO,qBAAmB,oBAAoB,IAjBtCnB",
6
- "names": ["ConnectUseCase_exports", "__export", "ConnectUseCase", "__toCommonJS", "import_inversify", "import_purify_ts", "import_Errors", "import_deviceSessionTypes", "import_DeviceSession", "import_loggerTypes", "import_managerApiTypes", "import_secureChannelTypes", "import_transportDiTypes", "ConnectUseCase", "transportService", "sessionService", "loggerFactory", "managerApi", "secureChannel", "deviceId", "deviceSessions", "deviceSession", "device", "sessionRefresherOptions", "transport", "deviceSessionId", "t", "dId", "error", "connectedDevice", "s", "__decorateClass", "__decorateParam"]
4
+ "sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { EitherAsync } from \"purify-ts\";\n\nimport { DeviceSessionId } from \"@api/device-session/types\";\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport { DiscoveredDevice } from \"@api/transport/model/DiscoveredDevice\";\nimport { TransportNotSupportedError } from \"@api/transport/model/Errors\";\nimport { DeviceId } from \"@api/types\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport {\n DeviceSession,\n DeviceSessionRefresherOptions,\n} from \"@internal/device-session/model/DeviceSession\";\nimport type { DeviceSessionService } from \"@internal/device-session/service/DeviceSessionService\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport type { ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { secureChannelTypes } from \"@internal/secure-channel/di/secureChannelTypes\";\nimport type { SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\n\n/**\n * The arguments for the ConnectUseCase.\n */\nexport type ConnectUseCaseArgs = {\n /**\n * Discovered device or connected device.\n */\n device: DiscoveredDevice | ConnectedDevice;\n\n /**\n * sessionRefresherOptions - optional\n * isRefresherDisabled - whether the refresher is disabled\n * pollingInterval - optional - the refresh interval in milliseconds\n */\n sessionRefresherOptions?: DeviceSessionRefresherOptions;\n};\n\n/**\n * Connects to a discovered device.\n */\n@injectable()\nexport class ConnectUseCase {\n private readonly _transportService: TransportService;\n private readonly _sessionService: DeviceSessionService;\n private readonly _loggerFactory: (tag: string) => LoggerPublisherService;\n private readonly _managerApi: ManagerApiService;\n private readonly _secureChannel: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n\n constructor(\n @inject(transportDiTypes.TransportService)\n transportService: TransportService,\n @inject(deviceSessionTypes.DeviceSessionService)\n sessionService: DeviceSessionService,\n @inject(loggerTypes.LoggerPublisherServiceFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n @inject(managerApiTypes.ManagerApiService)\n managerApi: ManagerApiService,\n @inject(secureChannelTypes.SecureChannelService)\n secureChannel: SecureChannelService,\n ) {\n this._sessionService = sessionService;\n this._transportService = transportService;\n this._loggerFactory = loggerFactory;\n this._logger = loggerFactory(\"ConnectUseCase\");\n this._managerApi = managerApi;\n this._secureChannel = secureChannel;\n }\n\n private handleDeviceDisconnect(deviceId: DeviceId) {\n this._sessionService\n .getDeviceSessionsByDeviceId(deviceId)\n .ifRight((deviceSessions) => {\n deviceSessions.forEach((deviceSession) => {\n this._sessionService.removeDeviceSession(deviceSession.id);\n this._logger.info(\"Session removed\", {\n data: { deviceId, sessionId: deviceSession.id },\n });\n });\n });\n }\n\n async execute({\n device,\n sessionRefresherOptions,\n }: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n const transport = this._transportService.getTransport(device.transport);\n // In case of a connected device, we reconnect using the same session id.\n // If not provided, a new device session id will be generated.\n const deviceSessionId =\n \"sessionId\" in device ? device.sessionId : undefined;\n\n return EitherAsync.liftEither(\n transport.toEither(\n new TransportNotSupportedError(new Error(\"Unknown transport\")),\n ),\n )\n .chain(async (t) => {\n return t.connect({\n deviceId: device.id,\n onDisconnect: (dId) => this.handleDeviceDisconnect(dId),\n });\n })\n .ifLeft((_) => {\n this._logger.error(\"Error connecting to device\");\n })\n .map(async (connectedDevice) => {\n const deviceSession = new DeviceSession(\n { connectedDevice, id: deviceSessionId },\n this._loggerFactory,\n this._managerApi,\n this._secureChannel,\n sessionRefresherOptions,\n );\n this._sessionService.addDeviceSession(deviceSession);\n await deviceSession.initialiseSession();\n return deviceSession.id;\n })\n .caseOf({\n Left: (error) => {\n throw error;\n },\n Right: (s) => s,\n });\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBACnCC,EAA4B,qBAM5BC,EAA2C,uCAE3CC,EAAmC,0DACnCC,EAGO,wDAEPC,EAA4B,qDAC5BC,EAAgC,oDAEhCC,EAAmC,0DAEnCC,EAAiC,mDAwB1B,IAAMC,EAAN,KAAqB,CACT,kBACA,gBACA,eACA,YACA,eACA,QAEjB,YAEEC,EAEAC,EAEAC,EAEAC,EAEAC,EACA,CACA,KAAK,gBAAkBH,EACvB,KAAK,kBAAoBD,EACzB,KAAK,eAAiBE,EACtB,KAAK,QAAUA,EAAc,gBAAgB,EAC7C,KAAK,YAAcC,EACnB,KAAK,eAAiBC,CACxB,CAEQ,uBAAuBC,EAAoB,CACjD,KAAK,gBACF,4BAA4BA,CAAQ,EACpC,QAASC,GAAmB,CAC3BA,EAAe,QAASC,GAAkB,CACxC,KAAK,gBAAgB,oBAAoBA,EAAc,EAAE,EACzD,KAAK,QAAQ,KAAK,kBAAmB,CACnC,KAAM,CAAE,SAAAF,EAAU,UAAWE,EAAc,EAAG,CAChD,CAAC,CACH,CAAC,CACH,CAAC,CACL,CAEA,MAAM,QAAQ,CACZ,OAAAC,EACA,wBAAAC,CACF,EAAiD,CAC/C,MAAMC,EAAY,KAAK,kBAAkB,aAAaF,EAAO,SAAS,EAGhEG,EACJ,cAAeH,EAASA,EAAO,UAAY,OAE7C,OAAO,cAAY,WACjBE,EAAU,SACR,IAAI,6BAA2B,IAAI,MAAM,mBAAmB,CAAC,CAC/D,CACF,EACG,MAAM,MAAOE,GACLA,EAAE,QAAQ,CACf,SAAUJ,EAAO,GACjB,aAAeK,GAAQ,KAAK,uBAAuBA,CAAG,CACxD,CAAC,CACF,EACA,OAAQC,GAAM,CACb,KAAK,QAAQ,MAAM,4BAA4B,CACjD,CAAC,EACA,IAAI,MAAOC,GAAoB,CAC9B,MAAMR,EAAgB,IAAI,gBACxB,CAAE,gBAAAQ,EAAiB,GAAIJ,CAAgB,EACvC,KAAK,eACL,KAAK,YACL,KAAK,eACLF,CACF,EACA,YAAK,gBAAgB,iBAAiBF,CAAa,EACnD,MAAMA,EAAc,kBAAkB,EAC/BA,EAAc,EACvB,CAAC,EACA,OAAO,CACN,KAAOS,GAAU,CACf,MAAMA,CACR,EACA,MAAQC,GAAMA,CAChB,CAAC,CACL,CACF,EApFalB,EAANmB,EAAA,IADN,cAAW,EAUPC,EAAA,eAAO,mBAAiB,gBAAgB,GAExCA,EAAA,eAAO,qBAAmB,oBAAoB,GAE9CA,EAAA,eAAO,cAAY,6BAA6B,GAEhDA,EAAA,eAAO,kBAAgB,iBAAiB,GAExCA,EAAA,eAAO,qBAAmB,oBAAoB,IAjBtCpB",
6
+ "names": ["ConnectUseCase_exports", "__export", "ConnectUseCase", "__toCommonJS", "import_inversify", "import_purify_ts", "import_Errors", "import_deviceSessionTypes", "import_DeviceSession", "import_loggerTypes", "import_managerApiTypes", "import_secureChannelTypes", "import_transportDiTypes", "ConnectUseCase", "transportService", "sessionService", "loggerFactory", "managerApi", "secureChannel", "deviceId", "deviceSessions", "deviceSession", "device", "sessionRefresherOptions", "transport", "deviceSessionId", "t", "dId", "_", "connectedDevice", "error", "s", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var l=(s,r)=>{for(var i in r)n(s,i,{get:r[i],enumerable:!0})},v=(s,r,i,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of u(r))!L.call(s,o)&&o!==i&&n(s,o,{get:()=>r[o],enumerable:!(t=c(r,o))||t.enumerable});return s};var O=s=>v(n({},"__esModule",{value:!0}),s),m=(s,r,i,t)=>{for(var o=t>1?void 0:t?c(r,i):r,g=s.length-1,p;g>=0;g--)(p=s[g])&&(o=(t?p(r,i,o):p(o))||o);return t&&o&&n(r,i,o),o};var a={};l(a,{DefaultLoggerPublisherService:()=>b});module.exports=O(a);var h=require("inversify"),e=require("../../../api/logger-subscriber/model/LogLevel");let b=class{subscribers;tag;constructor(r,i){this.subscribers=r,this.tag=i}_log(r,i,t){this.subscribers.forEach(o=>{const g={timestamp:Date.now(),tag:this.tag,...t};o.log(r,i,g)})}info(r,i){this._log(e.LogLevel.Info,r,i)}warn(r,i){this._log(e.LogLevel.Warning,r,i)}debug(r,i){this._log(e.LogLevel.Debug,r,i)}error(r,i){this._log(e.LogLevel.Error,r,i)}};b=m([(0,h.injectable)()],b);0&&(module.exports={DefaultLoggerPublisherService});
1
+ "use strict";var n=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var v=(s,r)=>{for(var t in r)n(s,t,{get:r[t],enumerable:!0})},O=(s,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of d(r))!f.call(s,o)&&o!==t&&n(s,o,{get:()=>r[o],enumerable:!(i=b(r,o))||i.enumerable});return s};var T=s=>O(n({},"__esModule",{value:!0}),s),p=(s,r,t,i)=>{for(var o=i>1?void 0:i?b(r,t):r,g=s.length-1,e;g>=0;g--)(e=s[g])&&(o=(i?e(r,t,o):e(o))||o);return i&&o&&n(r,t,o),o};var F={};v(F,{DefaultLoggerPublisherService:()=>m});module.exports=T(F);var L=require("inversify"),a=require("../../../api/logger-subscriber/model/LogLevel"),c=require("../../../api/logger-subscriber/service/DefaultLogTagFormatter"),h=require("../../logger-publisher/service/sanitiseData");let m=class{subscribers;tag;tagFormatter;constructor(r,t,i=new c.DefaultLogTagFormatter){this.subscribers=r,this.tag=t,this.tagFormatter=i}_log(r,t,i){const o=i?.data?(0,h.sanitiseData)(i.data):void 0,g=i?.tag??this.tag,e=this.tagFormatter.format(g);this.subscribers.forEach(u=>{const l={timestamp:i?.timestamp??Date.now(),tag:e,data:o};u.log(r,t,l)})}info(r,t){this._log(a.LogLevel.Info,r,t)}warn(r,t){this._log(a.LogLevel.Warning,r,t)}debug(r,t){this._log(a.LogLevel.Debug,r,t)}error(r,t){this._log(a.LogLevel.Error,r,t)}};m=p([(0,L.injectable)()],m);0&&(module.exports={DefaultLoggerPublisherService});
2
2
  //# sourceMappingURL=DefaultLoggerPublisherService.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/logger-publisher/service/DefaultLoggerPublisherService.ts"],
4
- "sourcesContent": ["import { injectable } from \"inversify\";\n\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { LogSubscriberOptions } from \"@api/logger-subscriber/model/LogSubscriberOptions\";\nimport { LoggerSubscriberService } from \"@api/logger-subscriber/service/LoggerSubscriberService\";\nimport { LogPublisherOptions } from \"@internal/logger-publisher/model/LogPublisherOptions\";\n\n@injectable()\nexport class DefaultLoggerPublisherService implements LoggerPublisherService {\n subscribers: LoggerSubscriberService[];\n tag: string;\n\n constructor(subscribers: LoggerSubscriberService[], tag: string) {\n this.subscribers = subscribers;\n this.tag = tag;\n }\n\n _log(level: LogLevel, message: string, options?: LogPublisherOptions): void {\n this.subscribers.forEach((subscriber) => {\n const subscriberOptions: LogSubscriberOptions = {\n timestamp: Date.now(),\n tag: this.tag,\n ...options,\n };\n subscriber.log(level, message, subscriberOptions);\n });\n }\n\n info(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Info, message, options);\n }\n\n warn(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Warning, message, options);\n }\n\n debug(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Debug, message, options);\n }\n\n error(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Error, message, options);\n }\n}\n"],
5
- "mappings": "2iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2B,qBAG3BC,EAAyB,iDAMlB,IAAMC,EAAN,KAAsE,CAC3E,YACA,IAEA,YAAYC,EAAwCC,EAAa,CAC/D,KAAK,YAAcD,EACnB,KAAK,IAAMC,CACb,CAEA,KAAKC,EAAiBC,EAAiBC,EAAqC,CAC1E,KAAK,YAAY,QAASC,GAAe,CACvC,MAAMC,EAA0C,CAC9C,UAAW,KAAK,IAAI,EACpB,IAAK,KAAK,IACV,GAAGF,CACL,EACAC,EAAW,IAAIH,EAAOC,EAASG,CAAiB,CAClD,CAAC,CACH,CAEA,KAAKH,EAAiBC,EAAqC,CACzD,KAAK,KAAK,WAAS,KAAMD,EAASC,CAAO,CAC3C,CAEA,KAAKD,EAAiBC,EAAqC,CACzD,KAAK,KAAK,WAAS,QAASD,EAASC,CAAO,CAC9C,CAEA,MAAMD,EAAiBC,EAAqC,CAC1D,KAAK,KAAK,WAAS,MAAOD,EAASC,CAAO,CAC5C,CAEA,MAAMD,EAAiBC,EAAqC,CAC1D,KAAK,KAAK,WAAS,MAAOD,EAASC,CAAO,CAC5C,CACF,EAnCaL,EAANQ,EAAA,IADN,cAAW,GACCR",
6
- "names": ["DefaultLoggerPublisherService_exports", "__export", "DefaultLoggerPublisherService", "__toCommonJS", "import_inversify", "import_LogLevel", "DefaultLoggerPublisherService", "subscribers", "tag", "level", "message", "options", "subscriber", "subscriberOptions", "__decorateClass"]
4
+ "sourcesContent": ["import { injectable } from \"inversify\";\n\nimport { LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport {\n type LogSubscriberOptions,\n type LogTag,\n} from \"@api/logger-subscriber/model/LogSubscriberOptions\";\nimport { DefaultLogTagFormatter } from \"@api/logger-subscriber/service/DefaultLogTagFormatter\";\nimport { LoggerSubscriberService } from \"@api/logger-subscriber/service/LoggerSubscriberService\";\nimport { type LogTagFormatter } from \"@api/logger-subscriber/service/LogTagFormatter\";\nimport { LogPublisherOptions } from \"@internal/logger-publisher/model/LogPublisherOptions\";\nimport { sanitiseData } from \"@internal/logger-publisher/service/sanitiseData\";\n\n@injectable()\nexport class DefaultLoggerPublisherService implements LoggerPublisherService {\n subscribers: LoggerSubscriberService[];\n tag: LogTag;\n private readonly tagFormatter: LogTagFormatter;\n\n constructor(\n subscribers: LoggerSubscriberService[],\n tag: LogTag,\n tagFormatter: LogTagFormatter = new DefaultLogTagFormatter(),\n ) {\n this.subscribers = subscribers;\n this.tag = tag;\n this.tagFormatter = tagFormatter;\n }\n\n _log(level: LogLevel, message: string, options?: LogPublisherOptions): void {\n const sanitisedData = options?.data\n ? sanitiseData(options.data)\n : undefined;\n\n // Format the tag from options if provided, otherwise use the instance tag\n const tagToFormat = options?.tag ?? this.tag;\n const formattedTag = this.tagFormatter.format(tagToFormat);\n\n this.subscribers.forEach((subscriber) => {\n const subscriberOptions: LogSubscriberOptions = {\n timestamp: options?.timestamp ?? Date.now(),\n tag: formattedTag,\n data: sanitisedData,\n };\n subscriber.log(level, message, subscriberOptions);\n });\n }\n\n info(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Info, message, options);\n }\n\n warn(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Warning, message, options);\n }\n\n debug(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Debug, message, options);\n }\n\n error(message: string, options?: LogPublisherOptions): void {\n this._log(LogLevel.Error, message, options);\n }\n}\n"],
5
+ "mappings": "2iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2B,qBAG3BC,EAAyB,iDAKzBC,EAAuC,iEAIvCC,EAA6B,2DAGtB,IAAMC,EAAN,KAAsE,CAC3E,YACA,IACiB,aAEjB,YACEC,EACAC,EACAC,EAAgC,IAAI,yBACpC,CACA,KAAK,YAAcF,EACnB,KAAK,IAAMC,EACX,KAAK,aAAeC,CACtB,CAEA,KAAKC,EAAiBC,EAAiBC,EAAqC,CAC1E,MAAMC,EAAgBD,GAAS,QAC3B,gBAAaA,EAAQ,IAAI,EACzB,OAGEE,EAAcF,GAAS,KAAO,KAAK,IACnCG,EAAe,KAAK,aAAa,OAAOD,CAAW,EAEzD,KAAK,YAAY,QAASE,GAAe,CACvC,MAAMC,EAA0C,CAC9C,UAAWL,GAAS,WAAa,KAAK,IAAI,EAC1C,IAAKG,EACL,KAAMF,CACR,EACAG,EAAW,IAAIN,EAAOC,EAASM,CAAiB,CAClD,CAAC,CACH,CAEA,KAAKN,EAAiBC,EAAqC,CACzD,KAAK,KAAK,WAAS,KAAMD,EAASC,CAAO,CAC3C,CAEA,KAAKD,EAAiBC,EAAqC,CACzD,KAAK,KAAK,WAAS,QAASD,EAASC,CAAO,CAC9C,CAEA,MAAMD,EAAiBC,EAAqC,CAC1D,KAAK,KAAK,WAAS,MAAOD,EAASC,CAAO,CAC5C,CAEA,MAAMD,EAAiBC,EAAqC,CAC1D,KAAK,KAAK,WAAS,MAAOD,EAASC,CAAO,CAC5C,CACF,EAjDaN,EAANY,EAAA,IADN,cAAW,GACCZ",
6
+ "names": ["DefaultLoggerPublisherService_exports", "__export", "DefaultLoggerPublisherService", "__toCommonJS", "import_inversify", "import_LogLevel", "import_DefaultLogTagFormatter", "import_sanitiseData", "DefaultLoggerPublisherService", "subscribers", "tag", "tagFormatter", "level", "message", "options", "sanitisedData", "tagToFormat", "formattedTag", "subscriber", "subscriberOptions", "__decorateClass"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=require("../../../api/logger-subscriber/model/LogLevel"),n=require("../../../api/logger-subscriber/service/ConsoleLogger"),c=require("./DefaultLoggerPublisherService");vi.mock("@api/logger-subscriber/service/ConsoleLogger");vi.useFakeTimers().setSystemTime(new Date("2024-01-01"));let o,s;const e="message",a="logger-tag",t={data:{key:"value"}},r={tag:a,timestamp:Date.now(),...t};describe("LoggerPublisherService",()=>{beforeEach(()=>{vi.clearAllMocks(),s=new n.ConsoleLogger,o=new c.DefaultLoggerPublisherService([s],a)}),it("should call subscriber.log with the correct log object",()=>{o.info(e,t),expect(s.log).toHaveBeenCalledWith(l.LogLevel.Info,e,r)}),it("should call subscriber.log with the correct log object when a tag is provided",()=>{const i="new-tag";o.info(e,{...t,tag:i}),expect(s.log).toHaveBeenCalledWith(l.LogLevel.Info,e,{...r,tag:i})}),it("should call subscriber.log with the correct log object when a timestamp is provided",()=>{o.info(e,{...t,timestamp:1}),expect(s.log).toHaveBeenCalledWith(l.LogLevel.Info,e,{...r,timestamp:1})}),it("should call _log with the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.info(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Info,e,t)}),it("should have the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.debug(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Debug,e,t)}),it("should have the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.warn(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Warning,e,t)}),it("should have the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.error(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Error,e,t)})});
1
+ "use strict";var l=require("../../../api/logger-subscriber/model/LogLevel"),r=require("../../../api/logger-subscriber/service/ConsoleLogger"),a=require("./DefaultLoggerPublisherService");vi.mock("@api/logger-subscriber/service/ConsoleLogger");vi.useFakeTimers().setSystemTime(new Date("2024-01-01"));let o,s;const e="message",c="logger-tag",g=`[${c}]`,t={data:{key:"value"}},n={tag:g,timestamp:Date.now(),...t};describe("LoggerPublisherService",()=>{beforeEach(()=>{vi.clearAllMocks(),s=new r.ConsoleLogger,o=new a.DefaultLoggerPublisherService([s],c)}),it("should call subscriber.log with the correct log object",()=>{o.info(e,t),expect(s.log).toHaveBeenCalledWith(l.LogLevel.Info,e,n)}),it("should call subscriber.log with the correct log object when a tag is provided in options",()=>{const i="new-tag";o.info(e,{...t,tag:i}),expect(s.log).toHaveBeenCalledWith(l.LogLevel.Info,e,{...n,tag:`[${i}]`})}),it("should call subscriber.log with the correct log object when a timestamp is provided",()=>{o.info(e,{...t,timestamp:1}),expect(s.log).toHaveBeenCalledWith(l.LogLevel.Info,e,{...n,timestamp:1})}),it("should call _log with the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.info(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Info,e,t)}),it("should have the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.debug(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Debug,e,t)}),it("should have the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.warn(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Warning,e,t)}),it("should have the correct LogLevel",()=>{const i=vi.spyOn(o,"_log").mockImplementation(vi.fn());o.error(e,t),expect(i).toHaveBeenCalledWith(l.LogLevel.Error,e,t)})});
2
2
  //# sourceMappingURL=DefaultLoggerPublisherService.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.ts"],
4
- "sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\n\nimport { DefaultLoggerPublisherService } from \"./DefaultLoggerPublisherService\";\n\nvi.mock(\"@api/logger-subscriber/service/ConsoleLogger\");\nvi.useFakeTimers().setSystemTime(new Date(\"2024-01-01\"));\n\nlet service: DefaultLoggerPublisherService;\nlet subscriber: Mocked<ConsoleLogger>;\nconst message = \"message\";\nconst tag = \"logger-tag\";\nconst options = { data: { key: \"value\" } };\nconst generatedOptions = { tag, timestamp: Date.now(), ...options };\n\ndescribe(\"LoggerPublisherService\", () => {\n beforeEach(() => {\n vi.clearAllMocks();\n subscriber = new ConsoleLogger() as Mocked<ConsoleLogger>;\n service = new DefaultLoggerPublisherService([subscriber], tag);\n });\n\n it(\"should call subscriber.log with the correct log object\", () => {\n service.info(message, options);\n expect(subscriber.log).toHaveBeenCalledWith(\n LogLevel.Info,\n message,\n generatedOptions,\n );\n });\n\n it(\"should call subscriber.log with the correct log object when a tag is provided\", () => {\n const newTag = \"new-tag\";\n service.info(message, { ...options, tag: newTag });\n expect(subscriber.log).toHaveBeenCalledWith(LogLevel.Info, message, {\n ...generatedOptions,\n tag: newTag,\n });\n });\n\n it(\"should call subscriber.log with the correct log object when a timestamp is provided\", () => {\n const newTimestamp = 1;\n service.info(message, { ...options, timestamp: newTimestamp });\n expect(subscriber.log).toHaveBeenCalledWith(LogLevel.Info, message, {\n ...generatedOptions,\n timestamp: newTimestamp,\n });\n });\n\n it(\"should call _log with the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.info(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Info, message, options);\n });\n\n it(\"should have the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.debug(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Debug, message, options);\n });\n\n it(\"should have the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.warn(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Warning, message, options);\n });\n\n it(\"should have the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.error(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Error, message, options);\n });\n});\n"],
5
- "mappings": "aAEA,IAAAA,EAAyB,iDACzBC,EAA8B,wDAE9BC,EAA8C,2CAE9C,GAAG,KAAK,8CAA8C,EACtD,GAAG,cAAc,EAAE,cAAc,IAAI,KAAK,YAAY,CAAC,EAEvD,IAAIC,EACAC,EACJ,MAAMC,EAAU,UACVC,EAAM,aACNC,EAAU,CAAE,KAAM,CAAE,IAAK,OAAQ,CAAE,EACnCC,EAAmB,CAAE,IAAAF,EAAK,UAAW,KAAK,IAAI,EAAG,GAAGC,CAAQ,EAElE,SAAS,yBAA0B,IAAM,CACvC,WAAW,IAAM,CACf,GAAG,cAAc,EACjBH,EAAa,IAAI,gBACjBD,EAAU,IAAI,gCAA8B,CAACC,CAAU,EAAGE,CAAG,CAC/D,CAAC,EAED,GAAG,yDAA0D,IAAM,CACjEH,EAAQ,KAAKE,EAASE,CAAO,EAC7B,OAAOH,EAAW,GAAG,EAAE,qBACrB,WAAS,KACTC,EACAG,CACF,CACF,CAAC,EAED,GAAG,gFAAiF,IAAM,CACxF,MAAMC,EAAS,UACfN,EAAQ,KAAKE,EAAS,CAAE,GAAGE,EAAS,IAAKE,CAAO,CAAC,EACjD,OAAOL,EAAW,GAAG,EAAE,qBAAqB,WAAS,KAAMC,EAAS,CAClE,GAAGG,EACH,IAAKC,CACP,CAAC,CACH,CAAC,EAED,GAAG,sFAAuF,IAAM,CAE9FN,EAAQ,KAAKE,EAAS,CAAE,GAAGE,EAAS,UAAW,CAAa,CAAC,EAC7D,OAAOH,EAAW,GAAG,EAAE,qBAAqB,WAAS,KAAMC,EAAS,CAClE,GAAGG,EACH,UAAW,CACb,CAAC,CACH,CAAC,EAED,GAAG,6CAA8C,IAAM,CACrD,MAAME,EAAM,GAAG,MAAMP,EAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAEhEA,EAAQ,KAAKE,EAASE,CAAO,EAC7B,OAAOG,CAAG,EAAE,qBAAqB,WAAS,KAAML,EAASE,CAAO,CAClE,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,MAAMG,EAAM,GAAG,MAAMP,EAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAEhEA,EAAQ,MAAME,EAASE,CAAO,EAC9B,OAAOG,CAAG,EAAE,qBAAqB,WAAS,MAAOL,EAASE,CAAO,CACnE,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,MAAMG,EAAM,GAAG,MAAMP,EAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAEhEA,EAAQ,KAAKE,EAASE,CAAO,EAC7B,OAAOG,CAAG,EAAE,qBAAqB,WAAS,QAASL,EAASE,CAAO,CACrE,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,MAAMG,EAAM,GAAG,MAAMP,EAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAEhEA,EAAQ,MAAME,EAASE,CAAO,EAC9B,OAAOG,CAAG,EAAE,qBAAqB,WAAS,MAAOL,EAASE,CAAO,CACnE,CAAC,CACH,CAAC",
6
- "names": ["import_LogLevel", "import_ConsoleLogger", "import_DefaultLoggerPublisherService", "service", "subscriber", "message", "tag", "options", "generatedOptions", "newTag", "spy"]
4
+ "sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\n\nimport { DefaultLoggerPublisherService } from \"./DefaultLoggerPublisherService\";\n\nvi.mock(\"@api/logger-subscriber/service/ConsoleLogger\");\nvi.useFakeTimers().setSystemTime(new Date(\"2024-01-01\"));\n\nlet service: DefaultLoggerPublisherService;\nlet subscriber: Mocked<ConsoleLogger>;\nconst message = \"message\";\nconst tag = \"logger-tag\";\nconst formattedTag = `[${tag}]`;\nconst options = { data: { key: \"value\" } };\nconst generatedOptions = {\n tag: formattedTag,\n timestamp: Date.now(),\n ...options,\n};\n\ndescribe(\"LoggerPublisherService\", () => {\n beforeEach(() => {\n vi.clearAllMocks();\n subscriber = new ConsoleLogger() as Mocked<ConsoleLogger>;\n service = new DefaultLoggerPublisherService([subscriber], tag);\n });\n\n it(\"should call subscriber.log with the correct log object\", () => {\n service.info(message, options);\n expect(subscriber.log).toHaveBeenCalledWith(\n LogLevel.Info,\n message,\n generatedOptions,\n );\n });\n\n it(\"should call subscriber.log with the correct log object when a tag is provided in options\", () => {\n const newTag = \"new-tag\";\n service.info(message, { ...options, tag: newTag });\n // Note: options.tag overrides and is formatted\n expect(subscriber.log).toHaveBeenCalledWith(LogLevel.Info, message, {\n ...generatedOptions,\n tag: `[${newTag}]`,\n });\n });\n\n it(\"should call subscriber.log with the correct log object when a timestamp is provided\", () => {\n const newTimestamp = 1;\n service.info(message, { ...options, timestamp: newTimestamp });\n expect(subscriber.log).toHaveBeenCalledWith(LogLevel.Info, message, {\n ...generatedOptions,\n timestamp: newTimestamp,\n });\n });\n\n it(\"should call _log with the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.info(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Info, message, options);\n });\n\n it(\"should have the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.debug(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Debug, message, options);\n });\n\n it(\"should have the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.warn(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Warning, message, options);\n });\n\n it(\"should have the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.error(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Error, message, options);\n });\n});\n"],
5
+ "mappings": "aAEA,IAAAA,EAAyB,iDACzBC,EAA8B,wDAE9BC,EAA8C,2CAE9C,GAAG,KAAK,8CAA8C,EACtD,GAAG,cAAc,EAAE,cAAc,IAAI,KAAK,YAAY,CAAC,EAEvD,IAAIC,EACAC,EACJ,MAAMC,EAAU,UACVC,EAAM,aACNC,EAAe,IAAID,CAAG,IACtBE,EAAU,CAAE,KAAM,CAAE,IAAK,OAAQ,CAAE,EACnCC,EAAmB,CACvB,IAAKF,EACL,UAAW,KAAK,IAAI,EACpB,GAAGC,CACL,EAEA,SAAS,yBAA0B,IAAM,CACvC,WAAW,IAAM,CACf,GAAG,cAAc,EACjBJ,EAAa,IAAI,gBACjBD,EAAU,IAAI,gCAA8B,CAACC,CAAU,EAAGE,CAAG,CAC/D,CAAC,EAED,GAAG,yDAA0D,IAAM,CACjEH,EAAQ,KAAKE,EAASG,CAAO,EAC7B,OAAOJ,EAAW,GAAG,EAAE,qBACrB,WAAS,KACTC,EACAI,CACF,CACF,CAAC,EAED,GAAG,2FAA4F,IAAM,CACnG,MAAMC,EAAS,UACfP,EAAQ,KAAKE,EAAS,CAAE,GAAGG,EAAS,IAAKE,CAAO,CAAC,EAEjD,OAAON,EAAW,GAAG,EAAE,qBAAqB,WAAS,KAAMC,EAAS,CAClE,GAAGI,EACH,IAAK,IAAIC,CAAM,GACjB,CAAC,CACH,CAAC,EAED,GAAG,sFAAuF,IAAM,CAE9FP,EAAQ,KAAKE,EAAS,CAAE,GAAGG,EAAS,UAAW,CAAa,CAAC,EAC7D,OAAOJ,EAAW,GAAG,EAAE,qBAAqB,WAAS,KAAMC,EAAS,CAClE,GAAGI,EACH,UAAW,CACb,CAAC,CACH,CAAC,EAED,GAAG,6CAA8C,IAAM,CACrD,MAAME,EAAM,GAAG,MAAMR,EAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAEhEA,EAAQ,KAAKE,EAASG,CAAO,EAC7B,OAAOG,CAAG,EAAE,qBAAqB,WAAS,KAAMN,EAASG,CAAO,CAClE,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,MAAMG,EAAM,GAAG,MAAMR,EAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAEhEA,EAAQ,MAAME,EAASG,CAAO,EAC9B,OAAOG,CAAG,EAAE,qBAAqB,WAAS,MAAON,EAASG,CAAO,CACnE,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,MAAMG,EAAM,GAAG,MAAMR,EAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAEhEA,EAAQ,KAAKE,EAASG,CAAO,EAC7B,OAAOG,CAAG,EAAE,qBAAqB,WAAS,QAASN,EAASG,CAAO,CACrE,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,MAAMG,EAAM,GAAG,MAAMR,EAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAEhEA,EAAQ,MAAME,EAASG,CAAO,EAC9B,OAAOG,CAAG,EAAE,qBAAqB,WAAS,MAAON,EAASG,CAAO,CACnE,CAAC,CACH,CAAC",
6
+ "names": ["import_LogLevel", "import_ConsoleLogger", "import_DefaultLoggerPublisherService", "service", "subscriber", "message", "tag", "formattedTag", "options", "generatedOptions", "newTag", "spy"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var c=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var k=(n,r)=>{for(var t in r)c(n,t,{get:r[t],enumerable:!0})},u=(n,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of f(r))!d.call(n,o)&&o!==t&&c(n,o,{get:()=>r[o],enumerable:!(i=s(r,o))||i.enumerable});return n};var a=n=>u(c({},"__esModule",{value:!0}),n);var b={};k(b,{sanitiseData:()=>w});module.exports=a(b);function e(n,r){if(typeof n=="bigint")return n.toString();if(Array.isArray(n))return r.has(n)?"[Circular]":(r.add(n),n.map(t=>e(t,r)));if(n!==null&&typeof n=="object"){if(r.has(n))return"[Circular]";r.add(n);const t={};for(const[i,o]of Object.entries(n))t[i]=e(o,r);return t}return n}function w(n){const r=new WeakSet;r.add(n);const t={};for(const[i,o]of Object.entries(n))t[i]=e(o,r);return t}0&&(module.exports={sanitiseData});
2
+ //# sourceMappingURL=sanitiseData.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/internal/logger-publisher/service/sanitiseData.ts"],
4
+ "sourcesContent": ["function sanitiseValue(value: unknown, seen: WeakSet<object>): unknown {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return \"[Circular]\";\n }\n seen.add(value);\n return value.map((v) => sanitiseValue(v, seen));\n }\n if (value !== null && typeof value === \"object\") {\n if (seen.has(value)) {\n return \"[Circular]\";\n }\n seen.add(value);\n const sanitised: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n sanitised[key] = sanitiseValue(val, seen);\n }\n return sanitised;\n }\n return value;\n}\n\n/**\n * Recursively sanitises data for JSON serialisation by converting BigInt values\n * to strings and handling circular references.\n */\nexport function sanitiseData(\n data: Record<string, unknown>,\n): Record<string, unknown> {\n const seen = new WeakSet<object>();\n seen.add(data);\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(data)) {\n result[key] = sanitiseValue(value, seen);\n }\n return result;\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAAA,SAASI,EAAcC,EAAgBC,EAAgC,CACrE,GAAI,OAAOD,GAAU,SACnB,OAAOA,EAAM,SAAS,EAExB,GAAI,MAAM,QAAQA,CAAK,EACrB,OAAIC,EAAK,IAAID,CAAK,EACT,cAETC,EAAK,IAAID,CAAK,EACPA,EAAM,IAAKE,GAAMH,EAAcG,EAAGD,CAAI,CAAC,GAEhD,GAAID,IAAU,MAAQ,OAAOA,GAAU,SAAU,CAC/C,GAAIC,EAAK,IAAID,CAAK,EAChB,MAAO,aAETC,EAAK,IAAID,CAAK,EACd,MAAMG,EAAqC,CAAC,EAC5C,SAAW,CAACC,EAAKC,CAAG,IAAK,OAAO,QAAQL,CAAK,EAC3CG,EAAUC,CAAG,EAAIL,EAAcM,EAAKJ,CAAI,EAE1C,OAAOE,CACT,CACA,OAAOH,CACT,CAMO,SAASH,EACdS,EACyB,CACzB,MAAML,EAAO,IAAI,QACjBA,EAAK,IAAIK,CAAI,EACb,MAAMC,EAAkC,CAAC,EACzC,SAAW,CAACH,EAAKJ,CAAK,IAAK,OAAO,QAAQM,CAAI,EAC5CC,EAAOH,CAAG,EAAIL,EAAcC,EAAOC,CAAI,EAEzC,OAAOM,CACT",
6
+ "names": ["sanitiseData_exports", "__export", "sanitiseData", "__toCommonJS", "sanitiseValue", "value", "seen", "v", "sanitised", "key", "val", "data", "result"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var t=require("vitest"),s=require("./sanitiseData");(0,t.describe)("sanitiseData",()=>{(0,t.it)("should convert BigInt values to strings",()=>{const e=(0,s.sanitiseData)({value:123456789012345678901234567890n});(0,t.expect)(e).toEqual({value:"123456789012345678901234567890"}),(0,t.expect)(typeof e.value).toBe("string")}),(0,t.it)("should handle primitive values unchanged",()=>{const e=(0,s.sanitiseData)({str:"hello",num:42,bool:!0,nil:null,undef:void 0});(0,t.expect)(e).toEqual({str:"hello",num:42,bool:!0,nil:null,undef:void 0})}),(0,t.it)("should recursively sanitise arrays",()=>{const n={items:[BigInt(1),"text",BigInt(2)]},e=(0,s.sanitiseData)(n);(0,t.expect)(e).toEqual({items:["1","text","2"]})}),(0,t.it)("should recursively sanitise nested arrays",()=>{const n={nested:[[BigInt(1)],[BigInt(2),[BigInt(3)]]]},e=(0,s.sanitiseData)(n);(0,t.expect)(e).toEqual({nested:[["1"],["2",["3"]]]})}),(0,t.it)("should recursively sanitise objects",()=>{const e=(0,s.sanitiseData)({amount:1000000000000000000n,name:"test",count:5});(0,t.expect)(e).toEqual({amount:"1000000000000000000",name:"test",count:5})}),(0,t.it)("should recursively sanitise nested objects",()=>{const e=(0,s.sanitiseData)({transaction:{value:100n,gasLimit:21000n,nested:{maxFeePerGas:50000000000n}},metadata:"info"});(0,t.expect)(e).toEqual({transaction:{value:"100",gasLimit:"21000",nested:{maxFeePerGas:"50000000000"}},metadata:"info"})}),(0,t.it)("should handle mixed arrays and objects",()=>{const e=(0,s.sanitiseData)({items:[{value:1n},{value:2n}],total:3n});(0,t.expect)(e).toEqual({items:[{value:"1"},{value:"2"}],total:"3"})}),(0,t.it)("should handle empty objects and arrays",()=>{(0,t.expect)((0,s.sanitiseData)({})).toEqual({}),(0,t.expect)((0,s.sanitiseData)({arr:[]})).toEqual({arr:[]})}),(0,t.it)("should produce JSON-serialisable output",()=>{const e=(0,s.sanitiseData)({bigValue:9007199254740991n,nested:{anotherBig:123n}});(0,t.expect)(()=>JSON.stringify(e)).not.toThrow(),(0,t.expect)(JSON.stringify(e)).toBe('{"bigValue":"9007199254740991","nested":{"anotherBig":"123"}}')}),(0,t.it)("should handle circular reference in object",()=>{const n={name:"test"};n.self=n;const e=(0,s.sanitiseData)(n);(0,t.expect)(e).toEqual({name:"test",self:"[Circular]"}),(0,t.expect)(()=>JSON.stringify(e)).not.toThrow()}),(0,t.it)("should handle circular reference in nested object",()=>{const n={level1:{level2:{}}};n.level1.level2=n;const e=(0,s.sanitiseData)(n);(0,t.expect)(e).toEqual({level1:{level2:"[Circular]"}})}),(0,t.it)("should handle circular reference in array",()=>{const n=[1,2];n.push(n);const u=(0,s.sanitiseData)({items:n});(0,t.expect)(u).toEqual({items:[1,2,"[Circular]"]})}),(0,t.it)("should handle same object referenced multiple times (not circular)",()=>{const n={value:42n},u=(0,s.sanitiseData)({a:n,b:n});(0,t.expect)(u).toEqual({a:{value:"42"},b:"[Circular]"})}),(0,t.it)("should handle deeply nested circular reference",()=>{const n={a:{b:{c:{d:{}}}}};n.a.b.c=n;const e=(0,s.sanitiseData)(n);(0,t.expect)(e).toEqual({a:{b:{c:"[Circular]"}}}),(0,t.expect)(()=>JSON.stringify(e)).not.toThrow()})});
2
+ //# sourceMappingURL=sanitiseData.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/internal/logger-publisher/service/sanitiseData.test.ts"],
4
+ "sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport { sanitiseData } from \"./sanitiseData\";\n\ndescribe(\"sanitiseData\", () => {\n it(\"should convert BigInt values to strings\", () => {\n const input = { value: BigInt(123456789012345678901234567890n) };\n const result = sanitiseData(input);\n expect(result).toEqual({ value: \"123456789012345678901234567890\" });\n expect(typeof result[\"value\"]).toBe(\"string\");\n });\n\n it(\"should handle primitive values unchanged\", () => {\n const input = {\n str: \"hello\",\n num: 42,\n bool: true,\n nil: null,\n undef: undefined,\n };\n const result = sanitiseData(input);\n expect(result).toEqual({\n str: \"hello\",\n num: 42,\n bool: true,\n nil: null,\n undef: undefined,\n });\n });\n\n it(\"should recursively sanitise arrays\", () => {\n const input = { items: [BigInt(1), \"text\", BigInt(2)] };\n const result = sanitiseData(input);\n expect(result).toEqual({ items: [\"1\", \"text\", \"2\"] });\n });\n\n it(\"should recursively sanitise nested arrays\", () => {\n const input = { nested: [[BigInt(1)], [BigInt(2), [BigInt(3)]]] };\n const result = sanitiseData(input);\n expect(result).toEqual({ nested: [[\"1\"], [\"2\", [\"3\"]]] });\n });\n\n it(\"should recursively sanitise objects\", () => {\n const input = {\n amount: BigInt(1000000000000000000n),\n name: \"test\",\n count: 5,\n };\n const result = sanitiseData(input);\n expect(result).toEqual({\n amount: \"1000000000000000000\",\n name: \"test\",\n count: 5,\n });\n });\n\n it(\"should recursively sanitise nested objects\", () => {\n const input = {\n transaction: {\n value: BigInt(100n),\n gasLimit: BigInt(21000n),\n nested: {\n maxFeePerGas: BigInt(50000000000n),\n },\n },\n metadata: \"info\",\n };\n const result = sanitiseData(input);\n expect(result).toEqual({\n transaction: {\n value: \"100\",\n gasLimit: \"21000\",\n nested: {\n maxFeePerGas: \"50000000000\",\n },\n },\n metadata: \"info\",\n });\n });\n\n it(\"should handle mixed arrays and objects\", () => {\n const input = {\n items: [{ value: BigInt(1n) }, { value: BigInt(2n) }],\n total: BigInt(3n),\n };\n const result = sanitiseData(input);\n expect(result).toEqual({\n items: [{ value: \"1\" }, { value: \"2\" }],\n total: \"3\",\n });\n });\n\n it(\"should handle empty objects and arrays\", () => {\n expect(sanitiseData({})).toEqual({});\n expect(sanitiseData({ arr: [] })).toEqual({ arr: [] });\n });\n\n it(\"should produce JSON-serialisable output\", () => {\n const input = {\n bigValue: BigInt(9007199254740991n),\n nested: {\n anotherBig: BigInt(123n),\n },\n };\n const result = sanitiseData(input);\n expect(() => JSON.stringify(result)).not.toThrow();\n expect(JSON.stringify(result)).toBe(\n '{\"bigValue\":\"9007199254740991\",\"nested\":{\"anotherBig\":\"123\"}}',\n );\n });\n\n it(\"should handle circular reference in object\", () => {\n const input: Record<string, unknown> = { name: \"test\" };\n input[\"self\"] = input;\n const result = sanitiseData(input);\n expect(result).toEqual({ name: \"test\", self: \"[Circular]\" });\n expect(() => JSON.stringify(result)).not.toThrow();\n });\n\n it(\"should handle circular reference in nested object\", () => {\n const input: Record<string, unknown> = {\n level1: {\n level2: {},\n },\n };\n (input[\"level1\"] as Record<string, unknown>)[\"level2\"] = input;\n const result = sanitiseData(input);\n expect(result).toEqual({\n level1: {\n level2: \"[Circular]\",\n },\n });\n });\n\n it(\"should handle circular reference in array\", () => {\n const arr: unknown[] = [1, 2];\n arr.push(arr);\n const input = { items: arr };\n const result = sanitiseData(input);\n expect(result).toEqual({ items: [1, 2, \"[Circular]\"] });\n });\n\n it(\"should handle same object referenced multiple times (not circular)\", () => {\n const shared = { value: BigInt(42n) };\n const input = { a: shared, b: shared };\n const result = sanitiseData(input);\n // Second reference to same object is detected as circular\n expect(result).toEqual({ a: { value: \"42\" }, b: \"[Circular]\" });\n });\n\n it(\"should handle deeply nested circular reference\", () => {\n const input: Record<string, unknown> = {\n a: {\n b: {\n c: {\n d: {},\n },\n },\n },\n };\n ((input[\"a\"] as Record<string, unknown>)[\"b\"] as Record<string, unknown>)[\n \"c\"\n ] = input;\n const result = sanitiseData(input);\n expect(result).toEqual({\n a: {\n b: {\n c: \"[Circular]\",\n },\n },\n });\n expect(() => JSON.stringify(result)).not.toThrow();\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAqC,kBAErCC,EAA6B,6BAE7B,YAAS,eAAgB,IAAM,IAC7B,MAAG,0CAA2C,IAAM,CAElD,MAAMC,KAAS,gBADD,CAAE,MAAc,+BAAiC,CAC9B,KACjC,UAAOA,CAAM,EAAE,QAAQ,CAAE,MAAO,gCAAiC,CAAC,KAClE,UAAO,OAAOA,EAAO,KAAQ,EAAE,KAAK,QAAQ,CAC9C,CAAC,KAED,MAAG,2CAA4C,IAAM,CAQnD,MAAMA,KAAS,gBAPD,CACZ,IAAK,QACL,IAAK,GACL,KAAM,GACN,IAAK,KACL,MAAO,MACT,CACiC,KACjC,UAAOA,CAAM,EAAE,QAAQ,CACrB,IAAK,QACL,IAAK,GACL,KAAM,GACN,IAAK,KACL,MAAO,MACT,CAAC,CACH,CAAC,KAED,MAAG,qCAAsC,IAAM,CAC7C,MAAMC,EAAQ,CAAE,MAAO,CAAC,OAAO,CAAC,EAAG,OAAQ,OAAO,CAAC,CAAC,CAAE,EAChDD,KAAS,gBAAaC,CAAK,KACjC,UAAOD,CAAM,EAAE,QAAQ,CAAE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AAO,IAAK,EAAG,EAAG,YAAa,CAAC,CAChE,CAAC,KAED,MAAG,iDAAkD,IAAM,CACzD,MAAMC,EAAiC,CACrC,EAAG,CACD,EAAG,CACD,EAAG,CACD,EAAG,CAAC,CACN,CACF,CACF,CACF,EACEA,EAAM,EAAiC,EACvC,EACEA,EACJ,MAAMD,KAAS,gBAAaC,CAAK,KACjC,UAAOD,CAAM,EAAE,QAAQ,CACrB,EAAG,CACD,EAAG,CACD,EAAG,YACL,CACF,CACF,CAAC,KACD,UAAO,IAAM,KAAK,UAAUA,CAAM,CAAC,EAAE,IAAI,QAAQ,CACnD,CAAC,CACH,CAAC",
6
+ "names": ["import_vitest", "import_sanitiseData", "result", "input", "arr", "shared"]
7
+ }
@@ -64,5 +64,5 @@
64
64
  "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
65
65
  "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
66
66
  },
67
- "version": "1.0.0"
67
+ "version": "1.0.1"
68
68
  }
@@ -1,2 +1,2 @@
1
- import{Observable as h,ReplaySubject as d,share as S}from"rxjs";import{createActor as I}from"xstate";import{DeviceActionStatus as a}from"../../device-action/model/DeviceActionState";class E{input;inspect=!1;constructor(e){this.input=e.input,this.inspect=!!e.inspect}_execute(e){const n=this.makeStateMachine(e);return this._subscribeToStateMachine(n)}_subscribeToStateMachine(e){const n=I(e,{input:this.input}),t=new d,o=r=>{const{context:i,status:p,output:l,error:m}=r;switch(p){case"active":t.next({status:a.Pending,intermediateValue:i.intermediateValue});break;case"done":l.caseOf({Left:c=>{t.next({status:a.Error,error:c})},Right:c=>{t.next({status:a.Completed,output:c})}}),t.complete();break;case"error":t.error(m),t.complete();break;case"stopped":t.next({status:a.Stopped}),t.complete();break;default:this._exhaustiveMatchingGuard(p)}},s=new h(r=>{const i=t.subscribe(r);return()=>{u.unsubscribe(),i.unsubscribe(),n.stop()}}),u=n.subscribe(o);return n.start(),{observable:s.pipe(S()),cancel:()=>{n.stop(),u.unsubscribe(),o(n.getSnapshot())}}}_exhaustiveMatchingGuard(e){throw console.log("_exhaustiveMatchingGuard status",e),new Error(`Unhandled status: ${e}`)}}export{E as XStateDeviceAction};
1
+ import{Observable as h,ReplaySubject as d,share as b}from"rxjs";import{createActor as I}from"xstate";import{DeviceActionStatus as o}from"../../device-action/model/DeviceActionState";class D{input;inspect=!1;logger;constructor(e){this.input=e.input,this.inspect=!!e.inspect,this.logger=e.logger}_execute(e){const r=this.makeStateMachine(e);return this._subscribeToStateMachine(r)}_subscribeToStateMachine(e){const r=I(e,{input:this.input}),t=new d;let c=!1;const p=a=>{const{context:n,status:u,output:m,error:S}=a;if(this.logger&&!c&&(c=!0,this.logger.debug("[XStateDeviceAction] Input",{data:{input:n.input}})),this.logger&&u==="active"){const i=typeof a.value=="string"?a.value:JSON.stringify(a.value);this.logger.debug(`[XStateDeviceAction] State: ${i}`,{data:{internalState:n._internalState}})}switch(u){case"active":t.next({status:o.Pending,intermediateValue:n.intermediateValue});break;case"done":m.caseOf({Left:i=>{t.next({status:o.Error,error:i})},Right:i=>{t.next({status:o.Completed,output:i})}}),t.complete();break;case"error":t.error(S),t.complete();break;case"stopped":t.next({status:o.Stopped}),t.complete();break;default:this._exhaustiveMatchingGuard(u)}},l=new h(a=>{const n=t.subscribe(a);return()=>{s.unsubscribe(),n.unsubscribe(),r.stop()}}),s=r.subscribe(p);return r.start(),{observable:l.pipe(b()),cancel:()=>{r.stop(),s.unsubscribe(),p(r.getSnapshot())}}}_exhaustiveMatchingGuard(e){throw console.log("_exhaustiveMatchingGuard status",e),new Error(`Unhandled status: ${e}`)}}export{D as XStateDeviceAction};
2
2
  //# sourceMappingURL=XStateDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/xstate-utils/XStateDeviceAction.ts"],
4
- "sourcesContent": ["// import { createBrowserInspector } from \"@statelyai/inspect\";\nimport { Observable, ReplaySubject, share } from \"rxjs\";\nimport {\n createActor,\n type SnapshotFrom,\n type StateMachine,\n type StateSchema,\n} from \"xstate\";\n\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\n\nimport { type StateMachineTypes } from \"./StateMachineTypes\";\n\nexport type DeviceActionStateMachine<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> = StateMachine<\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"context\"], // context\n /**\n * The following usages `any` are OK because this is just a wrapper around the\n * state machine and we are not directly going to use these types.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any, // event\n any, // children\n any, // actor\n any, // action\n any, // guard\n any, // delay\n any, // state value\n any, // tag\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"input\"],\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"output\"],\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any,\n any,\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateSchema\n>;\n\n/**\n * A DeviceAction that uses an XState state machine to execute.\n * It maps the state machine snapshots to the DeviceActionState.\n * This class is abstract and should be extended to implement the state machine.\n */\nexport abstract class XStateDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> implements DeviceAction<Output, Input, Error, IntermediateValue>\n{\n readonly input: Input;\n readonly inspect: boolean = false;\n\n /**\n *\n * @param input The input for the DeviceAction\n * @param inspect If true, the state machine will be inspected in the browser\n */\n constructor(args: { input: Input; inspect?: boolean }) {\n this.input = args.input;\n this.inspect = Boolean(args.inspect);\n }\n\n protected abstract makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >;\n\n _execute(\n internalApi: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const stateMachine = this.makeStateMachine(internalApi);\n return this._subscribeToStateMachine(stateMachine);\n }\n\n protected _subscribeToStateMachine(\n stateMachine: DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const actor = createActor(stateMachine, {\n input: this.input,\n // optional inspector for debugging\n // inspect: this.inspect ? createBrowserInspector().inspect : undefined,\n });\n\n /**\n * Using a ReplaySubject is important because the first snapshots might be\n * emitted before the observable is subscribed (if the machine goes through\n * those states fully synchronously).\n * This way, we ensure that the subscriber always receives the latest snapshot.\n * */\n const subject = new ReplaySubject<\n DeviceActionState<Output, Error, IntermediateValue>\n >();\n\n const handleActorSnapshot = (\n snapshot: SnapshotFrom<typeof stateMachine>,\n ) => {\n const { context, status, output, error } = snapshot;\n switch (status) {\n case \"active\":\n subject.next({\n status: DeviceActionStatus.Pending,\n intermediateValue: context.intermediateValue,\n });\n break;\n case \"done\":\n output.caseOf({\n Left: (err) => {\n subject.next({\n status: DeviceActionStatus.Error,\n error: err,\n });\n },\n Right: (result) => {\n subject.next({\n status: DeviceActionStatus.Completed,\n output: result,\n });\n },\n });\n subject.complete();\n break;\n case \"error\":\n // this is an error in the execution of the state machine, it should not happen\n subject.error(error);\n subject.complete();\n break;\n case \"stopped\":\n subject.next({\n status: DeviceActionStatus.Stopped,\n });\n subject.complete();\n break;\n default:\n this._exhaustiveMatchingGuard(status);\n }\n };\n\n const observable = new Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >((subscriber) => {\n const subjectSubscription = subject.subscribe(subscriber);\n return () => {\n actorSubscription.unsubscribe();\n subjectSubscription.unsubscribe();\n actor.stop(); // stop the actor when the observable is unsubscribed\n };\n });\n\n const actorSubscription = actor.subscribe(handleActorSnapshot);\n actor.start();\n\n return {\n observable: observable.pipe(share()), // share to garantee that once there is no more observer, the actor is stopped\n cancel: () => {\n actor.stop();\n actorSubscription.unsubscribe();\n handleActorSnapshot(actor.getSnapshot());\n },\n };\n }\n\n private _exhaustiveMatchingGuard(status: never): never {\n console.log(\"_exhaustiveMatchingGuard status\", status);\n throw new Error(`Unhandled status: ${status}`);\n }\n}\n"],
5
- "mappings": "AACA,OAAS,cAAAA,EAAY,iBAAAC,EAAe,SAAAC,MAAa,OACjD,OACE,eAAAC,MAIK,SAQP,OAEE,sBAAAC,MACK,6CA2DA,MAAeC,CAOtB,CACW,MACA,QAAmB,GAO5B,YAAYC,EAA2C,CACrD,KAAK,MAAQA,EAAK,MAClB,KAAK,QAAU,EAAQA,EAAK,OAC9B,CAYA,SACEC,EACiE,CACjE,MAAMC,EAAe,KAAK,iBAAiBD,CAAW,EACtD,OAAO,KAAK,yBAAyBC,CAAY,CACnD,CAEU,yBACRA,EAOiE,CACjE,MAAMC,EAAQN,EAAYK,EAAc,CACtC,MAAO,KAAK,KAGd,CAAC,EAQKE,EAAU,IAAIT,EAIdU,EACJC,GACG,CACH,KAAM,CAAE,QAAAC,EAAS,OAAAC,EAAQ,OAAAC,EAAQ,MAAAC,CAAM,EAAIJ,EAC3C,OAAQE,EAAQ,CACd,IAAK,SACHJ,EAAQ,KAAK,CACX,OAAQN,EAAmB,QAC3B,kBAAmBS,EAAQ,iBAC7B,CAAC,EACD,MACF,IAAK,OACHE,EAAO,OAAO,CACZ,KAAOE,GAAQ,CACbP,EAAQ,KAAK,CACX,OAAQN,EAAmB,MAC3B,MAAOa,CACT,CAAC,CACH,EACA,MAAQC,GAAW,CACjBR,EAAQ,KAAK,CACX,OAAQN,EAAmB,UAC3B,OAAQc,CACV,CAAC,CACH,CACF,CAAC,EACDR,EAAQ,SAAS,EACjB,MACF,IAAK,QAEHA,EAAQ,MAAMM,CAAK,EACnBN,EAAQ,SAAS,EACjB,MACF,IAAK,UACHA,EAAQ,KAAK,CACX,OAAQN,EAAmB,OAC7B,CAAC,EACDM,EAAQ,SAAS,EACjB,MACF,QACE,KAAK,yBAAyBI,CAAM,CACxC,CACF,EAEMK,EAAa,IAAInB,EAEpBoB,GAAe,CAChB,MAAMC,EAAsBX,EAAQ,UAAUU,CAAU,EACxD,MAAO,IAAM,CACXE,EAAkB,YAAY,EAC9BD,EAAoB,YAAY,EAChCZ,EAAM,KAAK,CACb,CACF,CAAC,EAEKa,EAAoBb,EAAM,UAAUE,CAAmB,EAC7D,OAAAF,EAAM,MAAM,EAEL,CACL,WAAYU,EAAW,KAAKjB,EAAM,CAAC,EACnC,OAAQ,IAAM,CACZO,EAAM,KAAK,EACXa,EAAkB,YAAY,EAC9BX,EAAoBF,EAAM,YAAY,CAAC,CACzC,CACF,CACF,CAEQ,yBAAyBK,EAAsB,CACrD,cAAQ,IAAI,kCAAmCA,CAAM,EAC/C,IAAI,MAAM,qBAAqBA,CAAM,EAAE,CAC/C,CACF",
6
- "names": ["Observable", "ReplaySubject", "share", "createActor", "DeviceActionStatus", "XStateDeviceAction", "args", "internalApi", "stateMachine", "actor", "subject", "handleActorSnapshot", "snapshot", "context", "status", "output", "error", "err", "result", "observable", "subscriber", "subjectSubscription", "actorSubscription"]
4
+ "sourcesContent": ["// import { createBrowserInspector } from \"@statelyai/inspect\";\nimport { Observable, ReplaySubject, share } from \"rxjs\";\nimport {\n createActor,\n type SnapshotFrom,\n type StateMachine,\n type StateSchema,\n} from \"xstate\";\n\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\n\nimport { type StateMachineTypes } from \"./StateMachineTypes\";\n\nexport type DeviceActionStateMachine<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> = StateMachine<\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"context\"], // context\n /**\n * The following usages `any` are OK because this is just a wrapper around the\n * state machine and we are not directly going to use these types.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any, // event\n any, // children\n any, // actor\n any, // action\n any, // guard\n any, // delay\n any, // state value\n any, // tag\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"input\"],\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"output\"],\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any,\n any,\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateSchema\n>;\n\n/**\n * A DeviceAction that uses an XState state machine to execute.\n * It maps the state machine snapshots to the DeviceActionState.\n * This class is abstract and should be extended to implement the state machine.\n */\nexport abstract class XStateDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> implements DeviceAction<Output, Input, Error, IntermediateValue>\n{\n readonly input: Input;\n readonly inspect: boolean = false;\n protected readonly logger?: LoggerPublisherService;\n\n /**\n *\n * @param input The input for the DeviceAction\n * @param inspect If true, the state machine will be inspected in the browser\n * @param logger Optional logger for debugging. If provided, input and internal state will be logged on state transitions.\n */\n constructor(args: {\n input: Input;\n inspect?: boolean;\n logger?: LoggerPublisherService;\n }) {\n this.input = args.input;\n this.inspect = Boolean(args.inspect);\n this.logger = args.logger;\n }\n\n protected abstract makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >;\n\n _execute(\n internalApi: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const stateMachine = this.makeStateMachine(internalApi);\n return this._subscribeToStateMachine(stateMachine);\n }\n\n protected _subscribeToStateMachine(\n stateMachine: DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const actor = createActor(stateMachine, {\n input: this.input,\n // optional inspector for debugging\n // inspect: this.inspect ? createBrowserInspector().inspect : undefined,\n });\n\n /**\n * Using a ReplaySubject is important because the first snapshots might be\n * emitted before the observable is subscribed (if the machine goes through\n * those states fully synchronously).\n * This way, we ensure that the subscriber always receives the latest snapshot.\n * */\n const subject = new ReplaySubject<\n DeviceActionState<Output, Error, IntermediateValue>\n >();\n\n let hasLoggedInput = false;\n\n const handleActorSnapshot = (\n snapshot: SnapshotFrom<typeof stateMachine>,\n ) => {\n const { context, status, output, error } = snapshot;\n\n // Log input once at the beginning\n if (this.logger && !hasLoggedInput) {\n hasLoggedInput = true;\n this.logger.debug(\"[XStateDeviceAction] Input\", {\n data: { input: context.input },\n });\n }\n\n // Log internal state on each state transition\n if (this.logger && status === \"active\") {\n const stateValue =\n typeof snapshot.value === \"string\"\n ? snapshot.value\n : JSON.stringify(snapshot.value);\n this.logger.debug(`[XStateDeviceAction] State: ${stateValue}`, {\n data: { internalState: context._internalState },\n });\n }\n\n switch (status) {\n case \"active\":\n subject.next({\n status: DeviceActionStatus.Pending,\n intermediateValue: context.intermediateValue,\n });\n break;\n case \"done\":\n output.caseOf({\n Left: (err) => {\n subject.next({\n status: DeviceActionStatus.Error,\n error: err,\n });\n },\n Right: (result) => {\n subject.next({\n status: DeviceActionStatus.Completed,\n output: result,\n });\n },\n });\n subject.complete();\n break;\n case \"error\":\n // this is an error in the execution of the state machine, it should not happen\n subject.error(error);\n subject.complete();\n break;\n case \"stopped\":\n subject.next({\n status: DeviceActionStatus.Stopped,\n });\n subject.complete();\n break;\n default:\n this._exhaustiveMatchingGuard(status);\n }\n };\n\n const observable = new Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >((subscriber) => {\n const subjectSubscription = subject.subscribe(subscriber);\n return () => {\n actorSubscription.unsubscribe();\n subjectSubscription.unsubscribe();\n actor.stop(); // stop the actor when the observable is unsubscribed\n };\n });\n\n const actorSubscription = actor.subscribe(handleActorSnapshot);\n actor.start();\n\n return {\n observable: observable.pipe(share()), // share to garantee that once there is no more observer, the actor is stopped\n cancel: () => {\n actor.stop();\n actorSubscription.unsubscribe();\n handleActorSnapshot(actor.getSnapshot());\n },\n };\n }\n\n private _exhaustiveMatchingGuard(status: never): never {\n console.log(\"_exhaustiveMatchingGuard status\", status);\n throw new Error(`Unhandled status: ${status}`);\n }\n}\n"],
5
+ "mappings": "AACA,OAAS,cAAAA,EAAY,iBAAAC,EAAe,SAAAC,MAAa,OACjD,OACE,eAAAC,MAIK,SAQP,OAEE,sBAAAC,MACK,6CA4DA,MAAeC,CAOtB,CACW,MACA,QAAmB,GACT,OAQnB,YAAYC,EAIT,CACD,KAAK,MAAQA,EAAK,MAClB,KAAK,QAAU,EAAQA,EAAK,QAC5B,KAAK,OAASA,EAAK,MACrB,CAYA,SACEC,EACiE,CACjE,MAAMC,EAAe,KAAK,iBAAiBD,CAAW,EACtD,OAAO,KAAK,yBAAyBC,CAAY,CACnD,CAEU,yBACRA,EAOiE,CACjE,MAAMC,EAAQN,EAAYK,EAAc,CACtC,MAAO,KAAK,KAGd,CAAC,EAQKE,EAAU,IAAIT,EAIpB,IAAIU,EAAiB,GAErB,MAAMC,EACJC,GACG,CACH,KAAM,CAAE,QAAAC,EAAS,OAAAC,EAAQ,OAAAC,EAAQ,MAAAC,CAAM,EAAIJ,EAW3C,GARI,KAAK,QAAU,CAACF,IAClBA,EAAiB,GACjB,KAAK,OAAO,MAAM,6BAA8B,CAC9C,KAAM,CAAE,MAAOG,EAAQ,KAAM,CAC/B,CAAC,GAIC,KAAK,QAAUC,IAAW,SAAU,C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ACF",
6
+ "names": ["Observable", "ReplaySubject", "share", "createActor", "DeviceActionStatus", "XStateDeviceAction", "args", "internalApi", "stateMachine", "actor", "subject", "hasLoggedInput", "handleActorSnapshot", "snapshot", "context", "status", "output", "error", "stateValue", "err", "result", "observable", "subscriber", "subjectSubscription", "actorSubscription"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Apdu as o}from"./apdu/model/Apdu";import{APDU_MAX_PAYLOAD as p,ApduBuilder as i}from"./apdu/utils/ApduBuilder";import{ApduParser as m}from"./apdu/utils/ApduParser";export*from"./apdu/utils/AppBuilderError";import{ByteArrayBuilder as c}from"./apdu/utils/ByteArrayBuilder";import{ByteArrayParser as x}from"./apdu/utils/ByteArrayParser";import{InvalidGetFirmwareMetadataResponseError as A,InvalidStatusWordError as D}from"./command/Errors";import{CommandResultFactory as u,CommandResultStatus as v,isSuccessCommandResult as S}from"./command/model/CommandResult";import{CloseAppCommand as y}from"./command/os/CloseAppCommand";import{GetAppAndVersionCommand as g}from"./command/os/GetAppAndVersionCommand";import{BatteryStatusType as B,GetBatteryStatusCommand as G}from"./command/os/GetBatteryStatusCommand";import{GetOsVersionCommand as M}from"./command/os/GetOsVersionCommand";import{ListAppsCommand as O}from"./command/os/ListAppsCommand";import{LoadCertificateCommand as h}from"./command/os/LoadCertificateCommand";import{OpenAppCommand as U}from"./command/os/OpenAppCommand";import{isCommandErrorCode as V}from"./command/utils/CommandErrors";import{CommandUtils as F}from"./command/utils/CommandUtils";import{GlobalCommandError as _,GlobalCommandErrorHandler as w}from"./command/utils/GlobalCommandError";import{DeviceModel as K,DeviceModelId as X,LEDGER_VENDOR_ID as q}from"./device/DeviceModel";import{DeviceStatus as Y}from"./device/DeviceStatus";import{DeviceActionStatus as z}from"./device-action/model/DeviceActionState";import{UserInteractionRequired as Q}from"./device-action/model/UserInteractionRequired";import{CallTaskInAppDeviceAction as $}from"./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction";import{AppAlreadyInstalledDAError as re,DeviceLockedError as oe,OutOfMemoryDAError as te,RefusedByUserDAError as pe,UnknownDAError as ie,UnsupportedFirmwareDAError as ne}from"./device-action/os/Errors";import{GetDeviceMetadataDeviceAction as ae}from"./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction";import{GetDeviceStatusDeviceAction as ce}from"./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{GoToDashboardDeviceAction as xe}from"./device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{InstallOrUpdateAppsDeviceAction as Ae}from"./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction";import{ListAppsDeviceAction as le}from"./device-action/os/ListApps/ListAppsDeviceAction";import{ListAppsWithMetadataDeviceAction as ve}from"./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction";import{OpenAppDeviceAction as Ce}from"./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{OpenAppWithDependenciesDeviceAction as Le}from"./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction";import{SendCommandInAppDeviceAction as Ee}from"./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction";import{XStateDeviceAction as Ge}from"./device-action/xstate-utils/XStateDeviceAction";import{StaticDeviceModelDataSource as Me}from"./device-model/data/StaticDeviceModelDataSource";import{BleDeviceInfos as Oe}from"./device-model/model/BleDeviceInfos";import{TransportDeviceModel as he}from"./device-model/model/DeviceModel";import{ApduResponse as Ue}from"./device-session/ApduResponse";export*from"./device-session/data/FramerConst";import{DeviceSessionStateType as ke}from"./device-session/DeviceSessionState";import{GenuineCheckDeviceAction as We}from"./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction";import{InstallAppDeviceAction as we}from"./secure-channel/device-action/InstallApp/InstallAppDeviceAction";import{ListInstalledAppsDeviceAction as Ke}from"./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction";import{UninstallAppDeviceAction as qe}from"./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction";import{SecureChannelError as Ye}from"../internal/secure-channel/model/Errors";import{defaultApduReceiverServiceStubBuilder as ze}from"./device-session/service/DefaultApduReceiverService.stub";import{defaultApduSenderServiceStubBuilder as Qe}from"./device-session/service/DefaultApduSenderService.stub";import{FramerUtils as $e}from"./device-session/utils/FramerUtils";import{DeviceManagementKit as rr}from"./DeviceManagementKit";import{DeviceManagementKitBuilder as tr}from"./DeviceManagementKitBuilder";export*from"./Error";import{LogLevel as nr}from"./logger-subscriber/model/LogLevel";import{ConsoleLogger as ar}from"./logger-subscriber/service/ConsoleLogger";import{WebLogsExporterLogger as cr}from"./logger-subscriber/service/WebLogsExporterLogger";import{ConnectedDevice as xr}from"./transport/model/ConnectedDevice";import{DeviceConnectionStateMachine as Ar}from"./transport/model/DeviceConnectionStateMachine";export*from"./transport/model/Errors";import{TransportConnectedDevice as ur}from"./transport/model/TransportConnectedDevice";import{connectedDeviceStubBuilder as Sr}from"./transport/model/TransportConnectedDevice.stub";export*from"./types";import{formatApduReceivedLog as Lr,formatApduSentLog as gr}from"./utils/apduLogs";import{base64StringToBuffer as Br,isBase64String as Gr}from"./utils/Base64String";import{bufferToHexaString as Mr,hexaStringToBuffer as Ir,isHexaString as Or}from"./utils/HexaString";export{p as APDU_MAX_PAYLOAD,o as Apdu,i as ApduBuilder,m as ApduParser,Ue as ApduResponse,re as AppAlreadyInstalledDAError,B as BatteryStatusType,Oe as BleDeviceInfos,c as ByteArrayBuilder,x as ByteArrayParser,$ as CallTaskInAppDeviceAction,y as CloseAppCommand,u as CommandResultFactory,v as CommandResultStatus,F as CommandUtils,xr as ConnectedDevice,ar as ConsoleLogger,z as DeviceActionStatus,Ar as DeviceConnectionStateMachine,oe as DeviceLockedError,rr as DeviceManagementKit,tr as DeviceManagementKitBuilder,K as DeviceModel,X as DeviceModelId,ke as DeviceSessionStateType,Y as DeviceStatus,$e as FramerUtils,We as GenuineCheckDeviceAction,g as GetAppAndVersionCommand,G as GetBatteryStatusCommand,ae as GetDeviceMetadataDeviceAction,ce as GetDeviceStatusDeviceAction,M as GetOsVersionCommand,_ as GlobalCommandError,w as GlobalCommandErrorHandler,xe as GoToDashboardDeviceAction,we as InstallAppDeviceAction,Ae as InstallOrUpdateAppsDeviceAction,A as InvalidGetFirmwareMetadataResponseError,D as InvalidStatusWordError,q as LEDGER_VENDOR_ID,O as ListAppsCommand,le as ListAppsDeviceAction,ve as ListAppsWithMetadataDeviceAction,Ke as ListInstalledAppsDeviceAction,h as LoadCertificateCommand,nr as LogLevel,U as OpenAppCommand,Ce as OpenAppDeviceAction,Le as OpenAppWithDependenciesDeviceAction,te as OutOfMemoryDAError,pe as RefusedByUserDAError,Ye as SecureChannelError,Ee as SendCommandInAppDeviceAction,Me as StaticDeviceModelDataSource,ur as TransportConnectedDevice,he as TransportDeviceModel,qe as UninstallAppDeviceAction,ie as UnknownDAError,ne as UnsupportedFirmwareDAError,Q as UserInteractionRequired,cr as WebLogsExporterLogger,Ge as XStateDeviceAction,Br as base64StringToBuffer,Mr as bufferToHexaString,Sr as connectedDeviceStubBuilder,ze as defaultApduReceiverServiceStubBuilder,Qe as defaultApduSenderServiceStubBuilder,Lr as formatApduReceivedLog,gr as formatApduSentLog,Ir as hexaStringToBuffer,Gr as isBase64String,V as isCommandErrorCode,Or as isHexaString,S as isSuccessCommandResult};
1
+ import{Apdu as o}from"./apdu/model/Apdu";import{APDU_MAX_PAYLOAD as p,ApduBuilder as i}from"./apdu/utils/ApduBuilder";import{ApduParser as n}from"./apdu/utils/ApduParser";export*from"./apdu/utils/AppBuilderError";import{ByteArrayBuilder as f}from"./apdu/utils/ByteArrayBuilder";import{ByteArrayParser as x}from"./apdu/utils/ByteArrayParser";import{InvalidGetFirmwareMetadataResponseError as A,InvalidStatusWordError as D}from"./command/Errors";import{CommandResultFactory as u,CommandResultStatus as v,isSuccessCommandResult as S}from"./command/model/CommandResult";import{CloseAppCommand as C}from"./command/os/CloseAppCommand";import{GetAppAndVersionCommand as L}from"./command/os/GetAppAndVersionCommand";import{BatteryStatusType as B,GetBatteryStatusCommand as G}from"./command/os/GetBatteryStatusCommand";import{GetOsVersionCommand as M}from"./command/os/GetOsVersionCommand";import{ListAppsCommand as O}from"./command/os/ListAppsCommand";import{LoadCertificateCommand as b}from"./command/os/LoadCertificateCommand";import{OpenAppCommand as U}from"./command/os/OpenAppCommand";import{isCommandErrorCode as P}from"./command/utils/CommandErrors";import{CommandUtils as k}from"./command/utils/CommandUtils";import{GlobalCommandError as _,GlobalCommandErrorHandler as w}from"./command/utils/GlobalCommandError";import{DeviceModel as K,DeviceModelId as X,LEDGER_VENDOR_ID as q}from"./device/DeviceModel";import{DeviceStatus as Y}from"./device/DeviceStatus";import{DeviceActionStatus as z}from"./device-action/model/DeviceActionState";import{UserInteractionRequired as Q}from"./device-action/model/UserInteractionRequired";import{CallTaskInAppDeviceAction as $}from"./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction";import{AppAlreadyInstalledDAError as re,DeviceLockedError as oe,OutOfMemoryDAError as te,RefusedByUserDAError as pe,UnknownDAError as ie,UnsupportedFirmwareDAError as me}from"./device-action/os/Errors";import{GetDeviceMetadataDeviceAction as ae}from"./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction";import{GetDeviceStatusDeviceAction as fe}from"./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{GoToDashboardDeviceAction as xe}from"./device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{InstallOrUpdateAppsDeviceAction as Ae}from"./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction";import{ListAppsDeviceAction as le}from"./device-action/os/ListApps/ListAppsDeviceAction";import{ListAppsWithMetadataDeviceAction as ve}from"./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction";import{OpenAppDeviceAction as ye}from"./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{OpenAppWithDependenciesDeviceAction as ge}from"./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction";import{SendCommandInAppDeviceAction as Ee}from"./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction";import{XStateDeviceAction as Ge}from"./device-action/xstate-utils/XStateDeviceAction";import{StaticDeviceModelDataSource as Me}from"./device-model/data/StaticDeviceModelDataSource";import{BleDeviceInfos as Oe}from"./device-model/model/BleDeviceInfos";import{TransportDeviceModel as be}from"./device-model/model/DeviceModel";import{ApduResponse as Ue}from"./device-session/ApduResponse";export*from"./device-session/data/FramerConst";import{DeviceSessionStateType as Ve}from"./device-session/DeviceSessionState";import{GenuineCheckDeviceAction as We}from"./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction";import{InstallAppDeviceAction as we}from"./secure-channel/device-action/InstallApp/InstallAppDeviceAction";import{ListInstalledAppsDeviceAction as Ke}from"./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction";import{UninstallAppDeviceAction as qe}from"./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction";import{SecureChannelError as Ye}from"../internal/secure-channel/model/Errors";import{defaultApduReceiverServiceStubBuilder as ze}from"./device-session/service/DefaultApduReceiverService.stub";import{defaultApduSenderServiceStubBuilder as Qe}from"./device-session/service/DefaultApduSenderService.stub";import{FramerUtils as $e}from"./device-session/utils/FramerUtils";import{DeviceManagementKit as rr}from"./DeviceManagementKit";import{DeviceManagementKitBuilder as tr}from"./DeviceManagementKitBuilder";export*from"./Error";import{LogLevel as mr}from"./logger-subscriber/model/LogLevel";import{ConsoleLogger as ar}from"./logger-subscriber/service/ConsoleLogger";import{DefaultLogTagFormatter as fr}from"./logger-subscriber/service/DefaultLogTagFormatter";import{WebLogsExporterLogger as xr}from"./logger-subscriber/service/WebLogsExporterLogger";import{ConnectedDevice as Ar}from"./transport/model/ConnectedDevice";import{DeviceConnectionStateMachine as lr}from"./transport/model/DeviceConnectionStateMachine";export*from"./transport/model/Errors";import{TransportConnectedDevice as Sr}from"./transport/model/TransportConnectedDevice";import{connectedDeviceStubBuilder as Cr}from"./transport/model/TransportConnectedDevice.stub";export*from"./types";import{formatApduReceivedLog as Er,formatApduSentLog as Br}from"./utils/apduLogs";import{base64StringToBuffer as Rr,isBase64String as Mr}from"./utils/Base64String";import{bufferToHexaString as Or,hexaStringToBuffer as Tr,isHexaString as br}from"./utils/HexaString";export{p as APDU_MAX_PAYLOAD,o as Apdu,i as ApduBuilder,n as ApduParser,Ue as ApduResponse,re as AppAlreadyInstalledDAError,B as BatteryStatusType,Oe as BleDeviceInfos,f as ByteArrayBuilder,x as ByteArrayParser,$ as CallTaskInAppDeviceAction,C as CloseAppCommand,u as CommandResultFactory,v as CommandResultStatus,k as CommandUtils,Ar as ConnectedDevice,ar as ConsoleLogger,fr as DefaultLogTagFormatter,z as DeviceActionStatus,lr as DeviceConnectionStateMachine,oe as DeviceLockedError,rr as DeviceManagementKit,tr as DeviceManagementKitBuilder,K as DeviceModel,X as DeviceModelId,Ve as DeviceSessionStateType,Y as DeviceStatus,$e as FramerUtils,We as GenuineCheckDeviceAction,L as GetAppAndVersionCommand,G as GetBatteryStatusCommand,ae as GetDeviceMetadataDeviceAction,fe as GetDeviceStatusDeviceAction,M as GetOsVersionCommand,_ as GlobalCommandError,w as GlobalCommandErrorHandler,xe as GoToDashboardDeviceAction,we as InstallAppDeviceAction,Ae as InstallOrUpdateAppsDeviceAction,A as InvalidGetFirmwareMetadataResponseError,D as InvalidStatusWordError,q as LEDGER_VENDOR_ID,O as ListAppsCommand,le as ListAppsDeviceAction,ve as ListAppsWithMetadataDeviceAction,Ke as ListInstalledAppsDeviceAction,b as LoadCertificateCommand,mr as LogLevel,U as OpenAppCommand,ye as OpenAppDeviceAction,ge as OpenAppWithDependenciesDeviceAction,te as OutOfMemoryDAError,pe as RefusedByUserDAError,Ye as SecureChannelError,Ee as SendCommandInAppDeviceAction,Me as StaticDeviceModelDataSource,Sr as TransportConnectedDevice,be as TransportDeviceModel,qe as UninstallAppDeviceAction,ie as UnknownDAError,me as UnsupportedFirmwareDAError,Q as UserInteractionRequired,xr as WebLogsExporterLogger,Ge as XStateDeviceAction,Rr as base64StringToBuffer,Or as bufferToHexaString,Cr as connectedDeviceStubBuilder,ze as defaultApduReceiverServiceStubBuilder,Qe as defaultApduSenderServiceStubBuilder,Er as formatApduReceivedLog,Br as formatApduSentLog,Tr as hexaStringToBuffer,Mr as isBase64String,P as isCommandErrorCode,br as isHexaString,S as isSuccessCommandResult};
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 {\n InvalidGetFirmwareMetadataResponseError,\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 GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\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 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 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 {\n AppAlreadyInstalledDAError,\n DeviceLockedError,\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 { 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 {\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 { 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 { 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 { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\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 { base64StringToBuffer, isBase64String } 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,kCAChC,OACE,2CAAAC,EACA,0BAAAC,MACK,sBACP,OACE,wBAAAC,EACA,uBAAAC,EACA,0BAAAC,MACK,mCACP,OAAS,mBAAAC,MAAuB,kCAChC,OACE,2BAAAC,MAEK,0CACP,OACE,qBAAAC,EAEA,2BAAAC,MAEK,0CACP,OACE,uBAAAC,MAEK,sCACP,OAEE,mBAAAC,MAGK,kCACP,OAEE,0BAAAC,MAEK,yCACP,OAEE,kBAAAC,MACK,iCACP,OAAS,sBAAAC,MAA0B,mCACnC,OAAS,gBAAAC,MAAoB,kCAC7B,OACE,sBAAAC,EACA,6BAAAC,MACK,wCACP,OACE,eAAAC,EACA,iBAAAC,EACA,oBAAAC,MACK,0BACP,OAAS,gBAAAC,MAAoB,2BAE7B,OAEE,sBAAAC,MACK,6CACP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,4EAC1C,OACE,8BAAAC,GACA,qBAAAC,GACA,sBAAAC,GACA,wBAAAC,GACA,kBAAAC,GACA,8BAAAC,OACK,+BACP,OAAS,iCAAAC,OAAqC,wEAC9C,OAAS,+BAAAC,OAAmC,oEAC5C,OAAS,6BAAAC,OAAiC,gEAC1C,OAAS,mCAAAC,OAAuC,4EAChD,OAAS,wBAAAC,OAA4B,sDACrC,OAAS,oCAAAC,OAAwC,8EACjD,OAAS,uBAAAC,OAA2B,gEACpC,OAAS,uCAAAC,OAA2C,oFACpD,OAAS,gCAAAC,OAAoC,kFAC7C,OAEE,sBAAAC,OACK,qDACP,OAAS,+BAAAC,OAAmC,qDAC5C,OAAS,kBAAAC,OAAsB,yCAC/B,OAAS,wBAAAC,OAA4B,sCACrC,OAAS,gBAAAC,OAAoB,mCAC7B,WAAc,uCACd,OAEE,0BAAAC,OACK,yCACP,OAAS,4BAAAC,OAAgC,0EACzC,OAAS,0BAAAC,OAA8B,sEACvC,OAAS,iCAAAC,OAAqC,oFAC9C,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,OAAS,YAAAC,OAAgB,wCACzB,OAAS,iBAAAC,OAAqB,+CAC9B,OAAS,yBAAAC,OAA6B,uDACtC,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,wBAAAC,GAAsB,kBAAAC,OAAsB,0BACrD,OACE,sBAAAC,GACA,sBAAAC,GACA,gBAAAC,OACK",
6
- "names": ["Apdu", "APDU_MAX_PAYLOAD", "ApduBuilder", "ApduParser", "ByteArrayBuilder", "ByteArrayParser", "InvalidGetFirmwareMetadataResponseError", "InvalidStatusWordError", "CommandResultFactory", "CommandResultStatus", "isSuccessCommandResult", "CloseAppCommand", "GetAppAndVersionCommand", "BatteryStatusType", "GetBatteryStatusCommand", "GetOsVersionCommand", "ListAppsCommand", "LoadCertificateCommand", "OpenAppCommand", "isCommandErrorCode", "CommandUtils", "GlobalCommandError", "GlobalCommandErrorHandler", "DeviceModel", "DeviceModelId", "LEDGER_VENDOR_ID", "DeviceStatus", "DeviceActionStatus", "UserInteractionRequired", "CallTaskInAppDeviceAction", "AppAlreadyInstalledDAError", "DeviceLockedError", "OutOfMemoryDAError", "RefusedByUserDAError", "UnknownDAError", "UnsupportedFirmwareDAError", "GetDeviceMetadataDeviceAction", "GetDeviceStatusDeviceAction", "GoToDashboardDeviceAction", "InstallOrUpdateAppsDeviceAction", "ListAppsDeviceAction", "ListAppsWithMetadataDeviceAction", "OpenAppDeviceAction", "OpenAppWithDependenciesDeviceAction", "SendCommandInAppDeviceAction", "XStateDeviceAction", "StaticDeviceModelDataSource", "BleDeviceInfos", "TransportDeviceModel", "ApduResponse", "DeviceSessionStateType", "GenuineCheckDeviceAction", "InstallAppDeviceAction", "ListInstalledAppsDeviceAction", "UninstallAppDeviceAction", "SecureChannelError", "defaultApduReceiverServiceStubBuilder", "defaultApduSenderServiceStubBuilder", "FramerUtils", "DeviceManagementKit", "DeviceManagementKitBuilder", "LogLevel", "ConsoleLogger", "WebLogsExporterLogger", "ConnectedDevice", "DeviceConnectionStateMachine", "TransportConnectedDevice", "connectedDeviceStubBuilder", "formatApduReceivedLog", "formatApduSentLog", "base64StringToBuffer", "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 {\n InvalidGetFirmwareMetadataResponseError,\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 GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\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 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 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 {\n AppAlreadyInstalledDAError,\n DeviceLockedError,\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 { 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 {\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 { 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 { 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 { 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 { 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 { base64StringToBuffer, isBase64String } 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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iCAAAC,OAAqC,oFAC9C,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,OAAS,YAAAC,OAAgB,wCACzB,OAAS,iBAAAC,OAAqB,+CAC9B,OAAS,0BAAAC,OAA8B,wDAEvC,OAAS,yBAAAC,OAA6B,uDACtC,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,wBAAAC,GAAsB,kBAAAC,OAAsB,0BACrD,OACE,sBAAAC,GACA,sBAAAC,GACA,gBAAAC,OACK",
6
+ "names": ["Apdu", "APDU_MAX_PAYLOAD", "ApduBuilder", "ApduParser", "ByteArrayBuilder", "ByteArrayParser", "InvalidGetFirmwareMetadataResponseError", "InvalidStatusWordError", "CommandResultFactory", "CommandResultStatus", "isSuccessCommandResult", "CloseAppCommand", "GetAppAndVersionCommand", "BatteryStatusType", "GetBatteryStatusCommand", "GetOsVersionCommand", "ListAppsCommand", "LoadCertificateCommand", "OpenAppCommand", "isCommandErrorCode", "CommandUtils", "GlobalCommandError", "GlobalCommandErrorHandler", "DeviceModel", "DeviceModelId", "LEDGER_VENDOR_ID", "DeviceStatus", "DeviceActionStatus", "UserInteractionRequired", "CallTaskInAppDeviceAction", "AppAlreadyInstalledDAError", "DeviceLockedError", "OutOfMemoryDAError", "RefusedByUserDAError", "UnknownDAError", "UnsupportedFirmwareDAError", "GetDeviceMetadataDeviceAction", "GetDeviceStatusDeviceAction", "GoToDashboardDeviceAction", "InstallOrUpdateAppsDeviceAction", "ListAppsDeviceAction", "ListAppsWithMetadataDeviceAction", "OpenAppDeviceAction", "OpenAppWithDependenciesDeviceAction", "SendCommandInAppDeviceAction", "XStateDeviceAction", "StaticDeviceModelDataSource", "BleDeviceInfos", "TransportDeviceModel", "ApduResponse", "DeviceSessionStateType", "GenuineCheckDeviceAction", "InstallAppDeviceAction", "ListInstalledAppsDeviceAction", "UninstallAppDeviceAction", "SecureChannelError", "defaultApduReceiverServiceStubBuilder", "defaultApduSenderServiceStubBuilder", "FramerUtils", "DeviceManagementKit", "DeviceManagementKitBuilder", "LogLevel", "ConsoleLogger", "DefaultLogTagFormatter", "WebLogsExporterLogger", "ConnectedDevice", "DeviceConnectionStateMachine", "TransportConnectedDevice", "connectedDeviceStubBuilder", "formatApduReceivedLog", "formatApduSentLog", "base64StringToBuffer", "isBase64String", "bufferToHexaString", "hexaStringToBuffer", "isHexaString"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{LogLevel as e}from"../../logger-subscriber/model/LogLevel";class g{maxLevel;constructor(t=e.Debug){this.maxLevel=t}log(t,a,r){const i=`[${r.tag}]`;switch(t){case e.Info:{this.maxLevel>=e.Info&&this.logWithData(i,console.info,a,r);break}case e.Warning:{this.maxLevel>=e.Warning&&this.logWithData(i,console.warn,a,r);break}case e.Debug:{this.maxLevel>=e.Debug&&this.logWithData(i,console.debug,a,r);break}case e.Error:{this.maxLevel>=e.Error&&this.logWithData(i,console.error,a,r);break}case e.Fatal:{this.maxLevel>=e.Fatal&&this.logWithData(i,console.error,a,r);break}default:this.logWithData(i,console.log,a,r)}}logWithData(t,a,r,i){i.data?a(t,r,i.data):a(t,r)}}export{g as ConsoleLogger};
1
+ import{LogLevel as e}from"../../logger-subscriber/model/LogLevel";class g{maxLevel;constructor(t=e.Debug){this.maxLevel=t}log(t,a,r){const i=r.tag;switch(t){case e.Info:{this.maxLevel>=e.Info&&this.logWithData(i,console.info,a,r);break}case e.Warning:{this.maxLevel>=e.Warning&&this.logWithData(i,console.warn,a,r);break}case e.Debug:{this.maxLevel>=e.Debug&&this.logWithData(i,console.debug,a,r);break}case e.Error:{this.maxLevel>=e.Error&&this.logWithData(i,console.error,a,r);break}case e.Fatal:{this.maxLevel>=e.Fatal&&this.logWithData(i,console.error,a,r);break}default:this.logWithData(i,console.log,a,r)}}logWithData(t,a,r,i){i.data?a(t,r,i.data):a(t,r)}}export{g as ConsoleLogger};
2
2
  //# sourceMappingURL=ConsoleLogger.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/logger-subscriber/service/ConsoleLogger.ts"],
4
- "sourcesContent": ["import { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { type LogSubscriberOptions } from \"@api/logger-subscriber/model/LogSubscriberOptions\";\nimport { type LoggerSubscriberService } from \"@api/logger-subscriber/service/LoggerSubscriberService\";\n\nexport class ConsoleLogger implements LoggerSubscriberService {\n private readonly maxLevel: LogLevel;\n\n constructor(level: LogLevel = LogLevel.Debug) {\n this.maxLevel = level;\n }\n\n log(\n level: LogLevel | null,\n message: string,\n options: LogSubscriberOptions,\n ): void {\n const tag = `[${options.tag}]`;\n\n switch (level) {\n case LogLevel.Info: {\n if (this.maxLevel >= LogLevel.Info) {\n this.logWithData(tag, console.info, message, options);\n }\n break;\n }\n case LogLevel.Warning: {\n if (this.maxLevel >= LogLevel.Warning) {\n this.logWithData(tag, console.warn, message, options);\n }\n break;\n }\n case LogLevel.Debug: {\n if (this.maxLevel >= LogLevel.Debug) {\n this.logWithData(tag, console.debug, message, options);\n }\n break;\n }\n case LogLevel.Error: {\n if (this.maxLevel >= LogLevel.Error) {\n this.logWithData(tag, console.error, message, options);\n }\n break;\n }\n case LogLevel.Fatal: {\n if (this.maxLevel >= LogLevel.Fatal) {\n this.logWithData(tag, console.error, message, options);\n }\n break;\n }\n default:\n this.logWithData(tag, console.log, message, options);\n }\n }\n\n private logWithData(\n tag: string,\n logFunction: (...args: unknown[]) => void,\n message: string,\n options: LogSubscriberOptions,\n ): void {\n if (options.data) {\n logFunction(tag, message, options.data);\n } else {\n logFunction(tag, message);\n }\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,YAAAA,MAAgB,wCAIlB,MAAMC,CAAiD,CAC3C,SAEjB,YAAYC,EAAkBF,EAAS,MAAO,CAC5C,KAAK,SAAWE,CAClB,CAEA,IACEA,EACAC,EACAC,EACM,CACN,MAAMC,EAAM,IAAID,EAAQ,GAAG,IAE3B,OAAQF,EAAO,CACb,KAAKF,EAAS,KAAM,CACd,KAAK,UAAYA,EAAS,MAC5B,KAAK,YAAYK,EAAK,QAAQ,KAAMF,EAASC,CAAO,EAEtD,KACF,CACA,KAAKJ,EAAS,QAAS,CACjB,KAAK,UAAYA,EAAS,SAC5B,KAAK,YAAYK,EAAK,QAAQ,KAAMF,EAASC,CAAO,EAEtD,KACF,CACA,KAAKJ,EAAS,MAAO,CACf,KAAK,UAAYA,EAAS,OAC5B,KAAK,YAAYK,EAAK,QAAQ,MAAOF,EAASC,CAAO,EAEvD,KACF,CACA,KAAKJ,EAAS,MAAO,CACf,KAAK,UAAYA,EAAS,OAC5B,KAAK,YAAYK,EAAK,QAAQ,MAAOF,EAASC,CAAO,EAEvD,KACF,CACA,KAAKJ,EAAS,MAAO,CACf,KAAK,UAAYA,EAAS,OAC5B,KAAK,YAAYK,EAAK,QAAQ,MAAOF,EAASC,CAAO,EAEvD,KACF,CACA,QACE,KAAK,YAAYC,EAAK,QAAQ,IAAKF,EAASC,CAAO,CACvD,CACF,CAEQ,YACNC,EACAC,EACAH,EACAC,EACM,CACFA,EAAQ,KACVE,EAAYD,EAAKF,EAASC,EAAQ,IAAI,EAEtCE,EAAYD,EAAKF,CAAO,CAE5B,CACF",
4
+ "sourcesContent": ["import { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { type LogSubscriberOptions } from \"@api/logger-subscriber/model/LogSubscriberOptions\";\nimport { type LoggerSubscriberService } from \"@api/logger-subscriber/service/LoggerSubscriberService\";\n\nexport class ConsoleLogger implements LoggerSubscriberService {\n private readonly maxLevel: LogLevel;\n\n constructor(level: LogLevel = LogLevel.Debug) {\n this.maxLevel = level;\n }\n\n log(\n level: LogLevel | null,\n message: string,\n options: LogSubscriberOptions,\n ): void {\n const tag = options.tag;\n\n switch (level) {\n case LogLevel.Info: {\n if (this.maxLevel >= LogLevel.Info) {\n this.logWithData(tag, console.info, message, options);\n }\n break;\n }\n case LogLevel.Warning: {\n if (this.maxLevel >= LogLevel.Warning) {\n this.logWithData(tag, console.warn, message, options);\n }\n break;\n }\n case LogLevel.Debug: {\n if (this.maxLevel >= LogLevel.Debug) {\n this.logWithData(tag, console.debug, message, options);\n }\n break;\n }\n case LogLevel.Error: {\n if (this.maxLevel >= LogLevel.Error) {\n this.logWithData(tag, console.error, message, options);\n }\n break;\n }\n case LogLevel.Fatal: {\n if (this.maxLevel >= LogLevel.Fatal) {\n this.logWithData(tag, console.error, message, options);\n }\n break;\n }\n default:\n this.logWithData(tag, console.log, message, options);\n }\n }\n\n private logWithData(\n tag: string,\n logFunction: (...args: unknown[]) => void,\n message: string,\n options: LogSubscriberOptions,\n ): void {\n if (options.data) {\n logFunction(tag, message, options.data);\n } else {\n logFunction(tag, message);\n }\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,YAAAA,MAAgB,wCAIlB,MAAMC,CAAiD,CAC3C,SAEjB,YAAYC,EAAkBF,EAAS,MAAO,CAC5C,KAAK,SAAWE,CAClB,CAEA,IACEA,EACAC,EACAC,EACM,CACN,MAAMC,EAAMD,EAAQ,IAEpB,OAAQF,EAAO,CACb,KAAKF,EAAS,KAAM,CACd,KAAK,UAAYA,EAAS,MAC5B,KAAK,YAAYK,EAAK,QAAQ,KAAMF,EAASC,CAAO,EAEtD,KACF,CACA,KAAKJ,EAAS,QAAS,CACjB,KAAK,UAAYA,EAAS,SAC5B,KAAK,YAAYK,EAAK,QAAQ,KAAMF,EAASC,CAAO,EAEtD,KACF,CACA,KAAKJ,EAAS,MAAO,CACf,KAAK,UAAYA,EAAS,OAC5B,KAAK,YAAYK,EAAK,QAAQ,MAAOF,EAASC,CAAO,EAEvD,KACF,CACA,KAAKJ,EAAS,MAAO,CACf,KAAK,UAAYA,EAAS,OAC5B,KAAK,YAAYK,EAAK,QAAQ,MAAOF,EAASC,CAAO,EAEvD,KACF,CACA,KAAKJ,EAAS,MAAO,CACf,KAAK,UAAYA,EAAS,OAC5B,KAAK,YAAYK,EAAK,QAAQ,MAAOF,EAASC,CAAO,EAEvD,KACF,CACA,QACE,KAAK,YAAYC,EAAK,QAAQ,IAAKF,EAASC,CAAO,CACvD,CACF,CAEQ,YACNC,EACAC,EACAH,EACAC,EACM,CACFA,EAAQ,KACVE,EAAYD,EAAKF,EAASC,EAAQ,IAAI,EAEtCE,EAAYD,EAAKF,CAAO,CAE5B,CACF",
6
6
  "names": ["LogLevel", "ConsoleLogger", "level", "message", "options", "tag", "logFunction"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{LogLevel as t}from"../../logger-subscriber/model/LogLevel";import{ConsoleLogger as i}from"./ConsoleLogger";const d=vi.spyOn(console,"warn").mockImplementation(vi.fn()),n=vi.spyOn(console,"info").mockImplementation(vi.fn()),r=vi.spyOn(console,"debug").mockImplementation(vi.fn()),a=vi.spyOn(console,"error").mockImplementation(vi.fn()),s=vi.spyOn(console,"log").mockImplementation(vi.fn());let o;const e={data:{key:"value"},timestamp:1,tag:"tag"},l="message";describe("ConsoleLogger",()=>{afterAll(()=>{vi.restoreAllMocks()}),describe("default level (LogLevel.DEBUG)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new i}),describe("log",()=>{it("should log Info level",()=>{o.log(t.Info,l,e),expect(n).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should log Info level with a custom tag",()=>{const g="custom-tag";o.log(t.Info,l,{...e,tag:g}),expect(n).toHaveBeenCalledWith(`[${g}]`,l,e.data)}),it("should log Warn level",()=>{o.log(t.Warning,l,e),expect(d).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should log Debug level",()=>{o.log(t.Debug,l,e),expect(r).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should log Fatal level",()=>{o.log(t.Fatal,l,e),expect(a).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should log Error level",()=>{o.log(t.Error,l,e),expect(a).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)})})}),describe("custom level (LogLevel.Info)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new i(t.Info)}),describe("log",()=>{it("should log Info level",()=>{o.log(t.Info,l,e),expect(n).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should log Info level with a custom tag",()=>{const g="custom-tag";o.log(t.Info,l,{...e,tag:g}),expect(n).toHaveBeenCalledWith(`[${g}]`,l,e.data)}),it("should log Warn level",()=>{o.log(t.Warning,l,e),expect(d).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should not log Debug level",()=>{o.log(t.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should log Error level",()=>{o.log(t.Error,l,e),expect(a).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should log Fatal level",()=>{o.log(t.Fatal,l,e),expect(a).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)})})}),describe("custom level (LogLevel.Warning)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new i(t.Warning)}),describe("log",()=>{it("should not log Info level",()=>{o.log(t.Info,l,e),expect(n).not.toHaveBeenCalled()}),it("should log Warn level",()=>{o.log(t.Warning,l,e),expect(d).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should not log Debug level",()=>{o.log(t.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should log Error level",()=>{o.log(t.Error,l,e),expect(a).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should log Fatal level",()=>{o.log(t.Fatal,l,e),expect(a).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)})})}),describe("custom level (LogLevel.Error)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new i(t.Error)}),describe("log",()=>{it("should not log Info level",()=>{o.log(t.Info,l,e),expect(n).not.toHaveBeenCalled()}),it("should not log Warn level",()=>{o.log(t.Warning,l,e),expect(d).not.toHaveBeenCalled()}),it("should not log Debug level",()=>{o.log(t.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should log Error level",()=>{o.log(t.Error,l,e),expect(a).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)}),it("should log Fatal level",()=>{o.log(t.Fatal,l,e),expect(a).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)})})}),describe("custom level (LogLevel.Fatal)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new i(t.Fatal)}),describe("log",()=>{it("should not log Info level",()=>{o.log(t.Info,l,e),expect(n).not.toHaveBeenCalled()}),it("should not log Warn level",()=>{o.log(t.Warning,l,e),expect(d).not.toHaveBeenCalled()}),it("should not log Debug level",()=>{o.log(t.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should log Fatal level",()=>{o.log(t.Fatal,l,e),expect(a).toHaveBeenCalledWith(`[${e.tag}]`,l,e.data)})})})});
1
+ import{LogLevel as t}from"../../logger-subscriber/model/LogLevel";import{ConsoleLogger as i}from"./ConsoleLogger";const d=vi.spyOn(console,"warn").mockImplementation(vi.fn()),n=vi.spyOn(console,"info").mockImplementation(vi.fn()),r=vi.spyOn(console,"debug").mockImplementation(vi.fn()),a=vi.spyOn(console,"error").mockImplementation(vi.fn()),s=vi.spyOn(console,"log").mockImplementation(vi.fn());let o;const e={data:{key:"value"},timestamp:1,tag:"[tag]"},l="message";describe("ConsoleLogger",()=>{afterAll(()=>{vi.restoreAllMocks()}),describe("default level (LogLevel.DEBUG)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new i}),describe("log",()=>{it("should log Info level",()=>{o.log(t.Info,l,e),expect(n).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Info level with a custom tag",()=>{const g="[custom-tag]";o.log(t.Info,l,{...e,tag:g}),expect(n).toHaveBeenCalledWith(g,l,e.data)}),it("should log Warn level",()=>{o.log(t.Warning,l,e),expect(d).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Debug level",()=>{o.log(t.Debug,l,e),expect(r).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Fatal level",()=>{o.log(t.Fatal,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Error level",()=>{o.log(t.Error,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)})})}),describe("custom level (LogLevel.Info)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new i(t.Info)}),describe("log",()=>{it("should log Info level",()=>{o.log(t.Info,l,e),expect(n).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Info level with a custom tag",()=>{const g="[custom-tag]";o.log(t.Info,l,{...e,tag:g}),expect(n).toHaveBeenCalledWith(g,l,e.data)}),it("should log Warn level",()=>{o.log(t.Warning,l,e),expect(d).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should not log Debug level",()=>{o.log(t.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Error level",()=>{o.log(t.Error,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Fatal level",()=>{o.log(t.Fatal,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)})})}),describe("custom level (LogLevel.Warning)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new i(t.Warning)}),describe("log",()=>{it("should not log Info level",()=>{o.log(t.Info,l,e),expect(n).not.toHaveBeenCalled()}),it("should log Warn level",()=>{o.log(t.Warning,l,e),expect(d).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should not log Debug level",()=>{o.log(t.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Error level",()=>{o.log(t.Error,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Fatal level",()=>{o.log(t.Fatal,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)})})}),describe("custom level (LogLevel.Error)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new i(t.Error)}),describe("log",()=>{it("should not log Info level",()=>{o.log(t.Info,l,e),expect(n).not.toHaveBeenCalled()}),it("should not log Warn level",()=>{o.log(t.Warning,l,e),expect(d).not.toHaveBeenCalled()}),it("should not log Debug level",()=>{o.log(t.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should default to Log level if none present",()=>{o.log(null,l,e),expect(s).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Error level",()=>{o.log(t.Error,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)}),it("should log Fatal level",()=>{o.log(t.Fatal,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)})})}),describe("custom level (LogLevel.Fatal)",()=>{beforeEach(()=>{vi.clearAllMocks(),o=new i(t.Fatal)}),describe("log",()=>{it("should not log Info level",()=>{o.log(t.Info,l,e),expect(n).not.toHaveBeenCalled()}),it("should not log Warn level",()=>{o.log(t.Warning,l,e),expect(d).not.toHaveBeenCalled()}),it("should not log Debug level",()=>{o.log(t.Debug,l,e),expect(r).not.toHaveBeenCalled()}),it("should log Fatal level",()=>{o.log(t.Fatal,l,e),expect(a).toHaveBeenCalledWith(e.tag,l,e.data)})})})});
2
2
  //# sourceMappingURL=ConsoleLogger.test.js.map