@onekeyfe/hd-transport-web-device 1.1.27-alpha.40 → 1.1.27-alpha.5
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/dist/electron-ble-transport.d.ts +13 -50
- package/dist/electron-ble-transport.d.ts.map +1 -1
- package/dist/index.d.ts +17 -73
- package/dist/index.js +108 -864
- package/dist/webusb.d.ts +3 -22
- package/dist/webusb.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/electron-ble-transport.ts +132 -612
- package/src/webusb.ts +40 -507
- package/__tests__/electron-ble-transport.test.ts +0 -231
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import transport from '@onekeyfe/hd-transport';
|
|
2
3
|
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
3
|
-
import type { DesktopAPI } from '@onekeyfe/hd-transport-electron';
|
|
4
|
-
import type { OneKeyDeviceInfo, ProtocolType, TransportCallOptions } from '@onekeyfe/hd-transport';
|
|
5
4
|
import type EventEmitter from 'events';
|
|
5
|
+
import type { DesktopAPI } from '@onekeyfe/hd-transport-electron';
|
|
6
6
|
declare global {
|
|
7
7
|
interface Window {
|
|
8
8
|
desktopApi?: DesktopAPI;
|
|
@@ -11,71 +11,34 @@ declare global {
|
|
|
11
11
|
export type BleAcquireInput = {
|
|
12
12
|
uuid: string;
|
|
13
13
|
forceCleanRunPromise?: boolean;
|
|
14
|
-
expectedProtocol?: ProtocolType;
|
|
15
14
|
};
|
|
16
15
|
export default class ElectronBleTransport {
|
|
17
|
-
|
|
18
|
-
private _messagesV2;
|
|
16
|
+
_messages: ReturnType<typeof transport.parseConfigure> | undefined;
|
|
19
17
|
name: string;
|
|
20
18
|
configured: boolean;
|
|
21
|
-
runPromise: Deferred<
|
|
19
|
+
runPromise: Deferred<any> | null;
|
|
22
20
|
Log?: any;
|
|
23
21
|
emitter?: EventEmitter;
|
|
24
22
|
private connectedDevices;
|
|
25
|
-
private
|
|
26
|
-
private deviceProtocolHints;
|
|
27
|
-
private v1Buffers;
|
|
28
|
-
private v2Assemblers;
|
|
29
|
-
private v2FrameQueues;
|
|
30
|
-
private v2FramePromises;
|
|
31
|
-
private activeProtocolV2Call;
|
|
32
|
-
private nextProtocolV2CallToken;
|
|
23
|
+
private dataBuffers;
|
|
33
24
|
private notificationCleanups;
|
|
34
25
|
private disconnectCleanups;
|
|
35
|
-
private notificationTokens;
|
|
36
|
-
private nextNotificationToken;
|
|
37
26
|
private handleBluetoothError;
|
|
38
27
|
private cleanupDeviceState;
|
|
39
28
|
init(logger: any, emitter?: EventEmitter): void;
|
|
40
29
|
configure(signedData: any): void;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
listen(): void;
|
|
31
|
+
enumerate(): Promise<{
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
}[]>;
|
|
44
35
|
acquire(input: BleAcquireInput): Promise<{
|
|
45
36
|
uuid: string;
|
|
46
|
-
commType: import("@onekeyfe/hd-transport").OneKeyDeviceCommType;
|
|
47
37
|
path: string;
|
|
48
|
-
session?: string | null | undefined;
|
|
49
|
-
debugSession?: string | null | undefined;
|
|
50
|
-
debug: boolean;
|
|
51
|
-
id: string;
|
|
52
|
-
name: string | null;
|
|
53
|
-
protocolType?: ProtocolType | undefined;
|
|
54
38
|
}>;
|
|
55
39
|
release(id: string): Promise<void>;
|
|
56
|
-
private
|
|
57
|
-
|
|
58
|
-
private
|
|
59
|
-
private detectProtocol;
|
|
60
|
-
private createNotificationSubscription;
|
|
61
|
-
private resetProbeStateAfterProtocolProbe;
|
|
62
|
-
private probeProtocolV1;
|
|
63
|
-
private probeProtocolV2;
|
|
64
|
-
private writeWithChunking;
|
|
65
|
-
private writeWithRetry;
|
|
66
|
-
private handleNotification;
|
|
67
|
-
private handleProtocolV2Notification;
|
|
68
|
-
private getProtocolV2FrameQueue;
|
|
69
|
-
private resolveProtocolV2Frame;
|
|
70
|
-
private rejectAllProtocolV2Frames;
|
|
71
|
-
private resetProtocolV2Frames;
|
|
72
|
-
private isActiveProtocolV2Call;
|
|
73
|
-
private readProtocolV2Frame;
|
|
74
|
-
private handleProtocolV1Notification;
|
|
75
|
-
call(uuid: string, name: string, data: Record<string, unknown>, options?: TransportCallOptions): Promise<import("@onekeyfe/hd-transport").MessageFromOneKey>;
|
|
76
|
-
private callProtocolV1;
|
|
77
|
-
private callProtocolV2;
|
|
78
|
-
private processProtocolV1Notification;
|
|
79
|
-
getProtocolType(path: string): ProtocolType | undefined;
|
|
40
|
+
private handleNotificationData;
|
|
41
|
+
call(uuid: string, name: string, data: Record<string, unknown>): Promise<import("@onekeyfe/hd-transport").MessageFromOneKey>;
|
|
42
|
+
private processNotificationPacket;
|
|
80
43
|
}
|
|
81
44
|
//# sourceMappingURL=electron-ble-transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-ble-transport.d.ts","sourceRoot":"","sources":["../src/electron-ble-transport.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"electron-ble-transport.d.ts","sourceRoot":"","sources":["../src/electron-ble-transport.ts"],"names":[],"mappings":";AAAA,OAAO,SAAkD,MAAM,wBAAwB,CAAC;AASxF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAKlE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,CAAC,EAAE,UAAU,CAAC;KACzB;CACF;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AASF,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACvC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,IAAI,SAA0B;IAE9B,UAAU,UAAS;IAEnB,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAExC,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV,OAAO,CAAC,EAAE,YAAY,CAAC;IAGvB,OAAO,CAAC,gBAAgB,CAA0B;IAGlD,OAAO,CAAC,WAAW,CAAsE;IAGzF,OAAO,CAAC,oBAAoB,CAAsC;IAGlE,OAAO,CAAC,kBAAkB,CAAsC;IAGhE,OAAO,CAAC,oBAAoB;IAmC5B,OAAO,CAAC,kBAAkB;IAmB1B,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY;IAexC,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,MAAM;IAEA,SAAS,IAAI,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAcpD,OAAO,CAAC,KAAK,EAAE,eAAe;;;;IA8E9B,OAAO,CAAC,EAAE,EAAE,MAAM;IAwBxB,OAAO,CAAC,sBAAsB;IA2BxB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA2EpE,OAAO,CAAC,yBAAyB;CAyDlC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as transport from '@onekeyfe/hd-transport';
|
|
2
|
+
import transport__default, { AcquireInput, OneKeyDeviceInfoBase } from '@onekeyfe/hd-transport';
|
|
3
3
|
import { Deferred } from '@onekeyfe/hd-shared';
|
|
4
|
-
import { DesktopAPI } from '@onekeyfe/hd-transport-electron';
|
|
5
4
|
import EventEmitter from 'events';
|
|
5
|
+
import { DesktopAPI } from '@onekeyfe/hd-transport-electron';
|
|
6
6
|
|
|
7
7
|
interface DeviceInfo extends OneKeyDeviceInfoBase {
|
|
8
8
|
path: string;
|
|
9
9
|
device: USBDevice;
|
|
10
|
-
protocolType?: ProtocolType;
|
|
11
10
|
}
|
|
12
11
|
declare class WebUsbTransport {
|
|
13
|
-
messages: ReturnType<typeof
|
|
14
|
-
messagesV2: ReturnType<typeof _onekeyfe_hd_transport__default.parseConfigure> | undefined;
|
|
15
|
-
private deviceProtocol;
|
|
16
|
-
private deviceProtocolHints;
|
|
17
|
-
private protocolV2Assemblers;
|
|
18
|
-
private deviceEndpoints;
|
|
12
|
+
messages: ReturnType<typeof transport__default.parseConfigure> | undefined;
|
|
19
13
|
name: string;
|
|
20
14
|
stopped: boolean;
|
|
21
15
|
configured: boolean;
|
|
@@ -27,17 +21,12 @@ declare class WebUsbTransport {
|
|
|
27
21
|
interfaceId: number;
|
|
28
22
|
init(logger: any): void;
|
|
29
23
|
configure(signedData: any): void;
|
|
30
|
-
configureProtocolV2(signedData: any): void;
|
|
31
24
|
promptDeviceAccess(): Promise<USBDevice | null>;
|
|
32
25
|
enumerate(): Promise<DeviceInfo[]>;
|
|
33
26
|
getConnectedDevices(): Promise<DeviceInfo[]>;
|
|
34
27
|
acquire(input: AcquireInput): Promise<string | undefined>;
|
|
35
|
-
private createProtocolMismatchError;
|
|
36
|
-
private createProtocolDetectionError;
|
|
37
|
-
private detectProtocol;
|
|
38
28
|
findDevice(path: string): Promise<USBDevice>;
|
|
39
29
|
connect(path: string, first: boolean): Promise<void>;
|
|
40
|
-
private discoverEndpoints;
|
|
41
30
|
connectToDevice(path: string, first: boolean): Promise<void>;
|
|
42
31
|
post(session: string, name: string, data: Record<string, unknown>): Promise<void>;
|
|
43
32
|
private getErrorMessage;
|
|
@@ -47,17 +36,9 @@ declare class WebUsbTransport {
|
|
|
47
36
|
private toArrayBuffer;
|
|
48
37
|
private transferOutWithRetry;
|
|
49
38
|
private transferInWithRetry;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
private probeProtocolV1;
|
|
53
|
-
private probeProtocolV2;
|
|
54
|
-
call(path: string, name: string, data: Record<string, unknown>, options?: TransportCallOptions): Promise<_onekeyfe_hd_transport.MessageFromOneKey>;
|
|
55
|
-
private callProtocolV1;
|
|
56
|
-
private callProtocolV2;
|
|
57
|
-
private receiveProtocolV2Frame;
|
|
58
|
-
receiveData(path: string, timeoutMs?: number): Promise<string>;
|
|
39
|
+
call(path: string, name: string, data: Record<string, unknown>): Promise<transport.MessageFromOneKey>;
|
|
40
|
+
receiveData(path: string): Promise<string>;
|
|
59
41
|
release(path: string): Promise<void>;
|
|
60
|
-
getProtocolType(path: string): ProtocolType | undefined;
|
|
61
42
|
}
|
|
62
43
|
|
|
63
44
|
declare global {
|
|
@@ -68,72 +49,35 @@ declare global {
|
|
|
68
49
|
type BleAcquireInput = {
|
|
69
50
|
uuid: string;
|
|
70
51
|
forceCleanRunPromise?: boolean;
|
|
71
|
-
expectedProtocol?: ProtocolType;
|
|
72
52
|
};
|
|
73
53
|
declare class ElectronBleTransport {
|
|
74
|
-
|
|
75
|
-
private _messagesV2;
|
|
54
|
+
_messages: ReturnType<typeof transport__default.parseConfigure> | undefined;
|
|
76
55
|
name: string;
|
|
77
56
|
configured: boolean;
|
|
78
|
-
runPromise: Deferred<
|
|
57
|
+
runPromise: Deferred<any> | null;
|
|
79
58
|
Log?: any;
|
|
80
59
|
emitter?: EventEmitter;
|
|
81
60
|
private connectedDevices;
|
|
82
|
-
private
|
|
83
|
-
private deviceProtocolHints;
|
|
84
|
-
private v1Buffers;
|
|
85
|
-
private v2Assemblers;
|
|
86
|
-
private v2FrameQueues;
|
|
87
|
-
private v2FramePromises;
|
|
88
|
-
private activeProtocolV2Call;
|
|
89
|
-
private nextProtocolV2CallToken;
|
|
61
|
+
private dataBuffers;
|
|
90
62
|
private notificationCleanups;
|
|
91
63
|
private disconnectCleanups;
|
|
92
|
-
private notificationTokens;
|
|
93
|
-
private nextNotificationToken;
|
|
94
64
|
private handleBluetoothError;
|
|
95
65
|
private cleanupDeviceState;
|
|
96
66
|
init(logger: any, emitter?: EventEmitter): void;
|
|
97
67
|
configure(signedData: any): void;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
68
|
+
listen(): void;
|
|
69
|
+
enumerate(): Promise<{
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
}[]>;
|
|
101
73
|
acquire(input: BleAcquireInput): Promise<{
|
|
102
74
|
uuid: string;
|
|
103
|
-
commType: _onekeyfe_hd_transport.OneKeyDeviceCommType;
|
|
104
75
|
path: string;
|
|
105
|
-
session?: string | null | undefined;
|
|
106
|
-
debugSession?: string | null | undefined;
|
|
107
|
-
debug: boolean;
|
|
108
|
-
id: string;
|
|
109
|
-
name: string | null;
|
|
110
|
-
protocolType?: ProtocolType | undefined;
|
|
111
76
|
}>;
|
|
112
77
|
release(id: string): Promise<void>;
|
|
113
|
-
private
|
|
114
|
-
|
|
115
|
-
private
|
|
116
|
-
private detectProtocol;
|
|
117
|
-
private createNotificationSubscription;
|
|
118
|
-
private resetProbeStateAfterProtocolProbe;
|
|
119
|
-
private probeProtocolV1;
|
|
120
|
-
private probeProtocolV2;
|
|
121
|
-
private writeWithChunking;
|
|
122
|
-
private writeWithRetry;
|
|
123
|
-
private handleNotification;
|
|
124
|
-
private handleProtocolV2Notification;
|
|
125
|
-
private getProtocolV2FrameQueue;
|
|
126
|
-
private resolveProtocolV2Frame;
|
|
127
|
-
private rejectAllProtocolV2Frames;
|
|
128
|
-
private resetProtocolV2Frames;
|
|
129
|
-
private isActiveProtocolV2Call;
|
|
130
|
-
private readProtocolV2Frame;
|
|
131
|
-
private handleProtocolV1Notification;
|
|
132
|
-
call(uuid: string, name: string, data: Record<string, unknown>, options?: TransportCallOptions): Promise<_onekeyfe_hd_transport.MessageFromOneKey>;
|
|
133
|
-
private callProtocolV1;
|
|
134
|
-
private callProtocolV2;
|
|
135
|
-
private processProtocolV1Notification;
|
|
136
|
-
getProtocolType(path: string): ProtocolType | undefined;
|
|
78
|
+
private handleNotificationData;
|
|
79
|
+
call(uuid: string, name: string, data: Record<string, unknown>): Promise<transport.MessageFromOneKey>;
|
|
80
|
+
private processNotificationPacket;
|
|
137
81
|
}
|
|
138
82
|
|
|
139
83
|
export { ElectronBleTransport, WebUsbTransport };
|