@ledgerhq/device-transport-kit-speculos 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +36 -32
- package/lib/cjs/src/api/SpeculosTransport.js +1 -1
- package/lib/cjs/src/api/SpeculosTransport.js.map +2 -2
- package/lib/esm/package.json +36 -32
- package/lib/esm/src/api/SpeculosTransport.js +1 -1
- package/lib/esm/src/api/SpeculosTransport.js.map +2 -2
- package/lib/types/src/api/SpeculosTransport.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +33 -29
package/lib/cjs/package.json
CHANGED
|
@@ -1,56 +1,60 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@sentry/minimal": "catalog:",
|
|
4
|
+
"axios": "catalog:",
|
|
5
|
+
"purify-ts": "catalog:"
|
|
6
|
+
},
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"@ledgerhq/device-management-kit": "workspace:^",
|
|
9
|
+
"@ledgerhq/eslint-config-dsdk": "workspace:^",
|
|
10
|
+
"@ledgerhq/ldmk-tool": "workspace:^",
|
|
11
|
+
"@ledgerhq/prettier-config-dsdk": "workspace:^",
|
|
12
|
+
"@ledgerhq/tsconfig-dsdk": "workspace:^",
|
|
13
|
+
"@ledgerhq/vitest-config-dmk": "workspace:^",
|
|
14
|
+
"rxjs": "catalog:",
|
|
15
|
+
"ts-node": "catalog:"
|
|
16
|
+
},
|
|
6
17
|
"exports": {
|
|
7
18
|
".": {
|
|
8
|
-
"types": "./lib/types/index.d.ts",
|
|
9
19
|
"import": "./lib/esm/index.js",
|
|
10
|
-
"require": "./lib/cjs/index.js"
|
|
20
|
+
"require": "./lib/cjs/index.js",
|
|
21
|
+
"types": "./lib/types/index.d.ts"
|
|
11
22
|
},
|
|
12
23
|
"./*": {
|
|
13
|
-
"types": "./lib/types/*",
|
|
14
24
|
"import": "./lib/esm/*",
|
|
15
|
-
"require": "./lib/cjs/*"
|
|
25
|
+
"require": "./lib/cjs/*",
|
|
26
|
+
"types": "./lib/types/*"
|
|
16
27
|
}
|
|
17
28
|
},
|
|
18
29
|
"files": [
|
|
19
30
|
"./lib"
|
|
20
31
|
],
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"name": "@ledgerhq/device-transport-kit-speculos",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@ledgerhq/device-management-kit": "workspace:^",
|
|
36
|
+
"rxjs": "catalog:"
|
|
37
|
+
},
|
|
38
|
+
"private": false,
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/LedgerHQ/device-sdk-ts.git"
|
|
42
|
+
},
|
|
21
43
|
"scripts": {
|
|
22
|
-
"prebuild": "rimraf lib",
|
|
23
44
|
"build": "pnpm ldmk-tool build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
24
45
|
"dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
|
|
25
|
-
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
26
|
-
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"",
|
|
27
46
|
"lint": "eslint",
|
|
28
47
|
"lint:fix": "pnpm lint --fix",
|
|
29
48
|
"postpack": "find . -name '*.tgz' -exec cp {} ../../../dist/ \\; ",
|
|
49
|
+
"prebuild": "rimraf lib",
|
|
30
50
|
"prettier": "prettier . --check",
|
|
31
51
|
"prettier:fix": "prettier . --write",
|
|
32
|
-
"typecheck": "tsc --noEmit",
|
|
33
52
|
"test": "vitest run --passWithNoTests",
|
|
53
|
+
"test:coverage": "vitest run --coverage --passWithNoTests",
|
|
34
54
|
"test:watch": "vitest --passWithNoTests",
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"@sentry/minimal": "catalog:",
|
|
39
|
-
"purify-ts": "catalog:",
|
|
40
|
-
"axios": "catalog:"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@ledgerhq/device-management-kit": "workspace:*",
|
|
44
|
-
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
45
|
-
"@ledgerhq/ldmk-tool": "workspace:*",
|
|
46
|
-
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
47
|
-
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
48
|
-
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
49
|
-
"rxjs": "catalog:",
|
|
50
|
-
"ts-node": "catalog:"
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
57
|
+
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
51
58
|
},
|
|
52
|
-
"
|
|
53
|
-
"@ledgerhq/device-management-kit": "workspace:*",
|
|
54
|
-
"rxjs": "catalog:"
|
|
55
|
-
}
|
|
59
|
+
"version": "1.1.2"
|
|
56
60
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var y=(s,e)=>{for(var t in e)l(s,t,{get:e[t],enumerable:!0})},b=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of S(e))!m.call(s,r)&&r!==t&&l(s,r,{get:()=>e[r],enumerable:!(n=f(e,r))||n.enumerable});return s};var I=s=>b(l({},"__esModule",{value:!0}),s);var E={};y(E,{SpeculosTransport:()=>D,speculosIdentifier:()=>g,speculosTransportFactory:()=>T});module.exports=I(E);var o=require("@ledgerhq/device-management-kit"),i=require("purify-ts"),u=require("rxjs"),v=require("../internal/datasource/HttpSpeculosDatasource");const g="SPECULOS_HTTP_TRANSPORT";class D{logger;identifier=g;_speculosDataSource;connectedDevice=null;disconnectInterval=null;_isE2E;speculosDevice={id:"SpeculosID",deviceModel:{id:o.DeviceModelId.STAX,productName:"Speculos - App Name - version",usbProductId:16,bootloaderUsbProductId:1,getBlockSize(){return 32},
|
|
1
|
+
"use strict";var l=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var y=(s,e)=>{for(var t in e)l(s,t,{get:e[t],enumerable:!0})},b=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of S(e))!m.call(s,r)&&r!==t&&l(s,r,{get:()=>e[r],enumerable:!(n=f(e,r))||n.enumerable});return s};var I=s=>b(l({},"__esModule",{value:!0}),s);var E={};y(E,{SpeculosTransport:()=>D,speculosIdentifier:()=>g,speculosTransportFactory:()=>T});module.exports=I(E);var o=require("@ledgerhq/device-management-kit"),i=require("purify-ts"),u=require("rxjs"),v=require("../internal/datasource/HttpSpeculosDatasource");const g="SPECULOS_HTTP_TRANSPORT";class D{logger;identifier=g;_speculosDataSource;connectedDevice=null;disconnectInterval=null;_isE2E;speculosDevice={id:"SpeculosID",deviceModel:{id:o.DeviceModelId.STAX,productName:"Speculos - App Name - version",usbProductId:16,bootloaderUsbProductId:1,getBlockSize(){return 32},usbOnly:!0,memorySize:320*1024,masks:[823132160]},transport:this.identifier};constructor(e,t,n,r){this._isE2E=r??!1,this.logger=e("SpeculosTransport"),this._speculosDataSource=new v.HttpSpeculosDatasource(n)}isSupported(){return!0}getIdentifier(){return this.identifier}listenToAvailableDevices(){return(0,u.from)([[this.speculosDevice]])}startDiscovering(){return this.logger.debug("startDiscovering"),(0,u.from)([this.speculosDevice])}stopDiscovering(){this.logger.debug("stopDiscovering")}async connect(e){this.logger.debug("connect");const t=await this._speculosDataSource.postApdu("B0010000");this.logger.debug(`Hex Response: ${t}`);const n=this.createApduResponse(t),r=new o.ApduParser(n);r.extract8BitUInt();const c=r.encodeToString(r.extractFieldLVEncoded()),a=r.encodeToString(r.extractFieldLVEncoded());this.logger.debug(`App Name: ${c} and version ${a}`);const d=e.deviceId;try{const p={sendApdu:h=>this.sendApdu(d,e.deviceId,e.onDisconnect,h),deviceModel:{...this.speculosDevice.deviceModel,productName:`Speculos - ${c} - ${a}`,getBlockSize(){return 32}},transport:this.identifier,id:"SpeculosID",type:"USB"};return this.connectedDevice=p,this._isE2E||this.listenForDisconnect(e.onDisconnect,e.deviceId),(0,i.Right)(p)}catch(p){return(0,i.Left)(new o.OpeningConnectionError(p))}}async disconnect(e){return this.logger.debug("disconnect"),this.connectedDevice=null,Promise.resolve((0,i.Right)(void 0))}async sendApdu(e,t,n,r){try{const c=(0,o.bufferToHexaString)(r).substring(2),a=await this._speculosDataSource.postApdu(c),d=this.createApduResponse(a);return(0,i.Right)(d)}catch(c){return this.connectedDevice&&(this.logger.debug("disconnecting"),n(t),this.disconnect({connectedDevice:this.connectedDevice}),this.disconnectInterval&&clearInterval(this.disconnectInterval)),(0,i.Left)(new o.GeneralDmkError(c))}}createApduResponse(e){return{statusCode:this.fromHexString(e.substring(e.length-4,e.length)),data:this.fromHexString(e.substring(0,e.length-4))}}fromHexString(e){return e?new Uint8Array(e.match(/.{1,2}/g).map(t=>parseInt(t,16))):Uint8Array.from([])}listenForDisconnect(e,t){this.disconnectInterval=setInterval(async()=>{await this._speculosDataSource.isServerAvailable()||(this.logger.info(`Speculos server unavailable, disconnecting device ${t}`),e(t),this.connectedDevice&&await this.disconnect({connectedDevice:this.connectedDevice}),this.disconnectInterval&&clearInterval(this.disconnectInterval))},2e3)}}const T=(s="http://127.0.0.1:5000",e=!1)=>({config:t,loggerServiceFactory:n})=>new D(n,t,s,e);0&&(module.exports={SpeculosTransport,speculosIdentifier,speculosTransportFactory});
|
|
2
2
|
//# sourceMappingURL=SpeculosTransport.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/SpeculosTransport.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduParser,\n type ApduResponse,\n bufferToHexaString,\n type ConnectError,\n type DeviceId,\n DeviceModelId,\n type DisconnectHandler,\n type DmkConfig,\n type DmkError,\n GeneralDmkError,\n type LoggerPublisherService,\n OpeningConnectionError,\n type Transport,\n type TransportConnectedDevice,\n type TransportDiscoveredDevice,\n type TransportFactory,\n type TransportIdentifier,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, Left, Right } from \"purify-ts\";\nimport { from, type Observable } from \"rxjs\";\n\nimport { HttpSpeculosDatasource } from \"@internal/datasource/HttpSpeculosDatasource\";\nimport { type SpeculosDatasource } from \"@internal/datasource/SpeculosDatasource\";\n\nexport const speculosIdentifier: TransportIdentifier =\n \"SPECULOS_HTTP_TRANSPORT\";\n\nexport class SpeculosTransport implements Transport {\n private logger: LoggerPublisherService;\n private readonly identifier: TransportIdentifier = speculosIdentifier;\n private readonly _speculosDataSource: SpeculosDatasource;\n private connectedDevice: TransportConnectedDevice | null = null;\n private disconnectInterval: NodeJS.Timeout | null = null;\n private readonly _isE2E: boolean;\n private readonly speculosDevice: TransportDiscoveredDevice = {\n id: \"SpeculosID\", //TODO make it dynamic at creation\n deviceModel: {\n id: DeviceModelId.STAX,\n productName: \"Speculos - App Name - version\",\n usbProductId: 0x10,\n bootloaderUsbProductId: 0x0001,\n getBlockSize() {\n return 32;\n },\n
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,uBAAAC,EAAA,6BAAAC,IAAA,eAAAC,EAAAL,GAAA,IAAAM,EAkBO,2CACPC,EAAyC,qBACzCC,EAAsC,gBAEtCC,EAAuC,uDAGhC,MAAMN,EACX,0BAEK,MAAMD,CAAuC,CAC1C,OACS,WAAkCC,EAClC,oBACT,gBAAmD,KACnD,mBAA4C,KACnC,OACA,eAA4C,CAC3D,GAAI,aACJ,YAAa,CACX,GAAI,gBAAc,KAClB,YAAa,gCACb,aAAc,GACd,uBAAwB,EACxB,cAAe,CACb,MAAO,GACT,EACA,
|
|
4
|
+
"sourcesContent": ["import {\n ApduParser,\n type ApduResponse,\n bufferToHexaString,\n type ConnectError,\n type DeviceId,\n DeviceModelId,\n type DisconnectHandler,\n type DmkConfig,\n type DmkError,\n GeneralDmkError,\n type LoggerPublisherService,\n OpeningConnectionError,\n type Transport,\n type TransportConnectedDevice,\n type TransportDiscoveredDevice,\n type TransportFactory,\n type TransportIdentifier,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, Left, Right } from \"purify-ts\";\nimport { from, type Observable } from \"rxjs\";\n\nimport { HttpSpeculosDatasource } from \"@internal/datasource/HttpSpeculosDatasource\";\nimport { type SpeculosDatasource } from \"@internal/datasource/SpeculosDatasource\";\n\nexport const speculosIdentifier: TransportIdentifier =\n \"SPECULOS_HTTP_TRANSPORT\";\n\nexport class SpeculosTransport implements Transport {\n private logger: LoggerPublisherService;\n private readonly identifier: TransportIdentifier = speculosIdentifier;\n private readonly _speculosDataSource: SpeculosDatasource;\n private connectedDevice: TransportConnectedDevice | null = null;\n private disconnectInterval: NodeJS.Timeout | null = null;\n private readonly _isE2E: boolean;\n private readonly speculosDevice: TransportDiscoveredDevice = {\n id: \"SpeculosID\", //TODO make it dynamic at creation\n deviceModel: {\n id: DeviceModelId.STAX,\n productName: \"Speculos - App Name - version\",\n usbProductId: 0x10,\n bootloaderUsbProductId: 0x0001,\n getBlockSize() {\n return 32;\n },\n usbOnly: true,\n memorySize: 320 * 1024,\n masks: [0x31100000],\n },\n transport: this.identifier,\n };\n\n constructor(\n loggerServiceFactory: (tag: string) => LoggerPublisherService,\n _config: DmkConfig,\n speculosUrl: string,\n isE2E?: boolean,\n ) {\n this._isE2E = isE2E ?? false;\n this.logger = loggerServiceFactory(\"SpeculosTransport\");\n this._speculosDataSource = new HttpSpeculosDatasource(speculosUrl); // See how to pass properly speculos config.\n }\n\n isSupported(): boolean {\n return true;\n }\n\n getIdentifier(): TransportIdentifier {\n return this.identifier;\n }\n\n listenToAvailableDevices(): Observable<TransportDiscoveredDevice[]> {\n return from([[this.speculosDevice]]);\n }\n\n startDiscovering(): Observable<TransportDiscoveredDevice> {\n this.logger.debug(\"startDiscovering\");\n return from([this.speculosDevice]);\n }\n\n stopDiscovering(): void {\n //DO NOTHING HERE\n this.logger.debug(\"stopDiscovering\");\n }\n\n async connect(params: {\n deviceId: DeviceId;\n onDisconnect: DisconnectHandler;\n }): Promise<Either<ConnectError, TransportConnectedDevice>> {\n this.logger.debug(\"connect\");\n\n const hexResponse = await this._speculosDataSource.postApdu(\"B0010000\");\n this.logger.debug(`Hex Response: ${hexResponse}`);\n const apduResponse = this.createApduResponse(hexResponse);\n const parser = new ApduParser(apduResponse);\n\n //Copy paste from GetAppAndVersionCommand\n parser.extract8BitUInt(); //Need otherwise parser is not in the right position\n const appName = parser.encodeToString(parser.extractFieldLVEncoded());\n const appVersion = parser.encodeToString(parser.extractFieldLVEncoded());\n\n this.logger.debug(`App Name: ${appName} and version ${appVersion}`);\n\n const sessionId: string = params.deviceId;\n try {\n const connectedDevice: TransportConnectedDevice = {\n sendApdu: (apdu) => {\n return this.sendApdu(\n sessionId,\n params.deviceId,\n params.onDisconnect,\n apdu,\n );\n },\n deviceModel: {\n ...this.speculosDevice.deviceModel,\n productName: `Speculos - ${appName} - ${appVersion}`,\n getBlockSize() {\n return 32;\n },\n },\n transport: this.identifier,\n id: \"SpeculosID\", //TODO make it dynamic at creation\n type: \"USB\",\n };\n\n this.connectedDevice = connectedDevice;\n if (!this._isE2E) {\n this.listenForDisconnect(params.onDisconnect, params.deviceId);\n }\n return Right(connectedDevice);\n } catch (error) {\n return Left(new OpeningConnectionError(error as Error));\n }\n }\n\n async disconnect(_params: {\n connectedDevice: TransportConnectedDevice;\n }): Promise<Either<DmkError, void>> {\n this.logger.debug(\"disconnect\");\n this.connectedDevice = null;\n return Promise.resolve(Right(undefined));\n }\n\n async sendApdu(\n _sessionId: string,\n deviceId: DeviceId,\n onDisconnect: DisconnectHandler,\n apdu: Uint8Array,\n ): Promise<Either<DmkError, ApduResponse>> {\n try {\n const hexApdu = bufferToHexaString(apdu).substring(2);\n const hexResponse: string =\n await this._speculosDataSource.postApdu(hexApdu);\n const apduResponse = this.createApduResponse(hexResponse);\n return Right(apduResponse);\n } catch (error) {\n if (this.connectedDevice) {\n this.logger.debug(\"disconnecting\");\n onDisconnect(deviceId);\n this.disconnect({\n connectedDevice: this.connectedDevice,\n });\n\n if (this.disconnectInterval) {\n clearInterval(this.disconnectInterval);\n }\n }\n return Left(new GeneralDmkError(error));\n }\n }\n\n private createApduResponse(hexApdu: string): ApduResponse {\n const apduResponse = {\n statusCode: this.fromHexString(\n hexApdu.substring(hexApdu.length - 4, hexApdu.length),\n ),\n data: this.fromHexString(hexApdu.substring(0, hexApdu.length - 4)),\n };\n return apduResponse;\n }\n\n //TODO: Move this to a helper\n private fromHexString(hexString: string): Uint8Array {\n if (!hexString) {\n return Uint8Array.from([]);\n }\n return new Uint8Array(\n hexString.match(/.{1,2}/g)!.map((byte) => parseInt(byte, 16)),\n );\n }\n\n private listenForDisconnect(\n onDisconnect: DisconnectHandler,\n deviceId: DeviceId,\n ): void {\n this.disconnectInterval = setInterval(async () => {\n const isServerAvailable =\n await this._speculosDataSource.isServerAvailable();\n\n if (!isServerAvailable) {\n this.logger.info(\n `Speculos server unavailable, disconnecting device ${deviceId}`,\n );\n onDisconnect(deviceId);\n\n if (this.connectedDevice) {\n await this.disconnect({\n connectedDevice: this.connectedDevice,\n });\n }\n\n if (this.disconnectInterval) {\n clearInterval(this.disconnectInterval);\n }\n }\n }, 2000);\n }\n}\n\nexport const speculosTransportFactory: (\n speculosUrl?: string,\n isE2E?: boolean,\n) => TransportFactory =\n (speculosUrl = \"http://127.0.0.1:5000\", isE2E = false) =>\n ({ config, loggerServiceFactory }) =>\n new SpeculosTransport(loggerServiceFactory, config, speculosUrl, isE2E);\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,uBAAAC,EAAA,6BAAAC,IAAA,eAAAC,EAAAL,GAAA,IAAAM,EAkBO,2CACPC,EAAyC,qBACzCC,EAAsC,gBAEtCC,EAAuC,uDAGhC,MAAMN,EACX,0BAEK,MAAMD,CAAuC,CAC1C,OACS,WAAkCC,EAClC,oBACT,gBAAmD,KACnD,mBAA4C,KACnC,OACA,eAA4C,CAC3D,GAAI,aACJ,YAAa,CACX,GAAI,gBAAc,KAClB,YAAa,gCACb,aAAc,GACd,uBAAwB,EACxB,cAAe,CACb,MAAO,GACT,EACA,QAAS,GACT,WAAY,IAAM,KAClB,MAAO,CAAC,SAAU,CACpB,EACA,UAAW,KAAK,UAClB,EAEA,YACEO,EACAC,EACAC,EACAC,EACA,CACA,KAAK,OAASA,GAAS,GACvB,KAAK,OAASH,EAAqB,mBAAmB,EACtD,KAAK,oBAAsB,IAAI,yBAAuBE,CAAW,CACnE,CAEA,aAAuB,CACrB,MAAO,EACT,CAEA,eAAqC,CACnC,OAAO,KAAK,UACd,CAEA,0BAAoE,CAClE,SAAO,QAAK,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,CACrC,CAEA,kBAA0D,CACxD,YAAK,OAAO,MAAM,kBAAkB,KAC7B,QAAK,CAAC,KAAK,cAAc,CAAC,CACnC,CAEA,iBAAwB,CAEtB,KAAK,OAAO,MAAM,iBAAiB,CACrC,CAEA,MAAM,QAAQE,EAG8C,CAC1D,KAAK,OAAO,MAAM,SAAS,EAE3B,MAAMC,EAAc,MAAM,KAAK,oBAAoB,SAAS,UAAU,EACtE,KAAK,OAAO,MAAM,iBAAiBA,CAAW,EAAE,EAChD,MAAMC,EAAe,KAAK,mBAAmBD,CAAW,EAClDE,EAAS,IAAI,aAAWD,CAAY,EAG1CC,EAAO,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,WAAY,KAAK,cACfA,EAAQ,UAAUA,EAAQ,OAAS,EAAGA,EAAQ,MAAM,CACtD,EACA,KAAM,KAAK,cAAcA,EAAQ,UAAU,EAAGA,EAAQ,OAAS,CAAC,CAAC,CACnE,CAEF,CAGQ,cAAcC,EAA+B,CACnD,OAAKA,EAGE,IAAI,WACTA,EAAU,MAAM,SAAS,EAAG,IAAKC,GAAS,SAASA,EAAM,EAAE,CAAC,CAC9D,EAJS,WAAW,KAAK,CAAC,CAAC,CAK7B,CAEQ,oBACNH,EACAD,EACM,CACN,KAAK,mBAAqB,YAAY,SAAY,CAE9C,MAAM,KAAK,oBAAoB,kBAAkB,IAGjD,KAAK,OAAO,KACV,qDAAqDA,CAAQ,EAC/D,EACAC,EAAaD,CAAQ,EAEjB,KAAK,iBACP,MAAM,KAAK,WAAW,CACpB,gBAAiB,KAAK,eACxB,CAAC,EAGC,KAAK,oBACP,cAAc,KAAK,kBAAkB,EAG3C,EAAG,GAAI,CACT,CACF,CAEO,MAAMtB,EAIX,CAACQ,EAAc,wBAAyBC,EAAQ,KAChD,CAAC,CAAE,OAAAkB,EAAQ,qBAAArB,CAAqB,IAC9B,IAAIR,EAAkBQ,EAAsBqB,EAAQnB,EAAaC,CAAK",
|
|
6
6
|
"names": ["SpeculosTransport_exports", "__export", "SpeculosTransport", "speculosIdentifier", "speculosTransportFactory", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_rxjs", "import_HttpSpeculosDatasource", "loggerServiceFactory", "_config", "speculosUrl", "isE2E", "params", "hexResponse", "apduResponse", "parser", "appName", "appVersion", "sessionId", "connectedDevice", "apdu", "error", "_params", "_sessionId", "deviceId", "onDisconnect", "hexApdu", "hexString", "byte", "config"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -1,56 +1,60 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@sentry/minimal": "catalog:",
|
|
4
|
+
"axios": "catalog:",
|
|
5
|
+
"purify-ts": "catalog:"
|
|
6
|
+
},
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"@ledgerhq/device-management-kit": "workspace:^",
|
|
9
|
+
"@ledgerhq/eslint-config-dsdk": "workspace:^",
|
|
10
|
+
"@ledgerhq/ldmk-tool": "workspace:^",
|
|
11
|
+
"@ledgerhq/prettier-config-dsdk": "workspace:^",
|
|
12
|
+
"@ledgerhq/tsconfig-dsdk": "workspace:^",
|
|
13
|
+
"@ledgerhq/vitest-config-dmk": "workspace:^",
|
|
14
|
+
"rxjs": "catalog:",
|
|
15
|
+
"ts-node": "catalog:"
|
|
16
|
+
},
|
|
6
17
|
"exports": {
|
|
7
18
|
".": {
|
|
8
|
-
"types": "./lib/types/index.d.ts",
|
|
9
19
|
"import": "./lib/esm/index.js",
|
|
10
|
-
"require": "./lib/cjs/index.js"
|
|
20
|
+
"require": "./lib/cjs/index.js",
|
|
21
|
+
"types": "./lib/types/index.d.ts"
|
|
11
22
|
},
|
|
12
23
|
"./*": {
|
|
13
|
-
"types": "./lib/types/*",
|
|
14
24
|
"import": "./lib/esm/*",
|
|
15
|
-
"require": "./lib/cjs/*"
|
|
25
|
+
"require": "./lib/cjs/*",
|
|
26
|
+
"types": "./lib/types/*"
|
|
16
27
|
}
|
|
17
28
|
},
|
|
18
29
|
"files": [
|
|
19
30
|
"./lib"
|
|
20
31
|
],
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"name": "@ledgerhq/device-transport-kit-speculos",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@ledgerhq/device-management-kit": "workspace:^",
|
|
36
|
+
"rxjs": "catalog:"
|
|
37
|
+
},
|
|
38
|
+
"private": false,
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/LedgerHQ/device-sdk-ts.git"
|
|
42
|
+
},
|
|
21
43
|
"scripts": {
|
|
22
|
-
"prebuild": "rimraf lib",
|
|
23
44
|
"build": "pnpm ldmk-tool build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
24
45
|
"dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
|
|
25
|
-
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
26
|
-
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"",
|
|
27
46
|
"lint": "eslint",
|
|
28
47
|
"lint:fix": "pnpm lint --fix",
|
|
29
48
|
"postpack": "find . -name '*.tgz' -exec cp {} ../../../dist/ \\; ",
|
|
49
|
+
"prebuild": "rimraf lib",
|
|
30
50
|
"prettier": "prettier . --check",
|
|
31
51
|
"prettier:fix": "prettier . --write",
|
|
32
|
-
"typecheck": "tsc --noEmit",
|
|
33
52
|
"test": "vitest run --passWithNoTests",
|
|
53
|
+
"test:coverage": "vitest run --coverage --passWithNoTests",
|
|
34
54
|
"test:watch": "vitest --passWithNoTests",
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"@sentry/minimal": "catalog:",
|
|
39
|
-
"purify-ts": "catalog:",
|
|
40
|
-
"axios": "catalog:"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@ledgerhq/device-management-kit": "workspace:*",
|
|
44
|
-
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
45
|
-
"@ledgerhq/ldmk-tool": "workspace:*",
|
|
46
|
-
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
47
|
-
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
48
|
-
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
49
|
-
"rxjs": "catalog:",
|
|
50
|
-
"ts-node": "catalog:"
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
57
|
+
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
51
58
|
},
|
|
52
|
-
"
|
|
53
|
-
"@ledgerhq/device-management-kit": "workspace:*",
|
|
54
|
-
"rxjs": "catalog:"
|
|
55
|
-
}
|
|
59
|
+
"version": "1.1.2"
|
|
56
60
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduParser as v,bufferToHexaString as g,DeviceModelId as D,GeneralDmkError as h,OpeningConnectionError as f}from"@ledgerhq/device-management-kit";import{Left as d,Right as a}from"purify-ts";import{from as l}from"rxjs";import{HttpSpeculosDatasource as S}from"../internal/datasource/HttpSpeculosDatasource";const m="SPECULOS_HTTP_TRANSPORT";class y{logger;identifier=m;_speculosDataSource;connectedDevice=null;disconnectInterval=null;_isE2E;speculosDevice={id:"SpeculosID",deviceModel:{id:D.STAX,productName:"Speculos - App Name - version",usbProductId:16,bootloaderUsbProductId:1,getBlockSize(){return 32},
|
|
1
|
+
import{ApduParser as v,bufferToHexaString as g,DeviceModelId as D,GeneralDmkError as h,OpeningConnectionError as f}from"@ledgerhq/device-management-kit";import{Left as d,Right as a}from"purify-ts";import{from as l}from"rxjs";import{HttpSpeculosDatasource as S}from"../internal/datasource/HttpSpeculosDatasource";const m="SPECULOS_HTTP_TRANSPORT";class y{logger;identifier=m;_speculosDataSource;connectedDevice=null;disconnectInterval=null;_isE2E;speculosDevice={id:"SpeculosID",deviceModel:{id:D.STAX,productName:"Speculos - App Name - version",usbProductId:16,bootloaderUsbProductId:1,getBlockSize(){return 32},usbOnly:!0,memorySize:320*1024,masks:[823132160]},transport:this.identifier};constructor(e,t,n,r){this._isE2E=r??!1,this.logger=e("SpeculosTransport"),this._speculosDataSource=new S(n)}isSupported(){return!0}getIdentifier(){return this.identifier}listenToAvailableDevices(){return l([[this.speculosDevice]])}startDiscovering(){return this.logger.debug("startDiscovering"),l([this.speculosDevice])}stopDiscovering(){this.logger.debug("stopDiscovering")}async connect(e){this.logger.debug("connect");const t=await this._speculosDataSource.postApdu("B0010000");this.logger.debug(`Hex Response: ${t}`);const n=this.createApduResponse(t),r=new v(n);r.extract8BitUInt();const s=r.encodeToString(r.extractFieldLVEncoded()),o=r.encodeToString(r.extractFieldLVEncoded());this.logger.debug(`App Name: ${s} and version ${o}`);const c=e.deviceId;try{const i={sendApdu:u=>this.sendApdu(c,e.deviceId,e.onDisconnect,u),deviceModel:{...this.speculosDevice.deviceModel,productName:`Speculos - ${s} - ${o}`,getBlockSize(){return 32}},transport:this.identifier,id:"SpeculosID",type:"USB"};return this.connectedDevice=i,this._isE2E||this.listenForDisconnect(e.onDisconnect,e.deviceId),a(i)}catch(i){return d(new f(i))}}async disconnect(e){return this.logger.debug("disconnect"),this.connectedDevice=null,Promise.resolve(a(void 0))}async sendApdu(e,t,n,r){try{const s=g(r).substring(2),o=await this._speculosDataSource.postApdu(s),c=this.createApduResponse(o);return a(c)}catch(s){return this.connectedDevice&&(this.logger.debug("disconnecting"),n(t),this.disconnect({connectedDevice:this.connectedDevice}),this.disconnectInterval&&clearInterval(this.disconnectInterval)),d(new h(s))}}createApduResponse(e){return{statusCode:this.fromHexString(e.substring(e.length-4,e.length)),data:this.fromHexString(e.substring(0,e.length-4))}}fromHexString(e){return e?new Uint8Array(e.match(/.{1,2}/g).map(t=>parseInt(t,16))):Uint8Array.from([])}listenForDisconnect(e,t){this.disconnectInterval=setInterval(async()=>{await this._speculosDataSource.isServerAvailable()||(this.logger.info(`Speculos server unavailable, disconnecting device ${t}`),e(t),this.connectedDevice&&await this.disconnect({connectedDevice:this.connectedDevice}),this.disconnectInterval&&clearInterval(this.disconnectInterval))},2e3)}}const A=(p="http://127.0.0.1:5000",e=!1)=>({config:t,loggerServiceFactory:n})=>new y(n,t,p,e);export{y as SpeculosTransport,m as speculosIdentifier,A as speculosTransportFactory};
|
|
2
2
|
//# sourceMappingURL=SpeculosTransport.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/SpeculosTransport.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduParser,\n type ApduResponse,\n bufferToHexaString,\n type ConnectError,\n type DeviceId,\n DeviceModelId,\n type DisconnectHandler,\n type DmkConfig,\n type DmkError,\n GeneralDmkError,\n type LoggerPublisherService,\n OpeningConnectionError,\n type Transport,\n type TransportConnectedDevice,\n type TransportDiscoveredDevice,\n type TransportFactory,\n type TransportIdentifier,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, Left, Right } from \"purify-ts\";\nimport { from, type Observable } from \"rxjs\";\n\nimport { HttpSpeculosDatasource } from \"@internal/datasource/HttpSpeculosDatasource\";\nimport { type SpeculosDatasource } from \"@internal/datasource/SpeculosDatasource\";\n\nexport const speculosIdentifier: TransportIdentifier =\n \"SPECULOS_HTTP_TRANSPORT\";\n\nexport class SpeculosTransport implements Transport {\n private logger: LoggerPublisherService;\n private readonly identifier: TransportIdentifier = speculosIdentifier;\n private readonly _speculosDataSource: SpeculosDatasource;\n private connectedDevice: TransportConnectedDevice | null = null;\n private disconnectInterval: NodeJS.Timeout | null = null;\n private readonly _isE2E: boolean;\n private readonly speculosDevice: TransportDiscoveredDevice = {\n id: \"SpeculosID\", //TODO make it dynamic at creation\n deviceModel: {\n id: DeviceModelId.STAX,\n productName: \"Speculos - App Name - version\",\n usbProductId: 0x10,\n bootloaderUsbProductId: 0x0001,\n getBlockSize() {\n return 32;\n },\n
|
|
5
|
-
"mappings": "AAAA,OACE,cAAAA,EAEA,sBAAAC,EAGA,iBAAAC,EAIA,mBAAAC,EAEA,0BAAAC,MAMK,kCACP,OAAsB,QAAAC,EAAM,SAAAC,MAAa,YACzC,OAAS,QAAAC,MAA6B,OAEtC,OAAS,0BAAAC,MAA8B,8CAGhC,MAAMC,EACX,0BAEK,MAAMC,CAAuC,CAC1C,OACS,WAAkCD,EAClC,oBACT,gBAAmD,KACnD,mBAA4C,KACnC,OACA,eAA4C,CAC3D,GAAI,aACJ,YAAa,CACX,GAAIP,EAAc,KAClB,YAAa,gCACb,aAAc,GACd,uBAAwB,EACxB,cAAe,CACb,MAAO,GACT,EACA,
|
|
4
|
+
"sourcesContent": ["import {\n ApduParser,\n type ApduResponse,\n bufferToHexaString,\n type ConnectError,\n type DeviceId,\n DeviceModelId,\n type DisconnectHandler,\n type DmkConfig,\n type DmkError,\n GeneralDmkError,\n type LoggerPublisherService,\n OpeningConnectionError,\n type Transport,\n type TransportConnectedDevice,\n type TransportDiscoveredDevice,\n type TransportFactory,\n type TransportIdentifier,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, Left, Right } from \"purify-ts\";\nimport { from, type Observable } from \"rxjs\";\n\nimport { HttpSpeculosDatasource } from \"@internal/datasource/HttpSpeculosDatasource\";\nimport { type SpeculosDatasource } from \"@internal/datasource/SpeculosDatasource\";\n\nexport const speculosIdentifier: TransportIdentifier =\n \"SPECULOS_HTTP_TRANSPORT\";\n\nexport class SpeculosTransport implements Transport {\n private logger: LoggerPublisherService;\n private readonly identifier: TransportIdentifier = speculosIdentifier;\n private readonly _speculosDataSource: SpeculosDatasource;\n private connectedDevice: TransportConnectedDevice | null = null;\n private disconnectInterval: NodeJS.Timeout | null = null;\n private readonly _isE2E: boolean;\n private readonly speculosDevice: TransportDiscoveredDevice = {\n id: \"SpeculosID\", //TODO make it dynamic at creation\n deviceModel: {\n id: DeviceModelId.STAX,\n productName: \"Speculos - App Name - version\",\n usbProductId: 0x10,\n bootloaderUsbProductId: 0x0001,\n getBlockSize() {\n return 32;\n },\n usbOnly: true,\n memorySize: 320 * 1024,\n masks: [0x31100000],\n },\n transport: this.identifier,\n };\n\n constructor(\n loggerServiceFactory: (tag: string) => LoggerPublisherService,\n _config: DmkConfig,\n speculosUrl: string,\n isE2E?: boolean,\n ) {\n this._isE2E = isE2E ?? false;\n this.logger = loggerServiceFactory(\"SpeculosTransport\");\n this._speculosDataSource = new HttpSpeculosDatasource(speculosUrl); // See how to pass properly speculos config.\n }\n\n isSupported(): boolean {\n return true;\n }\n\n getIdentifier(): TransportIdentifier {\n return this.identifier;\n }\n\n listenToAvailableDevices(): Observable<TransportDiscoveredDevice[]> {\n return from([[this.speculosDevice]]);\n }\n\n startDiscovering(): Observable<TransportDiscoveredDevice> {\n this.logger.debug(\"startDiscovering\");\n return from([this.speculosDevice]);\n }\n\n stopDiscovering(): void {\n //DO NOTHING HERE\n this.logger.debug(\"stopDiscovering\");\n }\n\n async connect(params: {\n deviceId: DeviceId;\n onDisconnect: DisconnectHandler;\n }): Promise<Either<ConnectError, TransportConnectedDevice>> {\n this.logger.debug(\"connect\");\n\n const hexResponse = await this._speculosDataSource.postApdu(\"B0010000\");\n this.logger.debug(`Hex Response: ${hexResponse}`);\n const apduResponse = this.createApduResponse(hexResponse);\n const parser = new ApduParser(apduResponse);\n\n //Copy paste from GetAppAndVersionCommand\n parser.extract8BitUInt(); //Need otherwise parser is not in the right position\n const appName = parser.encodeToString(parser.extractFieldLVEncoded());\n const appVersion = parser.encodeToString(parser.extractFieldLVEncoded());\n\n this.logger.debug(`App Name: ${appName} and version ${appVersion}`);\n\n const sessionId: string = params.deviceId;\n try {\n const connectedDevice: TransportConnectedDevice = {\n sendApdu: (apdu) => {\n return this.sendApdu(\n sessionId,\n params.deviceId,\n params.onDisconnect,\n apdu,\n );\n },\n deviceModel: {\n ...this.speculosDevice.deviceModel,\n productName: `Speculos - ${appName} - ${appVersion}`,\n getBlockSize() {\n return 32;\n },\n },\n transport: this.identifier,\n id: \"SpeculosID\", //TODO make it dynamic at creation\n type: \"USB\",\n };\n\n this.connectedDevice = connectedDevice;\n if (!this._isE2E) {\n this.listenForDisconnect(params.onDisconnect, params.deviceId);\n }\n return Right(connectedDevice);\n } catch (error) {\n return Left(new OpeningConnectionError(error as Error));\n }\n }\n\n async disconnect(_params: {\n connectedDevice: TransportConnectedDevice;\n }): Promise<Either<DmkError, void>> {\n this.logger.debug(\"disconnect\");\n this.connectedDevice = null;\n return Promise.resolve(Right(undefined));\n }\n\n async sendApdu(\n _sessionId: string,\n deviceId: DeviceId,\n onDisconnect: DisconnectHandler,\n apdu: Uint8Array,\n ): Promise<Either<DmkError, ApduResponse>> {\n try {\n const hexApdu = bufferToHexaString(apdu).substring(2);\n const hexResponse: string =\n await this._speculosDataSource.postApdu(hexApdu);\n const apduResponse = this.createApduResponse(hexResponse);\n return Right(apduResponse);\n } catch (error) {\n if (this.connectedDevice) {\n this.logger.debug(\"disconnecting\");\n onDisconnect(deviceId);\n this.disconnect({\n connectedDevice: this.connectedDevice,\n });\n\n if (this.disconnectInterval) {\n clearInterval(this.disconnectInterval);\n }\n }\n return Left(new GeneralDmkError(error));\n }\n }\n\n private createApduResponse(hexApdu: string): ApduResponse {\n const apduResponse = {\n statusCode: this.fromHexString(\n hexApdu.substring(hexApdu.length - 4, hexApdu.length),\n ),\n data: this.fromHexString(hexApdu.substring(0, hexApdu.length - 4)),\n };\n return apduResponse;\n }\n\n //TODO: Move this to a helper\n private fromHexString(hexString: string): Uint8Array {\n if (!hexString) {\n return Uint8Array.from([]);\n }\n return new Uint8Array(\n hexString.match(/.{1,2}/g)!.map((byte) => parseInt(byte, 16)),\n );\n }\n\n private listenForDisconnect(\n onDisconnect: DisconnectHandler,\n deviceId: DeviceId,\n ): void {\n this.disconnectInterval = setInterval(async () => {\n const isServerAvailable =\n await this._speculosDataSource.isServerAvailable();\n\n if (!isServerAvailable) {\n this.logger.info(\n `Speculos server unavailable, disconnecting device ${deviceId}`,\n );\n onDisconnect(deviceId);\n\n if (this.connectedDevice) {\n await this.disconnect({\n connectedDevice: this.connectedDevice,\n });\n }\n\n if (this.disconnectInterval) {\n clearInterval(this.disconnectInterval);\n }\n }\n }, 2000);\n }\n}\n\nexport const speculosTransportFactory: (\n speculosUrl?: string,\n isE2E?: boolean,\n) => TransportFactory =\n (speculosUrl = \"http://127.0.0.1:5000\", isE2E = false) =>\n ({ config, loggerServiceFactory }) =>\n new SpeculosTransport(loggerServiceFactory, config, speculosUrl, isE2E);\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,cAAAA,EAEA,sBAAAC,EAGA,iBAAAC,EAIA,mBAAAC,EAEA,0BAAAC,MAMK,kCACP,OAAsB,QAAAC,EAAM,SAAAC,MAAa,YACzC,OAAS,QAAAC,MAA6B,OAEtC,OAAS,0BAAAC,MAA8B,8CAGhC,MAAMC,EACX,0BAEK,MAAMC,CAAuC,CAC1C,OACS,WAAkCD,EAClC,oBACT,gBAAmD,KACnD,mBAA4C,KACnC,OACA,eAA4C,CAC3D,GAAI,aACJ,YAAa,CACX,GAAIP,EAAc,KAClB,YAAa,gCACb,aAAc,GACd,uBAAwB,EACxB,cAAe,CACb,MAAO,GACT,EACA,QAAS,GACT,WAAY,IAAM,KAClB,MAAO,CAAC,SAAU,CACpB,EACA,UAAW,KAAK,UAClB,EAEA,YACES,EACAC,EACAC,EACAC,EACA,CACA,KAAK,OAASA,GAAS,GACvB,KAAK,OAASH,EAAqB,mBAAmB,EACtD,KAAK,oBAAsB,IAAIH,EAAuBK,CAAW,CACnE,CAEA,aAAuB,CACrB,MAAO,EACT,CAEA,eAAqC,CACnC,OAAO,KAAK,UACd,CAEA,0BAAoE,CAClE,OAAON,EAAK,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,CACrC,CAEA,kBAA0D,CACxD,YAAK,OAAO,MAAM,kBAAkB,EAC7BA,EAAK,CAAC,KAAK,cAAc,CAAC,CACnC,CAEA,iBAAwB,CAEtB,KAAK,OAAO,MAAM,iBAAiB,CACrC,CAEA,MAAM,QAAQQ,EAG8C,CAC1D,KAAK,OAAO,MAAM,SAAS,EAE3B,MAAMC,EAAc,MAAM,KAAK,oBAAoB,SAAS,UAAU,EACtE,KAAK,OAAO,MAAM,iBAAiBA,CAAW,EAAE,EAChD,MAAMC,EAAe,KAAK,mBAAmBD,CAAW,EAClDE,EAAS,IAAIlB,EAAWiB,CAAY,EA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,EAA+B,CAOxD,MANqB,CACnB,WAAY,KAAK,cACfA,EAAQ,UAAUA,EAAQ,OAAS,EAAGA,EAAQ,MAAM,CACtD,EACA,KAAM,KAAK,cAAcA,EAAQ,UAAU,EAAGA,EAAQ,OAAS,CAAC,CAAC,CACnE,CAEF,CAGQ,cAAcC,EAA+B,CACnD,OAAKA,EAGE,IAAI,WACTA,EAAU,MAAM,SAAS,EAAG,IAAKC,GAAS,SAASA,EAAM,EAAE,CAAC,CAC9D,EAJS,WAAW,KAAK,CAAC,CAAC,CAK7B,CAEQ,oBACNH,EACAD,EACM,CACN,KAAK,mBAAqB,YAAY,SAAY,CAE9C,MAAM,KAAK,oBAAoB,kBAAkB,IAGjD,KAAK,OAAO,KACV,qDAAqDA,CAAQ,EAC/D,EACAC,EAAaD,CAAQ,EAEjB,KAAK,iBACP,MAAM,KAAK,WAAW,CACpB,gBAAiB,KAAK,eACxB,CAAC,EAGC,KAAK,oBACP,cAAc,KAAK,kBAAkB,EAG3C,EAAG,GAAI,CACT,CACF,CAEO,MAAMK,EAIX,CAACnB,EAAc,wBAAyBC,EAAQ,KAChD,CAAC,CAAE,OAAAmB,EAAQ,qBAAAtB,CAAqB,IAC9B,IAAID,EAAkBC,EAAsBsB,EAAQpB,EAAaC,CAAK",
|
|
6
6
|
"names": ["ApduParser", "bufferToHexaString", "DeviceModelId", "GeneralDmkError", "OpeningConnectionError", "Left", "Right", "from", "HttpSpeculosDatasource", "speculosIdentifier", "SpeculosTransport", "loggerServiceFactory", "_config", "speculosUrl", "isE2E", "params", "hexResponse", "apduResponse", "parser", "appName", "appVersion", "sessionId", "connectedDevice", "apdu", "error", "_params", "_sessionId", "deviceId", "onDisconnect", "hexApdu", "hexString", "byte", "speculosTransportFactory", "config"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpeculosTransport.d.ts","sourceRoot":"","sources":["../../../../src/api/SpeculosTransport.ts"],"names":[],"mappings":"AAAA,OAAO,E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