Socket
Socket
Sign inDemoInstall

@onekeyfe/hd-transport-react-native

Package Overview
Dependencies
Maintainers
2
Versions
247
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onekeyfe/hd-transport-react-native - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

2

dist/constants.d.ts

@@ -0,1 +1,3 @@

export declare const PERMISSION_ERROR = "Bluetooth required to be turned on";
export declare const LOCATION_ERROR = "Device is not authorized to use BluetoothLE";
export declare const isOnekeyDevice: (name: string | null, id?: string | undefined) => boolean;

@@ -2,0 +4,0 @@ export declare const getBluetoothServiceUuids: () => string[];

5

dist/index.d.ts
import transport from '@onekeyfe/hd-transport';
import { Device, Characteristic } from 'react-native-ble-plx';
declare const PERMISSION_ERROR = "Bluetooth required to be turned on";
declare const LOCATION_ERROR = "Device is not authorized to use BluetoothLE";
declare type Deferred<T, I = any, D = any> = {

@@ -39,2 +42,2 @@ id?: I;

export { ReactNativeBleTransport as default };
export { LOCATION_ERROR, PERMISSION_ERROR, ReactNativeBleTransport as default };
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var buffer = require('buffer');

@@ -49,2 +51,43 @@ var transport = require('@onekeyfe/hd-transport');

const PERMISSION_ERROR = 'Bluetooth required to be turned on';
const LOCATION_ERROR = 'Device is not authorized to use BluetoothLE';
const isOnekeyDevice = (name, id) => {
var _a;
if ((_a = id === null || id === void 0 ? void 0 : id.startsWith) === null || _a === void 0 ? void 0 : _a.call(id, 'MI')) {
return true;
}
const re = /(BixinKey\d{10})|(K\d{4})/i;
if (name && re.exec(name)) {
return true;
}
return false;
};
const ClassicServiceUUID = '00000001-0000-1000-8000-00805f9b34fb';
const OneKeyServices = {
classic: {
[ClassicServiceUUID]: {
serviceUuid: ClassicServiceUUID,
writeUuid: '00000002-0000-1000-8000-00805f9b34fb',
notifyUuid: '00000003-0000-1000-8000-00805f9b34fb',
},
},
};
const bluetoothServices = [];
for (const deviceType of Object.keys(OneKeyServices)) {
const services = OneKeyServices[deviceType];
bluetoothServices.push(...Object.keys(services));
}
const getBluetoothServiceUuids = () => bluetoothServices;
const getInfosForServiceUuid = (serviceUuid, deviceType) => {
const services = OneKeyServices[deviceType];
if (!services) {
return null;
}
const service = services[serviceUuid];
if (!service) {
return null;
}
return service;
};
const timer = process.env.NODE_ENV === 'development'

@@ -74,5 +117,3 @@ ? {

let done = false;
let lastState = 'Unknown';
const subscription = bleManager.onStateChange(state => {
lastState = state;
console.log('ble state -> ', state);

@@ -92,45 +133,6 @@ if (state === 'PoweredOn') {

subscription.remove();
reject(new Error(`Bluetooth required to be turned ${lastState}`));
reject(new Error(PERMISSION_ERROR));
}, ms);
});
const isOnekeyDevice = (name, id) => {
var _a;
if ((_a = id === null || id === void 0 ? void 0 : id.startsWith) === null || _a === void 0 ? void 0 : _a.call(id, 'MI')) {
return true;
}
const re = /(BixinKey\d{10})|(K\d{4})/i;
if (name && re.exec(name)) {
return true;
}
return false;
};
const ClassicServiceUUID = '00000001-0000-1000-8000-00805f9b34fb';
const OneKeyServices = {
classic: {
[ClassicServiceUUID]: {
serviceUuid: ClassicServiceUUID,
writeUuid: '00000002-0000-1000-8000-00805f9b34fb',
notifyUuid: '00000003-0000-1000-8000-00805f9b34fb',
},
},
};
const bluetoothServices = [];
for (const deviceType of Object.keys(OneKeyServices)) {
const services = OneKeyServices[deviceType];
bluetoothServices.push(...Object.keys(services));
}
const getBluetoothServiceUuids = () => bluetoothServices;
const getInfosForServiceUuid = (serviceUuid, deviceType) => {
const services = OneKeyServices[deviceType];
if (!services) {
return null;
}
const service = services[serviceUuid];
if (!service) {
return null;
}
return service;
};
function create(arg, data) {

@@ -223,3 +225,3 @@ let localResolve = (_t) => { };

return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
const deviceList = [];

@@ -231,3 +233,3 @@ try {

console.log('subscribeBleOn error: ', error);
resolve([]);
reject(error);
return;

@@ -242,2 +244,3 @@ }

console.log('ble scan error: ', error);
reject(error);
return;

@@ -494,2 +497,4 @@ }

module.exports = ReactNativeBleTransport;
exports.LOCATION_ERROR = LOCATION_ERROR;
exports.PERMISSION_ERROR = PERMISSION_ERROR;
exports["default"] = ReactNativeBleTransport;
{
"name": "@onekeyfe/hd-transport-react-native",
"version": "0.0.5",
"version": "0.0.6",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",

@@ -23,7 +23,7 @@ "license": "MIT",

"dependencies": {
"@onekeyfe/hd-transport": "^0.0.5",
"@onekeyfe/hd-transport": "^0.0.6",
"react-native-ble-manager": "^8.1.0",
"react-native-ble-plx": "^2.0.3"
},
"gitHead": "24d2a28fd3f2e7fda4c21742e968bce764985615"
"gitHead": "b37ddf4e02812f40a01ec38ffef2ff6cdcad4bbc"
}

@@ -0,1 +1,4 @@

export const PERMISSION_ERROR = 'Bluetooth required to be turned on';
export const LOCATION_ERROR = 'Device is not authorized to use BluetoothLE';
export const isOnekeyDevice = (name: string | null, id?: string): boolean => {

@@ -2,0 +5,0 @@ if (id?.startsWith?.('MI')) {

@@ -12,3 +12,9 @@ import { Buffer } from 'buffer';

import { subscribeBleOn } from './subscribeBleOn';
import { isOnekeyDevice, getBluetoothServiceUuids, getInfosForServiceUuid } from './constants';
import {
PERMISSION_ERROR,
LOCATION_ERROR,
isOnekeyDevice,
getBluetoothServiceUuids,
getInfosForServiceUuid,
} from './constants';
import { Deferred, create as createDeferred } from './utils/deferred';

@@ -75,3 +81,3 @@ import { isHeaderChunk } from './utils/validateNotify';

// eslint-disable-next-line no-async-promise-executor
return new Promise<Device[]>(async resolve => {
return new Promise<Device[]>(async (resolve, reject) => {
const deviceList: Device[] = [];

@@ -83,3 +89,3 @@

console.log('subscribeBleOn error: ', error);
resolve([]);
reject(error);
return;

@@ -97,2 +103,3 @@ }

console.log('ble scan error: ', error);
reject(error);
return;

@@ -396,1 +403,3 @@ }

}
export { PERMISSION_ERROR, LOCATION_ERROR };

@@ -0,1 +1,2 @@

import { PERMISSION_ERROR } from './constants';
import { BlePlxManager } from './types';

@@ -7,7 +8,4 @@ import timer from './utils/timer';

let done = false;
let lastState = 'Unknown';
const subscription = bleManager.onStateChange(state => {
lastState = state;
console.log('ble state -> ', state);

@@ -27,4 +25,4 @@

subscription.remove();
reject(new Error(`Bluetooth required to be turned ${lastState}`));
reject(new Error(PERMISSION_ERROR));
}, ms);
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc