@ledgerhq/device-management-kit 0.0.0-develop-20250312001129 → 0.0.0-develop-20250313001141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +2 -2
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +2 -2
- package/lib/esm/package.json +2 -2
- package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +2 -2
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +3 -3
package/lib/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/device-management-kit",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@sentry/minimal": "^6.19.7",
|
|
36
|
-
"axios": "^1.
|
|
36
|
+
"axios": "^1.8.2",
|
|
37
37
|
"inversify": "^6.2.2",
|
|
38
38
|
"inversify-logger-middleware": "^3.1.0",
|
|
39
39
|
"isomorphic-ws": "^5.0.0",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var y=(n,e)=>{for(var i in e)c(n,i,{get:e[i],enumerable:!0})},A=(n,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of _(e))!C.call(n,t)&&t!==i&&c(n,t,{get:()=>e[t],enumerable:!(r=g(e,t))||r.enumerable});return n};var E=n=>A(c({},"__esModule",{value:!0}),n);var R={};y(R,{DeviceSession:()=>b});module.exports=E(R);var d=require("purify-ts"),p=require("rxjs"),v=require("uuid"),u=require("../../../api/command/utils/CommandUtils"),s=require("../../../api/device/DeviceStatus"),S=require("../../../api/device-session/DeviceSessionState"),l=require("../../../api/Error"),h=require("../../device-session/data/DeviceSessionRefresherConst"),m=require("../../device-session/service/RefresherService"),D=require("./DeviceSessionRefresher");class b{_id;_connectedDevice;_deviceState;_refresher;_refresherService;_managerApiService;_secureChannelService;constructor({connectedDevice:e,id:i=(0,v.v4)()},r,t,a){this._id=i,this._connectedDevice=e,this._deviceState=new p.BehaviorSubject({sessionStateType:S.DeviceSessionStateType.Connected,deviceStatus:s.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._refresher=new D.DeviceSessionRefresher({refreshInterval:h.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:s.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id,sendApduFn:o=>this.sendApdu(o,{isPolling:!0,triggersDisconnection:!1}),updateStateFn:o=>{const f=this._deviceState.getValue();this.setDeviceSessionState(o(f))}},r("device-session-refresher")),this._refresherService=new m.RefresherService(this._refresher),this._managerApiService=t,this._secureChannelService=a}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}setDeviceSessionState(e){this._deviceState.next(e)}async sendApdu(e,i={isPolling:!1,triggersDisconnection:!1}){let r;return i.isPolling||(r=this._refresherService.disableRefresher("sendApdu"),await this.waitUntilReady()),this._deviceState.getValue().deviceStatus===s.DeviceStatus.BUSY?(0,d.Left)(new l.DeviceBusyError):(this.updateDeviceStatus(s.DeviceStatus.BUSY),(await this._connectedDevice.sendApdu(e,i.triggersDisconnection)).ifRight(o=>{u.CommandUtils.isLockedDeviceResponse(o)?this.updateDeviceStatus(s.DeviceStatus.LOCKED):this.updateDeviceStatus(s.DeviceStatus.CONNECTED),!i.isPolling&&r&&r()}).ifLeft(()=>{this.updateDeviceStatus(s.DeviceStatus.CONNECTED),!i.isPolling&&r&&r()}))}async sendCommand(e){const i=e.getApdu();return(await this.sendApdu(i.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:i,cancel:r}=e._execute({sendApdu:async t=>this.sendApdu(t),sendCommand:async t=>this.sendCommand(t),getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:t=>(this.setDeviceSessionState(t),this._deviceState.getValue()),disableRefresher:t=>this._refresherService.disableRefresher(t),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService});return{observable:i,cancel:r}}close(){this.updateDeviceStatus(s.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._refresher.stop()}disableRefresher(e){return this._refresherService.disableRefresher(e)}updateDeviceStatus(e){const i=this._deviceState.getValue();this._refresher.setDeviceStatus(e),this._deviceState.next({...i,deviceStatus:e})}async waitUntilReady(){let e;await new Promise(i=>{e=this._deviceState.subscribe(r=>{
|
|
1
|
+
"use strict";var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var y=(n,e)=>{for(var i in e)c(n,i,{get:e[i],enumerable:!0})},A=(n,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of _(e))!C.call(n,t)&&t!==i&&c(n,t,{get:()=>e[t],enumerable:!(r=g(e,t))||r.enumerable});return n};var E=n=>A(c({},"__esModule",{value:!0}),n);var R={};y(R,{DeviceSession:()=>b});module.exports=E(R);var d=require("purify-ts"),p=require("rxjs"),v=require("uuid"),u=require("../../../api/command/utils/CommandUtils"),s=require("../../../api/device/DeviceStatus"),S=require("../../../api/device-session/DeviceSessionState"),l=require("../../../api/Error"),h=require("../../device-session/data/DeviceSessionRefresherConst"),m=require("../../device-session/service/RefresherService"),D=require("./DeviceSessionRefresher");class b{_id;_connectedDevice;_deviceState;_refresher;_refresherService;_managerApiService;_secureChannelService;constructor({connectedDevice:e,id:i=(0,v.v4)()},r,t,a){this._id=i,this._connectedDevice=e,this._deviceState=new p.BehaviorSubject({sessionStateType:S.DeviceSessionStateType.Connected,deviceStatus:s.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._refresher=new D.DeviceSessionRefresher({refreshInterval:h.DEVICE_SESSION_REFRESH_INTERVAL,deviceStatus:s.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id,sendApduFn:o=>this.sendApdu(o,{isPolling:!0,triggersDisconnection:!1}),updateStateFn:o=>{const f=this._deviceState.getValue();this.setDeviceSessionState(o(f))}},r("device-session-refresher")),this._refresherService=new m.RefresherService(this._refresher),this._managerApiService=t,this._secureChannelService=a}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}setDeviceSessionState(e){this._deviceState.next(e)}async sendApdu(e,i={isPolling:!1,triggersDisconnection:!1}){let r;return i.isPolling||(r=this._refresherService.disableRefresher("sendApdu"),await this.waitUntilReady()),this._deviceState.getValue().deviceStatus===s.DeviceStatus.BUSY?(0,d.Left)(new l.DeviceBusyError):(this.updateDeviceStatus(s.DeviceStatus.BUSY),(await this._connectedDevice.sendApdu(e,i.triggersDisconnection)).ifRight(o=>{u.CommandUtils.isLockedDeviceResponse(o)?this.updateDeviceStatus(s.DeviceStatus.LOCKED):this.updateDeviceStatus(s.DeviceStatus.CONNECTED),!i.isPolling&&r&&r()}).ifLeft(()=>{this.updateDeviceStatus(s.DeviceStatus.CONNECTED),!i.isPolling&&r&&r()}))}async sendCommand(e){const i=e.getApdu();return(await this.sendApdu(i.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:i,cancel:r}=e._execute({sendApdu:async t=>this.sendApdu(t),sendCommand:async t=>this.sendCommand(t),getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:t=>(this.setDeviceSessionState(t),this._deviceState.getValue()),disableRefresher:t=>this._refresherService.disableRefresher(t),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService});return{observable:i,cancel:r}}close(){this.updateDeviceStatus(s.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._refresher.stop()}disableRefresher(e){return this._refresherService.disableRefresher(e)}updateDeviceStatus(e){const i=this._deviceState.getValue();this._refresher.setDeviceStatus(e),this._deviceState.next({...i,deviceStatus:e})}async waitUntilReady(){let e;await new Promise(i=>{e=this._deviceState.subscribe(r=>{[s.DeviceStatus.LOCKED,s.DeviceStatus.CONNECTED].includes(r.deviceStatus)&&(e?.unsubscribe(),i())})})}}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, type Subscription } 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 { 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 { 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 { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\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 _refresherService: RefresherService;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\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._refresherService = new RefresherService(this._refresher);\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\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 public async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n let reenableRefresher: () => void;\n if (!options.isPolling) {\n reenableRefresher = this._refresherService.disableRefresher(\"sendApdu\");\n await this.waitUntilReady();\n }\n\n const sessionState = this._deviceState.getValue();\n if (sessionState.deviceStatus === DeviceStatus.BUSY) {\n return Left(new DeviceBusyError());\n }\n\n 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 if (!options.isPolling && reenableRefresher) {\n reenableRefresher();\n }\n })\n .ifLeft(() => {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n\n if (!options.isPolling && reenableRefresher) {\n reenableRefresher();\n }\n });\n }\n\n public 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 public 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 sendApdu: async (apdu: Uint8Array) => this.sendApdu(apdu),\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 disableRefresher: (blockerId: string) =>\n this._refresherService.disableRefresher(blockerId),\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n public close() {\n this.updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._refresher.stop();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\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 private async waitUntilReady() {\n let deviceStateSub: Subscription;\n\n await new Promise<void>((resolve) => {\n deviceStateSub = this._deviceState.subscribe((state) => {\n if (
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkC,qBAClCC,EAAmD,gBACnDC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAEPC,EAA+C,sBAG/CC,EAAgD,qEAChDC,EAAiC,6DAIjCC,EAAuC,oCAehC,MAAMX,CAAc,CACR,IACA,iBACA,aAC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MC,EAAe,KAAK,aAAa,SAAS,EAChD,KAAK,WAAW,gBAAgBD,CAAY,EAC5C,KAAK,aAAa,KAAK,CACrB,GAAGC,EACH,aAAAD,CACF,CAAC,CACH,CAEA,MAAc,gBAAiB,CAC7B,IAAIE,EAEJ,MAAM,IAAI,QAAeC,GAAY,CACnCD,EAAiB,KAAK,aAAa,UAAWd,GAAU,
|
|
4
|
+
"sourcesContent": ["import { type Either, Left } from \"purify-ts\";\nimport { BehaviorSubject, type Subscription } 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 { 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 { 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 { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\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 _refresherService: RefresherService;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\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._refresherService = new RefresherService(this._refresher);\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\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 public async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n let reenableRefresher: () => void;\n if (!options.isPolling) {\n reenableRefresher = this._refresherService.disableRefresher(\"sendApdu\");\n await this.waitUntilReady();\n }\n\n const sessionState = this._deviceState.getValue();\n if (sessionState.deviceStatus === DeviceStatus.BUSY) {\n return Left(new DeviceBusyError());\n }\n\n 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 if (!options.isPolling && reenableRefresher) {\n reenableRefresher();\n }\n })\n .ifLeft(() => {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n\n if (!options.isPolling && reenableRefresher) {\n reenableRefresher();\n }\n });\n }\n\n public 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 public 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 sendApdu: async (apdu: Uint8Array) => this.sendApdu(apdu),\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 disableRefresher: (blockerId: string) =>\n this._refresherService.disableRefresher(blockerId),\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n public close() {\n this.updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._refresher.stop();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\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 private async waitUntilReady() {\n let deviceStateSub: Subscription;\n\n await new Promise<void>((resolve) => {\n deviceStateSub = this._deviceState.subscribe((state) => {\n if (\n [DeviceStatus.LOCKED, DeviceStatus.CONNECTED].includes(\n state.deviceStatus,\n )\n ) {\n deviceStateSub?.unsubscribe();\n resolve();\n }\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkC,qBAClCC,EAAmD,gBACnDC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAEPC,EAA+C,sBAG/CC,EAAgD,qEAChDC,EAAiC,6DAIjCC,EAAuC,oCAehC,MAAMX,CAAc,CACR,IACA,iBACA,aACA,WACA,kBACA,mBACA,sBAEjB,YACE,CAAE,gBAAAY,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjCC,EACAC,EACAC,EACA,CACA,KAAK,IAAMJ,EACX,KAAK,iBAAmBD,EACxB,KAAK,aAAe,IAAI,kBAAoC,CAC1D,iBAAkB,yBAAuB,UACzC,aAAc,eAAa,UAC3B,cAAe,KAAK,iBAAiB,YAAY,EACnD,CAAC,EACD,KAAK,WAAa,IAAI,yBACpB,CACE,gBAAiB,kCACjB,aAAc,eAAa,UAC3B,cAAe,KAAK,iBAAiB,YAAY,GACjD,WAAaM,GACX,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["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_purify_ts", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_Error", "import_DeviceSessionRefresherConst", "import_RefresherService", "import_DeviceSessionRefresher", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "secureChannelService", "rawApdu", "callback", "state", "options", "reenableRefresher", "response", "command", "apdu", "err", "r", "deviceAction", "observable", "cancel", "blockerId", "deviceStatus", "sessionState", "deviceStateSub", "resolve"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/device-management-kit",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@sentry/minimal": "^6.19.7",
|
|
36
|
-
"axios": "^1.
|
|
36
|
+
"axios": "^1.8.2",
|
|
37
37
|
"inversify": "^6.2.2",
|
|
38
38
|
"inversify-logger-middleware": "^3.1.0",
|
|
39
39
|
"isomorphic-ws": "^5.0.0",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as a}from"purify-ts";import{BehaviorSubject as d}from"rxjs";import{v4 as p}from"uuid";import{CommandUtils as v}from"../../../api/command/utils/CommandUtils";import{DeviceStatus as s}from"../../../api/device/DeviceStatus";import{DeviceSessionStateType as u}from"../../../api/device-session/DeviceSessionState";import{DeviceBusyError as S}from"../../../api/Error";import{DEVICE_SESSION_REFRESH_INTERVAL as l}from"../../device-session/data/DeviceSessionRefresherConst";import{RefresherService as h}from"../../device-session/service/RefresherService";import{DeviceSessionRefresher as m}from"./DeviceSessionRefresher";class I{_id;_connectedDevice;_deviceState;_refresher;_refresherService;_managerApiService;_secureChannelService;constructor({connectedDevice:e,id:t=p()},r,i,o){this._id=t,this._connectedDevice=e,this._deviceState=new d({sessionStateType:u.Connected,deviceStatus:s.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._refresher=new m({refreshInterval:l,deviceStatus:s.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id,sendApduFn:n=>this.sendApdu(n,{isPolling:!0,triggersDisconnection:!1}),updateStateFn:n=>{const c=this._deviceState.getValue();this.setDeviceSessionState(n(c))}},r("device-session-refresher")),this._refresherService=new h(this._refresher),this._managerApiService=i,this._secureChannelService=o}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}setDeviceSessionState(e){this._deviceState.next(e)}async sendApdu(e,t={isPolling:!1,triggersDisconnection:!1}){let r;return t.isPolling||(r=this._refresherService.disableRefresher("sendApdu"),await this.waitUntilReady()),this._deviceState.getValue().deviceStatus===s.BUSY?a(new S):(this.updateDeviceStatus(s.BUSY),(await this._connectedDevice.sendApdu(e,t.triggersDisconnection)).ifRight(n=>{v.isLockedDeviceResponse(n)?this.updateDeviceStatus(s.LOCKED):this.updateDeviceStatus(s.CONNECTED),!t.isPolling&&r&&r()}).ifLeft(()=>{this.updateDeviceStatus(s.CONNECTED),!t.isPolling&&r&&r()}))}async sendCommand(e){const t=e.getApdu();return(await this.sendApdu(t.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1})).caseOf({Left:i=>{throw i},Right:i=>e.parseResponse(i,this._connectedDevice.deviceModel.id)})}executeDeviceAction(e){const{observable:t,cancel:r}=e._execute({sendApdu:async i=>this.sendApdu(i),sendCommand:async i=>this.sendCommand(i),getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:i=>(this.setDeviceSessionState(i),this._deviceState.getValue()),disableRefresher:i=>this._refresherService.disableRefresher(i),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService});return{observable:t,cancel:r}}close(){this.updateDeviceStatus(s.NOT_CONNECTED),this._deviceState.complete(),this._refresher.stop()}disableRefresher(e){return this._refresherService.disableRefresher(e)}updateDeviceStatus(e){const t=this._deviceState.getValue();this._refresher.setDeviceStatus(e),this._deviceState.next({...t,deviceStatus:e})}async waitUntilReady(){let e;await new Promise(t=>{e=this._deviceState.subscribe(r=>{
|
|
1
|
+
import{Left as a}from"purify-ts";import{BehaviorSubject as d}from"rxjs";import{v4 as p}from"uuid";import{CommandUtils as v}from"../../../api/command/utils/CommandUtils";import{DeviceStatus as s}from"../../../api/device/DeviceStatus";import{DeviceSessionStateType as u}from"../../../api/device-session/DeviceSessionState";import{DeviceBusyError as S}from"../../../api/Error";import{DEVICE_SESSION_REFRESH_INTERVAL as l}from"../../device-session/data/DeviceSessionRefresherConst";import{RefresherService as h}from"../../device-session/service/RefresherService";import{DeviceSessionRefresher as m}from"./DeviceSessionRefresher";class I{_id;_connectedDevice;_deviceState;_refresher;_refresherService;_managerApiService;_secureChannelService;constructor({connectedDevice:e,id:t=p()},r,i,o){this._id=t,this._connectedDevice=e,this._deviceState=new d({sessionStateType:u.Connected,deviceStatus:s.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._refresher=new m({refreshInterval:l,deviceStatus:s.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id,sendApduFn:n=>this.sendApdu(n,{isPolling:!0,triggersDisconnection:!1}),updateStateFn:n=>{const c=this._deviceState.getValue();this.setDeviceSessionState(n(c))}},r("device-session-refresher")),this._refresherService=new h(this._refresher),this._managerApiService=i,this._secureChannelService=o}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}setDeviceSessionState(e){this._deviceState.next(e)}async sendApdu(e,t={isPolling:!1,triggersDisconnection:!1}){let r;return t.isPolling||(r=this._refresherService.disableRefresher("sendApdu"),await this.waitUntilReady()),this._deviceState.getValue().deviceStatus===s.BUSY?a(new S):(this.updateDeviceStatus(s.BUSY),(await this._connectedDevice.sendApdu(e,t.triggersDisconnection)).ifRight(n=>{v.isLockedDeviceResponse(n)?this.updateDeviceStatus(s.LOCKED):this.updateDeviceStatus(s.CONNECTED),!t.isPolling&&r&&r()}).ifLeft(()=>{this.updateDeviceStatus(s.CONNECTED),!t.isPolling&&r&&r()}))}async sendCommand(e){const t=e.getApdu();return(await this.sendApdu(t.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1})).caseOf({Left:i=>{throw i},Right:i=>e.parseResponse(i,this._connectedDevice.deviceModel.id)})}executeDeviceAction(e){const{observable:t,cancel:r}=e._execute({sendApdu:async i=>this.sendApdu(i),sendCommand:async i=>this.sendCommand(i),getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:i=>(this.setDeviceSessionState(i),this._deviceState.getValue()),disableRefresher:i=>this._refresherService.disableRefresher(i),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService});return{observable:t,cancel:r}}close(){this.updateDeviceStatus(s.NOT_CONNECTED),this._deviceState.complete(),this._refresher.stop()}disableRefresher(e){return this._refresherService.disableRefresher(e)}updateDeviceStatus(e){const t=this._deviceState.getValue();this._refresher.setDeviceStatus(e),this._deviceState.next({...t,deviceStatus:e})}async waitUntilReady(){let e;await new Promise(t=>{e=this._deviceState.subscribe(r=>{[s.LOCKED,s.CONNECTED].includes(r.deviceStatus)&&(e?.unsubscribe(),t())})})}}export{I 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, type Subscription } 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 { 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 { 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 { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\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 _refresherService: RefresherService;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\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._refresherService = new RefresherService(this._refresher);\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\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 public async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n let reenableRefresher: () => void;\n if (!options.isPolling) {\n reenableRefresher = this._refresherService.disableRefresher(\"sendApdu\");\n await this.waitUntilReady();\n }\n\n const sessionState = this._deviceState.getValue();\n if (sessionState.deviceStatus === DeviceStatus.BUSY) {\n return Left(new DeviceBusyError());\n }\n\n 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 if (!options.isPolling && reenableRefresher) {\n reenableRefresher();\n }\n })\n .ifLeft(() => {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n\n if (!options.isPolling && reenableRefresher) {\n reenableRefresher();\n }\n });\n }\n\n public 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 public 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 sendApdu: async (apdu: Uint8Array) => this.sendApdu(apdu),\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 disableRefresher: (blockerId: string) =>\n this._refresherService.disableRefresher(blockerId),\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n public close() {\n this.updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._refresher.stop();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\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 private async waitUntilReady() {\n let deviceStateSub: Subscription;\n\n await new Promise<void>((resolve) => {\n deviceStateSub = this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,GAEpC,iBAAmBW,GACjB,KAAK,kBAAkB,iBAAiBA,CAAS,EACnD,qBAAsB,IAAM,KAAK,mBACjC,wBAAyB,IAAM,KAAK,qBACtC,CAAC,EAED,MAAO,CACL,WAAAF,EACA,OAAAC,CACF,CACF,CAEO,OAAQ,CACb,KAAK,mBAAmBxB,EAAa,aAAa,EAClD,KAAK,aAAa,SAAS,EAC3B,KAAK,WAAW,KAAK,CACvB,CAEO,iBAAiBQ,EAAwB,CAC9C,OAAO,KAAK,kBAAkB,iBAAiBA,CAAE,CACnD,CAEQ,mBAAmBkB,EAA4B,CACrD,MAAMC,EAAe,KAAK,aAAa,SAAS,EAChD,KAAK,WAAW,gBAAgBD,CAAY,EAC5C,KAAK,aAAa,KAAK,CACrB,GAAGC,EACH,aAAAD,CACF,CAAC,CACH,CAEA,MAAc,gBAAiB,CAC7B,IAAIE,EAEJ,MAAM,IAAI,QAAeC,GAAY,CACnCD,EAAiB,KAAK,aAAa,UAAWd,GAAU,
|
|
4
|
+
"sourcesContent": ["import { type Either, Left } from \"purify-ts\";\nimport { BehaviorSubject, type Subscription } 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 { 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 { 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 { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\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 _refresherService: RefresherService;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\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._refresherService = new RefresherService(this._refresher);\n this._managerApiService = managerApiService;\n this._secureChannelService = secureChannelService;\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 public async sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n let reenableRefresher: () => void;\n if (!options.isPolling) {\n reenableRefresher = this._refresherService.disableRefresher(\"sendApdu\");\n await this.waitUntilReady();\n }\n\n const sessionState = this._deviceState.getValue();\n if (sessionState.deviceStatus === DeviceStatus.BUSY) {\n return Left(new DeviceBusyError());\n }\n\n 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 if (!options.isPolling && reenableRefresher) {\n reenableRefresher();\n }\n })\n .ifLeft(() => {\n this.updateDeviceStatus(DeviceStatus.CONNECTED);\n\n if (!options.isPolling && reenableRefresher) {\n reenableRefresher();\n }\n });\n }\n\n public 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 public 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 sendApdu: async (apdu: Uint8Array) => this.sendApdu(apdu),\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 disableRefresher: (blockerId: string) =>\n this._refresherService.disableRefresher(blockerId),\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n public close() {\n this.updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._refresher.stop();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\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 private async waitUntilReady() {\n let deviceStateSub: Subscription;\n\n await new Promise<void>((resolve) => {\n deviceStateSub = this._deviceState.subscribe((state) => {\n if (\n [DeviceStatus.LOCKED, DeviceStatus.CONNECTED].includes(\n state.deviceStatus,\n )\n ) {\n deviceStateSub?.unsubscribe();\n resolve();\n }\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAsB,QAAAA,MAAY,YAClC,OAAS,mBAAAC,MAA0C,OACnD,OAAS,MAAMC,MAAc,OAI7B,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,gBAAAC,MAAoB,2BAO7B,OAEE,0BAAAC,MACK,yCAEP,OAAS,mBAAAC,MAAsC,aAG/C,OAAS,mCAAAC,MAAuC,4DAChD,OAAS,oBAAAC,MAAwB,oDAIjC,OAAS,0BAAAC,MAA8B,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BA,CAAE,CACnD,CAEQ,mBAAmBkB,EAA4B,CACrD,MAAMC,EAAe,KAAK,aAAa,SAAS,EAChD,KAAK,WAAW,gBAAgBD,CAAY,EAC5C,KAAK,aAAa,KAAK,CACrB,GAAGC,EACH,aAAAD,CACF,CAAC,CACH,CAEA,MAAc,gBAAiB,CAC7B,IAAIE,EAEJ,MAAM,IAAI,QAAeC,GAAY,CACnCD,EAAiB,KAAK,aAAa,UAAWd,GAAU,CAEpD,CAACd,EAAa,OAAQA,EAAa,SAAS,EAAE,SAC5Cc,EAAM,YACR,IAEAc,GAAgB,YAAY,EAC5BC,EAAQ,EAEZ,CAAC,CACH,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["Left", "BehaviorSubject", "uuidv4", "CommandUtils", "DeviceStatus", "DeviceSessionStateType", "DeviceBusyError", "DEVICE_SESSION_REFRESH_INTERVAL", "RefresherService", "DeviceSessionRefresher", "DeviceSession", "connectedDevice", "id", "loggerModuleFactory", "managerApiService", "secureChannelService", "rawApdu", "callback", "state", "options", "reenableRefresher", "response", "command", "apdu", "err", "r", "deviceAction", "observable", "cancel", "blockerId", "deviceStatus", "sessionState", "deviceStateSub", "resolve"]
|
|
7
7
|
}
|
|
@@ -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;AAGtE,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,M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kBAAkB;IAIzC,QAAQ,CACnB,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE,eAGR,GACA,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAwC7B,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,gBAAgB,EACvD,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,gBAAgB,CAAC,GACjD,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IAgB9C,mBAAmB,CACxB,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;IAwB3D,KAAK;IAML,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,IAAI;IAI/C,OAAO,CAAC,kBAAkB;YASZ,cAAc;
|
|
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;AAGtE,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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