@ledgerhq/device-management-kit 0.13.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -0
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js.map +3 -3
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.js +1 -1
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.js.map +2 -2
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.test.js +1 -1
- package/lib/cjs/src/api/device-model/data/StaticDeviceModelDataSource.test.js.map +3 -3
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +3 -3
- package/lib/cjs/src/api/logger-subscriber/model/LogSubscriberOptions.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/model/LogSubscriberOptions.js.map +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.js.map +2 -2
- package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.test.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
- package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.js +2 -0
- package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.js.map +7 -0
- package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js +2 -0
- package/lib/cjs/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js.map +7 -0
- package/lib/cjs/src/api/logger-subscriber/service/LogTagFormatter.js +2 -0
- package/lib/cjs/src/api/logger-subscriber/service/LogTagFormatter.js.map +7 -0
- package/lib/cjs/src/api/utils/apduLogs.js +2 -0
- package/lib/cjs/src/api/utils/apduLogs.js.map +7 -0
- package/lib/cjs/src/api/utils/apduLogs.test.js +2 -0
- package/lib/cjs/src/api/utils/apduLogs.test.js.map +7 -0
- 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/cjs/src/internal/device-session/model/DeviceSession.test.js +2 -0
- package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js.map +7 -0
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js +1 -1
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js.map +3 -3
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
- package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +3 -3
- package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.js +2 -0
- package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.js.map +7 -0
- package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.test.js +2 -0
- package/lib/cjs/src/internal/logger-publisher/service/sanitiseData.test.js.map +7 -0
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js.map +3 -3
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.js +1 -1
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.js.map +2 -2
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.test.js +1 -1
- package/lib/esm/src/api/device-model/data/StaticDeviceModelDataSource.test.js.map +3 -3
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js +1 -1
- package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.js.map +2 -2
- package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.test.js +1 -1
- package/lib/esm/src/api/logger-subscriber/service/ConsoleLogger.test.js.map +2 -2
- package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.js +2 -0
- package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.js.map +7 -0
- package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js +2 -0
- package/lib/esm/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.js.map +7 -0
- package/lib/esm/src/api/logger-subscriber/service/LogTagFormatter.js +1 -0
- package/lib/esm/src/api/logger-subscriber/service/LogTagFormatter.js.map +7 -0
- package/lib/esm/src/api/utils/apduLogs.js +2 -0
- package/lib/esm/src/api/utils/apduLogs.js.map +7 -0
- package/lib/esm/src/api/utils/apduLogs.test.js +2 -0
- package/lib/esm/src/api/utils/apduLogs.test.js.map +7 -0
- 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/esm/src/internal/device-session/model/DeviceSession.test.js +2 -0
- package/lib/esm/src/internal/device-session/model/DeviceSession.test.js.map +7 -0
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.js.map +3 -3
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js +1 -1
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.js.map +3 -3
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js +1 -1
- package/lib/esm/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map +3 -3
- package/lib/esm/src/internal/logger-publisher/service/sanitiseData.js +2 -0
- package/lib/esm/src/internal/logger-publisher/service/sanitiseData.js.map +7 -0
- package/lib/esm/src/internal/logger-publisher/service/sanitiseData.test.js +2 -0
- package/lib/esm/src/internal/logger-publisher/service/sanitiseData.test.js.map +7 -0
- package/lib/types/src/api/DeviceManagementKit.d.ts +6 -2
- package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +2 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
- package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts +4 -0
- package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-model/data/StaticDeviceModelDataSource.d.ts +3 -0
- package/lib/types/src/api/device-model/data/StaticDeviceModelDataSource.d.ts.map +1 -1
- package/lib/types/src/api/index.d.ts +3 -0
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/logger-subscriber/model/LogSubscriberOptions.d.ts +1 -0
- package/lib/types/src/api/logger-subscriber/model/LogSubscriberOptions.d.ts.map +1 -1
- package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.d.ts +10 -0
- package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.d.ts.map +1 -0
- package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.d.ts +2 -0
- package/lib/types/src/api/logger-subscriber/service/DefaultLogTagFormatter.test.d.ts.map +1 -0
- package/lib/types/src/api/logger-subscriber/service/LogTagFormatter.d.ts +9 -0
- package/lib/types/src/api/logger-subscriber/service/LogTagFormatter.d.ts.map +1 -0
- package/lib/types/src/api/utils/apduLogs.d.ts +17 -0
- package/lib/types/src/api/utils/apduLogs.d.ts.map +1 -0
- package/lib/types/src/api/utils/apduLogs.test.d.ts +2 -0
- package/lib/types/src/api/utils/apduLogs.test.d.ts.map +1 -0
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.test.d.ts +2 -0
- package/lib/types/src/internal/device-session/model/DeviceSession.test.d.ts.map +1 -0
- package/lib/types/src/internal/discovery/use-case/ConnectUseCase.d.ts.map +1 -1
- package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.d.ts +5 -2
- package/lib/types/src/internal/logger-publisher/service/DefaultLoggerPublisherService.d.ts.map +1 -1
- package/lib/types/src/internal/logger-publisher/service/sanitiseData.d.ts +6 -0
- package/lib/types/src/internal/logger-publisher/service/sanitiseData.d.ts.map +1 -0
- package/lib/types/src/internal/logger-publisher/service/sanitiseData.test.d.ts +2 -0
- package/lib/types/src/internal/logger-publisher/service/sanitiseData.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +3 -3
package/lib/cjs/src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/logger-publisher/service/DefaultLoggerPublisherService.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\n\nimport { DefaultLoggerPublisherService } from \"./DefaultLoggerPublisherService\";\n\nvi.mock(\"@api/logger-subscriber/service/ConsoleLogger\");\nvi.useFakeTimers().setSystemTime(new Date(\"2024-01-01\"));\n\nlet service: DefaultLoggerPublisherService;\nlet subscriber: Mocked<ConsoleLogger>;\nconst message = \"message\";\nconst tag = \"logger-tag\";\nconst options = { data: { key: \"value\" } };\nconst generatedOptions = {
|
|
5
|
-
"mappings": "aAEA,IAAAA,EAAyB,iDACzBC,EAA8B,wDAE9BC,EAA8C,2CAE9C,GAAG,KAAK,8CAA8C,EACtD,GAAG,cAAc,EAAE,cAAc,IAAI,KAAK,YAAY,CAAC,EAEvD,IAAIC,EACAC,EACJ,MAAMC,EAAU,UACVC,EAAM,aACNC,EAAU,CAAE,KAAM,CAAE,IAAK,OAAQ,CAAE,EACnCC,EAAmB,
|
|
6
|
-
"names": ["import_LogLevel", "import_ConsoleLogger", "import_DefaultLoggerPublisherService", "service", "subscriber", "message", "tag", "options", "generatedOptions", "newTag", "spy"]
|
|
4
|
+
"sourcesContent": ["import { type Mocked } from \"vitest\";\n\nimport { LogLevel } from \"@api/logger-subscriber/model/LogLevel\";\nimport { ConsoleLogger } from \"@api/logger-subscriber/service/ConsoleLogger\";\n\nimport { DefaultLoggerPublisherService } from \"./DefaultLoggerPublisherService\";\n\nvi.mock(\"@api/logger-subscriber/service/ConsoleLogger\");\nvi.useFakeTimers().setSystemTime(new Date(\"2024-01-01\"));\n\nlet service: DefaultLoggerPublisherService;\nlet subscriber: Mocked<ConsoleLogger>;\nconst message = \"message\";\nconst tag = \"logger-tag\";\nconst formattedTag = `[${tag}]`;\nconst options = { data: { key: \"value\" } };\nconst generatedOptions = {\n tag: formattedTag,\n timestamp: Date.now(),\n ...options,\n};\n\ndescribe(\"LoggerPublisherService\", () => {\n beforeEach(() => {\n vi.clearAllMocks();\n subscriber = new ConsoleLogger() as Mocked<ConsoleLogger>;\n service = new DefaultLoggerPublisherService([subscriber], tag);\n });\n\n it(\"should call subscriber.log with the correct log object\", () => {\n service.info(message, options);\n expect(subscriber.log).toHaveBeenCalledWith(\n LogLevel.Info,\n message,\n generatedOptions,\n );\n });\n\n it(\"should call subscriber.log with the correct log object when a tag is provided in options\", () => {\n const newTag = \"new-tag\";\n service.info(message, { ...options, tag: newTag });\n // Note: options.tag overrides and is formatted\n expect(subscriber.log).toHaveBeenCalledWith(LogLevel.Info, message, {\n ...generatedOptions,\n tag: `[${newTag}]`,\n });\n });\n\n it(\"should call subscriber.log with the correct log object when a timestamp is provided\", () => {\n const newTimestamp = 1;\n service.info(message, { ...options, timestamp: newTimestamp });\n expect(subscriber.log).toHaveBeenCalledWith(LogLevel.Info, message, {\n ...generatedOptions,\n timestamp: newTimestamp,\n });\n });\n\n it(\"should call _log with the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.info(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Info, message, options);\n });\n\n it(\"should have the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.debug(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Debug, message, options);\n });\n\n it(\"should have the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.warn(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Warning, message, options);\n });\n\n it(\"should have the correct LogLevel\", () => {\n const spy = vi.spyOn(service, \"_log\").mockImplementation(vi.fn());\n\n service.error(message, options);\n expect(spy).toHaveBeenCalledWith(LogLevel.Error, message, options);\n });\n});\n"],
|
|
5
|
+
"mappings": "aAEA,IAAAA,EAAyB,iDACzBC,EAA8B,wDAE9BC,EAA8C,2CAE9C,GAAG,KAAK,8CAA8C,EACtD,GAAG,cAAc,EAAE,cAAc,IAAI,KAAK,YAAY,CAAC,EAEvD,IAAIC,EACAC,EACJ,MAAMC,EAAU,UACVC,EAAM,aACNC,EAAe,IAAID,CAAG,IACtBE,EAAU,CAAE,KAAM,CAAE,IAAK,OAAQ,CAAE,EACnCC,EAAmB,CACvB,IAAKF,EACL,UAAW,KAAK,IAAI,EACpB,GAAGC,CACL,EAEA,SAAS,yBAA0B,IAAM,CACvC,WAAW,IAAM,CACf,GAAG,cAAc,EACjBJ,EAAa,IAAI,gBACjBD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O,CACrE,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,MAAMG,EAAM,GAAG,MAAMR,EAAS,MAAM,EAAE,mBAAmB,GAAG,GAAG,CAAC,EAEhEA,EAAQ,MAAME,EAASG,CAAO,EAC9B,OAAOG,CAAG,EAAE,qBAAqB,WAAS,MAAON,EAASG,CAAO,CACnE,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_LogLevel", "import_ConsoleLogger", "import_DefaultLoggerPublisherService", "service", "subscriber", "message", "tag", "formattedTag", "options", "generatedOptions", "newTag", "spy"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var c=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var k=(n,r)=>{for(var t in r)c(n,t,{get:r[t],enumerable:!0})},u=(n,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of f(r))!d.call(n,o)&&o!==t&&c(n,o,{get:()=>r[o],enumerable:!(i=s(r,o))||i.enumerable});return n};var a=n=>u(c({},"__esModule",{value:!0}),n);var b={};k(b,{sanitiseData:()=>w});module.exports=a(b);function e(n,r){if(typeof n=="bigint")return n.toString();if(Array.isArray(n))return r.has(n)?"[Circular]":(r.add(n),n.map(t=>e(t,r)));if(n!==null&&typeof n=="object"){if(r.has(n))return"[Circular]";r.add(n);const t={};for(const[i,o]of Object.entries(n))t[i]=e(o,r);return t}return n}function w(n){const r=new WeakSet;r.add(n);const t={};for(const[i,o]of Object.entries(n))t[i]=e(o,r);return t}0&&(module.exports={sanitiseData});
|
|
2
|
+
//# sourceMappingURL=sanitiseData.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/internal/logger-publisher/service/sanitiseData.ts"],
|
|
4
|
+
"sourcesContent": ["function sanitiseValue(value: unknown, seen: WeakSet<object>): unknown {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return \"[Circular]\";\n }\n seen.add(value);\n return value.map((v) => sanitiseValue(v, seen));\n }\n if (value !== null && typeof value === \"object\") {\n if (seen.has(value)) {\n return \"[Circular]\";\n }\n seen.add(value);\n const sanitised: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n sanitised[key] = sanitiseValue(val, seen);\n }\n return sanitised;\n }\n return value;\n}\n\n/**\n * Recursively sanitises data for JSON serialisation by converting BigInt values\n * to strings and handling circular references.\n */\nexport function sanitiseData(\n data: Record<string, unknown>,\n): Record<string, unknown> {\n const seen = new WeakSet<object>();\n seen.add(data);\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(data)) {\n result[key] = sanitiseValue(value, seen);\n }\n return result;\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAAA,SAASI,EAAcC,EAAgBC,EAAgC,CACrE,GAAI,OAAOD,GAAU,SACnB,OAAOA,EAAM,SAAS,EAExB,GAAI,MAAM,QAAQA,CAAK,EACrB,OAAIC,EAAK,IAAID,CAAK,EACT,cAETC,EAAK,IAAID,CAAK,EACPA,EAAM,IAAKE,GAAMH,EAAcG,EAAGD,CAAI,CAAC,GAEhD,GAAID,IAAU,MAAQ,OAAOA,GAAU,SAAU,CAC/C,GAAIC,EAAK,IAAID,CAAK,EAChB,MAAO,aAETC,EAAK,IAAID,CAAK,EACd,MAAMG,EAAqC,CAAC,EAC5C,SAAW,CAACC,EAAKC,CAAG,IAAK,OAAO,QAAQL,CAAK,EAC3CG,EAAUC,CAAG,EAAIL,EAAcM,EAAKJ,CAAI,EAE1C,OAAOE,CACT,CACA,OAAOH,CACT,CAMO,SAASH,EACdS,EACyB,CACzB,MAAML,EAAO,IAAI,QACjBA,EAAK,IAAIK,CAAI,EACb,MAAMC,EAAkC,CAAC,EACzC,SAAW,CAACH,EAAKJ,CAAK,IAAK,OAAO,QAAQM,CAAI,EAC5CC,EAAOH,CAAG,EAAIL,EAAcC,EAAOC,CAAI,EAEzC,OAAOM,CACT",
|
|
6
|
+
"names": ["sanitiseData_exports", "__export", "sanitiseData", "__toCommonJS", "sanitiseValue", "value", "seen", "v", "sanitised", "key", "val", "data", "result"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=require("vitest"),s=require("./sanitiseData");(0,t.describe)("sanitiseData",()=>{(0,t.it)("should convert BigInt values to strings",()=>{const e=(0,s.sanitiseData)({value:123456789012345678901234567890n});(0,t.expect)(e).toEqual({value:"123456789012345678901234567890"}),(0,t.expect)(typeof e.value).toBe("string")}),(0,t.it)("should handle primitive values unchanged",()=>{const e=(0,s.sanitiseData)({str:"hello",num:42,bool:!0,nil:null,undef:void 0});(0,t.expect)(e).toEqual({str:"hello",num:42,bool:!0,nil:null,undef:void 0})}),(0,t.it)("should recursively sanitise arrays",()=>{const n={items:[BigInt(1),"text",BigInt(2)]},e=(0,s.sanitiseData)(n);(0,t.expect)(e).toEqual({items:["1","text","2"]})}),(0,t.it)("should recursively sanitise nested arrays",()=>{const n={nested:[[BigInt(1)],[BigInt(2),[BigInt(3)]]]},e=(0,s.sanitiseData)(n);(0,t.expect)(e).toEqual({nested:[["1"],["2",["3"]]]})}),(0,t.it)("should recursively sanitise objects",()=>{const e=(0,s.sanitiseData)({amount:1000000000000000000n,name:"test",count:5});(0,t.expect)(e).toEqual({amount:"1000000000000000000",name:"test",count:5})}),(0,t.it)("should recursively sanitise nested objects",()=>{const e=(0,s.sanitiseData)({transaction:{value:100n,gasLimit:21000n,nested:{maxFeePerGas:50000000000n}},metadata:"info"});(0,t.expect)(e).toEqual({transaction:{value:"100",gasLimit:"21000",nested:{maxFeePerGas:"50000000000"}},metadata:"info"})}),(0,t.it)("should handle mixed arrays and objects",()=>{const e=(0,s.sanitiseData)({items:[{value:1n},{value:2n}],total:3n});(0,t.expect)(e).toEqual({items:[{value:"1"},{value:"2"}],total:"3"})}),(0,t.it)("should handle empty objects and arrays",()=>{(0,t.expect)((0,s.sanitiseData)({})).toEqual({}),(0,t.expect)((0,s.sanitiseData)({arr:[]})).toEqual({arr:[]})}),(0,t.it)("should produce JSON-serialisable output",()=>{const e=(0,s.sanitiseData)({bigValue:9007199254740991n,nested:{anotherBig:123n}});(0,t.expect)(()=>JSON.stringify(e)).not.toThrow(),(0,t.expect)(JSON.stringify(e)).toBe('{"bigValue":"9007199254740991","nested":{"anotherBig":"123"}}')}),(0,t.it)("should handle circular reference in object",()=>{const n={name:"test"};n.self=n;const e=(0,s.sanitiseData)(n);(0,t.expect)(e).toEqual({name:"test",self:"[Circular]"}),(0,t.expect)(()=>JSON.stringify(e)).not.toThrow()}),(0,t.it)("should handle circular reference in nested object",()=>{const n={level1:{level2:{}}};n.level1.level2=n;const e=(0,s.sanitiseData)(n);(0,t.expect)(e).toEqual({level1:{level2:"[Circular]"}})}),(0,t.it)("should handle circular reference in array",()=>{const n=[1,2];n.push(n);const u=(0,s.sanitiseData)({items:n});(0,t.expect)(u).toEqual({items:[1,2,"[Circular]"]})}),(0,t.it)("should handle same object referenced multiple times (not circular)",()=>{const n={value:42n},u=(0,s.sanitiseData)({a:n,b:n});(0,t.expect)(u).toEqual({a:{value:"42"},b:"[Circular]"})}),(0,t.it)("should handle deeply nested circular reference",()=>{const n={a:{b:{c:{d:{}}}}};n.a.b.c=n;const e=(0,s.sanitiseData)(n);(0,t.expect)(e).toEqual({a:{b:{c:"[Circular]"}}}),(0,t.expect)(()=>JSON.stringify(e)).not.toThrow()})});
|
|
2
|
+
//# sourceMappingURL=sanitiseData.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/internal/logger-publisher/service/sanitiseData.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport { sanitiseData } from \"./sanitiseData\";\n\ndescribe(\"sanitiseData\", () => {\n it(\"should convert BigInt values to strings\", () => {\n const input = { value: BigInt(123456789012345678901234567890n) };\n const result = sanitiseData(input);\n expect(result).toEqual({ value: \"123456789012345678901234567890\" });\n expect(typeof result[\"value\"]).toBe(\"string\");\n });\n\n it(\"should handle primitive values unchanged\", () => {\n const input = {\n str: \"hello\",\n num: 42,\n bool: true,\n nil: null,\n undef: undefined,\n };\n const result = sanitiseData(input);\n expect(result).toEqual({\n str: \"hello\",\n num: 42,\n bool: true,\n nil: null,\n undef: undefined,\n });\n });\n\n it(\"should recursively sanitise arrays\", () => {\n const input = { items: [BigInt(1), \"text\", BigInt(2)] };\n const result = sanitiseData(input);\n expect(result).toEqual({ items: [\"1\", \"text\", \"2\"] });\n });\n\n it(\"should recursively sanitise nested arrays\", () => {\n const input = { nested: [[BigInt(1)], [BigInt(2), [BigInt(3)]]] };\n const result = sanitiseData(input);\n expect(result).toEqual({ nested: [[\"1\"], [\"2\", [\"3\"]]] });\n });\n\n it(\"should recursively sanitise objects\", () => {\n const input = {\n amount: BigInt(1000000000000000000n),\n name: \"test\",\n count: 5,\n };\n const result = sanitiseData(input);\n expect(result).toEqual({\n amount: \"1000000000000000000\",\n name: \"test\",\n count: 5,\n });\n });\n\n it(\"should recursively sanitise nested objects\", () => {\n const input = {\n transaction: {\n value: BigInt(100n),\n gasLimit: BigInt(21000n),\n nested: {\n maxFeePerGas: BigInt(50000000000n),\n },\n },\n metadata: \"info\",\n };\n const result = sanitiseData(input);\n expect(result).toEqual({\n transaction: {\n value: \"100\",\n gasLimit: \"21000\",\n nested: {\n maxFeePerGas: \"50000000000\",\n },\n },\n metadata: \"info\",\n });\n });\n\n it(\"should handle mixed arrays and objects\", () => {\n const input = {\n items: [{ value: BigInt(1n) }, { value: BigInt(2n) }],\n total: BigInt(3n),\n };\n const result = sanitiseData(input);\n expect(result).toEqual({\n items: [{ value: \"1\" }, { value: \"2\" }],\n total: \"3\",\n });\n });\n\n it(\"should handle empty objects and arrays\", () => {\n expect(sanitiseData({})).toEqual({});\n expect(sanitiseData({ arr: [] })).toEqual({ arr: [] });\n });\n\n it(\"should produce JSON-serialisable output\", () => {\n const input = {\n bigValue: BigInt(9007199254740991n),\n nested: {\n anotherBig: BigInt(123n),\n },\n };\n const result = sanitiseData(input);\n expect(() => JSON.stringify(result)).not.toThrow();\n expect(JSON.stringify(result)).toBe(\n '{\"bigValue\":\"9007199254740991\",\"nested\":{\"anotherBig\":\"123\"}}',\n );\n });\n\n it(\"should handle circular reference in object\", () => {\n const input: Record<string, unknown> = { name: \"test\" };\n input[\"self\"] = input;\n const result = sanitiseData(input);\n expect(result).toEqual({ name: \"test\", self: \"[Circular]\" });\n expect(() => JSON.stringify(result)).not.toThrow();\n });\n\n it(\"should handle circular reference in nested object\", () => {\n const input: Record<string, unknown> = {\n level1: {\n level2: {},\n },\n };\n (input[\"level1\"] as Record<string, unknown>)[\"level2\"] = input;\n const result = sanitiseData(input);\n expect(result).toEqual({\n level1: {\n level2: \"[Circular]\",\n },\n });\n });\n\n it(\"should handle circular reference in array\", () => {\n const arr: unknown[] = [1, 2];\n arr.push(arr);\n const input = { items: arr };\n const result = sanitiseData(input);\n expect(result).toEqual({ items: [1, 2, \"[Circular]\"] });\n });\n\n it(\"should handle same object referenced multiple times (not circular)\", () => {\n const shared = { value: BigInt(42n) };\n const input = { a: shared, b: shared };\n const result = sanitiseData(input);\n // Second reference to same object is detected as circular\n expect(result).toEqual({ a: { value: \"42\" }, b: \"[Circular]\" });\n });\n\n it(\"should handle deeply nested circular reference\", () => {\n const input: Record<string, unknown> = {\n a: {\n b: {\n c: {\n d: {},\n },\n },\n },\n };\n ((input[\"a\"] as Record<string, unknown>)[\"b\"] as Record<string, unknown>)[\n \"c\"\n ] = input;\n const result = sanitiseData(input);\n expect(result).toEqual({\n a: {\n b: {\n c: \"[Circular]\",\n },\n },\n });\n expect(() => JSON.stringify(result)).not.toThrow();\n });\n});\n"],
|
|
5
|
+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AAM,CAAC,EAAE,IAAI,QAAQ,CACnD,CAAC,KAED,MAAG,oDAAqD,IAAM,CAC5D,MAAMC,EAAiC,CACrC,OAAQ,CACN,OAAQ,CAAC,CACX,CACF,EACCA,EAAM,OAAsC,OAAYA,EACzD,MAAMD,KAAS,gBAAaC,CAAK,KACjC,UAAOD,CAAM,EAAE,QAAQ,CACrB,OAAQ,CACN,OAAQ,YACV,CACF,CAAC,CACH,CAAC,KAED,MAAG,4CAA6C,IAAM,CACpD,MAAME,EAAiB,CAAC,EAAG,CAAC,EAC5BA,EAAI,KAAKA,CAAG,EAEZ,MAAMF,KAAS,gBADD,CAAE,MAAOE,CAAI,CACM,KACjC,UAAOF,CAAM,EAAE,QAAQ,CAAE,MAAO,CAAC,EAAG,EAAG,YAAY,CAAE,CAAC,CACxD,CAAC,KAED,MAAG,qEAAsE,IAAM,CAC7E,MAAMG,EAAS,CAAE,MAAc,GAAK,EAE9BH,KAAS,gBADD,CAAE,EAAGG,EAAQ,EAAGA,CAAO,CACJ,KAEjC,UAAOH,CAAM,EAAE,QAAQ,CAAE,EAAG,CAAE,MAAO,IAAK,EAAG,EAAG,YAAa,CAAC,CAChE,CAAC,KAED,MAAG,iDAAkD,IAAM,CACzD,MAAMC,EAAiC,CACrC,EAAG,CACD,EAAG,CACD,EAAG,CACD,EAAG,CAAC,CACN,CACF,CACF,CACF,EACEA,EAAM,EAAiC,EACvC,EACEA,EACJ,MAAMD,KAAS,gBAAaC,CAAK,KACjC,UAAOD,CAAM,EAAE,QAAQ,CACrB,EAAG,CACD,EAAG,CACD,EAAG,YACL,CACF,CACF,CAAC,KACD,UAAO,IAAM,KAAK,UAAUA,CAAM,CAAC,EAAE,IAAI,QAAQ,CACnD,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_vitest", "import_sanitiseData", "result", "input", "arr", "shared"]
|
|
7
|
+
}
|
package/lib/esm/package.json
CHANGED
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
65
65
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
66
66
|
},
|
|
67
|
-
"version": "0.
|
|
67
|
+
"version": "1.0.1"
|
|
68
68
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{commandTypes as c}from"./command/di/commandTypes";import{configTypes as a}from"../internal/config/di/configTypes";import{deviceSessionTypes as t}from"../internal/device-session/di/deviceSessionTypes";import{discoveryTypes as s}from"../internal/discovery/di/discoveryTypes";import{managerApiTypes as r}from"../internal/manager-api/di/managerApiTypes";import{sendTypes as
|
|
1
|
+
import{commandTypes as c}from"./command/di/commandTypes";import{configTypes as a}from"../internal/config/di/configTypes";import{deviceSessionTypes as t}from"../internal/device-session/di/deviceSessionTypes";import{discoveryTypes as s}from"../internal/discovery/di/discoveryTypes";import{loggerTypes as p}from"../internal/logger-publisher/di/loggerTypes";import{managerApiTypes as r}from"../internal/manager-api/di/managerApiTypes";import{sendTypes as m}from"../internal/send/di/sendTypes";import{transportDiTypes as C}from"../internal/transport/di/transportDiTypes";import{makeContainer as v}from"../../src/di";import{deviceActionTypes as d}from"./device-action/di/deviceActionTypes";class x{container;constructor({stub:e,transports:o,loggers:i,config:n}={}){this.container=v({stub:e,transports:o,loggers:i,config:n})}getVersion(){return this.container.get(a.GetDmkVersionUseCase).getDmkVersion()}startDiscovering(e){return this.container.get(s.StartDiscoveringUseCase).execute(e)}stopDiscovering(){return this.container.get(s.StopDiscoveringUseCase).execute()}listenToAvailableDevices(e){return this.container.get(s.ListenToAvailableDevicesUseCase).execute(e)}async reconnect(e){return this.container.get(s.ReconnectUseCase).execute(e)}connect(e){return this.container.get(s.ConnectUseCase).execute(e)}disconnect(e){return this.container.get(s.DisconnectUseCase).execute(e)}sendApdu(e){return this.container.get(m.SendApduUseCase).execute(e)}sendCommand(e){return this.container.get(c.SendCommandUseCase).execute(e)}executeDeviceAction(e){return this.container.get(d.ExecuteDeviceActionUseCase).execute(e)}getConnectedDevice(e){return this.container.get(s.GetConnectedDeviceUseCase).execute(e)}getDeviceSessionState(e){return this.container.get(t.GetDeviceSessionStateUseCase).execute(e)}close(){return this.container.get(t.CloseSessionsUseCase).execute()}listConnectedDevices(){return this.container.get(s.ListConnectedDevicesUseCase).execute()}listenToConnectedDevice(){return this.container.get(s.ListenToConnectedDeviceUseCase).execute()}disableDeviceSessionRefresher(e){return this.container.get(t.DisableDeviceSessionRefresherUseCase).execute(e)}setProvider(e){return this.container.get(r.SetProviderUseCase).execute(e)}getProvider(){return this.container.get(r.ManagerApiDataSource).getProvider()}isEnvironmentSupported(){return this.container.get(C.TransportService).getAllTransports().some(e=>e.isSupported())}getLoggerFactory(){return this.container.get(p.LoggerPublisherServiceFactory)}}export{x as DeviceManagementKit};
|
|
2
2
|
//# sourceMappingURL=DeviceManagementKit.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/DeviceManagementKit.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Container } from \"inversify\";\nimport { type Observable } from \"rxjs\";\n\nimport { commandTypes } from \"@api/command/di/commandTypes\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport {\n type SendCommandUseCase,\n type SendCommandUseCaseArgs,\n} from \"@api/command/use-case/SendCommandUseCase\";\nimport {\n type ExecuteDeviceActionUseCase,\n type ExecuteDeviceActionUseCaseArgs,\n} from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport {\n type ConnectUseCaseArgs,\n type DisconnectUseCaseArgs,\n type DiscoveredDevice,\n type GetConnectedDeviceUseCaseArgs,\n type SendApduUseCaseArgs,\n type StartDiscoveringUseCaseArgs,\n} from \"@api/types\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { type GetDmkVersionUseCase } from \"@internal/config/use-case/GetDmkVersionUseCase\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { type CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { type GetDeviceSessionStateUseCase } from \"@internal/device-session/use-case/GetDeviceSessionStateUseCase\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { type ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { type DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { type GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { type ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport {\n type ListenToAvailableDevicesUseCase,\n type ListenToAvailableDevicesUseCaseArgs,\n} from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { type ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport {\n type ReconnectUseCase,\n type ReconnectUseCaseArgs,\n} from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport type { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport type { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport { type SetProviderUseCase } from \"@internal/manager-api/use-case/SetProviderUseCase\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport { type SendApduUseCase } from \"@internal/send/use-case/SendApduUseCase\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\nimport { makeContainer, type MakeContainerProps } from \"@root/src/di\";\n\nimport {\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"./device-action/DeviceAction\";\nimport { deviceActionTypes } from \"./device-action/di/deviceActionTypes\";\nimport { type DisableDeviceSessionRefresherUseCase } from \"./device-session/use-case/DisableDeviceSessionRefresher\";\nimport { type DmkError } from \"./Error\";\n\n/**\n * The main class to interact with the Device Management Kit.\n *\n * NB: do not instantiate this class directly, instead, use `LedgerDMKBuilder`.\n */\nexport class DeviceManagementKit {\n readonly container: Container;\n /** @internal */\n constructor({\n stub,\n transports,\n loggers,\n config,\n }: Partial<MakeContainerProps> = {}) {\n // NOTE: MakeContainerProps might not be the exact type here\n // For the init of the project this is sufficient, but we might need to\n // update the constructor arguments as we go (we might have more than just the container config)\n this.container = makeContainer({\n stub,\n transports,\n loggers,\n config,\n });\n }\n\n /**\n * Returns a promise resolving to the version of the SDK.\n */\n getVersion(): Promise<string> {\n return this.container\n .get<GetDmkVersionUseCase>(configTypes.GetDmkVersionUseCase)\n .getDmkVersion();\n }\n\n /**\n * Starts discovering devices connected.\n *\n * For the WeHID implementation, this use-case needs to be called as a result\n * of an user interaction (button \"click\" event for ex).\n *\n * @param {StartDiscoveringUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice>} An observable of discovered devices.\n */\n startDiscovering(\n args: StartDiscoveringUseCaseArgs,\n ): Observable<DiscoveredDevice> {\n return this.container\n .get<StartDiscoveringUseCase>(discoveryTypes.StartDiscoveringUseCase)\n .execute(args);\n }\n\n /**\n * Stops discovering devices connected.\n */\n stopDiscovering() {\n return this.container\n .get<StopDiscoveringUseCase>(discoveryTypes.StopDiscoveringUseCase)\n .execute();\n }\n\n /**\n * Listen to list of known discovered devices (and later BLE).\n * @param {ListenToAvailableDevicesUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice[]>} An observable of known discovered devices.\n */\n listenToAvailableDevices(\n args: ListenToAvailableDevicesUseCaseArgs,\n ): Observable<DiscoveredDevice[]> {\n return this.container\n .get<ListenToAvailableDevicesUseCase>(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n )\n .execute(args);\n }\n\n /**\n * Reconnects a device session by disconnecting and reconnecting to the device.\n *\n * @param args - The arguments for reconnecting the device session.\n * - `device`: The connected device.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n async reconnect(args: ReconnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ReconnectUseCase>(discoveryTypes.ReconnectUseCase)\n .execute(args);\n }\n\n /**\n * Connects to a device previously discovered with `DeviceManagementKit.startDiscovering`.\n * Creates a new device session which:\n * - Represents the connection to the device.\n * - Is terminated upon disconnection of the device.\n * - Exposes the device state through an observable (see `DeviceManagementKit.getDeviceSessionState`)\n * - Should be used for all subsequent communication with the device.\n *\n * @param {ConnectUseCaseArgs} args - The arguments for connecting to the device.\n * - `device`: The discovered device obtained from `StartDiscoveringUseCase`.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n connect(args: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ConnectUseCase>(discoveryTypes.ConnectUseCase)\n .execute(args);\n }\n\n /**\n * Disconnects to a discovered device.\n *\n * @param {DisconnectUseCaseArgs} args - The session ID to disconnect.\n */\n disconnect(args: DisconnectUseCaseArgs): Promise<void> {\n return this.container\n .get<DisconnectUseCase>(discoveryTypes.DisconnectUseCase)\n .execute(args);\n }\n\n /**\n * Sends an APDU command to a device through a device session.\n *\n * @param {SendApduUseCaseArgs} args - The device session ID and APDU command to send.\n */\n sendApdu(args: SendApduUseCaseArgs): Promise<ApduResponse> {\n return this.container\n .get<SendApduUseCase>(sendTypes.SendApduUseCase)\n .execute(args);\n }\n\n /**\n * Sends a command to a device through a device session.\n *\n * @param {SendCommandUseCaseArgs<Response, Args, ErrorCodes>} args - The device session ID, command, command error codes and command parameters to send.\n * @returns A promise resolving with the response from the command.\n */\n sendCommand<Response, Args, ErrorCodes>(\n args: SendCommandUseCaseArgs<Response, Args, ErrorCodes>,\n ): Promise<CommandResult<Response, ErrorCodes>> {\n return this.container\n .get<SendCommandUseCase>(commandTypes.SendCommandUseCase)\n .execute(args);\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n args: ExecuteDeviceActionUseCaseArgs<\n Output,\n Input,\n Error,\n IntermediateValue\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n return this.container\n .get<ExecuteDeviceActionUseCase>(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n )\n .execute(args);\n }\n\n /**\n * Gets the connected from its device session ID.\n *\n * @param {GetConnectedDeviceUseCaseArgs} args - The device session ID.\n * @returns {ConnectedDevice} The connected device.\n */\n getConnectedDevice(args: GetConnectedDeviceUseCaseArgs): ConnectedDevice {\n return this.container\n .get<GetConnectedDeviceUseCase>(discoveryTypes.GetConnectedDeviceUseCase)\n .execute(args);\n }\n\n /**\n * Gets the device state of a session.\n *\n * @param {{ sessionId: DeviceSessionId }} args - The device session ID.\n * @returns {Observable<DeviceSessionState>} An observable of the session device state.\n */\n getDeviceSessionState(args: {\n sessionId: DeviceSessionId;\n }): Observable<DeviceSessionState> {\n return this.container\n .get<GetDeviceSessionStateUseCase>(\n deviceSessionTypes.GetDeviceSessionStateUseCase,\n )\n .execute(args);\n }\n\n /**\n * Close the Device Management kit.\n *\n */\n close() {\n return this.container\n .get<CloseSessionsUseCase>(deviceSessionTypes.CloseSessionsUseCase)\n .execute();\n }\n\n /**\n * Lists all connected devices.\n *\n * @returns {ConnectedDevice[]} The list of device sessions.\n */\n listConnectedDevices(): ConnectedDevice[] {\n return this.container\n .get<ListConnectedDevicesUseCase>(\n discoveryTypes.ListConnectedDevicesUseCase,\n )\n .execute();\n }\n\n /**\n * Listen to connected device.\n *\n * @returns {Observable<ConnectedDevice>} An observable of connected device.\n */\n listenToConnectedDevice(): Observable<ConnectedDevice> {\n return this.container\n .get<ListenToConnectedDeviceUseCase>(\n discoveryTypes.ListenToConnectedDeviceUseCase,\n )\n .execute();\n }\n\n /**\n * Disable the device session refresher.\n *\n * @param {DisableDeviceSessionRefresherUseCaseArgs} args - The device session ID and a string to identify the blocker.\n * @returns {() => void} A function to reenable the device session refresher.\n */\n disableDeviceSessionRefresher(args: {\n sessionId: DeviceSessionId;\n blockerId: string;\n }): () => void {\n return this.container\n .get<DisableDeviceSessionRefresherUseCase>(\n deviceSessionTypes.DisableDeviceSessionRefresherUseCase,\n )\n .execute(args);\n }\n /**\n * Sets the provider for the manager API.\n *\n * @param {number} provider - The provider to set.\n */\n setProvider(provider: number): void {\n return this.container\n .get<SetProviderUseCase>(managerApiTypes.SetProviderUseCase)\n .execute(provider);\n }\n\n /**\n * Returns the current provider value from the manager API data source.\n */\n getProvider(): number {\n return this.container\n .get<ManagerApiDataSource>(managerApiTypes.ManagerApiDataSource)\n .getProvider();\n }\n\n /**\n * Check if the current environment is supported by any transport.\n */\n isEnvironmentSupported(): boolean {\n return this.container\n .get<TransportService>(transportDiTypes.TransportService)\n .getAllTransports()\n .some((transport) => transport.isSupported());\n }\n}\n"],
|
|
5
|
-
"mappings": "AAGA,OAAS,gBAAAA,MAAoB,+
|
|
6
|
-
"names": ["commandTypes", "configTypes", "deviceSessionTypes", "discoveryTypes", "managerApiTypes", "sendTypes", "transportDiTypes", "makeContainer", "deviceActionTypes", "DeviceManagementKit", "stub", "transports", "loggers", "config", "args", "provider", "transport"]
|
|
4
|
+
"sourcesContent": ["import { type Container, type Factory } from \"inversify\";\nimport { type Observable } from \"rxjs\";\n\nimport { commandTypes } from \"@api/command/di/commandTypes\";\nimport { type CommandResult } from \"@api/command/model/CommandResult\";\nimport {\n type SendCommandUseCase,\n type SendCommandUseCaseArgs,\n} from \"@api/command/use-case/SendCommandUseCase\";\nimport {\n type ExecuteDeviceActionUseCase,\n type ExecuteDeviceActionUseCaseArgs,\n} from \"@api/device-action/use-case/ExecuteDeviceActionUseCase\";\nimport { type ApduResponse } from \"@api/device-session/ApduResponse\";\nimport { type DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceSessionId } from \"@api/device-session/types\";\nimport { type ConnectedDevice } from \"@api/transport/model/ConnectedDevice\";\nimport {\n type ConnectUseCaseArgs,\n type DisconnectUseCaseArgs,\n type DiscoveredDevice,\n type GetConnectedDeviceUseCaseArgs,\n type LoggerPublisherService,\n type SendApduUseCaseArgs,\n type StartDiscoveringUseCaseArgs,\n} from \"@api/types\";\nimport { configTypes } from \"@internal/config/di/configTypes\";\nimport { type GetDmkVersionUseCase } from \"@internal/config/use-case/GetDmkVersionUseCase\";\nimport { deviceSessionTypes } from \"@internal/device-session/di/deviceSessionTypes\";\nimport { type CloseSessionsUseCase } from \"@internal/device-session/use-case/CloseSessionsUseCase\";\nimport { type GetDeviceSessionStateUseCase } from \"@internal/device-session/use-case/GetDeviceSessionStateUseCase\";\nimport { discoveryTypes } from \"@internal/discovery/di/discoveryTypes\";\nimport { type ConnectUseCase } from \"@internal/discovery/use-case/ConnectUseCase\";\nimport { type DisconnectUseCase } from \"@internal/discovery/use-case/DisconnectUseCase\";\nimport { type GetConnectedDeviceUseCase } from \"@internal/discovery/use-case/GetConnectedDeviceUseCase\";\nimport { type ListConnectedDevicesUseCase } from \"@internal/discovery/use-case/ListConnectedDevicesUseCase\";\nimport {\n type ListenToAvailableDevicesUseCase,\n type ListenToAvailableDevicesUseCaseArgs,\n} from \"@internal/discovery/use-case/ListenToAvailableDevicesUseCase\";\nimport { type ListenToConnectedDeviceUseCase } from \"@internal/discovery/use-case/ListenToConnectedDeviceUseCase\";\nimport {\n type ReconnectUseCase,\n type ReconnectUseCaseArgs,\n} from \"@internal/discovery/use-case/ReconnectUseCase\";\nimport type { StartDiscoveringUseCase } from \"@internal/discovery/use-case/StartDiscoveringUseCase\";\nimport type { StopDiscoveringUseCase } from \"@internal/discovery/use-case/StopDiscoveringUseCase\";\nimport { loggerTypes } from \"@internal/logger-publisher/di/loggerTypes\";\nimport { type ManagerApiDataSource } from \"@internal/manager-api/data/ManagerApiDataSource\";\nimport { managerApiTypes } from \"@internal/manager-api/di/managerApiTypes\";\nimport { type SetProviderUseCase } from \"@internal/manager-api/use-case/SetProviderUseCase\";\nimport { sendTypes } from \"@internal/send/di/sendTypes\";\nimport { type SendApduUseCase } from \"@internal/send/use-case/SendApduUseCase\";\nimport { transportDiTypes } from \"@internal/transport/di/transportDiTypes\";\nimport { type TransportService } from \"@internal/transport/service/TransportService\";\nimport { makeContainer, type MakeContainerProps } from \"@root/src/di\";\n\nimport {\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n} from \"./device-action/DeviceAction\";\nimport { deviceActionTypes } from \"./device-action/di/deviceActionTypes\";\nimport { type DisableDeviceSessionRefresherUseCase } from \"./device-session/use-case/DisableDeviceSessionRefresher\";\nimport { type DmkError } from \"./Error\";\n\n/**\n * The main class to interact with the Device Management Kit.\n *\n * NB: do not instantiate this class directly, instead, use `LedgerDMKBuilder`.\n */\nexport class DeviceManagementKit {\n readonly container: Container;\n /** @internal */\n constructor({\n stub,\n transports,\n loggers,\n config,\n }: Partial<MakeContainerProps> = {}) {\n // NOTE: MakeContainerProps might not be the exact type here\n // For the init of the project this is sufficient, but we might need to\n // update the constructor arguments as we go (we might have more than just the container config)\n this.container = makeContainer({\n stub,\n transports,\n loggers,\n config,\n });\n }\n\n /**\n * Returns a promise resolving to the version of the SDK.\n */\n getVersion(): Promise<string> {\n return this.container\n .get<GetDmkVersionUseCase>(configTypes.GetDmkVersionUseCase)\n .getDmkVersion();\n }\n\n /**\n * Starts discovering devices connected.\n *\n * For the WeHID implementation, this use-case needs to be called as a result\n * of an user interaction (button \"click\" event for ex).\n *\n * @param {StartDiscoveringUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice>} An observable of discovered devices.\n */\n startDiscovering(\n args: StartDiscoveringUseCaseArgs,\n ): Observable<DiscoveredDevice> {\n return this.container\n .get<StartDiscoveringUseCase>(discoveryTypes.StartDiscoveringUseCase)\n .execute(args);\n }\n\n /**\n * Stops discovering devices connected.\n */\n stopDiscovering() {\n return this.container\n .get<StopDiscoveringUseCase>(discoveryTypes.StopDiscoveringUseCase)\n .execute();\n }\n\n /**\n * Listen to list of known discovered devices (and later BLE).\n * @param {ListenToAvailableDevicesUseCaseArgs} args - The transport to use for discover, or undefined to discover from all transports.\n * @returns {Observable<DiscoveredDevice[]>} An observable of known discovered devices.\n */\n listenToAvailableDevices(\n args: ListenToAvailableDevicesUseCaseArgs,\n ): Observable<DiscoveredDevice[]> {\n return this.container\n .get<ListenToAvailableDevicesUseCase>(\n discoveryTypes.ListenToAvailableDevicesUseCase,\n )\n .execute(args);\n }\n\n /**\n * Reconnects a device session by disconnecting and reconnecting to the device.\n *\n * @param args - The arguments for reconnecting the device session.\n * - `device`: The connected device.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n async reconnect(args: ReconnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ReconnectUseCase>(discoveryTypes.ReconnectUseCase)\n .execute(args);\n }\n\n /**\n * Connects to a device previously discovered with `DeviceManagementKit.startDiscovering`.\n * Creates a new device session which:\n * - Represents the connection to the device.\n * - Is terminated upon disconnection of the device.\n * - Exposes the device state through an observable (see `DeviceManagementKit.getDeviceSessionState`)\n * - Should be used for all subsequent communication with the device.\n *\n * @param {ConnectUseCaseArgs} args - The arguments for connecting to the device.\n * - `device`: The discovered device obtained from `StartDiscoveringUseCase`.\n * - `sessionRefresherOptions` (optional): Configuration for session refreshing.\n * - `isRefresherDisabled`: Whether the refresher is disabled.\n * - `pollingInterval`: The refresh interval in milliseconds\n * @returns The session ID to use for further communication with the device.\n */\n connect(args: ConnectUseCaseArgs): Promise<DeviceSessionId> {\n return this.container\n .get<ConnectUseCase>(discoveryTypes.ConnectUseCase)\n .execute(args);\n }\n\n /**\n * Disconnects to a discovered device.\n *\n * @param {DisconnectUseCaseArgs} args - The session ID to disconnect.\n */\n disconnect(args: DisconnectUseCaseArgs): Promise<void> {\n return this.container\n .get<DisconnectUseCase>(discoveryTypes.DisconnectUseCase)\n .execute(args);\n }\n\n /**\n * Sends an APDU command to a device through a device session.\n *\n * @param {SendApduUseCaseArgs} args - The device session ID and APDU command to send.\n */\n sendApdu(args: SendApduUseCaseArgs): Promise<ApduResponse> {\n return this.container\n .get<SendApduUseCase>(sendTypes.SendApduUseCase)\n .execute(args);\n }\n\n /**\n * Sends a command to a device through a device session.\n *\n * @param {SendCommandUseCaseArgs<Response, Args, ErrorCodes>} args - The device session ID, command, command error codes and command parameters to send.\n * @returns A promise resolving with the response from the command.\n */\n sendCommand<Response, Args, ErrorCodes>(\n args: SendCommandUseCaseArgs<Response, Args, ErrorCodes>,\n ): Promise<CommandResult<Response, ErrorCodes>> {\n return this.container\n .get<SendCommandUseCase>(commandTypes.SendCommandUseCase)\n .execute(args);\n }\n\n executeDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n >(\n args: ExecuteDeviceActionUseCaseArgs<\n Output,\n Input,\n Error,\n IntermediateValue\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n return this.container\n .get<ExecuteDeviceActionUseCase>(\n deviceActionTypes.ExecuteDeviceActionUseCase,\n )\n .execute(args);\n }\n\n /**\n * Gets the connected from its device session ID.\n *\n * @param {GetConnectedDeviceUseCaseArgs} args - The device session ID.\n * @returns {ConnectedDevice} The connected device.\n */\n getConnectedDevice(args: GetConnectedDeviceUseCaseArgs): ConnectedDevice {\n return this.container\n .get<GetConnectedDeviceUseCase>(discoveryTypes.GetConnectedDeviceUseCase)\n .execute(args);\n }\n\n /**\n * Gets the device state of a session.\n *\n * @param {{ sessionId: DeviceSessionId }} args - The device session ID.\n * @returns {Observable<DeviceSessionState>} An observable of the session device state.\n */\n getDeviceSessionState(args: {\n sessionId: DeviceSessionId;\n }): Observable<DeviceSessionState> {\n return this.container\n .get<GetDeviceSessionStateUseCase>(\n deviceSessionTypes.GetDeviceSessionStateUseCase,\n )\n .execute(args);\n }\n\n /**\n * Close the Device Management kit.\n *\n */\n close() {\n return this.container\n .get<CloseSessionsUseCase>(deviceSessionTypes.CloseSessionsUseCase)\n .execute();\n }\n\n /**\n * Lists all connected devices.\n *\n * @returns {ConnectedDevice[]} The list of device sessions.\n */\n listConnectedDevices(): ConnectedDevice[] {\n return this.container\n .get<ListConnectedDevicesUseCase>(\n discoveryTypes.ListConnectedDevicesUseCase,\n )\n .execute();\n }\n\n /**\n * Listen to connected device.\n *\n * @returns {Observable<ConnectedDevice>} An observable of connected device.\n */\n listenToConnectedDevice(): Observable<ConnectedDevice> {\n return this.container\n .get<ListenToConnectedDeviceUseCase>(\n discoveryTypes.ListenToConnectedDeviceUseCase,\n )\n .execute();\n }\n\n /**\n * Disable the device session refresher.\n *\n * @param {DisableDeviceSessionRefresherUseCaseArgs} args - The device session ID and a string to identify the blocker.\n * @returns {() => void} A function to reenable the device session refresher.\n */\n disableDeviceSessionRefresher(args: {\n sessionId: DeviceSessionId;\n blockerId: string;\n }): () => void {\n return this.container\n .get<DisableDeviceSessionRefresherUseCase>(\n deviceSessionTypes.DisableDeviceSessionRefresherUseCase,\n )\n .execute(args);\n }\n /**\n * Sets the provider for the manager API.\n *\n * @param {number} provider - The provider to set.\n */\n setProvider(provider: number): void {\n return this.container\n .get<SetProviderUseCase>(managerApiTypes.SetProviderUseCase)\n .execute(provider);\n }\n\n /**\n * Returns the current provider value from the manager API data source.\n */\n getProvider(): number {\n return this.container\n .get<ManagerApiDataSource>(managerApiTypes.ManagerApiDataSource)\n .getProvider();\n }\n\n /**\n * Check if the current environment is supported by any transport.\n */\n isEnvironmentSupported(): boolean {\n return this.container\n .get<TransportService>(transportDiTypes.TransportService)\n .getAllTransports()\n .some((transport) => transport.isSupported());\n }\n\n /**\n * Returns the DMK logger factory with configured logger subscribers.\n */\n getLoggerFactory(): Factory<LoggerPublisherService> {\n return this.container.get(loggerTypes.LoggerPublisherServiceFactory);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,gBAAAA,MAAoB,+BAuB7B,OAAS,eAAAC,MAAmB,kCAE5B,OAAS,sBAAAC,MAA0B,iDAGnC,OAAS,kBAAAC,MAAsB,wCAgB/B,OAAS,eAAAC,MAAmB,4CAE5B,OAAS,mBAAAC,MAAuB,2CAEhC,OAAS,aAAAC,MAAiB,8BAE1B,OAAS,oBAAAC,MAAwB,0CAEjC,OAAS,iBAAAC,MAA8C,eAMvD,OAAS,qBAAAC,MAAyB,uCAS3B,MAAMC,CAAoB,CACtB,UAET,YAAY,CACV,KAAAC,EACA,WAAAC,EACA,QAAAC,EACA,OAAAC,CACF,EAAiC,CAAC,EAAG,CAInC,KAAK,UAAYN,EAAc,CAC7B,KAAAG,EACA,WAAAC,EACA,QAAAC,EACA,OAAAC,CACF,CAAC,CACH,CAKA,YAA8B,CAC5B,OAAO,KAAK,UACT,IAA0Bb,EAAY,oBAAoB,EAC1D,cAAc,CACnB,CAWA,iBACEc,EAC8B,CAC9B,OAAO,KAAK,UACT,IAA6BZ,EAAe,uBAAuB,EACnE,QAAQY,CAAI,CACjB,CAKA,iBAAkB,CAChB,OAAO,KAAK,UACT,IAA4BZ,EAAe,sBAAsB,EACjE,QAAQ,CACb,CAOA,yBACEY,EACgC,CAChC,OAAO,KAAK,UACT,IACCZ,EAAe,+BACjB,EACC,Q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AAY,CACjB,CAKA,wBAAkC,CAChC,OAAO,KAAK,UACT,IAAsBE,EAAiB,gBAAgB,EACvD,iBAAiB,EACjB,KAAMU,GAAcA,EAAU,YAAY,CAAC,CAChD,CAKA,kBAAoD,CAClD,OAAO,KAAK,UAAU,IAAIb,EAAY,6BAA6B,CACrE,CACF",
|
|
6
|
+
"names": ["commandTypes", "configTypes", "deviceSessionTypes", "discoveryTypes", "loggerTypes", "managerApiTypes", "sendTypes", "transportDiTypes", "makeContainer", "deviceActionTypes", "DeviceManagementKit", "stub", "transports", "loggers", "config", "args", "provider", "transport"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var s=(
|
|
1
|
+
var s=(l=>(l.None="none",l.UnlockDevice="unlock-device",l.AllowSecureConnection="allow-secure-connection",l.ConfirmOpenApp="confirm-open-app",l.SignTransaction="sign-transaction",l.SignTypedData="sign-typed-data",l.AllowListApps="allow-list-apps",l.VerifyAddress="verify-address",l.SignPersonalMessage="sign-personal-message",l.SignDelegationAuthorization="sign-delegation-authorization",l.Web3ChecksOptIn="web3-checks-opt-in",l.VerifySafeAddress="verify-safe-address",l.RegisterWallet="register-wallet",l))(s||{});export{s as UserInteractionRequired};
|
|
2
2
|
//# sourceMappingURL=UserInteractionRequired.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/model/UserInteractionRequired.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n VerifySafeAddress = \"verify-safe-address\",\n}\n"],
|
|
5
|
-
"mappings": "AAIO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAClBA,EAAA,kBAAoB,
|
|
4
|
+
"sourcesContent": ["/**\n * The user interaction required on the device to move further in a device action.\n * This is used to inform the users about the action they need to take on the device.\n */\nexport enum UserInteractionRequired {\n None = \"none\",\n UnlockDevice = \"unlock-device\",\n AllowSecureConnection = \"allow-secure-connection\",\n ConfirmOpenApp = \"confirm-open-app\",\n SignTransaction = \"sign-transaction\",\n SignTypedData = \"sign-typed-data\",\n AllowListApps = \"allow-list-apps\",\n VerifyAddress = \"verify-address\",\n SignPersonalMessage = \"sign-personal-message\",\n SignDelegationAuthorization = \"sign-delegation-authorization\",\n Web3ChecksOptIn = \"web3-checks-opt-in\",\n VerifySafeAddress = \"verify-safe-address\",\n RegisterWallet = \"register-wallet\",\n}\n"],
|
|
5
|
+
"mappings": "AAIO,IAAKA,OACVA,EAAA,KAAO,OACPA,EAAA,aAAe,gBACfA,EAAA,sBAAwB,0BACxBA,EAAA,eAAiB,mBACjBA,EAAA,gBAAkB,mBAClBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,iBAChBA,EAAA,oBAAsB,wBACtBA,EAAA,4BAA8B,gCAC9BA,EAAA,gBAAkB,qBAClBA,EAAA,kBAAoB,sBACpBA,EAAA,eAAiB,kBAbPA,OAAA",
|
|
6
6
|
"names": ["UserInteractionRequired"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Observable as h,ReplaySubject as d,share as
|
|
1
|
+
import{Observable as h,ReplaySubject as d,share as b}from"rxjs";import{createActor as I}from"xstate";import{DeviceActionStatus as o}from"../../device-action/model/DeviceActionState";class D{input;inspect=!1;logger;constructor(e){this.input=e.input,this.inspect=!!e.inspect,this.logger=e.logger}_execute(e){const r=this.makeStateMachine(e);return this._subscribeToStateMachine(r)}_subscribeToStateMachine(e){const r=I(e,{input:this.input}),t=new d;let c=!1;const p=a=>{const{context:n,status:u,output:m,error:S}=a;if(this.logger&&!c&&(c=!0,this.logger.debug("[XStateDeviceAction] Input",{data:{input:n.input}})),this.logger&&u==="active"){const i=typeof a.value=="string"?a.value:JSON.stringify(a.value);this.logger.debug(`[XStateDeviceAction] State: ${i}`,{data:{internalState:n._internalState}})}switch(u){case"active":t.next({status:o.Pending,intermediateValue:n.intermediateValue});break;case"done":m.caseOf({Left:i=>{t.next({status:o.Error,error:i})},Right:i=>{t.next({status:o.Completed,output:i})}}),t.complete();break;case"error":t.error(S),t.complete();break;case"stopped":t.next({status:o.Stopped}),t.complete();break;default:this._exhaustiveMatchingGuard(u)}},l=new h(a=>{const n=t.subscribe(a);return()=>{s.unsubscribe(),n.unsubscribe(),r.stop()}}),s=r.subscribe(p);return r.start(),{observable:l.pipe(b()),cancel:()=>{r.stop(),s.unsubscribe(),p(r.getSnapshot())}}}_exhaustiveMatchingGuard(e){throw console.log("_exhaustiveMatchingGuard status",e),new Error(`Unhandled status: ${e}`)}}export{D as XStateDeviceAction};
|
|
2
2
|
//# sourceMappingURL=XStateDeviceAction.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/xstate-utils/XStateDeviceAction.ts"],
|
|
4
|
-
"sourcesContent": ["// import { createBrowserInspector } from \"@statelyai/inspect\";\nimport { Observable, ReplaySubject, share } from \"rxjs\";\nimport {\n createActor,\n type SnapshotFrom,\n type StateMachine,\n type StateSchema,\n} from \"xstate\";\n\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\n\nimport { type StateMachineTypes } from \"./StateMachineTypes\";\n\nexport type DeviceActionStateMachine<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> = StateMachine<\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"context\"], // context\n /**\n * The following usages `any` are OK because this is just a wrapper around the\n * state machine and we are not directly going to use these types.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any, // event\n any, // children\n any, // actor\n any, // action\n any, // guard\n any, // delay\n any, // state value\n any, // tag\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"input\"],\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"output\"],\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any,\n any,\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateSchema\n>;\n\n/**\n * A DeviceAction that uses an XState state machine to execute.\n * It maps the state machine snapshots to the DeviceActionState.\n * This class is abstract and should be extended to implement the state machine.\n */\nexport abstract class XStateDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> implements DeviceAction<Output, Input, Error, IntermediateValue>\n{\n readonly input: Input;\n readonly inspect: boolean = false;\n\n /**\n *\n * @param input The input for the DeviceAction\n * @param inspect If true, the state machine will be inspected in the browser\n */\n constructor(args: {
|
|
5
|
-
"mappings": "AACA,OAAS,cAAAA,EAAY,iBAAAC,EAAe,SAAAC,MAAa,OACjD,OACE,eAAAC,MAIK,SAQP,OAEE,sBAAAC,MACK,
|
|
6
|
-
"names": ["Observable", "ReplaySubject", "share", "createActor", "DeviceActionStatus", "XStateDeviceAction", "args", "internalApi", "stateMachine", "actor", "subject", "handleActorSnapshot", "snapshot", "context", "status", "output", "error", "err", "result", "observable", "subscriber", "subjectSubscription", "actorSubscription"]
|
|
4
|
+
"sourcesContent": ["// import { createBrowserInspector } from \"@statelyai/inspect\";\nimport { Observable, ReplaySubject, share } from \"rxjs\";\nimport {\n createActor,\n type SnapshotFrom,\n type StateMachine,\n type StateSchema,\n} from \"xstate\";\n\nimport {\n type DeviceAction,\n type DeviceActionIntermediateValue,\n type ExecuteDeviceActionReturnType,\n type InternalApi,\n} from \"@api/device-action/DeviceAction\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { type DmkError } from \"@api/Error\";\nimport { type LoggerPublisherService } from \"@api/logger-publisher/service/LoggerPublisherService\";\n\nimport { type StateMachineTypes } from \"./StateMachineTypes\";\n\nexport type DeviceActionStateMachine<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> = StateMachine<\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"context\"], // context\n /**\n * The following usages `any` are OK because this is just a wrapper around the\n * state machine and we are not directly going to use these types.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any, // event\n any, // children\n any, // actor\n any, // action\n any, // guard\n any, // delay\n any, // state value\n any, // tag\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"input\"],\n StateMachineTypes<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >[\"output\"],\n /* eslint-disable @typescript-eslint/no-explicit-any */\n any,\n any,\n /* eslint-enable @typescript-eslint/no-explicit-any */\n StateSchema\n>;\n\n/**\n * A DeviceAction that uses an XState state machine to execute.\n * It maps the state machine snapshots to the DeviceActionState.\n * This class is abstract and should be extended to implement the state machine.\n */\nexport abstract class XStateDeviceAction<\n Output,\n Input,\n Error extends DmkError,\n IntermediateValue extends DeviceActionIntermediateValue,\n InternalState,\n> implements DeviceAction<Output, Input, Error, IntermediateValue>\n{\n readonly input: Input;\n readonly inspect: boolean = false;\n protected readonly logger?: LoggerPublisherService;\n\n /**\n *\n * @param input The input for the DeviceAction\n * @param inspect If true, the state machine will be inspected in the browser\n * @param logger Optional logger for debugging. If provided, input and internal state will be logged on state transitions.\n */\n constructor(args: {\n input: Input;\n inspect?: boolean;\n logger?: LoggerPublisherService;\n }) {\n this.input = args.input;\n this.inspect = Boolean(args.inspect);\n this.logger = args.logger;\n }\n\n protected abstract makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >;\n\n _execute(\n internalApi: InternalApi,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const stateMachine = this.makeStateMachine(internalApi);\n return this._subscribeToStateMachine(stateMachine);\n }\n\n protected _subscribeToStateMachine(\n stateMachine: DeviceActionStateMachine<\n Output,\n Input,\n Error,\n IntermediateValue,\n InternalState\n >,\n ): ExecuteDeviceActionReturnType<Output, Error, IntermediateValue> {\n const actor = createActor(stateMachine, {\n input: this.input,\n // optional inspector for debugging\n // inspect: this.inspect ? createBrowserInspector().inspect : undefined,\n });\n\n /**\n * Using a ReplaySubject is important because the first snapshots might be\n * emitted before the observable is subscribed (if the machine goes through\n * those states fully synchronously).\n * This way, we ensure that the subscriber always receives the latest snapshot.\n * */\n const subject = new ReplaySubject<\n DeviceActionState<Output, Error, IntermediateValue>\n >();\n\n let hasLoggedInput = false;\n\n const handleActorSnapshot = (\n snapshot: SnapshotFrom<typeof stateMachine>,\n ) => {\n const { context, status, output, error } = snapshot;\n\n // Log input once at the beginning\n if (this.logger && !hasLoggedInput) {\n hasLoggedInput = true;\n this.logger.debug(\"[XStateDeviceAction] Input\", {\n data: { input: context.input },\n });\n }\n\n // Log internal state on each state transition\n if (this.logger && status === \"active\") {\n const stateValue =\n typeof snapshot.value === \"string\"\n ? snapshot.value\n : JSON.stringify(snapshot.value);\n this.logger.debug(`[XStateDeviceAction] State: ${stateValue}`, {\n data: { internalState: context._internalState },\n });\n }\n\n switch (status) {\n case \"active\":\n subject.next({\n status: DeviceActionStatus.Pending,\n intermediateValue: context.intermediateValue,\n });\n break;\n case \"done\":\n output.caseOf({\n Left: (err) => {\n subject.next({\n status: DeviceActionStatus.Error,\n error: err,\n });\n },\n Right: (result) => {\n subject.next({\n status: DeviceActionStatus.Completed,\n output: result,\n });\n },\n });\n subject.complete();\n break;\n case \"error\":\n // this is an error in the execution of the state machine, it should not happen\n subject.error(error);\n subject.complete();\n break;\n case \"stopped\":\n subject.next({\n status: DeviceActionStatus.Stopped,\n });\n subject.complete();\n break;\n default:\n this._exhaustiveMatchingGuard(status);\n }\n };\n\n const observable = new Observable<\n DeviceActionState<Output, Error, IntermediateValue>\n >((subscriber) => {\n const subjectSubscription = subject.subscribe(subscriber);\n return () => {\n actorSubscription.unsubscribe();\n subjectSubscription.unsubscribe();\n actor.stop(); // stop the actor when the observable is unsubscribed\n };\n });\n\n const actorSubscription = actor.subscribe(handleActorSnapshot);\n actor.start();\n\n return {\n observable: observable.pipe(share()), // share to garantee that once there is no more observer, the actor is stopped\n cancel: () => {\n actor.stop();\n actorSubscription.unsubscribe();\n handleActorSnapshot(actor.getSnapshot());\n },\n };\n }\n\n private _exhaustiveMatchingGuard(status: never): never {\n console.log(\"_exhaustiveMatchingGuard status\", status);\n throw new Error(`Unhandled status: ${status}`);\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,cAAAA,EAAY,iBAAAC,EAAe,SAAAC,MAAa,OACjD,OACE,eAAAC,MAIK,SAQP,OAEE,sBAAAC,MACK,6CA4DA,MAAeC,CAOtB,CACW,MACA,QAAmB,GACT,OAQnB,YAAYC,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EAAmB,OAC7B,CAAC,EACDM,EAAQ,SAAS,EACjB,MACF,QACE,KAAK,yBAAyBK,CAAM,CACxC,CACF,EAEMM,EAAa,IAAIrB,EAEpBsB,GAAe,CAChB,MAAMC,EAAsBb,EAAQ,UAAUY,CAAU,EACxD,MAAO,IAAM,CACXE,EAAkB,YAAY,EAC9BD,EAAoB,YAAY,EAChCd,EAAM,KAAK,CACb,CACF,CAAC,EAEKe,EAAoBf,EAAM,UAAUG,CAAmB,EAC7D,OAAAH,EAAM,MAAM,EAEL,CACL,WAAYY,EAAW,KAAKnB,EAAM,CAAC,EACnC,OAAQ,IAAM,CACZO,EAAM,KAAK,EACXe,EAAkB,YAAY,EAC9BZ,EAAoBH,EAAM,YAAY,CAAC,CACzC,CACF,CACF,CAEQ,yBAAyBM,EAAsB,CACrD,cAAQ,IAAI,kCAAmCA,CAAM,EAC/C,IAAI,MAAM,qBAAqBA,CAAM,EAAE,CAC/C,CACF",
|
|
6
|
+
"names": ["Observable", "ReplaySubject", "share", "createActor", "DeviceActionStatus", "XStateDeviceAction", "args", "internalApi", "stateMachine", "actor", "subject", "hasLoggedInput", "handleActorSnapshot", "snapshot", "context", "status", "output", "error", "stateValue", "err", "result", "observable", "subscriber", "subjectSubscription", "actorSubscription"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var n=Object.defineProperty;var
|
|
1
|
+
var n=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var f=(s,e,d)=>e in s?n(s,e,{enumerable:!0,configurable:!0,writable:!0,value:d}):s[e]=d;var m=(s,e,d,t)=>{for(var o=t>1?void 0:t?v(e,d):e,c=s.length-1,l;c>=0;c--)(l=s[c])&&(o=(t?l(e,d,o):l(o))||o);return t&&o&&n(e,d,o),o};var U=(s,e,d)=>f(s,typeof e!="symbol"?e+"":e,d);import{injectable as p}from"inversify";import b from"semver";import{DeviceModelId as r}from"../../device/DeviceModel";import{BleDeviceInfos as y}from"../../device-model/model/BleDeviceInfos";import{TransportDeviceModel as u}from"../../device-model/model/DeviceModel";let i=class{getAllDeviceModels(){return Object.values(i.deviceModelByIds)}getDeviceModel(e){return i.deviceModelByIds[e.id]}filterDeviceModels(e){return this.getAllDeviceModels().filter(d=>Object.entries(e).every(([t,o])=>d[t]===o))}getBluetoothServicesInfos(){return Object.values(i.deviceModelByIds).reduce((e,d)=>{const{bluetoothSpec:t}=d;return t?{...e,...t.reduce((o,c)=>({...o,[c.serviceUuid]:new y(d,c.serviceUuid,c.writeUuid,c.writeCmdUuid,c.notifyUuid)}),{})}:e},{})}getBluetoothServices(){return Object.values(i.deviceModelByIds).map(e=>(e.bluetoothSpec||[]).map(d=>d.serviceUuid)).flat().filter(e=>!!e)}};U(i,"deviceModelByIds",{[r.NANO_S]:new u({id:r.NANO_S,productName:"Ledger Nano S",usbProductId:16,bootloaderUsbProductId:1,usbOnly:!0,memorySize:320*1024,getBlockSize:e=>b.lt(b.coerce(e.firmwareVersion)??"","2.0.0")?4*1024:2*1024,masks:[823132160]}),[r.NANO_SP]:new u({id:r.NANO_SP,productName:"Ledger Nano S Plus",usbProductId:80,bootloaderUsbProductId:5,usbOnly:!0,memorySize:1533*1024,getBlockSize:()=>32,masks:[856686592]}),[r.NANO_X]:new u({id:r.NANO_X,productName:"Ledger Nano X",usbProductId:64,bootloaderUsbProductId:4,usbOnly:!1,memorySize:2*1024*1024,getBlockSize:()=>4*1024,masks:[855638016],bluetoothSpec:[{serviceUuid:"13d63400-2c97-0004-0000-4c6564676572",notifyUuid:"13d63400-2c97-0004-0001-4c6564676572",writeUuid:"13d63400-2c97-0004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-0004-0003-4c6564676572"}]}),[r.STAX]:new u({id:r.STAX,productName:"Ledger Stax",usbProductId:96,bootloaderUsbProductId:6,usbOnly:!1,memorySize:1533*1024,getBlockSize:()=>32,masks:[857735168],bluetoothSpec:[{serviceUuid:"13d63400-2c97-6004-0000-4c6564676572",notifyUuid:"13d63400-2c97-6004-0001-4c6564676572",writeUuid:"13d63400-2c97-6004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-6004-0003-4c6564676572"}]}),[r.FLEX]:new u({id:r.FLEX,productName:"Ledger Flex",usbProductId:112,bootloaderUsbProductId:7,usbOnly:!1,memorySize:1533*1024,getBlockSize:()=>32,masks:[858783744],bluetoothSpec:[{serviceUuid:"13d63400-2c97-3004-0000-4c6564676572",notifyUuid:"13d63400-2c97-3004-0001-4c6564676572",writeUuid:"13d63400-2c97-3004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-3004-0003-4c6564676572"}]}),[r.APEX]:new u({id:r.APEX,productName:"Ledger\xA0Nano\xA0Gen5",usbProductId:128,bootloaderUsbProductId:8,usbOnly:!1,memorySize:1533*1024,getBlockSize:()=>32,masks:[859832320],bluetoothSpec:[{serviceUuid:"13d63400-2c97-8004-0000-4c6564676572",notifyUuid:"13d63400-2c97-8004-0001-4c6564676572",writeUuid:"13d63400-2c97-8004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-8004-0003-4c6564676572"},{serviceUuid:"13d63400-2c97-9004-0000-4c6564676572",notifyUuid:"13d63400-2c97-9004-0001-4c6564676572",writeUuid:"13d63400-2c97-9004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-9004-0003-4c6564676572"}]})}),i=m([p()],i);export{i as StaticDeviceModelDataSource};
|
|
2
2
|
//# sourceMappingURL=StaticDeviceModelDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-model/data/StaticDeviceModelDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { injectable } from \"inversify\";\nimport semver from \"semver\";\n\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceModelDataSource } from \"@api/device-model/data/DeviceModelDataSource\";\nimport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nimport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\n\n/**\n * Static/in memory implementation of the device model data source\n */\n@injectable()\nexport class StaticDeviceModelDataSource implements DeviceModelDataSource {\n private static deviceModelByIds: {\n [_key in DeviceModelId]: TransportDeviceModel;\n } = {\n [DeviceModelId.NANO_S]: new TransportDeviceModel({\n id: DeviceModelId.NANO_S,\n productName: \"Ledger Nano S\",\n usbProductId: 0x10,\n bootloaderUsbProductId: 0x0001,\n usbOnly: true,\n memorySize: 320 * 1024,\n getBlockSize: (p: { firmwareVersion: string }) =>\n semver.lt(semver.coerce(p.firmwareVersion) ?? \"\", \"2.0.0\")\n ? 4 * 1024\n : 2 * 1024,\n masks: [0x31100000],\n }),\n [DeviceModelId.NANO_SP]: new TransportDeviceModel({\n id: DeviceModelId.NANO_SP,\n productName: \"Ledger Nano S Plus\",\n usbProductId: 0x50,\n bootloaderUsbProductId: 0x0005,\n usbOnly: true,\n memorySize: 1533 * 1024,\n getBlockSize: () => 32,\n masks: [0x33100000],\n }),\n [DeviceModelId.NANO_X]: new TransportDeviceModel({\n id: DeviceModelId.NANO_X,\n productName: \"Ledger Nano X\",\n usbProductId: 0x40,\n bootloaderUsbProductId: 0x0004,\n usbOnly: false,\n memorySize: 2 * 1024 * 1024,\n getBlockSize: () => 4 * 1024,\n masks: [0x33000000],\n bluetoothSpec: [\n {\n serviceUuid: \"13d63400-2c97-0004-0000-4c6564676572\",\n notifyUuid: \"13d63400-2c97-0004-0001-4c6564676572\",\n writeUuid: \"13d63400-2c97-0004-0002-4c6564676572\",\n writeCmdUuid: \"13d63400-2c97-0004-0003-4c6564676572\",\n },\n ],\n }),\n [DeviceModelId.STAX]: new TransportDeviceModel({\n id: DeviceModelId.STAX,\n productName: \"Ledger Stax\",\n usbProductId: 0x60,\n bootloaderUsbProductId: 0x0006,\n usbOnly: false,\n memorySize: 1533 * 1024,\n getBlockSize: () => 32,\n masks: [0x33200000],\n bluetoothSpec: [\n {\n serviceUuid: \"13d63400-2c97-6004-0000-4c6564676572\",\n notifyUuid: \"13d63400-2c97-6004-0001-4c6564676572\",\n writeUuid: \"13d63400-2c97-6004-0002-4c6564676572\",\n writeCmdUuid: \"13d63400-2c97-6004-0003-4c6564676572\",\n },\n ],\n }),\n [DeviceModelId.FLEX]: new TransportDeviceModel({\n id: DeviceModelId.FLEX,\n productName: \"Ledger Flex\",\n usbProductId: 0x70,\n bootloaderUsbProductId: 0x0007,\n usbOnly: false,\n memorySize: 1533 * 1024,\n getBlockSize: () => 32,\n masks: [0x33300000],\n bluetoothSpec: [\n {\n serviceUuid: \"13d63400-2c97-3004-0000-4c6564676572\",\n notifyUuid: \"13d63400-2c97-3004-0001-4c6564676572\",\n writeUuid: \"13d63400-2c97-3004-0002-4c6564676572\",\n writeCmdUuid: \"13d63400-2c97-3004-0003-4c6564676572\",\n },\n ],\n }),\n [DeviceModelId.APEX]: new TransportDeviceModel({\n id: DeviceModelId.APEX,\n productName: \"Ledger
|
|
5
|
-
"mappings": "gVAAA,OAAS,cAAAA,MAAkB,YAC3B,OAAOC,MAAY,SAEnB,OAAS,iBAAAC,MAAqB,0BAE9B,OAAS,kBAAAC,MAAsB,yCAC/B,OAAS,wBAAAC,MAA4B,sCAM9B,IAAMC,EAAN,KAAmE,
|
|
4
|
+
"sourcesContent": ["import { injectable } from \"inversify\";\nimport semver from \"semver\";\n\nimport { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceModelDataSource } from \"@api/device-model/data/DeviceModelDataSource\";\nimport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\nimport { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\n\n/**\n * Static/in memory implementation of the device model data source\n */\n@injectable()\nexport class StaticDeviceModelDataSource implements DeviceModelDataSource {\n private static deviceModelByIds: {\n [_key in DeviceModelId]: TransportDeviceModel;\n } = {\n [DeviceModelId.NANO_S]: new TransportDeviceModel({\n id: DeviceModelId.NANO_S,\n productName: \"Ledger Nano S\",\n usbProductId: 0x10,\n bootloaderUsbProductId: 0x0001,\n usbOnly: true,\n memorySize: 320 * 1024,\n getBlockSize: (p: { firmwareVersion: string }) =>\n semver.lt(semver.coerce(p.firmwareVersion) ?? \"\", \"2.0.0\")\n ? 4 * 1024\n : 2 * 1024,\n masks: [0x31100000],\n }),\n [DeviceModelId.NANO_SP]: new TransportDeviceModel({\n id: DeviceModelId.NANO_SP,\n productName: \"Ledger Nano S Plus\",\n usbProductId: 0x50,\n bootloaderUsbProductId: 0x0005,\n usbOnly: true,\n memorySize: 1533 * 1024,\n getBlockSize: () => 32,\n masks: [0x33100000],\n }),\n [DeviceModelId.NANO_X]: new TransportDeviceModel({\n id: DeviceModelId.NANO_X,\n productName: \"Ledger Nano X\",\n usbProductId: 0x40,\n bootloaderUsbProductId: 0x0004,\n usbOnly: false,\n memorySize: 2 * 1024 * 1024,\n getBlockSize: () => 4 * 1024,\n masks: [0x33000000],\n bluetoothSpec: [\n {\n serviceUuid: \"13d63400-2c97-0004-0000-4c6564676572\",\n notifyUuid: \"13d63400-2c97-0004-0001-4c6564676572\",\n writeUuid: \"13d63400-2c97-0004-0002-4c6564676572\",\n writeCmdUuid: \"13d63400-2c97-0004-0003-4c6564676572\",\n },\n ],\n }),\n [DeviceModelId.STAX]: new TransportDeviceModel({\n id: DeviceModelId.STAX,\n productName: \"Ledger Stax\",\n usbProductId: 0x60,\n bootloaderUsbProductId: 0x0006,\n usbOnly: false,\n memorySize: 1533 * 1024,\n getBlockSize: () => 32,\n masks: [0x33200000],\n bluetoothSpec: [\n {\n serviceUuid: \"13d63400-2c97-6004-0000-4c6564676572\",\n notifyUuid: \"13d63400-2c97-6004-0001-4c6564676572\",\n writeUuid: \"13d63400-2c97-6004-0002-4c6564676572\",\n writeCmdUuid: \"13d63400-2c97-6004-0003-4c6564676572\",\n },\n ],\n }),\n [DeviceModelId.FLEX]: new TransportDeviceModel({\n id: DeviceModelId.FLEX,\n productName: \"Ledger Flex\",\n usbProductId: 0x70,\n bootloaderUsbProductId: 0x0007,\n usbOnly: false,\n memorySize: 1533 * 1024,\n getBlockSize: () => 32,\n masks: [0x33300000],\n bluetoothSpec: [\n {\n serviceUuid: \"13d63400-2c97-3004-0000-4c6564676572\",\n notifyUuid: \"13d63400-2c97-3004-0001-4c6564676572\",\n writeUuid: \"13d63400-2c97-3004-0002-4c6564676572\",\n writeCmdUuid: \"13d63400-2c97-3004-0003-4c6564676572\",\n },\n ],\n }),\n [DeviceModelId.APEX]: new TransportDeviceModel({\n id: DeviceModelId.APEX,\n productName: \"Ledger\u00A0Nano\u00A0Gen5\",\n usbProductId: 0x80,\n bootloaderUsbProductId: 0x0008,\n usbOnly: false,\n memorySize: 1533 * 1024,\n getBlockSize: () => 32,\n masks: [0x33400000],\n bluetoothSpec: [\n {\n serviceUuid: \"13d63400-2c97-8004-0000-4c6564676572\",\n notifyUuid: \"13d63400-2c97-8004-0001-4c6564676572\",\n writeUuid: \"13d63400-2c97-8004-0002-4c6564676572\",\n writeCmdUuid: \"13d63400-2c97-8004-0003-4c6564676572\",\n },\n {\n serviceUuid: \"13d63400-2c97-9004-0000-4c6564676572\",\n notifyUuid: \"13d63400-2c97-9004-0001-4c6564676572\",\n writeUuid: \"13d63400-2c97-9004-0002-4c6564676572\",\n writeCmdUuid: \"13d63400-2c97-9004-0003-4c6564676572\",\n },\n ],\n }),\n };\n\n getAllDeviceModels(): TransportDeviceModel[] {\n return Object.values(StaticDeviceModelDataSource.deviceModelByIds);\n }\n\n getDeviceModel(params: { id: DeviceModelId }): TransportDeviceModel {\n return StaticDeviceModelDataSource.deviceModelByIds[params.id];\n }\n\n /**\n * Returns the list of device models that match all the given parameters\n */\n filterDeviceModels(\n params: Partial<TransportDeviceModel>,\n ): TransportDeviceModel[] {\n return this.getAllDeviceModels().filter((deviceModel) => {\n return Object.entries(params).every(([key, value]) => {\n return deviceModel[key as keyof TransportDeviceModel] === value;\n });\n });\n }\n\n /**\n * @returns A record of service UUIDs to BleDeviceInfos\n */\n getBluetoothServicesInfos(): Record<string, BleDeviceInfos> {\n return Object.values(StaticDeviceModelDataSource.deviceModelByIds).reduce<\n Record<string, BleDeviceInfos>\n >((acc, deviceModel) => {\n const { bluetoothSpec } = deviceModel;\n if (bluetoothSpec) {\n return {\n ...acc,\n ...bluetoothSpec.reduce<Record<string, BleDeviceInfos>>(\n (serviceToModel, bleSpec) => ({\n ...serviceToModel,\n [bleSpec.serviceUuid]: new BleDeviceInfos(\n deviceModel,\n bleSpec.serviceUuid,\n bleSpec.writeUuid,\n bleSpec.writeCmdUuid,\n bleSpec.notifyUuid,\n ),\n }),\n {},\n ),\n };\n }\n return acc;\n }, {});\n }\n\n getBluetoothServices(): string[] {\n return Object.values(StaticDeviceModelDataSource.deviceModelByIds)\n .map((deviceModel) =>\n (deviceModel.bluetoothSpec || []).map((spec) => spec.serviceUuid),\n )\n .flat()\n .filter((uuid) => !!uuid);\n }\n}\n"],
|
|
5
|
+
"mappings": "gVAAA,OAAS,cAAAA,MAAkB,YAC3B,OAAOC,MAAY,SAEnB,OAAS,iBAAAC,MAAqB,0BAE9B,OAAS,kBAAAC,MAAsB,yCAC/B,OAAS,wBAAAC,MAA4B,sCAM9B,IAAMC,EAAN,KAAmE,CA2GxE,oBAA6C,CAC3C,OAAO,OAAO,OAAOA,EAA4B,gBAAgB,CACnE,CAEA,eAAeC,EAAqD,CAClE,OAAOD,EAA4B,iBAAiBC,EAAO,EAAE,CAC/D,CAKA,mBACEA,EACwB,CACxB,OAAO,KAAK,mBAAmB,EAAE,OAAQC,GAChC,OAAO,QAAQD,CAAM,EAAE,MAAM,CAAC,CAACE,EAAKC,CAAK,IACvCF,EAAYC,CAAiC,IAAMC,CAC3D,CACF,CACH,CAKA,2BAA4D,CAC1D,OAAO,OAAO,OAAOJ,EAA4B,gBAAgB,EAAE,OAEjE,CAACK,EAAKH,IAAgB,CACtB,KAAM,CAAE,cAAAI,CAAc,EAAIJ,EAC1B,OAAII,EACK,CACL,GAAGD,EACH,GAAGC,EAAc,OACf,CAACC,EAAgBC,KAAa,CAC5B,GAAGD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,aAAc,IAAM,GACpB,MAAO,CAAC,SAAU,EAClB,cAAe,CACb,CACE,YAAa,uCACb,WAAY,uCACZ,UAAW,uCACX,aAAc,sCAChB,CACF,CACF,CAAC,EACD,CAACA,EAAc,IAAI,EAAG,IAAIC,EAAqB,CAC7C,GAAID,EAAc,KAClB,YAAa,cACb,aAAc,IACd,uBAAwB,EACxB,QAAS,GACT,WAAY,KAAO,KACnB,aAAc,IAAM,GACpB,MAAO,CAAC,SAAU,EAClB,cAAe,CACb,CACE,YAAa,uCACb,WAAY,uCACZ,UAAW,uCACX,aAAc,sCAChB,CACF,CACF,CAAC,EACD,CAACA,EAAc,IAAI,EAAG,IAAIC,EAAqB,CAC7C,GAAID,EAAc,KAClB,YAAa,yBACb,aAAc,IACd,uBAAwB,EACxB,QAAS,GACT,WAAY,KAAO,KACnB,aAAc,IAAM,GACpB,MAAO,CAAC,SAAU,EAClB,cAAe,CACb,CACE,YAAa,uCACb,WAAY,uCACZ,UAAW,uCACX,aAAc,sCAChB,EACA,CACE,YAAa,uCACb,WAAY,uCACZ,UAAW,uCACX,aAAc,sCAChB,CACF,CACF,CAAC,CACH,GAzGWb,EAANiB,EAAA,CADNC,EAAW,GACClB",
|
|
6
6
|
"names": ["injectable", "semver", "DeviceModelId", "BleDeviceInfos", "TransportDeviceModel", "StaticDeviceModelDataSource", "params", "deviceModel", "key", "value", "acc", "bluetoothSpec", "serviceToModel", "bleSpec", "BleDeviceInfos", "spec", "uuid", "__publicField", "DeviceModelId", "TransportDeviceModel", "p", "semver", "__decorateClass", "injectable"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DeviceModelId as e}from"../../device/DeviceModel";import{BleDeviceInfos as r}from"../../device-model/model/BleDeviceInfos";import{StaticDeviceModelDataSource as
|
|
1
|
+
import{DeviceModelId as e}from"../../device/DeviceModel";import{BleDeviceInfos as r}from"../../device-model/model/BleDeviceInfos";import{StaticDeviceModelDataSource as n}from"./StaticDeviceModelDataSource";describe("StaticDeviceModelDataSource",()=>{describe("getAllDeviceModels",()=>{it("should return all device models",()=>{const c=new n().getAllDeviceModels();expect(c.length).toEqual(6),expect(c).toContainEqual(expect.objectContaining({id:e.APEX})),expect(c).toContainEqual(expect.objectContaining({id:e.NANO_S})),expect(c).toContainEqual(expect.objectContaining({id:e.NANO_SP})),expect(c).toContainEqual(expect.objectContaining({id:e.NANO_X})),expect(c).toContainEqual(expect.objectContaining({id:e.STAX})),expect(c).toContainEqual(expect.objectContaining({id:e.FLEX}))})}),describe("getDeviceModel",()=>{it("should return the associated device model",()=>{const t=new n,c=t.getDeviceModel({id:e.NANO_S});expect(c).toEqual(expect.objectContaining({id:e.NANO_S}));const o=t.getDeviceModel({id:e.NANO_SP});expect(o).toEqual(expect.objectContaining({id:e.NANO_SP}));const i=t.getDeviceModel({id:e.NANO_X});expect(i).toEqual(expect.objectContaining({id:e.NANO_X}));const d=t.getDeviceModel({id:e.STAX});expect(d).toEqual(expect.objectContaining({id:e.STAX}));const l=t.getDeviceModel({id:e.FLEX});expect(l).toEqual(expect.objectContaining({id:e.FLEX}))})}),describe("filterDeviceModels",()=>{it("should return the device models that match the given single parameter",()=>{const t=new n,c=t.filterDeviceModels({usbOnly:!0});expect(c.length).toEqual(2),expect(c).toContainEqual(expect.objectContaining({id:e.NANO_SP})),expect(c).toContainEqual(expect.objectContaining({id:e.NANO_S}));const o=t.filterDeviceModels({usbProductId:16});expect(o.length).toEqual(1),expect(o[0]).toEqual(expect.objectContaining({id:e.NANO_S}));const i=t.filterDeviceModels({usbProductId:64});expect(i.length).toEqual(1),expect(i[0]).toEqual(expect.objectContaining({id:e.NANO_X}));const d=t.filterDeviceModels({usbProductId:80});expect(d.length).toEqual(1),expect(d[0]).toEqual(expect.objectContaining({id:e.NANO_SP}));const l=t.filterDeviceModels({usbProductId:96});expect(l.length).toEqual(1),expect(l[0]).toEqual(expect.objectContaining({id:e.STAX}));const s=t.filterDeviceModels({usbProductId:0});expect(s.length).toEqual(0)}),it("should return the device models that match the given multiple parameters",()=>{const t=new n,c=t.filterDeviceModels({usbOnly:!1,usbProductId:64});expect(c.length).toEqual(1),expect(c[0]).toEqual(expect.objectContaining({id:e.NANO_X}));const o=t.filterDeviceModels({usbOnly:!0,usbProductId:80});expect(o.length).toEqual(1),expect(o[0]).toEqual(expect.objectContaining({id:e.NANO_SP}));const i=t.filterDeviceModels({usbOnly:!1,usbProductId:16});expect(i.length).toEqual(0)})}),describe("getBluetoothServicesInfos",()=>{it("should return the ble service infos record",()=>{const c=new n,o=c.getBluetoothServicesInfos();expect(o).toStrictEqual({"13d63400-2c97-0004-0000-4c6564676572":new r(c.getDeviceModel({id:e.NANO_X}),"13d63400-2c97-0004-0000-4c6564676572","13d63400-2c97-0004-0002-4c6564676572","13d63400-2c97-0004-0003-4c6564676572","13d63400-2c97-0004-0001-4c6564676572"),"13d63400-2c97-6004-0000-4c6564676572":new r(c.getDeviceModel({id:e.STAX}),"13d63400-2c97-6004-0000-4c6564676572","13d63400-2c97-6004-0002-4c6564676572","13d63400-2c97-6004-0003-4c6564676572","13d63400-2c97-6004-0001-4c6564676572"),"13d63400-2c97-3004-0000-4c6564676572":new r(c.getDeviceModel({id:e.FLEX}),"13d63400-2c97-3004-0000-4c6564676572","13d63400-2c97-3004-0002-4c6564676572","13d63400-2c97-3004-0003-4c6564676572","13d63400-2c97-3004-0001-4c6564676572"),"13d63400-2c97-8004-0000-4c6564676572":new r(c.getDeviceModel({id:e.APEX}),"13d63400-2c97-8004-0000-4c6564676572","13d63400-2c97-8004-0002-4c6564676572","13d63400-2c97-8004-0003-4c6564676572","13d63400-2c97-8004-0001-4c6564676572"),"13d63400-2c97-9004-0000-4c6564676572":new r(c.getDeviceModel({id:e.APEX}),"13d63400-2c97-9004-0000-4c6564676572","13d63400-2c97-9004-0002-4c6564676572","13d63400-2c97-9004-0003-4c6564676572","13d63400-2c97-9004-0001-4c6564676572")})});const t=[{serviceUuid:"13d63400-2c97-0004-0000-4c6564676572",deviceModel:e.NANO_X},{serviceUuid:"13d63400-2c97-6004-0000-4c6564676572",deviceModel:e.STAX},{serviceUuid:"13d63400-2c97-3004-0000-4c6564676572",deviceModel:e.FLEX},{serviceUuid:"13d63400-2c97-8004-0000-4c6564676572",deviceModel:e.APEX},{serviceUuid:"13d63400-2c97-9004-0000-4c6564676572",deviceModel:e.APEX}];it.each(t)("should properly map the service UUID $serviceUuid to the device model $deviceModel",({serviceUuid:c,deviceModel:o})=>{const d=new n().getBluetoothServicesInfos();expect(d[c]?.deviceModel.id).toEqual(o)})}),describe("getBluetoothServices",()=>{it("should return the bluetooth services",()=>{const c=new n().getBluetoothServices();expect(c).toStrictEqual(["13d63400-2c97-0004-0000-4c6564676572","13d63400-2c97-6004-0000-4c6564676572","13d63400-2c97-3004-0000-4c6564676572","13d63400-2c97-8004-0000-4c6564676572","13d63400-2c97-9004-0000-4c6564676572"])})}),describe("getBlockSize",()=>{const t={[e.NANO_S]:[{firmwareVersion:"1.0.0",expectedBlockSize:4096},{firmwareVersion:"1.0.0-rc1",expectedBlockSize:4096},{firmwareVersion:"2.0.0",expectedBlockSize:2048},{firmwareVersion:"2.0.0-rc1",expectedBlockSize:2048}],[e.NANO_SP]:[{firmwareVersion:"1.0.0",expectedBlockSize:32}],[e.NANO_X]:[{firmwareVersion:"1.0.0",expectedBlockSize:4096}],[e.STAX]:[{firmwareVersion:"1.0.0",expectedBlockSize:32}],[e.FLEX]:[{firmwareVersion:"1.0.0",expectedBlockSize:32}],[e.APEX]:[{firmwareVersion:"1.0.0",expectedBlockSize:32}]};describe.each(Object.entries(t))("Device Model: %s",(c,o)=>{it.each(o)("should return $expectedBlockSize for firmware version $firmwareVersion",({firmwareVersion:i,expectedBlockSize:d})=>{const l=new n().getDeviceModel({id:c});expect(l.getBlockSize({firmwareVersion:i})).toBe(d)})})})});
|
|
2
2
|
//# sourceMappingURL=StaticDeviceModelDataSource.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-model/data/StaticDeviceModelDataSource.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\n\nimport { StaticDeviceModelDataSource } from \"./StaticDeviceModelDataSource\";\n\ndescribe(\"StaticDeviceModelDataSource\", () => {\n describe(\"getAllDeviceModels\", () => {\n it(\"should return all device models\", () => {\n const dataSource = new StaticDeviceModelDataSource();\n const deviceModels = dataSource.getAllDeviceModels();\n\n expect(deviceModels.length).toEqual(6);\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.APEX }),\n );\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_S }),\n );\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_SP }),\n );\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_X }),\n );\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.STAX }),\n );\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.FLEX }),\n );\n });\n });\n\n describe(\"getDeviceModel\", () => {\n it(\"should return the associated device model\", () => {\n const dataSource = new StaticDeviceModelDataSource();\n\n const deviceModel1 = dataSource.getDeviceModel({\n id: DeviceModelId.NANO_S,\n });\n expect(deviceModel1).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_S }),\n );\n\n const deviceModel2 = dataSource.getDeviceModel({\n id: DeviceModelId.NANO_SP,\n });\n expect(deviceModel2).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_SP }),\n );\n\n const deviceModel3 = dataSource.getDeviceModel({\n id: DeviceModelId.NANO_X,\n });\n expect(deviceModel3).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_X }),\n );\n\n const deviceModel4 = dataSource.getDeviceModel({\n id: DeviceModelId.STAX,\n });\n expect(deviceModel4).toEqual(\n expect.objectContaining({ id: DeviceModelId.STAX }),\n );\n\n const deviceModel5 = dataSource.getDeviceModel({\n id: DeviceModelId.FLEX,\n });\n expect(deviceModel5).toEqual(\n expect.objectContaining({ id: DeviceModelId.FLEX }),\n );\n });\n });\n\n describe(\"filterDeviceModels\", () => {\n it(\"should return the device models that match the given single parameter\", () => {\n const dataSource = new StaticDeviceModelDataSource();\n\n const deviceModels1 = dataSource.filterDeviceModels({ usbOnly: true });\n expect(deviceModels1.length).toEqual(2);\n expect(deviceModels1).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_SP }),\n );\n expect(deviceModels1).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_S }),\n );\n\n const deviceModels2 = dataSource.filterDeviceModels({\n usbProductId: 0x10,\n });\n expect(deviceModels2.length).toEqual(1);\n expect(deviceModels2[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_S }),\n );\n\n const deviceModels3 = dataSource.filterDeviceModels({\n usbProductId: 0x40,\n });\n expect(deviceModels3.length).toEqual(1);\n expect(deviceModels3[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_X }),\n );\n\n const deviceModels4 = dataSource.filterDeviceModels({\n usbProductId: 0x50,\n });\n expect(deviceModels4.length).toEqual(1);\n expect(deviceModels4[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_SP }),\n );\n\n const deviceModels5 = dataSource.filterDeviceModels({\n usbProductId: 0x60,\n });\n expect(deviceModels5.length).toEqual(1);\n expect(deviceModels5[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.STAX }),\n );\n\n const deviceModels6 = dataSource.filterDeviceModels({\n usbProductId: 0x00,\n });\n expect(deviceModels6.length).toEqual(0);\n });\n\n it(\"should return the device models that match the given multiple parameters\", () => {\n const dataSource = new StaticDeviceModelDataSource();\n\n const deviceModels1 = dataSource.filterDeviceModels({\n usbOnly: false,\n usbProductId: 0x40,\n });\n expect(deviceModels1.length).toEqual(1);\n expect(deviceModels1[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_X }),\n );\n\n const deviceModels2 = dataSource.filterDeviceModels({\n usbOnly: true,\n usbProductId: 0x50,\n });\n expect(deviceModels2.length).toEqual(1);\n expect(deviceModels2[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_SP }),\n );\n\n // Nano S is usbOnly\n const deviceModels3 = dataSource.filterDeviceModels({\n usbOnly: false,\n usbProductId: 0x10,\n });\n expect(deviceModels3.length).toEqual(0);\n });\n });\n describe(\"getBluetoothServicesInfos\", () => {\n it(\"should return the ble service infos record\", () => {\n // given\n const dataSource = new StaticDeviceModelDataSource();\n // when\n const bleServiceInfos = dataSource.getBluetoothServicesInfos();\n // then\n expect(bleServiceInfos).toStrictEqual({\n \"13d63400-2c97-0004-0000-4c6564676572\": new BleDeviceInfos(\n dataSource.getDeviceModel({ id: DeviceModelId.NANO_X }),\n \"13d63400-2c97-0004-0000-4c6564676572\",\n \"13d63400-2c97-0004-0002-4c6564676572\",\n \"13d63400-2c97-0004-0003-4c6564676572\",\n \"13d63400-2c97-0004-0001-4c6564676572\",\n ),\n \"13d63400-2c97-6004-0000-4c6564676572\": new BleDeviceInfos(\n dataSource.getDeviceModel({ id: DeviceModelId.STAX }),\n \"13d63400-2c97-6004-0000-4c6564676572\",\n \"13d63400-2c97-6004-0002-4c6564676572\",\n \"13d63400-2c97-6004-0003-4c6564676572\",\n \"13d63400-2c97-6004-0001-4c6564676572\",\n ),\n \"13d63400-2c97-3004-0000-4c6564676572\": new BleDeviceInfos(\n dataSource.getDeviceModel({ id: DeviceModelId.FLEX }),\n \"13d63400-2c97-3004-0000-4c6564676572\",\n \"13d63400-2c97-3004-0002-4c6564676572\",\n \"13d63400-2c97-3004-0003-4c6564676572\",\n \"13d63400-2c97-3004-0001-4c6564676572\",\n ),\n \"13d63400-2c97-8004-0000-4c6564676572\": new BleDeviceInfos(\n dataSource.getDeviceModel({ id: DeviceModelId.APEX }),\n \"13d63400-2c97-8004-0000-4c6564676572\",\n \"13d63400-2c97-8004-0002-4c6564676572\",\n \"13d63400-2c97-8004-0003-4c6564676572\",\n \"13d63400-2c97-8004-0001-4c6564676572\",\n ),\n });\n });\n });\n describe(\"getBluetoothServices\", () => {\n it(\"should return the bluetooth services\", () => {\n // given\n const dataSource = new StaticDeviceModelDataSource();\n // when\n const bleServices = dataSource.getBluetoothServices();\n // then\n expect(bleServices).toStrictEqual([\n \"13d63400-2c97-0004-0000-4c6564676572\",\n \"13d63400-2c97-6004-0000-4c6564676572\",\n \"13d63400-2c97-3004-0000-4c6564676572\",\n \"13d63400-2c97-8004-0000-4c6564676572\",\n ]);\n });\n });\n\n describe(\"getBlockSize\", () => {\n const testData: Record<\n DeviceModelId,\n Array<{ firmwareVersion: string; expectedBlockSize: number }>\n > = {\n [DeviceModelId.NANO_S]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 4 * 1024 },\n { firmwareVersion: \"1.0.0-rc1\", expectedBlockSize: 4 * 1024 },\n { firmwareVersion: \"2.0.0\", expectedBlockSize: 2 * 1024 },\n { firmwareVersion: \"2.0.0-rc1\", expectedBlockSize: 2 * 1024 },\n ],\n [DeviceModelId.NANO_SP]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 32 },\n ],\n [DeviceModelId.NANO_X]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 4 * 1024 },\n ],\n [DeviceModelId.STAX]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 32 },\n ],\n [DeviceModelId.FLEX]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 32 },\n ],\n [DeviceModelId.APEX]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 32 },\n ],\n };\n\n describe.each(Object.entries(testData))(\n \"Device Model: %s\",\n (deviceModelId, scenarios) => {\n it.each(scenarios)(\n \"should return $expectedBlockSize for firmware version $firmwareVersion\",\n ({ firmwareVersion, expectedBlockSize }) => {\n const deviceModel =\n new StaticDeviceModelDataSource().getDeviceModel({\n id: deviceModelId as DeviceModelId,\n });\n expect(deviceModel.getBlockSize({ firmwareVersion })).toBe(\n expectedBlockSize,\n );\n },\n );\n },\n );\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,0BAC9B,OAAS,kBAAAC,MAAsB,yCAE/B,OAAS,+BAAAC,MAAmC,gCAE5C,SAAS,8BAA+B,IAAM,CAC5C,SAAS,qBAAsB,IAAM,CACnC,GAAG,kCAAmC,IAAM,CAE1C,MAAMC,EADa,IAAID,EAA4B,EACnB,mBAAmB,EAEnD,OAAOC,EAAa,MAAM,EAAE,QAAQ,CAAC,EACrC,OAAOA,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,IAAK,CAAC,CACpD,EACA,OAAOG,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,MAAO,CAAC,CACtD,EACA,OAAOG,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,OAAQ,CAAC,CACvD,EACA,OAAOG,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,MAAO,CAAC,CACtD,EACA,OAAOG,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,IAAK,CAAC,CACpD,EACA,OAAOG,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,IAAK,CAAC,CACpD,CACF,CAAC,CACH,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,4CAA6C,IAAM,CACpD,MAAMI,EAAa,IAAIF,EAEjBG,EAAeD,EAAW,eAAe,CAC7C,GAAIJ,EAAc,MACpB,CAAC,EACD,OAAOK,CAAY,EAAE,QACnB,OAAO,iBAAiB,CAAE,GAAIL,EAAc,MAAO,CAAC,CACtD,EAEA,MAAMM,EAAeF,EAAW,eAAe,CAC7C,GAAIJ,EAAc,OACpB,CAAC,EACD,OAAOM,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AAMR,EAAa,IAAIF,EAEjBc,EAAkBZ,EAAW,0BAA0B,EAE7D,OAAOY,CAAe,EAAE,cAAc,CACpC,uCAAwC,IAAIf,EAC1CG,EAAW,eAAe,CAAE,GAAIJ,EAAc,MAAO,CAAC,EACtD,uCACA,uCACA,uCACA,sCACF,EACA,uCAAwC,IAAIC,EAC1CG,EAAW,eAAe,CAAE,GAAIJ,EAAc,IAAK,CAAC,EACpD,uCACA,uCACA,uCACA,sCACF,EACA,uCAAwC,IAAIC,EAC1CG,EAAW,eAAe,CAAE,GAAIJ,EAAc,IAAK,CAAC,EACpD,uCACA,uCACA,uCACA,sCACF,EACA,uCAAwC,IAAIC,EAC1CG,EAAW,eAAe,CAAE,GAAIJ,EAAc,IAAK,CAAC,EACpD,uCACA,uCACA,uCACA,sCACF,CACF,CAAC,CACH,CAAC,
|
|
6
|
-
"names": ["DeviceModelId", "BleDeviceInfos", "StaticDeviceModelDataSource", "deviceModels", "dataSource", "deviceModel1", "deviceModel2", "deviceModel3", "deviceModel4", "deviceModel5", "deviceModels1", "deviceModels2", "deviceModels3", "deviceModels4", "deviceModels5", "deviceModels6", "bleServiceInfos", "bleServices", "testData", "deviceModelId", "scenarios", "firmwareVersion", "expectedBlockSize"
|
|
4
|
+
"sourcesContent": ["import { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { BleDeviceInfos } from \"@api/device-model/model/BleDeviceInfos\";\n\nimport { StaticDeviceModelDataSource } from \"./StaticDeviceModelDataSource\";\n\ndescribe(\"StaticDeviceModelDataSource\", () => {\n describe(\"getAllDeviceModels\", () => {\n it(\"should return all device models\", () => {\n const dataSource = new StaticDeviceModelDataSource();\n const deviceModels = dataSource.getAllDeviceModels();\n\n expect(deviceModels.length).toEqual(6);\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.APEX }),\n );\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_S }),\n );\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_SP }),\n );\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_X }),\n );\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.STAX }),\n );\n expect(deviceModels).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.FLEX }),\n );\n });\n });\n\n describe(\"getDeviceModel\", () => {\n it(\"should return the associated device model\", () => {\n const dataSource = new StaticDeviceModelDataSource();\n\n const deviceModel1 = dataSource.getDeviceModel({\n id: DeviceModelId.NANO_S,\n });\n expect(deviceModel1).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_S }),\n );\n\n const deviceModel2 = dataSource.getDeviceModel({\n id: DeviceModelId.NANO_SP,\n });\n expect(deviceModel2).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_SP }),\n );\n\n const deviceModel3 = dataSource.getDeviceModel({\n id: DeviceModelId.NANO_X,\n });\n expect(deviceModel3).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_X }),\n );\n\n const deviceModel4 = dataSource.getDeviceModel({\n id: DeviceModelId.STAX,\n });\n expect(deviceModel4).toEqual(\n expect.objectContaining({ id: DeviceModelId.STAX }),\n );\n\n const deviceModel5 = dataSource.getDeviceModel({\n id: DeviceModelId.FLEX,\n });\n expect(deviceModel5).toEqual(\n expect.objectContaining({ id: DeviceModelId.FLEX }),\n );\n });\n });\n\n describe(\"filterDeviceModels\", () => {\n it(\"should return the device models that match the given single parameter\", () => {\n const dataSource = new StaticDeviceModelDataSource();\n\n const deviceModels1 = dataSource.filterDeviceModels({ usbOnly: true });\n expect(deviceModels1.length).toEqual(2);\n expect(deviceModels1).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_SP }),\n );\n expect(deviceModels1).toContainEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_S }),\n );\n\n const deviceModels2 = dataSource.filterDeviceModels({\n usbProductId: 0x10,\n });\n expect(deviceModels2.length).toEqual(1);\n expect(deviceModels2[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_S }),\n );\n\n const deviceModels3 = dataSource.filterDeviceModels({\n usbProductId: 0x40,\n });\n expect(deviceModels3.length).toEqual(1);\n expect(deviceModels3[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_X }),\n );\n\n const deviceModels4 = dataSource.filterDeviceModels({\n usbProductId: 0x50,\n });\n expect(deviceModels4.length).toEqual(1);\n expect(deviceModels4[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_SP }),\n );\n\n const deviceModels5 = dataSource.filterDeviceModels({\n usbProductId: 0x60,\n });\n expect(deviceModels5.length).toEqual(1);\n expect(deviceModels5[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.STAX }),\n );\n\n const deviceModels6 = dataSource.filterDeviceModels({\n usbProductId: 0x00,\n });\n expect(deviceModels6.length).toEqual(0);\n });\n\n it(\"should return the device models that match the given multiple parameters\", () => {\n const dataSource = new StaticDeviceModelDataSource();\n\n const deviceModels1 = dataSource.filterDeviceModels({\n usbOnly: false,\n usbProductId: 0x40,\n });\n expect(deviceModels1.length).toEqual(1);\n expect(deviceModels1[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_X }),\n );\n\n const deviceModels2 = dataSource.filterDeviceModels({\n usbOnly: true,\n usbProductId: 0x50,\n });\n expect(deviceModels2.length).toEqual(1);\n expect(deviceModels2[0]).toEqual(\n expect.objectContaining({ id: DeviceModelId.NANO_SP }),\n );\n\n // Nano S is usbOnly\n const deviceModels3 = dataSource.filterDeviceModels({\n usbOnly: false,\n usbProductId: 0x10,\n });\n expect(deviceModels3.length).toEqual(0);\n });\n });\n describe(\"getBluetoothServicesInfos\", () => {\n it(\"should return the ble service infos record\", () => {\n // given\n const dataSource = new StaticDeviceModelDataSource();\n // when\n const bleServiceInfos = dataSource.getBluetoothServicesInfos();\n // then\n expect(bleServiceInfos).toStrictEqual({\n \"13d63400-2c97-0004-0000-4c6564676572\": new BleDeviceInfos(\n dataSource.getDeviceModel({ id: DeviceModelId.NANO_X }),\n \"13d63400-2c97-0004-0000-4c6564676572\",\n \"13d63400-2c97-0004-0002-4c6564676572\",\n \"13d63400-2c97-0004-0003-4c6564676572\",\n \"13d63400-2c97-0004-0001-4c6564676572\",\n ),\n \"13d63400-2c97-6004-0000-4c6564676572\": new BleDeviceInfos(\n dataSource.getDeviceModel({ id: DeviceModelId.STAX }),\n \"13d63400-2c97-6004-0000-4c6564676572\",\n \"13d63400-2c97-6004-0002-4c6564676572\",\n \"13d63400-2c97-6004-0003-4c6564676572\",\n \"13d63400-2c97-6004-0001-4c6564676572\",\n ),\n \"13d63400-2c97-3004-0000-4c6564676572\": new BleDeviceInfos(\n dataSource.getDeviceModel({ id: DeviceModelId.FLEX }),\n \"13d63400-2c97-3004-0000-4c6564676572\",\n \"13d63400-2c97-3004-0002-4c6564676572\",\n \"13d63400-2c97-3004-0003-4c6564676572\",\n \"13d63400-2c97-3004-0001-4c6564676572\",\n ),\n \"13d63400-2c97-8004-0000-4c6564676572\": new BleDeviceInfos(\n dataSource.getDeviceModel({ id: DeviceModelId.APEX }),\n \"13d63400-2c97-8004-0000-4c6564676572\",\n \"13d63400-2c97-8004-0002-4c6564676572\",\n \"13d63400-2c97-8004-0003-4c6564676572\",\n \"13d63400-2c97-8004-0001-4c6564676572\",\n ),\n \"13d63400-2c97-9004-0000-4c6564676572\": new BleDeviceInfos(\n dataSource.getDeviceModel({ id: DeviceModelId.APEX }),\n \"13d63400-2c97-9004-0000-4c6564676572\",\n \"13d63400-2c97-9004-0002-4c6564676572\",\n \"13d63400-2c97-9004-0003-4c6564676572\",\n \"13d63400-2c97-9004-0001-4c6564676572\",\n ),\n });\n });\n const expectedMatches = [\n {\n serviceUuid: \"13d63400-2c97-0004-0000-4c6564676572\",\n deviceModel: DeviceModelId.NANO_X,\n },\n {\n serviceUuid: \"13d63400-2c97-6004-0000-4c6564676572\",\n deviceModel: DeviceModelId.STAX,\n },\n {\n serviceUuid: \"13d63400-2c97-3004-0000-4c6564676572\",\n deviceModel: DeviceModelId.FLEX,\n },\n {\n serviceUuid: \"13d63400-2c97-8004-0000-4c6564676572\",\n deviceModel: DeviceModelId.APEX,\n },\n {\n serviceUuid: \"13d63400-2c97-9004-0000-4c6564676572\",\n deviceModel: DeviceModelId.APEX,\n },\n ];\n\n it.each(expectedMatches)(\n \"should properly map the service UUID $serviceUuid to the device model $deviceModel\",\n ({ serviceUuid, deviceModel }) => {\n // given\n const dataSource = new StaticDeviceModelDataSource();\n // when\n const bleServiceInfos = dataSource.getBluetoothServicesInfos();\n // then\n expect(bleServiceInfos[serviceUuid]?.deviceModel.id).toEqual(\n deviceModel,\n );\n },\n );\n });\n describe(\"getBluetoothServices\", () => {\n it(\"should return the bluetooth services\", () => {\n // given\n const dataSource = new StaticDeviceModelDataSource();\n // when\n const bleServices = dataSource.getBluetoothServices();\n // then\n expect(bleServices).toStrictEqual([\n \"13d63400-2c97-0004-0000-4c6564676572\",\n \"13d63400-2c97-6004-0000-4c6564676572\",\n \"13d63400-2c97-3004-0000-4c6564676572\",\n \"13d63400-2c97-8004-0000-4c6564676572\",\n \"13d63400-2c97-9004-0000-4c6564676572\",\n ]);\n });\n });\n\n describe(\"getBlockSize\", () => {\n const testData: Record<\n DeviceModelId,\n Array<{ firmwareVersion: string; expectedBlockSize: number }>\n > = {\n [DeviceModelId.NANO_S]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 4 * 1024 },\n { firmwareVersion: \"1.0.0-rc1\", expectedBlockSize: 4 * 1024 },\n { firmwareVersion: \"2.0.0\", expectedBlockSize: 2 * 1024 },\n { firmwareVersion: \"2.0.0-rc1\", expectedBlockSize: 2 * 1024 },\n ],\n [DeviceModelId.NANO_SP]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 32 },\n ],\n [DeviceModelId.NANO_X]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 4 * 1024 },\n ],\n [DeviceModelId.STAX]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 32 },\n ],\n [DeviceModelId.FLEX]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 32 },\n ],\n [DeviceModelId.APEX]: [\n { firmwareVersion: \"1.0.0\", expectedBlockSize: 32 },\n ],\n };\n\n describe.each(Object.entries(testData))(\n \"Device Model: %s\",\n (deviceModelId, scenarios) => {\n it.each(scenarios)(\n \"should return $expectedBlockSize for firmware version $firmwareVersion\",\n ({ firmwareVersion, expectedBlockSize }) => {\n const deviceModel =\n new StaticDeviceModelDataSource().getDeviceModel({\n id: deviceModelId as DeviceModelId,\n });\n expect(deviceModel.getBlockSize({ firmwareVersion })).toBe(\n expectedBlockSize,\n );\n },\n );\n },\n );\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,MAAqB,0BAC9B,OAAS,kBAAAC,MAAsB,yCAE/B,OAAS,+BAAAC,MAAmC,gCAE5C,SAAS,8BAA+B,IAAM,CAC5C,SAAS,qBAAsB,IAAM,CACnC,GAAG,kCAAmC,IAAM,CAE1C,MAAMC,EADa,IAAID,EAA4B,EACnB,mBAAmB,EAEnD,OAAOC,EAAa,MAAM,EAAE,QAAQ,CAAC,EACrC,OAAOA,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,IAAK,CAAC,CACpD,EACA,OAAOG,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,MAAO,CAAC,CACtD,EACA,OAAOG,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,OAAQ,CAAC,CACvD,EACA,OAAOG,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,MAAO,CAAC,CACtD,EACA,OAAOG,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,IAAK,CAAC,CACpD,EACA,OAAOG,CAAY,EAAE,eACnB,OAAO,iBAAiB,CAAE,GAAIH,EAAc,IAAK,CAAC,CACpD,CACF,C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C,EACH,OAAOH,EAAY,aAAa,CAAE,gBAAAK,CAAgB,CAAC,CAAC,EAAE,KACpDC,CACF,CACF,CACF,CACF,CACF,CACF,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["DeviceModelId", "BleDeviceInfos", "StaticDeviceModelDataSource", "deviceModels", "dataSource", "deviceModel1", "deviceModel2", "deviceModel3", "deviceModel4", "deviceModel5", "deviceModels1", "deviceModels2", "deviceModels3", "deviceModels4", "deviceModels5", "deviceModels6", "bleServiceInfos", "expectedMatches", "serviceUuid", "deviceModel", "bleServices", "testData", "deviceModelId", "scenarios", "firmwareVersion", "expectedBlockSize"]
|
|
7
7
|
}
|
package/lib/esm/src/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Apdu as o}from"./apdu/model/Apdu";import{APDU_MAX_PAYLOAD as p,ApduBuilder as i}from"./apdu/utils/ApduBuilder";import{ApduParser as
|
|
1
|
+
import{Apdu as o}from"./apdu/model/Apdu";import{APDU_MAX_PAYLOAD as p,ApduBuilder as i}from"./apdu/utils/ApduBuilder";import{ApduParser as n}from"./apdu/utils/ApduParser";export*from"./apdu/utils/AppBuilderError";import{ByteArrayBuilder as f}from"./apdu/utils/ByteArrayBuilder";import{ByteArrayParser as x}from"./apdu/utils/ByteArrayParser";import{InvalidGetFirmwareMetadataResponseError as A,InvalidStatusWordError as D}from"./command/Errors";import{CommandResultFactory as u,CommandResultStatus as v,isSuccessCommandResult as S}from"./command/model/CommandResult";import{CloseAppCommand as C}from"./command/os/CloseAppCommand";import{GetAppAndVersionCommand as L}from"./command/os/GetAppAndVersionCommand";import{BatteryStatusType as B,GetBatteryStatusCommand as G}from"./command/os/GetBatteryStatusCommand";import{GetOsVersionCommand as M}from"./command/os/GetOsVersionCommand";import{ListAppsCommand as O}from"./command/os/ListAppsCommand";import{LoadCertificateCommand as b}from"./command/os/LoadCertificateCommand";import{OpenAppCommand as U}from"./command/os/OpenAppCommand";import{isCommandErrorCode as P}from"./command/utils/CommandErrors";import{CommandUtils as k}from"./command/utils/CommandUtils";import{GlobalCommandError as _,GlobalCommandErrorHandler as w}from"./command/utils/GlobalCommandError";import{DeviceModel as K,DeviceModelId as X,LEDGER_VENDOR_ID as q}from"./device/DeviceModel";import{DeviceStatus as Y}from"./device/DeviceStatus";import{DeviceActionStatus as z}from"./device-action/model/DeviceActionState";import{UserInteractionRequired as Q}from"./device-action/model/UserInteractionRequired";import{CallTaskInAppDeviceAction as $}from"./device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction";import{AppAlreadyInstalledDAError as re,DeviceLockedError as oe,OutOfMemoryDAError as te,RefusedByUserDAError as pe,UnknownDAError as ie,UnsupportedFirmwareDAError as me}from"./device-action/os/Errors";import{GetDeviceMetadataDeviceAction as ae}from"./device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction";import{GetDeviceStatusDeviceAction as fe}from"./device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction";import{GoToDashboardDeviceAction as xe}from"./device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{InstallOrUpdateAppsDeviceAction as Ae}from"./device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction";import{ListAppsDeviceAction as le}from"./device-action/os/ListApps/ListAppsDeviceAction";import{ListAppsWithMetadataDeviceAction as ve}from"./device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction";import{OpenAppDeviceAction as ye}from"./device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{OpenAppWithDependenciesDeviceAction as ge}from"./device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction";import{SendCommandInAppDeviceAction as Ee}from"./device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction";import{XStateDeviceAction as Ge}from"./device-action/xstate-utils/XStateDeviceAction";import{StaticDeviceModelDataSource as Me}from"./device-model/data/StaticDeviceModelDataSource";import{BleDeviceInfos as Oe}from"./device-model/model/BleDeviceInfos";import{TransportDeviceModel as be}from"./device-model/model/DeviceModel";import{ApduResponse as Ue}from"./device-session/ApduResponse";export*from"./device-session/data/FramerConst";import{DeviceSessionStateType as Ve}from"./device-session/DeviceSessionState";import{GenuineCheckDeviceAction as We}from"./secure-channel/device-action/GenuineCheck/GenuineCheckDeviceAction";import{InstallAppDeviceAction as we}from"./secure-channel/device-action/InstallApp/InstallAppDeviceAction";import{ListInstalledAppsDeviceAction as Ke}from"./secure-channel/device-action/ListInstalledApps/ListInstalledAppsDeviceAction";import{UninstallAppDeviceAction as qe}from"./secure-channel/device-action/UninstallApp/UninstallAppDeviceAction";import{SecureChannelError as Ye}from"../internal/secure-channel/model/Errors";import{defaultApduReceiverServiceStubBuilder as ze}from"./device-session/service/DefaultApduReceiverService.stub";import{defaultApduSenderServiceStubBuilder as Qe}from"./device-session/service/DefaultApduSenderService.stub";import{FramerUtils as $e}from"./device-session/utils/FramerUtils";import{DeviceManagementKit as rr}from"./DeviceManagementKit";import{DeviceManagementKitBuilder as tr}from"./DeviceManagementKitBuilder";export*from"./Error";import{LogLevel as mr}from"./logger-subscriber/model/LogLevel";import{ConsoleLogger as ar}from"./logger-subscriber/service/ConsoleLogger";import{DefaultLogTagFormatter as fr}from"./logger-subscriber/service/DefaultLogTagFormatter";import{WebLogsExporterLogger as xr}from"./logger-subscriber/service/WebLogsExporterLogger";import{ConnectedDevice as Ar}from"./transport/model/ConnectedDevice";import{DeviceConnectionStateMachine as lr}from"./transport/model/DeviceConnectionStateMachine";export*from"./transport/model/Errors";import{TransportConnectedDevice as Sr}from"./transport/model/TransportConnectedDevice";import{connectedDeviceStubBuilder as Cr}from"./transport/model/TransportConnectedDevice.stub";export*from"./types";import{formatApduReceivedLog as Er,formatApduSentLog as Br}from"./utils/apduLogs";import{base64StringToBuffer as Rr,isBase64String as Mr}from"./utils/Base64String";import{bufferToHexaString as Or,hexaStringToBuffer as Tr,isHexaString as br}from"./utils/HexaString";export{p as APDU_MAX_PAYLOAD,o as Apdu,i as ApduBuilder,n as ApduParser,Ue as ApduResponse,re as AppAlreadyInstalledDAError,B as BatteryStatusType,Oe as BleDeviceInfos,f as ByteArrayBuilder,x as ByteArrayParser,$ as CallTaskInAppDeviceAction,C as CloseAppCommand,u as CommandResultFactory,v as CommandResultStatus,k as CommandUtils,Ar as ConnectedDevice,ar as ConsoleLogger,fr as DefaultLogTagFormatter,z as DeviceActionStatus,lr as DeviceConnectionStateMachine,oe as DeviceLockedError,rr as DeviceManagementKit,tr as DeviceManagementKitBuilder,K as DeviceModel,X as DeviceModelId,Ve as DeviceSessionStateType,Y as DeviceStatus,$e as FramerUtils,We as GenuineCheckDeviceAction,L as GetAppAndVersionCommand,G as GetBatteryStatusCommand,ae as GetDeviceMetadataDeviceAction,fe as GetDeviceStatusDeviceAction,M as GetOsVersionCommand,_ as GlobalCommandError,w as GlobalCommandErrorHandler,xe as GoToDashboardDeviceAction,we as InstallAppDeviceAction,Ae as InstallOrUpdateAppsDeviceAction,A as InvalidGetFirmwareMetadataResponseError,D as InvalidStatusWordError,q as LEDGER_VENDOR_ID,O as ListAppsCommand,le as ListAppsDeviceAction,ve as ListAppsWithMetadataDeviceAction,Ke as ListInstalledAppsDeviceAction,b as LoadCertificateCommand,mr as LogLevel,U as OpenAppCommand,ye as OpenAppDeviceAction,ge as OpenAppWithDependenciesDeviceAction,te as OutOfMemoryDAError,pe as RefusedByUserDAError,Ye as SecureChannelError,Ee as SendCommandInAppDeviceAction,Me as StaticDeviceModelDataSource,Sr as TransportConnectedDevice,be as TransportDeviceModel,qe as UninstallAppDeviceAction,ie as UnknownDAError,me as UnsupportedFirmwareDAError,Q as UserInteractionRequired,xr as WebLogsExporterLogger,Ge as XStateDeviceAction,Rr as base64StringToBuffer,Or as bufferToHexaString,Cr as connectedDeviceStubBuilder,ze as defaultApduReceiverServiceStubBuilder,Qe as defaultApduSenderServiceStubBuilder,Er as formatApduReceivedLog,Br as formatApduSentLog,Tr as hexaStringToBuffer,Mr as isBase64String,P as isCommandErrorCode,br as isHexaString,S as isSuccessCommandResult};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|