UNPKG

@ledgerhq/swift-bridge-hw-transport-ble

Version:

Package to expose the Swift BLE transport to JS

38 lines 1.1 kB
import Transport from "@ledgerhq/hw-transport"; /** * iOS Bluetooth Transport implementation */ export default class TransportBLESwift extends Transport { /** * SwiftTransport lives in the `global` scope and gets injected by the Swift Native Module */ transport; constructor() { super(); this.transport = SwiftTransport.create(); } /** * communicate with a BLE transport */ async exchange(apdu) { const response = await this.promisify(this.transport.exchange(apdu)); return Buffer.from(response); } // eslint-disable-next-line @typescript-eslint/no-explicit-any promisify(callback) { return new Promise((resolve, reject) => { callback(function (response, error) { if (response) { resolve(response); } else { reject(error); } }); }); } arrayToBuffer(int8Array) { return Buffer.from(int8Array); } } //# sourceMappingURL=TransportBLESwift.js.map