@ukeyfe/hardware-transport-react-native 1.1.13

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/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # `@ukeyfe/hardware-transport-react-native`
2
+
3
+ `@ukeyfe/hardware-transport-react-native` is a library that implements transport communication by [react-native-ble-plx](https://github.com/dotintent/react-native-ble-plx).
4
+
5
+ ## What is the purpose
6
+
7
+ - translate JSON payloads to binary messages using protobuf definitions comprehensible to UKey devices
8
+ - chunking and reading chunked messages according to the [UKey protocol](./protocol.md)
9
+ - exposing single API for various transport methods:
10
+ - Http Transport
11
+ - React Native Transport
12
+ - WebUSB
13
+ - Create and expose typescript definitions based on protobuf definitions.
14
+
15
+ ### The short version
16
+
17
+ In order to be able to use new features of ukey-firmware you need to update protobuf definitions.
18
+
19
+ 1. `git submodule update --init --recursive` to initialize git submodules.
20
+ 1. `yarn update-submodules` to update firmware submodule
21
+ 1. `yarn update:protobuf` to generate new `./messages.json` and `./src/types/messages.ts`
22
+
23
+ git submodule update --init --recursive to initialize firmware submodule
24
+ yarn update-submodules to update firmware submodule
25
+ yar update:protobuf to generate new ./messages.json and ./src/types/messages.ts
26
+
27
+ ## Docs
28
+
29
+ Documentation is available [hardware-js-sdk](https://developer.ukey.so/connect-to-hardware/hardware-sdk/start)
@@ -0,0 +1,9 @@
1
+ import { Peripheral } from '@ukeyfe/react-native-ble-utils';
2
+ export declare const getConnectedDeviceIds: (serviceUuids: string[]) => Promise<Peripheral[]>;
3
+ export declare const getBondedDevices: () => Promise<Peripheral[]>;
4
+ export declare const pairDevice: (macAddress: string) => Promise<{
5
+ bonded: boolean;
6
+ bonding: boolean;
7
+ }>;
8
+ export declare const onDeviceBondState: (bleMacAddress: string) => Promise<Peripheral | undefined>;
9
+ //# sourceMappingURL=BleManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BleManager.d.ts","sourceRoot":"","sources":["../src/BleManager.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAWtE,eAAO,MAAM,qBAAqB,iBAAkB,MAAM,EAAE,0BACZ,CAAC;AAEjD,eAAO,MAAM,gBAAgB,6BAAwC,CAAC;AAEtE,eAAO,MAAM,UAAU,eAAgB,MAAM;;;EAAoC,CAAC;AAElF,eAAO,MAAM,iBAAiB,kBAAmB,MAAM,KAAG,QAAQ,UAAU,GAAG,SAAS,CAmCpF,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { Device, Characteristic } from 'react-native-ble-plx';
2
+ export default class BleTransport {
3
+ id: string;
4
+ name: string;
5
+ device: Device;
6
+ mtuSize: number;
7
+ writeCharacteristic: Characteristic;
8
+ notifyCharacteristic: Characteristic;
9
+ nofitySubscription?: () => void;
10
+ static MAX_RETRIES: number;
11
+ static RETRY_DELAY: number;
12
+ constructor(device: Device, writeCharacteristic: Characteristic, notifyCharacteristic: Characteristic);
13
+ writeWithRetry(data: string, retryCount?: number): Promise<void>;
14
+ }
15
+ //# sourceMappingURL=BleTransport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BleTransport.d.ts","sourceRoot":"","sources":["../src/BleTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAgB,MAAM,sBAAsB,CAAC;AAM5E,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,SAA6B;IAEjC,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,SAAM;IAEb,mBAAmB,EAAE,cAAc,CAAC;IAEpC,oBAAoB,EAAE,cAAc,CAAC;IAErC,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAEhC,MAAM,CAAC,WAAW,SAAK;IAEvB,MAAM,CAAC,WAAW,SAAQ;gBAGxB,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,cAAc,EACnC,oBAAoB,EAAE,cAAc;IAehC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,SAA2B,GAAG,OAAO,CAAC,IAAI,CAAC;CA2BzF"}
@@ -0,0 +1,9 @@
1
+ export declare const IOS_PACKET_LENGTH = 128;
2
+ export declare const ANDROID_PACKET_LENGTH = 192;
3
+ export declare const getBluetoothServiceUuids: () => string[];
4
+ export declare const getInfosForServiceUuid: (serviceUuid: string, deviceType: 'classic') => {
5
+ serviceUuid: string;
6
+ writeUuid?: string | undefined;
7
+ notifyUuid?: string | undefined;
8
+ } | null;
9
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AA8BzC,eAAO,MAAM,wBAAwB,gBAA0B,CAAC;AAChE,eAAO,MAAM,sBAAsB,gBAAiB,MAAM,cAAc,SAAS;iBA1BhE,MAAM;;;QAoCtB,CAAC"}
@@ -0,0 +1,42 @@
1
+ import * as transport from '@ukeyfe/hardware-transport';
2
+ import transport__default from '@ukeyfe/hardware-transport';
3
+ import { BleManager, Device, Characteristic } from 'react-native-ble-plx';
4
+ import { Deferred } from '@ukeyfe/hardware-shared';
5
+ import EventEmitter from 'events';
6
+
7
+ type TransportOptions = {
8
+ scanTimeout?: number;
9
+ };
10
+ type BleAcquireInput = {
11
+ uuid: string;
12
+ forceCleanRunPromise?: boolean;
13
+ };
14
+
15
+ declare class ReactNativeBleTransport {
16
+ blePlxManager: BleManager | undefined;
17
+ _messages: ReturnType<typeof transport__default.parseConfigure> | undefined;
18
+ name: string;
19
+ configured: boolean;
20
+ stopped: boolean;
21
+ scanTimeout: number;
22
+ runPromise: Deferred<any> | null;
23
+ Log?: any;
24
+ emitter?: EventEmitter;
25
+ constructor(options: TransportOptions);
26
+ init(logger: any, emitter: EventEmitter): void;
27
+ configure(signedData: any): void;
28
+ listen(): void;
29
+ getPlxManager(): Promise<BleManager>;
30
+ enumerate(): Promise<Device[]>;
31
+ acquire(input: BleAcquireInput): Promise<{
32
+ uuid: string;
33
+ }>;
34
+ _monitorCharacteristic(characteristic: Characteristic): () => void;
35
+ release(uuid: string): Promise<boolean>;
36
+ post(session: string, name: string, data: Record<string, unknown>): Promise<void>;
37
+ call(uuid: string, name: string, data: Record<string, unknown>): Promise<transport.MessageFromUKey>;
38
+ stop(): void;
39
+ cancel(): void;
40
+ }
41
+
42
+ export { ReactNativeBleTransport as default };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,MAAM,EAEN,cAAc,EAIf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAkD,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAEL,QAAQ,EAIT,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AAYvC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAoDjE,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAC1C,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,IAAI,SAA6B;IAEjC,UAAU,UAAS;IAEnB,OAAO,UAAS;IAEhB,WAAW,SAAQ;IAEnB,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAExC,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV,OAAO,CAAC,EAAE,YAAY,CAAC;gBAEX,OAAO,EAAE,gBAAgB;IAIrC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY;IAKvC,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,MAAM;IAIN,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAWjC,SAAS;IA6FT,OAAO,CAAC,KAAK,EAAE,eAAe;;;IAkNpC,sBAAsB,CAAC,cAAc,EAAE,cAAc;IAkF/C,OAAO,CAAC,IAAI,EAAE,MAAM;IAepB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIjE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA2HpE,IAAI;IAIJ,MAAM;CAOP"}