Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
listen(({ type, message, ...rest }) => {
if (Object.keys(rest).length) {
console.log(`${type}: ${message || ""}`, rest); // eslint-disable-line no-console
} else {
console.log(`${type}: ${message || ""}`); // eslint-disable-line no-console
}
});
}
if (Config.DEBUG_SOCKET) {
logs.subscribe(e => {
console.log(e); // eslint-disable-line no-console
});
}
if (Config.BLE_LOG_LEVEL) BluetoothTransport.setLogLevel(Config.BLE_LOG_LEVEL);
setNetwork(network);
setEnv("FORCE_PROVIDER", Config.FORCE_PROVIDER);
// Add support of HID (experimental until we stabilize it)
registerTransportModule({
id: "hid",
// prettier-ignore
open: id => { // eslint-disable-line consistent-return
if (id.startsWith("usb|")) {
const devicePath = JSON.parse(id.slice(4));
return retry(() => HIDTransport.open(devicePath), { maxRetry: 2 });
}
},
import { receiveAPDU } from "./receiveAPDU";
import { monitorCharacteristic } from "./monitorCharacteristic";
import { awaitsBleOn } from "./awaitsBleOn";
const ServiceUuid = "d973f2e0-b19e-11e2-9e96-0800200c9a66";
const WriteCharacteristicUuid = "d973f2e2-b19e-11e2-9e96-0800200c9a66";
const NotifyCharacteristicUuid = "d973f2e1-b19e-11e2-9e96-0800200c9a66";
let connectOptions = {
requestMTU: 156,
};
const transportsCache = {};
const bleManager = new BleManager();
if (Config.BLE_LOG_LEVEL) bleManager.setLogLevel(Config.BLE_LOG_LEVEL);
/**
* react-native bluetooth BLE implementation
* @example
* import BluetoothTransport from "@ledgerhq/react-native-hw-transport-ble";
*/
export default class BluetoothTransport extends Transport {
static isSupported = (): Promise =>
Promise.resolve(typeof BleManager === "function");
/**
* TODO could add this concept in all transports
* observe event with { available: bool, type: string } // available is generic, type is specific
* an event is emit once and then listened
*/
static observeState(observer: *) {