@ledgerhq/device-management-kit 0.0.0-develop-20260210001806 → 0.0.0-develop-20260211001836

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/lib/cjs/package.json +1 -1
  2. package/lib/cjs/src/api/device-action/DeviceAction.js +1 -1
  3. package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
  4. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  5. package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  6. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  7. package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  8. package/lib/cjs/src/api/index.js +1 -1
  9. package/lib/cjs/src/api/index.js.map +3 -3
  10. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
  11. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
  12. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
  13. package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
  14. package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
  15. package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +2 -2
  16. package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js +1 -1
  17. package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js.map +2 -2
  18. package/lib/esm/package.json +1 -1
  19. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
  20. package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
  21. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
  22. package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
  23. package/lib/esm/src/api/index.js +1 -1
  24. package/lib/esm/src/api/index.js.map +3 -3
  25. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
  26. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
  27. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
  28. package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
  29. package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
  30. package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +2 -2
  31. package/lib/esm/src/internal/device-session/model/DeviceSession.test.js +1 -1
  32. package/lib/esm/src/internal/device-session/model/DeviceSession.test.js.map +2 -2
  33. package/lib/types/src/api/device-action/DeviceAction.d.ts +2 -0
  34. package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
  35. package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
  36. package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts +10 -1
  37. package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts.map +1 -1
  38. package/lib/types/src/api/index.d.ts +1 -0
  39. package/lib/types/src/api/index.d.ts.map +1 -1
  40. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts +12 -0
  41. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts.map +1 -0
  42. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts +2 -0
  43. package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts.map +1 -0
  44. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +1 -0
  45. package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
  46. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  47. package/package.json +4 -4
@@ -64,5 +64,5 @@
64
64
  "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
65
65
  "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
66
66
  },
67
- "version": "0.0.0-develop-20260210001806"
67
+ "version": "0.0.0-develop-20260211001836"
68
68
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var m=(r,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!s.call(r,t)&&t!==i&&n(r,t,{get:()=>e[t],enumerable:!(o=a(e,t))||o.enumerable});return r};var c=r=>m(n({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
1
+ "use strict";var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var m=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!s.call(r,t)&&t!==n&&i(r,t,{get:()=>e[t],enumerable:!(o=a(e,t))||o.enumerable});return r};var c=r=>m(i({},"__esModule",{value:!0}),r);var d={};module.exports=c(d);
2
2
  //# sourceMappingURL=DeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/api/device-action/DeviceAction.ts"],
4
- "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { type DeviceActionState } from \"./model/DeviceActionState\";\n\nexport type InternalApi = {\n readonly sendApdu: (\n apdu: Uint8Array,\n ) => Promise<Either<DmkError, ApduResponse>>;\n readonly sendCommand: <Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\n readonly getDeviceModel: () => TransportDeviceModel;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly getDeviceSessionStateObservable: () => Observable<DeviceSessionState>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly getManagerApiService: () => ManagerApiService;\n readonly getSecureChannelService: () => SecureChannelService;\n};\n\nexport type DeviceActionIntermediateValue = {\n readonly requiredUserInteraction: string;\n};\n\nexport type ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> = {\n readonly observable: Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >;\n cancel(): void;\n};\n\nexport interface DeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n> {\n readonly input: Input;\n\n _execute(\n params: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue>;\n}\n"],
4
+ "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport { type Observable } from \"rxjs\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { type TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { type DeviceActionState } from \"./model/DeviceActionState\";\n\nexport type InternalApi = {\n readonly sendApdu: (\n apdu: Uint8Array,\n ) => Promise<Either<DmkError, ApduResponse>>;\n readonly sendCommand: <Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ) => Promise<CommandResult<Response, ErrorStatusCodes>>;\n readonly getDeviceModel: () => TransportDeviceModel;\n readonly getDeviceSessionState: () => DeviceSessionState;\n readonly getDeviceSessionStateObservable: () => Observable<DeviceSessionState>;\n readonly setDeviceSessionState: (\n state: DeviceSessionState,\n ) => DeviceSessionState;\n readonly getManagerApiService: () => ManagerApiService;\n readonly getSecureChannelService: () => SecureChannelService;\n readonly loggerFactory?: (tag: string) => LoggerPublisherService;\n};\n\nexport type DeviceActionIntermediateValue = {\n readonly requiredUserInteraction: string;\n};\n\nexport type ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> = {\n readonly observable: Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >;\n cancel(): void;\n};\n\nexport interface DeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n> {\n readonly input: Input;\n\n _execute(\n params: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue>;\n}\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["DeviceAction_exports", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var r=(n,e)=>{for(var i in e)c(n,i,{get:e[i],enumerable:!0})},S=(n,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of a(e))!v.call(n,t)&&t!==i&&c(n,t,{get:()=>e[t],enumerable:!(o=s(e,t))||o.enumerable});return n};var p=n=>S(c({},"__esModule",{value:!0}),n);var u={};r(u,{makeDeviceActionInternalApiMock:()=>A});module.exports=p(u);const M=vi.fn(),d=vi.fn(),k=vi.fn(),f=vi.fn(),g=vi.fn(),l=vi.fn(),m=vi.fn(),D=vi.fn();function A(){return{sendApdu:M,sendCommand:d,getDeviceModel:k,getDeviceSessionState:f,getDeviceSessionStateObservable:g,setDeviceSessionState:l,getManagerApiService:m,getSecureChannelService:D}}0&&(module.exports={makeDeviceActionInternalApiMock});
1
+ "use strict";var i=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var S=(e,t)=>{for(var o in t)i(e,o,{get:t[o],enumerable:!0})},p=(e,t,o,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of a(t))!v.call(e,n)&&n!==o&&i(e,n,{get:()=>t[n],enumerable:!(c=r(t,n))||c.enumerable});return e};var M=e=>p(i({},"__esModule",{value:!0}),e);var y={};S(y,{makeDeviceActionInternalApiMock:()=>b});module.exports=M(y);var s=require("../../../internal/logger-publisher/service/DefaultLoggerPublisherService");const g=vi.fn(),f=vi.fn(),k=vi.fn(),l=vi.fn(),d=vi.fn(),m=vi.fn(),D=vi.fn(),u=vi.fn(),A=vi.fn(e=>new s.DefaultLoggerPublisherService([],e));function b(){return{sendApdu:g,sendCommand:f,getDeviceModel:k,getDeviceSessionState:l,getDeviceSessionStateObservable:d,setDeviceSessionState:m,getManagerApiService:D,getSecureChannelService:u,loggerFactory:A}}0&&(module.exports={makeDeviceActionInternalApiMock});
2
2
  //# sourceMappingURL=makeInternalApi.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/__test-utils__/makeInternalApi.ts"],
4
- "sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\n\nconst sendApduMock = vi.fn();\nconst sendCommandMock = vi.fn();\nconst apiGetDeviceModelMock = vi.fn();\nconst apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\n\nexport function makeDeviceActionInternalApiMock(): Mocked<InternalApi> {\n return {\n sendApdu: sendApduMock,\n sendCommand: sendCommandMock,\n getDeviceModel: apiGetDeviceModelMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getManagerApiService: getManagerApiServiceMock,\n getSecureChannelService: getSecureChannelServiceMock,\n };\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAIA,MAAMI,EAAe,GAAG,GAAG,EACrBC,EAAkB,GAAG,GAAG,EACxBC,EAAwB,GAAG,GAAG,EAC9BC,EAA+B,GAAG,GAAG,EACrCC,EAAyC,GAAG,GAAG,EAC/CC,EAA4B,GAAG,GAAG,EAClCC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,EAEnC,SAAST,GAAuD,CACrE,MAAO,CACL,SAAUE,EACV,YAAaC,EACb,eAAgBC,EAChB,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,qBAAsBC,EACtB,wBAAyBC,CAC3B,CACF",
6
- "names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "sendApduMock", "sendCommandMock", "apiGetDeviceModelMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock"]
4
+ "sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { DefaultLoggerPublisherService } from \"@internal/logger-publisher/service/DefaultLoggerPublisherService\";\n\nconst sendApduMock = vi.fn();\nconst sendCommandMock = vi.fn();\nconst apiGetDeviceModelMock = vi.fn();\nconst apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\nconst loggerFactoryMock = vi.fn(\n (tag) => new DefaultLoggerPublisherService([], tag),\n);\n\nexport function makeDeviceActionInternalApiMock(): Mocked<InternalApi> {\n return {\n sendApdu: sendApduMock,\n sendCommand: sendCommandMock,\n getDeviceModel: apiGetDeviceModelMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getManagerApiService: getManagerApiServiceMock,\n getSecureChannelService: getSecureChannelServiceMock,\n loggerFactory: loggerFactoryMock,\n };\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAA8C,4EAE9C,MAAMC,EAAe,GAAG,GAAG,EACrBC,EAAkB,GAAG,GAAG,EACxBC,EAAwB,GAAG,GAAG,EAC9BC,EAA+B,GAAG,GAAG,EACrCC,EAAyC,GAAG,GAAG,EAC/CC,EAA4B,GAAG,GAAG,EAClCC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,EACpCC,EAAoB,GAAG,GAC1BC,GAAQ,IAAI,gCAA8B,CAAC,EAAGA,CAAG,CACpD,EAEO,SAASZ,GAAuD,CACrE,MAAO,CACL,SAAUG,EACV,YAAaC,EACb,eAAgBC,EAChB,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,qBAAsBC,EACtB,wBAAyBC,EACzB,cAAeC,CACjB,CACF",
6
+ "names": ["makeInternalApi_exports", "__export", "makeDeviceActionInternalApiMock", "__toCommonJS", "import_DefaultLoggerPublisherService", "sendApduMock", "sendCommandMock", "apiGetDeviceModelMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock", "loggerFactoryMock", "tag"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var A=(a,e)=>{for(var t in e)l(a,t,{get:e[t],enumerable:!0})},D=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of v(e))!g.call(a,n)&&n!==t&&l(a,n,{get:()=>e[n],enumerable:!(r=y(e,n))||r.enumerable});return a};var E=a=>D(l({},"__esModule",{value:!0}),a);var M={};A(M,{XStateDeviceAction:()=>x});module.exports=E(M);var o=require("rxjs"),h=require("xstate"),p=require("../../device-action/model/DeviceActionState");class x{input;inspect=!1;logger;constructor(e){this.input=e.input,this.inspect=!!e.inspect,this.logger=e.logger}_execute(e){const t=this.makeStateMachine(e);return this._subscribeToStateMachine(t)}_subscribeToStateMachine(e){const t=(0,h.createActor)(e,{input:this.input}),r=new o.ReplaySubject;let n=!1;const m=i=>{const{context:u,status:s,output:b,error:I}=i;if(this.logger&&!n&&(n=!0,this.logger.debug("[XStateDeviceAction] Input",{data:{input:u.input}})),this.logger&&s==="active"){const c=typeof i.value=="string"?i.value:JSON.stringify(i.value);this.logger.debug(`[XStateDeviceAction] State: ${c}`,{data:{internalState:u._internalState}})}switch(s){case"active":r.next({status:p.DeviceActionStatus.Pending,intermediateValue:u.intermediateValue});break;case"done":b.caseOf({Left:c=>{r.next({status:p.DeviceActionStatus.Error,error:c})},Right:c=>{r.next({status:p.DeviceActionStatus.Completed,output:c})}}),r.complete();break;case"error":r.error(I),r.complete();break;case"stopped":r.next({status:p.DeviceActionStatus.Stopped}),r.complete();break;default:this._exhaustiveMatchingGuard(s)}},d=new o.Observable(i=>{const u=r.subscribe(i);return()=>{S.unsubscribe(),u.unsubscribe(),t.stop()}}),S=t.subscribe(m);return t.start(),{observable:d.pipe((0,o.share)()),cancel:()=>{t.stop(),S.unsubscribe(),m(t.getSnapshot())}}}_exhaustiveMatchingGuard(e){throw console.log("_exhaustiveMatchingGuard status",e),new Error(`Unhandled status: ${e}`)}}0&&(module.exports={XStateDeviceAction});
1
+ "use strict";var l=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var D=(a,e)=>{for(var t in e)l(a,t,{get:e[t],enumerable:!0})},E=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of v(e))!A.call(a,n)&&n!==t&&l(a,n,{get:()=>e[n],enumerable:!(r=I(e,n))||r.enumerable});return a};var f=a=>E(l({},"__esModule",{value:!0}),a);var M={};D(M,{XStateDeviceAction:()=>x});module.exports=f(M);var o=require("rxjs"),S=require("xstate"),s=require("../../device-action/model/DeviceActionState"),m=require("../../logger-publisher/utils/noopLoggerFactory");class x{input;inspect=!1;logger;loggerFactory;constructor(e){this.input=e.input,this.inspect=!!e.inspect,this.logger=e.logger,this.loggerFactory=e.loggerFactory}getLoggerFactory(e){return this.loggerFactory??e.loggerFactory??m.noopLoggerFactory}_execute(e){const t=this.makeStateMachine(e);return!this.logger&&t.id&&(this.logger=this.getLoggerFactory(e)(t.id)),this._subscribeToStateMachine(t)}_subscribeToStateMachine(e){const t=(0,S.createActor)(e,{input:this.input}),r=new o.ReplaySubject;let n=!1;const g=i=>{const{context:c,status:p,output:y,error:b}=i;if(this.logger&&!n&&(n=!0,this.logger.debug("[XStateDeviceAction] Input",{data:{input:c.input}})),this.logger&&p==="active"){const u=typeof i.value=="string"?i.value:JSON.stringify(i.value);this.logger.debug(`[XStateDeviceAction] State: ${u}`,{data:{internalState:c._internalState}})}switch(p){case"active":r.next({status:s.DeviceActionStatus.Pending,intermediateValue:c.intermediateValue});break;case"done":y.caseOf({Left:u=>{r.next({status:s.DeviceActionStatus.Error,error:u})},Right:u=>{r.next({status:s.DeviceActionStatus.Completed,output:u})}}),r.complete();break;case"error":r.error(b),r.complete();break;case"stopped":r.next({status:s.DeviceActionStatus.Stopped}),r.complete();break;default:this._exhaustiveMatchingGuard(p)}},d=new o.Observable(i=>{const c=r.subscribe(i);return()=>{h.unsubscribe(),c.unsubscribe(),t.stop()}}),h=t.subscribe(g);return t.start(),{observable:d.pipe((0,o.share)()),cancel:()=>{t.stop(),h.unsubscribe(),g(t.getSnapshot())}}}_exhaustiveMatchingGuard(e){throw console.log("_exhaustiveMatchingGuard status",e),new Error(`Unhandled status: ${e}`)}}0&&(module.exports={XStateDeviceAction});
2
2
  //# sourceMappingURL=XStateDeviceAction.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/xstate-utils/XStateDeviceAction.ts"],
4
- "sourcesContent": ["// import { createBrowserInspector } from \"@statelyai/inspect\";\nimport { Observable, ReplaySubject, share } from \"rxjs\";\nimport {\n createActor,\n type SnapshotFrom,\n type StateMachine,\n type StateSchema,\n} from \"xstate\";\n\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\n\nimport { type StateMachineTypes } from \"./StateMachineTypes\";\n\nexport type DeviceActionStateMachine<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> = StateMachine<\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"context\"], // context\n /**\n * The following usages `any` are OK because this is just a wrapper around the\n * state machine and we are not directly going to use these types.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any, // event\n any, // children\n any, // actor\n any, // action\n any, // guard\n any, // delay\n any, // state value\n any, // tag\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"input\"],\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"output\"],\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any,\n any,\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateSchema\n>;\n\n/**\n * A DeviceAction that uses an XState state machine to execute.\n * It maps the state machine snapshots to the DeviceActionState.\n * This class is abstract and should be extended to implement the state machine.\n */\nexport abstract class XStateDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> implements DeviceAction<Output, Input, Error, IntermediateValue>\n{\n readonly input: Input;\n readonly inspect: boolean = false;\n protected readonly logger?: LoggerPublisherService;\n\n /**\n *\n * @param input The input for the DeviceAction\n * @param inspect If true, the state machine will be inspected in the browser\n * @param logger Optional logger for debugging. If provided, input and internal state will be logged on state transitions.\n */\n constructor(args: {\n input: Input;\n inspect?: boolean;\n logger?: LoggerPublisherService;\n }) {\n this.input = args.input;\n this.inspect = Boolean(args.inspect);\n this.logger = args.logger;\n }\n\n protected abstract makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >;\n\n _execute(\n internalApi: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const stateMachine = this.makeStateMachine(internalApi);\n return this._subscribeToStateMachine(stateMachine);\n }\n\n protected _subscribeToStateMachine(\n stateMachine: DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const actor = createActor(stateMachine, {\n input: this.input,\n // optional inspector for debugging\n // inspect: this.inspect ? createBrowserInspector().inspect : undefined,\n });\n\n /**\n * Using a ReplaySubject is important because the first snapshots might be\n * emitted before the observable is subscribed (if the machine goes through\n * those states fully synchronously).\n * This way, we ensure that the subscriber always receives the latest snapshot.\n * */\n const subject = new ReplaySubject<\n DeviceActionState<Output, Error, IntermediateValue>\n >();\n\n let hasLoggedInput = false;\n\n const handleActorSnapshot = (\n snapshot: SnapshotFrom<typeof stateMachine>,\n ) => {\n const { context, status, output, error } = snapshot;\n\n // Log input once at the beginning\n if (this.logger && !hasLoggedInput) {\n hasLoggedInput = true;\n this.logger.debug(\"[XStateDeviceAction] Input\", {\n data: { input: context.input },\n });\n }\n\n // Log internal state on each state transition\n if (this.logger && status === \"active\") {\n const stateValue =\n typeof snapshot.value === \"string\"\n ? snapshot.value\n : JSON.stringify(snapshot.value);\n this.logger.debug(`[XStateDeviceAction] State: ${stateValue}`, {\n data: { internalState: context._internalState },\n });\n }\n\n switch (status) {\n case \"active\":\n subject.next({\n status: DeviceActionStatus.Pending,\n intermediateValue: context.intermediateValue,\n });\n break;\n case \"done\":\n output.caseOf({\n Left: (err) => {\n subject.next({\n status: DeviceActionStatus.Error,\n error: err,\n });\n },\n Right: (result) => {\n subject.next({\n status: DeviceActionStatus.Completed,\n output: result,\n });\n },\n });\n subject.complete();\n break;\n case \"error\":\n // this is an error in the execution of the state machine, it should not happen\n subject.error(error);\n subject.complete();\n break;\n case \"stopped\":\n subject.next({\n status: DeviceActionStatus.Stopped,\n });\n subject.complete();\n break;\n default:\n this._exhaustiveMatchingGuard(status);\n }\n };\n\n const observable = new Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >((subscriber) => {\n const subjectSubscription = subject.subscribe(subscriber);\n return () => {\n actorSubscription.unsubscribe();\n subjectSubscription.unsubscribe();\n actor.stop(); // stop the actor when the observable is unsubscribed\n };\n });\n\n const actorSubscription = actor.subscribe(handleActorSnapshot);\n actor.start();\n\n return {\n observable: observable.pipe(share()), // share to garantee that once there is no more observer, the actor is stopped\n cancel: () => {\n actor.stop();\n actorSubscription.unsubscribe();\n handleActorSnapshot(actor.getSnapshot());\n },\n };\n }\n\n private _exhaustiveMatchingGuard(status: never): never {\n console.log(\"_exhaustiveMatchingGuard status\", status);\n throw new Error(`Unhandled status: ${status}`);\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EA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AQU,CACV,CAAC,CACH,CACF,CAAC,EACDV,EAAQ,SAAS,EACjB,MACF,IAAK,QAEHA,EAAQ,MAAMO,CAAK,EACnBP,EAAQ,SAAS,EACjB,MACF,IAAK,UACHA,EAAQ,KAAK,CACX,OAAQ,qBAAmB,OAC7B,CAAC,EACDA,EAAQ,SAAS,EACjB,MACF,QACE,KAAK,yBAAyBK,CAAM,CACxC,CACF,EAEMM,EAAa,IAAI,aAEpBC,GAAe,CAChB,MAAMC,EAAsBb,EAAQ,UAAUY,CAAU,EACxD,MAAO,IAAM,CACXE,EAAkB,YAAY,EAC9BD,EAAoB,YAAY,EAChCd,EAAM,KAAK,CACb,CACF,CAAC,EAEKe,EAAoBf,EAAM,UAAUG,CAAmB,EAC7D,OAAAH,EAAM,MAAM,EAEL,CACL,WAAYY,EAAW,QAAK,SAAM,CAAC,EACnC,OAAQ,IAAM,CACZZ,EAAM,KAAK,EACXe,EAAkB,YAAY,EAC9BZ,EAAoBH,EAAM,YAAY,CAAC,CACzC,CACF,CACF,CAEQ,yBAAyBM,EAAsB,CACrD,cAAQ,IAAI,kCAAmCA,CAAM,EAC/C,IAAI,MAAM,qBAAqBA,CAAM,EAAE,CAC/C,CACF",
6
- "names": ["XStateDeviceAction_exports", "__export", "XStateDeviceAction", "__toCommonJS", "import_rxjs", "import_xstate", "import_DeviceActionState", "args", "internalApi", "stateMachine", "actor", "subject", "hasLoggedInput", "handleActorSnapshot", "snapshot", "context", "status", "output", "error", "stateValue", "err", "result", "observable", "subscriber", "subjectSubscription", "actorSubscription"]
4
+ "sourcesContent": ["// import { createBrowserInspector } from \"@statelyai/inspect\";\nimport { Observable, ReplaySubject, share } from \"rxjs\";\nimport {\n createActor,\n type SnapshotFrom,\n type StateMachine,\n type StateSchema,\n} from \"xstate\";\n\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport { noopLoggerFactory } from \"@api/logger-publisher/utils/noopLoggerFactory\";\n\nimport { type StateMachineTypes } from \"./StateMachineTypes\";\n\nexport type DeviceActionStateMachine<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> = StateMachine<\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"context\"], // context\n /**\n * The following usages `any` are OK because this is just a wrapper around the\n * state machine and we are not directly going to use these types.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any, // event\n any, // children\n any, // actor\n any, // action\n any, // guard\n any, // delay\n any, // state value\n any, // tag\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"input\"],\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"output\"],\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any,\n any,\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateSchema\n>;\n\n/**\n * A DeviceAction that uses an XState state machine to execute.\n * It maps the state machine snapshots to the DeviceActionState.\n * This class is abstract and should be extended to implement the state machine.\n */\nexport abstract class XStateDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> implements DeviceAction<Output, Input, Error, IntermediateValue>\n{\n readonly input: Input;\n readonly inspect: boolean = false;\n protected logger?: LoggerPublisherService;\n protected loggerFactory?: (tag: string) => LoggerPublisherService;\n\n /**\n *\n * @param input The input for the DeviceAction\n * @param inspect If true, the state machine will be inspected in the browser\n * @param logger Optional logger for debugging. If provided, input and internal state will be logged on state transitions.\n * @param loggerFactory Optional logger factory for creating loggers with prefixed tags. Takes precedence over logger.\n */\n constructor(args: {\n input: Input;\n inspect?: boolean;\n logger?: LoggerPublisherService;\n loggerFactory?: (tag: string) => LoggerPublisherService;\n }) {\n this.input = args.input;\n this.inspect = Boolean(args.inspect);\n this.logger = args.logger;\n this.loggerFactory = args.loggerFactory;\n }\n\n /**\n * Returns the logger factory to use for creating loggers.\n * Prefers the instance loggerFactory, then internalApi.loggerFactory,\n * and falls back to a no-op logger factory if neither is available.\n */\n protected getLoggerFactory(\n internalApi: InternalApi,\n ): (tag: string) => LoggerPublisherService {\n return this.loggerFactory ?? internalApi.loggerFactory ?? noopLoggerFactory;\n }\n\n protected abstract makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >;\n\n _execute(\n internalApi: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const stateMachine = this.makeStateMachine(internalApi);\n\n // Create logger from machine ID if not explicitly provided\n // Prefer loggerFactory (prefixed) over internalApi.loggerFactory (unprefixed)\n if (!this.logger && stateMachine.id) {\n this.logger = this.getLoggerFactory(internalApi)(stateMachine.id);\n }\n\n return this._subscribeToStateMachine(stateMachine);\n }\n\n protected _subscribeToStateMachine(\n stateMachine: DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const actor = createActor(stateMachine, {\n input: this.input,\n // optional inspector for debugging\n // inspect: this.inspect ? createBrowserInspector().inspect : undefined,\n });\n\n /**\n * Using a ReplaySubject is important because the first snapshots might be\n * emitted before the observable is subscribed (if the machine goes through\n * those states fully synchronously).\n * This way, we ensure that the subscriber always receives the latest snapshot.\n * */\n const subject = new ReplaySubject<\n DeviceActionState<Output, Error, IntermediateValue>\n >();\n\n let hasLoggedInput = false;\n\n const handleActorSnapshot = (\n snapshot: SnapshotFrom<typeof stateMachine>,\n ) => {\n const { context, status, output, error } = snapshot;\n\n // Log input once at the beginning\n if (this.logger && !hasLoggedInput) {\n hasLoggedInput = true;\n this.logger.debug(\"[XStateDeviceAction] Input\", {\n data: { input: context.input },\n });\n }\n\n // Log internal state on each state transition\n if (this.logger && status === \"active\") {\n const stateValue =\n typeof snapshot.value === \"string\"\n ? snapshot.value\n : JSON.stringify(snapshot.value);\n this.logger.debug(`[XStateDeviceAction] State: ${stateValue}`, {\n data: { internalState: context._internalState },\n });\n }\n\n switch (status) {\n case \"active\":\n subject.next({\n status: DeviceActionStatus.Pending,\n intermediateValue: context.intermediateValue,\n });\n break;\n case \"done\":\n output.caseOf({\n Left: (err) => {\n subject.next({\n status: DeviceActionStatus.Error,\n error: err,\n });\n },\n Right: (result) => {\n subject.next({\n status: DeviceActionStatus.Completed,\n output: result,\n });\n },\n });\n subject.complete();\n break;\n case \"error\":\n // this is an error in the execution of the state machine, it should not happen\n subject.error(error);\n subject.complete();\n break;\n case \"stopped\":\n subject.next({\n status: DeviceActionStatus.Stopped,\n });\n subject.complete();\n break;\n default:\n this._exhaustiveMatchingGuard(status);\n }\n };\n\n const observable = new Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >((subscriber) => {\n const subjectSubscription = subject.subscribe(subscriber);\n return () => {\n actorSubscription.unsubscribe();\n subjectSubscription.unsubscribe();\n actor.stop(); // stop the actor when the observable is unsubscribed\n };\n });\n\n const actorSubscription = actor.subscribe(handleActorSnapshot);\n actor.start();\n\n return {\n observable: observable.pipe(share()), // share to garantee that once there is no more observer, the actor is stopped\n cancel: () => {\n actor.stop();\n actorSubscription.unsubscribe();\n handleActorSnapshot(actor.getSnapshot());\n },\n };\n }\n\n private _exhaustiveMatchingGuard(status: never): never {\n console.log(\"_exhaustiveMatchingGuard status\", status);\n throw new Error(`Unhandled status: ${status}`);\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAiD,gBACjDC,EAKO,kBAQPC,EAGO,sDAGPC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MAC3B,MAAOS,CACT,CAAC,CACH,EACA,MAAQC,GAAW,CACjBV,EAAQ,KAAK,CACX,OAAQ,qBAAmB,UAC3B,OAAQU,CACV,CAAC,CACH,CACF,CAAC,EACDV,EAAQ,SAAS,EACjB,MACF,IAAK,QAEHA,EAAQ,MAAMO,CAAK,EACnBP,EAAQ,SAAS,EACjB,MACF,IAAK,UACHA,EAAQ,KAAK,CACX,OAAQ,qBAAmB,OAC7B,CAAC,EACDA,EAAQ,SAAS,EACjB,MACF,QACE,KAAK,yBAAyBK,CAAM,CACxC,CACF,EAEMM,EAAa,IAAI,aAEpBC,GAAe,CAChB,MAAMC,EAAsBb,EAAQ,UAAUY,CAAU,EACxD,MAAO,IAAM,CACXE,EAAkB,YAAY,EAC9BD,EAAoB,YAAY,EAChCd,EAAM,KAAK,CACb,CACF,CAAC,EAEKe,EAAoBf,EAAM,UAAUG,CAAmB,EAC7D,OAAAH,EAAM,MAAM,EAEL,CACL,WAAYY,EAAW,QAAK,SAAM,CAAC,EACnC,OAAQ,IAAM,CACZZ,EAAM,KAAK,EACXe,EAAkB,YAAY,EAC9BZ,EAAoBH,EAAM,YAAY,CAAC,CACzC,CACF,CACF,CAEQ,yBAAyBM,EAAsB,CACrD,cAAQ,IAAI,kCAAmCA,CAAM,EAC/C,IAAI,MAAM,qBAAqBA,CAAM,EAAE,CAC/C,CACF",
6
+ "names": ["XStateDeviceAction_exports", "__export", "XStateDeviceAction", "__toCommonJS", "import_rxjs", "import_xstate", "import_DeviceActionState", "import_noopLoggerFactory", "args", "internalApi", "stateMachine", "actor", "subject", "hasLoggedInput", "handleActorSnapshot", "snapshot", "context", "status", "output", "error", "stateValue", "err", "result", "observable", "subscriber", "subjectSubscription", "actorSubscription"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var v=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ve=Object.prototype.hasOwnProperty;var Se=(p,t)=>{for(var a in t)v(p,a,{get:t[a],enumerable:!0})},l=(p,t,a,S)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of le(t))!ve.call(p,c)&&c!==a&&v(p,c,{get:()=>t[c],enumerable:!(S=ue(t,c))||S.enumerable});return p},o=(p,t,a)=>(l(p,t,"default"),a&&l(a,t,"default"));var ye=p=>l(v({},"__esModule",{value:!0}),p);var e={};Se(e,{APDU_MAX_PAYLOAD:()=>d.APDU_MAX_PAYLOAD,Apdu:()=>y.Apdu,ApduBuilder:()=>d.ApduBuilder,ApduParser:()=>C.ApduParser,ApduResponse:()=>J.ApduResponse,AppAlreadyInstalledDAError:()=>r.AppAlreadyInstalledDAError,BatteryStatusType:()=>A.BatteryStatusType,BleDeviceInfos:()=>Y.BleDeviceInfos,ByteArrayBuilder:()=>g.ByteArrayBuilder,ByteArrayParser:()=>G.ByteArrayParser,CallTaskInAppDeviceAction:()=>k.CallTaskInAppDeviceAction,CloseAppCommand:()=>L.CloseAppCommand,CommandResultFactory:()=>i.CommandResultFactory,CommandResultStatus:()=>i.CommandResultStatus,CommandUtils:()=>O.CommandUtils,ConnectedDevice:()=>fe.ConnectedDevice,ConsoleLogger:()=>se.ConsoleLogger,DEFAULT_UNLOCK_TIMEOUT_MS:()=>_.DEFAULT_UNLOCK_TIMEOUT_MS,DefaultLogTagFormatter:()=>ce.DefaultLogTagFormatter,DeviceActionStatus:()=>M.DeviceActionStatus,DeviceConnectionStateMachine:()=>xe.DeviceConnectionStateMachine,DeviceLockedError:()=>r.DeviceLockedError,DeviceManagementKit:()=>ie.DeviceManagementKit,DeviceManagementKitBuilder:()=>me.DeviceManagementKitBuilder,DeviceModel:()=>n.DeviceModel,DeviceModelId:()=>n.DeviceModelId,DeviceNotOnboardedError:()=>r.DeviceNotOnboardedError,DeviceSessionStateType:()=>Q.DeviceSessionStateType,DeviceStatus:()=>h.DeviceStatus,FramerUtils:()=>ae.FramerUtils,GLOBAL_ERRORS:()=>m.GLOBAL_ERRORS,GenuineCheckDeviceAction:()=>Z.GenuineCheckDeviceAction,GetAppAndVersionCommand:()=>E.GetAppAndVersionCommand,GetBackgroundImageSizeCommand:()=>x.GetBackgroundImageSizeCommand,GetBackgroundImageSizeCommandError:()=>x.GetBackgroundImageSizeCommandError,GetBatteryStatusCommand:()=>A.GetBatteryStatusCommand,GetDeviceMetadataDeviceAction:()=>F.GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction:()=>V.GetDeviceStatusDeviceAction,GetOsVersionCommand:()=>B.GetOsVersionCommand,GlobalCommandError:()=>m.GlobalCommandError,GlobalCommandErrorHandler:()=>m.GlobalCommandErrorHandler,GoToDashboardDeviceAction:()=>z.GoToDashboardDeviceAction,InstallAppDeviceAction:()=>$.InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction:()=>P.InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError:()=>f.InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError:()=>f.InvalidStatusWordError,LEDGER_VENDOR_ID:()=>n.LEDGER_VENDOR_ID,ListAppsCommand:()=>I.ListAppsCommand,ListAppsDeviceAction:()=>W.ListAppsDeviceAction,ListAppsWithMetadataDeviceAction:()=>w.ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction:()=>ee.ListInstalledAppsDeviceAction,LoadCertificateCommand:()=>R.LoadCertificateCommand,LogLevel:()=>ne.LogLevel,OpenAppCommand:()=>T.OpenAppCommand,OpenAppDeviceAction:()=>H.OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction:()=>K.OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError:()=>r.OutOfMemoryDAError,RefusedByUserDAError:()=>r.RefusedByUserDAError,SecureChannelError:()=>re.SecureChannelError,SendCommandInAppDeviceAction:()=>N.SendCommandInAppDeviceAction,StaticDeviceModelDataSource:()=>X.StaticDeviceModelDataSource,TransportConnectedDevice:()=>Ae.TransportConnectedDevice,TransportDeviceModel:()=>j.TransportDeviceModel,UninstallAppDeviceAction:()=>oe.UninstallAppDeviceAction,UnknownDAError:()=>r.UnknownDAError,UnsupportedFirmwareDAError:()=>r.UnsupportedFirmwareDAError,UserInteractionRequired:()=>U.UserInteractionRequired,WebLogsExporterLogger:()=>de.WebLogsExporterLogger,XStateDeviceAction:()=>q.XStateDeviceAction,base64StringToBuffer:()=>u.base64StringToBuffer,bufferToHexaString:()=>s.bufferToHexaString,connectedDeviceStubBuilder:()=>De.connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder:()=>te.defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder:()=>pe.defaultApduSenderServiceStubBuilder,formatApduReceivedLog:()=>D.formatApduReceivedLog,formatApduSentLog:()=>D.formatApduSentLog,hexaStringToBuffer:()=>s.hexaStringToBuffer,isBase64String:()=>u.isBase64String,isCommandErrorCode:()=>b.isCommandErrorCode,isHexaString:()=>s.isHexaString,isSuccessCommandResult:()=>i.isSuccessCommandResult});module.exports=ye(e);var y=require("./apdu/model/Apdu"),d=require("./apdu/utils/ApduBuilder"),C=require("./apdu/utils/ApduParser");o(e,require("./apdu/utils/AppBuilderError"),module.exports);var g=require("./apdu/utils/ByteArrayBuilder"),G=require("./apdu/utils/ByteArrayParser"),f=require("./command/Errors"),i=require("./command/model/CommandResult"),L=require("./command/os/CloseAppCommand"),E=require("./command/os/GetAppAndVersionCommand"),x=require("./command/os/GetBackgroundImageSizeCommand"),A=require("./command/os/GetBatteryStatusCommand"),B=require("./command/os/GetOsVersionCommand"),I=require("./command/os/ListAppsCommand"),R=require("./command/os/LoadCertificateCommand"),T=require("./command/os/OpenAppCommand"),b=require("./command/utils/CommandErrors"),O=require("./command/utils/CommandUtils"),m=require("./command/utils/GlobalCommandError"),n=require("./device/DeviceModel"),h=require("./device/DeviceStatus"),M=require("./device-action/model/DeviceActionState"),U=require("./device-action/model/UserInteractionRequired"),k=require("./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction"),_=require("./device-action/os/Const"),r=require("./device-action/os/Errors"),F=require("./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),V=require("./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),z=require("./device-action/os/GoToDashboard/GoToDashboardDeviceAction"),P=require("./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction"),W=require("./device-action/os/ListApps/ListAppsDeviceAction"),w=require("./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction"),H=require("./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),K=require("./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction"),N=require("./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction"),q=require("./device-action/xstate-utils/XStateDeviceAction"),X=require("./device-model/data/StaticDeviceModelDataSource"),Y=require("./device-model/model/BleDeviceInfos"),j=require("./device-model/model/DeviceModel"),J=require("./device-session/ApduResponse");o(e,require("./device-session/data/FramerConst"),module.exports);var Q=require("./device-session/DeviceSessionState"),Z=require("./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction"),$=require("./secure-channel/device-action/InstallApp/InstallAppDeviceAction"),ee=require("./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction"),oe=require("./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction"),re=require("../internal/secure-channel/model/Errors"),te=require("./device-session/service/DefaultApduReceiverService.stub"),pe=require("./device-session/service/DefaultApduSenderService.stub"),ae=require("./device-session/utils/FramerUtils"),ie=require("./DeviceManagementKit"),me=require("./DeviceManagementKitBuilder");o(e,require("./Error"),module.exports);var ne=require("./logger-subscriber/model/LogLevel"),se=require("./logger-subscriber/service/ConsoleLogger"),ce=require("./logger-subscriber/service/DefaultLogTagFormatter"),de=require("./logger-subscriber/service/WebLogsExporterLogger"),fe=require("./transport/model/ConnectedDevice"),xe=require("./transport/model/DeviceConnectionStateMachine");o(e,require("./transport/model/Errors"),module.exports);var Ae=require("./transport/model/TransportConnectedDevice"),De=require("./transport/model/TransportConnectedDevice.stub");o(e,require("./types"),module.exports);var D=require("./utils/apduLogs"),u=require("./utils/Base64String"),s=require("./utils/HexaString");0&&(module.exports={APDU_MAX_PAYLOAD,Apdu,ApduBuilder,ApduParser,ApduResponse,AppAlreadyInstalledDAError,BatteryStatusType,BleDeviceInfos,ByteArrayBuilder,ByteArrayParser,CallTaskInAppDeviceAction,CloseAppCommand,CommandResultFactory,CommandResultStatus,CommandUtils,ConnectedDevice,ConsoleLogger,DEFAULT_UNLOCK_TIMEOUT_MS,DefaultLogTagFormatter,DeviceActionStatus,DeviceConnectionStateMachine,DeviceLockedError,DeviceManagementKit,DeviceManagementKitBuilder,DeviceModel,DeviceModelId,DeviceNotOnboardedError,DeviceSessionStateType,DeviceStatus,FramerUtils,GLOBAL_ERRORS,GenuineCheckDeviceAction,GetAppAndVersionCommand,GetBackgroundImageSizeCommand,GetBackgroundImageSizeCommandError,GetBatteryStatusCommand,GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction,GetOsVersionCommand,GlobalCommandError,GlobalCommandErrorHandler,GoToDashboardDeviceAction,InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError,LEDGER_VENDOR_ID,ListAppsCommand,ListAppsDeviceAction,ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction,LoadCertificateCommand,LogLevel,OpenAppCommand,OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError,RefusedByUserDAError,SecureChannelError,SendCommandInAppDeviceAction,StaticDeviceModelDataSource,TransportConnectedDevice,TransportDeviceModel,UninstallAppDeviceAction,UnknownDAError,UnsupportedFirmwareDAError,UserInteractionRequired,WebLogsExporterLogger,XStateDeviceAction,base64StringToBuffer,bufferToHexaString,connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder,formatApduReceivedLog,formatApduSentLog,hexaStringToBuffer,isBase64String,isCommandErrorCode,isHexaString,isSuccessCommandResult,...require("./apdu/utils/AppBuilderError"),...require("./device-session/data/FramerConst"),...require("./Error"),...require("./transport/model/Errors"),...require("./types")});
1
+ "use strict";var S=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var ge=(p,t)=>{for(var a in t)S(p,a,{get:t[a],enumerable:!0})},v=(p,t,a,g)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of ve(t))!Se.call(p,c)&&c!==a&&S(p,c,{get:()=>t[c],enumerable:!(g=le(t,c))||g.enumerable});return p},o=(p,t,a)=>(v(p,t,"default"),a&&v(a,t,"default"));var ye=p=>v(S({},"__esModule",{value:!0}),p);var e={};ge(e,{APDU_MAX_PAYLOAD:()=>d.APDU_MAX_PAYLOAD,Apdu:()=>y.Apdu,ApduBuilder:()=>d.ApduBuilder,ApduParser:()=>C.ApduParser,ApduResponse:()=>Q.ApduResponse,AppAlreadyInstalledDAError:()=>r.AppAlreadyInstalledDAError,BatteryStatusType:()=>A.BatteryStatusType,BleDeviceInfos:()=>j.BleDeviceInfos,ByteArrayBuilder:()=>G.ByteArrayBuilder,ByteArrayParser:()=>L.ByteArrayParser,CallTaskInAppDeviceAction:()=>F.CallTaskInAppDeviceAction,CloseAppCommand:()=>E.CloseAppCommand,CommandResultFactory:()=>i.CommandResultFactory,CommandResultStatus:()=>i.CommandResultStatus,CommandUtils:()=>h.CommandUtils,ConnectedDevice:()=>xe.ConnectedDevice,ConsoleLogger:()=>ce.ConsoleLogger,DEFAULT_UNLOCK_TIMEOUT_MS:()=>_.DEFAULT_UNLOCK_TIMEOUT_MS,DefaultLogTagFormatter:()=>de.DefaultLogTagFormatter,DeviceActionStatus:()=>U.DeviceActionStatus,DeviceConnectionStateMachine:()=>Ae.DeviceConnectionStateMachine,DeviceLockedError:()=>r.DeviceLockedError,DeviceManagementKit:()=>me.DeviceManagementKit,DeviceManagementKitBuilder:()=>ne.DeviceManagementKitBuilder,DeviceModel:()=>n.DeviceModel,DeviceModelId:()=>n.DeviceModelId,DeviceNotOnboardedError:()=>r.DeviceNotOnboardedError,DeviceSessionStateType:()=>Z.DeviceSessionStateType,DeviceStatus:()=>M.DeviceStatus,FramerUtils:()=>ie.FramerUtils,GLOBAL_ERRORS:()=>m.GLOBAL_ERRORS,GenuineCheckDeviceAction:()=>$.GenuineCheckDeviceAction,GetAppAndVersionCommand:()=>B.GetAppAndVersionCommand,GetBackgroundImageSizeCommand:()=>x.GetBackgroundImageSizeCommand,GetBackgroundImageSizeCommandError:()=>x.GetBackgroundImageSizeCommandError,GetBatteryStatusCommand:()=>A.GetBatteryStatusCommand,GetDeviceMetadataDeviceAction:()=>V.GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction:()=>z.GetDeviceStatusDeviceAction,GetOsVersionCommand:()=>I.GetOsVersionCommand,GlobalCommandError:()=>m.GlobalCommandError,GlobalCommandErrorHandler:()=>m.GlobalCommandErrorHandler,GoToDashboardDeviceAction:()=>P.GoToDashboardDeviceAction,InstallAppDeviceAction:()=>ee.InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction:()=>W.InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError:()=>f.InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError:()=>f.InvalidStatusWordError,LEDGER_VENDOR_ID:()=>n.LEDGER_VENDOR_ID,ListAppsCommand:()=>R.ListAppsCommand,ListAppsDeviceAction:()=>w.ListAppsDeviceAction,ListAppsWithMetadataDeviceAction:()=>H.ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction:()=>oe.ListInstalledAppsDeviceAction,LoadCertificateCommand:()=>T.LoadCertificateCommand,LogLevel:()=>se.LogLevel,OpenAppCommand:()=>b.OpenAppCommand,OpenAppDeviceAction:()=>K.OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction:()=>N.OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError:()=>r.OutOfMemoryDAError,RefusedByUserDAError:()=>r.RefusedByUserDAError,SecureChannelError:()=>te.SecureChannelError,SendCommandInAppDeviceAction:()=>q.SendCommandInAppDeviceAction,StaticDeviceModelDataSource:()=>Y.StaticDeviceModelDataSource,TransportConnectedDevice:()=>De.TransportConnectedDevice,TransportDeviceModel:()=>J.TransportDeviceModel,UninstallAppDeviceAction:()=>re.UninstallAppDeviceAction,UnknownDAError:()=>r.UnknownDAError,UnsupportedFirmwareDAError:()=>r.UnsupportedFirmwareDAError,UserInteractionRequired:()=>k.UserInteractionRequired,WebLogsExporterLogger:()=>fe.WebLogsExporterLogger,XStateDeviceAction:()=>X.XStateDeviceAction,base64StringToBuffer:()=>l.base64StringToBuffer,bufferToHexaString:()=>s.bufferToHexaString,connectedDeviceStubBuilder:()=>ue.connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder:()=>pe.defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder:()=>ae.defaultApduSenderServiceStubBuilder,formatApduReceivedLog:()=>u.formatApduReceivedLog,formatApduSentLog:()=>u.formatApduSentLog,hexaStringToBuffer:()=>s.hexaStringToBuffer,isBase64String:()=>l.isBase64String,isCommandErrorCode:()=>O.isCommandErrorCode,isHexaString:()=>s.isHexaString,isSuccessCommandResult:()=>i.isSuccessCommandResult,noopLogger:()=>D.noopLogger,noopLoggerFactory:()=>D.noopLoggerFactory});module.exports=ye(e);var y=require("./apdu/model/Apdu"),d=require("./apdu/utils/ApduBuilder"),C=require("./apdu/utils/ApduParser");o(e,require("./apdu/utils/AppBuilderError"),module.exports);var G=require("./apdu/utils/ByteArrayBuilder"),L=require("./apdu/utils/ByteArrayParser"),f=require("./command/Errors"),i=require("./command/model/CommandResult"),E=require("./command/os/CloseAppCommand"),B=require("./command/os/GetAppAndVersionCommand"),x=require("./command/os/GetBackgroundImageSizeCommand"),A=require("./command/os/GetBatteryStatusCommand"),I=require("./command/os/GetOsVersionCommand"),R=require("./command/os/ListAppsCommand"),T=require("./command/os/LoadCertificateCommand"),b=require("./command/os/OpenAppCommand"),O=require("./command/utils/CommandErrors"),h=require("./command/utils/CommandUtils"),m=require("./command/utils/GlobalCommandError"),n=require("./device/DeviceModel"),M=require("./device/DeviceStatus"),U=require("./device-action/model/DeviceActionState"),k=require("./device-action/model/UserInteractionRequired"),F=require("./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction"),_=require("./device-action/os/Const"),r=require("./device-action/os/Errors"),V=require("./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction"),z=require("./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction"),P=require("./device-action/os/GoToDashboard/GoToDashboardDeviceAction"),W=require("./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction"),w=require("./device-action/os/ListApps/ListAppsDeviceAction"),H=require("./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction"),K=require("./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction"),N=require("./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction"),q=require("./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction"),X=require("./device-action/xstate-utils/XStateDeviceAction"),Y=require("./device-model/data/StaticDeviceModelDataSource"),j=require("./device-model/model/BleDeviceInfos"),J=require("./device-model/model/DeviceModel"),Q=require("./device-session/ApduResponse");o(e,require("./device-session/data/FramerConst"),module.exports);var Z=require("./device-session/DeviceSessionState"),$=require("./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction"),ee=require("./secure-channel/device-action/InstallApp/InstallAppDeviceAction"),oe=require("./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction"),re=require("./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction"),te=require("../internal/secure-channel/model/Errors"),pe=require("./device-session/service/DefaultApduReceiverService.stub"),ae=require("./device-session/service/DefaultApduSenderService.stub"),ie=require("./device-session/utils/FramerUtils"),me=require("./DeviceManagementKit"),ne=require("./DeviceManagementKitBuilder");o(e,require("./Error"),module.exports);var D=require("./logger-publisher/utils/noopLoggerFactory"),se=require("./logger-subscriber/model/LogLevel"),ce=require("./logger-subscriber/service/ConsoleLogger"),de=require("./logger-subscriber/service/DefaultLogTagFormatter"),fe=require("./logger-subscriber/service/WebLogsExporterLogger"),xe=require("./transport/model/ConnectedDevice"),Ae=require("./transport/model/DeviceConnectionStateMachine");o(e,require("./transport/model/Errors"),module.exports);var De=require("./transport/model/TransportConnectedDevice"),ue=require("./transport/model/TransportConnectedDevice.stub");o(e,require("./types"),module.exports);var u=require("./utils/apduLogs"),l=require("./utils/Base64String"),s=require("./utils/HexaString");0&&(module.exports={APDU_MAX_PAYLOAD,Apdu,ApduBuilder,ApduParser,ApduResponse,AppAlreadyInstalledDAError,BatteryStatusType,BleDeviceInfos,ByteArrayBuilder,ByteArrayParser,CallTaskInAppDeviceAction,CloseAppCommand,CommandResultFactory,CommandResultStatus,CommandUtils,ConnectedDevice,ConsoleLogger,DEFAULT_UNLOCK_TIMEOUT_MS,DefaultLogTagFormatter,DeviceActionStatus,DeviceConnectionStateMachine,DeviceLockedError,DeviceManagementKit,DeviceManagementKitBuilder,DeviceModel,DeviceModelId,DeviceNotOnboardedError,DeviceSessionStateType,DeviceStatus,FramerUtils,GLOBAL_ERRORS,GenuineCheckDeviceAction,GetAppAndVersionCommand,GetBackgroundImageSizeCommand,GetBackgroundImageSizeCommandError,GetBatteryStatusCommand,GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction,GetOsVersionCommand,GlobalCommandError,GlobalCommandErrorHandler,GoToDashboardDeviceAction,InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError,LEDGER_VENDOR_ID,ListAppsCommand,ListAppsDeviceAction,ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction,LoadCertificateCommand,LogLevel,OpenAppCommand,OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError,RefusedByUserDAError,SecureChannelError,SendCommandInAppDeviceAction,StaticDeviceModelDataSource,TransportConnectedDevice,TransportDeviceModel,UninstallAppDeviceAction,UnknownDAError,UnsupportedFirmwareDAError,UserInteractionRequired,WebLogsExporterLogger,XStateDeviceAction,base64StringToBuffer,bufferToHexaString,connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder,formatApduReceivedLog,formatApduSentLog,hexaStringToBuffer,isBase64String,isCommandErrorCode,isHexaString,isSuccessCommandResult,noopLogger,noopLoggerFactory,...require("./apdu/utils/AppBuilderError"),...require("./device-session/data/FramerConst"),...require("./Error"),...require("./transport/model/Errors"),...require("./types")});
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/index.ts"],
4
- "sourcesContent": ["\"use strict\";\n\nexport { Apdu } from \"@api/apdu/model/Apdu\";\nexport { APDU_MAX_PAYLOAD, ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nexport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nexport * from \"@api/apdu/utils/AppBuilderError\";\nexport { ByteArrayBuilder } from \"@api/apdu/utils/ByteArrayBuilder\";\nexport { ByteArrayParser } from \"@api/apdu/utils/ByteArrayParser\";\nexport { type Command } from \"@api/command/Command\";\nexport {\n InvalidGetFirmwareMetadataResponseError,\n InvalidStatusWordError,\n} from \"@api/command/Errors\";\nexport {\n CommandResultFactory,\n CommandResultStatus,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nexport { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nexport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n GetBackgroundImageSizeCommand,\n GetBackgroundImageSizeCommandError,\n type GetBackgroundImageSizeCommandResult,\n type GetBackgroundImageSizeErrorCodes,\n type GetBackgroundImageSizeResponse,\n} from \"@api/command/os/GetBackgroundImageSizeCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nexport {\n AppAlreadyInstalledDAError,\n DeviceLockedError,\n DeviceNotOnboardedError,\n OutOfMemoryDAError,\n RefusedByUserDAError,\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nexport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nexport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nexport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nexport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n GoToDashboardDARequiredInteraction,\n GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nexport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nexport { ListAppsWithMetadataDeviceAction } from \"@api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction\";\nexport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nexport { OpenAppWithDependenciesDeviceAction } from \"@api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction\";\nexport { SendCommandInAppDeviceAction } from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction\";\nexport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nexport { GenuineCheckDeviceAction } from \"@api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction\";\nexport { InstallAppDeviceAction } from \"@api/secure-channel/device-action/InstallApp/InstallAppDeviceAction\";\nexport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nexport { UninstallAppDeviceAction } from \"@api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction\";\nexport { SecureChannelError } from \"@internal/secure-channel/model/Errors\";\n// TODO: remove from exported\nexport { defaultApduReceiverServiceStubBuilder } from \"@api/device-session/service/DefaultApduReceiverService.stub\";\nexport { defaultApduSenderServiceStubBuilder } from \"@api/device-session/service/DefaultApduSenderService.stub\";\nexport { FramerUtils } from \"@api/device-session/utils/FramerUtils\";\nexport { DeviceManagementKit } from \"@api/DeviceManagementKit\";\nexport { DeviceManagementKitBuilder } from \"@api/DeviceManagementKitBuilder\";\nexport * from \"@api/Error\";\nexport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { DefaultLogTagFormatter } from \"@api/logger-subscriber/service/DefaultLogTagFormatter\";\nexport { type LogTagFormatter } from \"@api/logger-subscriber/service/LogTagFormatter\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\nexport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nexport {\n DeviceConnectionStateMachine,\n type DeviceConnectionStateMachineParams,\n} from \"@api/transport/model/DeviceConnectionStateMachine\";\nexport * from \"@api/transport/model/Errors\";\nexport { TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nexport { connectedDeviceStubBuilder } from \"@api/transport/model/TransportConnectedDevice.stub\";\nexport * from \"@api/types\";\nexport { formatApduReceivedLog, formatApduSentLog } from \"@api/utils/apduLogs\";\nexport { base64StringToBuffer, isBase64String } from \"@api/utils/Base64String\";\nexport {\n bufferToHexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@api/utils/HexaString\";\n"],
5
- "mappings": "meAAA,IAAAA,EAAA,GAAAC,GAAAD,EAAA,g6HAAAE,GAAAF,GAEA,IAAAG,EAAqB,gCACrBC,EAA8C,uCAC9CC,EAA2B,sCAC3BC,EAAAN,EAAc,2CALd,gBAMA,IAAAO,EAAiC,4CACjCC,EAAgC,2CAEhCC,EAGO,+BACPC,EAIO,4CACPC,EAAgC,2CAChCC,EAGO,mDACPC,EAMO,yDACPC,EAKO,mDACPC,EAGO,+CACPC,EAKO,2CACPC,EAIO,kDACPC,EAGO,0CACPC,EAAmC,4CACnCC,EAA6B,2CAC7BC,EAIO,iDACPC,EAIO,mCACPC,EAA6B,oCAE7BC,EAGO,sDACPC,EAAwC,4DACxCC,EAA0C,qFAC1CC,EAA0C,uCAC1ClB,EAQO,wCACPmB,EAA8C,iFAC9CC,EAA4C,6EAC5CC,EAA0C,yEAS1CC,EAAgD,qFAChDC,EAAqC,+DACrCC,EAAiD,uFACjDC,EAAoC,yEACpCC,EAAoD,6FACpDC,EAA6C,2FAC7CC,EAGO,8DACPC,EAA4C,8DAC5CC,EAA+B,kDAC/BjB,EAAqC,+CACrCkB,EAA6B,4CAC7BlC,EAAAN,EAAc,gDA9Gd,gBA+GA,IAAAyC,EAGO,kDACPC,EAAyC,mFACzCC,EAAuC,+EACvCC,GAA8C,6FAC9CC,GAAyC,mFACzCpC,GAAmC,iDAEnCqC,GAAsD,uEACtDC,GAAoD,qEACpDC,GAA4B,iDAC5BC,GAAoC,oCACpCC,GAA2C,2CAC3C5C,EAAAN,EAAc,sBA9Hd,gBA+HA,IAAAmD,GAAyB,iDACzBC,GAA8B,wDAC9BC,GAAuC,iEAEvCC,GAAsC,gEACtCC,GAAgC,gDAChCC,GAGO,6DACPlD,EAAAN,EAAc,uCAzId,gBA0IA,IAAAyD,GAAyC,yDACzCA,GAA2C,8DAC3CnD,EAAAN,EAAc,sBA5Id,gBA6IA,IAAA0D,EAAyD,+BACzDC,EAAqD,mCACrDC,EAIO",
6
- "names": ["api_exports", "__export", "__toCommonJS", "import_Apdu", "import_ApduBuilder", "import_ApduParser", "__reExport", "import_ByteArrayBuilder", "import_ByteArrayParser", "import_Errors", "import_CommandResult", "import_CloseAppCommand", "import_GetAppAndVersionCommand", "import_GetBackgroundImageSizeCommand", "import_GetBatteryStatusCommand", "import_GetOsVersionCommand", "import_ListAppsCommand", "import_LoadCertificateCommand", "import_OpenAppCommand", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_DeviceActionState", "import_UserInteractionRequired", "import_CallTaskInAppDeviceAction", "import_Const", "import_GetDeviceMetadataDeviceAction", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_ListAppsWithMetadataDeviceAction", "import_OpenAppDeviceAction", "import_OpenAppWithDependenciesDeviceAction", "import_SendCommandInAppDeviceAction", "import_XStateDeviceAction", "import_StaticDeviceModelDataSource", "import_BleDeviceInfos", "import_ApduResponse", "import_DeviceSessionState", "import_GenuineCheckDeviceAction", "import_InstallAppDeviceAction", "import_ListInstalledAppsDeviceAction", "import_UninstallAppDeviceAction", "import_DefaultApduReceiverService", "import_DefaultApduSenderService", "import_FramerUtils", "import_DeviceManagementKit", "import_DeviceManagementKitBuilder", "import_LogLevel", "import_ConsoleLogger", "import_DefaultLogTagFormatter", "import_WebLogsExporterLogger", "import_ConnectedDevice", "import_DeviceConnectionStateMachine", "import_TransportConnectedDevice", "import_apduLogs", "import_Base64String", "import_HexaString"]
4
+ "sourcesContent": ["\"use strict\";\n\nexport { Apdu } from \"@api/apdu/model/Apdu\";\nexport { APDU_MAX_PAYLOAD, ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nexport { ApduParser } from \"@api/apdu/utils/ApduParser\";\nexport * from \"@api/apdu/utils/AppBuilderError\";\nexport { ByteArrayBuilder } from \"@api/apdu/utils/ByteArrayBuilder\";\nexport { ByteArrayParser } from \"@api/apdu/utils/ByteArrayParser\";\nexport { type Command } from \"@api/command/Command\";\nexport {\n InvalidGetFirmwareMetadataResponseError,\n InvalidStatusWordError,\n} from \"@api/command/Errors\";\nexport {\n CommandResultFactory,\n CommandResultStatus,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nexport { CloseAppCommand } from \"@api/command/os/CloseAppCommand\";\nexport {\n GetAppAndVersionCommand,\n type GetAppAndVersionResponse,\n} from \"@api/command/os/GetAppAndVersionCommand\";\nexport {\n GetBackgroundImageSizeCommand,\n GetBackgroundImageSizeCommandError,\n type GetBackgroundImageSizeCommandResult,\n type GetBackgroundImageSizeErrorCodes,\n type GetBackgroundImageSizeResponse,\n} from \"@api/command/os/GetBackgroundImageSizeCommand\";\nexport {\n BatteryStatusType,\n type GetBatteryStatusArgs,\n GetBatteryStatusCommand,\n type GetBatteryStatusResponse,\n} from \"@api/command/os/GetBatteryStatusCommand\";\nexport {\n GetOsVersionCommand,\n type GetOsVersionResponse,\n} from \"@api/command/os/GetOsVersionCommand\";\nexport {\n type ListAppsArgs,\n ListAppsCommand,\n type ListAppsErrorCodes,\n type ListAppsResponse,\n} from \"@api/command/os/ListAppsCommand\";\nexport {\n type LoadCertificateArgs,\n LoadCertificateCommand,\n type LoadCertificateErrorCodes,\n} from \"@api/command/os/LoadCertificateCommand\";\nexport {\n type OpenAppArgs,\n OpenAppCommand,\n} from \"@api/command/os/OpenAppCommand\";\nexport { isCommandErrorCode } from \"@api/command/utils/CommandErrors\";\nexport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nexport {\n GLOBAL_ERRORS,\n GlobalCommandError,\n GlobalCommandErrorHandler,\n} from \"@api/command/utils/GlobalCommandError\";\nexport {\n DeviceModel,\n DeviceModelId,\n LEDGER_VENDOR_ID,\n} from \"@api/device/DeviceModel\";\nexport { DeviceStatus } from \"@api/device/DeviceStatus\";\nexport { type InternalApi } from \"@api/device-action/DeviceAction\";\nexport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nexport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nexport { CallTaskInAppDeviceAction } from \"@api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction\";\nexport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nexport {\n AppAlreadyInstalledDAError,\n DeviceLockedError,\n DeviceNotOnboardedError,\n OutOfMemoryDAError,\n RefusedByUserDAError,\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nexport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nexport { GetDeviceStatusDeviceAction } from \"@api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction\";\nexport { GoToDashboardDeviceAction } from \"@api/device-action/os/GoToDashboard/GoToDashboardDeviceAction\";\nexport type {\n GoToDashboardDAError,\n GoToDashboardDAInput,\n GoToDashboardDAIntermediateValue,\n GoToDashboardDAOutput,\n GoToDashboardDARequiredInteraction,\n GoToDashboardDAState,\n} from \"@api/device-action/os/GoToDashboard/types\";\nexport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nexport { ListAppsDeviceAction } from \"@api/device-action/os/ListApps/ListAppsDeviceAction\";\nexport { ListAppsWithMetadataDeviceAction } from \"@api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction\";\nexport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nexport { OpenAppWithDependenciesDeviceAction } from \"@api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction\";\nexport { SendCommandInAppDeviceAction } from \"@api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction\";\nexport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nexport { StaticDeviceModelDataSource } from \"@api/device-model/data/StaticDeviceModelDataSource\";\nexport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nexport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nexport { ApduResponse } from \"@api/device-session/ApduResponse\";\nexport * from \"@api/device-session/data/FramerConst\";\nexport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nexport { GenuineCheckDeviceAction } from \"@api/secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction\";\nexport { InstallAppDeviceAction } from \"@api/secure-channel/device-action/InstallApp/InstallAppDeviceAction\";\nexport { ListInstalledAppsDeviceAction } from \"@api/secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction\";\nexport { UninstallAppDeviceAction } from \"@api/secure-channel/device-action/UninstallApp/UninstallAppDeviceAction\";\nexport { SecureChannelError } from \"@internal/secure-channel/model/Errors\";\n// TODO: remove from exported\nexport { defaultApduReceiverServiceStubBuilder } from \"@api/device-session/service/DefaultApduReceiverService.stub\";\nexport { defaultApduSenderServiceStubBuilder } from \"@api/device-session/service/DefaultApduSenderService.stub\";\nexport { FramerUtils } from \"@api/device-session/utils/FramerUtils\";\nexport { DeviceManagementKit } from \"@api/DeviceManagementKit\";\nexport { DeviceManagementKitBuilder } from \"@api/DeviceManagementKitBuilder\";\nexport * from \"@api/Error\";\nexport {\n noopLogger,\n noopLoggerFactory,\n} from \"@api/logger-publisher/utils/noopLoggerFactory\";\nexport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nexport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\nexport { DefaultLogTagFormatter } from \"@api/logger-subscriber/service/DefaultLogTagFormatter\";\nexport { type LogTagFormatter } from \"@api/logger-subscriber/service/LogTagFormatter\";\nexport { WebLogsExporterLogger } from \"@api/logger-subscriber/service/WebLogsExporterLogger\";\nexport { ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nexport {\n DeviceConnectionStateMachine,\n type DeviceConnectionStateMachineParams,\n} from \"@api/transport/model/DeviceConnectionStateMachine\";\nexport * from \"@api/transport/model/Errors\";\nexport { TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nexport { connectedDeviceStubBuilder } from \"@api/transport/model/TransportConnectedDevice.stub\";\nexport * from \"@api/types\";\nexport { formatApduReceivedLog, formatApduSentLog } from \"@api/utils/apduLogs\";\nexport { base64StringToBuffer, isBase64String } from \"@api/utils/Base64String\";\nexport {\n bufferToHexaString,\n hexaStringToBuffer,\n isHexaString,\n} from \"@api/utils/HexaString\";\n"],
5
+ "mappings": "meAAA,IAAAA,EAAA,GAAAC,GAAAD,EAAA,u+HAAAE,GAAAF,GAEA,IAAAG,EAAqB,gCACrBC,EAA8C,uCAC9CC,EAA2B,sCAC3BC,EAAAN,EAAc,2CALd,gBAMA,IAAAO,EAAiC,4CACjCC,EAAgC,2CAEhCC,EAGO,+BACPC,EAIO,4CACPC,EAAgC,2CAChCC,EAGO,mDACPC,EAMO,yDACPC,EAKO,mDACPC,EAGO,+CACPC,EAKO,2CACPC,EAIO,kDACPC,EAGO,0CACPC,EAAmC,4CACnCC,EAA6B,2CAC7BC,EAIO,iDACPC,EAIO,mCACPC,EAA6B,oCAE7BC,EAGO,sDACPC,EAAwC,4DACxCC,EAA0C,qFAC1CC,EAA0C,uCAC1ClB,EAQO,wCACPmB,EAA8C,iFAC9CC,EAA4C,6EAC5CC,EAA0C,yEAS1CC,EAAgD,qFAChDC,EAAqC,+DACrCC,EAAiD,uFACjDC,EAAoC,yEACpCC,EAAoD,6FACpDC,EAA6C,2FAC7CC,EAGO,8DACPC,EAA4C,8DAC5CC,EAA+B,kDAC/BjB,EAAqC,+CACrCkB,EAA6B,4CAC7BlC,EAAAN,EAAc,gDA9Gd,gBA+GA,IAAAyC,EAGO,kDACPC,EAAyC,mFACzCC,GAAuC,+EACvCC,GAA8C,6FAC9CC,GAAyC,mFACzCpC,GAAmC,iDAEnCqC,GAAsD,uEACtDC,GAAoD,qEACpDC,GAA4B,iDAC5BC,GAAoC,oCACpCC,GAA2C,2CAC3C5C,EAAAN,EAAc,sBA9Hd,gBA+HA,IAAAmD,EAGO,yDACPC,GAAyB,iDACzBC,GAA8B,wDAC9BC,GAAuC,iEAEvCC,GAAsC,gEACtCC,GAAgC,gDAChCC,GAGO,6DACPnD,EAAAN,EAAc,uCA7Id,gBA8IA,IAAA0D,GAAyC,yDACzCA,GAA2C,8DAC3CpD,EAAAN,EAAc,sBAhJd,gBAiJA,IAAA2D,EAAyD,+BACzDC,EAAqD,mCACrDC,EAIO",
6
+ "names": ["api_exports", "__export", "__toCommonJS", "import_Apdu", "import_ApduBuilder", "import_ApduParser", "__reExport", "import_ByteArrayBuilder", "import_ByteArrayParser", "import_Errors", "import_CommandResult", "import_CloseAppCommand", "import_GetAppAndVersionCommand", "import_GetBackgroundImageSizeCommand", "import_GetBatteryStatusCommand", "import_GetOsVersionCommand", "import_ListAppsCommand", "import_LoadCertificateCommand", "import_OpenAppCommand", "import_CommandErrors", "import_CommandUtils", "import_GlobalCommandError", "import_DeviceModel", "import_DeviceStatus", "import_DeviceActionState", "import_UserInteractionRequired", "import_CallTaskInAppDeviceAction", "import_Const", "import_GetDeviceMetadataDeviceAction", "import_GetDeviceStatusDeviceAction", "import_GoToDashboardDeviceAction", "import_InstallOrUpdateAppsDeviceAction", "import_ListAppsDeviceAction", "import_ListAppsWithMetadataDeviceAction", "import_OpenAppDeviceAction", "import_OpenAppWithDependenciesDeviceAction", "import_SendCommandInAppDeviceAction", "import_XStateDeviceAction", "import_StaticDeviceModelDataSource", "import_BleDeviceInfos", "import_ApduResponse", "import_DeviceSessionState", "import_GenuineCheckDeviceAction", "import_InstallAppDeviceAction", "import_ListInstalledAppsDeviceAction", "import_UninstallAppDeviceAction", "import_DefaultApduReceiverService", "import_DefaultApduSenderService", "import_FramerUtils", "import_DeviceManagementKit", "import_DeviceManagementKitBuilder", "import_noopLoggerFactory", "import_LogLevel", "import_ConsoleLogger", "import_DefaultLogTagFormatter", "import_WebLogsExporterLogger", "import_ConnectedDevice", "import_DeviceConnectionStateMachine", "import_TransportConnectedDevice", "import_apduLogs", "import_Base64String", "import_HexaString"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var p=(e,r)=>{for(var g in r)i(e,g,{get:r[g],enumerable:!0})},u=(e,r,g,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of n(r))!b.call(e,o)&&o!==g&&i(e,o,{get:()=>r[o],enumerable:!(s=c(r,o))||s.enumerable});return e};var L=e=>u(i({},"__esModule",{value:!0}),e);var h={};p(h,{noopLogger:()=>t,noopLoggerFactory:()=>a});module.exports=L(h);const t={subscribers:[],error:()=>{},warn:()=>{},info:()=>{},debug:()=>{}},a=e=>t;0&&(module.exports={noopLogger,noopLoggerFactory});
2
+ //# sourceMappingURL=noopLoggerFactory.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/api/logger-publisher/utils/noopLoggerFactory.ts"],
4
+ "sourcesContent": ["import { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\n\n/**\n * A no-op logger that silently discards all log messages.\n * Useful as a default when no logger is configured.\n */\nexport const noopLogger: LoggerPublisherService = {\n subscribers: [],\n error: () => {},\n warn: () => {},\n info: () => {},\n debug: () => {},\n};\n\n/**\n * A logger factory that always returns a no-op logger, regardless of the tag.\n * Use this as a fallback when no logger factory is provided.\n */\nexport const noopLoggerFactory = (_tag: string): LoggerPublisherService =>\n noopLogger;\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,sBAAAC,IAAA,eAAAC,EAAAJ,GAMO,MAAME,EAAqC,CAChD,YAAa,CAAC,EACd,MAAO,IAAM,CAAC,EACd,KAAM,IAAM,CAAC,EACb,KAAM,IAAM,CAAC,EACb,MAAO,IAAM,CAAC,CAChB,EAMaC,EAAqBE,GAChCH",
6
+ "names": ["noopLoggerFactory_exports", "__export", "noopLogger", "noopLoggerFactory", "__toCommonJS", "_tag"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var o=require("vitest"),t=require("./noopLoggerFactory");(0,o.describe)("noopLogger",()=>{(0,o.it)("should have an empty subscribers array",()=>{(0,o.expect)(t.noopLogger.subscribers).toEqual([])}),(0,o.it)("should not throw when calling error",()=>{(0,o.expect)(()=>t.noopLogger.error("test")).not.toThrow()}),(0,o.it)("should not throw when calling warn",()=>{(0,o.expect)(()=>t.noopLogger.warn("test")).not.toThrow()}),(0,o.it)("should not throw when calling info",()=>{(0,o.expect)(()=>t.noopLogger.info("test")).not.toThrow()}),(0,o.it)("should not throw when calling debug",()=>{(0,o.expect)(()=>t.noopLogger.debug("test")).not.toThrow()}),(0,o.it)("should not throw when calling methods with options",()=>{const e={data:{key:"value"}};(0,o.expect)(()=>t.noopLogger.error("test",e)).not.toThrow(),(0,o.expect)(()=>t.noopLogger.warn("test",e)).not.toThrow(),(0,o.expect)(()=>t.noopLogger.info("test",e)).not.toThrow(),(0,o.expect)(()=>t.noopLogger.debug("test",e)).not.toThrow()})});(0,o.describe)("noopLoggerFactory",()=>{(0,o.it)("should return a LoggerPublisherService regardless of tag",()=>{const e=(0,t.noopLoggerFactory)("any-tag");(0,o.expect)(e).toBeDefined(),(0,o.expect)(e.subscribers).toEqual([]),(0,o.expect)(typeof e.error).toBe("function"),(0,o.expect)(typeof e.warn).toBe("function"),(0,o.expect)(typeof e.info).toBe("function"),(0,o.expect)(typeof e.debug).toBe("function")}),(0,o.it)("should always return the same noopLogger instance",()=>{const e=(0,t.noopLoggerFactory)("tag-a"),r=(0,t.noopLoggerFactory)("tag-b");(0,o.expect)(e).toBe(r),(0,o.expect)(e).toBe(t.noopLogger)})});
2
+ //# sourceMappingURL=noopLoggerFactory.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/api/logger-publisher/utils/noopLoggerFactory.test.ts"],
4
+ "sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport { noopLogger, noopLoggerFactory } from \"./noopLoggerFactory\";\n\ndescribe(\"noopLogger\", () => {\n it(\"should have an empty subscribers array\", () => {\n expect(noopLogger.subscribers).toEqual([]);\n });\n\n it(\"should not throw when calling error\", () => {\n expect(() => noopLogger.error(\"test\")).not.toThrow();\n });\n\n it(\"should not throw when calling warn\", () => {\n expect(() => noopLogger.warn(\"test\")).not.toThrow();\n });\n\n it(\"should not throw when calling info\", () => {\n expect(() => noopLogger.info(\"test\")).not.toThrow();\n });\n\n it(\"should not throw when calling debug\", () => {\n expect(() => noopLogger.debug(\"test\")).not.toThrow();\n });\n\n it(\"should not throw when calling methods with options\", () => {\n const options = { data: { key: \"value\" } };\n expect(() => noopLogger.error(\"test\", options)).not.toThrow();\n expect(() => noopLogger.warn(\"test\", options)).not.toThrow();\n expect(() => noopLogger.info(\"test\", options)).not.toThrow();\n expect(() => noopLogger.debug(\"test\", options)).not.toThrow();\n });\n});\n\ndescribe(\"noopLoggerFactory\", () => {\n it(\"should return a LoggerPublisherService regardless of tag\", () => {\n const logger = noopLoggerFactory(\"any-tag\");\n expect(logger).toBeDefined();\n expect(logger.subscribers).toEqual([]);\n expect(typeof logger.error).toBe(\"function\");\n expect(typeof logger.warn).toBe(\"function\");\n expect(typeof logger.info).toBe(\"function\");\n expect(typeof logger.debug).toBe(\"function\");\n });\n\n it(\"should always return the same noopLogger instance\", () => {\n const logger1 = noopLoggerFactory(\"tag-a\");\n const logger2 = noopLoggerFactory(\"tag-b\");\n expect(logger1).toBe(logger2);\n expect(logger1).toBe(noopLogger);\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAqC,kBAErCC,EAA8C,kCAE9C,YAAS,aAAc,IAAM,IAC3B,MAAG,yCAA0C,IAAM,IACjD,UAAO,aAAW,WAAW,EAAE,QAAQ,CAAC,CAAC,CAC3C,CAAC,KAED,MAAG,sCAAuC,IAAM,IAC9C,UAAO,IAAM,aAAW,MAAM,MAAM,CAAC,EAAE,IAAI,QAAQ,CACrD,CAAC,KAED,MAAG,qCAAsC,IAAM,IAC7C,UAAO,IAAM,aAAW,KAAK,MAAM,CAAC,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logger1", "logger2"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var O=(a,e)=>{for(var t in e)m(a,t,{get:e[t],enumerable:!0})},T=(a,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of I(e))!y.call(a,i)&&i!==t&&m(a,i,{get:()=>e[i],enumerable:!(s=R(e,i))||s.enumerable});return a};var x=a=>T(m({},"__esModule",{value:!0}),a);var P={};O(P,{DeviceSession:()=>w});module.exports=x(P);var r=require("rxjs"),S=require("uuid"),D=require("../../../api/command/utils/CommandUtils"),l=require("../../../api/device/DeviceStatus"),_=require("../../../api/device-session/DeviceSessionState"),p=require("../../../api/transport/model/Errors"),v=require("../../../api/utils/apduLogs"),f=require("../../device-session/data/DeviceSessionRefresherConst"),g=require("../../device-session/service/IntentQueueService"),E=require("../../device-session/service/RefresherService"),b=require("./DevicePinger"),u=require("./DeviceSessionEventDispatcher"),A=require("./DeviceSessionRefresher"),C=require("./DeviceSessionStateHandler");class w{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_intentQueueService;_sessionEventDispatcher=new u.DeviceSessionEventDispatcher;_bypassIntentQueue=!1;constructor({connectedDevice:e,id:t=(0,S.v4)()},s,i,n,o,d=c=>new g.IntentQueueService(s,c)){this._id=t,this._connectedDevice=e,this._logger=s("device-session"),this._managerApiService=i,this._intentQueueService=d(this._sessionEventDispatcher),this._secureChannelService=n,this._refresherOptions={...f.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,...o},this._deviceState=new r.BehaviorSubject({sessionStateType:_.DeviceSessionStateType.Connected,deviceStatus:l.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new b.DevicePinger(s,e,this._sessionEventDispatcher,(c,h)=>this.sendCommand(c,h)),this._deviceSessionRefresher=new A.DeviceSessionRefresher(s,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new C.DeviceSessionStateHandler(s,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,c=>this.setDeviceSessionState(c)),this._refresherService=new E.RefresherService(s,{start:()=>this._deviceSessionRefresher.restartRefresher(),stop:()=>this._deviceSessionRefresher.stopRefresher()})}async initialiseSession(){try{this._refresherOptions.isRefresherDisabled?await this._pinger.ping():this._deviceSessionRefresher.startRefresher()}catch(e){throw this._logger.error("Error while initialising session",{data:{error:e}}),e}}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}getDeviceSessionState(){return this._deviceState.getValue()}setDeviceSessionState(e){this._deviceState.next(e)}sendApdu(e,t={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._bypassIntentQueue?this._unsafeInternalSendApdu(e,t):this._internalSendApdu(e,t)}_internalSendApdu(e,t){const s=t.abortTimeout,i=Date.now(),{observable:n,cancel:o}=this._intentQueueService.enqueue({type:"send-apdu",execute:()=>(0,r.from)((async()=>{const c=Date.now()-i;return await this._unsafeInternalSendApdu(e,{isPolling:t.isPolling,triggersDisconnection:t.triggersDisconnection,abortTimeout:s?s-c:void 0})})())}),d=s?n.pipe((0,r.timeout)({each:s,with:()=>{throw o(),new p.SendApduTimeoutError}})):n;return(0,r.lastValueFrom)(d)}async _unsafeInternalSendApdu(e,t={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._logger.debug((0,v.formatApduSendingLog)(e)),(await this._connectedDevice.sendApdu(e,t.triggersDisconnection,t.abortTimeout)).ifRight(i=>{this._logger.debug((0,v.formatApduReceivedLog)(i)),D.CommandUtils.isLockedDeviceResponse(i)?this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_UNKNOWN})})}sendCommand(e,t){return this._logger.debug(`[sendCommand] ${e.name}`),this._bypassIntentQueue?this._unsafeInternalSendCommand(e,t):this._internalSendCommand(e,t)}_internalSendCommand(e,t){const s=Date.now(),{observable:i,cancel:n}=this._intentQueueService.enqueue({type:"send-command",execute:()=>(0,r.from)((async()=>{const d=Date.now()-s;return await this._unsafeInternalSendCommand(e,t?t-d:void 0)})())}),o=t?i.pipe((0,r.timeout)({each:t,with:()=>{throw n(),new p.SendCommandTimeoutError}})):i;return(0,r.lastValueFrom)(o)}async _unsafeInternalSendCommand(e,t){const s=e.getApdu();return(await this._unsafeInternalSendApdu(s.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1,abortTimeout:t})).caseOf({Left:n=>{throw this._logger.error("[sendCommand] error",{data:{err:n}}),n},Right:n=>{const o=e.parseResponse(n,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:o}}),o}})}executeDeviceAction(e){return this._bypassIntentQueue?this._unsafeInternalExecuteDeviceAction(e):this._internalExecuteDeviceAction(e)}_internalExecuteDeviceAction(e){let t;const{observable:s,cancel:i}=this._intentQueueService.enqueue({type:"device-action",execute:()=>{const{observable:n,cancel:o}=this._unsafeInternalExecuteDeviceAction(e);return t=o,n}});return{observable:s,cancel:()=>{t?.(),i()}}}_unsafeInternalExecuteDeviceAction(e){const{observable:t,cancel:s}=e._execute({sendApdu:async i=>this._unsafeInternalSendApdu(i),sendCommand:async i=>this._unsafeInternalSendCommand(i),getDeviceModel:()=>this._connectedDevice.deviceModel,getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:i=>(this.setDeviceSessionState(i),this._deviceState.getValue()),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService});return{observable:t,cancel:s}}close(){this._updateDeviceStatus(l.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._deviceSessionRefresher.stopRefresher(),this._pinger.unsubscribe()}disableRefresher(e){return this._refresherService.disableRefresher(e)}_unsafeBypassIntentQueue(e){this._bypassIntentQueue=e}_updateDeviceStatus(e){const t=this._deviceState.getValue();this._deviceState.next({...t,deviceStatus:e})}}0&&(module.exports={DeviceSession});
1
+ "use strict";var l=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var O=(a,e)=>{for(var t in e)l(a,t,{get:e[t],enumerable:!0})},T=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of y(e))!I.call(a,s)&&s!==t&&l(a,s,{get:()=>e[s],enumerable:!(i=R(e,s))||i.enumerable});return a};var x=a=>T(l({},"__esModule",{value:!0}),a);var P={};O(P,{DeviceSession:()=>w});module.exports=x(P);var r=require("rxjs"),S=require("uuid"),D=require("../../../api/command/utils/CommandUtils"),h=require("../../../api/device/DeviceStatus"),_=require("../../../api/device-session/DeviceSessionState"),p=require("../../../api/transport/model/Errors"),v=require("../../../api/utils/apduLogs"),g=require("../../device-session/data/DeviceSessionRefresherConst"),f=require("../../device-session/service/IntentQueueService"),E=require("../../device-session/service/RefresherService"),b=require("./DevicePinger"),u=require("./DeviceSessionEventDispatcher"),A=require("./DeviceSessionRefresher"),C=require("./DeviceSessionStateHandler");class w{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_loggerModuleFactory;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_intentQueueService;_sessionEventDispatcher=new u.DeviceSessionEventDispatcher;_bypassIntentQueue=!1;constructor({connectedDevice:e,id:t=(0,S.v4)()},i,s,n,o,d=c=>new f.IntentQueueService(i,c)){this._id=t,this._connectedDevice=e,this._loggerModuleFactory=i,this._logger=i("device-session"),this._managerApiService=s,this._intentQueueService=d(this._sessionEventDispatcher),this._secureChannelService=n,this._refresherOptions={...g.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,...o},this._deviceState=new r.BehaviorSubject({sessionStateType:_.DeviceSessionStateType.Connected,deviceStatus:h.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new b.DevicePinger(i,e,this._sessionEventDispatcher,(c,m)=>this.sendCommand(c,m)),this._deviceSessionRefresher=new A.DeviceSessionRefresher(i,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new C.DeviceSessionStateHandler(i,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,c=>this.setDeviceSessionState(c)),this._refresherService=new E.RefresherService(i,{start:()=>this._deviceSessionRefresher.restartRefresher(),stop:()=>this._deviceSessionRefresher.stopRefresher()})}async initialiseSession(){try{this._refresherOptions.isRefresherDisabled?await this._pinger.ping():this._deviceSessionRefresher.startRefresher()}catch(e){throw this._logger.error("Error while initialising session",{data:{error:e}}),e}}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}getDeviceSessionState(){return this._deviceState.getValue()}setDeviceSessionState(e){this._deviceState.next(e)}sendApdu(e,t={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._bypassIntentQueue?this._unsafeInternalSendApdu(e,t):this._internalSendApdu(e,t)}_internalSendApdu(e,t){const i=t.abortTimeout,s=Date.now(),{observable:n,cancel:o}=this._intentQueueService.enqueue({type:"send-apdu",execute:()=>(0,r.from)((async()=>{const c=Date.now()-s;return await this._unsafeInternalSendApdu(e,{isPolling:t.isPolling,triggersDisconnection:t.triggersDisconnection,abortTimeout:i?i-c:void 0})})())}),d=i?n.pipe((0,r.timeout)({each:i,with:()=>{throw o(),new p.SendApduTimeoutError}})):n;return(0,r.lastValueFrom)(d)}async _unsafeInternalSendApdu(e,t={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._logger.debug((0,v.formatApduSendingLog)(e)),(await this._connectedDevice.sendApdu(e,t.triggersDisconnection,t.abortTimeout)).ifRight(s=>{this._logger.debug((0,v.formatApduReceivedLog)(s)),D.CommandUtils.isLockedDeviceResponse(s)?this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:u.SessionEvents.DEVICE_STATE_UPDATE_UNKNOWN})})}sendCommand(e,t){return this._logger.debug(`[sendCommand] ${e.name}`),this._bypassIntentQueue?this._unsafeInternalSendCommand(e,t):this._internalSendCommand(e,t)}_internalSendCommand(e,t){const i=Date.now(),{observable:s,cancel:n}=this._intentQueueService.enqueue({type:"send-command",execute:()=>(0,r.from)((async()=>{const d=Date.now()-i;return await this._unsafeInternalSendCommand(e,t?t-d:void 0)})())}),o=t?s.pipe((0,r.timeout)({each:t,with:()=>{throw n(),new p.SendCommandTimeoutError}})):s;return(0,r.lastValueFrom)(o)}async _unsafeInternalSendCommand(e,t){const i=e.getApdu();return(await this._unsafeInternalSendApdu(i.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1,abortTimeout:t})).caseOf({Left:n=>{throw this._logger.error("[sendCommand] error",{data:{err:n}}),n},Right:n=>{const o=e.parseResponse(n,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:o}}),o}})}executeDeviceAction(e){return this._bypassIntentQueue?this._unsafeInternalExecuteDeviceAction(e):this._internalExecuteDeviceAction(e)}_internalExecuteDeviceAction(e){let t;const{observable:i,cancel:s}=this._intentQueueService.enqueue({type:"device-action",execute:()=>{const{observable:n,cancel:o}=this._unsafeInternalExecuteDeviceAction(e);return t=o,n}});return{observable:i,cancel:()=>{t?.(),s()}}}_unsafeInternalExecuteDeviceAction(e){const{observable:t,cancel:i}=e._execute({sendApdu:async s=>this._unsafeInternalSendApdu(s),sendCommand:async s=>this._unsafeInternalSendCommand(s),getDeviceModel:()=>this._connectedDevice.deviceModel,getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:s=>(this.setDeviceSessionState(s),this._deviceState.getValue()),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService,loggerFactory:this._loggerModuleFactory});return{observable:t,cancel:i}}close(){this._updateDeviceStatus(h.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._deviceSessionRefresher.stopRefresher(),this._pinger.unsubscribe()}disableRefresher(e){return this._refresherService.disableRefresher(e)}_unsafeBypassIntentQueue(e){this._bypassIntentQueue=e}_updateDeviceStatus(e){const t=this._deviceState.getValue();this._deviceState.next({...t,deviceStatus:e})}}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 } from \"purify-ts\";\nimport {\n BehaviorSubject,\n from,\n lastValueFrom,\n type Observable,\n timeout,\n} from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport {\n SendApduTimeoutError,\n SendCommandTimeoutError,\n} from \"@api/transport/model/Errors\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport {\n formatApduReceivedLog,\n formatApduSendingLog,\n} from \"@api/utils/apduLogs\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { IntentQueueService } from \"@internal/device-session/service/IntentQueueService\";\nimport { RefresherService } from \"@internal/device-session/service/RefresherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DevicePinger } from \"./DevicePinger\";\nimport {\n DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"./DeviceSessionEventDispatcher\";\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceSessionStateHandler } from \"./DeviceSessionStateHandler\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\nexport type DeviceSessionRefresherOptions = {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n abortTimeout?: number;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n private readonly _refresherOptions: DeviceSessionRefresherOptions;\n private _pinger: DevicePinger;\n private _deviceSessionRefresher: DeviceSessionRefresher;\n private readonly _refresherService: RefresherService;\n private readonly _intentQueueService: IntentQueueService;\n private _sessionEventDispatcher = new DeviceSessionEventDispatcher();\n private _bypassIntentQueue: boolean = false;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n deviceSessionRefresherOptions: DeviceSessionRefresherOptions | undefined,\n intentQueueServiceFactory: (\n sessionEventDispatcher: DeviceSessionEventDispatcher,\n ) => IntentQueueService = (sessionEventDispatcher) =>\n new IntentQueueService(loggerModuleFactory, sessionEventDispatcher),\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._logger = loggerModuleFactory(\"device-session\");\n this._managerApiService = managerApiService;\n this._intentQueueService = intentQueueServiceFactory(\n this._sessionEventDispatcher,\n );\n this._secureChannelService = secureChannelService;\n this._refresherOptions = {\n ...DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n ...deviceSessionRefresherOptions,\n };\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n\n this._pinger = new DevicePinger(\n loggerModuleFactory,\n connectedDevice,\n this._sessionEventDispatcher,\n (command, abortTimeout) => this.sendCommand(command, abortTimeout),\n );\n this._deviceSessionRefresher = new DeviceSessionRefresher(\n loggerModuleFactory,\n this._refresherOptions,\n this._sessionEventDispatcher,\n this._connectedDevice,\n );\n new DeviceSessionStateHandler(\n loggerModuleFactory,\n this._sessionEventDispatcher,\n this._connectedDevice,\n this._deviceState,\n (state) => this.setDeviceSessionState(state),\n );\n\n this._refresherService = new RefresherService(loggerModuleFactory, {\n start: () => this._deviceSessionRefresher.restartRefresher(),\n stop: () => this._deviceSessionRefresher.stopRefresher(),\n });\n }\n\n public async initialiseSession(): Promise<void> {\n try {\n if (this._refresherOptions.isRefresherDisabled) await this._pinger.ping();\n else this._deviceSessionRefresher.startRefresher();\n } catch (error) {\n this._logger.error(\"Error while initialising session\", {\n data: { error },\n });\n throw error;\n }\n }\n\n public get id(): DeviceSessionId {\n return this._id;\n }\n\n public get connectedDevice(): TransportConnectedDevice {\n return this._connectedDevice;\n }\n\n public get state(): Observable<DeviceSessionState> {\n return this._deviceState.asObservable();\n }\n\n public getDeviceSessionState(): DeviceSessionState {\n return this._deviceState.getValue();\n }\n\n public setDeviceSessionState(state: DeviceSessionState): void {\n this._deviceState.next(state);\n }\n\n public sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalSendApdu(rawApdu, options);\n }\n return this._internalSendApdu(rawApdu, options);\n }\n\n private _internalSendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions,\n ): Promise<Either<DmkError, ApduResponse>> {\n const abortTimeout = options.abortTimeout;\n const beforeQueuedTimestamp = Date.now();\n const { observable, cancel } = this._intentQueueService.enqueue({\n type: \"send-apdu\",\n execute: () =>\n from(\n (async () => {\n const elapsedTime = Date.now() - beforeQueuedTimestamp;\n const result = await this._unsafeInternalSendApdu(rawApdu, {\n isPolling: options.isPolling,\n triggersDisconnection: options.triggersDisconnection,\n // Subtract the elapsed time to account for the time spent in the queue\n // to sync both observable and transport timeout\n abortTimeout: abortTimeout\n ? abortTimeout - elapsedTime\n : undefined,\n });\n return result;\n })(),\n ),\n });\n\n const timeoutObservable = abortTimeout\n ? observable.pipe(\n timeout({\n each: abortTimeout,\n with: () => {\n cancel();\n throw new SendApduTimeoutError();\n },\n }),\n )\n : observable;\n\n return lastValueFrom(timeoutObservable);\n }\n\n private async _unsafeInternalSendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n this._logger.debug(formatApduSendingLog(rawApdu));\n const result = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n options.abortTimeout,\n );\n\n return result\n .ifRight((response: ApduResponse) => {\n this._logger.debug(formatApduReceivedLog(response));\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_LOCKED,\n });\n } else {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n }\n })\n .ifLeft(() => {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_UNKNOWN,\n });\n });\n }\n\n public sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n this._logger.debug(`[sendCommand] ${command.name}`);\n\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalSendCommand(command, abortTimeout);\n }\n return this._internalSendCommand(command, abortTimeout);\n }\n\n private _internalSendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const beforeQueuedTimestamp = Date.now();\n const { observable, cancel } = this._intentQueueService.enqueue({\n type: \"send-command\",\n execute: () =>\n from(\n (async () => {\n const elapsedTime = Date.now() - beforeQueuedTimestamp;\n const result = await this._unsafeInternalSendCommand(\n command,\n // Subtract the elapsed time to account for the time spent in the queue\n // to sync both observable and transport timeout\n abortTimeout ? abortTimeout - elapsedTime : undefined,\n );\n return result;\n })(),\n ),\n });\n\n const timeoutObservable = abortTimeout\n ? observable.pipe(\n timeout({\n each: abortTimeout,\n with: () => {\n cancel();\n throw new SendCommandTimeoutError();\n },\n }),\n )\n : observable;\n\n return lastValueFrom(timeoutObservable);\n }\n\n private async _unsafeInternalSendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n\n const response = await this._unsafeInternalSendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n abortTimeout,\n });\n\n return response.caseOf({\n Left: (err) => {\n this._logger.error(\"[sendCommand] error\", { data: { err } });\n throw err;\n },\n Right: (r) => {\n const result = command.parseResponse(\n r,\n this._connectedDevice.deviceModel.id,\n );\n this._logger.debug(\"[sendCommand] result\", { data: { result } });\n return result;\n },\n });\n }\n\n public executeDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalExecuteDeviceAction(deviceAction);\n }\n return this._internalExecuteDeviceAction(deviceAction);\n }\n\n private _internalExecuteDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n let deviceActionCancel: (() => void) | undefined;\n\n const { observable: o, cancel: queueCancel } =\n this._intentQueueService.enqueue({\n type: \"device-action\",\n execute: () => {\n const { observable, cancel } =\n this._unsafeInternalExecuteDeviceAction(deviceAction);\n deviceActionCancel = cancel;\n return observable;\n },\n });\n\n return {\n observable: o,\n cancel: () => {\n deviceActionCancel?.();\n queueCancel();\n },\n };\n }\n\n private _unsafeInternalExecuteDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendApdu: async (apdu: Uint8Array) => this._unsafeInternalSendApdu(apdu), // note: there is no timeout handled at this stage\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n ) => this._unsafeInternalSendCommand(command), // note: there is no timeout handled at this stage\n getDeviceModel: () => this._connectedDevice.deviceModel,\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n public close(): void {\n this._updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._deviceSessionRefresher.stopRefresher();\n this._pinger.unsubscribe();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\n }\n\n public _unsafeBypassIntentQueue(bypass: boolean): void {\n this._bypassIntentQueue = bypass;\n }\n\n private _updateDeviceStatus(deviceStatus: DeviceStatus): void {\n const state = this._deviceState.getValue();\n this._deviceState.next({ ...state, deviceStatus });\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAMO,gBACPC,EAA6B,gBAI7BC,EAA6B,2CAC7BC,EAA6B,oCAO7BC,EAGO,kDAIPC,EAGO,uCAEPC,EAGO,+BACPC,EAAyD,qEACzDC,EAAmC,+DACnCC,EAAiC,6DAIjCC,EAA6B,0BAC7BC,EAGO,0CACPC,EAAuC,oCACvCC,EAA0C,uCAqBnC,MAAMf,CAAc,CACR,IACA,iBACA,aACA,mBACA,sBACA,QACA,kBACT,QACA,wBACS,kBACA,oBACT,wBAA0B,IAAI,+BAC9B,mBAA8B,GAEtC,YACE,CAAE,gBAAAgB,EAAiB,GAAAC,KAAK,EAAAC,IAAO,CAAE,EACjCC,EACAC,EACAC,EACAC,EACAC,EAE2BC,GACzB,IAAI,qBAAmBL,EAAqBK,CAAsB,EACpE,CACA,KAAK,IAAMP,EACX,KAAK,iBAAmBD,EACxB,KAAK,QAAUG,EAAoB,gBAAgB,EACnD,KAAK,mBAAqBC,EAC1B,KAAK,oBAAsBG,EACzB,KAAK,uBACP,EACA,KAAK,sBA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AZ,EAAY,OAAAC,CAAO,EACzB,KAAK,mCAAmCQ,CAAY,EACtD,OAAAC,EAAqBT,EACdD,CACT,CACF,CAAC,EAEH,MAAO,CACL,WAAYW,EACZ,OAAQ,IAAM,CACZD,IAAqB,EACrBE,EAAY,CACd,CACF,CACF,CAEQ,mCAMNH,EAC6D,CAC7D,KAAM,CAAE,WAAAT,EAAY,OAAAC,CAAO,EAAIQ,EAAa,SAAS,CACnD,SAAU,MAAOJ,GAAqB,KAAK,wBAAwBA,CAAI,EACvE,YAAa,MACXZ,GACG,KAAK,2BAA2BA,CAAO,EAC5C,eAAgB,IAAM,KAAK,iBAAiB,YAC5C,sBAAuB,IAAM,KAAK,aAAa,SAAS,EACxD,gCAAiC,IAAM,KAAK,MAC5C,sBAAwBE,IACtB,KAAK,sBAAsBA,CAAK,EACzB,KAAK,aAAa,SAAS,GAEpC,qBAAsB,IAAM,KAAK,mBACjC,wBAAyB,IAAM,KAAK,qBACtC,CAAC,EAED,MAAO,CACL,WAAAK,EACA,OAAAC,CACF,CACF,CAEO,OAAc,CACnB,KAAK,oBAAoB,eAAa,aAAa,EACnD,KAAK,aAAa,SAAS,EAC3B,KAAK,wBAAwB,cAAc,EAC3C,KAAK,QAAQ,YAAY,CAC3B,CAEO,iBAAiBhB,EAAwB,CAC9C,OAAO,KAAK,kBAAkB,iBAAiBA,CAAE,CACnD,CAEO,yBAAyB4B,EAAuB,CACrD,KAAK,mBAAqBA,CAC5B,CAEQ,oBAAoBC,EAAkC,CAC5D,MAAMnB,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,aAAa,KAAK,CAAE,GAAGA,EAAO,aAAAmB,CAAa,CAAC,CACnD,CACF",
4
+ "sourcesContent": ["import { type Either } from \"purify-ts\";\nimport {\n BehaviorSubject,\n from,\n lastValueFrom,\n type Observable,\n timeout,\n} from \"rxjs\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport { type Command } from \"@api/command/Command\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport { CommandUtils } from \"@api/command/utils/CommandUtils\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"@api/device-action/DeviceAction\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport {\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\nimport {\n SendApduTimeoutError,\n SendCommandTimeoutError,\n} from \"@api/transport/model/Errors\";\nimport { type TransportConnectedDevice } from \"@api/transport/model/TransportConnectedDevice\";\nimport {\n formatApduReceivedLog,\n formatApduSendingLog,\n} from \"@api/utils/apduLogs\";\nimport { DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS } from \"@internal/device-session/data/DeviceSessionRefresherConst\";\nimport { IntentQueueService } from \"@internal/device-session/service/IntentQueueService\";\nimport { RefresherService } from \"@internal/device-session/service/RefresherService\";\nimport { type ManagerApiService } from \"@internal/manager-api/service/ManagerApiService\";\nimport { type SecureChannelService } from \"@internal/secure-channel/service/SecureChannelService\";\n\nimport { DevicePinger } from \"./DevicePinger\";\nimport {\n DeviceSessionEventDispatcher,\n SessionEvents,\n} from \"./DeviceSessionEventDispatcher\";\nimport { DeviceSessionRefresher } from \"./DeviceSessionRefresher\";\nimport { DeviceSessionStateHandler } from \"./DeviceSessionStateHandler\";\n\nexport type SessionConstructorArgs = {\n connectedDevice: TransportConnectedDevice;\n id?: DeviceSessionId;\n};\n\nexport type DeviceSessionRefresherOptions = {\n isRefresherDisabled: boolean;\n pollingInterval?: number;\n};\n\ntype SendApduOptions = {\n isPolling?: boolean;\n triggersDisconnection?: boolean;\n abortTimeout?: number;\n};\n\n/**\n * Represents a session with a device.\n */\nexport class DeviceSession {\n private readonly _id: DeviceSessionId;\n private readonly _connectedDevice: TransportConnectedDevice;\n private readonly _deviceState: BehaviorSubject<DeviceSessionState>;\n private readonly _managerApiService: ManagerApiService;\n private readonly _secureChannelService: SecureChannelService;\n private readonly _logger: LoggerPublisherService;\n private readonly _loggerModuleFactory: (\n tag: string,\n ) => LoggerPublisherService;\n private readonly _refresherOptions: DeviceSessionRefresherOptions;\n private _pinger: DevicePinger;\n private _deviceSessionRefresher: DeviceSessionRefresher;\n private readonly _refresherService: RefresherService;\n private readonly _intentQueueService: IntentQueueService;\n private _sessionEventDispatcher = new DeviceSessionEventDispatcher();\n private _bypassIntentQueue: boolean = false;\n\n constructor(\n { connectedDevice, id = uuidv4() }: SessionConstructorArgs,\n loggerModuleFactory: (tag: string) => LoggerPublisherService,\n managerApiService: ManagerApiService,\n secureChannelService: SecureChannelService,\n deviceSessionRefresherOptions: DeviceSessionRefresherOptions | undefined,\n intentQueueServiceFactory: (\n sessionEventDispatcher: DeviceSessionEventDispatcher,\n ) => IntentQueueService = (sessionEventDispatcher) =>\n new IntentQueueService(loggerModuleFactory, sessionEventDispatcher),\n ) {\n this._id = id;\n this._connectedDevice = connectedDevice;\n this._loggerModuleFactory = loggerModuleFactory;\n this._logger = loggerModuleFactory(\"device-session\");\n this._managerApiService = managerApiService;\n this._intentQueueService = intentQueueServiceFactory(\n this._sessionEventDispatcher,\n );\n this._secureChannelService = secureChannelService;\n this._refresherOptions = {\n ...DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,\n ...deviceSessionRefresherOptions,\n };\n this._deviceState = new BehaviorSubject<DeviceSessionState>({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n deviceModelId: this._connectedDevice.deviceModel.id,\n });\n\n this._pinger = new DevicePinger(\n loggerModuleFactory,\n connectedDevice,\n this._sessionEventDispatcher,\n (command, abortTimeout) => this.sendCommand(command, abortTimeout),\n );\n this._deviceSessionRefresher = new DeviceSessionRefresher(\n loggerModuleFactory,\n this._refresherOptions,\n this._sessionEventDispatcher,\n this._connectedDevice,\n );\n new DeviceSessionStateHandler(\n loggerModuleFactory,\n this._sessionEventDispatcher,\n this._connectedDevice,\n this._deviceState,\n (state) => this.setDeviceSessionState(state),\n );\n\n this._refresherService = new RefresherService(loggerModuleFactory, {\n start: () => this._deviceSessionRefresher.restartRefresher(),\n stop: () => this._deviceSessionRefresher.stopRefresher(),\n });\n }\n\n public async initialiseSession(): Promise<void> {\n try {\n if (this._refresherOptions.isRefresherDisabled) await this._pinger.ping();\n else this._deviceSessionRefresher.startRefresher();\n } catch (error) {\n this._logger.error(\"Error while initialising session\", {\n data: { error },\n });\n throw error;\n }\n }\n\n public get id(): DeviceSessionId {\n return this._id;\n }\n\n public get connectedDevice(): TransportConnectedDevice {\n return this._connectedDevice;\n }\n\n public get state(): Observable<DeviceSessionState> {\n return this._deviceState.asObservable();\n }\n\n public getDeviceSessionState(): DeviceSessionState {\n return this._deviceState.getValue();\n }\n\n public setDeviceSessionState(state: DeviceSessionState): void {\n this._deviceState.next(state);\n }\n\n public sendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalSendApdu(rawApdu, options);\n }\n return this._internalSendApdu(rawApdu, options);\n }\n\n private _internalSendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions,\n ): Promise<Either<DmkError, ApduResponse>> {\n const abortTimeout = options.abortTimeout;\n const beforeQueuedTimestamp = Date.now();\n const { observable, cancel } = this._intentQueueService.enqueue({\n type: \"send-apdu\",\n execute: () =>\n from(\n (async () => {\n const elapsedTime = Date.now() - beforeQueuedTimestamp;\n const result = await this._unsafeInternalSendApdu(rawApdu, {\n isPolling: options.isPolling,\n triggersDisconnection: options.triggersDisconnection,\n // Subtract the elapsed time to account for the time spent in the queue\n // to sync both observable and transport timeout\n abortTimeout: abortTimeout\n ? abortTimeout - elapsedTime\n : undefined,\n });\n return result;\n })(),\n ),\n });\n\n const timeoutObservable = abortTimeout\n ? observable.pipe(\n timeout({\n each: abortTimeout,\n with: () => {\n cancel();\n throw new SendApduTimeoutError();\n },\n }),\n )\n : observable;\n\n return lastValueFrom(timeoutObservable);\n }\n\n private async _unsafeInternalSendApdu(\n rawApdu: Uint8Array,\n options: SendApduOptions = {\n isPolling: false,\n triggersDisconnection: false,\n abortTimeout: undefined,\n },\n ): Promise<Either<DmkError, ApduResponse>> {\n this._logger.debug(formatApduSendingLog(rawApdu));\n const result = await this._connectedDevice.sendApdu(\n rawApdu,\n options.triggersDisconnection,\n options.abortTimeout,\n );\n\n return result\n .ifRight((response: ApduResponse) => {\n this._logger.debug(formatApduReceivedLog(response));\n if (CommandUtils.isLockedDeviceResponse(response)) {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_LOCKED,\n });\n } else {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_CONNECTED,\n });\n }\n })\n .ifLeft(() => {\n this._sessionEventDispatcher.dispatch({\n eventName: SessionEvents.DEVICE_STATE_UPDATE_UNKNOWN,\n });\n });\n }\n\n public sendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n this._logger.debug(`[sendCommand] ${command.name}`);\n\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalSendCommand(command, abortTimeout);\n }\n return this._internalSendCommand(command, abortTimeout);\n }\n\n private _internalSendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const beforeQueuedTimestamp = Date.now();\n const { observable, cancel } = this._intentQueueService.enqueue({\n type: \"send-command\",\n execute: () =>\n from(\n (async () => {\n const elapsedTime = Date.now() - beforeQueuedTimestamp;\n const result = await this._unsafeInternalSendCommand(\n command,\n // Subtract the elapsed time to account for the time spent in the queue\n // to sync both observable and transport timeout\n abortTimeout ? abortTimeout - elapsedTime : undefined,\n );\n return result;\n })(),\n ),\n });\n\n const timeoutObservable = abortTimeout\n ? observable.pipe(\n timeout({\n each: abortTimeout,\n with: () => {\n cancel();\n throw new SendCommandTimeoutError();\n },\n }),\n )\n : observable;\n\n return lastValueFrom(timeoutObservable);\n }\n\n private async _unsafeInternalSendCommand<Response, Args, ErrorStatusCodes>(\n command: Command<Response, Args, ErrorStatusCodes>,\n abortTimeout?: number,\n ): Promise<CommandResult<Response, ErrorStatusCodes>> {\n const apdu = command.getApdu();\n\n const response = await this._unsafeInternalSendApdu(apdu.getRawApdu(), {\n isPolling: false,\n triggersDisconnection: command.triggersDisconnection ?? false,\n abortTimeout,\n });\n\n return response.caseOf({\n Left: (err) => {\n this._logger.error(\"[sendCommand] error\", { data: { err } });\n throw err;\n },\n Right: (r) => {\n const result = command.parseResponse(\n r,\n this._connectedDevice.deviceModel.id,\n );\n this._logger.debug(\"[sendCommand] result\", { data: { result } });\n return result;\n },\n });\n }\n\n public executeDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n // Bypass intent queue if flag is set\n if (this._bypassIntentQueue) {\n return this._unsafeInternalExecuteDeviceAction(deviceAction);\n }\n return this._internalExecuteDeviceAction(deviceAction);\n }\n\n private _internalExecuteDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n let deviceActionCancel: (() => void) | undefined;\n\n const { observable: o, cancel: queueCancel } =\n this._intentQueueService.enqueue({\n type: \"device-action\",\n execute: () => {\n const { observable, cancel } =\n this._unsafeInternalExecuteDeviceAction(deviceAction);\n deviceActionCancel = cancel;\n return observable;\n },\n });\n\n return {\n observable: o,\n cancel: () => {\n deviceActionCancel?.();\n queueCancel();\n },\n };\n }\n\n private _unsafeInternalExecuteDeviceAction<\n Output,\n Input,\n E extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n deviceAction: DeviceAction<Output, Input, E, IntermediateValue>,\n ): ExecuteDeviceActionReturnType<Output, E, IntermediateValue> {\n const { observable, cancel } = deviceAction._execute({\n sendApdu: async (apdu: Uint8Array) => this._unsafeInternalSendApdu(apdu), // note: there is no timeout handled at this stage\n sendCommand: async <Response, ErrorStatusCodes, Args>(\n command: Command<Response, ErrorStatusCodes, Args>,\n ) => this._unsafeInternalSendCommand(command), // note: there is no timeout handled at this stage\n getDeviceModel: () => this._connectedDevice.deviceModel,\n getDeviceSessionState: () => this._deviceState.getValue(),\n getDeviceSessionStateObservable: () => this.state,\n setDeviceSessionState: (state: DeviceSessionState) => {\n this.setDeviceSessionState(state);\n return this._deviceState.getValue();\n },\n getManagerApiService: () => this._managerApiService,\n getSecureChannelService: () => this._secureChannelService,\n loggerFactory: this._loggerModuleFactory,\n });\n\n return {\n observable,\n cancel,\n };\n }\n\n public close(): void {\n this._updateDeviceStatus(DeviceStatus.NOT_CONNECTED);\n this._deviceState.complete();\n this._deviceSessionRefresher.stopRefresher();\n this._pinger.unsubscribe();\n }\n\n public disableRefresher(id: string): () => void {\n return this._refresherService.disableRefresher(id);\n }\n\n public _unsafeBypassIntentQueue(bypass: boolean): void {\n this._bypassIntentQueue = bypass;\n }\n\n private _updateDeviceStatus(deviceStatus: DeviceStatus): void {\n const state = this._deviceState.getValue();\n this._deviceState.next({ ...state, deviceStatus });\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GACA,I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,wBAAyB,IAAM,KAAK,sBACpC,cAAe,KAAK,oBACtB,CAAC,EAED,MAAO,CACL,WAAAK,EACA,OAAAC,CACF,CACF,CAEO,OAAc,CACnB,KAAK,oBAAoB,eAAa,aAAa,EACnD,KAAK,aAAa,SAAS,EAC3B,KAAK,wBAAwB,cAAc,EAC3C,KAAK,QAAQ,YAAY,CAC3B,CAEO,iBAAiBhB,EAAwB,CAC9C,OAAO,KAAK,kBAAkB,iBAAiBA,CAAE,CACnD,CAEO,yBAAyB4B,EAAuB,CACrD,KAAK,mBAAqBA,CAC5B,CAEQ,oBAAoBC,EAAkC,CAC5D,MAAMnB,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,aAAa,KAAK,CAAE,GAAGA,EAAO,aAAAmB,CAAa,CAAC,CACnD,CACF",
6
6
  "names": ["DeviceSession_exports", "__export", "DeviceSession", "__toCommonJS", "import_rxjs", "import_uuid", "import_CommandUtils", "import_DeviceStatus", "import_DeviceSessionState", "import_Errors", "import_apduLogs", "import_DeviceSessionRefresherConst", "import_IntentQueueService", "import_RefresherService", "import_DevicePinger", "import_DeviceSessionEventDispatcher", "import_DeviceSessionRefresher", "import_DeviceSessionStateHandler", "connectedDevice", "id", "uuidv4", "loggerModuleFactory", "managerApiService", "secureChannelService", "deviceSessionRefresherOptions", "intentQueueServiceFactory", "sessionEventDispatcher", "command", "abortTimeout", "state", "error", "rawApdu", "options", "beforeQueuedTimestamp", "observable", "cancel", "elapsedTime", "timeoutObservable", "response", "apdu", "err", "r", "result", "deviceAction", "deviceActionCancel", "o", "queueCancel", "bypass", "deviceStatus"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var y=require("purify-ts"),r=require("rxjs"),m=require("rxjs/operators"),D=require("../../../api/command/model/CommandResult"),S=require("../../../api/device/DeviceStatus"),h=require("../../../api/device-session/DeviceSessionState"),C=require("../../../api/transport/model/TransportConnectedDevice.stub"),g=require("../../logger-publisher/service/DefaultLoggerPublisherService"),v=require("./DeviceSession");describe("DeviceSession",()=>{let e,k,u,d,l,o,p,b;const a=(0,C.connectedDeviceStubBuilder)();beforeEach(()=>{k=new g.DefaultLoggerPublisherService([],"device-session-test"),u=vi.fn(()=>k),d={getAppList:vi.fn(),getAppsByHash:vi.fn(),getCurrentFirmware:vi.fn(),getLatestFirmware:vi.fn()},l={genuineCheck:vi.fn(),listInstalledApps:vi.fn(),updateMcu:vi.fn(),updateFirmware:vi.fn(),installApp:vi.fn(),uninstallApp:vi.fn()},o={enqueue:vi.fn().mockReturnValue({observable:(0,r.of)(null).pipe((0,m.delay)(1)),cancel:vi.fn()})},p=()=>o,b={isRefresherDisabled:!0}}),afterEach(()=>{e?.close(),vi.restoreAllMocks()}),describe("constructor",()=>{it("should create a device session with default id",()=>{e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p),expect(e).toBeDefined(),expect(e.id).toBeDefined(),expect(e.connectedDevice).toBe(a)}),it("should create a device session with custom id",()=>{const t="custom-session-id";e=new v.DeviceSession({connectedDevice:a,id:t},u,d,l,b,p),expect(e.id).toBe(t)})}),describe("initialiseSession",()=>{it("should successfully initialize session",()=>{e=new v.DeviceSession({connectedDevice:a},u,d,l,{isRefresherDisabled:!1,pollingInterval:1e3},p);const t=vi.spyOn(e._deviceSessionRefresher,"startRefresher");e.initialiseSession(),expect(t).toHaveBeenCalled()})}),describe("getters",()=>{beforeEach(()=>{e=new v.DeviceSession({connectedDevice:a,id:"test-id"},u,d,l,b,p)}),it("should return session id",()=>{expect(e.id).toBe("test-id")}),it("should return connected device",()=>{expect(e.connectedDevice).toBe(a)}),it("should return state as observable",async()=>{const t=e.state;await new Promise(s=>{t.pipe((0,m.take)(1)).subscribe(n=>{expect(n.sessionStateType).toBe(h.DeviceSessionStateType.Connected),expect(n.deviceStatus).toBe(S.DeviceStatus.CONNECTED),s()})})})}),describe("getDeviceSessionState and setDeviceSessionState",()=>{beforeEach(()=>{e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p)}),it("should get current device session state",()=>{const t=e.getDeviceSessionState();expect(t.sessionStateType).toBe(h.DeviceSessionStateType.Connected),expect(t.deviceStatus).toBe(S.DeviceStatus.CONNECTED)}),it("should set device session state",async()=>{const t={sessionStateType:h.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:S.DeviceStatus.LOCKED,deviceModelId:a.deviceModel.id,currentApp:{name:"Test",version:"1.0.0"},installedApps:[],isSecureConnectionAllowed:!1};await new Promise(s=>{let n=!1;const c=e.state.subscribe(i=>{i.sessionStateType===h.DeviceSessionStateType.ReadyWithoutSecureChannel?(expect(i).toMatchObject({sessionStateType:h.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:S.DeviceStatus.LOCKED,deviceModelId:a.deviceModel.id}),c.unsubscribe(),s()):n||(n=!0)});e.setDeviceSessionState(t)})})}),describe("sendApdu",()=>{let t,s;beforeEach(()=>{t=new Uint8Array([224,1,0,0]),s={data:new Uint8Array([1,2]),statusCode:new Uint8Array([144,0])},e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p)}),it("should successfully send APDU",async()=>{const n=(0,r.of)((0,y.Right)(s)).pipe((0,m.delay)(1));o.enqueue.mockReturnValue({observable:n,cancel:vi.fn()});const c=await e.sendApdu(t);expect(o.enqueue).toHaveBeenCalledWith({type:"send-apdu",execute:expect.any(Function)}),expect(c.isRight()).toBe(!0),c.ifRight(i=>{expect(i).toEqual(s)})}),it("should handle APDU send error",async()=>{const n={_tag:"SendApduError"},c=(0,r.of)((0,y.Left)(n)).pipe((0,m.delay)(1));o.enqueue.mockReturnValue({observable:c,cancel:vi.fn()});const i=await e.sendApdu(t);expect(i.isLeft()).toBe(!0),i.ifLeft(f=>{expect(f).toEqual(n)})}),it("should handle APDU timeout",async()=>{const n=vi.fn(),c=new r.Subject;o.enqueue.mockReturnValue({observable:c.asObservable(),cancel:n}),vi.useFakeTimers();const i=e.sendApdu(t,{abortTimeout:1e3});vi.advanceTimersByTime(1100);let f;try{await i}catch(x){f=x}vi.useRealTimers(),expect(f).toBeDefined(),expect(o.enqueue).toHaveBeenCalled()})}),describe("sendCommand",()=>{let t,s;beforeEach(()=>{s={status:D.CommandResultStatus.Success,data:{test:"data"}},t={getApdu:vi.fn().mockReturnValue({getRawApdu:()=>new Uint8Array([224,1,0,0])}),parseResponse:vi.fn().mockReturnValue(s),triggersDisconnection:!1},e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p)}),it("should successfully send command",async()=>{const n=(0,r.of)(s).pipe((0,m.delay)(1));o.enqueue.mockReturnValue({observable:n,cancel:vi.fn()});const c=await e.sendCommand(t);expect(o.enqueue).toHaveBeenCalledWith({type:"send-command",execute:expect.any(Function)}),expect(c).toEqual(s)}),it("should handle command timeout",async()=>{const n=vi.fn(),c=new r.Subject;o.enqueue.mockReturnValue({observable:c.asObservable(),cancel:n}),vi.useFakeTimers();const i=e.sendCommand(t,1e3);vi.advanceTimersByTime(1100);try{await i}catch{}vi.useRealTimers(),expect(o.enqueue).toHaveBeenCalled()}),it("should handle command error",async()=>{const n=new Error("Command failed"),c=(0,r.throwError)(()=>n);o.enqueue.mockReturnValue({observable:c,cancel:vi.fn()}),await expect(e.sendCommand(t)).rejects.toThrow("Command failed")})}),describe("executeDeviceAction",()=>{let t;beforeEach(()=>{const s=(0,r.of)({intermediateValue:"test",requiredUserInteraction:"SignTransaction"}).pipe((0,m.delay)(1));t={_execute:vi.fn().mockReturnValue({observable:s})},e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p)}),it("should execute device action",async()=>{const s=(0,r.of)({intermediateValue:"test",requiredUserInteraction:"SignTransaction"}).pipe((0,m.delay)(1)),n=vi.fn();o.enqueue.mockReturnValue({observable:s,cancel:n});const{observable:c,cancel:i}=e.executeDeviceAction(t);expect(o.enqueue).toHaveBeenCalledWith({type:"device-action",execute:expect.any(Function)}),expect(c).toBeDefined(),expect(i).toBeTypeOf("function");const f=[];await new Promise(x=>{c.subscribe({next:A=>f.push(A),complete:()=>x()})}),expect(f).toEqual([{intermediateValue:"test",requiredUserInteraction:"SignTransaction"}]),i(),expect(n).toHaveBeenCalled()}),it("should provide correct internal API to device action",()=>{const s=(0,r.of)({intermediateValue:"test",requiredUserInteraction:"SignTransaction"}).pipe((0,m.delay)(1));o.enqueue.mockImplementation(n=>(n.execute(),{observable:s,cancel:vi.fn()})),e.executeDeviceAction(t),expect(t._execute).toHaveBeenCalledWith({sendApdu:expect.any(Function),sendCommand:expect.any(Function),getDeviceModel:expect.any(Function),getDeviceSessionState:expect.any(Function),getDeviceSessionStateObservable:expect.any(Function),setDeviceSessionState:expect.any(Function),getManagerApiService:expect.any(Function),getSecureChannelService:expect.any(Function)})}),it("should allow cancelling device action",()=>{const s=vi.fn(),n=new r.Subject;o.enqueue.mockReturnValue({observable:n.asObservable(),cancel:s});const{cancel:c}=e.executeDeviceAction(t);c(),expect(s).toHaveBeenCalled()})}),describe("close",()=>{it("should close the session and update device status",()=>{e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p);let t=!1;e.state.subscribe({complete:()=>{t=!0}}),e.close();const s=e.getDeviceSessionState();expect(s.deviceStatus).toBe(S.DeviceStatus.NOT_CONNECTED),expect(t).toBe(!0)})})});
1
+ "use strict";var h=require("purify-ts"),r=require("rxjs"),m=require("rxjs/operators"),D=require("../../../api/command/model/CommandResult"),S=require("../../../api/device/DeviceStatus"),y=require("../../../api/device-session/DeviceSessionState"),C=require("../../../api/transport/model/TransportConnectedDevice.stub"),g=require("../../logger-publisher/service/DefaultLoggerPublisherService"),v=require("./DeviceSession");describe("DeviceSession",()=>{let e,k,u,d,l,o,p,b;const a=(0,C.connectedDeviceStubBuilder)();beforeEach(()=>{k=new g.DefaultLoggerPublisherService([],"device-session-test"),u=vi.fn(()=>k),d={getAppList:vi.fn(),getAppsByHash:vi.fn(),getCurrentFirmware:vi.fn(),getLatestFirmware:vi.fn()},l={genuineCheck:vi.fn(),listInstalledApps:vi.fn(),updateMcu:vi.fn(),updateFirmware:vi.fn(),installApp:vi.fn(),uninstallApp:vi.fn()},o={enqueue:vi.fn().mockReturnValue({observable:(0,r.of)(null).pipe((0,m.delay)(1)),cancel:vi.fn()})},p=()=>o,b={isRefresherDisabled:!0}}),afterEach(()=>{e?.close(),vi.restoreAllMocks()}),describe("constructor",()=>{it("should create a device session with default id",()=>{e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p),expect(e).toBeDefined(),expect(e.id).toBeDefined(),expect(e.connectedDevice).toBe(a)}),it("should create a device session with custom id",()=>{const t="custom-session-id";e=new v.DeviceSession({connectedDevice:a,id:t},u,d,l,b,p),expect(e.id).toBe(t)})}),describe("initialiseSession",()=>{it("should successfully initialize session",()=>{e=new v.DeviceSession({connectedDevice:a},u,d,l,{isRefresherDisabled:!1,pollingInterval:1e3},p);const t=vi.spyOn(e._deviceSessionRefresher,"startRefresher");e.initialiseSession(),expect(t).toHaveBeenCalled()})}),describe("getters",()=>{beforeEach(()=>{e=new v.DeviceSession({connectedDevice:a,id:"test-id"},u,d,l,b,p)}),it("should return session id",()=>{expect(e.id).toBe("test-id")}),it("should return connected device",()=>{expect(e.connectedDevice).toBe(a)}),it("should return state as observable",async()=>{const t=e.state;await new Promise(c=>{t.pipe((0,m.take)(1)).subscribe(n=>{expect(n.sessionStateType).toBe(y.DeviceSessionStateType.Connected),expect(n.deviceStatus).toBe(S.DeviceStatus.CONNECTED),c()})})})}),describe("getDeviceSessionState and setDeviceSessionState",()=>{beforeEach(()=>{e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p)}),it("should get current device session state",()=>{const t=e.getDeviceSessionState();expect(t.sessionStateType).toBe(y.DeviceSessionStateType.Connected),expect(t.deviceStatus).toBe(S.DeviceStatus.CONNECTED)}),it("should set device session state",async()=>{const t={sessionStateType:y.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:S.DeviceStatus.LOCKED,deviceModelId:a.deviceModel.id,currentApp:{name:"Test",version:"1.0.0"},installedApps:[],isSecureConnectionAllowed:!1};await new Promise(c=>{let n=!1;const s=e.state.subscribe(i=>{i.sessionStateType===y.DeviceSessionStateType.ReadyWithoutSecureChannel?(expect(i).toMatchObject({sessionStateType:y.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:S.DeviceStatus.LOCKED,deviceModelId:a.deviceModel.id}),s.unsubscribe(),c()):n||(n=!0)});e.setDeviceSessionState(t)})})}),describe("sendApdu",()=>{let t,c;beforeEach(()=>{t=new Uint8Array([224,1,0,0]),c={data:new Uint8Array([1,2]),statusCode:new Uint8Array([144,0])},e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p)}),it("should successfully send APDU",async()=>{const n=(0,r.of)((0,h.Right)(c)).pipe((0,m.delay)(1));o.enqueue.mockReturnValue({observable:n,cancel:vi.fn()});const s=await e.sendApdu(t);expect(o.enqueue).toHaveBeenCalledWith({type:"send-apdu",execute:expect.any(Function)}),expect(s.isRight()).toBe(!0),s.ifRight(i=>{expect(i).toEqual(c)})}),it("should handle APDU send error",async()=>{const n={_tag:"SendApduError"},s=(0,r.of)((0,h.Left)(n)).pipe((0,m.delay)(1));o.enqueue.mockReturnValue({observable:s,cancel:vi.fn()});const i=await e.sendApdu(t);expect(i.isLeft()).toBe(!0),i.ifLeft(f=>{expect(f).toEqual(n)})}),it("should handle APDU timeout",async()=>{const n=vi.fn(),s=new r.Subject;o.enqueue.mockReturnValue({observable:s.asObservable(),cancel:n}),vi.useFakeTimers();const i=e.sendApdu(t,{abortTimeout:1e3});vi.advanceTimersByTime(1100);let f;try{await i}catch(x){f=x}vi.useRealTimers(),expect(f).toBeDefined(),expect(o.enqueue).toHaveBeenCalled()})}),describe("sendCommand",()=>{let t,c;beforeEach(()=>{c={status:D.CommandResultStatus.Success,data:{test:"data"}},t={getApdu:vi.fn().mockReturnValue({getRawApdu:()=>new Uint8Array([224,1,0,0])}),parseResponse:vi.fn().mockReturnValue(c),triggersDisconnection:!1},e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p)}),it("should successfully send command",async()=>{const n=(0,r.of)(c).pipe((0,m.delay)(1));o.enqueue.mockReturnValue({observable:n,cancel:vi.fn()});const s=await e.sendCommand(t);expect(o.enqueue).toHaveBeenCalledWith({type:"send-command",execute:expect.any(Function)}),expect(s).toEqual(c)}),it("should handle command timeout",async()=>{const n=vi.fn(),s=new r.Subject;o.enqueue.mockReturnValue({observable:s.asObservable(),cancel:n}),vi.useFakeTimers();const i=e.sendCommand(t,1e3);vi.advanceTimersByTime(1100);try{await i}catch{}vi.useRealTimers(),expect(o.enqueue).toHaveBeenCalled()}),it("should handle command error",async()=>{const n=new Error("Command failed"),s=(0,r.throwError)(()=>n);o.enqueue.mockReturnValue({observable:s,cancel:vi.fn()}),await expect(e.sendCommand(t)).rejects.toThrow("Command failed")})}),describe("executeDeviceAction",()=>{let t;beforeEach(()=>{const c=(0,r.of)({intermediateValue:"test",requiredUserInteraction:"SignTransaction"}).pipe((0,m.delay)(1));t={_execute:vi.fn().mockReturnValue({observable:c})},e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p)}),it("should execute device action",async()=>{const c=(0,r.of)({intermediateValue:"test",requiredUserInteraction:"SignTransaction"}).pipe((0,m.delay)(1)),n=vi.fn();o.enqueue.mockReturnValue({observable:c,cancel:n});const{observable:s,cancel:i}=e.executeDeviceAction(t);expect(o.enqueue).toHaveBeenCalledWith({type:"device-action",execute:expect.any(Function)}),expect(s).toBeDefined(),expect(i).toBeTypeOf("function");const f=[];await new Promise(x=>{s.subscribe({next:A=>f.push(A),complete:()=>x()})}),expect(f).toEqual([{intermediateValue:"test",requiredUserInteraction:"SignTransaction"}]),i(),expect(n).toHaveBeenCalled()}),it("should provide correct internal API to device action",()=>{const c=(0,r.of)({intermediateValue:"test",requiredUserInteraction:"SignTransaction"}).pipe((0,m.delay)(1));o.enqueue.mockImplementation(n=>(n.execute(),{observable:c,cancel:vi.fn()})),e.executeDeviceAction(t),expect(t._execute).toHaveBeenCalledWith({sendApdu:expect.any(Function),sendCommand:expect.any(Function),getDeviceModel:expect.any(Function),getDeviceSessionState:expect.any(Function),getDeviceSessionStateObservable:expect.any(Function),setDeviceSessionState:expect.any(Function),getManagerApiService:expect.any(Function),getSecureChannelService:expect.any(Function),loggerFactory:expect.any(Function)})}),it("should allow cancelling device action",()=>{const c=vi.fn(),n=new r.Subject;o.enqueue.mockReturnValue({observable:n.asObservable(),cancel:c});const{cancel:s}=e.executeDeviceAction(t);s(),expect(c).toHaveBeenCalled()})}),describe("close",()=>{it("should close the session and update device status",()=>{e=new v.DeviceSession({connectedDevice:a},u,d,l,b,p);let t=!1;e.state.subscribe({complete:()=>{t=!0}}),e.close();const c=e.getDeviceSessionState();expect(c.deviceStatus).toBe(S.DeviceStatus.NOT_CONNECTED),expect(t).toBe(!0)})})});
2
2
  //# sourceMappingURL=DeviceSession.test.js.map