@ledgerhq/device-management-kit 0.0.0-develop-20241231103948 → 0.0.0-develop-20250106155104

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.
@@ -8,11 +8,6 @@
8
8
  "types": "./lib/types/index.d.ts",
9
9
  "import": "./lib/esm/index.js",
10
10
  "require": "./lib/cjs/index.js"
11
- },
12
- "./*": {
13
- "types": "./lib/types/*",
14
- "import": "./lib/esm/*",
15
- "require": "./lib/cjs/*"
16
11
  }
17
12
  },
18
13
  "files": [
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var t=(e,r)=>{for(var n in r)s(e,n,{get:r[n],enumerable:!0})},d=(e,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of c(r))!g.call(e,o)&&o!==n&&s(e,o,{get:()=>r[o],enumerable:!(i=a(r,o))||i.enumerable});return e};var E=e=>d(s({},"__esModule",{value:!0}),e);var h={};t(h,{DeviceExchangeError:()=>p,UnknownDeviceExchangeError:()=>l});module.exports=E(h);class p{_tag;originalError;errorCode;message;constructor({tag:r,errorCode:n,originalError:i,message:o}){this._tag=r,this.originalError=i,this.errorCode=n,this.message=o??"An error occured during device exchange."}}class l{_tag="UnknownDeviceExchangeError";originalError;message;constructor(r){this.originalError=r,this.message="Unexpected device exchange error happened."}}0&&(module.exports={DeviceExchangeError,UnknownDeviceExchangeError});
1
+ "use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var t=Object.prototype.hasOwnProperty;var g=(e,r)=>{for(var n in r)s(e,n,{get:r[n],enumerable:!0})},E=(e,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of c(r))!t.call(e,o)&&o!==n&&s(e,o,{get:()=>r[o],enumerable:!(i=a(r,o))||i.enumerable});return e};var d=e=>E(s({},"__esModule",{value:!0}),e);var m={};g(m,{DeviceBusyError:()=>h,DeviceExchangeError:()=>l,UnknownDeviceExchangeError:()=>p});module.exports=d(m);class l{_tag;originalError;errorCode;message;constructor({tag:r,errorCode:n,originalError:i,message:o}){this._tag=r,this.originalError=i,this.errorCode=n,this.message=o??"An error occured during device exchange."}}class p{_tag="UnknownDeviceExchangeError";originalError;message;constructor(r){this.originalError=r,this.message="Unexpected device exchange error happened."}}class h{_tag="DeviceBusyError";originalError;constructor(r){this.originalError=r??new Error("Device is busy, please try again later")}}0&&(module.exports={DeviceBusyError,DeviceExchangeError,UnknownDeviceExchangeError});
2
2
  //# sourceMappingURL=Error.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/Error.ts"],
4
- "sourcesContent": ["export interface DmkError {\n readonly _tag: string;\n readonly originalError?: unknown;\n message?: string;\n}\n\nexport type DeviceExchangeErrorArgs<SpecificErrorCodes> = {\n tag: string;\n originalError?: unknown;\n errorCode: SpecificErrorCodes;\n message: string;\n};\n\nexport type CommandErrorArgs<SpecificErrorCodes> = Omit<\n DeviceExchangeErrorArgs<SpecificErrorCodes>,\n \"tag\"\n>;\n\nexport abstract class DeviceExchangeError<SpecificErrorCodes = void> {\n readonly _tag: string;\n readonly originalError?: unknown;\n readonly errorCode: SpecificErrorCodes;\n readonly message: string;\n\n protected constructor({\n tag,\n errorCode,\n originalError,\n message,\n }: DeviceExchangeErrorArgs<SpecificErrorCodes>) {\n this._tag = tag;\n this.originalError = originalError;\n this.errorCode = errorCode;\n this.message = message ?? \"An error occured during device exchange.\";\n }\n}\n\nexport class UnknownDeviceExchangeError implements DmkError {\n readonly _tag = \"UnknownDeviceExchangeError\";\n readonly originalError?: unknown;\n readonly message: string;\n\n constructor(originalError?: unknown) {\n this.originalError = originalError;\n this.message = \"Unexpected device exchange error happened.\";\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,+BAAAC,IAAA,eAAAC,EAAAJ,GAkBO,MAAeE,CAA+C,CAC1D,KACA,cACA,UACA,QAEC,YAAY,CACpB,IAAAG,EACA,UAAAC,EACA,cAAAC,EACA,QAAAC,CACF,EAAgD,CAC9C,KAAK,KAAOH,EACZ,KAAK,cAAgBE,EACrB,KAAK,UAAYD,EACjB,KAAK,QAAUE,GAAW,0CAC5B,CACF,CAEO,MAAML,CAA+C,CACjD,KAAO,6BACP,cACA,QAET,YAAYI,EAAyB,CACnC,KAAK,cAAgBA,EACrB,KAAK,QAAU,4CACjB,CACF",
6
- "names": ["Error_exports", "__export", "DeviceExchangeError", "UnknownDeviceExchangeError", "__toCommonJS", "tag", "errorCode", "originalError", "message"]
4
+ "sourcesContent": ["export interface DmkError {\n readonly _tag: string;\n readonly originalError?: unknown;\n message?: string;\n}\n\nexport type DeviceExchangeErrorArgs<SpecificErrorCodes> = {\n tag: string;\n originalError?: unknown;\n errorCode: SpecificErrorCodes;\n message: string;\n};\n\nexport type CommandErrorArgs<SpecificErrorCodes> = Omit<\n DeviceExchangeErrorArgs<SpecificErrorCodes>,\n \"tag\"\n>;\n\nexport abstract class DeviceExchangeError<SpecificErrorCodes = void> {\n readonly _tag: string;\n readonly originalError?: unknown;\n readonly errorCode: SpecificErrorCodes;\n readonly message: string;\n\n protected constructor({\n tag,\n errorCode,\n originalError,\n message,\n }: DeviceExchangeErrorArgs<SpecificErrorCodes>) {\n this._tag = tag;\n this.originalError = originalError;\n this.errorCode = errorCode;\n this.message = message ?? \"An error occured during device exchange.\";\n }\n}\n\nexport class UnknownDeviceExchangeError implements DmkError {\n readonly _tag = \"UnknownDeviceExchangeError\";\n readonly originalError?: unknown;\n readonly message: string;\n\n constructor(originalError?: unknown) {\n this.originalError = originalError;\n this.message = \"Unexpected device exchange error happened.\";\n }\n}\n\nexport class DeviceBusyError implements DmkError {\n readonly _tag = \"DeviceBusyError\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError =\n originalError ?? new Error(\"Device is busy, please try again later\");\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,wBAAAC,EAAA,+BAAAC,IAAA,eAAAC,EAAAL,GAkBO,MAAeG,CAA+C,CAC1D,KACA,cACA,UACA,QAEC,YAAY,CACpB,IAAAG,EACA,UAAAC,EACA,cAAAC,EACA,QAAAC,CACF,EAAgD,CAC9C,KAAK,KAAOH,EACZ,KAAK,cAAgBE,EACrB,KAAK,UAAYD,EACjB,KAAK,QAAUE,GAAW,0CAC5B,CACF,CAEO,MAAML,CAA+C,CACjD,KAAO,6BACP,cACA,QAET,YAAYI,EAAyB,CACnC,KAAK,cAAgBA,EACrB,KAAK,QAAU,4CACjB,CACF,CAEO,MAAMN,CAAoC,CACtC,KAAO,kBAChB,cAEA,YAAYM,EAAuB,CACjC,KAAK,cACHA,GAAiB,IAAI,MAAM,wCAAwC,CACvE,CACF",
6
+ "names": ["Error_exports", "__export", "DeviceBusyError", "DeviceExchangeError", "UnknownDeviceExchangeError", "__toCommonJS", "tag", "errorCode", "originalError", "message"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var A=(r,e)=>{for(var s in e)a(r,s,{get:e[s],enumerable:!0})},_=(r,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of g(e))!f.call(r,t)&&t!==s&&a(r,t,{get:()=>e[t],enumerable:!(o=h(e,t))||o.enumerable});return r};var C=r=>_(a({},"__esModule",{value:!0}),r);var y={};A(y,{DeviceSession:()=>E});module.exports=C(y);var c=require("purify-ts"),p=require("rxjs"),d=require("uuid"),v=require("../../../api/command/utils/CommandUtils"),i=require("../../../api/device/DeviceStatus"),u=require("../../../api/device-session/DeviceSessionState"),S=require("../../device-session/data/DeviceSessionRefresherConst"),m=require("./DeviceSessionRefresher"),D=require("./Errors");class E{_id;_connectedDevice;_deviceState;_refresher;_managerApiService;constructor({connectedDevice:e,id:s=(0,d.v4)()},o,t){this._id=s,this._connectedDevice=e,this._deviceState=new p.BehaviorSubject({sessionStateType:u.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED}),this._refresher=new m.DeviceSessionRefresher({refreshInterval:S.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id,sendApduFn:n=>this.sendApdu(n,{isPolling:!0,triggersDisconnection:!1}),updateStateFn:n=>{const l=this._deviceState.getValue();this.setDeviceSessionState(n(l))}},o("device-session-refresher")),this._managerApiService=t}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}setDeviceSessionState(e){this._deviceState.next(e)}updateDeviceStatus(e){const s=this._deviceState.getValue();this._refresher.setDeviceStatus(e),this._deviceState.next({...s,deviceStatus:e})}async sendApdu(e,s={isPolling:!1,triggersDisconnection:!1}){return this._deviceState.getValue().deviceStatus===i.DeviceStatus.BUSY?(0,c.Left)(new D.DeviceBusyError):(s.isPolling||this.updateDeviceStatus(i.DeviceStatus.BUSY),(await this._connectedDevice.sendApdu(e,s.triggersDisconnection)).ifRight(n=>{v.CommandUtils.isLockedDeviceResponse(n)?this.updateDeviceStatus(i.DeviceStatus.LOCKED):this.updateDeviceStatus(i.DeviceStatus.CONNECTED)}).ifLeft(n=>{console.log("sendApduUseCase:Got error",n),this.updateDeviceStatus(i.DeviceStatus.CONNECTED)}))}async sendCommand(e){const s=e.getApdu();return(await this.sendApdu(s.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1})).caseOf({Left:t=>{throw t},Right:t=>e.parseResponse(t,this._connectedDevice.deviceModel.id)})}executeDeviceAction(e){const{observable:s,cancel:o}=e._execute({sendCommand:async t=>this.sendCommand(t),getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:t=>(this.setDeviceSessionState(t),this._deviceState.getValue()),getMetadataForAppHashes:t=>this._managerApiService.getAppsByHash(t)});return{observable:s,cancel:o}}close(){this.updateDeviceStatus(i.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._refresher.stop()}toggleRefresher(e){e?this._refresher.start():this._refresher.stop()}}0&&(module.exports={DeviceSession});
1
+ "use strict";var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var A=(r,e)=>{for(var s in e)a(r,s,{get:e[s],enumerable:!0})},_=(r,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of g(e))!f.call(r,t)&&t!==s&&a(r,t,{get:()=>e[t],enumerable:!(o=l(e,t))||o.enumerable});return r};var E=r=>_(a({},"__esModule",{value:!0}),r);var y={};A(y,{DeviceSession:()=>C});module.exports=E(y);var c=require("purify-ts"),p=require("rxjs"),d=require("uuid"),v=require("../../../api/command/utils/CommandUtils"),i=require("../../../api/device/DeviceStatus"),u=require("../../../api/device-session/DeviceSessionState"),S=require("../../../api/Error"),m=require("../../device-session/data/DeviceSessionRefresherConst"),D=require("./DeviceSessionRefresher");class C{_id;_connectedDevice;_deviceState;_refresher;_managerApiService;constructor({connectedDevice:e,id:s=(0,d.v4)()},o,t){this._id=s,this._connectedDevice=e,this._deviceState=new p.BehaviorSubject({sessionStateType:u.DeviceSessionStateType.Connected,deviceStatus:i.DeviceStatus.CONNECTED}),this._refresher=new D.DeviceSessionRefresher({refreshInterval:m.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:i.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id,sendApduFn:n=>this.sendApdu(n,{isPolling:!0,triggersDisconnection:!1}),updateStateFn:n=>{const h=this._deviceState.getValue();this.setDeviceSessionState(n(h))}},o("device-session-refresher")),this._managerApiService=t}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}setDeviceSessionState(e){this._deviceState.next(e)}updateDeviceStatus(e){const s=this._deviceState.getValue();this._refresher.setDeviceStatus(e),this._deviceState.next({...s,deviceStatus:e})}async sendApdu(e,s={isPolling:!1,triggersDisconnection:!1}){return this._deviceState.getValue().deviceStatus===i.DeviceStatus.BUSY?(0,c.Left)(new S.DeviceBusyError):(s.isPolling||this.updateDeviceStatus(i.DeviceStatus.BUSY),(await this._connectedDevice.sendApdu(e,s.triggersDisconnection)).ifRight(n=>{v.CommandUtils.isLockedDeviceResponse(n)?this.updateDeviceStatus(i.DeviceStatus.LOCKED):this.updateDeviceStatus(i.DeviceStatus.CONNECTED)}).ifLeft(()=>{this.updateDeviceStatus(i.DeviceStatus.CONNECTED)}))}async sendCommand(e){const s=e.getApdu();return(await this.sendApdu(s.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1})).caseOf({Left:t=>{throw t},Right:t=>e.parseResponse(t,this._connectedDevice.deviceModel.id)})}executeDeviceAction(e){const{observable:s,cancel:o}=e._execute({sendCommand:async t=>this.sendCommand(t),getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:t=>(this.setDeviceSessionState(t),this._deviceState.getValue()),getMetadataForAppHashes:t=>this._managerApiService.getAppsByHash(t)});return{observable:s,cancel:o}}close(){this.updateDeviceStatus(i.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._refresher.stop()}toggleRefresher(e){e?this._refresher.start():this._refresher.stop()}}0&&(module.exports={DeviceSession});
2
2
  //# sourceMappingURL=DeviceSession.js.map
@@ -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, Left } from \"purify-ts\";\nimport { BehaviorSubject } 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 { type ListAppsResponse } from \"@api/command/os/ListAppsCommand\";\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 { DEVICE_SESSION_REFRESH_INTERVAL } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceBusyError } from \"./Errors\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\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 _refresher: DeviceSessionRefresher;\n private readonly _managerApiService: ManagerApiService;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n });\n this._refresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n sendApduFn: (rawApdu: Uint8Array) =>\n this.sendApdu(rawApdu, {\n isPolling: true,\n triggersDisconnection: false,\n }),\n updateStateFn: (callback) => {\n const state = this._deviceState.getValue();\n this.setDeviceSessionState(callback(state));\n },\n },\n loggerModuleFactory(\"device-session-refresher\"),\n );\n this._managerApiService = managerApiService;\n }\n\n public get id() {\n return this._id;\n }\n\n public get connectedDevice() {\n return this._connectedDevice;\n }\n\n public get state() {\n return this._deviceState.asObservable();\n }\n\n public setDeviceSessionState(state: DeviceSessionState) {\n this._deviceState.next(state);\n }\n\n private updateDeviceStatus(deviceStatus: DeviceStatus) {\n const sessionState = this._deviceState.getValue();\n this._refresher.setDeviceStatus(deviceStatus);\n this._deviceState.next({\n ...sessionState,\n deviceStatus,\n });\n }\n\n async sendApdu(\n rawApdu: Uint8Array,\n options: {\n isPolling: boolean;\n triggersDisconnection: boolean;\n } = {\n isPolling: false,\n triggersDisconnection: false,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const sessionState = this._deviceState.getValue();\n if (sessionState.deviceStatus === DeviceStatus.BUSY) {\n return Left(new DeviceBusyError());\n }\n\n if (!options.isPolling) this.updateDeviceStatus(DeviceStatus.BUSY);\n\n const errorOrResponse = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n );\n\n return errorOrResponse\n .ifRight((response: ApduResponse) => {\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this.updateDeviceStatus(DeviceStatus.LOCKED);\n } else {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n }\n })\n .ifLeft((_error) => {\n console.log(\"sendApduUseCase:Got error\", _error);\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n });\n }\n\n async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n });\n\n return response.caseOf({\n Left: (err) => {\n throw err;\n },\n Right: (r) =>\n command.parseResponse(r, this._connectedDevice.deviceModel.id),\n });\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, Error, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n ) => this.sendCommand(command),\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n getMetadataForAppHashes: (apps: ListAppsResponse) =>\n this._managerApiService.getAppsByHash(apps),\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n close() {\n this.updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._refresher.stop();\n }\n\n toggleRefresher(enabled: boolean) {\n if (enabled) {\n this._refresher.start();\n } else {\n this._refresher.stop();\n }\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkC,qBAClCC,EAAgC,gBAChCC,EAA6B,gBAK7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAKPC,EAAgD,qEAGhDC,EAAuC,oCACvCC,EAAgC,oBAUzB,MAAMV,CAAc,CACR,IACA,iBACA,aACA,WACA,mBAEjB,YACE,CAAE,gBAAAW,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjCC,EACAC,EACA,CACA,KAAK,IAAMH,EACX,KAAK,iBAAmBD,EACxB,KAAK,aAAe,IAAI,kBAAoC,CAC1D,iBAAkB,yBAAuB,UACzC,aAAc,e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C,EAAOD,EAAQ,QAAQ,EAM7B,OALiB,MAAM,KAAK,SAASC,EAAK,WAAW,EAAG,CACtD,UAAW,GACX,sBAAuBD,EAAQ,uBAAyB,EAC1D,CAAC,GAEe,OAAO,CACrB,KAAOE,GAAQ,CACb,MAAMA,CACR,EACA,MAAQC,GACNH,EAAQ,cAAcG,EAAG,KAAK,iBAAiB,YAAY,EAAE,CACjE,CAAC,CACH,CAEA,oBAMEC,EACiE,CACjE,KAAM,CAAE,WAAAC,EAAY,OAAAC,CAAO,EAAIF,EAAa,SAAS,CACnD,YAAa,MACXJ,GACG,KAAK,YAAYA,CAAO,EAC7B,sBAAuB,IAAM,KAAK,aAAa,SAAS,EACxD,gCAAiC,IAAM,KAAK,MAC5C,sBAAwBN,IACtB,KAAK,sBAAsBA,CAAK,EACzB,KAAK,aAAa,SAAS,GAEpC,wBAA0Ba,GACxB,KAAK,mBAAmB,cAAcA,CAAI,CAC9C,CAAC,EAED,MAAO,CACL,WAAAF,EACA,OAAAC,CACF,CACF,CAEA,OAAQ,CACN,KAAK,mBAAmB,eAAa,aAAa,EAClD,KAAK,aAAa,SAAS,EAC3B,KAAK,WAAW,KAAK,CACvB,CAEA,gBAAgBE,EAAkB,CAC5BA,EACF,KAAK,WAAW,MAAM,EAEtB,KAAK,WAAW,KAAK,CAEzB,CACF",
6
- "names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_purify_ts", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_DeviceSessionRefresherConst", "import_DeviceSessionRefresher", "import_Errors", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "rawApdu", "callback", "state", "deviceStatus", "sessionState", "options", "response", "_error", "command", "apdu", "err", "r", "deviceAction", "observable", "cancel", "apps", "enabled"]
4
+ "sourcesContent": ["import { type Either, Left } from \"purify-ts\";\nimport { BehaviorSubject } 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 { type ListAppsResponse } from \"@api/command/os/ListAppsCommand\";\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 { DeviceBusyError, type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { DEVICE_SESSION_REFRESH_INTERVAL } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\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 _refresher: DeviceSessionRefresher;\n private readonly _managerApiService: ManagerApiService;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n });\n this._refresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n sendApduFn: (rawApdu: Uint8Array) =>\n this.sendApdu(rawApdu, {\n isPolling: true,\n triggersDisconnection: false,\n }),\n updateStateFn: (callback) => {\n const state = this._deviceState.getValue();\n this.setDeviceSessionState(callback(state));\n },\n },\n loggerModuleFactory(\"device-session-refresher\"),\n );\n this._managerApiService = managerApiService;\n }\n\n public get id() {\n return this._id;\n }\n\n public get connectedDevice() {\n return this._connectedDevice;\n }\n\n public get state() {\n return this._deviceState.asObservable();\n }\n\n public setDeviceSessionState(state: DeviceSessionState) {\n this._deviceState.next(state);\n }\n\n private updateDeviceStatus(deviceStatus: DeviceStatus) {\n const sessionState = this._deviceState.getValue();\n this._refresher.setDeviceStatus(deviceStatus);\n this._deviceState.next({\n ...sessionState,\n deviceStatus,\n });\n }\n\n async sendApdu(\n rawApdu: Uint8Array,\n options: {\n isPolling: boolean;\n triggersDisconnection: boolean;\n } = {\n isPolling: false,\n triggersDisconnection: false,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const sessionState = this._deviceState.getValue();\n if (sessionState.deviceStatus === DeviceStatus.BUSY) {\n return Left(new DeviceBusyError());\n }\n\n if (!options.isPolling) this.updateDeviceStatus(DeviceStatus.BUSY);\n\n const errorOrResponse = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n );\n\n return errorOrResponse\n .ifRight((response: ApduResponse) => {\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this.updateDeviceStatus(DeviceStatus.LOCKED);\n } else {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n }\n })\n .ifLeft(() => {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n });\n }\n\n async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n });\n\n return response.caseOf({\n Left: (err) => {\n throw err;\n },\n Right: (r) =>\n command.parseResponse(r, this._connectedDevice.deviceModel.id),\n });\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, Error, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n ) => this.sendCommand(command),\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n getMetadataForAppHashes: (apps: ListAppsResponse) =>\n this._managerApiService.getAppsByHash(apps),\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n close() {\n this.updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._refresher.stop();\n }\n\n toggleRefresher(enabled: boolean) {\n if (enabled) {\n this._refresher.start();\n } else {\n this._refresher.stop();\n }\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkC,qBAClCC,EAAgC,gBAChCC,EAA6B,gBAK7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAEPC,EAA+C,sBAG/CC,EAAgD,qEAGhDC,EAAuC,oCAUhC,MAAMV,CAAc,CACR,IACA,iBACA,aACA,WACA,mBAEjB,YACE,CAAE,gBAAAW,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjCC,EACAC,EACA,CACA,KAAK,IAAMH,EACX,KAAK,iBAAmBD,EACxB,KAAK,aAAe,IAAI,kBAAoC,CAC1D,iBAAkB,yBA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AQ,EAM7B,OALiB,MAAM,KAAK,SAASC,EAAK,WAAW,EAAG,CACtD,UAAW,GACX,sBAAuBD,EAAQ,uBAAyB,EAC1D,CAAC,GAEe,OAAO,CACrB,KAAOE,GAAQ,CACb,MAAMA,CACR,EACA,MAAQC,GACNH,EAAQ,cAAcG,EAAG,KAAK,iBAAiB,YAAY,EAAE,CACjE,CAAC,CACH,CAEA,oBAMEC,EACiE,CACjE,KAAM,CAAE,WAAAC,EAAY,OAAAC,CAAO,EAAIF,EAAa,SAAS,CACnD,YAAa,MACXJ,GACG,KAAK,YAAYA,CAAO,EAC7B,sBAAuB,IAAM,KAAK,aAAa,SAAS,EACxD,gCAAiC,IAAM,KAAK,MAC5C,sBAAwBL,IACtB,KAAK,sBAAsBA,CAAK,EACzB,KAAK,aAAa,SAAS,GAEpC,wBAA0BY,GACxB,KAAK,mBAAmB,cAAcA,CAAI,CAC9C,CAAC,EAED,MAAO,CACL,WAAAF,EACA,OAAAC,CACF,CACF,CAEA,OAAQ,CACN,KAAK,mBAAmB,eAAa,aAAa,EAClD,KAAK,aAAa,SAAS,EAC3B,KAAK,WAAW,KAAK,CACvB,CAEA,gBAAgBE,EAAkB,CAC5BA,EACF,KAAK,WAAW,MAAM,EAEtB,KAAK,WAAW,KAAK,CAEzB,CACF",
6
+ "names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_purify_ts", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_Error", "import_DeviceSessionRefresherConst", "import_DeviceSessionRefresher", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "rawApdu", "callback", "state", "deviceStatus", "sessionState", "options", "response", "command", "apdu", "err", "r", "deviceAction", "observable", "cancel", "apps", "enabled"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var l=(o,r)=>{for(var i in r)s(o,i,{get:r[i],enumerable:!0})},c=(o,r,i,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of a(r))!E.call(o,e)&&e!==i&&s(o,e,{get:()=>r[e],enumerable:!(n=t(r,e))||n.enumerable});return o};var m=o=>c(s({},"__esModule",{value:!0}),o);var v={};l(v,{DeviceBusyError:()=>h,DeviceSessionNotFound:()=>d,DeviceSessionRefresherError:()=>D,FramerApduError:()=>p,FramerOverflowError:()=>g,ReceiverApduError:()=>u});module.exports=m(v);class g{_tag="FramerOverflowError";originalError;constructor(){this.originalError=new Error("Frame header length is greater than frame size")}}class p{_tag="FramerApduError";originalError;constructor(){this.originalError=new Error("Frame offset is greater than apdu length")}}class u{_tag="ReceiverApduError";originalError;constructor(r){this.originalError=new Error(r??"Unable to parse apdu")}}class d{_tag="DeviceSessionNotFound";originalError;constructor(r){this.originalError=r??new Error("Device session not found")}}class D{_tag="DeviceSessionRefresherError";originalError;constructor(r){this.originalError=r??new Error("Device session refresher error")}}class h{_tag="DeviceBusyError";originalError;constructor(r){this.originalError=r??new Error("Device is busy, please try again later")}}0&&(module.exports={DeviceBusyError,DeviceSessionNotFound,DeviceSessionRefresherError,FramerApduError,FramerOverflowError,ReceiverApduError});
1
+ "use strict";var s=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var l=(o,r)=>{for(var i in r)s(o,i,{get:r[i],enumerable:!0})},m=(o,r,i,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of a(r))!E.call(o,e)&&e!==i&&s(o,e,{get:()=>r[e],enumerable:!(n=t(r,e))||n.enumerable});return o};var c=o=>m(s({},"__esModule",{value:!0}),o);var D={};l(D,{DeviceSessionNotFound:()=>u,DeviceSessionRefresherError:()=>h,FramerApduError:()=>p,FramerOverflowError:()=>g,ReceiverApduError:()=>d});module.exports=c(D);class g{_tag="FramerOverflowError";originalError;constructor(){this.originalError=new Error("Frame header length is greater than frame size")}}class p{_tag="FramerApduError";originalError;constructor(){this.originalError=new Error("Frame offset is greater than apdu length")}}class d{_tag="ReceiverApduError";originalError;constructor(r){this.originalError=new Error(r??"Unable to parse apdu")}}class u{_tag="DeviceSessionNotFound";originalError;constructor(r){this.originalError=r??new Error("Device session not found")}}class h{_tag="DeviceSessionRefresherError";originalError;constructor(r){this.originalError=r??new Error("Device session refresher error")}}0&&(module.exports={DeviceSessionNotFound,DeviceSessionRefresherError,FramerApduError,FramerOverflowError,ReceiverApduError});
2
2
  //# sourceMappingURL=Errors.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/model/Errors.ts"],
4
- "sourcesContent": ["import { type DmkError } from \"@root/src/api/Error\";\n\nexport class FramerOverflowError implements DmkError {\n readonly _tag = \"FramerOverflowError\";\n originalError?: Error;\n constructor() {\n this.originalError = new Error(\n \"Frame header length is greater than frame size\",\n );\n }\n}\n\nexport class FramerApduError implements DmkError {\n readonly _tag = \"FramerApduError\";\n originalError?: Error;\n\n constructor() {\n this.originalError = new Error(\"Frame offset is greater than apdu length\");\n }\n}\n\nexport class ReceiverApduError implements DmkError {\n readonly _tag = \"ReceiverApduError\";\n originalError: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unable to parse apdu\");\n }\n}\n\nexport class DeviceSessionNotFound implements DmkError {\n readonly _tag = \"DeviceSessionNotFound\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError = originalError ?? new Error(\"Device session not found\");\n }\n}\n\nexport class DeviceSessionRefresherError implements DmkError {\n readonly _tag = \"DeviceSessionRefresherError\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError =\n originalError ?? new Error(\"Device session refresher error\");\n }\n}\n\nexport class DeviceBusyError implements DmkError {\n readonly _tag = \"DeviceBusyError\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError =\n originalError ?? new Error(\"Device is busy, please try again later\");\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,0BAAAC,EAAA,gCAAAC,EAAA,oBAAAC,EAAA,wBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAR,GAEO,MAAMM,CAAwC,CAC1C,KAAO,sBAChB,cACA,aAAc,CACZ,KAAK,cAAgB,IAAI,MACvB,gDACF,CACF,CACF,CAEO,MAAMD,CAAoC,CACtC,KAAO,kBAChB,cAEA,aAAc,CACZ,KAAK,cAAgB,IAAI,MAAM,0CAA0C,CAC3E,CACF,CAEO,MAAME,CAAsC,CACxC,KAAO,oBAChB,cAEA,YAAYE,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,sBAAsB,CAClE,CACF,CAEO,MAAMN,CAA0C,CAC5C,KAAO,wBAChB,cAEA,YAAYO,EAAuB,CACjC,KAAK,cAAgBA,GAAiB,IAAI,MAAM,0BAA0B,CAC5E,CACF,CAEO,MAAMN,CAAgD,CAClD,KAAO,8BAChB,cAEA,YAAYM,EAAuB,CACjC,KAAK,cACHA,GAAiB,IAAI,MAAM,gCAAgC,CAC/D,CACF,CAEO,MAAMR,CAAoC,CACtC,KAAO,kBAChB,cAEA,YAAYQ,EAAuB,CACjC,KAAK,cACHA,GAAiB,IAAI,MAAM,wCAAwC,CACvE,CACF",
6
- "names": ["Errors_exports", "__export", "DeviceBusyError", "DeviceSessionNotFound", "DeviceSessionRefresherError", "FramerApduError", "FramerOverflowError", "ReceiverApduError", "__toCommonJS", "message", "originalError"]
4
+ "sourcesContent": ["import { type DmkError } from \"@api/Error\";\n\nexport class FramerOverflowError implements DmkError {\n readonly _tag = \"FramerOverflowError\";\n originalError?: Error;\n constructor() {\n this.originalError = new Error(\n \"Frame header length is greater than frame size\",\n );\n }\n}\n\nexport class FramerApduError implements DmkError {\n readonly _tag = \"FramerApduError\";\n originalError?: Error;\n\n constructor() {\n this.originalError = new Error(\"Frame offset is greater than apdu length\");\n }\n}\n\nexport class ReceiverApduError implements DmkError {\n readonly _tag = \"ReceiverApduError\";\n originalError: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unable to parse apdu\");\n }\n}\n\nexport class DeviceSessionNotFound implements DmkError {\n readonly _tag = \"DeviceSessionNotFound\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError = originalError ?? new Error(\"Device session not found\");\n }\n}\n\nexport class DeviceSessionRefresherError implements DmkError {\n readonly _tag = \"DeviceSessionRefresherError\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError =\n originalError ?? new Error(\"Device session refresher error\");\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,EAAA,gCAAAC,EAAA,oBAAAC,EAAA,wBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAP,GAEO,MAAMK,CAAwC,CAC1C,KAAO,sBAChB,cACA,aAAc,CACZ,KAAK,cAAgB,IAAI,MACvB,gDACF,CACF,CACF,CAEO,MAAMD,CAAoC,CACtC,KAAO,kBAChB,cAEA,aAAc,CACZ,KAAK,cAAgB,IAAI,MAAM,0CAA0C,CAC3E,CACF,CAEO,MAAME,CAAsC,CACxC,KAAO,oBAChB,cAEA,YAAYE,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,sBAAsB,CAClE,CACF,CAEO,MAAMN,CAA0C,CAC5C,KAAO,wBAChB,cAEA,YAAYO,EAAuB,CACjC,KAAK,cAAgBA,GAAiB,IAAI,MAAM,0BAA0B,CAC5E,CACF,CAEO,MAAMN,CAAgD,CAClD,KAAO,8BAChB,cAEA,YAAYM,EAAuB,CACjC,KAAK,cACHA,GAAiB,IAAI,MAAM,gCAAgC,CAC/D,CACF",
6
+ "names": ["Errors_exports", "__export", "DeviceSessionNotFound", "DeviceSessionRefresherError", "FramerApduError", "FramerOverflowError", "ReceiverApduError", "__toCommonJS", "message", "originalError"]
7
7
  }
@@ -8,11 +8,6 @@
8
8
  "types": "./lib/types/index.d.ts",
9
9
  "import": "./lib/esm/index.js",
10
10
  "require": "./lib/cjs/index.js"
11
- },
12
- "./*": {
13
- "types": "./lib/types/*",
14
- "import": "./lib/esm/*",
15
- "require": "./lib/cjs/*"
16
11
  }
17
12
  },
18
13
  "files": [
@@ -1,2 +1,2 @@
1
- class s{_tag;originalError;errorCode;message;constructor({tag:r,errorCode:o,originalError:n,message:i}){this._tag=r,this.originalError=n,this.errorCode=o,this.message=i??"An error occured during device exchange."}}class a{_tag="UnknownDeviceExchangeError";originalError;message;constructor(r){this.originalError=r,this.message="Unexpected device exchange error happened."}}export{s as DeviceExchangeError,a as UnknownDeviceExchangeError};
1
+ class s{_tag;originalError;errorCode;message;constructor({tag:r,errorCode:o,originalError:n,message:i}){this._tag=r,this.originalError=n,this.errorCode=o,this.message=i??"An error occured during device exchange."}}class a{_tag="UnknownDeviceExchangeError";originalError;message;constructor(r){this.originalError=r,this.message="Unexpected device exchange error happened."}}class c{_tag="DeviceBusyError";originalError;constructor(r){this.originalError=r??new Error("Device is busy, please try again later")}}export{c as DeviceBusyError,s as DeviceExchangeError,a as UnknownDeviceExchangeError};
2
2
  //# sourceMappingURL=Error.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/Error.ts"],
4
- "sourcesContent": ["export interface DmkError {\n readonly _tag: string;\n readonly originalError?: unknown;\n message?: string;\n}\n\nexport type DeviceExchangeErrorArgs<SpecificErrorCodes> = {\n tag: string;\n originalError?: unknown;\n errorCode: SpecificErrorCodes;\n message: string;\n};\n\nexport type CommandErrorArgs<SpecificErrorCodes> = Omit<\n DeviceExchangeErrorArgs<SpecificErrorCodes>,\n \"tag\"\n>;\n\nexport abstract class DeviceExchangeError<SpecificErrorCodes = void> {\n readonly _tag: string;\n readonly originalError?: unknown;\n readonly errorCode: SpecificErrorCodes;\n readonly message: string;\n\n protected constructor({\n tag,\n errorCode,\n originalError,\n message,\n }: DeviceExchangeErrorArgs<SpecificErrorCodes>) {\n this._tag = tag;\n this.originalError = originalError;\n this.errorCode = errorCode;\n this.message = message ?? \"An error occured during device exchange.\";\n }\n}\n\nexport class UnknownDeviceExchangeError implements DmkError {\n readonly _tag = \"UnknownDeviceExchangeError\";\n readonly originalError?: unknown;\n readonly message: string;\n\n constructor(originalError?: unknown) {\n this.originalError = originalError;\n this.message = \"Unexpected device exchange error happened.\";\n }\n}\n"],
5
- "mappings": "AAkBO,MAAeA,CAA+C,CAC1D,KACA,cACA,UACA,QAEC,YAAY,CACpB,IAAAC,EACA,UAAAC,EACA,cAAAC,EACA,QAAAC,CACF,EAAgD,CAC9C,KAAK,KAAOH,EACZ,KAAK,cAAgBE,EACrB,KAAK,UAAYD,EACjB,KAAK,QAAUE,GAAW,0CAC5B,CACF,CAEO,MAAMC,CAA+C,CACjD,KAAO,6BACP,cACA,QAET,YAAYF,EAAyB,CACnC,KAAK,cAAgBA,EACrB,KAAK,QAAU,4CACjB,CACF",
6
- "names": ["DeviceExchangeError", "tag", "errorCode", "originalError", "message", "UnknownDeviceExchangeError"]
4
+ "sourcesContent": ["export interface DmkError {\n readonly _tag: string;\n readonly originalError?: unknown;\n message?: string;\n}\n\nexport type DeviceExchangeErrorArgs<SpecificErrorCodes> = {\n tag: string;\n originalError?: unknown;\n errorCode: SpecificErrorCodes;\n message: string;\n};\n\nexport type CommandErrorArgs<SpecificErrorCodes> = Omit<\n DeviceExchangeErrorArgs<SpecificErrorCodes>,\n \"tag\"\n>;\n\nexport abstract class DeviceExchangeError<SpecificErrorCodes = void> {\n readonly _tag: string;\n readonly originalError?: unknown;\n readonly errorCode: SpecificErrorCodes;\n readonly message: string;\n\n protected constructor({\n tag,\n errorCode,\n originalError,\n message,\n }: DeviceExchangeErrorArgs<SpecificErrorCodes>) {\n this._tag = tag;\n this.originalError = originalError;\n this.errorCode = errorCode;\n this.message = message ?? \"An error occured during device exchange.\";\n }\n}\n\nexport class UnknownDeviceExchangeError implements DmkError {\n readonly _tag = \"UnknownDeviceExchangeError\";\n readonly originalError?: unknown;\n readonly message: string;\n\n constructor(originalError?: unknown) {\n this.originalError = originalError;\n this.message = \"Unexpected device exchange error happened.\";\n }\n}\n\nexport class DeviceBusyError implements DmkError {\n readonly _tag = \"DeviceBusyError\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError =\n originalError ?? new Error(\"Device is busy, please try again later\");\n }\n}\n"],
5
+ "mappings": "AAkBO,MAAeA,CAA+C,CAC1D,KACA,cACA,UACA,QAEC,YAAY,CACpB,IAAAC,EACA,UAAAC,EACA,cAAAC,EACA,QAAAC,CACF,EAAgD,CAC9C,KAAK,KAAOH,EACZ,KAAK,cAAgBE,EACrB,KAAK,UAAYD,EACjB,KAAK,QAAUE,GAAW,0CAC5B,CACF,CAEO,MAAMC,CAA+C,CACjD,KAAO,6BACP,cACA,QAET,YAAYF,EAAyB,CACnC,KAAK,cAAgBA,EACrB,KAAK,QAAU,4CACjB,CACF,CAEO,MAAMG,CAAoC,CACtC,KAAO,kBAChB,cAEA,YAAYH,EAAuB,CACjC,KAAK,cACHA,GAAiB,IAAI,MAAM,wCAAwC,CACvE,CACF",
6
+ "names": ["DeviceExchangeError", "tag", "errorCode", "originalError", "message", "UnknownDeviceExchangeError", "DeviceBusyError"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as a}from"purify-ts";import{BehaviorSubject as c}from"rxjs";import{v4 as p}from"uuid";import{CommandUtils as d}from"../../../api/command/utils/CommandUtils";import{DeviceStatus as i}from"../../../api/device/DeviceStatus";import{DeviceSessionStateType as v}from"../../../api/device-session/DeviceSessionState";import{DEVICE_SESSION_REFRESH_INTERVAL as u}from"../../device-session/data/DeviceSessionRefresherConst";import{DeviceSessionRefresher as S}from"./DeviceSessionRefresher";import{DeviceBusyError as m}from"./Errors";class R{_id;_connectedDevice;_deviceState;_refresher;_managerApiService;constructor({connectedDevice:e,id:s=p()},o,t){this._id=s,this._connectedDevice=e,this._deviceState=new c({sessionStateType:v.Connected,deviceStatus:i.CONNECTED}),this._refresher=new S({refreshInterval:u,deviceStatus:i.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id,sendApduFn:r=>this.sendApdu(r,{isPolling:!0,triggersDisconnection:!1}),updateStateFn:r=>{const n=this._deviceState.getValue();this.setDeviceSessionState(r(n))}},o("device-session-refresher")),this._managerApiService=t}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}setDeviceSessionState(e){this._deviceState.next(e)}updateDeviceStatus(e){const s=this._deviceState.getValue();this._refresher.setDeviceStatus(e),this._deviceState.next({...s,deviceStatus:e})}async sendApdu(e,s={isPolling:!1,triggersDisconnection:!1}){return this._deviceState.getValue().deviceStatus===i.BUSY?a(new m):(s.isPolling||this.updateDeviceStatus(i.BUSY),(await this._connectedDevice.sendApdu(e,s.triggersDisconnection)).ifRight(r=>{d.isLockedDeviceResponse(r)?this.updateDeviceStatus(i.LOCKED):this.updateDeviceStatus(i.CONNECTED)}).ifLeft(r=>{console.log("sendApduUseCase:Got error",r),this.updateDeviceStatus(i.CONNECTED)}))}async sendCommand(e){const s=e.getApdu();return(await this.sendApdu(s.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1})).caseOf({Left:t=>{throw t},Right:t=>e.parseResponse(t,this._connectedDevice.deviceModel.id)})}executeDeviceAction(e){const{observable:s,cancel:o}=e._execute({sendCommand:async t=>this.sendCommand(t),getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:t=>(this.setDeviceSessionState(t),this._deviceState.getValue()),getMetadataForAppHashes:t=>this._managerApiService.getAppsByHash(t)});return{observable:s,cancel:o}}close(){this.updateDeviceStatus(i.NOT_CONNECTED),this._deviceState.complete(),this._refresher.stop()}toggleRefresher(e){e?this._refresher.start():this._refresher.stop()}}export{R as DeviceSession};
1
+ import{Left as a}from"purify-ts";import{BehaviorSubject as c}from"rxjs";import{v4 as p}from"uuid";import{CommandUtils as d}from"../../../api/command/utils/CommandUtils";import{DeviceStatus as i}from"../../../api/device/DeviceStatus";import{DeviceSessionStateType as v}from"../../../api/device-session/DeviceSessionState";import{DeviceBusyError as u}from"../../../api/Error";import{DEVICE_SESSION_REFRESH_INTERVAL as S}from"../../device-session/data/DeviceSessionRefresherConst";import{DeviceSessionRefresher as m}from"./DeviceSessionRefresher";class R{_id;_connectedDevice;_deviceState;_refresher;_managerApiService;constructor({connectedDevice:e,id:s=p()},r,t){this._id=s,this._connectedDevice=e,this._deviceState=new c({sessionStateType:v.Connected,deviceStatus:i.CONNECTED}),this._refresher=new m({refreshInterval:S,deviceStatus:i.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id,sendApduFn:o=>this.sendApdu(o,{isPolling:!0,triggersDisconnection:!1}),updateStateFn:o=>{const n=this._deviceState.getValue();this.setDeviceSessionState(o(n))}},r("device-session-refresher")),this._managerApiService=t}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}setDeviceSessionState(e){this._deviceState.next(e)}updateDeviceStatus(e){const s=this._deviceState.getValue();this._refresher.setDeviceStatus(e),this._deviceState.next({...s,deviceStatus:e})}async sendApdu(e,s={isPolling:!1,triggersDisconnection:!1}){return this._deviceState.getValue().deviceStatus===i.BUSY?a(new u):(s.isPolling||this.updateDeviceStatus(i.BUSY),(await this._connectedDevice.sendApdu(e,s.triggersDisconnection)).ifRight(o=>{d.isLockedDeviceResponse(o)?this.updateDeviceStatus(i.LOCKED):this.updateDeviceStatus(i.CONNECTED)}).ifLeft(()=>{this.updateDeviceStatus(i.CONNECTED)}))}async sendCommand(e){const s=e.getApdu();return(await this.sendApdu(s.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1})).caseOf({Left:t=>{throw t},Right:t=>e.parseResponse(t,this._connectedDevice.deviceModel.id)})}executeDeviceAction(e){const{observable:s,cancel:r}=e._execute({sendCommand:async t=>this.sendCommand(t),getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:t=>(this.setDeviceSessionState(t),this._deviceState.getValue()),getMetadataForAppHashes:t=>this._managerApiService.getAppsByHash(t)});return{observable:s,cancel:r}}close(){this.updateDeviceStatus(i.NOT_CONNECTED),this._deviceState.complete(),this._refresher.stop()}toggleRefresher(e){e?this._refresher.start():this._refresher.stop()}}export{R as DeviceSession};
2
2
  //# sourceMappingURL=DeviceSession.js.map
@@ -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, Left } from \"purify-ts\";\nimport { BehaviorSubject } 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 { type ListAppsResponse } from \"@api/command/os/ListAppsCommand\";\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 { DEVICE_SESSION_REFRESH_INTERVAL } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceBusyError } from \"./Errors\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\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 _refresher: DeviceSessionRefresher;\n private readonly _managerApiService: ManagerApiService;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n });\n this._refresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n sendApduFn: (rawApdu: Uint8Array) =>\n this.sendApdu(rawApdu, {\n isPolling: true,\n triggersDisconnection: false,\n }),\n updateStateFn: (callback) => {\n const state = this._deviceState.getValue();\n this.setDeviceSessionState(callback(state));\n },\n },\n loggerModuleFactory(\"device-session-refresher\"),\n );\n this._managerApiService = managerApiService;\n }\n\n public get id() {\n return this._id;\n }\n\n public get connectedDevice() {\n return this._connectedDevice;\n }\n\n public get state() {\n return this._deviceState.asObservable();\n }\n\n public setDeviceSessionState(state: DeviceSessionState) {\n this._deviceState.next(state);\n }\n\n private updateDeviceStatus(deviceStatus: DeviceStatus) {\n const sessionState = this._deviceState.getValue();\n this._refresher.setDeviceStatus(deviceStatus);\n this._deviceState.next({\n ...sessionState,\n deviceStatus,\n });\n }\n\n async sendApdu(\n rawApdu: Uint8Array,\n options: {\n isPolling: boolean;\n triggersDisconnection: boolean;\n } = {\n isPolling: false,\n triggersDisconnection: false,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const sessionState = this._deviceState.getValue();\n if (sessionState.deviceStatus === DeviceStatus.BUSY) {\n return Left(new DeviceBusyError());\n }\n\n if (!options.isPolling) this.updateDeviceStatus(DeviceStatus.BUSY);\n\n const errorOrResponse = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n );\n\n return errorOrResponse\n .ifRight((response: ApduResponse) => {\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this.updateDeviceStatus(DeviceStatus.LOCKED);\n } else {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n }\n })\n .ifLeft((_error) => {\n console.log(\"sendApduUseCase:Got error\", _error);\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n });\n }\n\n async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n });\n\n return response.caseOf({\n Left: (err) => {\n throw err;\n },\n Right: (r) =>\n command.parseResponse(r, this._connectedDevice.deviceModel.id),\n });\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, Error, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n ) => this.sendCommand(command),\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n getMetadataForAppHashes: (apps: ListAppsResponse) =>\n this._managerApiService.getAppsByHash(apps),\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n close() {\n this.updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._refresher.stop();\n }\n\n toggleRefresher(enabled: boolean) {\n if (enabled) {\n this._refresher.start();\n } else {\n this._refresher.stop();\n }\n }\n}\n"],
5
- "mappings": "AAAA,OAAsB,QAAAA,MAAY,YAClC,OAAS,mBAAAC,MAAuB,OAChC,OAAS,MAAMC,MAAc,OAK7B,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,gBAAAC,MAAoB,2BAO7B,OAEE,0BAAAC,MACK,yCAKP,OAAS,mCAAAC,MAAuC,4DAGhD,OAAS,0BAAAC,MAA8B,2BACvC,OAAS,mBAAAC,MAAuB,WAUzB,MAAMC,CAAc,CACR,IACA,iBACA,aACA,WACA,mBAEjB,YACE,CAAE,gBAAAC,EAAiB,GAAAC,EAAKT,EAAO,CAAE,EACjCU,EACAC,EACA,CACA,KAAK,IAAMF,EACX,KAAK,iBAAmBD,EACxB,KAAK,aAAe,IAAIT,EAAoC,CAC1D,iBAAkBI,EAAuB,UACzC,aAAcD,EAAa,SAC7B,CAAC,EACD,KAAK,WAAa,IAAIG,EACpB,CACE,gBAAiBD,EACjB,aAAcF,EAAa,UAC3B,cAAe,KAAK,iBAAiB,YAAY,GACjD,WAAaU,GACX,KAAK,SAASA,EAAS,CACrB,UAAW,GACX,sBAAuB,EACzB,CAAC,EACH,cAAgBC,GAAa,CAC3B,MAAMC,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,sBAAsBD,EAASC,CAAK,CAAC,CAC5C,CACF,EACAJ,EAAoB,0BAA0B,CAChD,EACA,KAAK,mBAAqBC,CAC5B,CAEA,IAAW,IAAK,CACd,OAAO,KAAK,GACd,CAEA,IAAW,iBAAkB,CAC3B,OAAO,KAAK,gBACd,CAEA,IAAW,OAAQ,CACjB,OAAO,KAAK,aAAa,aAAa,CACxC,CAEO,sBAAsBG,EAA2B,CACtD,KAAK,aAAa,KAAKA,CAAK,CAC9B,CAEQ,mBAAmBC,EAA4B,CACrD,MAAMC,EAAe,KAAK,aAAa,SAAS,EAChD,KAAK,WAAW,gBAAgBD,CAAY,EA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,OAAQ,CACN,KAAK,mBAAmBxB,EAAa,aAAa,EAClD,KAAK,aAAa,SAAS,EAC3B,KAAK,WAAW,KAAK,CACvB,CAEA,gBAAgB0B,EAAkB,CAC5BA,EACF,KAAK,WAAW,MAAM,EAEtB,KAAK,WAAW,KAAK,CAEzB,CACF",
6
- "names": ["Left", "BehaviorSubject", "uuidv4", "CommandUtils", "DeviceStatus", "DeviceSessionStateType", "DEVICE_SESSION_REFRESH_INTERVAL", "DeviceSessionRefresher", "DeviceBusyError", "DeviceSession", "connectedDevice", "id", "loggerModuleFactory", "managerApiService", "rawApdu", "callback", "state", "deviceStatus", "sessionState", "options", "response", "_error", "command", "apdu", "err", "r", "deviceAction", "observable", "cancel", "apps", "enabled"]
4
+ "sourcesContent": ["import { type Either, Left } from \"purify-ts\";\nimport { BehaviorSubject } 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 { type ListAppsResponse } from \"@api/command/os/ListAppsCommand\";\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 { DeviceBusyError, type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport { DEVICE_SESSION_REFRESH_INTERVAL } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\n\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\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 _refresher: DeviceSessionRefresher;\n private readonly _managerApiService: ManagerApiService;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n });\n this._refresher = new DeviceSessionRefresher(\n {\n refreshInterval: DEVICE_SESSION_REFRESH_INTERVAL,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n sendApduFn: (rawApdu: Uint8Array) =>\n this.sendApdu(rawApdu, {\n isPolling: true,\n triggersDisconnection: false,\n }),\n updateStateFn: (callback) => {\n const state = this._deviceState.getValue();\n this.setDeviceSessionState(callback(state));\n },\n },\n loggerModuleFactory(\"device-session-refresher\"),\n );\n this._managerApiService = managerApiService;\n }\n\n public get id() {\n return this._id;\n }\n\n public get connectedDevice() {\n return this._connectedDevice;\n }\n\n public get state() {\n return this._deviceState.asObservable();\n }\n\n public setDeviceSessionState(state: DeviceSessionState) {\n this._deviceState.next(state);\n }\n\n private updateDeviceStatus(deviceStatus: DeviceStatus) {\n const sessionState = this._deviceState.getValue();\n this._refresher.setDeviceStatus(deviceStatus);\n this._deviceState.next({\n ...sessionState,\n deviceStatus,\n });\n }\n\n async sendApdu(\n rawApdu: Uint8Array,\n options: {\n isPolling: boolean;\n triggersDisconnection: boolean;\n } = {\n isPolling: false,\n triggersDisconnection: false,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n const sessionState = this._deviceState.getValue();\n if (sessionState.deviceStatus === DeviceStatus.BUSY) {\n return Left(new DeviceBusyError());\n }\n\n if (!options.isPolling) this.updateDeviceStatus(DeviceStatus.BUSY);\n\n const errorOrResponse = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n );\n\n return errorOrResponse\n .ifRight((response: ApduResponse) => {\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this.updateDeviceStatus(DeviceStatus.LOCKED);\n } else {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n }\n })\n .ifLeft(() => {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n });\n }\n\n async sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n const response = await this.sendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n });\n\n return response.caseOf({\n Left: (err) => {\n throw err;\n },\n Right: (r) =>\n command.parseResponse(r, this._connectedDevice.deviceModel.id),\n });\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, Error, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n ) => this.sendCommand(command),\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n getMetadataForAppHashes: (apps: ListAppsResponse) =>\n this._managerApiService.getAppsByHash(apps),\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n close() {\n this.updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._refresher.stop();\n }\n\n toggleRefresher(enabled: boolean) {\n if (enabled) {\n this._refresher.start();\n } else {\n this._refresher.stop();\n }\n }\n}\n"],
5
+ "mappings": "AAAA,OAAsB,QAAAA,MAAY,YAClC,OAAS,mBAAAC,MAAuB,OAChC,OAAS,MAAMC,MAAc,OAK7B,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,gBAAAC,MAAoB,2BAO7B,OAEE,0BAAAC,MACK,yCAEP,OAAS,mBAAAC,MAAsC,aAG/C,OAAS,mCAAAC,MAAuC,4DAGhD,OAAS,0BAAAC,MAA8B,2BAUhC,MAAMC,CAAc,CACR,IACA,iBACA,aACA,WACA,mBAEjB,YACE,CAAE,gBAAAC,EAAiB,GAAAC,EAAKT,EAAO,CAAE,EACjCU,EACAC,EACA,CACA,KAAK,IAAMF,EACX,KAAK,iBAAmBD,EACxB,KAAK,aAAe,IAAIT,EAAoC,CAC1D,iBAAkBI,EAAuB,UACzC,aAAcD,EAAa,SAC7B,CAAC,EACD,KAAK,WAAa,IAAII,EACpB,CACE,gBAAiBD,EACjB,aAAcH,EAAa,UAC3B,cAAe,KAAK,iBAAiB,YAAY,GACjD,WAAaU,GACX,KAAK,SAASA,EAAS,CACrB,UAAW,GACX,sBAAuB,EACzB,CAAC,EACH,cAAgBC,GAAa,CAC3B,MAAMC,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,sBAAsBD,EAASC,CAAK,CAAC,CAC5C,CACF,EACAJ,EAAoB,0BAA0B,CAChD,EACA,KAAK,mBAAqBC,CAC5B,CAEA,IAAW,IAAK,CACd,OAAO,KAAK,GACd,CAEA,IAAW,iBAAkB,CAC3B,OAAO,KAAK,gBACd,CAEA,IAAW,OAAQ,CACjB,OAAO,KAAK,aAAa,aAAa,CACxC,CAEO,sBAAsBG,EAA2B,CACtD,KAAK,aAAa,KAAKA,CAAK,CAC9B,CAEQ,mBAAmBC,EAA4B,CACrD,MAAMC,EAAe,KAAK,aAAa,SAAS,EA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,CACN,KAAK,mBAAmBvB,EAAa,aAAa,EAClD,KAAK,aAAa,SAAS,EAC3B,KAAK,WAAW,KAAK,CACvB,CAEA,gBAAgByB,EAAkB,CAC5BA,EACF,KAAK,WAAW,MAAM,EAEtB,KAAK,WAAW,KAAK,CAEzB,CACF",
6
+ "names": ["Left", "BehaviorSubject", "uuidv4", "CommandUtils", "DeviceStatus", "DeviceSessionStateType", "DeviceBusyError", "DEVICE_SESSION_REFRESH_INTERVAL", "DeviceSessionRefresher", "DeviceSession", "connectedDevice", "id", "loggerModuleFactory", "managerApiService", "rawApdu", "callback", "state", "deviceStatus", "sessionState", "options", "response", "command", "apdu", "err", "r", "deviceAction", "observable", "cancel", "apps", "enabled"]
7
7
  }
@@ -1,2 +1,2 @@
1
- class e{_tag="FramerOverflowError";originalError;constructor(){this.originalError=new Error("Frame header length is greater than frame size")}}class i{_tag="FramerApduError";originalError;constructor(){this.originalError=new Error("Frame offset is greater than apdu length")}}class s{_tag="ReceiverApduError";originalError;constructor(r){this.originalError=new Error(r??"Unable to parse apdu")}}class n{_tag="DeviceSessionNotFound";originalError;constructor(r){this.originalError=r??new Error("Device session not found")}}class t{_tag="DeviceSessionRefresherError";originalError;constructor(r){this.originalError=r??new Error("Device session refresher error")}}class a{_tag="DeviceBusyError";originalError;constructor(r){this.originalError=r??new Error("Device is busy, please try again later")}}export{a as DeviceBusyError,n as DeviceSessionNotFound,t as DeviceSessionRefresherError,i as FramerApduError,e as FramerOverflowError,s as ReceiverApduError};
1
+ class e{_tag="FramerOverflowError";originalError;constructor(){this.originalError=new Error("Frame header length is greater than frame size")}}class i{_tag="FramerApduError";originalError;constructor(){this.originalError=new Error("Frame offset is greater than apdu length")}}class s{_tag="ReceiverApduError";originalError;constructor(r){this.originalError=new Error(r??"Unable to parse apdu")}}class n{_tag="DeviceSessionNotFound";originalError;constructor(r){this.originalError=r??new Error("Device session not found")}}class t{_tag="DeviceSessionRefresherError";originalError;constructor(r){this.originalError=r??new Error("Device session refresher error")}}export{n as DeviceSessionNotFound,t as DeviceSessionRefresherError,i as FramerApduError,e as FramerOverflowError,s as ReceiverApduError};
2
2
  //# sourceMappingURL=Errors.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/device-session/model/Errors.ts"],
4
- "sourcesContent": ["import { type DmkError } from \"@root/src/api/Error\";\n\nexport class FramerOverflowError implements DmkError {\n readonly _tag = \"FramerOverflowError\";\n originalError?: Error;\n constructor() {\n this.originalError = new Error(\n \"Frame header length is greater than frame size\",\n );\n }\n}\n\nexport class FramerApduError implements DmkError {\n readonly _tag = \"FramerApduError\";\n originalError?: Error;\n\n constructor() {\n this.originalError = new Error(\"Frame offset is greater than apdu length\");\n }\n}\n\nexport class ReceiverApduError implements DmkError {\n readonly _tag = \"ReceiverApduError\";\n originalError: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unable to parse apdu\");\n }\n}\n\nexport class DeviceSessionNotFound implements DmkError {\n readonly _tag = \"DeviceSessionNotFound\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError = originalError ?? new Error(\"Device session not found\");\n }\n}\n\nexport class DeviceSessionRefresherError implements DmkError {\n readonly _tag = \"DeviceSessionRefresherError\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError =\n originalError ?? new Error(\"Device session refresher error\");\n }\n}\n\nexport class DeviceBusyError implements DmkError {\n readonly _tag = \"DeviceBusyError\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError =\n originalError ?? new Error(\"Device is busy, please try again later\");\n }\n}\n"],
5
- "mappings": "AAEO,MAAMA,CAAwC,CAC1C,KAAO,sBAChB,cACA,aAAc,CACZ,KAAK,cAAgB,IAAI,MACvB,gDACF,CACF,CACF,CAEO,MAAMC,CAAoC,CACtC,KAAO,kBAChB,cAEA,aAAc,CACZ,KAAK,cAAgB,IAAI,MAAM,0CAA0C,CAC3E,CACF,CAEO,MAAMC,CAAsC,CACxC,KAAO,oBAChB,cAEA,YAAYC,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,sBAAsB,CAClE,CACF,CAEO,MAAMC,CAA0C,CAC5C,KAAO,wBAChB,cAEA,YAAYC,EAAuB,CACjC,KAAK,cAAgBA,GAAiB,IAAI,MAAM,0BAA0B,CAC5E,CACF,CAEO,MAAMC,CAAgD,CAClD,KAAO,8BAChB,cAEA,YAAYD,EAAuB,CACjC,KAAK,cACHA,GAAiB,IAAI,MAAM,gCAAgC,CAC/D,CACF,CAEO,MAAME,CAAoC,CACtC,KAAO,kBAChB,cAEA,YAAYF,EAAuB,CACjC,KAAK,cACHA,GAAiB,IAAI,MAAM,wCAAwC,CACvE,CACF",
6
- "names": ["FramerOverflowError", "FramerApduError", "ReceiverApduError", "message", "DeviceSessionNotFound", "originalError", "DeviceSessionRefresherError", "DeviceBusyError"]
4
+ "sourcesContent": ["import { type DmkError } from \"@api/Error\";\n\nexport class FramerOverflowError implements DmkError {\n readonly _tag = \"FramerOverflowError\";\n originalError?: Error;\n constructor() {\n this.originalError = new Error(\n \"Frame header length is greater than frame size\",\n );\n }\n}\n\nexport class FramerApduError implements DmkError {\n readonly _tag = \"FramerApduError\";\n originalError?: Error;\n\n constructor() {\n this.originalError = new Error(\"Frame offset is greater than apdu length\");\n }\n}\n\nexport class ReceiverApduError implements DmkError {\n readonly _tag = \"ReceiverApduError\";\n originalError: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unable to parse apdu\");\n }\n}\n\nexport class DeviceSessionNotFound implements DmkError {\n readonly _tag = \"DeviceSessionNotFound\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError = originalError ?? new Error(\"Device session not found\");\n }\n}\n\nexport class DeviceSessionRefresherError implements DmkError {\n readonly _tag = \"DeviceSessionRefresherError\";\n originalError?: Error;\n\n constructor(originalError?: Error) {\n this.originalError =\n originalError ?? new Error(\"Device session refresher error\");\n }\n}\n"],
5
+ "mappings": "AAEO,MAAMA,CAAwC,CAC1C,KAAO,sBAChB,cACA,aAAc,CACZ,KAAK,cAAgB,IAAI,MACvB,gDACF,CACF,CACF,CAEO,MAAMC,CAAoC,CACtC,KAAO,kBAChB,cAEA,aAAc,CACZ,KAAK,cAAgB,IAAI,MAAM,0CAA0C,CAC3E,CACF,CAEO,MAAMC,CAAsC,CACxC,KAAO,oBAChB,cAEA,YAAYC,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,sBAAsB,CAClE,CACF,CAEO,MAAMC,CAA0C,CAC5C,KAAO,wBAChB,cAEA,YAAYC,EAAuB,CACjC,KAAK,cAAgBA,GAAiB,IAAI,MAAM,0BAA0B,CAC5E,CACF,CAEO,MAAMC,CAAgD,CAClD,KAAO,8BAChB,cAEA,YAAYD,EAAuB,CACjC,KAAK,cACHA,GAAiB,IAAI,MAAM,gCAAgC,CAC/D,CACF",
6
+ "names": ["FramerOverflowError", "FramerApduError", "ReceiverApduError", "message", "DeviceSessionNotFound", "originalError", "DeviceSessionRefresherError"]
7
7
  }
@@ -23,4 +23,9 @@ export declare class UnknownDeviceExchangeError implements DmkError {
23
23
  readonly message: string;
24
24
  constructor(originalError?: unknown);
25
25
  }
26
+ export declare class DeviceBusyError implements DmkError {
27
+ readonly _tag = "DeviceBusyError";
28
+ originalError?: Error;
29
+ constructor(originalError?: Error);
30
+ }
26
31
  //# sourceMappingURL=Error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../../../src/api/Error.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,uBAAuB,CAAC,kBAAkB,IAAI;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,OA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AC,kBAAkB,CAAC,EAC3C,KAAK,CACN,CAAC;AAEF,8BAAsB,mBAAmB,CAAC,kBAAkB,GAAG,IAAI;IACjE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,SAAS,aAAa,EACpB,GAAG,EACH,SAAS,EACT,aAAa,EACb,OAAO,GACR,EAAE,uBAAuB,CAAC,kBAAkB,CAAC;CAM/C;AAED,qBAAa,0BAA2B,YAAW,QAAQ;IACzD,QAAQ,CAAC,IAAI,gCAAgC;IAC7C,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,aAAa,CAAC,EAAE,OAAO;CAIpC;AAED,qBAAa,eAAgB,YAAW,QAAQ;IAC9C,QAAQ,CAAC,IAAI,qBAAqB;IAClC,aAAa,CAAC,EAAE,KAAK,CAAC;gBAEV,aAAa,CAAC,EAAE,KAAK;CAIlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceSession.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/device-session/model/DeviceSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,WAAW,CAAC;AAI9C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAItE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EACnC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE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BAAgB,CAAC,GACjD,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IAgBrD,mBAAmB,CACjB,MAAM,EACN,KAAK,EACL,KAAK,SAAS,QAAQ,EACtB,iBAAiB,SAAS,6BAA6B,EAEvD,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,CAAC,GAClE,6BAA6B,CAAC,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC;IAqBlE,KAAK;IAML,eAAe,CAAC,OAAO,EAAE,OAAO;CAOjC"}
1
+ {"version":3,"file":"DeviceSession.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/device-session/model/DeviceSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,WAAW,CAAC;AAI9C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAItE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EACnC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,sDAAsD,CAAC;AACnG,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAE9F,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AAIzF,MAAM,MAAM,sBAAsB,GAAG;IACnC,eAAe,EAAE,wBAAwB,CAAC;IAC1C,EAAE,CAAC,EAAE,eAAe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@ -1,4 +1,4 @@
1
- import { type DmkError } from "../../../../src/api/Error";
1
+ import { type DmkError } from "../../../api/Error";
2
2
  export declare class FramerOverflowError implements DmkError {
3
3
  readonly _tag = "FramerOverflowError";
4
4
  originalError?: Error;
@@ -24,9 +24,4 @@ export declare class DeviceSessionRefresherError implements DmkError {
24
24
  originalError?: Error;
25
25
  constructor(originalError?: Error);
26
26
  }
27
- export declare class DeviceBusyError implements DmkError {
28
- readonly _tag = "DeviceBusyError";
29
- originalError?: Error;
30
- constructor(originalError?: Error);
31
- }
32
27
  //# sourceMappingURL=Errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/device-session/model/Errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,qBAAa,mBAAoB,YAAW,QAAQ;IAClD,QAAQ,CAAC,IAAI,yBAAyB;IACtC,aAAa,CAAC,EAAE,KAAK,CAAC;;CAMvB;AAED,qBAAa,eAAgB,YAAW,QAAQ;IAC9C,QAAQ,CAAC,IAAI,qBAAqB;IAClC,aAAa,CAAC,EAAE,KAAK,CAAC;;CAKvB;AAED,qBAAa,iBAAkB,YAAW,QAAQ;IAChD,QAAQ,CAAC,IAAI,uBAAuB;IACpC,aAAa,EAAE,KAAK,CAAC;gBAET,OAAO,CAAC,EAAE,MAAM;CAG7B;AAED,qBAAa,qBAAsB,YAAW,QAAQ;IACpD,QAAQ,CAAC,IAAI,2BAA2B;IACxC,aAAa,CAAC,EAAE,KAAK,CAAC;gBAEV,aAAa,CAAC,EAAE,KAAK;CAGlC;AAED,qBAAa,2BAA4B,YAAW,QAAQ;IAC1D,QAAQ,CAAC,IAAI,iCAAiC;IAC9C,aAAa,CAAC,EAAE,KAAK,CAAC;gBAEV,aAAa,CAAC,EAAE,KAAK;CAIlC;AAED,qBAAa,eAAgB,YAAW,QAAQ;IAC9C,QAAQ,CAAC,IAA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