@ledgerhq/device-transport-kit-react-native-ble 0.0.0-develop-20250412001122
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/LICENSE.MD +202 -0
- package/README.md +92 -0
- package/lib/cjs/api/index.js +2 -0
- package/lib/cjs/api/index.js.map +7 -0
- package/lib/cjs/api/model/Const.js +2 -0
- package/lib/cjs/api/model/Const.js.map +7 -0
- package/lib/cjs/api/model/Errors.js +2 -0
- package/lib/cjs/api/model/Errors.js.map +7 -0
- package/lib/cjs/api/transport/RNBleApduSender.js +2 -0
- package/lib/cjs/api/transport/RNBleApduSender.js.map +7 -0
- package/lib/cjs/api/transport/RNBleApduSender.test.js +2 -0
- package/lib/cjs/api/transport/RNBleApduSender.test.js.map +7 -0
- package/lib/cjs/api/transport/RNBleTransport.js +2 -0
- package/lib/cjs/api/transport/RNBleTransport.js.map +7 -0
- package/lib/cjs/api/transport/RNBleTransport.test.js +2 -0
- package/lib/cjs/api/transport/RNBleTransport.test.js.map +7 -0
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/index.js.map +7 -0
- package/lib/cjs/package.json +64 -0
- package/lib/esm/api/index.js +2 -0
- package/lib/esm/api/index.js.map +7 -0
- package/lib/esm/api/model/Const.js +2 -0
- package/lib/esm/api/model/Const.js.map +7 -0
- package/lib/esm/api/model/Errors.js +2 -0
- package/lib/esm/api/model/Errors.js.map +7 -0
- package/lib/esm/api/transport/RNBleApduSender.js +2 -0
- package/lib/esm/api/transport/RNBleApduSender.js.map +7 -0
- package/lib/esm/api/transport/RNBleApduSender.test.js +2 -0
- package/lib/esm/api/transport/RNBleApduSender.test.js.map +7 -0
- package/lib/esm/api/transport/RNBleTransport.js +2 -0
- package/lib/esm/api/transport/RNBleTransport.js.map +7 -0
- package/lib/esm/api/transport/RNBleTransport.test.js +2 -0
- package/lib/esm/api/transport/RNBleTransport.test.js.map +7 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +7 -0
- package/lib/esm/package.json +64 -0
- package/lib/types/api/index.d.ts +3 -0
- package/lib/types/api/index.d.ts.map +1 -0
- package/lib/types/api/model/Const.d.ts +4 -0
- package/lib/types/api/model/Const.d.ts.map +1 -0
- package/lib/types/api/model/Errors.d.ts +27 -0
- package/lib/types/api/model/Errors.d.ts.map +1 -0
- package/lib/types/api/transport/RNBleApduSender.d.ts +40 -0
- package/lib/types/api/transport/RNBleApduSender.d.ts.map +1 -0
- package/lib/types/api/transport/RNBleApduSender.test.d.ts +2 -0
- package/lib/types/api/transport/RNBleApduSender.test.d.ts.map +1 -0
- package/lib/types/api/transport/RNBleTransport.d.ts +169 -0
- package/lib/types/api/transport/RNBleTransport.d.ts.map +1 -0
- package/lib/types/api/transport/RNBleTransport.test.d.ts +2 -0
- package/lib/types/api/transport/RNBleTransport.test.d.ts.map +1 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/api/transport/RNBleTransport.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { type PermissionsAndroid, type Platform } from \"react-native\";\nimport { type PermissionStatus } from \"react-native/Libraries/PermissionsAndroid/PermissionsAndroid\";\nimport { type BleManager } from \"react-native-ble-plx\";\nimport {\n type ApduReceiverServiceFactory,\n type ApduSenderServiceFactory,\n BleDeviceInfos,\n DeviceConnectionStateMachine,\n type DeviceConnectionStateMachineParams,\n type DeviceModelDataSource,\n DeviceModelId,\n type DmkConfig,\n type LoggerPublisherService,\n TransportConnectedDevice,\n TransportDeviceModel,\n type TransportDiscoveredDevice,\n UnknownDeviceError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { firstValueFrom } from \"rxjs\";\nimport { beforeEach, expect, type Mock } from \"vitest\";\n\nimport { BleNotSupported } from \"@api/model/Errors\";\n\nimport { type RNBleApduSenderDependencies } from \"./RNBleApduSender\";\nimport { RNBleTransport, RNBleTransportFactory } from \"./RNBleTransport\";\n\nconst fakeLogger = {\n error: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n debug: vi.fn(),\n};\n\nvi.mock(\"react-native\", () => ({\n Platform: {},\n PermissionsAndroid: {},\n}));\n\nvi.mock(\"react-native-ble-plx\", () => ({\n BleManager: vi.fn(),\n}));\n\nconst expectAndroidSupportedResult = async (\n params: {\n version: number;\n permissions: Record<string, string>;\n requestPermissionResult: {\n \"android.permission.BLUETOOTH_CONNECT\": PermissionStatus;\n \"android.permission.BLUETOOTH_SCAN\": PermissionStatus;\n \"android.permission.ACCESS_FINE_LOCATION\": PermissionStatus;\n };\n accessFineLocationResult?: PermissionStatus;\n },\n expects: {\n isSupported: boolean;\n callRequestPermission: boolean;\n },\n) => {\n // given\n const platform = { OS: \"android\", Version: params.version };\n const permissionsAndroid = {\n request: vi.fn().mockImplementation((key: string) =>\n Promise.resolve(\n {\n ACCESS_FINE_LOCATION: params.accessFineLocationResult,\n }[key],\n ),\n ),\n PERMISSIONS: params.permissions,\n RESULTS: {\n GRANTED: \"granted\",\n },\n requestMultiple: vi\n .fn()\n .mockImplementation(() =>\n Promise.resolve(params.requestPermissionResult),\n ),\n };\n const transport = new RNBleTransport(\n \"DeviceModelDataSource\" as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n platform as Platform,\n permissionsAndroid as unknown as PermissionsAndroid,\n );\n // when\n await transport.requestPermission();\n const isSupported = transport.isSupported();\n // then\n if (expects.callRequestPermission) {\n expect(permissionsAndroid.request).toHaveBeenCalledWith(\n \"ACCESS_FINE_LOCATION\",\n );\n }\n expect(isSupported).toBe(expects.isSupported);\n};\n\ndescribe(\"RNBleTransportFactory\", () => {\n it(\"should return a RNBleTransport\", () => {\n const fakeArgs = {\n deviceModelDataSource:\n \"DeviceModelDataSource\" as unknown as DeviceModelDataSource,\n loggerServiceFactory: () =>\n fakeLogger as unknown as LoggerPublisherService,\n apduSenderServiceFactory:\n (() => {}) as unknown as ApduSenderServiceFactory,\n apduReceiverServiceFactory:\n (() => {}) as unknown as ApduReceiverServiceFactory,\n config: {} as DmkConfig,\n };\n // when\n const transport = RNBleTransportFactory(fakeArgs);\n // then\n expect(transport).toBeInstanceOf(RNBleTransport);\n });\n});\n\ndescribe(\"RNBleTransport\", () => {\n const fakePlaftorm = { OS: \"ios\" };\n const fakeDeviceModel = new TransportDeviceModel({\n id: DeviceModelId.FLEX,\n productName: \"Ledger Flex\",\n usbProductId: 0x70,\n bootloaderUsbProductId: 0x0007,\n usbOnly: false,\n memorySize: 1533 * 1024,\n masks: [0x33300000],\n });\n const getBluetoothServicesMock = vi.fn(() => [\"ledgerId\"]);\n const getBluetoothServicesInfosMock = vi.fn(() => ({\n ledgerId: new BleDeviceInfos(\n fakeDeviceModel,\n \"serviceUuid\",\n \"notifyUuid\",\n \"writeCmdUuid\",\n \"readCmdUuid\",\n ),\n }));\n const fakeDataSource = {\n getBluetoothServices: getBluetoothServicesMock,\n getBluetoothServicesInfos: getBluetoothServicesInfosMock,\n };\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"getIdentifier\", () => {\n it(\"should return rnBleTransportIdentifier\", () => {\n // given\n const transport = new RNBleTransport(\n \"DeviceModelDataSource\" as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n );\n\n // when\n const identifier = transport.getIdentifier();\n\n // then\n expect(identifier).toStrictEqual(\"RN_BLE\");\n });\n });\n\n describe(\"isSupported\", () => {\n it(\"should return true if platform is ios\", async () => {\n // given\n const platform = { OS: \"ios\" };\n const transport = new RNBleTransport(\n \"DeviceModelDataSource\" as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n platform as Platform,\n );\n\n // when\n await transport.requestPermission();\n const isSupported = transport.isSupported();\n\n // then\n expect(isSupported).toBe(true);\n });\n\n it(\"should return true if platform is android and apiLevel < 31 with good permissions\", async () => {\n await expectAndroidSupportedResult(\n {\n version: 30,\n permissions: {\n ACCESS_FINE_LOCATION: \"ACCESS_FINE_LOCATION\",\n BLUETOOTH_SCAN: \"BLUETOOTH_SCAN\",\n BLUETOOTH_CONNECT: \"BLUETOOTH_CONNECT\",\n },\n requestPermissionResult: {\n \"android.permission.BLUETOOTH_CONNECT\": \"granted\",\n \"android.permission.BLUETOOTH_SCAN\": \"granted\",\n \"android.permission.ACCESS_FINE_LOCATION\": \"granted\",\n },\n },\n {\n isSupported: true,\n callRequestPermission: true,\n },\n );\n });\n\n it(\"should return true if platform is android and apiLevel >= 31 with good permissions\", async () => {\n await expectAndroidSupportedResult(\n {\n version: 31,\n permissions: {\n ACCESS_FINE_LOCATION: \"ACCESS_FINE_LOCATION\",\n BLUETOOTH_SCAN: \"BLUETOOTH_SCAN\",\n BLUETOOTH_CONNECT: \"BLUETOOTH_CONNECT\",\n },\n requestPermissionResult: {\n \"android.permission.BLUETOOTH_CONNECT\": \"granted\",\n \"android.permission.BLUETOOTH_SCAN\": \"granted\",\n \"android.permission.ACCESS_FINE_LOCATION\": \"granted\",\n },\n },\n {\n isSupported: true,\n callRequestPermission: false,\n },\n );\n });\n\n it(\"should return false if platform is android with bad permissions\", async () => {\n await expectAndroidSupportedResult(\n {\n version: 31,\n permissions: {\n ACCESS_FINE_LOCATION: \"\",\n BLUETOOTH_SCAN: \"\",\n BLUETOOTH_CONNECT: \"BLUETOOTH_CONNECT\",\n },\n requestPermissionResult: {\n \"android.permission.ACCESS_FINE_LOCATION\": \"denied\",\n \"android.permission.BLUETOOTH_CONNECT\": \"granted\",\n \"android.permission.BLUETOOTH_SCAN\": \"granted\",\n },\n },\n {\n isSupported: false,\n callRequestPermission: false,\n },\n );\n });\n\n it(\"should return false if platform is android and denied permissions\", async () => {\n await expectAndroidSupportedResult(\n {\n version: 31,\n permissions: {\n ACCESS_FINE_LOCATION: \"ACCESS_FINE_LOCATION\",\n BLUETOOTH_SCAN: \"BLUETOOTH_SCAN\",\n BLUETOOTH_CONNECT: \"BLUETOOTH_CONNECT\",\n },\n requestPermissionResult: {\n \"android.permission.BLUETOOTH_CONNECT\": \"denied\",\n \"android.permission.BLUETOOTH_SCAN\": \"denied\",\n \"android.permission.ACCESS_FINE_LOCATION\": \"denied\",\n },\n },\n {\n isSupported: false,\n callRequestPermission: false,\n },\n );\n });\n\n it(\"should return false if platform isn't android nor ios\", async () => {\n // given\n const transport = new RNBleTransport(\n \"DeviceModelDataSource\" as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n { OS: \"windows\" } as Platform,\n );\n\n // when\n await transport.requestPermission();\n const isSupported = transport.isSupported();\n\n // then\n expect(isSupported).toBe(false);\n });\n });\n\n describe(\"startDiscovering\", () => {\n it(\"should throw error if transport is not supported\", () => {\n // given\n const platform = { OS: \"windows\" };\n\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n platform as Platform,\n );\n\n try {\n // when\n transport.startDiscovering();\n } catch (e) {\n // then\n expect(e).toBeInstanceOf(BleNotSupported);\n }\n });\n\n it(\"should emit discovered known device\", () =>\n new Promise((done) => {\n // given\n const bleManager = {\n connectedDevices: vi.fn().mockResolvedValueOnce([\n {\n readRSSI: vi.fn().mockResolvedValueOnce({\n discoverAllServicesAndCharacteristics: vi\n .fn()\n .mockResolvedValueOnce({\n services: vi.fn().mockResolvedValue({}),\n serviceUUIDs: [\"ledgerId\"],\n rssi: 42,\n id: \"id\",\n localName: \"name\",\n }),\n }),\n },\n ]),\n startDeviceScan: vi.fn(),\n stopDeviceScan: vi.fn(),\n onDeviceDisconnected: vi.fn(),\n } as unknown as BleManager;\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n fakePlaftorm as Platform,\n {} as unknown as PermissionsAndroid,\n () => bleManager,\n );\n\n // when\n const observable = transport.startDiscovering();\n\n // then\n const subscription = observable.subscribe({\n next: (discoveredDevice) => {\n expect(discoveredDevice).toStrictEqual({\n id: \"id\",\n name: \"name\",\n deviceModel: fakeDeviceModel,\n transport: \"RN_BLE\",\n rssi: 42,\n });\n subscription.unsubscribe();\n done(void 0);\n },\n error: (e) => {\n if (subscription && !subscription.closed) {\n subscription.unsubscribe();\n }\n throw e;\n },\n complete: () => {\n if (subscription && !subscription.closed) {\n subscription.unsubscribe();\n }\n throw new Error(\"complete should not be called\");\n },\n });\n }));\n\n it(\"should emit discovered new device\", () =>\n new Promise((done) => {\n // given\n let scanInterval: NodeJS.Timeout;\n\n const startScan = vi.fn((_uuids, _options, listener) => {\n scanInterval = setInterval(() => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n listener(null, {\n id: \"id\",\n localName: \"name\",\n serviceUUIDs: [\"ledgerId\"],\n rssi: 42,\n });\n }, 500);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n listener(null, {\n id: \"43\",\n localName: \"name43\",\n serviceUUIDs: [\"notLedgerId\"],\n rssi: 43,\n });\n });\n\n const stopScan = vi.fn(() => {\n clearInterval(scanInterval);\n });\n\n const bleManager = {\n connectedDevices: vi.fn().mockResolvedValueOnce([]),\n startDeviceScan: startScan,\n stopDeviceScan: stopScan,\n onDeviceDisconnected: vi.fn(),\n } as unknown as BleManager;\n\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n fakePlaftorm as Platform,\n {} as unknown as PermissionsAndroid,\n () => bleManager,\n );\n\n // when\n const observable = transport.startDiscovering();\n\n // then\n const subscription = observable.subscribe({\n next: (discoveredDevice) => {\n expect(discoveredDevice).toStrictEqual({\n id: \"id\",\n name: \"name\",\n deviceModel: fakeDeviceModel,\n transport: \"RN_BLE\",\n rssi: 42,\n });\n subscription.unsubscribe();\n done(void 0);\n },\n error: (e) => {\n if (subscription && !subscription.closed) {\n subscription.unsubscribe();\n }\n throw e;\n },\n complete: () => {\n if (subscription && !subscription.closed) {\n subscription.unsubscribe();\n }\n throw new Error(\"complete should not be called\");\n },\n });\n }));\n\n it(\"should emit both known and new device\", () =>\n new Promise((done) => {\n // given\n let scanInterval: NodeJS.Timeout;\n const startScan = vi.fn((_uuids, _options, listener) => {\n scanInterval = setInterval(() => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n listener(null, {\n id: \"newDeviceId\",\n localName: \"newDeviceName\",\n serviceUUIDs: [\"ledgerId\"],\n rssi: 42,\n });\n }, 500);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n listener(null, {\n id: \"43\",\n localName: \"name43\",\n serviceUUIDs: [\"notLedgerId\"],\n rssi: 43,\n });\n });\n\n const stopScan = vi.fn(() => {\n clearInterval(scanInterval);\n });\n\n const fakeConnectedDevices = vi.fn().mockResolvedValueOnce([\n {\n readRSSI: vi.fn().mockResolvedValueOnce({\n discoverAllServicesAndCharacteristics: vi\n .fn()\n .mockResolvedValueOnce({\n services: vi.fn().mockResolvedValueOnce({}),\n serviceUUIDs: [\"ledgerId\"],\n rssi: 64,\n id: \"knownDeviceId\",\n localName: \"knownDeviceName\",\n }),\n }),\n },\n ]);\n\n const bleManager = {\n connectedDevices: fakeConnectedDevices,\n startDeviceScan: startScan,\n stopDeviceScan: stopScan,\n onDeviceDisconnected: vi.fn(),\n } as unknown as BleManager;\n\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n fakePlaftorm as Platform,\n {} as unknown as PermissionsAndroid,\n () => bleManager,\n );\n\n // when\n const obs = transport.startDiscovering();\n const discoveredDevices: Record<string, TransportDiscoveredDevice> = {};\n\n // then\n const subscription = obs.subscribe({\n next: (device) => {\n discoveredDevices[device.id] = device;\n if (Object.values(discoveredDevices).length === 2) {\n subscription.unsubscribe();\n expect(Object.values(discoveredDevices)).toStrictEqual([\n {\n id: \"knownDeviceId\",\n name: \"knownDeviceName\",\n deviceModel: fakeDeviceModel,\n transport: \"RN_BLE\",\n rssi: 64,\n },\n {\n id: \"newDeviceId\",\n name: \"newDeviceName\",\n deviceModel: fakeDeviceModel,\n transport: \"RN_BLE\",\n rssi: 42,\n },\n ]);\n done(void 0);\n }\n },\n });\n }));\n });\n\n describe(\"stopDiscovering\", () => {\n it(\"should call ble manager stop scan on stop discovering\", () => {\n // given\n const fakeStopDeviceScan = vi.fn();\n const bleManager = {\n connectedDevices: vi.fn().mockResolvedValueOnce([]),\n startDeviceScan: vi.fn(),\n stopDeviceScan: fakeStopDeviceScan,\n onDeviceDisconnected: vi.fn(),\n } as unknown as BleManager;\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n fakePlaftorm as Platform,\n {} as unknown as PermissionsAndroid,\n () => bleManager,\n );\n\n // when\n transport.stopDiscovering();\n\n // then\n expect(fakeStopDeviceScan).toHaveBeenCalled();\n });\n\n it(\"should call ble manager stop scan when unsubscribe startDiscovering obs\", () => {\n // given\n let scanInterval: NodeJS.Timeout | undefined;\n\n const startScan = vi.fn((_uuids, _options, listener) => {\n scanInterval = setInterval(() => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n listener(null, {\n id: \"id\",\n localName: \"name\",\n serviceUUIDs: [\"ledgerId\"],\n rssi: 42,\n });\n }, 500);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n listener(null, {\n id: \"43\",\n localName: \"name43\",\n serviceUUIDs: [\"notLedgerId\"],\n rssi: 43,\n });\n });\n\n const stopScan = vi.fn(() => {\n clearInterval(scanInterval);\n scanInterval = undefined;\n });\n\n const bleManager = {\n connectedDevices: vi.fn().mockResolvedValueOnce([]),\n startDeviceScan: startScan,\n stopDeviceScan: stopScan,\n onDeviceDisconnected: vi.fn(),\n } as unknown as BleManager;\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n fakePlaftorm as Platform,\n {} as unknown as PermissionsAndroid,\n () => bleManager,\n );\n\n // when\n transport.startDiscovering().subscribe().unsubscribe();\n\n // then\n expect(startScan).toHaveBeenCalled();\n expect(stopScan).toHaveBeenCalled();\n });\n });\n\n describe(\"listenToAvailableDevices\", () => {\n it(\"should call startScan and connectedDevices from ble manager\", () =>\n new Promise((done) => {\n // given\n let scanInterval: NodeJS.Timeout | undefined;\n\n const startScan = vi.fn((_uuids, _options, listener) => {\n scanInterval = setInterval(() => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n listener(null, {\n id: \"id\",\n localName: \"name\",\n serviceUUIDs: [\"ledgerId\"],\n rssi: 42,\n });\n }, 500);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n listener(null, {\n id: \"43\",\n localName: \"name43\",\n serviceUUIDs: [\"notLedgerId\"],\n rssi: 43,\n });\n });\n const stopScan = vi.fn(() => {\n clearInterval(scanInterval);\n scanInterval = undefined;\n });\n const fakeConnectedDevices = vi.fn().mockResolvedValueOnce([\n {\n readRSSI: vi.fn().mockResolvedValueOnce({\n discoverAllServicesAndCharacteristics: vi\n .fn()\n .mockResolvedValueOnce({\n services: vi.fn().mockResolvedValueOnce({}),\n serviceUUIDs: [\"ledgerId\"],\n rssi: 64,\n id: \"knownDeviceId\",\n localName: \"knownDeviceName\",\n }),\n }),\n },\n ]);\n const bleManager = {\n connectedDevices: fakeConnectedDevices,\n startDeviceScan: startScan,\n stopDeviceScan: stopScan,\n onDeviceDisconnected: vi.fn(),\n isDeviceConnected: vi.fn(),\n } as unknown as BleManager;\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n fakePlaftorm as Platform,\n {} as unknown as PermissionsAndroid,\n () => bleManager,\n );\n\n // when\n const sub = transport.listenToAvailableDevices().subscribe({\n next: (devices) => {\n if (devices.length === 2) {\n // then\n expect(devices).toEqual([\n {\n id: \"knownDeviceId\",\n name: \"knownDeviceName\",\n deviceModel: fakeDeviceModel,\n transport: \"RN_BLE\",\n rssi: 64,\n },\n {\n id: \"id\",\n name: \"name\",\n deviceModel: fakeDeviceModel,\n transport: \"RN_BLE\",\n rssi: 42,\n },\n ]);\n sub.unsubscribe();\n done(void 0);\n }\n },\n });\n }));\n });\n\n describe(\"connect\", () => {\n let fakeConnectedDevices: Mock;\n\n beforeEach(() => {\n fakeConnectedDevices = vi.fn().mockResolvedValueOnce([\n {\n readRSSI: vi.fn().mockResolvedValueOnce({\n discoverAllServicesAndCharacteristics: vi\n .fn()\n .mockResolvedValueOnce({\n services: vi.fn().mockResolvedValueOnce({}),\n serviceUUIDs: [\"ledgerId\"],\n rssi: 64,\n id: \"deviceId\",\n localName: \"knownDeviceName\",\n }),\n }),\n },\n ]);\n });\n\n it(\"should throw an error if device id is unknown\", async () => {\n // given\n const bleManager = {\n connectedDevices: vi.fn(),\n startDeviceScan: vi.fn(),\n stopDeviceScan: vi.fn(),\n onDeviceDisconnected: vi.fn(),\n isDeviceConnected: vi.fn(),\n } as unknown as BleManager;\n\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n fakePlaftorm as Platform,\n {} as unknown as PermissionsAndroid,\n () => bleManager,\n );\n\n // when\n const result = await transport.connect({\n deviceId: \"42\",\n onDisconnect: vi.fn(),\n });\n\n // then\n expect(result).toEqual(Left(new UnknownDeviceError(`Unknown device 42`)));\n });\n\n it(\"should connect to a discovered device with correct MTU and discover services and setup apdu sender\", async () => {\n // given\n const bleManager = {\n connectedDevices: fakeConnectedDevices,\n startDeviceScan: vi.fn(),\n stopDeviceScan: vi.fn(),\n onDeviceDisconnected: vi.fn(),\n isDeviceConnected: vi.fn(),\n monitorCharacteristicForDevice: vi.fn(),\n writeCharacteristicWithoutResponseForDevice: vi.fn(),\n connectToDevice: vi.fn().mockResolvedValueOnce({\n id: \"deviceId\",\n rssi: 64,\n }),\n discoverAllServicesAndCharacteristicsForDevice: vi.fn(),\n } as unknown as BleManager;\n\n const fakeSetupConnection = vi.fn();\n const deviceConnectionStateMachineFactory = vi.fn().mockReturnValue({\n sendApdu: vi.fn(),\n });\n const deviceApduSenderFactory = vi.fn().mockReturnValue({\n setupConnection: fakeSetupConnection,\n });\n\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n fakePlaftorm as Platform,\n {} as unknown as PermissionsAndroid,\n () => bleManager,\n deviceConnectionStateMachineFactory,\n deviceApduSenderFactory,\n );\n\n // when\n const device = await firstValueFrom(transport.startDiscovering());\n const result = await transport.connect({\n deviceId: device.id,\n onDisconnect: vi.fn(),\n });\n\n // then\n expect(result.isRight()).toBe(true);\n expect(bleManager.connectToDevice).toHaveBeenCalledWith(\"deviceId\", {\n requestMTU: 156,\n });\n expect(\n bleManager.discoverAllServicesAndCharacteristicsForDevice,\n ).toHaveBeenCalledWith(\"deviceId\");\n expect(fakeSetupConnection).toHaveBeenCalled();\n });\n\n it(\"should return a connected device which calls state machine sendApdu\", async () => {\n // given\n const bleManager = {\n connectedDevices: fakeConnectedDevices,\n startDeviceScan: vi.fn(),\n stopDeviceScan: vi.fn(),\n onDeviceDisconnected: vi.fn(),\n isDeviceConnected: vi.fn(),\n monitorCharacteristicForDevice: vi.fn(),\n writeCharacteristicWithoutResponseForDevice: vi.fn(),\n connectToDevice: vi.fn().mockResolvedValueOnce({\n id: \"deviceId\",\n rssi: 64,\n }),\n discoverAllServicesAndCharacteristicsForDevice: vi.fn(),\n } as unknown as BleManager;\n\n const fakeSendApdu = vi.fn();\n const deviceConnectionStateMachineFactory = vi.fn().mockReturnValue({\n sendApdu: fakeSendApdu,\n });\n const deviceApduSenderFactory = vi.fn().mockReturnValue({\n setupConnection: vi.fn(),\n });\n\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n fakePlaftorm as Platform,\n {} as unknown as PermissionsAndroid,\n () => bleManager,\n deviceConnectionStateMachineFactory,\n deviceApduSenderFactory,\n );\n\n // when\n const device = await firstValueFrom(transport.startDiscovering());\n const result = await transport.connect({\n deviceId: device.id,\n onDisconnect: vi.fn(),\n });\n\n const connectedDevice = result.extract() as TransportConnectedDevice;\n connectedDevice.sendApdu(Uint8Array.from([0x43, 0x32]));\n // then\n expect(result).toEqual(\n Right(\n new TransportConnectedDevice({\n id: \"deviceId\",\n deviceModel: fakeDeviceModel,\n type: \"BLE\",\n transport: \"RN_BLE\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n sendApdu: expect.any(Function),\n }),\n ),\n );\n expect(fakeSendApdu).toHaveBeenCalledWith(Uint8Array.from([0x43, 0x32]));\n });\n });\n\n describe(\"disconnect\", () => {\n let fakeConnectedDevices: Mock;\n\n beforeEach(() => {\n fakeConnectedDevices = vi.fn().mockResolvedValueOnce([\n {\n readRSSI: vi.fn().mockResolvedValueOnce({\n discoverAllServicesAndCharacteristics: vi\n .fn()\n .mockResolvedValueOnce({\n services: vi.fn().mockResolvedValueOnce({}),\n serviceUUIDs: [\"ledgerId\"],\n rssi: 64,\n id: \"deviceId\",\n localName: \"knownDeviceName\",\n }),\n }),\n },\n ]);\n });\n\n it(\"should disconnect gracefully\", async () => {\n const onDeviceDisconnected = vi\n .fn()\n .mockImplementation((_id, callback) => {\n callback(null, {\n deviceId: \"deviceId\",\n connect: vi.fn().mockResolvedValue({\n services: vi.fn().mockResolvedValueOnce({}),\n serviceUUIDs: [\"ledgerId\"],\n rssi: 64,\n id: \"deviceId\",\n localName: \"knownDeviceName\",\n }),\n discoverAllServicesAndCharacteristics: vi\n .fn()\n .mockResolvedValueOnce({\n services: vi.fn().mockResolvedValueOnce({}),\n serviceUUIDs: [\"ledgerId\"],\n rssi: 64,\n id: \"deviceId\",\n localName: \"knownDeviceName\",\n }),\n });\n return { remove: vi.fn() };\n });\n // given\n const bleManager = {\n connectedDevices: fakeConnectedDevices,\n startDeviceScan: vi.fn(),\n stopDeviceScan: vi.fn(),\n onDeviceDisconnected: onDeviceDisconnected,\n isDeviceConnected: vi.fn(),\n monitorCharacteristicForDevice: vi.fn(),\n writeCharacteristicWithoutResponseForDevice: vi.fn(),\n connectToDevice: vi.fn().mockResolvedValueOnce({\n id: \"deviceId\",\n rssi: 64,\n }),\n discoverAllServicesAndCharacteristicsForDevice: vi.fn(),\n } as unknown as BleManager;\n\n const fakeCloseConnection = vi.fn();\n\n const deviceConnectionStateMachineFactory = (\n _args: DeviceConnectionStateMachineParams<RNBleApduSenderDependencies>,\n ) => {\n return new DeviceConnectionStateMachine({\n deviceId: \"deviceId\",\n deviceApduSender: _args.deviceApduSender,\n timeoutDuration: 1000,\n onTerminated: _args.onTerminated,\n });\n };\n\n const deviceApduSenderFactory = vi.fn().mockReturnValue({\n setupConnection: vi.fn(),\n closeConnection: fakeCloseConnection,\n });\n\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n fakePlaftorm as Platform,\n {} as unknown as PermissionsAndroid,\n () => bleManager,\n deviceConnectionStateMachineFactory,\n deviceApduSenderFactory,\n );\n\n const fakeOnDisconnect = vi.fn();\n\n // when\n const device = await firstValueFrom(transport.startDiscovering());\n const result = await transport.connect({\n deviceId: device.id,\n onDisconnect: fakeOnDisconnect,\n });\n\n const res = await transport.disconnect({\n connectedDevice: result.extract() as TransportConnectedDevice,\n });\n\n // then\n expect(res).toEqual(Right(undefined));\n expect(fakeOnDisconnect).toHaveBeenCalled();\n expect(fakeCloseConnection).toHaveBeenCalled();\n });\n\n it(\"should handle error while disconnecting\", async () => {\n const onDeviceDisconnected = vi\n .fn()\n .mockImplementation((_id, callback) => {\n callback(new Error(\"yolo\"), null);\n return { remove: vi.fn() };\n });\n // given\n const bleManager = {\n connectedDevices: fakeConnectedDevices,\n startDeviceScan: vi.fn(),\n stopDeviceScan: vi.fn(),\n onDeviceDisconnected: onDeviceDisconnected,\n isDeviceConnected: vi.fn(),\n monitorCharacteristicForDevice: vi.fn(),\n writeCharacteristicWithoutResponseForDevice: vi.fn(),\n connectToDevice: vi.fn().mockResolvedValueOnce({\n id: \"deviceId\",\n rssi: 64,\n }),\n discoverAllServicesAndCharacteristicsForDevice: vi.fn(),\n } as unknown as BleManager;\n\n const fakeCloseConnection = vi.fn();\n\n const deviceConnectionStateMachineFactory = (\n _args: DeviceConnectionStateMachineParams<RNBleApduSenderDependencies>,\n ) => {\n return new DeviceConnectionStateMachine({\n deviceId: \"deviceId\",\n deviceApduSender: _args.deviceApduSender,\n timeoutDuration: 1000,\n onTerminated: _args.onTerminated,\n });\n };\n\n const deviceApduSenderFactory = vi.fn().mockReturnValue({\n setupConnection: vi.fn(),\n closeConnection: fakeCloseConnection,\n });\n\n const transport = new RNBleTransport(\n fakeDataSource as unknown as DeviceModelDataSource,\n () => fakeLogger as unknown as LoggerPublisherService,\n (() => {}) as unknown as ApduSenderServiceFactory,\n (() => {}) as unknown as ApduReceiverServiceFactory,\n fakePlaftorm as Platform,\n {} as unknown as PermissionsAndroid,\n () => bleManager,\n deviceConnectionStateMachineFactory,\n deviceApduSenderFactory,\n );\n\n const fakeOnDisconnect = vi.fn();\n\n // when\n const device = await firstValueFrom(transport.startDiscovering());\n const result = await transport.connect({\n deviceId: device.id,\n onDisconnect: fakeOnDisconnect,\n });\n\n const res = await transport.disconnect({\n connectedDevice: result.extract() as TransportConnectedDevice,\n });\n\n // then\n expect(res).toEqual(Right(undefined));\n expect(fakeOnDisconnect).toHaveBeenCalled();\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAGA,OAGE,kBAAAA,EACA,gCAAAC,EAGA,iBAAAC,EAGA,4BAAAC,EACA,wBAAAC,EAEA,sBAAAC,MACK,kCACP,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAC5B,OAAS,kBAAAC,MAAsB,OAC/B,OAAS,cAAAC,EAAY,UAAAC,MAAyB,SAE9C,OAAS,mBAAAC,MAAuB,oBAGhC,OAAS,kBAAAC,EAAgB,yBAAAC,MAA6B,mBAEtD,MAAMC,EAAa,CACjB,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,CACf,EAEA,GAAG,KAAK,eAAgB,KAAO,CAC7B,SAAU,CAAC,EACX,mBAAoB,CAAC,C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MlC,EAAea,EAAU,iBAAiB,CAAC,EAC1D0B,EAAS,MAAM1B,EAAU,QAAQ,CACrC,SAAUqB,EAAO,GACjB,aAAce,CAChB,CAAC,EAEKC,EAAM,MAAMrC,EAAU,WAAW,CACrC,gBAAiB0B,EAAO,QAAQ,CAClC,CAAC,EAGDrC,EAAOgD,CAAG,EAAE,QAAQnD,EAAM,MAAS,CAAC,EACpCG,EAAO+C,CAAgB,EAAE,iBAAiB,CAC5C,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["BleDeviceInfos", "DeviceConnectionStateMachine", "DeviceModelId", "TransportConnectedDevice", "TransportDeviceModel", "UnknownDeviceError", "Left", "Right", "firstValueFrom", "beforeEach", "expect", "BleNotSupported", "RNBleTransport", "RNBleTransportFactory", "fakeLogger", "expectAndroidSupportedResult", "params", "expects", "platform", "permissionsAndroid", "key", "transport", "isSupported", "fakePlaftorm", "fakeDeviceModel", "getBluetoothServicesMock", "getBluetoothServicesInfosMock", "fakeDataSource", "identifier", "e", "done", "bleManager", "subscription", "discoveredDevice", "scanInterval", "startScan", "_uuids", "_options", "listener", "stopScan", "obs", "discoveredDevices", "device", "fakeStopDeviceScan", "sub", "devices", "fakeConnectedDevices", "result", "fakeSetupConnection", "deviceConnectionStateMachineFactory", "deviceApduSenderFactory", "fakeSendApdu", "onDeviceDisconnected", "_id", "callback", "fakeCloseConnection", "_args", "fakeOnDisconnect", "res"]
|
|
7
|
+
}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ledgerhq/device-transport-kit-react-native-ble",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"private": false,
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./lib/types/index.d.ts",
|
|
9
|
+
"import": "./lib/esm/index.js",
|
|
10
|
+
"require": "./lib/cjs/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./*": {
|
|
13
|
+
"types": "./lib/types/*",
|
|
14
|
+
"import": "./lib/esm/*",
|
|
15
|
+
"require": "./lib/cjs/*"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"./lib"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"prebuild": "rimraf lib",
|
|
23
|
+
"build": "pnpm lmdk-build --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
24
|
+
"dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
|
|
25
|
+
"watch:builds": "pnpm lmdk-watch --entryPoints src/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
|
+
"lint": "eslint",
|
|
28
|
+
"lint:fix": "pnpm lint --fix",
|
|
29
|
+
"postpack": "find . -name '*.tgz' -exec cp {} ../../../dist/ \\; ",
|
|
30
|
+
"prettier": "prettier . --check",
|
|
31
|
+
"prettier:fix": "prettier . --write",
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest",
|
|
35
|
+
"test:coverage": "vitest run --coverage"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@sentry/minimal": "^6.19.7",
|
|
39
|
+
"js-base64": "^3.7.7",
|
|
40
|
+
"purify-ts": "^2.1.0",
|
|
41
|
+
"uuid": "^10.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@ledgerhq/device-management-kit": "workspace:*",
|
|
45
|
+
"@ledgerhq/esbuild-tools": "workspace:*",
|
|
46
|
+
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
47
|
+
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
48
|
+
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
49
|
+
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
50
|
+
"@types/uuid": "^10.0.0",
|
|
51
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
52
|
+
"react-native": "^0.76.3",
|
|
53
|
+
"react-native-ble-plx": "3.4.0",
|
|
54
|
+
"rxjs": "^7.8.1",
|
|
55
|
+
"ts-node": "^10.9.2",
|
|
56
|
+
"vitest-react-native": "^0.1.5"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@ledgerhq/device-management-kit": "workspace:*",
|
|
60
|
+
"react-native": ">0.74.1",
|
|
61
|
+
"react-native-ble-plx": "3.4.0",
|
|
62
|
+
"rxjs": "^7.8.1"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Const.d.ts","sourceRoot":"","sources":["../../../../src/api/model/Const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,qBAAqB,OAAM,CAAC;AACzC,eAAO,MAAM,sBAAsB,QAAO,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GeneralDmkError } from "@ledgerhq/device-management-kit";
|
|
2
|
+
export declare class BleTransportNotSupportedError extends GeneralDmkError {
|
|
3
|
+
readonly err?: unknown | undefined;
|
|
4
|
+
readonly _tag = "BleTransportNotSupportedError";
|
|
5
|
+
constructor(err?: unknown | undefined);
|
|
6
|
+
}
|
|
7
|
+
export declare class BleDeviceGattServerError extends GeneralDmkError {
|
|
8
|
+
readonly err?: unknown | undefined;
|
|
9
|
+
readonly _tag = "BleDeviceGattServerError";
|
|
10
|
+
constructor(err?: unknown | undefined);
|
|
11
|
+
}
|
|
12
|
+
export declare class DeviceConnectionNotFound extends GeneralDmkError {
|
|
13
|
+
readonly err?: unknown | undefined;
|
|
14
|
+
readonly _tag = "DeviceConnectionNotFound";
|
|
15
|
+
constructor(err?: unknown | undefined);
|
|
16
|
+
}
|
|
17
|
+
export declare class InternalDeviceNotFound extends GeneralDmkError {
|
|
18
|
+
readonly err?: unknown | undefined;
|
|
19
|
+
readonly _tag = "InternalDeviceNotFound";
|
|
20
|
+
constructor(err?: unknown | undefined);
|
|
21
|
+
}
|
|
22
|
+
export declare class BleNotSupported extends GeneralDmkError {
|
|
23
|
+
readonly err?: unknown | undefined;
|
|
24
|
+
readonly _tag = "BleNotSupported";
|
|
25
|
+
constructor(err?: unknown | undefined);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=Errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../../../../src/api/model/Errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,qBAAa,6BAA8B,SAAQ,eAAe;IAEpD,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO;IADlC,SAAkB,IAAI,mCAAmC;gBACpC,GAAG,CAAC,EAAE,OAAO,YAAA;CAGnC;AACD,qBAAa,wBAAyB,SAAQ,eAAe;IAE/C,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO;IADlC,SAAkB,IAAI,8BAA8B;gBAC/B,GAAG,CAAC,EAAE,OAAO,YAAA;CAGnC;AACD,qBAAa,wBAAyB,SAAQ,eAAe;IAE/C,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO;IADlC,SAAkB,IAAI,8BAA8B;gBAC/B,GAAG,CAAC,EAAE,OAAO,YAAA;CAGnC;AACD,qBAAa,sBAAuB,SAAQ,eAAe;IAE7C,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO;IADlC,SAAkB,IAAI,4BAA4B;gBAC7B,GAAG,CAAC,EAAE,OAAO,YAAA;CAGnC;AAED,qBAAa,eAAgB,SAAQ,eAAe;IAEtC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO;IADlC,SAAkB,IAAI,qBAAqB;gBACtB,GAAG,CAAC,EAAE,OAAO,YAAA;CAGnC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type BleManager, type Device, type Subscription as RNBleSubscription } from "react-native-ble-plx";
|
|
2
|
+
import { type ApduReceiverServiceFactory, type ApduResponse, type ApduSenderServiceFactory, type BleDeviceInfos, type DeviceApduSender, type DeviceId, type DmkError, type LoggerPublisherService, type TransportDiscoveredDevice } from "@ledgerhq/device-management-kit";
|
|
3
|
+
import { type Either, Maybe } from "purify-ts";
|
|
4
|
+
export type RNBleInternalDevice = {
|
|
5
|
+
id: DeviceId;
|
|
6
|
+
bleDeviceInfos: BleDeviceInfos;
|
|
7
|
+
discoveredDevice: TransportDiscoveredDevice;
|
|
8
|
+
disconnectionSubscription: RNBleSubscription;
|
|
9
|
+
lastDiscoveredTimeStamp: Maybe<number>;
|
|
10
|
+
};
|
|
11
|
+
export type RNBleApduSenderConstructorArgs = {
|
|
12
|
+
dependencies: RNBleApduSenderDependencies;
|
|
13
|
+
apduSenderFactory: ApduSenderServiceFactory;
|
|
14
|
+
apduReceiverFactory: ApduReceiverServiceFactory;
|
|
15
|
+
};
|
|
16
|
+
export type RNBleApduSenderDependencies = {
|
|
17
|
+
device: Device;
|
|
18
|
+
internalDevice: RNBleInternalDevice;
|
|
19
|
+
manager: BleManager;
|
|
20
|
+
};
|
|
21
|
+
export declare class RNBleApduSender implements DeviceApduSender<RNBleApduSenderDependencies> {
|
|
22
|
+
private _dependencies;
|
|
23
|
+
private _isDeviceReady;
|
|
24
|
+
private _logger;
|
|
25
|
+
private _apduSender;
|
|
26
|
+
private readonly _apduSenderFactory;
|
|
27
|
+
private readonly _apduReceiver;
|
|
28
|
+
private _sendApduPromiseResolver;
|
|
29
|
+
constructor({ apduSenderFactory, apduReceiverFactory, dependencies, }: RNBleApduSenderConstructorArgs, loggerServiceFactory: (tag: string) => LoggerPublisherService);
|
|
30
|
+
private onReceiveSetupApduResponse;
|
|
31
|
+
private receiveApdu;
|
|
32
|
+
private onMonitor;
|
|
33
|
+
private write;
|
|
34
|
+
getDependencies(): RNBleApduSenderDependencies;
|
|
35
|
+
setDependencies(dependencies: RNBleApduSenderDependencies): void;
|
|
36
|
+
setupConnection(): Promise<void>;
|
|
37
|
+
sendApdu(apdu: Uint8Array, _triggersDisconnection?: boolean, abortTimeout?: number): Promise<Either<DmkError, ApduResponse>>;
|
|
38
|
+
closeConnection(): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=RNBleApduSender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RNBleApduSender.d.ts","sourceRoot":"","sources":["../../../../src/api/transport/RNBleApduSender.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,MAAM,EACX,KAAK,YAAY,IAAI,iBAAiB,EACvC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EAEjB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EAEb,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAE3B,KAAK,yBAAyB,EAC/B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,MAAM,EAAQ,KAAK,EAAkB,MAAM,WAAW,CAAC;AAKrE,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,QAAQ,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,yBAAyB,EAAE,iBAAiB,CAAC;IAC7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ender.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { PermissionsAndroid, Platform } from "react-native";
|
|
2
|
+
import { BleManager } from "react-native-ble-plx";
|
|
3
|
+
import { type ApduReceiverServiceFactory, type ApduSenderServiceFactory, type ConnectError, DeviceConnectionStateMachine, type DeviceConnectionStateMachineParams, type DeviceId, type DeviceModelDataSource, type DisconnectHandler, type DmkError, type LoggerPublisherService, type Transport, TransportConnectedDevice, type TransportDiscoveredDevice, type TransportFactory, type TransportIdentifier } from "@ledgerhq/device-management-kit";
|
|
4
|
+
import { type Either } from "purify-ts";
|
|
5
|
+
import { Observable } from "rxjs";
|
|
6
|
+
import { RNBleApduSender, type RNBleApduSenderConstructorArgs, type RNBleApduSenderDependencies } from "../transport/RNBleApduSender";
|
|
7
|
+
export declare const rnBleTransportIdentifier = "RN_BLE";
|
|
8
|
+
export declare class RNBleTransport implements Transport {
|
|
9
|
+
private readonly _deviceModelDataSource;
|
|
10
|
+
private readonly _loggerServiceFactory;
|
|
11
|
+
private readonly _apduSenderFactory;
|
|
12
|
+
private readonly _apduReceiverFactory;
|
|
13
|
+
private readonly _platform;
|
|
14
|
+
private readonly _permissionsAndroid;
|
|
15
|
+
private readonly _deviceConnectionStateMachineFactory;
|
|
16
|
+
private readonly _deviceApduSenderFactory;
|
|
17
|
+
private _logger;
|
|
18
|
+
private _isSupported;
|
|
19
|
+
private _internalDevicesById;
|
|
20
|
+
private _deviceConnectionsById;
|
|
21
|
+
private readonly _manager;
|
|
22
|
+
private readonly identifier;
|
|
23
|
+
private _reconnectionSubscription;
|
|
24
|
+
private _lastScanTimestamp;
|
|
25
|
+
constructor(_deviceModelDataSource: DeviceModelDataSource, _loggerServiceFactory: (tag: string) => LoggerPublisherService, _apduSenderFactory: ApduSenderServiceFactory, _apduReceiverFactory: ApduReceiverServiceFactory, _platform?: Platform, _permissionsAndroid?: PermissionsAndroid, _bleManagerFactory?: () => BleManager, _deviceConnectionStateMachineFactory?: (args: DeviceConnectionStateMachineParams<RNBleApduSenderDependencies>) => DeviceConnectionStateMachine<RNBleApduSenderDependencies>, _deviceApduSenderFactory?: (args: RNBleApduSenderConstructorArgs, loggerFactory: (tag: string) => LoggerPublisherService) => RNBleApduSender);
|
|
26
|
+
private _startDiscovering;
|
|
27
|
+
/**
|
|
28
|
+
* Starts the discovery process to find Bluetooth devices that match specific criteria.
|
|
29
|
+
*
|
|
30
|
+
* This method clears the internal device cache and requests necessary permissions
|
|
31
|
+
* before initiating the discovery of both known and new devices. If the Bluetooth
|
|
32
|
+
* Low Energy (BLE) feature is not supported, an error is thrown.
|
|
33
|
+
*
|
|
34
|
+
* @return {Observable<TransportDiscoveredDevice>} An observable emitting discovered devices
|
|
35
|
+
* that match the specified Bluetooth services.
|
|
36
|
+
*/
|
|
37
|
+
startDiscovering(): Observable<TransportDiscoveredDevice>;
|
|
38
|
+
/**
|
|
39
|
+
* Stops the device scanning operation currently in progress.
|
|
40
|
+
*
|
|
41
|
+
* @return {Promise<void>} A promise that resolves once the device scanning has been successfully stopped.
|
|
42
|
+
*/
|
|
43
|
+
stopDiscovering(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Establishes a connection to a device and configures the necessary parameters for communication.
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} params - An object containing parameters required for the connection.
|
|
48
|
+
* @param {DeviceId} params.deviceId - The unique identifier of the device to connect to.
|
|
49
|
+
* @param {DisconnectHandler} params.onDisconnect - A callback function to handle device disconnection.
|
|
50
|
+
* @returns {Promise<Either<ConnectError, TransportConnectedDevice>>} A promise resolving to either a connection error or a successfully connected device.
|
|
51
|
+
*/
|
|
52
|
+
connect(params: {
|
|
53
|
+
deviceId: DeviceId;
|
|
54
|
+
onDisconnect: DisconnectHandler;
|
|
55
|
+
}): Promise<Either<ConnectError, TransportConnectedDevice>>;
|
|
56
|
+
/**
|
|
57
|
+
* Terminates the connection with the connected device and cleans up related resources.
|
|
58
|
+
*
|
|
59
|
+
* @param {TransportConnectedDevice} params.connectedDevice - The connected device to be disconnected.
|
|
60
|
+
* @return {Promise<Either<DmkError, void>>} A promise resolving to either a success (void) or a failure (DmkError) value.
|
|
61
|
+
*/
|
|
62
|
+
disconnect(params: {
|
|
63
|
+
connectedDevice: TransportConnectedDevice;
|
|
64
|
+
}): Promise<Either<DmkError, void>>;
|
|
65
|
+
/**
|
|
66
|
+
* Listens to known devices and emits updates when new devices are discovered or when properties of existing devices are updated.
|
|
67
|
+
*
|
|
68
|
+
* @return {Observable<TransportDiscoveredDevice[]>} An observable stream of discovered devices, containing device information as an array of TransportDiscoveredDevice objects.
|
|
69
|
+
*/
|
|
70
|
+
listenToAvailableDevices(): Observable<TransportDiscoveredDevice[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Determines if the feature or permission is supported.
|
|
73
|
+
*
|
|
74
|
+
* This method evaluates the current state of the `_isSupported` property to determine
|
|
75
|
+
* whether the relevant feature is supported or throws an error if its state has
|
|
76
|
+
* not been initialized properly.
|
|
77
|
+
*
|
|
78
|
+
* @return {boolean} Returns `true` if the feature is supported, otherwise `false`.
|
|
79
|
+
* Throws an error if the `_isSupported` property has not been initialized.
|
|
80
|
+
*/
|
|
81
|
+
isSupported(): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the transport identifier associated with the object.
|
|
84
|
+
*
|
|
85
|
+
* @return {TransportIdentifier} The transport identifier.
|
|
86
|
+
*/
|
|
87
|
+
getIdentifier(): TransportIdentifier;
|
|
88
|
+
/**
|
|
89
|
+
* Requests the necessary permissions based on the operating system.
|
|
90
|
+
* For iOS, it automatically sets the permissions as granted.
|
|
91
|
+
* For Android, it checks and requests location, Bluetooth scan, and Bluetooth connect permissions, depending on the API level.
|
|
92
|
+
* If permissions are granted, updates the internal support state and logs the result.
|
|
93
|
+
*
|
|
94
|
+
* @return {Promise<boolean>} A promise that resolves to true if the required permissions are granted, otherwise false.
|
|
95
|
+
*/
|
|
96
|
+
requestPermission(): Promise<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* Retrieves a discovered device and its BLE device information, if available, from the provided input.
|
|
99
|
+
*
|
|
100
|
+
* @param {Device} rnDevice - The Bluetooth device to analyze for discovery.
|
|
101
|
+
* @param {string[]} ledgerUuids - A list of UUIDs associated with the target Ledger devices.
|
|
102
|
+
* @return {Maybe<{ bleDeviceInfos: BleDeviceInfos; discoveredDevice: TransportDiscoveredDevice }>} A Maybe object containing the discovered device and its BLE information, or Nothing if the device or information cannot be determined.
|
|
103
|
+
*/
|
|
104
|
+
private _getDiscoveredDeviceFrom;
|
|
105
|
+
/**
|
|
106
|
+
* Determines whether the delay since the device was last discovered has exceeded a predefined threshold.
|
|
107
|
+
*
|
|
108
|
+
* @param {RNBleInternalDevice} internalDevice - The internal device object containing the last discovered timestamp.
|
|
109
|
+
* @return {boolean} - Returns true if the delay is over, otherwise false.
|
|
110
|
+
*/
|
|
111
|
+
private _isDiscoveredDeviceDelayOver;
|
|
112
|
+
/**
|
|
113
|
+
* Handles the processing of devices that have been determined to be "lost" by iterating
|
|
114
|
+
* through a collection of internal devices, identifying lost devices, updating their status,
|
|
115
|
+
* and notifying a subscriber about the change.
|
|
116
|
+
*
|
|
117
|
+
* @param {Subscriber<TransportDiscoveredDevice>} subscriber - The observer that will be notified
|
|
118
|
+
* when a device is marked as lost, including updated device information with its availability set to false.
|
|
119
|
+
* @return {void} This method does not return a value.
|
|
120
|
+
*/
|
|
121
|
+
private _handleLostDiscoveredDevices;
|
|
122
|
+
/**
|
|
123
|
+
* Emits a discovered device to the provided subscriber and manages internal state
|
|
124
|
+
* for the discovered device, including handling its availability status and disconnection events.
|
|
125
|
+
*
|
|
126
|
+
* @param {Subscriber<TransportDiscoveredDevice>} subscriber The subscriber to emit the discovered device to.
|
|
127
|
+
* @param {BleDeviceInfos} bleDeviceInfos The BLE device information associated with the discovered device.
|
|
128
|
+
* @param {TransportDiscoveredDevice} discoveredDevice The newly discovered device to be emitted.
|
|
129
|
+
* @return {void} */
|
|
130
|
+
private _emitDiscoveredDevice;
|
|
131
|
+
/**
|
|
132
|
+
* Discovers new devices by scanning for BLE devices and filtering them based on the provided ledger UUIDs.
|
|
133
|
+
*
|
|
134
|
+
* @param {string[]} ledgerUuids - An array of UUIDs used to identify relevant ledger devices.
|
|
135
|
+
* @return {Observable<TransportDiscoveredDevice>} An observable that emits discovered devices matching the provided UUIDs.
|
|
136
|
+
*/
|
|
137
|
+
private _discoverNewDevices;
|
|
138
|
+
/**
|
|
139
|
+
* Discovers and emits known ledger devices based on the provided UUIDs.
|
|
140
|
+
*
|
|
141
|
+
* @param {string[]} ledgerUuids - An array of UUIDs representing the target ledger devices to discover.
|
|
142
|
+
* @return {Observable<TransportDiscoveredDevice>} An Observable that emits discovered devices matching the provided UUIDs.
|
|
143
|
+
*/
|
|
144
|
+
private _discoverKnownDevices;
|
|
145
|
+
/**
|
|
146
|
+
* Handles the event when a Bluetooth device gets disconnected. This method attempts
|
|
147
|
+
* to reconnect to the device, retries a certain number of times on failure, and
|
|
148
|
+
* invokes a callback if the reconnection does not succeed.
|
|
149
|
+
*
|
|
150
|
+
* @param {BleError | null} error - The error object representing the reason for the disconnection, or null if no error occurred.
|
|
151
|
+
* @param {Device | null} device - The Bluetooth device that was disconnected, or null if no device is provided.
|
|
152
|
+
* @return {void}
|
|
153
|
+
*/
|
|
154
|
+
private _handleDeviceDisconnected;
|
|
155
|
+
/**
|
|
156
|
+
* Handles the reconnection of a device. Configures the device connection and its corresponding
|
|
157
|
+
* internal device upon reconnection, including updating the connection state, registering
|
|
158
|
+
* callbacks for write and monitor operations, and initiating a reconnect operation.
|
|
159
|
+
*
|
|
160
|
+
* @param {Device} device - The device object that has been reconnected. Contains device details,
|
|
161
|
+
* such as the device ID.
|
|
162
|
+
* @return {Promise<Either<DeviceConnectionNotFound | InternalDeviceNotFound, void>>} A promise that completes when the device reconnection has been fully
|
|
163
|
+
* configured. Resolves with no value or rejects if an error occurs during
|
|
164
|
+
* the reconnection process.
|
|
165
|
+
*/
|
|
166
|
+
private _handleDeviceReconnected;
|
|
167
|
+
}
|
|
168
|
+
export declare const RNBleTransportFactory: TransportFactory;
|
|
169
|
+
//# sourceMappingURL=RNBleTransport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RNBleTransport.d.ts","sourceRoot":"","sources":["../../../../src/api/transport/RNBleTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAiB,UAAU,EAAe,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAE7B,KAAK,YAAY,EACjB,4BAA4B,EAC5B,KAAK,kCAAkC,EACvC,KAAK,QAAQ,EACb,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAE3B,KAAK,SAAS,EACd,wBAAwB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EAEzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,MAAM,EAAsC,MAAM,WAAW,CAAC;AAC5E,OAAO,EAIL,UAAU,EAOX,MAAM,MAAM,CAAC;AAYd,OAAO,EACL,eAAe,EACf,KAAK,8BAA8B,EACnC,KAAK,2BAA2B,EAEjC,MAAM,gCAAgC,CAAC;AAExC,eAAO,MAAM,wBAAwB,WAAW,CAAC;AAEjD,qBAAa,cAAe,YAAW,SAAS;IAc5C,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAGtC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAEpC,OAAO,CAAC,QAAQ,CAAC,o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,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAcnC;;;;OAIG;IACH,wBAAwB,IAAI,UAAU,CAAC,yBAAyB,EAAE,CAAC;IAYnE;;;;;;;;;OASG;IACH,WAAW,IAAI,OAAO;IAStB;;;;OAIG;IACH,aAAa,IAAI,mBAAmB;IAIpC;;;;;;;OAOG;IACG,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAmD3C;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IAqDhC;;;;;OAKG;IACH,OAAO,CAAC,4BAA4B;IAWpC;;;;;;;;OAQG;YACW,4BAA4B;IAiB1C;;;;;;;wBAOoB;IACpB,OAAO,CAAC,qBAAqB;IA0B7B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAkD3B;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAgC7B;;;;;;;;OAQG;IACH,OAAO,CAAC,yBAAyB;IAgFjC;;;;;;;;;;OAUG;YACW,wBAAwB;CA2BvC;AAED,eAAO,MAAM,qBAAqB,EAAE,gBAWjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RNBleTransport.test.d.ts","sourceRoot":"","sources":["../../../../src/api/transport/RNBleTransport.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|