@ledgerhq/device-management-kit 0.0.0-develop-20260629003450 → 0.0.0-develop-20260701003433
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/api/utils/apduLogs.js +1 -1
- package/lib/cjs/src/api/utils/apduLogs.js.map +3 -3
- package/lib/cjs/src/api/utils/apduLogs.test.js +1 -1
- package/lib/cjs/src/api/utils/apduLogs.test.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/api/utils/apduLogs.js +1 -1
- package/lib/esm/src/api/utils/apduLogs.js.map +3 -3
- package/lib/esm/src/api/utils/apduLogs.test.js +1 -1
- package/lib/esm/src/api/utils/apduLogs.test.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
- package/lib/types/src/api/utils/apduLogs.d.ts +15 -0
- package/lib/types/src/api/utils/apduLogs.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +2 -2
package/lib/cjs/package.json
CHANGED
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
63
63
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
64
64
|
},
|
|
65
|
-
"version": "0.0.0-develop-
|
|
65
|
+
"version": "0.0.0-develop-20260701003433"
|
|
66
66
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})},A=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!f.call(e,s)&&s!==r&&a(e,s,{get:()=>t[s],enumerable:!(o=i(t,s))||o.enumerable});return e};var c=e=>A(a({},"__esModule",{value:!0}),e);var y={};d(y,{APDU_EXCHANGE_LOG:()=>p,formatApduExchangeLog:()=>l,formatApduReceivedLog:()=>g,formatApduSendingLog:()=>x,formatApduSentLog:()=>m});module.exports=c(y);var n=require("./HexaString");function x(e){return`[will send APDU] ~...> ${(0,n.bufferToHexaString)(e,!1)}`}function m(e){return`[exchange] => ${(0,n.bufferToHexaString)(e,!1)}`}function g(e){return`[exchange] <= ${(0,n.bufferToHexaString)(e.data,!1)}${(0,n.bufferToHexaString)(e.statusCode,!1)}`}const p="apdu-exchange";function l(e,t,r){const o=(0,n.bufferToHexaString)(t,!1),s=`${(0,n.bufferToHexaString)(r.data,!1)}${(0,n.bufferToHexaString)(r.statusCode,!1)}`;return{message:g(r),data:{type:p,sessionId:e,apdu:o,response:s}}}0&&(module.exports={APDU_EXCHANGE_LOG,formatApduExchangeLog,formatApduReceivedLog,formatApduSendingLog,formatApduSentLog});
|
|
2
2
|
//# sourceMappingURL=apduLogs.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/api/utils/apduLogs.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { bufferToHexaString } from \"./HexaString\";\n\n/**\n * Formats the log message for an APDU that is about to be sent.\n * Only call this at the device session layer, before calling sendApdu on the connected device.\n */\nexport function formatApduSendingLog(apdu: Uint8Array): string {\n return `[will send APDU] ~...> ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU that was sent.\n * Only call this at the transport layer, after the APDU sending logic has been executed\n * without any error.\n */\nexport function formatApduSentLog(apdu: Uint8Array): string {\n return `[exchange] => ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU response received from the device.\n */\nexport function formatApduReceivedLog(apduResponse: ApduResponse): string {\n return `[exchange] <= ${bufferToHexaString(apduResponse.data, false)}${bufferToHexaString(apduResponse.statusCode, false)}`;\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,
|
|
6
|
-
"names": ["apduLogs_exports", "__export", "formatApduReceivedLog", "formatApduSendingLog", "formatApduSentLog", "__toCommonJS", "import_HexaString", "apdu", "apduResponse"]
|
|
4
|
+
"sourcesContent": ["import { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { bufferToHexaString } from \"./HexaString\";\n\n/**\n * Formats the log message for an APDU that is about to be sent.\n * Only call this at the device session layer, before calling sendApdu on the connected device.\n */\nexport function formatApduSendingLog(apdu: Uint8Array): string {\n return `[will send APDU] ~...> ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU that was sent.\n * Only call this at the transport layer, after the APDU sending logic has been executed\n * without any error.\n */\nexport function formatApduSentLog(apdu: Uint8Array): string {\n return `[exchange] => ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU response received from the device.\n */\nexport function formatApduReceivedLog(apduResponse: ApduResponse): string {\n return `[exchange] <= ${bufferToHexaString(apduResponse.data, false)}${bufferToHexaString(apduResponse.statusCode, false)}`;\n}\n\nexport const APDU_EXCHANGE_LOG = \"apdu-exchange\";\n\nexport type ApduExchangeLog = {\n type: typeof APDU_EXCHANGE_LOG;\n sessionId: string;\n apdu: string;\n response: string;\n};\n\n/**\n * Formats the log message and builds the structured `data` payload for a completed APDU exchange\n * (request + response).\n */\nexport function formatApduExchangeLog(\n sessionId: string,\n apdu: Uint8Array,\n apduResponse: ApduResponse,\n): { message: string; data: ApduExchangeLog } {\n const request = bufferToHexaString(apdu, false);\n const response = `${bufferToHexaString(apduResponse.data, false)}${bufferToHexaString(apduResponse.statusCode, false)}`;\n return {\n message: formatApduReceivedLog(apduResponse),\n data: { type: APDU_EXCHANGE_LOG, sessionId, apdu: request, response },\n };\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,0BAAAC,EAAA,0BAAAC,EAAA,yBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAP,GAEA,IAAAQ,EAAmC,wBAM5B,SAASH,EAAqBI,EAA0B,CAC7D,MAAO,6BAA0B,sBAAmBA,EAAM,EAAK,CAAC,EAClE,CAOO,SAASH,EAAkBG,EAA0B,CAC1D,MAAO,oBAAiB,sBAAmBA,EAAM,EAAK,CAAC,EACzD,CAKO,SAASL,EAAsBM,EAAoC,CACxE,MAAO,oBAAiB,sBAAmBA,EAAa,KAAM,EAAK,CAAC,MAAG,sBAAmBA,EAAa,WAAY,EAAK,CAAC,EAC3H,CAEO,MAAMR,EAAoB,gBAa1B,SAASC,EACdQ,EACAF,EACAC,EAC4C,CAC5C,MAAME,KAAU,sBAAmBH,EAAM,EAAK,EACxCI,EAAW,MAAG,sBAAmBH,EAAa,KAAM,EAAK,CAAC,MAAG,sBAAmBA,EAAa,WAAY,EAAK,CAAC,GACrH,MAAO,CACL,QAASN,EAAsBM,CAAY,EAC3C,KAAM,CAAE,KAAMR,EAAmB,UAAAS,EAAW,KAAMC,EAAS,SAAAC,CAAS,CACtE,CACF",
|
|
6
|
+
"names": ["apduLogs_exports", "__export", "APDU_EXCHANGE_LOG", "formatApduExchangeLog", "formatApduReceivedLog", "formatApduSendingLog", "formatApduSentLog", "__toCommonJS", "import_HexaString", "apdu", "apduResponse", "sessionId", "request", "response"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=require("vitest"),o=require("./apduLogs");(0,e.describe)("apduLogs",()=>{(0,e.describe)("formatApduSendingLog",()=>{(0,e.it)("should format APDU with correct format before sending",()=>{const t=Uint8Array.from([224,1,0,0,4]);(0,e.expect)((0,o.formatApduSendingLog)(t)).toBe("[will send APDU] ~...> e001000004")}),(0,e.it)("should handle empty APDU",()=>{const t=Uint8Array.from([]);(0,e.expect)((0,o.formatApduSendingLog)(t)).toBe("[will send APDU] ~...> ")})}),(0,e.describe)("formatApduSentLog",()=>{(0,e.it)("should format APDU with correct format after sending",()=>{const t=Uint8Array.from([224,1,0,0,4]);(0,e.expect)((0,o.formatApduSentLog)(t)).toBe("[exchange] => e001000004")}),(0,e.it)("should handle empty APDU",()=>{const t=Uint8Array.from([]);(0,e.expect)((0,o.formatApduSentLog)(t)).toBe("[exchange] => ")})}),(0,e.describe)("formatApduReceivedLog",()=>{(0,e.it)("should format APDU response with data and status code",()=>{const t={data:Uint8Array.from([1,2,3]),statusCode:Uint8Array.from([144,0])};(0,e.expect)((0,o.formatApduReceivedLog)(t)).toBe("[exchange] <= 0102039000")}),(0,e.it)("should format APDU response with only status code when data is empty",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([144,0])};(0,e.expect)((0,o.formatApduReceivedLog)(t)).toBe("[exchange] <= 9000")}),(0,e.it)("should format error status code correctly",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([105,133])};(0,e.expect)((0,o.formatApduReceivedLog)(t)).toBe("[exchange] <= 6985")})}),(0,e.describe)("formatApduExchangeLog",()=>{(0,e.it)("should keep the legacy received-log message and expose structured data",()=>{const t=Uint8Array.from([224,1,0,0,4]),a={data:Uint8Array.from([1,2,3]),statusCode:Uint8Array.from([144,0])},{message:r,data:s}=(0,o.formatApduExchangeLog)("session-1",t,a);(0,e.expect)(r).toBe((0,o.formatApduReceivedLog)(a)),(0,e.expect)(r).toBe("[exchange] <= 0102039000"),(0,e.expect)(s).toEqual({type:o.APDU_EXCHANGE_LOG,sessionId:"session-1",apdu:"e001000004",response:"0102039000"})}),(0,e.it)("should concatenate empty data with the status word in the structured payload",()=>{const t=Uint8Array.from([176,1,0,0]),a={data:Uint8Array.from([]),statusCode:Uint8Array.from([85,21])},{message:r,data:s}=(0,o.formatApduExchangeLog)("session-2",t,a);(0,e.expect)(r).toBe("[exchange] <= 5515"),(0,e.expect)(s.apdu).toBe("b0010000"),(0,e.expect)(s.response).toBe("5515")})})});
|
|
2
2
|
//# sourceMappingURL=apduLogs.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/api/utils/apduLogs.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport {\n formatApduReceivedLog,\n formatApduSendingLog,\n formatApduSentLog,\n} from \"./apduLogs\";\n\ndescribe(\"apduLogs\", () => {\n describe(\"formatApduSendingLog\", () => {\n it(\"should format APDU with correct format before sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSendingLog(apdu)).toBe(\n \"[will send APDU] ~...> e001000004\",\n );\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSendingLog(apdu)).toBe(\"[will send APDU] ~...> \");\n });\n });\n\n describe(\"formatApduSentLog\", () => {\n it(\"should format APDU with correct format after sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => e001000004\");\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => \");\n });\n });\n\n describe(\"formatApduReceivedLog\", () => {\n it(\"should format APDU response with data and status code\", () => {\n const apduResponse = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\n \"[exchange] <= 0102039000\",\n );\n });\n\n it(\"should format APDU response with only status code when data is empty\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 9000\");\n });\n\n it(\"should format error status code correctly\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x69, 0x85]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 6985\");\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAAqC,kBAErCC,
|
|
6
|
-
"names": ["import_vitest", "import_apduLogs", "apdu", "apduResponse"]
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport {\n APDU_EXCHANGE_LOG,\n formatApduExchangeLog,\n formatApduReceivedLog,\n formatApduSendingLog,\n formatApduSentLog,\n} from \"./apduLogs\";\n\ndescribe(\"apduLogs\", () => {\n describe(\"formatApduSendingLog\", () => {\n it(\"should format APDU with correct format before sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSendingLog(apdu)).toBe(\n \"[will send APDU] ~...> e001000004\",\n );\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSendingLog(apdu)).toBe(\"[will send APDU] ~...> \");\n });\n });\n\n describe(\"formatApduSentLog\", () => {\n it(\"should format APDU with correct format after sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => e001000004\");\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => \");\n });\n });\n\n describe(\"formatApduReceivedLog\", () => {\n it(\"should format APDU response with data and status code\", () => {\n const apduResponse = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\n \"[exchange] <= 0102039000\",\n );\n });\n\n it(\"should format APDU response with only status code when data is empty\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 9000\");\n });\n\n it(\"should format error status code correctly\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x69, 0x85]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 6985\");\n });\n });\n\n describe(\"formatApduExchangeLog\", () => {\n it(\"should keep the legacy received-log message and expose structured data\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n const apduResponse = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n\n const { message, data } = formatApduExchangeLog(\n \"session-1\",\n apdu,\n apduResponse,\n );\n\n expect(message).toBe(formatApduReceivedLog(apduResponse));\n expect(message).toBe(\"[exchange] <= 0102039000\");\n expect(data).toEqual({\n type: APDU_EXCHANGE_LOG,\n sessionId: \"session-1\",\n apdu: \"e001000004\",\n response: \"0102039000\",\n });\n });\n\n it(\"should concatenate empty data with the status word in the structured payload\", () => {\n const apdu = Uint8Array.from([0xb0, 0x01, 0x00, 0x00]);\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x55, 0x15]),\n };\n\n const { message, data } = formatApduExchangeLog(\n \"session-2\",\n apdu,\n apduResponse,\n );\n\n expect(message).toBe(\"[exchange] <= 5515\");\n expect(data.apdu).toBe(\"b0010000\");\n expect(data.response).toBe(\"5515\");\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAAqC,kBAErCC,EAMO,yBAEP,YAAS,WAAY,IAAM,IACzB,YAAS,uBAAwB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CAC1C,KACA,aAAO,yBAAsBA,CAAY,CAAC,EAAE,KAAK,oBAAoB,CACvE,CAAC,CACH,CAAC,KAED,YAAS,wBAAyB,IAAM,IACtC,MAAG,yEAA0E,IAAM,CACjF,MAAMD,EAAO,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EACrDC,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,EAAM,EAAM,CAAI,CAAC,EACxC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,CAC1C,EAEM,CAAE,QAAAC,EAAS,KAAAC,CAAK,KAAI,yBACxB,YACAH,EACAC,CACF,KAEA,UAAOC,CAAO,EAAE,QAAK,yBAAsBD,CAAY,CAAC,KACxD,UAAOC,CAAO,EAAE,KAAK,0BAA0B,KAC/C,UAAOC,CAAI,EAAE,QAAQ,CACnB,KAAM,oBACN,UAAW,YACX,KAAM,aACN,SAAU,YACZ,CAAC,CACH,CAAC,KAED,MAAG,+EAAgF,IAAM,CACvF,MAAMH,EAAO,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAC/CC,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,WAAW,KAAK,CAAC,GAAM,EAAI,CAAC,CAC1C,EAEM,CAAE,QAAAC,EAAS,KAAAC,CAAK,KAAI,yBACxB,YACAH,EACAC,CACF,KAEA,UAAOC,CAAO,EAAE,KAAK,oBAAoB,KACzC,UAAOC,EAAK,IAAI,EAAE,KAAK,UAAU,KACjC,UAAOA,EAAK,QAAQ,EAAE,KAAK,MAAM,CACnC,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_vitest", "import_apduLogs", "apdu", "apduResponse", "message", "data"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var
|
|
1
|
+
"use strict";var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var R=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 R(e))!I.call(a,s)&&s!==t&&l(a,s,{get:()=>e[s],enumerable:!(i=y(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 o=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,r,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,...r},this._deviceState=new o.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:r}=this._intentQueueService.enqueue({type:"send-apdu",execute:()=>(0,o.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,o.timeout)({each:i,with:()=>{throw r(),new p.SendApduTimeoutError}})):n;return(0,o.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=>{const{message:n,data:r}=(0,v.formatApduExchangeLog)(this._id,e,s);this._logger.debug(n,{data:r}),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,o.from)((async()=>{const d=Date.now()-i;return await this._unsafeInternalSendCommand(e,t?t-d:void 0)})())}),r=t?s.pipe((0,o.timeout)({each:t,with:()=>{throw n(),new p.SendCommandTimeoutError}})):s;return(0,o.lastValueFrom)(r)}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 r=e.parseResponse(n,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:r}}),r}})}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:r}=this._unsafeInternalExecuteDeviceAction(e);return t=r,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 _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,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,qBAGA,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,qBAAuBG,EAC5B,KAAK,QAAUA,EAAoB,gBAAgB,EACnD,KAAK,mBAAqBC,EAC1B,KAAK,oBAAsBG,EACzB,KAAK,uBACP,EACA,KAAK,sBAAwBF,EAC7B,KAAK,kBAAoB,CACvB,GAAG,2CAC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,EAAeI,EAAQ,aACvBC,EAAwB,KAAK,IAAI,EACjC,CAAE,WAAAC,EAAY,OAAAC,CAAO,EAAI,KAAK,oBAAoB,QAAQ,CAC9D,KAAM,YACN,QAAS,OACP,SACG,SAAY,CACX,MAAMC,EAAc,KAAK,IAAI,EAAIH,EAUjC,OATe,MAAM,KAAK,wBAAwBF,EAAS,CACzD,UAAWC,EAAQ,UACnB,sBAAuBA,EAAQ,sBAG/B,aAAcJ,EACVA,EAAeQ,EACf,MACN,CAAC,CAEH,GAAG,CACL,CACJ,CAAC,EAEKC,EAAoBT,EACtBM,EAAW,QACT,WAAQ,CACN,KAAMN,EACN,KAAM,IAAM,CACV,MAAAO,EAAO,EACD,IAAI,sBACZ,CACF,CAAC,CACH,EACAD,EAEJ,SAAO,iBAAcG,CAAiB,CACxC,CAEA,MAAc,wBACZN,EACAC,EAA2B,CACzB,UAAW,GACX,sBAAuB,GACvB,aAAc,MAChB,EACyC,CACzC,YAAK,QAAQ,SAAM,wBAAqBD,CAAO,CAAC,GACjC,MAAM,KAAK,iBAAiB,SACzCA,EACAC,EAAQ,sBACRA,EAAQ,YACV,GAGG,QAASM,GAA2B,CACnC,KAAK,QAAQ,
|
|
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"]
|
|
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 formatApduExchangeLog,\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 const { message, data } = formatApduExchangeLog(\n this._id,\n rawApdu,\n response,\n );\n this._logger.debug(message, { data });\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,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,qBAGA,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,qBAAuBG,EAC5B,KAAK,QAAUA,EAAoB,gBAAgB,EACnD,KAAK,mBAAqBC,EAC1B,KAAK,oBAAsBG,EACzB,KAAK,uBACP,EACA,KAAK,sBAAwBF,EAC7B,KAAK,kBAAoB,CACvB,GAAG,2CACH,GAAGC,CACL,EACA,KAAK,aAAe,IAAI,kBAAoC,CAC1D,iBAAkB,yBAAuB,UACzC,aAAc,eAAa,UAC3B,cAAe,KAAK,iBAAiB,YAAY,EACnD,CAAC,EAED,KAAK,QAAU,IAAI,eACjBH,EACAH,EACA,KAAK,wBACL,CAACS,EAASC,IAAiB,KAAK,YAAYD,EAASC,CAAY,CACnE,EACA,KAAK,wBAA0B,IAAI,yBACjCP,E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EAAY,OAAAC,CAAO,EAAIU,EAAa,SAAS,CACnD,SAAU,MAAOJ,GAAqB,KAAK,wBAAwBA,CAAI,EACvE,YAAa,MACXd,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,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,yBAAyB8B,EAAuB,CACrD,KAAK,mBAAqBA,CAC5B,CAEQ,oBAAoBC,EAAkC,CAC5D,MAAMrB,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,aAAa,KAAK,CAAE,GAAGA,EAAO,aAAAqB,CAAa,CAAC,CACnD,CACF",
|
|
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", "message", "data", "apdu", "err", "r", "result", "deviceAction", "deviceActionCancel", "o", "queueCancel", "bypass", "deviceStatus"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
63
63
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
64
64
|
},
|
|
65
|
-
"version": "0.0.0-develop-
|
|
65
|
+
"version": "0.0.0-develop-20260701003433"
|
|
66
66
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{bufferToHexaString as
|
|
1
|
+
import{bufferToHexaString as t}from"./HexaString";function i(e){return`[will send APDU] ~...> ${t(e,!1)}`}function u(e){return`[exchange] => ${t(e,!1)}`}function a(e){return`[exchange] <= ${t(e.data,!1)}${t(e.statusCode,!1)}`}const g="apdu-exchange";function f(e,n,r){const s=t(n,!1),o=`${t(r.data,!1)}${t(r.statusCode,!1)}`;return{message:a(r),data:{type:g,sessionId:e,apdu:s,response:o}}}export{g as APDU_EXCHANGE_LOG,f as formatApduExchangeLog,a as formatApduReceivedLog,i as formatApduSendingLog,u as formatApduSentLog};
|
|
2
2
|
//# sourceMappingURL=apduLogs.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/api/utils/apduLogs.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { bufferToHexaString } from \"./HexaString\";\n\n/**\n * Formats the log message for an APDU that is about to be sent.\n * Only call this at the device session layer, before calling sendApdu on the connected device.\n */\nexport function formatApduSendingLog(apdu: Uint8Array): string {\n return `[will send APDU] ~...> ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU that was sent.\n * Only call this at the transport layer, after the APDU sending logic has been executed\n * without any error.\n */\nexport function formatApduSentLog(apdu: Uint8Array): string {\n return `[exchange] => ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU response received from the device.\n */\nexport function formatApduReceivedLog(apduResponse: ApduResponse): string {\n return `[exchange] <= ${bufferToHexaString(apduResponse.data, false)}${bufferToHexaString(apduResponse.statusCode, false)}`;\n}\n"],
|
|
5
|
-
"mappings": "AAEA,OAAS,sBAAAA,MAA0B,eAM5B,SAASC,EAAqBC,EAA0B,CAC7D,MAAO,0BAA0BF,EAAmBE,EAAM,EAAK,CAAC,EAClE,CAOO,SAASC,EAAkBD,EAA0B,CAC1D,MAAO,iBAAiBF,EAAmBE,EAAM,EAAK,CAAC,EACzD,CAKO,SAASE,EAAsBC,EAAoC,CACxE,MAAO,iBAAiBL,EAAmBK,EAAa,KAAM,EAAK,CAAC,GAAGL,EAAmBK,EAAa,WAAY,EAAK,CAAC,EAC3H",
|
|
6
|
-
"names": ["bufferToHexaString", "formatApduSendingLog", "apdu", "formatApduSentLog", "formatApduReceivedLog", "apduResponse"]
|
|
4
|
+
"sourcesContent": ["import { type ApduResponse } from \"@api/device-session/ApduResponse\";\n\nimport { bufferToHexaString } from \"./HexaString\";\n\n/**\n * Formats the log message for an APDU that is about to be sent.\n * Only call this at the device session layer, before calling sendApdu on the connected device.\n */\nexport function formatApduSendingLog(apdu: Uint8Array): string {\n return `[will send APDU] ~...> ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU that was sent.\n * Only call this at the transport layer, after the APDU sending logic has been executed\n * without any error.\n */\nexport function formatApduSentLog(apdu: Uint8Array): string {\n return `[exchange] => ${bufferToHexaString(apdu, false)}`;\n}\n\n/**\n * Formats the log message for an APDU response received from the device.\n */\nexport function formatApduReceivedLog(apduResponse: ApduResponse): string {\n return `[exchange] <= ${bufferToHexaString(apduResponse.data, false)}${bufferToHexaString(apduResponse.statusCode, false)}`;\n}\n\nexport const APDU_EXCHANGE_LOG = \"apdu-exchange\";\n\nexport type ApduExchangeLog = {\n type: typeof APDU_EXCHANGE_LOG;\n sessionId: string;\n apdu: string;\n response: string;\n};\n\n/**\n * Formats the log message and builds the structured `data` payload for a completed APDU exchange\n * (request + response).\n */\nexport function formatApduExchangeLog(\n sessionId: string,\n apdu: Uint8Array,\n apduResponse: ApduResponse,\n): { message: string; data: ApduExchangeLog } {\n const request = bufferToHexaString(apdu, false);\n const response = `${bufferToHexaString(apduResponse.data, false)}${bufferToHexaString(apduResponse.statusCode, false)}`;\n return {\n message: formatApduReceivedLog(apduResponse),\n data: { type: APDU_EXCHANGE_LOG, sessionId, apdu: request, response },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAEA,OAAS,sBAAAA,MAA0B,eAM5B,SAASC,EAAqBC,EAA0B,CAC7D,MAAO,0BAA0BF,EAAmBE,EAAM,EAAK,CAAC,EAClE,CAOO,SAASC,EAAkBD,EAA0B,CAC1D,MAAO,iBAAiBF,EAAmBE,EAAM,EAAK,CAAC,EACzD,CAKO,SAASE,EAAsBC,EAAoC,CACxE,MAAO,iBAAiBL,EAAmBK,EAAa,KAAM,EAAK,CAAC,GAAGL,EAAmBK,EAAa,WAAY,EAAK,CAAC,EAC3H,CAEO,MAAMC,EAAoB,gBAa1B,SAASC,EACdC,EACAN,EACAG,EAC4C,CAC5C,MAAMI,EAAUT,EAAmBE,EAAM,EAAK,EACxCQ,EAAW,GAAGV,EAAmBK,EAAa,KAAM,EAAK,CAAC,GAAGL,EAAmBK,EAAa,WAAY,EAAK,CAAC,GACrH,MAAO,CACL,QAASD,EAAsBC,CAAY,EAC3C,KAAM,CAAE,KAAMC,EAAmB,UAAAE,EAAW,KAAMC,EAAS,SAAAC,CAAS,CACtE,CACF",
|
|
6
|
+
"names": ["bufferToHexaString", "formatApduSendingLog", "apdu", "formatApduSentLog", "formatApduReceivedLog", "apduResponse", "APDU_EXCHANGE_LOG", "formatApduExchangeLog", "sessionId", "request", "response"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{describe as
|
|
1
|
+
import{describe as a,expect as t,it as o}from"vitest";import{APDU_EXCHANGE_LOG as p,formatApduExchangeLog as x,formatApduReceivedLog as d,formatApduSendingLog as u,formatApduSentLog as m}from"./apduLogs";a("apduLogs",()=>{a("formatApduSendingLog",()=>{o("should format APDU with correct format before sending",()=>{const e=Uint8Array.from([224,1,0,0,4]);t(u(e)).toBe("[will send APDU] ~...> e001000004")}),o("should handle empty APDU",()=>{const e=Uint8Array.from([]);t(u(e)).toBe("[will send APDU] ~...> ")})}),a("formatApduSentLog",()=>{o("should format APDU with correct format after sending",()=>{const e=Uint8Array.from([224,1,0,0,4]);t(m(e)).toBe("[exchange] => e001000004")}),o("should handle empty APDU",()=>{const e=Uint8Array.from([]);t(m(e)).toBe("[exchange] => ")})}),a("formatApduReceivedLog",()=>{o("should format APDU response with data and status code",()=>{const e={data:Uint8Array.from([1,2,3]),statusCode:Uint8Array.from([144,0])};t(d(e)).toBe("[exchange] <= 0102039000")}),o("should format APDU response with only status code when data is empty",()=>{const e={data:Uint8Array.from([]),statusCode:Uint8Array.from([144,0])};t(d(e)).toBe("[exchange] <= 9000")}),o("should format error status code correctly",()=>{const e={data:Uint8Array.from([]),statusCode:Uint8Array.from([105,133])};t(d(e)).toBe("[exchange] <= 6985")})}),a("formatApduExchangeLog",()=>{o("should keep the legacy received-log message and expose structured data",()=>{const e=Uint8Array.from([224,1,0,0,4]),r={data:Uint8Array.from([1,2,3]),statusCode:Uint8Array.from([144,0])},{message:s,data:n}=x("session-1",e,r);t(s).toBe(d(r)),t(s).toBe("[exchange] <= 0102039000"),t(n).toEqual({type:p,sessionId:"session-1",apdu:"e001000004",response:"0102039000"})}),o("should concatenate empty data with the status word in the structured payload",()=>{const e=Uint8Array.from([176,1,0,0]),r={data:Uint8Array.from([]),statusCode:Uint8Array.from([85,21])},{message:s,data:n}=x("session-2",e,r);t(s).toBe("[exchange] <= 5515"),t(n.apdu).toBe("b0010000"),t(n.response).toBe("5515")})})});
|
|
2
2
|
//# sourceMappingURL=apduLogs.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/api/utils/apduLogs.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport {\n formatApduReceivedLog,\n formatApduSendingLog,\n formatApduSentLog,\n} from \"./apduLogs\";\n\ndescribe(\"apduLogs\", () => {\n describe(\"formatApduSendingLog\", () => {\n it(\"should format APDU with correct format before sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSendingLog(apdu)).toBe(\n \"[will send APDU] ~...> e001000004\",\n );\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSendingLog(apdu)).toBe(\"[will send APDU] ~...> \");\n });\n });\n\n describe(\"formatApduSentLog\", () => {\n it(\"should format APDU with correct format after sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => e001000004\");\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => \");\n });\n });\n\n describe(\"formatApduReceivedLog\", () => {\n it(\"should format APDU response with data and status code\", () => {\n const apduResponse = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\n \"[exchange] <= 0102039000\",\n );\n });\n\n it(\"should format APDU response with only status code when data is empty\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 9000\");\n });\n\n it(\"should format error status code correctly\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x69, 0x85]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 6985\");\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,YAAAA,EAAU,UAAAC,EAAQ,MAAAC,MAAU,SAErC,OACE,yBAAAC,EACA,wBAAAC,EACA,qBAAAC,MACK,
|
|
6
|
-
"names": ["describe", "expect", "it", "formatApduReceivedLog", "formatApduSendingLog", "formatApduSentLog", "apdu", "apduResponse"]
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport {\n APDU_EXCHANGE_LOG,\n formatApduExchangeLog,\n formatApduReceivedLog,\n formatApduSendingLog,\n formatApduSentLog,\n} from \"./apduLogs\";\n\ndescribe(\"apduLogs\", () => {\n describe(\"formatApduSendingLog\", () => {\n it(\"should format APDU with correct format before sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSendingLog(apdu)).toBe(\n \"[will send APDU] ~...> e001000004\",\n );\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSendingLog(apdu)).toBe(\"[will send APDU] ~...> \");\n });\n });\n\n describe(\"formatApduSentLog\", () => {\n it(\"should format APDU with correct format after sending\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => e001000004\");\n });\n\n it(\"should handle empty APDU\", () => {\n const apdu = Uint8Array.from([]);\n expect(formatApduSentLog(apdu)).toBe(\"[exchange] => \");\n });\n });\n\n describe(\"formatApduReceivedLog\", () => {\n it(\"should format APDU response with data and status code\", () => {\n const apduResponse = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\n \"[exchange] <= 0102039000\",\n );\n });\n\n it(\"should format APDU response with only status code when data is empty\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 9000\");\n });\n\n it(\"should format error status code correctly\", () => {\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x69, 0x85]),\n };\n expect(formatApduReceivedLog(apduResponse)).toBe(\"[exchange] <= 6985\");\n });\n });\n\n describe(\"formatApduExchangeLog\", () => {\n it(\"should keep the legacy received-log message and expose structured data\", () => {\n const apdu = Uint8Array.from([0xe0, 0x01, 0x00, 0x00, 0x04]);\n const apduResponse = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n statusCode: Uint8Array.from([0x90, 0x00]),\n };\n\n const { message, data } = formatApduExchangeLog(\n \"session-1\",\n apdu,\n apduResponse,\n );\n\n expect(message).toBe(formatApduReceivedLog(apduResponse));\n expect(message).toBe(\"[exchange] <= 0102039000\");\n expect(data).toEqual({\n type: APDU_EXCHANGE_LOG,\n sessionId: \"session-1\",\n apdu: \"e001000004\",\n response: \"0102039000\",\n });\n });\n\n it(\"should concatenate empty data with the status word in the structured payload\", () => {\n const apdu = Uint8Array.from([0xb0, 0x01, 0x00, 0x00]);\n const apduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x55, 0x15]),\n };\n\n const { message, data } = formatApduExchangeLog(\n \"session-2\",\n apdu,\n apduResponse,\n );\n\n expect(message).toBe(\"[exchange] <= 5515\");\n expect(data.apdu).toBe(\"b0010000\");\n expect(data.response).toBe(\"5515\");\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,YAAAA,EAAU,UAAAC,EAAQ,MAAAC,MAAU,SAErC,OACE,qBAAAC,EACA,yBAAAC,EACA,yBAAAC,EACA,wBAAAC,EACA,qBAAAC,MACK,aAEPP,EAAS,WAAY,IAAM,CACzBA,EAAS,uBAAwB,IAAM,CACrCE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GAAI,CAAC,CAC1C,EACAR,EAAOI,EAAsBI,CAAY,CAAC,EAAE,KAAK,oBAAoB,CACvE,CAAC,CACH,CAAC,EAEDT,EAAS,wBAAyB,IAAM,CACtCE,EAAG,yEAA0E,IAAM,CACjF,MAAMM,EAAO,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EACrDC,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,EAAM,EAAM,CAAI,CAAC,EACxC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,CAC1C,EAEM,CAAE,QAAAC,EAAS,KAAAC,CAAK,EAAIP,EACxB,YACAI,EACAC,CACF,EAEAR,EAAOS,CAAO,EAAE,KAAKL,EAAsBI,CAAY,CAAC,EACxDR,EAAOS,CAAO,EAAE,KAAK,0BAA0B,EAC/CT,EAAOU,CAAI,EAAE,QAAQ,CACnB,KAAMR,EACN,UAAW,YACX,KAAM,aACN,SAAU,YACZ,CAAC,CACH,CAAC,EAEDD,EAAG,+EAAgF,IAAM,CACvF,MAAMM,EAAO,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,CAAI,CAAC,EAC/CC,EAAe,CACnB,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,WAAW,KAAK,CAAC,GAAM,EAAI,CAAC,CAC1C,EAEM,CAAE,QAAAC,EAAS,KAAAC,CAAK,EAAIP,EACxB,YACAI,EACAC,CACF,EAEAR,EAAOS,CAAO,EAAE,KAAK,oBAAoB,EACzCT,EAAOU,EAAK,IAAI,EAAE,KAAK,UAAU,EACjCV,EAAOU,EAAK,QAAQ,EAAE,KAAK,MAAM,CACnC,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["describe", "expect", "it", "APDU_EXCHANGE_LOG", "formatApduExchangeLog", "formatApduReceivedLog", "formatApduSendingLog", "formatApduSentLog", "apdu", "apduResponse", "message", "data"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{BehaviorSubject as h,from as d,lastValueFrom as p,timeout as v}from"rxjs";import{v4 as m}from"uuid";import{CommandUtils as S}from"../../../api/command/utils/CommandUtils";import{DeviceStatus as l}from"../../../api/device/DeviceStatus";import{DeviceSessionStateType as D}from"../../../api/device-session/DeviceSessionState";import{SendApduTimeoutError as _,SendCommandTimeoutError as g}from"../../../api/transport/model/Errors";import{
|
|
1
|
+
import{BehaviorSubject as h,from as d,lastValueFrom as p,timeout as v}from"rxjs";import{v4 as m}from"uuid";import{CommandUtils as S}from"../../../api/command/utils/CommandUtils";import{DeviceStatus as l}from"../../../api/device/DeviceStatus";import{DeviceSessionStateType as D}from"../../../api/device-session/DeviceSessionState";import{SendApduTimeoutError as _,SendCommandTimeoutError as g}from"../../../api/transport/model/Errors";import{formatApduExchangeLog as f,formatApduSendingLog as E}from"../../../api/utils/apduLogs";import{DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS as b}from"../../device-session/data/DeviceSessionRefresherConst";import{IntentQueueService as A}from"../../device-session/service/IntentQueueService";import{RefresherService as C}from"../../device-session/service/RefresherService";import{DevicePinger as y}from"./DevicePinger";import{DeviceSessionEventDispatcher as R,SessionEvents as c}from"./DeviceSessionEventDispatcher";import{DeviceSessionRefresher as I}from"./DeviceSessionRefresher";import{DeviceSessionStateHandler as O}from"./DeviceSessionStateHandler";class K{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_loggerModuleFactory;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_intentQueueService;_sessionEventDispatcher=new R;_bypassIntentQueue=!1;constructor({connectedDevice:e,id:t=m()},i,s,n,r,a=o=>new A(i,o)){this._id=t,this._connectedDevice=e,this._loggerModuleFactory=i,this._logger=i("device-session"),this._managerApiService=s,this._intentQueueService=a(this._sessionEventDispatcher),this._secureChannelService=n,this._refresherOptions={...b,...r},this._deviceState=new h({sessionStateType:D.Connected,deviceStatus:l.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new y(i,e,this._sessionEventDispatcher,(o,u)=>this.sendCommand(o,u)),this._deviceSessionRefresher=new I(i,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new O(i,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,o=>this.setDeviceSessionState(o)),this._refresherService=new C(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:r}=this._intentQueueService.enqueue({type:"send-apdu",execute:()=>d((async()=>{const o=Date.now()-s;return await this._unsafeInternalSendApdu(e,{isPolling:t.isPolling,triggersDisconnection:t.triggersDisconnection,abortTimeout:i?i-o:void 0})})())}),a=i?n.pipe(v({each:i,with:()=>{throw r(),new _}})):n;return p(a)}async _unsafeInternalSendApdu(e,t={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._logger.debug(E(e)),(await this._connectedDevice.sendApdu(e,t.triggersDisconnection,t.abortTimeout)).ifRight(s=>{const{message:n,data:r}=f(this._id,e,s);this._logger.debug(n,{data:r}),S.isLockedDeviceResponse(s)?this._sessionEventDispatcher.dispatch({eventName:c.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:c.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:c.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:()=>d((async()=>{const a=Date.now()-i;return await this._unsafeInternalSendCommand(e,t?t-a:void 0)})())}),r=t?s.pipe(v({each:t,with:()=>{throw n(),new g}})):s;return p(r)}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 r=e.parseResponse(n,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:r}}),r}})}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:r}=this._unsafeInternalExecuteDeviceAction(e);return t=r,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(l.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})}}export{K as DeviceSession};
|
|
2
2
|
//# sourceMappingURL=DeviceSession.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/device-session/model/DeviceSession.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Either } 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": "AACA,OACE,mBAAAA,EACA,QAAAC,EACA,iBAAAC,EAEA,WAAAC,MACK,OACP,OAAS,MAAMC,MAAc,OAI7B,OAAS,gBAAAC,MAAoB,kCAC7B,OAAS,gBAAAC,MAAoB,2BAO7B,OAEE,0BAAAC,MACK,yCAIP,OACE,wBAAAC,EACA,2BAAAC,MACK,8BAEP,OACE,yBAAAC,EACA,wBAAAC,MACK,sBACP,OAAS,4CAAAC,MAAgD,4DACzD,OAAS,sBAAAC,MAA0B,sDACnC,OAAS,oBAAAC,MAAwB,oDAIjC,OAAS,gBAAAC,MAAoB,iBAC7B,OACE,gCAAAC,EACA,iBAAAC,MACK,iCACP,OAAS,0BAAAC,MAA8B,2BACvC,OAAS,6BAAAC,MAAiC,8BAqBnC,MAAMC,CAAc,CACR,IACA,iBACA,aACA,mBACA,sBACA,QACA,qBAGA,kBACT,QACA,wBACS,kBACA,oBACT,wBAA0B,IAAIJ,EAC9B,mBAA8B,GAEtC,YACE,CAAE,gBAAAK,EAAiB,GAAAC,EAAKlB,EAAO,CAAE,EACjCmB,EACAC,EACAC,EACAC,EACAC,EAE2BC,GACzB,IAAIf,EAAmBU,EAAqBK,CAAsB,EACpE,CACA,KAAK,IAAMN,EACX,KAAK,iBAAmBD,EACxB,KAAK,qBAAuBE,EAC5B,KAAK,QAAUA,EAAoB,gBAAgB,EACnD,KAAK,mBAAqBC,EAC1B,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,wBAAwBD,EAASC,CAAO,EAE/C,KAAK,kBAAkBD,EAASC,CAAO,CAChD,CAEQ,kBACND,EACAC,EACyC,CACzC,MAAMJ,EAAeI,EAAQ,aACvBC,EAAwB,KAAK,IAAI,EACjC,CAAE,WAAAC,EAAY,OAAAC,CAAO,EAAI,KAAK,oBAAoB,QAAQ,CAC9D,KAAM,YACN,QAAS,IACPpC,GACG,SAAY,CACX,MAAMqC,EAAc,KAAK,IAAI,EAAIH,EAUjC,OATe,MAAM,KAAK,wBAAwBF,EAAS,CACzD,UAAWC,EAAQ,UACnB,sBAAuBA,EAAQ,sBAG/B,aAAcJ,EACVA,EAAeQ,EACf,MACN,CAAC,CAEH,GAAG,CACL,CACJ,CAAC,EAEKC,EAAoBT,EACtBM,EAAW,KACTjC,EAAQ,CACN,KAAM2B,EACN,KAAM,IAAM,CACV,MAAAO,EAAO,EACD,IAAI7B,CACZ,CACF,CAAC,CACH,EACA4B,EAEJ,OAAOlC,EAAcqC,CAAiB,CACxC,CAEA,MAAc,wBACZN,EACAC,EAA2B,CACzB,UAAW,GACX,sBAAuB,GACvB,aAAc,MAChB,EACyC,CACzC,YAAK,QAAQ,MAAMvB,EAAqBsB,CAAO,CAAC,GACjC,MAAM,KAAK,iBAAiB,SACzCA,EACAC,EAAQ,sBACRA,EAAQ,YACV,GAGG,QAASM,GAA2B,CACnC,KAAK,QAAQ,
|
|
6
|
-
"names": ["BehaviorSubject", "from", "lastValueFrom", "timeout", "uuidv4", "CommandUtils", "DeviceStatus", "DeviceSessionStateType", "SendApduTimeoutError", "SendCommandTimeoutError", "
|
|
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 formatApduExchangeLog,\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 const { message, data } = formatApduExchangeLog(\n this._id,\n rawApdu,\n response,\n );\n this._logger.debug(message, { data });\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": "AACA,OACE,mBAAAA,EACA,QAAAC,EACA,iBAAAC,EAEA,WAAAC,MACK,OACP,OAAS,MAAMC,MAA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U,MAAOJ,GAAqB,KAAK,wBAAwBA,CAAI,EACvE,YAAa,MACXd,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,sBACpC,cAAe,KAAK,oBACtB,CAAC,EAED,MAAO,CACL,WAAAK,EACA,OAAAC,CACF,CACF,CAEO,OAAc,CACnB,KAAK,oBAAoB/B,EAAa,aAAa,EACnD,KAAK,aAAa,SAAS,EAC3B,KAAK,wBAAwB,cAAc,EAC3C,KAAK,QAAQ,YAAY,CAC3B,CAEO,iBAAiBgB,EAAwB,CAC9C,OAAO,KAAK,kBAAkB,iBAAiBA,CAAE,CACnD,CAEO,yBAAyB6B,EAAuB,CACrD,KAAK,mBAAqBA,CAC5B,CAEQ,oBAAoBC,EAAkC,CAC5D,MAAMrB,EAAQ,KAAK,aAAa,SAAS,EACzC,KAAK,aAAa,KAAK,CAAE,GAAGA,EAAO,aAAAqB,CAAa,CAAC,CACnD,CACF",
|
|
6
|
+
"names": ["BehaviorSubject", "from", "lastValueFrom", "timeout", "uuidv4", "CommandUtils", "DeviceStatus", "DeviceSessionStateType", "SendApduTimeoutError", "SendCommandTimeoutError", "formatApduExchangeLog", "formatApduSendingLog", "DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS", "IntentQueueService", "RefresherService", "DevicePinger", "DeviceSessionEventDispatcher", "SessionEvents", "DeviceSessionRefresher", "DeviceSessionStateHandler", "DeviceSession", "connectedDevice", "id", "loggerModuleFactory", "managerApiService", "secureChannelService", "deviceSessionRefresherOptions", "intentQueueServiceFactory", "sessionEventDispatcher", "command", "abortTimeout", "state", "error", "rawApdu", "options", "beforeQueuedTimestamp", "observable", "cancel", "elapsedTime", "timeoutObservable", "response", "message", "data", "apdu", "err", "r", "result", "deviceAction", "deviceActionCancel", "o", "queueCancel", "bypass", "deviceStatus"]
|
|
7
7
|
}
|
|
@@ -14,4 +14,19 @@ export declare function formatApduSentLog(apdu: Uint8Array): string;
|
|
|
14
14
|
* Formats the log message for an APDU response received from the device.
|
|
15
15
|
*/
|
|
16
16
|
export declare function formatApduReceivedLog(apduResponse: ApduResponse): string;
|
|
17
|
+
export declare const APDU_EXCHANGE_LOG = "apdu-exchange";
|
|
18
|
+
export type ApduExchangeLog = {
|
|
19
|
+
type: typeof APDU_EXCHANGE_LOG;
|
|
20
|
+
sessionId: string;
|
|
21
|
+
apdu: string;
|
|
22
|
+
response: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Formats the log message and builds the structured `data` payload for a completed APDU exchange
|
|
26
|
+
* (request + response).
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatApduExchangeLog(sessionId: string, apdu: Uint8Array, apduResponse: ApduResponse): {
|
|
29
|
+
message: string;
|
|
30
|
+
data: ApduExchangeLog;
|
|
31
|
+
};
|
|
17
32
|
//# sourceMappingURL=apduLogs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apduLogs.d.ts","sourceRoot":"","sources":["../../../../../src/api/utils/apduLogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAIrE;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAE1D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAExE"}
|
|
1
|
+
{"version":3,"file":"apduLogs.d.ts","sourceRoot":"","sources":["../../../../../src/api/utils/apduLogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAIrE;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAE1D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAExE;AAED,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,OAAO,iBAAiB,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,UAAU,EAChB,YAAY,EAAE,YAAY,GACzB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,eAAe,CAAA;CAAE,CAO5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceSession.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/device-session/model/DeviceSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAGtE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EACnC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,KAAK,kBAAkB,EAExB,M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