@ledgerhq/device-transport-kit-react-native-hid 0.0.0-rn-ble-logs-20250416162013 → 0.0.0-rn-hid-sync-onboarding-behavior-20250516094633
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/android/src/main/kotlin/com/ledger/androidtransporthid/TransportHidModule.kt +11 -2
- package/android/src/main/kotlin/com/ledger/androidtransporthid/bridge/serialization.kt +2 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/DefaultAndroidUsbTransport.kt +59 -10
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMain/transport/usb/connection/AndroidUsbApduSender.kt +72 -32
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMainInternal/transport/deviceconnection/DeviceApduSender.kt +2 -1
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMainInternal/transport/deviceconnection/DeviceConnection.kt +5 -4
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/androidMainInternal/transport/deviceconnection/DeviceConnectionStateMachine.kt +3 -2
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/api/apdu/SendApduResult.kt +4 -0
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/connection/InternalConnectedDevice.kt +1 -1
- package/android/src/main/kotlin/com/ledger/devicesdk/shared/internal/transport/framer/FramerService.kt +1 -1
- package/lib/cjs/api/bridge/DefaultNativeModuleWrapper.js +1 -1
- package/lib/cjs/api/bridge/DefaultNativeModuleWrapper.js.map +3 -3
- package/lib/cjs/api/bridge/mapper.js +1 -1
- package/lib/cjs/api/bridge/mapper.js.map +2 -2
- package/lib/cjs/api/bridge/types.js +1 -1
- package/lib/cjs/api/bridge/types.js.map +1 -1
- package/lib/cjs/api/transport/NativeModuleWrapper.js +1 -1
- package/lib/cjs/api/transport/NativeModuleWrapper.js.map +1 -1
- package/lib/cjs/api/transport/RNHidTransport.js +1 -1
- package/lib/cjs/api/transport/RNHidTransport.js.map +3 -3
- package/lib/cjs/package.json +10 -10
- package/lib/esm/api/bridge/DefaultNativeModuleWrapper.js +1 -1
- package/lib/esm/api/bridge/DefaultNativeModuleWrapper.js.map +3 -3
- package/lib/esm/api/bridge/mapper.js +1 -1
- package/lib/esm/api/bridge/mapper.js.map +3 -3
- package/lib/esm/api/bridge/types.js.map +1 -1
- package/lib/esm/api/transport/RNHidTransport.js +1 -1
- package/lib/esm/api/transport/RNHidTransport.js.map +3 -3
- package/lib/esm/package.json +10 -10
- package/lib/types/api/bridge/DefaultNativeModuleWrapper.d.ts +1 -1
- package/lib/types/api/bridge/DefaultNativeModuleWrapper.d.ts.map +1 -1
- package/lib/types/api/bridge/mapper.d.ts.map +1 -1
- package/lib/types/api/bridge/types.d.ts +2 -2
- package/lib/types/api/bridge/types.d.ts.map +1 -1
- package/lib/types/api/transport/NativeModuleWrapper.d.ts +1 -1
- package/lib/types/api/transport/NativeModuleWrapper.d.ts.map +1 -1
- package/lib/types/api/transport/RNHidTransport.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +14 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/transport/RNHidTransport.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ConnectError,\n type DeviceId,\n DisconnectError,\n type DisconnectHandler,\n type DmkError,\n type LoggerPublisherService,\n LogLevel,\n OpeningConnectionError,\n type Transport,\n TransportConnectedDevice,\n type TransportDiscoveredDevice,\n type TransportIdentifier,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, Left, Right } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\n\nimport { getObservableOfArraysNewItems } from \"@api/helpers/getObservableOfArraysNewItems\";\nimport { TRANSPORT_IDENTIFIER } from \"@api/transport/rnHidTransportIdentifier\";\n\nimport { SendApduError } from \"./Errors\";\nimport { type NativeModuleWrapper } from \"./NativeModuleWrapper\";\n\nexport class RNHidTransport implements Transport {\n private _loggerService: LoggerPublisherService;\n\n constructor(\n private readonly _isSupported: boolean,\n private readonly _nativeModuleWrapper: NativeModuleWrapper,\n _loggerServiceFactory: (tag: string) => LoggerPublisherService,\n ) {\n this._loggerService = _loggerServiceFactory(\"RNHidTransport\");\n this._nativeModuleWrapper.subscribeToTransportLogs().subscribe((log) => {\n const [logLevel, message, options] = log;\n const logMethod = {\n [LogLevel.Fatal]: this._loggerService.error.bind(this._loggerService),\n [LogLevel.Error]: this._loggerService.error.bind(this._loggerService),\n [LogLevel.Warning]: this._loggerService.warn.bind(this._loggerService),\n [LogLevel.Info]: this._loggerService.info.bind(this._loggerService),\n [LogLevel.Debug]: this._loggerService.debug.bind(this._loggerService),\n }[logLevel];\n logMethod(message, options);\n });\n }\n\n getIdentifier(): TransportIdentifier {\n return TRANSPORT_IDENTIFIER;\n }\n\n isSupported(): boolean {\n return this._isSupported;\n }\n\n startDiscovering(): Observable<TransportDiscoveredDevice> {\n const observable = new Observable<TransportDiscoveredDevice>(\n (subscriber) => {\n const subscription = getObservableOfArraysNewItems(\n this._nativeModuleWrapper.subscribeToDiscoveredDevicesEvents(),\n (device) => device.id,\n ).subscribe(subscriber);\n\n this._nativeModuleWrapper.startScan().catch((error) => {\n subscriber.error(error);\n this._loggerService.error(\"startDiscovering error\", error);\n });\n return () => subscription.unsubscribe();\n },\n );\n return observable;\n }\n\n stopDiscovering(): void {\n this._nativeModuleWrapper.stopScan().catch((error) => {\n this._loggerService.error(\"stopDiscovering error\", error);\n });\n }\n\n listenToAvailableDevices(): Observable<TransportDiscoveredDevice[]> {\n /**\n * NB: here we need to define the unsubscribe logic as there is no\n * \"stopListeningToKnownDevices\" method.\n * That's why we create a new observable rather than returning the one\n * returned by subscribeToDiscoveredDevicesEvents.\n */\n const observable = new Observable<TransportDiscoveredDevice[]>(\n (subscriber) => {\n const subscription = this._nativeModuleWrapper\n .subscribeToDiscoveredDevicesEvents()\n .subscribe((devices) => {\n subscriber.next(devices);\n });\n this._nativeModuleWrapper.startScan().catch((error) => {\n this._loggerService.error(\"startDiscovering error\", error);\n subscriber.error(error);\n });\n return () => {\n subscription.unsubscribe();\n this._nativeModuleWrapper.stopScan().catch((error) => {\n this._loggerService.error(\"stopDiscovering error\", error);\n });\n };\n },\n );\n return observable;\n }\n\n connect(_params: {\n deviceId: DeviceId;\n onDisconnect: DisconnectHandler;\n }): Promise<Either<ConnectError, TransportConnectedDevice>> {\n return this._nativeModuleWrapper\n .connectDevice(_params.deviceId)\n .then((result) => {\n return result.map(\n ({ sessionId, transportDeviceModel: deviceModel }) => {\n const sub = this._nativeModuleWrapper\n .subscribeToDeviceDisconnectedEvents()\n .subscribe((device) => {\n if (device.sessionId === sessionId) {\n _params.onDisconnect(sessionId);\n sub.unsubscribe();\n }\n });\n\n return new TransportConnectedDevice({\n id: sessionId,\n deviceModel,\n sendApdu: async (apdu) => {\n return this._nativeModuleWrapper\n .sendApdu(sessionId
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAaO,2CACPC,EAAyC,qBACzCC,EAA2B,gBAE3BC,EAA8C,sDAC9CC,EAAqC,mDAErCC,EAA8B,oBAGvB,MAAMP,CAAoC,CAG/C,YACmBQ,EACAC,EACjBC,EACA,CAHiB,kBAAAF,EACA,0BAAAC,EAGjB,KAAK,eAAiBC,EAAsB,gBAAgB,EAC5D,KAAK,qBAAqB,yBAAyB,EAAE,UAAWC,GAAQ,CACtE,KAAM,CAACC,EAAUC,EAASC,CAAO,EAAIH,EAC/BI,EAAY,CAChB,CAAC,WAAS,KAAK,EAAG,KAAK,eAAe,MAAM,KAAK,KAAK,cAAc,EACpE,CAAC,WAAS,KAAK,EAAG,KAAK,eAAe,MAAM,KAAK,KAAK,cAAc,EACpE,CAAC,WAAS,OAAO,EAAG,KAAK,eAAe,KAAK,KAAK,KAAK,cAAc,EACrE,CAAC,WAAS,IAAI,E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AY,IAAM,CACpD,MAAMC,EAAM,KAAK,qBACd,oCAAoC,EACpC,UAAWP,GAAW,CACjBA,EAAO,YAAcK,IACvBF,EAAQ,aAAaE,CAAS,EAC9BE,EAAI,YAAY,EAEpB,CAAC,EAEH,OAAO,IAAI,2BAAyB,CAClC,GAAIF,EACJ,YAAAC,EACA,SAAU,
|
|
6
|
-
"names": ["RNHidTransport_exports", "__export", "RNHidTransport", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_rxjs", "import_getObservableOfArraysNewItems", "import_rnHidTransportIdentifier", "import_Errors", "_isSupported", "_nativeModuleWrapper", "_loggerServiceFactory", "log", "logLevel", "message", "options", "logMethod", "subscriber", "subscription", "device", "error", "devices", "_params", "result", "sessionId", "deviceModel", "sub", "apdu", "e"]
|
|
4
|
+
"sourcesContent": ["import {\n type ConnectError,\n type DeviceId,\n DisconnectError,\n type DisconnectHandler,\n type DmkError,\n type LoggerPublisherService,\n LogLevel,\n OpeningConnectionError,\n type Transport,\n TransportConnectedDevice,\n type TransportDiscoveredDevice,\n type TransportIdentifier,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, Left, Right } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\n\nimport { getObservableOfArraysNewItems } from \"@api/helpers/getObservableOfArraysNewItems\";\nimport { TRANSPORT_IDENTIFIER } from \"@api/transport/rnHidTransportIdentifier\";\n\nimport { SendApduError } from \"./Errors\";\nimport { type NativeModuleWrapper } from \"./NativeModuleWrapper\";\n\nexport class RNHidTransport implements Transport {\n private _loggerService: LoggerPublisherService;\n\n constructor(\n private readonly _isSupported: boolean,\n private readonly _nativeModuleWrapper: NativeModuleWrapper,\n _loggerServiceFactory: (tag: string) => LoggerPublisherService,\n ) {\n this._loggerService = _loggerServiceFactory(\"RNHidTransport\");\n this._nativeModuleWrapper.subscribeToTransportLogs().subscribe((log) => {\n const [logLevel, message, options] = log;\n const logMethod = {\n [LogLevel.Fatal]: this._loggerService.error.bind(this._loggerService),\n [LogLevel.Error]: this._loggerService.error.bind(this._loggerService),\n [LogLevel.Warning]: this._loggerService.warn.bind(this._loggerService),\n [LogLevel.Info]: this._loggerService.info.bind(this._loggerService),\n [LogLevel.Debug]: this._loggerService.debug.bind(this._loggerService),\n }[logLevel];\n logMethod(message, options);\n });\n }\n\n getIdentifier(): TransportIdentifier {\n return TRANSPORT_IDENTIFIER;\n }\n\n isSupported(): boolean {\n return this._isSupported;\n }\n\n startDiscovering(): Observable<TransportDiscoveredDevice> {\n const observable = new Observable<TransportDiscoveredDevice>(\n (subscriber) => {\n const subscription = getObservableOfArraysNewItems(\n this._nativeModuleWrapper.subscribeToDiscoveredDevicesEvents(),\n (device) => device.id,\n ).subscribe(subscriber);\n\n this._nativeModuleWrapper.startScan().catch((error) => {\n subscriber.error(error);\n this._loggerService.error(\"startDiscovering error\", error);\n });\n return () => subscription.unsubscribe();\n },\n );\n return observable;\n }\n\n stopDiscovering(): void {\n this._nativeModuleWrapper.stopScan().catch((error) => {\n this._loggerService.error(\"stopDiscovering error\", error);\n });\n }\n\n listenToAvailableDevices(): Observable<TransportDiscoveredDevice[]> {\n /**\n * NB: here we need to define the unsubscribe logic as there is no\n * \"stopListeningToKnownDevices\" method.\n * That's why we create a new observable rather than returning the one\n * returned by subscribeToDiscoveredDevicesEvents.\n */\n const observable = new Observable<TransportDiscoveredDevice[]>(\n (subscriber) => {\n const subscription = this._nativeModuleWrapper\n .subscribeToDiscoveredDevicesEvents()\n .subscribe((devices) => {\n subscriber.next(devices);\n });\n this._nativeModuleWrapper.startScan().catch((error) => {\n this._loggerService.error(\"startDiscovering error\", error);\n subscriber.error(error);\n });\n return () => {\n subscription.unsubscribe();\n this._nativeModuleWrapper.stopScan().catch((error) => {\n this._loggerService.error(\"stopDiscovering error\", error);\n });\n };\n },\n );\n return observable;\n }\n\n connect(_params: {\n deviceId: DeviceId;\n onDisconnect: DisconnectHandler;\n }): Promise<Either<ConnectError, TransportConnectedDevice>> {\n return this._nativeModuleWrapper\n .connectDevice(_params.deviceId)\n .then((result) => {\n return result.map(\n ({ sessionId, transportDeviceModel: deviceModel }) => {\n const sub = this._nativeModuleWrapper\n .subscribeToDeviceDisconnectedEvents()\n .subscribe((device) => {\n if (device.sessionId === sessionId) {\n _params.onDisconnect(sessionId);\n sub.unsubscribe();\n }\n });\n\n return new TransportConnectedDevice({\n id: sessionId,\n deviceModel,\n sendApdu: async (\n apdu,\n triggersDisconnection = false,\n abortTimeout = -1,\n ) => {\n return this._nativeModuleWrapper\n .sendApdu(\n sessionId,\n apdu,\n triggersDisconnection,\n abortTimeout,\n )\n .catch((e) => Left(new SendApduError(e)));\n },\n transport: this.getIdentifier(),\n type: \"USB\",\n });\n },\n );\n })\n .catch((error) => {\n return Left(new OpeningConnectionError(error));\n });\n }\n\n disconnect(_params: {\n connectedDevice: TransportConnectedDevice;\n }): Promise<Either<DmkError, void>> {\n return this._nativeModuleWrapper\n .disconnectDevice(_params.connectedDevice.id)\n .then(() => Right(undefined))\n .catch((error) => {\n return Left(new DisconnectError(error));\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAaO,2CACPC,EAAyC,qBACzCC,EAA2B,gBAE3BC,EAA8C,sDAC9CC,EAAqC,mDAErCC,EAA8B,oBAGvB,MAAMP,CAAoC,CAG/C,YACmBQ,EACAC,EACjBC,EACA,CAHiB,kBAAAF,EACA,0BAAAC,EAGjB,KAAK,eAAiBC,EAAsB,gBAAgB,EAC5D,KAAK,qBAAqB,yBAAyB,EAAE,UAAWC,GAAQ,CACtE,KAAM,CAACC,EAAUC,EAASC,CAAO,EAAIH,EAC/BI,EAAY,CAChB,CAAC,WAAS,KAAK,EAAG,KAAK,eAAe,MAAM,KAAK,KAAK,cAAc,EACpE,CAAC,WAAS,KAAK,EAAG,KAAK,eAAe,MAAM,KAAK,KAAK,cAAc,EACpE,CAAC,WAAS,OAAO,EAAG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KAAMC,GACEA,EAAO,IACZ,CAAC,CAAE,UAAAC,EAAW,qBAAsBC,CAAY,IAAM,CACpD,MAAMC,EAAM,KAAK,qBACd,oCAAoC,EACpC,UAAWP,GAAW,CACjBA,EAAO,YAAcK,IACvBF,EAAQ,aAAaE,CAAS,EAC9BE,EAAI,YAAY,EAEpB,CAAC,EAEH,OAAO,IAAI,2BAAyB,CAClC,GAAIF,EACJ,YAAAC,EACA,SAAU,MACRE,EACAC,EAAwB,GACxBC,EAAe,KAER,KAAK,qBACT,SACCL,EACAG,EACAC,EACAC,CACF,EACC,MAAOC,MAAM,QAAK,IAAI,gBAAcA,CAAC,CAAC,CAAC,EAE5C,UAAW,KAAK,cAAc,EAC9B,KAAM,KACR,CAAC,CACH,CACF,CACD,EACA,MAAOV,MACC,QAAK,IAAI,yBAAuBA,CAAK,CAAC,CAC9C,CACL,CAEA,WAAWE,EAEyB,CAClC,OAAO,KAAK,qBACT,iBAAiBA,EAAQ,gBAAgB,EAAE,EAC3C,KAAK,OAAM,SAAM,MAAS,CAAC,EAC3B,MAAOF,MACC,QAAK,IAAI,kBAAgBA,CAAK,CAAC,CACvC,CACL,CACF",
|
|
6
|
+
"names": ["RNHidTransport_exports", "__export", "RNHidTransport", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_rxjs", "import_getObservableOfArraysNewItems", "import_rnHidTransportIdentifier", "import_Errors", "_isSupported", "_nativeModuleWrapper", "_loggerServiceFactory", "log", "logLevel", "message", "options", "logMethod", "subscriber", "subscription", "device", "error", "devices", "_params", "result", "sessionId", "deviceModel", "sub", "apdu", "triggersDisconnection", "abortTimeout", "e"]
|
|
7
7
|
}
|
package/lib/cjs/package.json
CHANGED
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
30
|
"prebuild": "rimraf lib",
|
|
31
|
-
"build": "pnpm
|
|
31
|
+
"build": "pnpm ldmk-tool build --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
32
32
|
"dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
|
|
33
|
-
"watch:builds": "pnpm
|
|
33
|
+
"watch:builds": "pnpm ldmk-tool watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
34
34
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"",
|
|
35
35
|
"lint": "eslint",
|
|
36
36
|
"lint:fix": "pnpm lint --fix",
|
|
@@ -43,24 +43,24 @@
|
|
|
43
43
|
"test:coverage": "vitest run --coverage --passWithNoTests"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@sentry/minimal": "
|
|
47
|
-
"purify-ts": "
|
|
48
|
-
"uuid": "
|
|
46
|
+
"@sentry/minimal": "catalog:",
|
|
47
|
+
"purify-ts": "catalog:",
|
|
48
|
+
"uuid": "catalog:"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@ledgerhq/device-management-kit": "workspace:*",
|
|
52
|
-
"@ledgerhq/esbuild-tools": "workspace:*",
|
|
53
52
|
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
53
|
+
"@ledgerhq/ldmk-tool": "workspace:*",
|
|
54
54
|
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
55
55
|
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
56
56
|
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
57
|
-
"@types/uuid": "
|
|
58
|
-
"react-native": "
|
|
59
|
-
"rxjs": "
|
|
57
|
+
"@types/uuid": "catalog:",
|
|
58
|
+
"react-native": "catalog:",
|
|
59
|
+
"rxjs": "catalog:"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@ledgerhq/device-management-kit": "workspace:*",
|
|
63
63
|
"react-native": ">0.74.1",
|
|
64
|
-
"rxjs": "
|
|
64
|
+
"rxjs": "catalog:"
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{NativeEventEmitter as i}from"react-native";import{Observable as a}from"rxjs";import{uint8ArrayToBase64 as s}from"../helpers/base64Utils";import{mapNativeConnectionResultToConnectionResult as c,mapNativeDeviceConnectionLostToDeviceDisconnected as v,mapNativeDiscoveryDeviceToTransportDiscoveredDevice as d,mapNativeSendApduResultToSendApduResult as u,mapNativeTransportLogToLog as l}from"./mapper";import{DEVICE_DISCONNECTED_EVENT as p,DISCOVERED_DEVICES_EVENT as D,TRANSPORT_LOG_EVENT as m}from"./types";class _{_nativeModule;_deviceModelDataSource;constructor(e){this._nativeModule=e.nativeModule,this._deviceModelDataSource=e.deviceModelDataSource}startScan(){return this._nativeModule.startScan()}stopScan(){return this._nativeModule.stopScan()}subscribeToDiscoveredDevicesEvents(){return new a(e=>{const t=new i(this._nativeModule).addListener(D,
|
|
1
|
+
import{NativeEventEmitter as i}from"react-native";import{Observable as a}from"rxjs";import{uint8ArrayToBase64 as s}from"../helpers/base64Utils";import{mapNativeConnectionResultToConnectionResult as c,mapNativeDeviceConnectionLostToDeviceDisconnected as v,mapNativeDiscoveryDeviceToTransportDiscoveredDevice as d,mapNativeSendApduResultToSendApduResult as u,mapNativeTransportLogToLog as l}from"./mapper";import{DEVICE_DISCONNECTED_EVENT as p,DISCOVERED_DEVICES_EVENT as D,TRANSPORT_LOG_EVENT as m}from"./types";class _{_nativeModule;_deviceModelDataSource;constructor(e){this._nativeModule=e.nativeModule,this._deviceModelDataSource=e.deviceModelDataSource}startScan(){return this._nativeModule.startScan()}stopScan(){return this._nativeModule.stopScan()}subscribeToDiscoveredDevicesEvents(){return new a(e=>{const t=new i(this._nativeModule).addListener(D,n=>{e.next(n.map(r=>d(r,this._deviceModelDataSource)).filter(r=>r!==null))});return()=>{t.remove()}})}subscribeToDeviceDisconnectedEvents(){return new a(e=>{const t=new i(this._nativeModule).addListener(p,n=>{e.next(v(n))});return()=>{t.remove()}})}subscribeToTransportLogs(){return new a(e=>{const t=new i(this._nativeModule).addListener(m,n=>{e.next(l(n))});return()=>{t.remove()}})}async connectDevice(e){const o=await this._nativeModule.connectDevice(e);return c(o,this._deviceModelDataSource)}async disconnectDevice(e){return this._nativeModule.disconnectDevice(e)}async sendApdu(e,o,t,n){const r=await this._nativeModule.sendApdu(e,s(o),t,n);return u(r)}}export{_ as DefaultNativeModuleWrapper};
|
|
2
2
|
//# sourceMappingURL=DefaultNativeModuleWrapper.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/bridge/DefaultNativeModuleWrapper.ts"],
|
|
4
|
-
"sourcesContent": ["import { NativeEventEmitter } from \"react-native\";\nimport {\n type DeviceModelDataSource,\n type LogParams,\n type SendApduResult,\n type TransportDiscoveredDevice,\n} from \"@ledgerhq/device-management-kit\";\nimport { Observable } from \"rxjs\";\n\nimport { uint8ArrayToBase64 } from \"@api/helpers/base64Utils\";\nimport { type NativeModuleWrapper } from \"@api/transport/NativeModuleWrapper\";\nimport {\n type InternalConnectionResult,\n type InternalDeviceDisconnected,\n} from \"@api/transport/types\";\n\nimport {\n mapNativeConnectionResultToConnectionResult,\n mapNativeDeviceConnectionLostToDeviceDisconnected,\n mapNativeDiscoveryDeviceToTransportDiscoveredDevice,\n mapNativeSendApduResultToSendApduResult,\n mapNativeTransportLogToLog,\n} from \"./mapper\";\nimport {\n DEVICE_DISCONNECTED_EVENT,\n type DeviceDisconnectedEventPayload,\n DISCOVERED_DEVICES_EVENT,\n type DiscoveredDevicesEventPayload,\n type NativeLog,\n TRANSPORT_LOG_EVENT,\n} from \"./types\";\nimport { type NativeTransportModuleType } from \"./types\";\n\nexport class DefaultNativeModuleWrapper implements NativeModuleWrapper {\n private readonly _nativeModule: NativeTransportModuleType;\n private readonly _deviceModelDataSource: DeviceModelDataSource;\n\n constructor(args: {\n nativeModule: NativeTransportModuleType;\n deviceModelDataSource: DeviceModelDataSource;\n }) {\n this._nativeModule = args.nativeModule;\n this._deviceModelDataSource = args.deviceModelDataSource;\n }\n\n startScan() {\n return this._nativeModule.startScan();\n }\n\n stopScan() {\n return this._nativeModule.stopScan();\n }\n\n subscribeToDiscoveredDevicesEvents(): Observable<\n Array<TransportDiscoveredDevice>\n > {\n return new Observable((subscriber) => {\n const eventEmitter = new NativeEventEmitter(this._nativeModule);\n const eventListener = eventEmitter.addListener(\n DISCOVERED_DEVICES_EVENT,\n (discoveredDevices: DiscoveredDevicesEventPayload) => {\n subscriber.next(\n discoveredDevices\n .map((device) =>\n mapNativeDiscoveryDeviceToTransportDiscoveredDevice(\n device,\n this._deviceModelDataSource,\n ),\n )\n .filter((d) => d !== null),\n );\n },\n );\n\n return () => {\n eventListener.remove();\n };\n });\n }\n\n subscribeToDeviceDisconnectedEvents(): Observable<InternalDeviceDisconnected> {\n return new Observable((subscriber) => {\n const eventEmitter = new NativeEventEmitter(this._nativeModule);\n const eventListener = eventEmitter.addListener(\n DEVICE_DISCONNECTED_EVENT,\n (device: DeviceDisconnectedEventPayload) => {\n subscriber.next(\n mapNativeDeviceConnectionLostToDeviceDisconnected(device),\n );\n },\n );\n\n return () => {\n eventListener.remove();\n };\n });\n }\n\n subscribeToTransportLogs(): Observable<LogParams> {\n return new Observable((subscriber) => {\n const eventEmitter = new NativeEventEmitter(this._nativeModule);\n const eventListener = eventEmitter.addListener(\n TRANSPORT_LOG_EVENT,\n (logParams: NativeLog) => {\n subscriber.next(mapNativeTransportLogToLog(logParams));\n },\n );\n\n return () => {\n eventListener.remove();\n };\n });\n }\n\n async connectDevice(uid: string): Promise<InternalConnectionResult> {\n const nConnectionResult = await this._nativeModule.connectDevice(uid);\n return mapNativeConnectionResultToConnectionResult(\n nConnectionResult,\n this._deviceModelDataSource,\n );\n }\n\n async disconnectDevice(sessionId: string): Promise<void> {\n return this._nativeModule.disconnectDevice(sessionId);\n }\n\n async sendApdu(sessionId: string
|
|
5
|
-
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M,KAAK,cAAc,cAAcD,CAAG,EACpE,OAAOhB,EACLiB,EACA,KAAK,sBACP,CACF,CAEA,MAAM,iBAAiBC,EAAkC,CACvD,OAAO,KAAK,cAAc,iBAAiBA,CAAS,CACtD,CAEA,MAAM,
|
|
6
|
-
"names": ["NativeEventEmitter", "Observable", "uint8ArrayToBase64", "mapNativeConnectionResultToConnectionResult", "mapNativeDeviceConnectionLostToDeviceDisconnected", "mapNativeDiscoveryDeviceToTransportDiscoveredDevice", "mapNativeSendApduResultToSendApduResult", "mapNativeTransportLogToLog", "DEVICE_DISCONNECTED_EVENT", "DISCOVERED_DEVICES_EVENT", "TRANSPORT_LOG_EVENT", "DefaultNativeModuleWrapper", "args", "subscriber", "eventListener", "discoveredDevices", "device", "d", "logParams", "uid", "nConnectionResult", "sessionId", "apdu", "nSendApduResult"]
|
|
4
|
+
"sourcesContent": ["import { NativeEventEmitter } from \"react-native\";\nimport {\n type DeviceModelDataSource,\n type LogParams,\n type SendApduResult,\n type TransportDiscoveredDevice,\n} from \"@ledgerhq/device-management-kit\";\nimport { Observable } from \"rxjs\";\n\nimport { uint8ArrayToBase64 } from \"@api/helpers/base64Utils\";\nimport { type NativeModuleWrapper } from \"@api/transport/NativeModuleWrapper\";\nimport {\n type InternalConnectionResult,\n type InternalDeviceDisconnected,\n} from \"@api/transport/types\";\n\nimport {\n mapNativeConnectionResultToConnectionResult,\n mapNativeDeviceConnectionLostToDeviceDisconnected,\n mapNativeDiscoveryDeviceToTransportDiscoveredDevice,\n mapNativeSendApduResultToSendApduResult,\n mapNativeTransportLogToLog,\n} from \"./mapper\";\nimport {\n DEVICE_DISCONNECTED_EVENT,\n type DeviceDisconnectedEventPayload,\n DISCOVERED_DEVICES_EVENT,\n type DiscoveredDevicesEventPayload,\n type NativeLog,\n TRANSPORT_LOG_EVENT,\n} from \"./types\";\nimport { type NativeTransportModuleType } from \"./types\";\n\nexport class DefaultNativeModuleWrapper implements NativeModuleWrapper {\n private readonly _nativeModule: NativeTransportModuleType;\n private readonly _deviceModelDataSource: DeviceModelDataSource;\n\n constructor(args: {\n nativeModule: NativeTransportModuleType;\n deviceModelDataSource: DeviceModelDataSource;\n }) {\n this._nativeModule = args.nativeModule;\n this._deviceModelDataSource = args.deviceModelDataSource;\n }\n\n startScan() {\n return this._nativeModule.startScan();\n }\n\n stopScan() {\n return this._nativeModule.stopScan();\n }\n\n subscribeToDiscoveredDevicesEvents(): Observable<\n Array<TransportDiscoveredDevice>\n > {\n return new Observable((subscriber) => {\n const eventEmitter = new NativeEventEmitter(this._nativeModule);\n const eventListener = eventEmitter.addListener(\n DISCOVERED_DEVICES_EVENT,\n (discoveredDevices: DiscoveredDevicesEventPayload) => {\n subscriber.next(\n discoveredDevices\n .map((device) =>\n mapNativeDiscoveryDeviceToTransportDiscoveredDevice(\n device,\n this._deviceModelDataSource,\n ),\n )\n .filter((d) => d !== null),\n );\n },\n );\n\n return () => {\n eventListener.remove();\n };\n });\n }\n\n subscribeToDeviceDisconnectedEvents(): Observable<InternalDeviceDisconnected> {\n return new Observable((subscriber) => {\n const eventEmitter = new NativeEventEmitter(this._nativeModule);\n const eventListener = eventEmitter.addListener(\n DEVICE_DISCONNECTED_EVENT,\n (device: DeviceDisconnectedEventPayload) => {\n subscriber.next(\n mapNativeDeviceConnectionLostToDeviceDisconnected(device),\n );\n },\n );\n\n return () => {\n eventListener.remove();\n };\n });\n }\n\n subscribeToTransportLogs(): Observable<LogParams> {\n return new Observable((subscriber) => {\n const eventEmitter = new NativeEventEmitter(this._nativeModule);\n const eventListener = eventEmitter.addListener(\n TRANSPORT_LOG_EVENT,\n (logParams: NativeLog) => {\n subscriber.next(mapNativeTransportLogToLog(logParams));\n },\n );\n\n return () => {\n eventListener.remove();\n };\n });\n }\n\n async connectDevice(uid: string): Promise<InternalConnectionResult> {\n const nConnectionResult = await this._nativeModule.connectDevice(uid);\n return mapNativeConnectionResultToConnectionResult(\n nConnectionResult,\n this._deviceModelDataSource,\n );\n }\n\n async disconnectDevice(sessionId: string): Promise<void> {\n return this._nativeModule.disconnectDevice(sessionId);\n }\n\n async sendApdu(\n sessionId: string,\n apdu: Uint8Array,\n triggersDisconnection: boolean,\n abortTimeout: number,\n ): Promise<SendApduResult> {\n const nSendApduResult = await this._nativeModule.sendApdu(\n sessionId,\n uint8ArrayToBase64(apdu),\n triggersDisconnection,\n abortTimeout,\n );\n return mapNativeSendApduResultToSendApduResult(nSendApduResult);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,sBAAAA,MAA0B,eAOnC,OAAS,cAAAC,MAAkB,OAE3B,OAAS,sBAAAC,MAA0B,2BAOnC,OACE,+CAAAC,EACA,qDAAAC,EACA,uDAAAC,EACA,2CAAAC,EACA,8BAAAC,MACK,WACP,OACE,6BAAAC,EAEA,4BAAAC,EAGA,uBAAAC,MACK,UAGA,MAAMC,CAA0D,CACpD,cACA,uBAEjB,YAAYC,EAGT,CACD,KAAK,cAAgBA,EAAK,aAC1B,KAAK,uBAAyBA,EAAK,qBACrC,CAEA,WAAY,CACV,OAAO,KAAK,cAAc,UAAU,CACtC,CAEA,UAAW,CACT,OAAO,KAAK,cAAc,SAAS,CACrC,CAEA,oCAEE,CACA,OAAO,IAAIX,EAAYY,GAAe,CAEpC,MAAMC,EADe,IAAId,EAAmB,KAAK,aAAa,EAC3B,YACjCS,EACCM,GAAqD,CACpDF,EAAW,KACTE,EACG,IAAKC,GACJX,EACEW,EACA,KAAK,sBACP,CACF,EACC,OAAQC,GAAMA,IAAM,IAAI,CAC7B,CACF,CACF,EAEA,MAAO,IAAM,CACXH,EAAc,OAAO,CACvB,CACF,CAAC,CACH,CAEA,qCAA8E,CAC5E,OAAO,IAAIb,EAAYY,GAAe,CAEpC,MAAMC,EADe,IAAId,EAAmB,KAAK,aAAa,EAC3B,YACjCQ,EACCQ,GAA2C,CAC1CH,EAAW,KACTT,EAAkDY,CAAM,CAC1D,CACF,CACF,EAEA,MAAO,IAAM,CACXF,EAAc,OAAO,CACvB,CACF,CAAC,CACH,CAEA,0BAAkD,CAChD,OAAO,IAAIb,EAAYY,GAAe,CAEpC,MAAMC,EADe,IAAId,EAAmB,KAAK,aAAa,EAC3B,YACjCU,EACCQ,GAAyB,CACxBL,EAAW,KAAKN,EAA2BW,CAAS,CAAC,CACvD,CACF,EAEA,MAAO,IAAM,CACXJ,EAAc,OAAO,CACvB,CACF,CAAC,CACH,CAEA,MAAM,cAAcK,EAAgD,CAClE,MAAMC,EAAoB,MAAM,KAAK,cAAc,cAAcD,CAAG,EACpE,OAAOhB,EACLiB,EACA,KAAK,sBACP,CACF,CAEA,MAAM,iBAAiBC,EAAkC,CACvD,OAAO,KAAK,cAAc,iBAAiBA,CAAS,CACtD,CAEA,MAAM,SACJA,EACAC,EACAC,EACAC,EACyB,CACzB,MAAMC,EAAkB,MAAM,KAAK,cAAc,SAC/CJ,EACAnB,EAAmBoB,CAAI,EACvBC,EACAC,CACF,EACA,OAAOlB,EAAwCmB,CAAe,CAChE,CACF",
|
|
6
|
+
"names": ["NativeEventEmitter", "Observable", "uint8ArrayToBase64", "mapNativeConnectionResultToConnectionResult", "mapNativeDeviceConnectionLostToDeviceDisconnected", "mapNativeDiscoveryDeviceToTransportDiscoveredDevice", "mapNativeSendApduResultToSendApduResult", "mapNativeTransportLogToLog", "DEVICE_DISCONNECTED_EVENT", "DISCOVERED_DEVICES_EVENT", "TRANSPORT_LOG_EVENT", "DefaultNativeModuleWrapper", "args", "subscriber", "eventListener", "discoveredDevices", "device", "d", "logParams", "uid", "nConnectionResult", "sessionId", "apdu", "triggersDisconnection", "abortTimeout", "nSendApduResult"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduResponse as
|
|
1
|
+
import{ApduResponse as p,FramerUtils as i,LogLevel as o,OpeningConnectionError as s,SendApduEmptyResponseError as u,SendApduTimeoutError as v}from"@ledgerhq/device-management-kit";import{Left as n,Right as a}from"purify-ts";import{base64ToUint8Array as l}from"../helpers/base64Utils";import{SendApduError as m}from"../transport/Errors";import{TRANSPORT_IDENTIFIER as D}from"../transport/rnHidTransportIdentifier";function c(e,t){return t.filterDeviceModels({usbProductId:Number.parseInt(e.usbProductIdMask,16)})[0]??null}function L(e,t){const r=c(e.ledgerDevice,t);return r==null?null:{id:e.uid,deviceModel:r,transport:D,name:e.name}}function T(e){let t;switch(e.level){case"error":t=o.Error;break;case"warning":t=o.Warning;break;case"info":t=o.Info;break;case"debug":t=o.Debug;break;default:f(e.level),t=o.Info;break}return[t,e.message,{tag:e.tag,data:e.jsonPayload,timestamp:Number.parseInt(e.timestamp,10)}]}function f(e){throw new Error("Unexpected object: "+e)}function b(e,t){if(e.success){const r=c(e.ledgerDevice,t);return r?a({sessionId:e.sessionId,transportDeviceModel:r}):n(new s(`Could not find device model for the connected device with usbProductIdMask: ${e.ledgerDevice.usbProductIdMask}`))}else return n(new s(e.error))}function S(e){if(e.success){const t=l(e.apdu),r=i.getFirstBytesFrom(t,t.length-2),d=i.getLastBytesFrom(t,2);return a(new p({data:r,statusCode:d}))}else return e.error==="SendApduTimeout"?n(new v("Abort timeout")):e.error==="EmptyResponseError"?n(new u("Empty response")):n(new m(e.error))}function A(e){return{sessionId:e.id}}export{b as mapNativeConnectionResultToConnectionResult,A as mapNativeDeviceConnectionLostToDeviceDisconnected,L as mapNativeDiscoveryDeviceToTransportDiscoveredDevice,c as mapNativeLedgerDeviceToDeviceModel,S as mapNativeSendApduResultToSendApduResult,T as mapNativeTransportLogToLog};
|
|
2
2
|
//# sourceMappingURL=mapper.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/bridge/mapper.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduResponse,\n type DeviceModelDataSource,\n FramerUtils,\n LogLevel,\n type LogParams,\n OpeningConnectionError,\n type SendApduResult,\n type TransportDeviceModel,\n type TransportDiscoveredDevice,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { base64ToUint8Array } from \"@api/helpers/base64Utils\";\nimport { SendApduError } from \"@api/transport/Errors\";\nimport { TRANSPORT_IDENTIFIER } from \"@api/transport/rnHidTransportIdentifier\";\nimport {\n type InternalConnectionResult,\n type InternalDeviceDisconnected,\n} from \"@api/transport/types\";\n\nimport {\n type NativeDeviceConnectionLost,\n type NativeDiscoveryDevice,\n type NativeInternalConnectionResult,\n type NativeLedgerDevice,\n type NativeLog,\n type NativeSendApduResult,\n} from \"./types\";\n\nexport function mapNativeLedgerDeviceToDeviceModel(\n nativeLedgerDevice: NativeLedgerDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDeviceModel | null {\n return (\n deviceModelDataSource.filterDeviceModels({\n usbProductId: Number.parseInt(nativeLedgerDevice.usbProductIdMask, 16),\n })[0] ?? null\n );\n}\n\nexport function mapNativeDiscoveryDeviceToTransportDiscoveredDevice(\n nativeDevice: NativeDiscoveryDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDiscoveredDevice | null {\n const deviceModel = mapNativeLedgerDeviceToDeviceModel(\n nativeDevice.ledgerDevice,\n deviceModelDataSource,\n );\n if (deviceModel == null) return null;\n\n return {\n id: nativeDevice.uid,\n deviceModel,\n transport: TRANSPORT_IDENTIFIER,\n name: nativeDevice.name,\n };\n}\n\nexport function mapNativeTransportLogToLog(log: NativeLog): LogParams {\n let level: LogLevel;\n switch (log.level) {\n case \"error\":\n level = LogLevel.Error;\n break;\n case \"warning\":\n level = LogLevel.Warning;\n break;\n case \"info\":\n level = LogLevel.Info;\n break;\n case \"debug\":\n level = LogLevel.Debug;\n break;\n default:\n assertNever(log.level);\n level = LogLevel.Info;\n break;\n }\n\n return [\n level,\n log.message,\n {\n tag: log.tag,\n data: log.jsonPayload,\n timestamp: Number.parseInt(log.timestamp, 10),\n },\n ];\n}\n\nfunction assertNever(x: never) {\n throw new Error(\"Unexpected object: \" + x);\n}\n\nexport function mapNativeConnectionResultToConnectionResult(\n result: NativeInternalConnectionResult,\n deviceModelDataSource: DeviceModelDataSource,\n): InternalConnectionResult {\n if (result.success) {\n const transportDeviceModel = mapNativeLedgerDeviceToDeviceModel(\n result.ledgerDevice,\n deviceModelDataSource,\n );\n if (!transportDeviceModel)\n return Left(\n new OpeningConnectionError(\n `Could not find device model for the connected device with usbProductIdMask: ${result.ledgerDevice.usbProductIdMask}`,\n ),\n );\n return Right({ sessionId: result.sessionId, transportDeviceModel });\n } else {\n return Left(new OpeningConnectionError(result.error));\n }\n}\n\nexport function mapNativeSendApduResultToSendApduResult(\n result: NativeSendApduResult,\n): SendApduResult {\n if (result.success) {\n const responseBytes = base64ToUint8Array(result.apdu);\n const data = FramerUtils.getFirstBytesFrom(\n responseBytes,\n responseBytes.length - 2,\n );\n const statusCode = FramerUtils.getLastBytesFrom(responseBytes, 2);\n return Right(new ApduResponse({ data, statusCode }));\n } else {\n return Left(new SendApduError(result.error));\n }\n}\n\nexport function mapNativeDeviceConnectionLostToDeviceDisconnected(\n nativeDeviceConnectionLost: NativeDeviceConnectionLost,\n): InternalDeviceDisconnected {\n return {\n sessionId: nativeDeviceConnectionLost.id,\n };\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,gBAAAA,EAEA,eAAAC,EACA,YAAAC,EAEA,0BAAAC,
|
|
6
|
-
"names": ["ApduResponse", "FramerUtils", "LogLevel", "OpeningConnectionError", "Left", "Right", "base64ToUint8Array", "SendApduError", "TRANSPORT_IDENTIFIER", "mapNativeLedgerDeviceToDeviceModel", "nativeLedgerDevice", "deviceModelDataSource", "mapNativeDiscoveryDeviceToTransportDiscoveredDevice", "nativeDevice", "deviceModel", "mapNativeTransportLogToLog", "log", "level", "assertNever", "x", "mapNativeConnectionResultToConnectionResult", "result", "transportDeviceModel", "mapNativeSendApduResultToSendApduResult", "responseBytes", "data", "statusCode", "mapNativeDeviceConnectionLostToDeviceDisconnected", "nativeDeviceConnectionLost"]
|
|
4
|
+
"sourcesContent": ["import {\n ApduResponse,\n type DeviceModelDataSource,\n FramerUtils,\n LogLevel,\n type LogParams,\n OpeningConnectionError,\n SendApduEmptyResponseError,\n type SendApduResult,\n SendApduTimeoutError,\n type TransportDeviceModel,\n type TransportDiscoveredDevice,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { base64ToUint8Array } from \"@api/helpers/base64Utils\";\nimport { SendApduError } from \"@api/transport/Errors\";\nimport { TRANSPORT_IDENTIFIER } from \"@api/transport/rnHidTransportIdentifier\";\nimport {\n type InternalConnectionResult,\n type InternalDeviceDisconnected,\n} from \"@api/transport/types\";\n\nimport {\n type NativeDeviceConnectionLost,\n type NativeDiscoveryDevice,\n type NativeInternalConnectionResult,\n type NativeLedgerDevice,\n type NativeLog,\n type NativeSendApduResult,\n} from \"./types\";\n\nexport function mapNativeLedgerDeviceToDeviceModel(\n nativeLedgerDevice: NativeLedgerDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDeviceModel | null {\n return (\n deviceModelDataSource.filterDeviceModels({\n usbProductId: Number.parseInt(nativeLedgerDevice.usbProductIdMask, 16),\n })[0] ?? null\n );\n}\n\nexport function mapNativeDiscoveryDeviceToTransportDiscoveredDevice(\n nativeDevice: NativeDiscoveryDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDiscoveredDevice | null {\n const deviceModel = mapNativeLedgerDeviceToDeviceModel(\n nativeDevice.ledgerDevice,\n deviceModelDataSource,\n );\n if (deviceModel == null) return null;\n\n return {\n id: nativeDevice.uid,\n deviceModel,\n transport: TRANSPORT_IDENTIFIER,\n name: nativeDevice.name,\n };\n}\n\nexport function mapNativeTransportLogToLog(log: NativeLog): LogParams {\n let level: LogLevel;\n switch (log.level) {\n case \"error\":\n level = LogLevel.Error;\n break;\n case \"warning\":\n level = LogLevel.Warning;\n break;\n case \"info\":\n level = LogLevel.Info;\n break;\n case \"debug\":\n level = LogLevel.Debug;\n break;\n default:\n assertNever(log.level);\n level = LogLevel.Info;\n break;\n }\n\n return [\n level,\n log.message,\n {\n tag: log.tag,\n data: log.jsonPayload,\n timestamp: Number.parseInt(log.timestamp, 10),\n },\n ];\n}\n\nfunction assertNever(x: never) {\n throw new Error(\"Unexpected object: \" + x);\n}\n\nexport function mapNativeConnectionResultToConnectionResult(\n result: NativeInternalConnectionResult,\n deviceModelDataSource: DeviceModelDataSource,\n): InternalConnectionResult {\n if (result.success) {\n const transportDeviceModel = mapNativeLedgerDeviceToDeviceModel(\n result.ledgerDevice,\n deviceModelDataSource,\n );\n if (!transportDeviceModel)\n return Left(\n new OpeningConnectionError(\n `Could not find device model for the connected device with usbProductIdMask: ${result.ledgerDevice.usbProductIdMask}`,\n ),\n );\n return Right({ sessionId: result.sessionId, transportDeviceModel });\n } else {\n return Left(new OpeningConnectionError(result.error));\n }\n}\n\nexport function mapNativeSendApduResultToSendApduResult(\n result: NativeSendApduResult,\n): SendApduResult {\n if (result.success) {\n const responseBytes = base64ToUint8Array(result.apdu);\n const data = FramerUtils.getFirstBytesFrom(\n responseBytes,\n responseBytes.length - 2,\n );\n const statusCode = FramerUtils.getLastBytesFrom(responseBytes, 2);\n return Right(new ApduResponse({ data, statusCode }));\n } else if (result.error === \"SendApduTimeout\") {\n return Left(new SendApduTimeoutError(\"Abort timeout\"));\n } else if (result.error === \"EmptyResponseError\") {\n return Left(new SendApduEmptyResponseError(\"Empty response\"));\n } else {\n return Left(new SendApduError(result.error));\n }\n}\n\nexport function mapNativeDeviceConnectionLostToDeviceDisconnected(\n nativeDeviceConnectionLost: NativeDeviceConnectionLost,\n): InternalDeviceDisconnected {\n return {\n sessionId: nativeDeviceConnectionLost.id,\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,gBAAAA,EAEA,eAAAC,EACA,YAAAC,EAEA,0BAAAC,EACA,8BAAAC,EAEA,wBAAAC,MAGK,kCACP,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAS,sBAAAC,MAA0B,2BACnC,OAAS,iBAAAC,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B,EAAmBe,EAAO,IAAI,EAC9CI,EAAO1B,EAAY,kBACvByB,EACAA,EAAc,OAAS,CACzB,EACME,EAAa3B,EAAY,iBAAiByB,EAAe,CAAC,EAChE,OAAOnB,EAAM,IAAIP,EAAa,CAAE,KAAA2B,EAAM,WAAAC,CAAW,CAAC,CAAC,CACrD,KAAO,QAAIL,EAAO,QAAU,kBACnBjB,EAAK,IAAID,EAAqB,eAAe,CAAC,EAC5CkB,EAAO,QAAU,qBACnBjB,EAAK,IAAIF,EAA2B,gBAAgB,CAAC,EAErDE,EAAK,IAAIG,EAAcc,EAAO,KAAK,CAAC,CAE/C,CAEO,SAASM,EACdC,EAC4B,CAC5B,MAAO,CACL,UAAWA,EAA2B,EACxC,CACF",
|
|
6
|
+
"names": ["ApduResponse", "FramerUtils", "LogLevel", "OpeningConnectionError", "SendApduEmptyResponseError", "SendApduTimeoutError", "Left", "Right", "base64ToUint8Array", "SendApduError", "TRANSPORT_IDENTIFIER", "mapNativeLedgerDeviceToDeviceModel", "nativeLedgerDevice", "deviceModelDataSource", "mapNativeDiscoveryDeviceToTransportDiscoveredDevice", "nativeDevice", "deviceModel", "mapNativeTransportLogToLog", "log", "level", "assertNever", "x", "mapNativeConnectionResultToConnectionResult", "result", "transportDeviceModel", "mapNativeSendApduResultToSendApduResult", "responseBytes", "data", "statusCode", "mapNativeDeviceConnectionLostToDeviceDisconnected", "nativeDeviceConnectionLost"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/bridge/types.ts"],
|
|
4
|
-
"sourcesContent": ["import { type NativeModule } from \"react-native\";\n\nexport type NativeLedgerDevice = {\n name: \"NanoS\" | \"NanoSPlus\" | \"NanoX\" | \"Flex\" | \"Stax\";\n usbProductIdMask: string;\n};\n\nexport type NativeDiscoveryDevice = {\n uid: string;\n name: string;\n ledgerDevice: NativeLedgerDevice;\n};\n\ntype NativeLogLevel = \"debug\" | \"info\" | \"warning\" | \"error\";\n\nexport type NativeLog = {\n level: NativeLogLevel;\n tag: string;\n message: string;\n jsonPayload: Record<string, string>;\n timestamp: string;\n};\n\nexport type NativeInternalConnectionResult =\n | {\n success: true;\n sessionId: string;\n ledgerDevice: NativeLedgerDevice;\n deviceName: string;\n }\n | {\n success: false;\n error: string;\n };\n\nexport type NativeSendApduResult =\n | {\n success: true;\n apdu: string;\n }\n | {\n success: false;\n error: string;\n };\n\nexport type NativeDeviceConnectionLost = {\n id: string;\n};\n\n/**\n * Events\n */\n\n/** DiscoveredDevices */\nexport const DISCOVERED_DEVICES_EVENT = \"DiscoveredDevices\";\nexport type DiscoveredDevicesEventPayload = Array<NativeDiscoveryDevice>;\n\n/** TransportLog */\nexport const TRANSPORT_LOG_EVENT = \"TransportLog\";\nexport type LogEventPayload = NativeLog;\n\n/** DeviceDisconnected */\nexport const DEVICE_DISCONNECTED_EVENT = \"DeviceDisconnected\";\nexport type DeviceDisconnectedEventPayload = NativeDeviceConnectionLost;\n\n/**\n * Signature of the native transport module.\n */\nexport type NativeTransportModuleType = {\n startScan: () => Promise<void>;\n stopScan: () => Promise<void>;\n connectDevice: (uid: string) => Promise<NativeInternalConnectionResult>;\n disconnectDevice: (sessionId: string) => Promise<void>;\n sendApdu: (sessionId: string
|
|
4
|
+
"sourcesContent": ["import { type NativeModule } from \"react-native\";\n\nexport type NativeLedgerDevice = {\n name: \"NanoS\" | \"NanoSPlus\" | \"NanoX\" | \"Flex\" | \"Stax\";\n usbProductIdMask: string;\n};\n\nexport type NativeDiscoveryDevice = {\n uid: string;\n name: string;\n ledgerDevice: NativeLedgerDevice;\n};\n\ntype NativeLogLevel = \"debug\" | \"info\" | \"warning\" | \"error\";\n\nexport type NativeLog = {\n level: NativeLogLevel;\n tag: string;\n message: string;\n jsonPayload: Record<string, string>;\n timestamp: string;\n};\n\nexport type NativeInternalConnectionResult =\n | {\n success: true;\n sessionId: string;\n ledgerDevice: NativeLedgerDevice;\n deviceName: string;\n }\n | {\n success: false;\n error: string;\n };\n\nexport type NativeSendApduResult =\n | {\n success: true;\n apdu: string;\n }\n | {\n success: false;\n error: string | \"SendApduTimeout\";\n };\n\nexport type NativeDeviceConnectionLost = {\n id: string;\n};\n\n/**\n * Events\n */\n\n/** DiscoveredDevices */\nexport const DISCOVERED_DEVICES_EVENT = \"DiscoveredDevices\";\nexport type DiscoveredDevicesEventPayload = Array<NativeDiscoveryDevice>;\n\n/** TransportLog */\nexport const TRANSPORT_LOG_EVENT = \"TransportLog\";\nexport type LogEventPayload = NativeLog;\n\n/** DeviceDisconnected */\nexport const DEVICE_DISCONNECTED_EVENT = \"DeviceDisconnected\";\nexport type DeviceDisconnectedEventPayload = NativeDeviceConnectionLost;\n\n/**\n * Signature of the native transport module.\n */\nexport type NativeTransportModuleType = {\n startScan: () => Promise<void>;\n stopScan: () => Promise<void>;\n connectDevice: (uid: string) => Promise<NativeInternalConnectionResult>;\n disconnectDevice: (sessionId: string) => Promise<void>;\n sendApdu: (\n sessionId: string,\n apdu: string,\n triggersDisconnection: boolean,\n abortTimeout: number,\n ) => Promise<NativeSendApduResult>;\n} & NativeModule;\n"],
|
|
5
5
|
"mappings": "AAsDO,MAAMA,EAA2B,oBAI3BC,EAAsB,eAItBC,EAA4B",
|
|
6
6
|
"names": ["DISCOVERED_DEVICES_EVENT", "TRANSPORT_LOG_EVENT", "DEVICE_DISCONNECTED_EVENT"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DisconnectError as
|
|
1
|
+
import{DisconnectError as g,LogLevel as n,OpeningConnectionError as l,TransportConnectedDevice as u}from"@ledgerhq/device-management-kit";import{Left as p,Right as b}from"purify-ts";import{Observable as v}from"rxjs";import{getObservableOfArraysNewItems as h}from"../helpers/getObservableOfArraysNewItems";import{TRANSPORT_IDENTIFIER as D}from"../transport/rnHidTransportIdentifier";import{SendApduError as _}from"./Errors";class W{constructor(i,r,t){this._isSupported=i;this._nativeModuleWrapper=r;this._loggerService=t("RNHidTransport"),this._nativeModuleWrapper.subscribeToTransportLogs().subscribe(e=>{const[s,o,c]=e,a={[n.Fatal]:this._loggerService.error.bind(this._loggerService),[n.Error]:this._loggerService.error.bind(this._loggerService),[n.Warning]:this._loggerService.warn.bind(this._loggerService),[n.Info]:this._loggerService.info.bind(this._loggerService),[n.Debug]:this._loggerService.debug.bind(this._loggerService)}[s];a(o,c)})}_loggerService;getIdentifier(){return D}isSupported(){return this._isSupported}startDiscovering(){return new v(r=>{const t=h(this._nativeModuleWrapper.subscribeToDiscoveredDevicesEvents(),e=>e.id).subscribe(r);return this._nativeModuleWrapper.startScan().catch(e=>{r.error(e),this._loggerService.error("startDiscovering error",e)}),()=>t.unsubscribe()})}stopDiscovering(){this._nativeModuleWrapper.stopScan().catch(i=>{this._loggerService.error("stopDiscovering error",i)})}listenToAvailableDevices(){return new v(r=>{const t=this._nativeModuleWrapper.subscribeToDiscoveredDevicesEvents().subscribe(e=>{r.next(e)});return this._nativeModuleWrapper.startScan().catch(e=>{this._loggerService.error("startDiscovering error",e),r.error(e)}),()=>{t.unsubscribe(),this._nativeModuleWrapper.stopScan().catch(e=>{this._loggerService.error("stopDiscovering error",e)})}})}connect(i){return this._nativeModuleWrapper.connectDevice(i.deviceId).then(r=>r.map(({sessionId:t,transportDeviceModel:e})=>{const s=this._nativeModuleWrapper.subscribeToDeviceDisconnectedEvents().subscribe(o=>{o.sessionId===t&&(i.onDisconnect(t),s.unsubscribe())});return new u({id:t,deviceModel:e,sendApdu:async(o,c=!1,a=-1)=>this._nativeModuleWrapper.sendApdu(t,o,c,a).catch(d=>p(new _(d))),transport:this.getIdentifier(),type:"USB"})})).catch(r=>p(new l(r)))}disconnect(i){return this._nativeModuleWrapper.disconnectDevice(i.connectedDevice.id).then(()=>b(void 0)).catch(r=>p(new g(r)))}}export{W as RNHidTransport};
|
|
2
2
|
//# sourceMappingURL=RNHidTransport.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/transport/RNHidTransport.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ConnectError,\n type DeviceId,\n DisconnectError,\n type DisconnectHandler,\n type DmkError,\n type LoggerPublisherService,\n LogLevel,\n OpeningConnectionError,\n type Transport,\n TransportConnectedDevice,\n type TransportDiscoveredDevice,\n type TransportIdentifier,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, Left, Right } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\n\nimport { getObservableOfArraysNewItems } from \"@api/helpers/getObservableOfArraysNewItems\";\nimport { TRANSPORT_IDENTIFIER } from \"@api/transport/rnHidTransportIdentifier\";\n\nimport { SendApduError } from \"./Errors\";\nimport { type NativeModuleWrapper } from \"./NativeModuleWrapper\";\n\nexport class RNHidTransport implements Transport {\n private _loggerService: LoggerPublisherService;\n\n constructor(\n private readonly _isSupported: boolean,\n private readonly _nativeModuleWrapper: NativeModuleWrapper,\n _loggerServiceFactory: (tag: string) => LoggerPublisherService,\n ) {\n this._loggerService = _loggerServiceFactory(\"RNHidTransport\");\n this._nativeModuleWrapper.subscribeToTransportLogs().subscribe((log) => {\n const [logLevel, message, options] = log;\n const logMethod = {\n [LogLevel.Fatal]: this._loggerService.error.bind(this._loggerService),\n [LogLevel.Error]: this._loggerService.error.bind(this._loggerService),\n [LogLevel.Warning]: this._loggerService.warn.bind(this._loggerService),\n [LogLevel.Info]: this._loggerService.info.bind(this._loggerService),\n [LogLevel.Debug]: this._loggerService.debug.bind(this._loggerService),\n }[logLevel];\n logMethod(message, options);\n });\n }\n\n getIdentifier(): TransportIdentifier {\n return TRANSPORT_IDENTIFIER;\n }\n\n isSupported(): boolean {\n return this._isSupported;\n }\n\n startDiscovering(): Observable<TransportDiscoveredDevice> {\n const observable = new Observable<TransportDiscoveredDevice>(\n (subscriber) => {\n const subscription = getObservableOfArraysNewItems(\n this._nativeModuleWrapper.subscribeToDiscoveredDevicesEvents(),\n (device) => device.id,\n ).subscribe(subscriber);\n\n this._nativeModuleWrapper.startScan().catch((error) => {\n subscriber.error(error);\n this._loggerService.error(\"startDiscovering error\", error);\n });\n return () => subscription.unsubscribe();\n },\n );\n return observable;\n }\n\n stopDiscovering(): void {\n this._nativeModuleWrapper.stopScan().catch((error) => {\n this._loggerService.error(\"stopDiscovering error\", error);\n });\n }\n\n listenToAvailableDevices(): Observable<TransportDiscoveredDevice[]> {\n /**\n * NB: here we need to define the unsubscribe logic as there is no\n * \"stopListeningToKnownDevices\" method.\n * That's why we create a new observable rather than returning the one\n * returned by subscribeToDiscoveredDevicesEvents.\n */\n const observable = new Observable<TransportDiscoveredDevice[]>(\n (subscriber) => {\n const subscription = this._nativeModuleWrapper\n .subscribeToDiscoveredDevicesEvents()\n .subscribe((devices) => {\n subscriber.next(devices);\n });\n this._nativeModuleWrapper.startScan().catch((error) => {\n this._loggerService.error(\"startDiscovering error\", error);\n subscriber.error(error);\n });\n return () => {\n subscription.unsubscribe();\n this._nativeModuleWrapper.stopScan().catch((error) => {\n this._loggerService.error(\"stopDiscovering error\", error);\n });\n };\n },\n );\n return observable;\n }\n\n connect(_params: {\n deviceId: DeviceId;\n onDisconnect: DisconnectHandler;\n }): Promise<Either<ConnectError, TransportConnectedDevice>> {\n return this._nativeModuleWrapper\n .connectDevice(_params.deviceId)\n .then((result) => {\n return result.map(\n ({ sessionId, transportDeviceModel: deviceModel }) => {\n const sub = this._nativeModuleWrapper\n .subscribeToDeviceDisconnectedEvents()\n .subscribe((device) => {\n if (device.sessionId === sessionId) {\n _params.onDisconnect(sessionId);\n sub.unsubscribe();\n }\n });\n\n return new TransportConnectedDevice({\n id: sessionId,\n deviceModel,\n sendApdu: async (apdu) => {\n return this._nativeModuleWrapper\n .sendApdu(sessionId
|
|
5
|
-
"mappings": "AAAA,OAGE,mBAAAA,EAIA,YAAAC,EACA,0BAAAC,EAEA,4BAAAC,MAGK,kCACP,OAAsB,QAAAC,EAAM,SAAAC,MA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CAC1D,CAAC,CACH,CAEA,0BAAoE,CA0BlE,OAnBmB,IAAIhB,EACpBa,GAAe,CACd,MAAMC,EAAe,KAAK,qBACvB,mCAAmC,EACnC,UAAWG,GAAY,CACtBJ,EAAW,KAAKI,CAAO,CACzB,CAAC,EACH,YAAK,qBAAqB,UAAU,EAAE,MAAOD,GAAU,CACrD,KAAK,eAAe,MAAM,yBAA0BA,CAAK,EACzDH,EAAW,MAAMG,CAAK,CACxB,CAAC,EACM,IAAM,CACXF,EAAa,YAAY,EACzB,KAAK,qBAAqB,SAAS,EAAE,MAAOE,GAAU,CACpD,KAAK,eAAe,MAAM,wBAAyBA,CAAK,CAC1D,CAAC,CACH,CACF,CACF,CAEF,CAEA,QAAQE,EAGoD,CAC1D,OAAO,KAAK,qBACT,cAAcA,EAAQ,QAAQ,EAC9B,KAAMC,GACEA,EAAO,IACZ,CAAC,CAAE,UAAAC,EAAW,qBAAsBC,CAAY,IAAM,CACpD,MAAMC,EAAM,KAAK,qBACd,oCAAoC,EACpC,UAAWP,GAAW,CACjBA,EAAO,YAAcK,IACvBF,EAAQ,aAAaE,CAAS,EAC9BE,EAAI,YAAY,EAEpB,CAAC,EAEH,OAAO,IAAIzB,EAAyB,CAClC,GAAIuB,EACJ,YAAAC,EACA,SAAU,
|
|
6
|
-
"names": ["DisconnectError", "LogLevel", "OpeningConnectionError", "TransportConnectedDevice", "Left", "Right", "Observable", "getObservableOfArraysNewItems", "TRANSPORT_IDENTIFIER", "SendApduError", "RNHidTransport", "_isSupported", "_nativeModuleWrapper", "_loggerServiceFactory", "log", "logLevel", "message", "options", "logMethod", "subscriber", "subscription", "device", "error", "devices", "_params", "result", "sessionId", "deviceModel", "sub", "apdu", "e"]
|
|
4
|
+
"sourcesContent": ["import {\n type ConnectError,\n type DeviceId,\n DisconnectError,\n type DisconnectHandler,\n type DmkError,\n type LoggerPublisherService,\n LogLevel,\n OpeningConnectionError,\n type Transport,\n TransportConnectedDevice,\n type TransportDiscoveredDevice,\n type TransportIdentifier,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, Left, Right } from \"purify-ts\";\nimport { Observable } from \"rxjs\";\n\nimport { getObservableOfArraysNewItems } from \"@api/helpers/getObservableOfArraysNewItems\";\nimport { TRANSPORT_IDENTIFIER } from \"@api/transport/rnHidTransportIdentifier\";\n\nimport { SendApduError } from \"./Errors\";\nimport { type NativeModuleWrapper } from \"./NativeModuleWrapper\";\n\nexport class RNHidTransport implements Transport {\n private _loggerService: LoggerPublisherService;\n\n constructor(\n private readonly _isSupported: boolean,\n private readonly _nativeModuleWrapper: NativeModuleWrapper,\n _loggerServiceFactory: (tag: string) => LoggerPublisherService,\n ) {\n this._loggerService = _loggerServiceFactory(\"RNHidTransport\");\n this._nativeModuleWrapper.subscribeToTransportLogs().subscribe((log) => {\n const [logLevel, message, options] = log;\n const logMethod = {\n [LogLevel.Fatal]: this._loggerService.error.bind(this._loggerService),\n [LogLevel.Error]: this._loggerService.error.bind(this._loggerService),\n [LogLevel.Warning]: this._loggerService.warn.bind(this._loggerService),\n [LogLevel.Info]: this._loggerService.info.bind(this._loggerService),\n [LogLevel.Debug]: this._loggerService.debug.bind(this._loggerService),\n }[logLevel];\n logMethod(message, options);\n });\n }\n\n getIdentifier(): TransportIdentifier {\n return TRANSPORT_IDENTIFIER;\n }\n\n isSupported(): boolean {\n return this._isSupported;\n }\n\n startDiscovering(): Observable<TransportDiscoveredDevice> {\n const observable = new Observable<TransportDiscoveredDevice>(\n (subscriber) => {\n const subscription = getObservableOfArraysNewItems(\n this._nativeModuleWrapper.subscribeToDiscoveredDevicesEvents(),\n (device) => device.id,\n ).subscribe(subscriber);\n\n this._nativeModuleWrapper.startScan().catch((error) => {\n subscriber.error(error);\n this._loggerService.error(\"startDiscovering error\", error);\n });\n return () => subscription.unsubscribe();\n },\n );\n return observable;\n }\n\n stopDiscovering(): void {\n this._nativeModuleWrapper.stopScan().catch((error) => {\n this._loggerService.error(\"stopDiscovering error\", error);\n });\n }\n\n listenToAvailableDevices(): Observable<TransportDiscoveredDevice[]> {\n /**\n * NB: here we need to define the unsubscribe logic as there is no\n * \"stopListeningToKnownDevices\" method.\n * That's why we create a new observable rather than returning the one\n * returned by subscribeToDiscoveredDevicesEvents.\n */\n const observable = new Observable<TransportDiscoveredDevice[]>(\n (subscriber) => {\n const subscription = this._nativeModuleWrapper\n .subscribeToDiscoveredDevicesEvents()\n .subscribe((devices) => {\n subscriber.next(devices);\n });\n this._nativeModuleWrapper.startScan().catch((error) => {\n this._loggerService.error(\"startDiscovering error\", error);\n subscriber.error(error);\n });\n return () => {\n subscription.unsubscribe();\n this._nativeModuleWrapper.stopScan().catch((error) => {\n this._loggerService.error(\"stopDiscovering error\", error);\n });\n };\n },\n );\n return observable;\n }\n\n connect(_params: {\n deviceId: DeviceId;\n onDisconnect: DisconnectHandler;\n }): Promise<Either<ConnectError, TransportConnectedDevice>> {\n return this._nativeModuleWrapper\n .connectDevice(_params.deviceId)\n .then((result) => {\n return result.map(\n ({ sessionId, transportDeviceModel: deviceModel }) => {\n const sub = this._nativeModuleWrapper\n .subscribeToDeviceDisconnectedEvents()\n .subscribe((device) => {\n if (device.sessionId === sessionId) {\n _params.onDisconnect(sessionId);\n sub.unsubscribe();\n }\n });\n\n return new TransportConnectedDevice({\n id: sessionId,\n deviceModel,\n sendApdu: async (\n apdu,\n triggersDisconnection = false,\n abortTimeout = -1,\n ) => {\n return this._nativeModuleWrapper\n .sendApdu(\n sessionId,\n apdu,\n triggersDisconnection,\n abortTimeout,\n )\n .catch((e) => Left(new SendApduError(e)));\n },\n transport: this.getIdentifier(),\n type: \"USB\",\n });\n },\n );\n })\n .catch((error) => {\n return Left(new OpeningConnectionError(error));\n });\n }\n\n disconnect(_params: {\n connectedDevice: TransportConnectedDevice;\n }): Promise<Either<DmkError, void>> {\n return this._nativeModuleWrapper\n .disconnectDevice(_params.connectedDevice.id)\n .then(() => Right(undefined))\n .catch((error) => {\n return Left(new DisconnectError(error));\n });\n }\n}\n"],
|
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BA,EAAQ,gBAAgB,EAAE,EAC3C,KAAK,IAAMnB,EAAM,MAAS,CAAC,EAC3B,MAAOiB,GACClB,EAAK,IAAIJ,EAAgBsB,CAAK,CAAC,CACvC,CACL,CACF",
|
|
6
|
+
"names": ["DisconnectError", "LogLevel", "OpeningConnectionError", "TransportConnectedDevice", "Left", "Right", "Observable", "getObservableOfArraysNewItems", "TRANSPORT_IDENTIFIER", "SendApduError", "RNHidTransport", "_isSupported", "_nativeModuleWrapper", "_loggerServiceFactory", "log", "logLevel", "message", "options", "logMethod", "subscriber", "subscription", "device", "error", "devices", "_params", "result", "sessionId", "deviceModel", "sub", "apdu", "triggersDisconnection", "abortTimeout", "e"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
30
|
"prebuild": "rimraf lib",
|
|
31
|
-
"build": "pnpm
|
|
31
|
+
"build": "pnpm ldmk-tool build --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
32
32
|
"dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
|
|
33
|
-
"watch:builds": "pnpm
|
|
33
|
+
"watch:builds": "pnpm ldmk-tool watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
34
34
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"",
|
|
35
35
|
"lint": "eslint",
|
|
36
36
|
"lint:fix": "pnpm lint --fix",
|
|
@@ -43,24 +43,24 @@
|
|
|
43
43
|
"test:coverage": "vitest run --coverage --passWithNoTests"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@sentry/minimal": "
|
|
47
|
-
"purify-ts": "
|
|
48
|
-
"uuid": "
|
|
46
|
+
"@sentry/minimal": "catalog:",
|
|
47
|
+
"purify-ts": "catalog:",
|
|
48
|
+
"uuid": "catalog:"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@ledgerhq/device-management-kit": "workspace:*",
|
|
52
|
-
"@ledgerhq/esbuild-tools": "workspace:*",
|
|
53
52
|
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
53
|
+
"@ledgerhq/ldmk-tool": "workspace:*",
|
|
54
54
|
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
55
55
|
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
56
56
|
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
57
|
-
"@types/uuid": "
|
|
58
|
-
"react-native": "
|
|
59
|
-
"rxjs": "
|
|
57
|
+
"@types/uuid": "catalog:",
|
|
58
|
+
"react-native": "catalog:",
|
|
59
|
+
"rxjs": "catalog:"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@ledgerhq/device-management-kit": "workspace:*",
|
|
63
63
|
"react-native": ">0.74.1",
|
|
64
|
-
"rxjs": "
|
|
64
|
+
"rxjs": "catalog:"
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -17,6 +17,6 @@ export declare class DefaultNativeModuleWrapper implements NativeModuleWrapper {
|
|
|
17
17
|
subscribeToTransportLogs(): Observable<LogParams>;
|
|
18
18
|
connectDevice(uid: string): Promise<InternalConnectionResult>;
|
|
19
19
|
disconnectDevice(sessionId: string): Promise<void>;
|
|
20
|
-
sendApdu(sessionId: string, apdu: Uint8Array): Promise<SendApduResult>;
|
|
20
|
+
sendApdu(sessionId: string, apdu: Uint8Array, triggersDisconnection: boolean, abortTimeout: number): Promise<SendApduResult>;
|
|
21
21
|
}
|
|
22
22
|
//# sourceMappingURL=DefaultNativeModuleWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultNativeModuleWrapper.d.ts","sourceRoot":"","sources":["../../../../src/api/bridge/DefaultNativeModuleWrapper.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK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,oCAAoC,CAAC;AAC9E,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAiB9B,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEzD,qBAAa,0BAA2B,YAAW,mBAAmB;IACpE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAC1D,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAwB;gBAEnD,IAAI,EAAE;QAChB,YAAY,EAAE,yBAAyB,CAAC;QACxC,qBAAqB,EAAE,qBAAqB,CAAC;KAC9C;IAKD,SAAS;IAIT,QAAQ;IAIR,kCAAkC,IAAI,UAAU,CAC9C,KAAK,CAAC,yBAAyB,CAAC,CACjC;IAyBD,mCAAmC,IAAI,UAAU,CAAC,0BAA0B,CAAC;IAkB7E,wBAAwB,IAAI,UAAU,CAAC,SAAS,CAAC;IAgB3C,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAQ7D,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,QAAQ,CACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,UAAU,EAChB,qBAAqB,EAAE,OAAO,EAC9B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,cAAc,CAAC;CAS3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/api/bridge/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,qBAAqB,EAG1B,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/api/bridge/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,qBAAqB,EAG1B,KAAK,SAAS,EAGd,KAAK,cAAc,EAEnB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC/B,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EACnC,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,oBAAoB,EAC1B,MAAM,SAAS,CAAC;AAEjB,wBAAgB,kCAAkC,CAChD,kBAAkB,EAAE,kBAAkB,EACtC,qBAAqB,EAAE,qBAAqB,GAC3C,oBAAoB,GAAG,IAAI,CAM7B;AAED,wBAAgB,mDAAmD,CACjE,YAAY,EAAE,qBAAqB,EACnC,qBAAqB,EAAE,qBAAqB,GAC3C,yBAAyB,GAAG,IAAI,CAalC;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,SAAS,GAAG,SAAS,CA8BpE;AAMD,wBAAgB,2CAA2C,CACzD,MAAM,EAAE,8BAA8B,EACtC,qBAAqB,EAAE,qBAAqB,GAC3C,wBAAwB,CAgB1B;AAED,wBAAgB,uCAAuC,CACrD,MAAM,EAAE,oBAAoB,GAC3B,cAAc,CAgBhB;AAED,wBAAgB,iDAAiD,CAC/D,0BAA0B,EAAE,0BAA0B,GACrD,0BAA0B,CAI5B"}
|
|
@@ -30,7 +30,7 @@ export type NativeSendApduResult = {
|
|
|
30
30
|
apdu: string;
|
|
31
31
|
} | {
|
|
32
32
|
success: false;
|
|
33
|
-
error: string;
|
|
33
|
+
error: string | "SendApduTimeout";
|
|
34
34
|
};
|
|
35
35
|
export type NativeDeviceConnectionLost = {
|
|
36
36
|
id: string;
|
|
@@ -55,7 +55,7 @@ export type NativeTransportModuleType = {
|
|
|
55
55
|
stopScan: () => Promise<void>;
|
|
56
56
|
connectDevice: (uid: string) => Promise<NativeInternalConnectionResult>;
|
|
57
57
|
disconnectDevice: (sessionId: string) => Promise<void>;
|
|
58
|
-
sendApdu: (sessionId: string, apdu: string) => Promise<NativeSendApduResult>;
|
|
58
|
+
sendApdu: (sessionId: string, apdu: string, triggersDisconnection: boolean, abortTimeout: number) => Promise<NativeSendApduResult>;
|
|
59
59
|
} & NativeModule;
|
|
60
60
|
export {};
|
|
61
61
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/api/bridge/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACxD,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,kBAAkB,CAAC;CAClC,CAAC;AAEF,KAAK,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,cAAc,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GACtC;IACE,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,kBAAkB,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB,GACD;IACE,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,MAAM,MAAM,oBAAoB,GAC5B;IACE,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,MAAM,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MAAM,0BAA0B,GAAG;IACvC,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;GAEG;AAEH,wBAAwB;AACxB,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,MAAM,MAAM,6BAA6B,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEzE,mBAAmB;AACnB,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC;AAExC,yBAAyB;AACzB,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAC9D,MAAM,MAAM,8BAA8B,GAAG,0BAA0B,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACxE,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,QAAQ,EAAE,CACR,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,qBAAqB,EAAE,OAAO,EAC9B,YAAY,EAAE,MAAM,KACjB,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACpC,GAAG,YAAY,CAAC"}
|
|
@@ -18,6 +18,6 @@ export interface NativeModuleWrapper {
|
|
|
18
18
|
subscribeToTransportLogs(): Observable<LogParams>;
|
|
19
19
|
connectDevice(uid: string): Promise<InternalConnectionResult>;
|
|
20
20
|
disconnectDevice(uid: string): Promise<void>;
|
|
21
|
-
sendApdu(sessionId: string, apdu: Uint8Array): Promise<SendApduResult>;
|
|
21
|
+
sendApdu(sessionId: string, apdu: Uint8Array, triggersDisconnection: boolean, abortTimeout: number): Promise<SendApduResult>;
|
|
22
22
|
}
|
|
23
23
|
//# sourceMappingURL=NativeModuleWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeModuleWrapper.d.ts","sourceRoot":"","sources":["../../../../src/api/transport/NativeModuleWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC/B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAChC,MAAM,SAAS,CAAC;AAEjB;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,kCAAkC,IAAI,UAAU,CAC9C,KAAK,CAAC,yBAAyB,CAAC,CACjC,CAAC;IACF,mCAAmC,IAAI,UAAU,CAAC,0BAA0B,CAAC,CAAC;IAC9E,wBAAwB,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;IAClD,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC9D,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,QAAQ,
|
|
1
|
+
{"version":3,"file":"NativeModuleWrapper.d.ts","sourceRoot":"","sources":["../../../../src/api/transport/NativeModuleWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC/B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAChC,MAAM,SAAS,CAAC;AAEjB;;;;;;;;GAQG;AACH,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