@onekeyfe/hd-core 0.1.49 → 0.1.51
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 +31 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +4 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +2 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +9 -1
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +10 -1
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +31 -4
- package/dist/index.js +74 -18
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/core/index.ts +44 -13
- package/src/device/Device.ts +12 -3
- package/src/device/DeviceCommands.ts +43 -15
- package/src/device/DevicePool.ts +2 -7
- package/src/events/ui-request.ts +12 -2
- package/src/events/ui-response.ts +11 -1
- package/src/types/params.ts +6 -0
package/README.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@onekeyfe/hd-core`
|
|
2
2
|
|
|
3
|
-
OneKey
|
|
3
|
+
@onekeyfe/hd-core is a platform for easy integration of OneKey hardware into 3rd party services. This library provides the core processes and APIs for communicating with OneKey hardware.
|
|
4
|
+
|
|
5
|
+
This library is not environment specific, if you want to use a specific SDK, please refer to the SDK for each environment.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install library as npm module:
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
npm install @onekeyfe/hd-core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
or
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
yarn add @onekeyfe/hd-core
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Initialization
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import Core from '@onekeyfe/hd-core';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Docs
|
|
28
|
+
|
|
29
|
+
Documentation is available [hardware-js-sdk](https://developer.onekey.so/connect-to-hardware/hardware-sdk/start)
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
// TODO: add example url
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAqBlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAqBlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AA4BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBA4PjD,CAAC;AA2KF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AAiJF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IACtC,aAAa,CAAC,OAAO,EAAE,WAAW;IA8CxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aAAoB,eAAe,aAAa,GAAG,8BAmBnE,CAAC"}
|
package/dist/device/Device.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import EventEmitter from 'events';
|
|
|
3
3
|
import { OneKeyDeviceInfo as DeviceDescriptor } from '@onekeyfe/hd-transport';
|
|
4
4
|
import { Deferred } from '@onekeyfe/hd-shared';
|
|
5
5
|
import type DeviceConnector from './DeviceConnector';
|
|
6
|
-
import { DeviceCommands } from './DeviceCommands';
|
|
6
|
+
import { DeviceCommands, PassphrasePromptResponse } from './DeviceCommands';
|
|
7
7
|
import type { Features, Device as DeviceTyped, UnavailableCapabilities } from '../types';
|
|
8
8
|
import { DEVICE, DeviceButtonRequestPayload, DeviceFeaturesPayload } from '../events';
|
|
9
9
|
import { PROTO } from '../constants';
|
|
@@ -11,6 +11,7 @@ export declare type InitOptions = {
|
|
|
11
11
|
initSession?: boolean;
|
|
12
12
|
deviceId?: string;
|
|
13
13
|
passphraseState?: string;
|
|
14
|
+
skipPassphraseCheck?: boolean;
|
|
14
15
|
};
|
|
15
16
|
export declare type RunOptions = {
|
|
16
17
|
keepSession?: boolean;
|
|
@@ -20,6 +21,7 @@ export interface DeviceEvents {
|
|
|
20
21
|
[DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
|
|
21
22
|
[DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
|
|
22
23
|
[DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
|
|
24
|
+
[DEVICE.PASSPHRASE]: [Device, (response: PassphrasePromptResponse, error?: Error) => void];
|
|
23
25
|
}
|
|
24
26
|
export interface Device {
|
|
25
27
|
on<K extends keyof DeviceEvents>(type: K, listener: (...event: DeviceEvents[K]) => void): this;
|
|
@@ -41,6 +43,7 @@ export declare class Device extends EventEmitter {
|
|
|
41
43
|
needReloadDevice: boolean;
|
|
42
44
|
keepSession: boolean;
|
|
43
45
|
passphraseState: string | undefined;
|
|
46
|
+
skipPassphraseCheck: boolean | undefined;
|
|
44
47
|
constructor(descriptor: DeviceDescriptor);
|
|
45
48
|
static fromDescriptor(originalDescriptor: DeviceDescriptor): Device;
|
|
46
49
|
toMessageObject(): DeviceTyped | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../src/device/Device.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAEL,QAAQ,EAIT,MAAM,qBAAqB,CAAC;AAW7B,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../src/device/Device.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAEL,QAAQ,EAIT,MAAM,qBAAqB,CAAC;AAW7B,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,WAAW,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEtF,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrC,oBAAY,WAAW,GAAG;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,WAAW,CAAC;AAShB,MAAM,WAAW,YAAY;IAC3B,CAAC,M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;IAyDpE,uBAAuB;IASvB,oBAAoB;IAS1B,OAAO;IAOP,kBAAkB;IAKlB,qBAAqB;IAKrB,MAAM;IAIN,UAAU;IAQV,eAAe,IAAI,OAAO;IAI1B,YAAY;IAIZ,aAAa;IAIb,UAAU;IAIV,YAAY,IAAI,OAAO;IAIvB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;IAsBpD,gBAAgB;IAQhB,aAAa,CAAC,QAAQ,EAAE,MAAM;IAOxB,oBAAoB;CAmB3B;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -28,8 +28,9 @@ export declare class DeviceCommands {
|
|
|
28
28
|
typedCall<T extends MessageKey, R extends MessageKey[]>(type: T, resType: R, msg?: MessageType[T]): Promise<TypedCallResponseMap[R[number]]>;
|
|
29
29
|
typedCall<T extends MessageKey, R extends MessageKey>(type: T, resType: R, msg?: MessageType[T]): Promise<TypedResponseMessage<R>>;
|
|
30
30
|
_commonCall(type: MessageKey, msg?: DefaultMessageResponse['message']): Promise<DefaultMessageResponse>;
|
|
31
|
-
_filterCommonTypes(res: DefaultMessageResponse): Promise<DefaultMessageResponse>;
|
|
31
|
+
_filterCommonTypes(res: DefaultMessageResponse, callType: MessageKey): Promise<DefaultMessageResponse>;
|
|
32
32
|
_promptPin(type?: Messages.PinMatrixRequestType): Promise<string>;
|
|
33
|
+
_promptPassphrase(): Promise<PassphrasePromptResponse>;
|
|
33
34
|
}
|
|
34
35
|
export declare type TypedCall = DeviceCommands['typedCall'];
|
|
35
36
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceCommands.d.ts","sourceRoot":"","sources":["../../src/device/DeviceCommands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAKlE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,aAAK,WAAW,GAAG,QA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7
7
|
readonly REQUEST_PIN: "ui-request_pin";
|
|
8
8
|
readonly INVALID_PIN: "ui-invalid_pin";
|
|
9
9
|
readonly REQUEST_BUTTON: "ui-button";
|
|
10
|
+
readonly REQUEST_PASSPHRASE: "ui-request_passphrase";
|
|
10
11
|
readonly REQUEST_PASSPHRASE_ON_DEVICE: "ui-request_passphrase_on_device";
|
|
11
12
|
readonly CLOSE_UI_WINDOW: "ui-close_window";
|
|
12
13
|
readonly BLUETOOTH_PERMISSION: "ui-bluetooth_permission";
|
|
@@ -31,6 +32,13 @@ export interface UiRequestButton {
|
|
|
31
32
|
payload: DeviceButtonRequest['payload'];
|
|
32
33
|
}
|
|
33
34
|
export interface UiRequestPassphrase {
|
|
35
|
+
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
36
|
+
payload: {
|
|
37
|
+
device: Device;
|
|
38
|
+
passphraseState?: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface UiRequestPassphraseOnDevice {
|
|
34
42
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
35
43
|
payload: {
|
|
36
44
|
device: Device;
|
|
@@ -44,7 +52,7 @@ export interface FirmwareProgress {
|
|
|
44
52
|
progress: number;
|
|
45
53
|
};
|
|
46
54
|
}
|
|
47
|
-
export declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton |
|
|
55
|
+
export declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPassphraseOnDevice | FirmwareProgress | UiRequestPassphrase;
|
|
48
56
|
export declare type UiEventMessage = UiEvent & {
|
|
49
57
|
event: typeof UI_EVENT;
|
|
50
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-request.d.ts","sourceRoot":"","sources":["../../src/events/ui-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAA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kBAAkB,CAAC;IAC3C,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,OAAO,UAAU,CAAC,4BAA4B,CAAC;IACrD,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,UAAU,CAAC,iBAAiB,CAAC;IAC1C,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,oBAAY,OAAO,GACf,uBAAuB,GACvB,qBAAqB,GACrB,eAAe,GACf,2BAA2B,GAC3B,gBAAgB,GAChB,mBAAmB,CAAC;AAExB,oBAAY,cAAc,GAAG,OAAO,GAAG;IAAE,KAAK,EAAE,OAAO,QAAQ,CAAA;CAAE,CAAC;AAElE,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,OAAO,QAAQ,EAAE,OAAO,CAK5D,CAAC"}
|
|
@@ -2,12 +2,21 @@ import { UI_EVENT } from './ui-request';
|
|
|
2
2
|
import type { MessageFactoryFn } from './utils';
|
|
3
3
|
export declare const UI_RESPONSE: {
|
|
4
4
|
readonly RECEIVE_PIN: "ui-receive_pin";
|
|
5
|
+
readonly RECEIVE_PASSPHRASE: "ui-receive_passphrase";
|
|
5
6
|
};
|
|
6
7
|
export interface UiResponsePin {
|
|
7
8
|
type: typeof UI_RESPONSE.RECEIVE_PIN;
|
|
8
9
|
payload: string;
|
|
9
10
|
}
|
|
10
|
-
export
|
|
11
|
+
export interface UiResponsePassphrase {
|
|
12
|
+
type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;
|
|
13
|
+
payload: {
|
|
14
|
+
value: string;
|
|
15
|
+
passphraseOnDevice?: boolean;
|
|
16
|
+
save?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare type UiResponseEvent = UiResponsePin | UiResponsePassphrase;
|
|
11
20
|
export declare type UiResponseMessage = UiResponseEvent & {
|
|
12
21
|
event: typeof UI_EVENT;
|
|
13
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-response.d.ts","sourceRoot":"","sources":["../../src/events/ui-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"ui-response.d.ts","sourceRoot":"","sources":["../../src/events/ui-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,WAAW;;;CAGd,CAAC;AAEX,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,WAAW,CAAC,WAAW,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,OAAO,WAAW,CAAC,kBAAkB,CAAC;IAC5C,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;CACH;AAED,oBAAY,eAAe,GAAG,aAAa,GAAG,oBAAoB,CAAC;AAEnE,oBAAY,iBAAiB,GAAG,eAAe,GAAG;IAAE,KAAK,EAAE,OAAO,QAAQ,CAAA;CAAE,CAAC;AAE7E,eAAO,MAAM,gBAAgB,EAAE,gBAAgB,CAAC,OAAO,QAAQ,EAAE,eAAe,CAQrE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ interface CommonParams {
|
|
|
11
11
|
timeout?: number;
|
|
12
12
|
passphraseState?: string;
|
|
13
13
|
initSession?: boolean;
|
|
14
|
+
skipPassphraseCheck?: boolean;
|
|
14
15
|
}
|
|
15
16
|
declare type Params<T> = CommonParams & T & {
|
|
16
17
|
bundle?: undefined;
|
|
@@ -1187,6 +1188,7 @@ declare const UI_REQUEST: {
|
|
|
1187
1188
|
readonly REQUEST_PIN: "ui-request_pin";
|
|
1188
1189
|
readonly INVALID_PIN: "ui-invalid_pin";
|
|
1189
1190
|
readonly REQUEST_BUTTON: "ui-button";
|
|
1191
|
+
readonly REQUEST_PASSPHRASE: "ui-request_passphrase";
|
|
1190
1192
|
readonly REQUEST_PASSPHRASE_ON_DEVICE: "ui-request_passphrase_on_device";
|
|
1191
1193
|
readonly CLOSE_UI_WINDOW: "ui-close_window";
|
|
1192
1194
|
readonly BLUETOOTH_PERMISSION: "ui-bluetooth_permission";
|
|
@@ -1211,6 +1213,13 @@ interface UiRequestButton {
|
|
|
1211
1213
|
payload: DeviceButtonRequest['payload'];
|
|
1212
1214
|
}
|
|
1213
1215
|
interface UiRequestPassphrase {
|
|
1216
|
+
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
1217
|
+
payload: {
|
|
1218
|
+
device: Device$1;
|
|
1219
|
+
passphraseState?: string;
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
interface UiRequestPassphraseOnDevice {
|
|
1214
1223
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1215
1224
|
payload: {
|
|
1216
1225
|
device: Device$1;
|
|
@@ -1224,7 +1233,7 @@ interface FirmwareProgress {
|
|
|
1224
1233
|
progress: number;
|
|
1225
1234
|
};
|
|
1226
1235
|
}
|
|
1227
|
-
declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton |
|
|
1236
|
+
declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPassphraseOnDevice | FirmwareProgress | UiRequestPassphrase;
|
|
1228
1237
|
declare type UiEventMessage = UiEvent & {
|
|
1229
1238
|
event: typeof UI_EVENT;
|
|
1230
1239
|
};
|
|
@@ -1299,12 +1308,21 @@ declare type CallMethodKeys = keyof CoreApi;
|
|
|
1299
1308
|
|
|
1300
1309
|
declare const UI_RESPONSE: {
|
|
1301
1310
|
readonly RECEIVE_PIN: "ui-receive_pin";
|
|
1311
|
+
readonly RECEIVE_PASSPHRASE: "ui-receive_passphrase";
|
|
1302
1312
|
};
|
|
1303
1313
|
interface UiResponsePin {
|
|
1304
1314
|
type: typeof UI_RESPONSE.RECEIVE_PIN;
|
|
1305
1315
|
payload: string;
|
|
1306
1316
|
}
|
|
1307
|
-
|
|
1317
|
+
interface UiResponsePassphrase {
|
|
1318
|
+
type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;
|
|
1319
|
+
payload: {
|
|
1320
|
+
value: string;
|
|
1321
|
+
passphraseOnDevice?: boolean;
|
|
1322
|
+
save?: boolean;
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
declare type UiResponseEvent = UiResponsePin | UiResponsePassphrase;
|
|
1308
1326
|
declare type UiResponseMessage = UiResponseEvent & {
|
|
1309
1327
|
event: typeof UI_EVENT;
|
|
1310
1328
|
};
|
|
@@ -1415,6 +1433,11 @@ declare type TypedCallResponseMap = {
|
|
|
1415
1433
|
[K in keyof MessageType]: TypedResponseMessage<K>;
|
|
1416
1434
|
};
|
|
1417
1435
|
declare type DefaultMessageResponse = TypedCallResponseMap[keyof MessageType];
|
|
1436
|
+
declare type PassphrasePromptResponse = {
|
|
1437
|
+
passphrase?: string;
|
|
1438
|
+
passphraseOnDevice?: boolean;
|
|
1439
|
+
cache?: boolean;
|
|
1440
|
+
};
|
|
1418
1441
|
declare class DeviceCommands {
|
|
1419
1442
|
device: Device;
|
|
1420
1443
|
transport: Transport;
|
|
@@ -1428,14 +1451,16 @@ declare class DeviceCommands {
|
|
|
1428
1451
|
typedCall<T extends MessageKey, R extends MessageKey[]>(type: T, resType: R, msg?: MessageType[T]): Promise<TypedCallResponseMap[R[number]]>;
|
|
1429
1452
|
typedCall<T extends MessageKey, R extends MessageKey>(type: T, resType: R, msg?: MessageType[T]): Promise<TypedResponseMessage<R>>;
|
|
1430
1453
|
_commonCall(type: MessageKey, msg?: DefaultMessageResponse['message']): Promise<DefaultMessageResponse>;
|
|
1431
|
-
_filterCommonTypes(res: DefaultMessageResponse): Promise<DefaultMessageResponse>;
|
|
1454
|
+
_filterCommonTypes(res: DefaultMessageResponse, callType: MessageKey): Promise<DefaultMessageResponse>;
|
|
1432
1455
|
_promptPin(type?: Messages.PinMatrixRequestType): Promise<string>;
|
|
1456
|
+
_promptPassphrase(): Promise<PassphrasePromptResponse>;
|
|
1433
1457
|
}
|
|
1434
1458
|
|
|
1435
1459
|
declare type InitOptions = {
|
|
1436
1460
|
initSession?: boolean;
|
|
1437
1461
|
deviceId?: string;
|
|
1438
1462
|
passphraseState?: string;
|
|
1463
|
+
skipPassphraseCheck?: boolean;
|
|
1439
1464
|
};
|
|
1440
1465
|
declare type RunOptions = {
|
|
1441
1466
|
keepSession?: boolean;
|
|
@@ -1445,6 +1470,7 @@ interface DeviceEvents {
|
|
|
1445
1470
|
[DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
|
|
1446
1471
|
[DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
|
|
1447
1472
|
[DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
|
|
1473
|
+
[DEVICE.PASSPHRASE]: [Device, (response: PassphrasePromptResponse, error?: Error) => void];
|
|
1448
1474
|
}
|
|
1449
1475
|
interface Device {
|
|
1450
1476
|
on<K extends keyof DeviceEvents>(type: K, listener: (...event: DeviceEvents[K]) => void): this;
|
|
@@ -1466,6 +1492,7 @@ declare class Device extends EventEmitter {
|
|
|
1466
1492
|
needReloadDevice: boolean;
|
|
1467
1493
|
keepSession: boolean;
|
|
1468
1494
|
passphraseState: string | undefined;
|
|
1495
|
+
skipPassphraseCheck: boolean | undefined;
|
|
1469
1496
|
constructor(descriptor: OneKeyDeviceInfo);
|
|
1470
1497
|
static fromDescriptor(originalDescriptor: OneKeyDeviceInfo): Device;
|
|
1471
1498
|
toMessageObject(): Device$1 | null;
|
|
@@ -1621,4 +1648,4 @@ declare class DataManager {
|
|
|
1621
1648
|
|
|
1622
1649
|
declare const HardwareSdk: ({ init, call, dispose, eventEmitter, uiResponse, cancel, }: InjectApi) => CoreApi;
|
|
1623
1650
|
|
|
1624
|
-
export { AccountAddress, AccountAddresses, AptosAddress, AptosGetAddressParams, AptosSignTransactionParams, AptosSignedTx, AssetsMap, BTCAddress, BTCGetAddressParams, BTCGetPublicKeyParams, BTCPublicKey, BTCSignMessageParams, BTCSignTransactionParams, BTCVerifyMessageParams, BleReleaseInfoEvent, BleReleaseInfoPayload, CORE_EVENT, CallMethod, CallMethodAnyResponse, CallMethodKeys, CallMethodPayload, CallMethodResponse, CallMethodUnion, CipheredKeyValue, CipheredKeyValueParams, CommonParams, ConfluxAddress, ConfluxGetAddressParams, ConfluxSignMessageCIP23Params, ConfluxSignMessageParams, ConfluxSignTransactionParams, ConfluxSignedTx, ConfluxTransaction, ConnectSettings, Core, CoreApi, CoreMessage, DEFAULT_PRIORITY, DEVICE, DEVICE_EVENT, DataManager, Device$1 as Device, DeviceButtonRequest, DeviceButtonRequestPayload, DeviceChangePinParams, DeviceConnnectRequest, DeviceDisconnnectRequest, DeviceEvent, DeviceEventListenerFn, DeviceEventMessage, DeviceFeaturesPayload, DeviceFirmwareRange, DeviceFlagsParams, DeviceMode, DeviceRecoveryParams, DeviceResetParams, DeviceSendFeatures, DeviceSendSupportFeatures, DeviceSettingsParams, DeviceStatus, DeviceSupportFeatures, DeviceSupportFeaturesPayload, DeviceTypeMap, DeviceVerifyParams, DeviceVerifySignature, EVMAccessList, EVMAddress, EVMGetAddressParams, EVMGetPublicKeyParams, EVMPublicKey, EVMSignMessageEIP712Params, EVMSignMessageParams, EVMSignTransactionParams, EVMSignTypedDataParams, EVMSignedTx, EVMTransaction, EVMTransactionEIP1559, EVMVerifyMessageParams, EthereumSignTypedDataMessage, EthereumSignTypedDataTypeProperty, EthereumSignTypedDataTypes, FIRMWARE, FIRMWARE_EVENT, Features, FirmwareEvent, FirmwareMessage, FirmwareProgress, FirmwareRange, FirmwareRelease$1 as FirmwareRelease, IBLEFirmwareReleaseInfo, IDeviceBLEFirmwareStatus, IDeviceFirmwareStatus, IDeviceModel, IDeviceType, IFRAME, IFirmwareReleaseInfo, IFrameBridge, IFrameCallMessage, IFrameCancelMessage, IFrameEvent, IFrameEventMessage, IFrameInit, ILocale, ITransportStatus, IVersionArray, KnownDevice, LOG, LOG_EVENT, LogEvent, LogEventMessage, LogOutput, LoggerNames, MajorVersion, MethodResponseMessage, NEMAddress, NEMAggregateModificationTransaction, NEMGetAddressParams, NEMImportanceTransaction, NEMMosaic, NEMMosaicCreationTransaction, NEMMultisigTransaction, NEMProvisionNamespaceTransaction, NEMSignTransactionParams, NEMSupplyChangeTransaction, NEMTransaction, NEMTransferTransaction, NearAddress, NearGetAddressParams, NearSignTransactionParams, Params, PostMessageEvent, RESPONSE_EVENT, RefTransaction, ReleaseInfo, ReleaseInfoEvent, ReleaseInfoPayload, RemoteConfigResponse, Response, SearchDevice, SignedTransaction, SolanaAddress, SolanaGetAddressParams, SolanaSignTransactionParams, SolanaSignedTx, StarcoinAddress, StarcoinGetAddressParams, StarcoinGetPublicKeyParams, StarcoinPublicKey, StarcoinSignMessageParams, StarcoinSignTransactionParams, StarcoinVerifyMessageParams, StellarAddress, StellarAsset, StellarGetAddressParams, StellarOperation, StellarSignTransactionParams, StellarTransaction, StrictFeatures, Success, SupportFeatureType, SupportFeatures, TransactionOptions, TransportReleaseStatus, TronAddress, TronGetAddressParams, TronSignMessageParams, TronSignTransactionParams, TronTransaction, TronTransactionContract, TronTransferContract, TronTriggerSmartContract, UI_EVENT, UI_REQUEST, UI_RESPONSE, UiEvent, UiEventMessage, UiPromise, UiPromiseResponse, UiRequestButton, UiRequestDeviceAction, UiRequestPassphrase, UiRequestWithoutPayload, UiResponseEvent, UiResponseMessage, UiResponsePin, UnavailableCapabilities, UnavailableCapability, Unsuccessful, VersionArray, corsValidator, createDeviceMessage, createErrorMessage, createFirmwareMessage, createIFrameMessage, createLogMessage, createResponseMessage, createUiMessage, createUiResponse, HardwareSdk as default, enableLog, getDeviceLabel, getDeviceType, getDeviceTypeByBleName, getDeviceTypeByDeviceId, getDeviceUUID, getEnv, getHDPath, getLog, getLogger, getSDKVersion, getScriptType, getTimeStamp, httpRequest, init as initCore, isValidVersionArray, isValidVersionString, normalizeVersionArray, parseConnectSettings, parseMessage, patchFeatures, safeThrowError, setLoggerPostMessage, versionCompare, versionSplit };
|
|
1651
|
+
export { AccountAddress, AccountAddresses, AptosAddress, AptosGetAddressParams, AptosSignTransactionParams, AptosSignedTx, AssetsMap, BTCAddress, BTCGetAddressParams, BTCGetPublicKeyParams, BTCPublicKey, BTCSignMessageParams, BTCSignTransactionParams, BTCVerifyMessageParams, BleReleaseInfoEvent, BleReleaseInfoPayload, CORE_EVENT, CallMethod, CallMethodAnyResponse, CallMethodKeys, CallMethodPayload, CallMethodResponse, CallMethodUnion, CipheredKeyValue, CipheredKeyValueParams, CommonParams, ConfluxAddress, ConfluxGetAddressParams, ConfluxSignMessageCIP23Params, ConfluxSignMessageParams, ConfluxSignTransactionParams, ConfluxSignedTx, ConfluxTransaction, ConnectSettings, Core, CoreApi, CoreMessage, DEFAULT_PRIORITY, DEVICE, DEVICE_EVENT, DataManager, Device$1 as Device, DeviceButtonRequest, DeviceButtonRequestPayload, DeviceChangePinParams, DeviceConnnectRequest, DeviceDisconnnectRequest, DeviceEvent, DeviceEventListenerFn, DeviceEventMessage, DeviceFeaturesPayload, DeviceFirmwareRange, DeviceFlagsParams, DeviceMode, DeviceRecoveryParams, DeviceResetParams, DeviceSendFeatures, DeviceSendSupportFeatures, DeviceSettingsParams, DeviceStatus, DeviceSupportFeatures, DeviceSupportFeaturesPayload, DeviceTypeMap, DeviceVerifyParams, DeviceVerifySignature, EVMAccessList, EVMAddress, EVMGetAddressParams, EVMGetPublicKeyParams, EVMPublicKey, EVMSignMessageEIP712Params, EVMSignMessageParams, EVMSignTransactionParams, EVMSignTypedDataParams, EVMSignedTx, EVMTransaction, EVMTransactionEIP1559, EVMVerifyMessageParams, EthereumSignTypedDataMessage, EthereumSignTypedDataTypeProperty, EthereumSignTypedDataTypes, FIRMWARE, FIRMWARE_EVENT, Features, FirmwareEvent, FirmwareMessage, FirmwareProgress, FirmwareRange, FirmwareRelease$1 as FirmwareRelease, IBLEFirmwareReleaseInfo, IDeviceBLEFirmwareStatus, IDeviceFirmwareStatus, IDeviceModel, IDeviceType, IFRAME, IFirmwareReleaseInfo, IFrameBridge, IFrameCallMessage, IFrameCancelMessage, IFrameEvent, IFrameEventMessage, IFrameInit, ILocale, ITransportStatus, IVersionArray, KnownDevice, LOG, LOG_EVENT, LogEvent, LogEventMessage, LogOutput, LoggerNames, MajorVersion, MethodResponseMessage, NEMAddress, NEMAggregateModificationTransaction, NEMGetAddressParams, NEMImportanceTransaction, NEMMosaic, NEMMosaicCreationTransaction, NEMMultisigTransaction, NEMProvisionNamespaceTransaction, NEMSignTransactionParams, NEMSupplyChangeTransaction, NEMTransaction, NEMTransferTransaction, NearAddress, NearGetAddressParams, NearSignTransactionParams, Params, PostMessageEvent, RESPONSE_EVENT, RefTransaction, ReleaseInfo, ReleaseInfoEvent, ReleaseInfoPayload, RemoteConfigResponse, Response, SearchDevice, SignedTransaction, SolanaAddress, SolanaGetAddressParams, SolanaSignTransactionParams, SolanaSignedTx, StarcoinAddress, StarcoinGetAddressParams, StarcoinGetPublicKeyParams, StarcoinPublicKey, StarcoinSignMessageParams, StarcoinSignTransactionParams, StarcoinVerifyMessageParams, StellarAddress, StellarAsset, StellarGetAddressParams, StellarOperation, StellarSignTransactionParams, StellarTransaction, StrictFeatures, Success, SupportFeatureType, SupportFeatures, TransactionOptions, TransportReleaseStatus, TronAddress, TronGetAddressParams, TronSignMessageParams, TronSignTransactionParams, TronTransaction, TronTransactionContract, TronTransferContract, TronTriggerSmartContract, UI_EVENT, UI_REQUEST, UI_RESPONSE, UiEvent, UiEventMessage, UiPromise, UiPromiseResponse, UiRequestButton, UiRequestDeviceAction, UiRequestPassphrase, UiRequestPassphraseOnDevice, UiRequestWithoutPayload, UiResponseEvent, UiResponseMessage, UiResponsePassphrase, UiResponsePin, UnavailableCapabilities, UnavailableCapability, Unsuccessful, VersionArray, corsValidator, createDeviceMessage, createErrorMessage, createFirmwareMessage, createIFrameMessage, createLogMessage, createResponseMessage, createUiMessage, createUiResponse, HardwareSdk as default, enableLog, getDeviceLabel, getDeviceType, getDeviceTypeByBleName, getDeviceTypeByDeviceId, getDeviceUUID, getEnv, getHDPath, getLog, getLogger, getSDKVersion, getScriptType, getTimeStamp, httpRequest, init as initCore, isValidVersionArray, isValidVersionString, normalizeVersionArray, parseConnectSettings, parseMessage, patchFeatures, safeThrowError, setLoggerPostMessage, versionCompare, versionSplit };
|
package/dist/index.js
CHANGED
|
@@ -10460,6 +10460,7 @@ const UI_REQUEST$1 = {
|
|
|
10460
10460
|
REQUEST_PIN: 'ui-request_pin',
|
|
10461
10461
|
INVALID_PIN: 'ui-invalid_pin',
|
|
10462
10462
|
REQUEST_BUTTON: 'ui-button',
|
|
10463
|
+
REQUEST_PASSPHRASE: 'ui-request_passphrase',
|
|
10463
10464
|
REQUEST_PASSPHRASE_ON_DEVICE: 'ui-request_passphrase_on_device',
|
|
10464
10465
|
CLOSE_UI_WINDOW: 'ui-close_window',
|
|
10465
10466
|
BLUETOOTH_PERMISSION: 'ui-bluetooth_permission',
|
|
@@ -10497,6 +10498,7 @@ const createResponseMessage = (id, success, payload) => ({
|
|
|
10497
10498
|
|
|
10498
10499
|
const UI_RESPONSE = {
|
|
10499
10500
|
RECEIVE_PIN: 'ui-receive_pin',
|
|
10501
|
+
RECEIVE_PASSPHRASE: 'ui-receive_passphrase',
|
|
10500
10502
|
};
|
|
10501
10503
|
const createUiResponse = (type, payload) => ({
|
|
10502
10504
|
event: UI_EVENT,
|
|
@@ -10628,7 +10630,6 @@ class DevicePool extends events.exports {
|
|
|
10628
10630
|
}
|
|
10629
10631
|
finally { if (e_1) throw e_1.error; }
|
|
10630
10632
|
}
|
|
10631
|
-
Log$7.debug('get devices result : ', devices, deviceList);
|
|
10632
10633
|
console.log('device poll -> connected: ', this.connectedPool);
|
|
10633
10634
|
console.log('device poll -> disconnected: ', this.disconnectPool);
|
|
10634
10635
|
yield this._checkDevicePool(initOptions);
|
|
@@ -10895,10 +10896,10 @@ class DeviceCommands {
|
|
|
10895
10896
|
_commonCall(type, msg) {
|
|
10896
10897
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10897
10898
|
const resp = yield this.call(type, msg);
|
|
10898
|
-
return this._filterCommonTypes(resp);
|
|
10899
|
+
return this._filterCommonTypes(resp, type);
|
|
10899
10900
|
});
|
|
10900
10901
|
}
|
|
10901
|
-
_filterCommonTypes(res) {
|
|
10902
|
+
_filterCommonTypes(res, callType) {
|
|
10902
10903
|
Log$5.debug('_filterCommonTypes: ', res);
|
|
10903
10904
|
if (res.type === 'Failure') {
|
|
10904
10905
|
const { code, message } = res.message;
|
|
@@ -10918,6 +10919,9 @@ class DeviceCommands {
|
|
|
10918
10919
|
if (code === 'Failure_DataError' && message === 'Please confirm the BlindSign enabled') {
|
|
10919
10920
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BlindSignDisabled);
|
|
10920
10921
|
}
|
|
10922
|
+
if (code === 'Failure_UnexpectedMessage' && callType === 'PassphraseAck') {
|
|
10923
|
+
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.UnexpectPassphrase);
|
|
10924
|
+
}
|
|
10921
10925
|
if (error) {
|
|
10922
10926
|
return Promise.reject(error);
|
|
10923
10927
|
}
|
|
@@ -10949,9 +10953,12 @@ class DeviceCommands {
|
|
|
10949
10953
|
}, () => this._commonCall('Cancel', {}));
|
|
10950
10954
|
}
|
|
10951
10955
|
if (res.type === 'PassphraseRequest') {
|
|
10952
|
-
return
|
|
10953
|
-
|
|
10954
|
-
|
|
10956
|
+
return this._promptPassphrase().then(response => {
|
|
10957
|
+
const { passphrase, passphraseOnDevice } = response;
|
|
10958
|
+
return !passphraseOnDevice
|
|
10959
|
+
? this._commonCall('PassphraseAck', { passphrase })
|
|
10960
|
+
: this._commonCall('PassphraseAck', { on_device: true });
|
|
10961
|
+
});
|
|
10955
10962
|
}
|
|
10956
10963
|
if (res.type === 'Deprecated_PassphraseStateRequest') ;
|
|
10957
10964
|
if (res.type === 'WordRequest') ;
|
|
@@ -10977,6 +10984,26 @@ class DeviceCommands {
|
|
|
10977
10984
|
}
|
|
10978
10985
|
});
|
|
10979
10986
|
}
|
|
10987
|
+
_promptPassphrase() {
|
|
10988
|
+
return new Promise((resolve, reject) => {
|
|
10989
|
+
if (this.device.listenerCount(DEVICE.PASSPHRASE) > 0) {
|
|
10990
|
+
this._cancelableRequest = reject;
|
|
10991
|
+
this.device.emit(DEVICE.PASSPHRASE, this.device, (response, error) => {
|
|
10992
|
+
this._cancelableRequest = undefined;
|
|
10993
|
+
if (error) {
|
|
10994
|
+
reject(error);
|
|
10995
|
+
}
|
|
10996
|
+
else {
|
|
10997
|
+
resolve(response);
|
|
10998
|
+
}
|
|
10999
|
+
});
|
|
11000
|
+
}
|
|
11001
|
+
else {
|
|
11002
|
+
Log$5.error('[DeviceCommands] [call] Passphrase callback not configured, cancelling request');
|
|
11003
|
+
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, '_promptPassphrase: Passphrase callback not configured'));
|
|
11004
|
+
}
|
|
11005
|
+
});
|
|
11006
|
+
}
|
|
10980
11007
|
}
|
|
10981
11008
|
|
|
10982
11009
|
const UI_REQUEST = {
|
|
@@ -11100,6 +11127,7 @@ class Device extends events.exports {
|
|
|
11100
11127
|
this.needReloadDevice = false;
|
|
11101
11128
|
this.keepSession = false;
|
|
11102
11129
|
this.passphraseState = undefined;
|
|
11130
|
+
this.skipPassphraseCheck = false;
|
|
11103
11131
|
this.originalDescriptor = descriptor;
|
|
11104
11132
|
}
|
|
11105
11133
|
static fromDescriptor(originalDescriptor) {
|
|
@@ -11226,11 +11254,13 @@ class Device extends events.exports {
|
|
|
11226
11254
|
}
|
|
11227
11255
|
getInternalState(_deviceId) {
|
|
11228
11256
|
var _a, _b;
|
|
11229
|
-
Log$4.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `features.device_id: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id}`, `passphraseState: ${this.passphraseState}`);
|
|
11257
|
+
Log$4.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `features.device_id: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id}`, `passphraseState: ${this.passphraseState}`, `skipPassphraseCheck: ${this.skipPassphraseCheck}`);
|
|
11230
11258
|
Log$4.debug('getInternalState session cache: ', deviceSessionCache);
|
|
11231
11259
|
const deviceId = _deviceId || ((_b = this.features) === null || _b === void 0 ? void 0 : _b.device_id);
|
|
11232
11260
|
if (!deviceId)
|
|
11233
11261
|
return undefined;
|
|
11262
|
+
if (this.skipPassphraseCheck)
|
|
11263
|
+
return deviceSessionCache[deviceId];
|
|
11234
11264
|
if (!this.passphraseState)
|
|
11235
11265
|
return undefined;
|
|
11236
11266
|
const usePassKey = `${deviceId}@${this.passphraseState}`;
|
|
@@ -11247,8 +11277,10 @@ class Device extends events.exports {
|
|
|
11247
11277
|
Log$4.debug('setInternalState session param: ', `state: ${state}`, `initSession: ${initSession}`, `device_id: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id}`, `passphraseState: ${this.passphraseState}`);
|
|
11248
11278
|
if (!this.features)
|
|
11249
11279
|
return;
|
|
11250
|
-
if (!this.
|
|
11251
|
-
|
|
11280
|
+
if (!this.skipPassphraseCheck) {
|
|
11281
|
+
if (!this.passphraseState && !initSession)
|
|
11282
|
+
return;
|
|
11283
|
+
}
|
|
11252
11284
|
let key = `${this.features.device_id}`;
|
|
11253
11285
|
if (this.passphraseState) {
|
|
11254
11286
|
key += `@${this.passphraseState}`;
|
|
@@ -11275,6 +11307,7 @@ class Device extends events.exports {
|
|
|
11275
11307
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11276
11308
|
Log$4.debug('initialize param:', options);
|
|
11277
11309
|
this.passphraseState = options === null || options === void 0 ? void 0 : options.passphraseState;
|
|
11310
|
+
this.skipPassphraseCheck = options === null || options === void 0 ? void 0 : options.skipPassphraseCheck;
|
|
11278
11311
|
if (options === null || options === void 0 ? void 0 : options.initSession) {
|
|
11279
11312
|
this.clearInternalState(options === null || options === void 0 ? void 0 : options.deviceId);
|
|
11280
11313
|
}
|
|
@@ -15025,6 +15058,7 @@ const Log = getLogger(exports.LoggerNames.Core);
|
|
|
15025
15058
|
const parseInitOptions = (method) => ({
|
|
15026
15059
|
initSession: method === null || method === void 0 ? void 0 : method.payload.initSession,
|
|
15027
15060
|
passphraseState: method === null || method === void 0 ? void 0 : method.payload.passphraseState,
|
|
15061
|
+
skipPassphraseCheck: method === null || method === void 0 ? void 0 : method.payload.skipPassphraseCheck,
|
|
15028
15062
|
deviceId: method === null || method === void 0 ? void 0 : method.payload.deviceId,
|
|
15029
15063
|
});
|
|
15030
15064
|
let _core;
|
|
@@ -15092,7 +15126,8 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
15092
15126
|
(_a = method.setDevice) === null || _a === void 0 ? void 0 : _a.call(method, device);
|
|
15093
15127
|
device.on(DEVICE.PIN, onDevicePinHandler);
|
|
15094
15128
|
device.on(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
15095
|
-
device.on(DEVICE.
|
|
15129
|
+
device.on(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
|
|
15130
|
+
device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
15096
15131
|
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
15097
15132
|
try {
|
|
15098
15133
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -15138,11 +15173,13 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
15138
15173
|
require: support.require,
|
|
15139
15174
|
}));
|
|
15140
15175
|
}
|
|
15141
|
-
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15176
|
+
if (!method.payload.skipPassphraseCheck) {
|
|
15177
|
+
const passphraseState = yield device.checkPassphraseState();
|
|
15178
|
+
checkPassphraseSafety(method, device.features);
|
|
15179
|
+
if (passphraseState) {
|
|
15180
|
+
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
15181
|
+
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckPassphraseStateError));
|
|
15182
|
+
}
|
|
15146
15183
|
}
|
|
15147
15184
|
}
|
|
15148
15185
|
try {
|
|
@@ -15367,6 +15404,8 @@ const cancel = (connectId) => {
|
|
|
15367
15404
|
const checkPassphraseSafety = (method, features) => {
|
|
15368
15405
|
if (!method.useDevicePassphraseState)
|
|
15369
15406
|
return;
|
|
15407
|
+
if (method.payload.skipPassphraseCheck)
|
|
15408
|
+
return;
|
|
15370
15409
|
if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === true && !method.payload.passphraseState) {
|
|
15371
15410
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
15372
15411
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceOpenedPassphrase);
|
|
@@ -15383,7 +15422,8 @@ const cleanup = () => {
|
|
|
15383
15422
|
const removeDeviceListener = (device) => {
|
|
15384
15423
|
device.removeListener(DEVICE.PIN, onDevicePinHandler);
|
|
15385
15424
|
device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
15386
|
-
device.removeListener(DEVICE.
|
|
15425
|
+
device.removeListener(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
|
|
15426
|
+
device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
15387
15427
|
device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
15388
15428
|
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
15389
15429
|
};
|
|
@@ -15425,7 +15465,22 @@ const onDeviceButtonHandler = (...[device, request]) => {
|
|
|
15425
15465
|
const onDeviceFeaturesHandler = (...[_, features]) => {
|
|
15426
15466
|
postMessage(createDeviceMessage(DEVICE.FEATURES, Object.assign({}, features)));
|
|
15427
15467
|
};
|
|
15428
|
-
const onDevicePassphraseHandler = (...[device]) => {
|
|
15468
|
+
const onDevicePassphraseHandler = (...[device, callback]) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15469
|
+
Log.debug('onDevicePassphraseHandler');
|
|
15470
|
+
const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PASSPHRASE, device);
|
|
15471
|
+
postMessage(createUiMessage(UI_REQUEST$1.REQUEST_PASSPHRASE, {
|
|
15472
|
+
device: device.toMessageObject(),
|
|
15473
|
+
passphraseState: device.passphraseState,
|
|
15474
|
+
}));
|
|
15475
|
+
const uiResp = yield uiPromise.promise;
|
|
15476
|
+
const { value, passphraseOnDevice, save } = uiResp.payload;
|
|
15477
|
+
callback({
|
|
15478
|
+
passphrase: value.normalize('NFKD'),
|
|
15479
|
+
passphraseOnDevice,
|
|
15480
|
+
cache: save,
|
|
15481
|
+
});
|
|
15482
|
+
});
|
|
15483
|
+
const onEnterPassphraseOnDeviceHandler = (...[device]) => {
|
|
15429
15484
|
postMessage(createUiMessage(UI_REQUEST$1.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
15430
15485
|
device: device.toMessageObject(),
|
|
15431
15486
|
passphraseState: device.passphraseState,
|
|
@@ -15448,7 +15503,8 @@ class Core extends events.exports {
|
|
|
15448
15503
|
var _a, _b, _c, _d;
|
|
15449
15504
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15450
15505
|
switch (message.type) {
|
|
15451
|
-
case UI_RESPONSE.RECEIVE_PIN:
|
|
15506
|
+
case UI_RESPONSE.RECEIVE_PIN:
|
|
15507
|
+
case UI_RESPONSE.RECEIVE_PASSPHRASE: {
|
|
15452
15508
|
const uiPromise = findUiPromise(message.type);
|
|
15453
15509
|
if (uiPromise) {
|
|
15454
15510
|
uiPromise.resolve(message);
|
package/dist/types/params.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/types/params.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,UAAU,CAAC,EAAE,MAAM,CAAC;IAIpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,eAAe,CAAC,EAAE,MAAM,CAAC;IAIzB,WAAW,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/types/params.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,UAAU,CAAC,EAAE,MAAM,CAAC;IAIpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,eAAe,CAAC,EAAE,MAAM,CAAC;IAIzB,WAAW,CAAC,EAAE,OAAO,CAAC;IAMtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,oBAAY,MAAM,CAAC,CAAC,IAAI,YAAY,GAAG,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD;AAED,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,oBAAY,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@onekeyfe/hd-shared": "^0.1.
|
|
28
|
-
"@onekeyfe/hd-transport": "^0.1.
|
|
27
|
+
"@onekeyfe/hd-shared": "^0.1.51",
|
|
28
|
+
"@onekeyfe/hd-transport": "^0.1.51",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"bignumber.js": "^9.0.2",
|
|
31
31
|
"js-sha256": "^0.9.0",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"@types/parse-uri": "^1.0.0",
|
|
37
37
|
"@types/semver": "^7.3.9"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "0bc84671cf1fabb0f50339407dd43ad82ff096b8"
|
|
40
40
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -44,6 +44,7 @@ const Log = getLogger(LoggerNames.Core);
|
|
|
44
44
|
const parseInitOptions = (method?: BaseMethod): InitOptions => ({
|
|
45
45
|
initSession: method?.payload.initSession,
|
|
46
46
|
passphraseState: method?.payload.passphraseState,
|
|
47
|
+
skipPassphraseCheck: method?.payload.skipPassphraseCheck,
|
|
47
48
|
deviceId: method?.payload.deviceId,
|
|
48
49
|
});
|
|
49
50
|
|
|
@@ -132,7 +133,8 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
132
133
|
|
|
133
134
|
device.on(DEVICE.PIN, onDevicePinHandler);
|
|
134
135
|
device.on(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
135
|
-
device.on(DEVICE.
|
|
136
|
+
device.on(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
|
|
137
|
+
device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
136
138
|
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
137
139
|
|
|
138
140
|
try {
|
|
@@ -228,17 +230,19 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
228
230
|
);
|
|
229
231
|
}
|
|
230
232
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
+
if (!method.payload.skipPassphraseCheck) {
|
|
234
|
+
// Check Device passphrase State
|
|
235
|
+
const passphraseState = await device.checkPassphraseState();
|
|
233
236
|
|
|
234
|
-
|
|
235
|
-
|
|
237
|
+
// Double check, handles the special case of Touch/Pro
|
|
238
|
+
checkPassphraseSafety(method, device.features);
|
|
236
239
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
if (passphraseState) {
|
|
241
|
+
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
242
|
+
return Promise.reject(
|
|
243
|
+
ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError)
|
|
244
|
+
);
|
|
245
|
+
}
|
|
242
246
|
}
|
|
243
247
|
}
|
|
244
248
|
|
|
@@ -507,6 +511,9 @@ export const cancel = (connectId?: string) => {
|
|
|
507
511
|
const checkPassphraseSafety = (method: BaseMethod, features?: Features) => {
|
|
508
512
|
if (!method.useDevicePassphraseState) return;
|
|
509
513
|
|
|
514
|
+
// skip check passphrase status
|
|
515
|
+
if (method.payload.skipPassphraseCheck) return;
|
|
516
|
+
|
|
510
517
|
if (features?.passphrase_protection === true && !method.payload.passphraseState) {
|
|
511
518
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
512
519
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceOpenedPassphrase);
|
|
@@ -526,7 +533,8 @@ const cleanup = () => {
|
|
|
526
533
|
const removeDeviceListener = (device: Device) => {
|
|
527
534
|
device.removeListener(DEVICE.PIN, onDevicePinHandler);
|
|
528
535
|
device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
529
|
-
device.removeListener(DEVICE.
|
|
536
|
+
device.removeListener(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
|
|
537
|
+
device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
530
538
|
device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
531
539
|
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
532
540
|
// DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
@@ -587,7 +595,29 @@ const onDeviceFeaturesHandler = (...[_, features]: [...DeviceEvents['features']]
|
|
|
587
595
|
postMessage(createDeviceMessage(DEVICE.FEATURES, { ...features }));
|
|
588
596
|
};
|
|
589
597
|
|
|
590
|
-
const onDevicePassphraseHandler = (...[device]:
|
|
598
|
+
const onDevicePassphraseHandler = async (...[device, callback]: DeviceEvents['passphrase']) => {
|
|
599
|
+
Log.debug('onDevicePassphraseHandler');
|
|
600
|
+
const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PASSPHRASE, device);
|
|
601
|
+
postMessage(
|
|
602
|
+
createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE, {
|
|
603
|
+
device: device.toMessageObject() as KnownDevice,
|
|
604
|
+
passphraseState: device.passphraseState,
|
|
605
|
+
})
|
|
606
|
+
);
|
|
607
|
+
// wait for passphrase
|
|
608
|
+
const uiResp = await uiPromise.promise;
|
|
609
|
+
const { value, passphraseOnDevice, save } = uiResp.payload;
|
|
610
|
+
// send as PassphrasePromptResponse
|
|
611
|
+
callback({
|
|
612
|
+
passphrase: value.normalize('NFKD'),
|
|
613
|
+
passphraseOnDevice,
|
|
614
|
+
cache: save,
|
|
615
|
+
});
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
const onEnterPassphraseOnDeviceHandler = (
|
|
619
|
+
...[device]: [...DeviceEvents['passphrase_on_device']]
|
|
620
|
+
) => {
|
|
591
621
|
postMessage(
|
|
592
622
|
createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
593
623
|
device: device.toMessageObject() as KnownDevice,
|
|
@@ -624,7 +654,8 @@ const removeUiPromise = (promise: Deferred<any>) => {
|
|
|
624
654
|
export default class Core extends EventEmitter {
|
|
625
655
|
async handleMessage(message: CoreMessage) {
|
|
626
656
|
switch (message.type) {
|
|
627
|
-
case UI_RESPONSE.RECEIVE_PIN:
|
|
657
|
+
case UI_RESPONSE.RECEIVE_PIN:
|
|
658
|
+
case UI_RESPONSE.RECEIVE_PASSPHRASE: {
|
|
628
659
|
const uiPromise = findUiPromise(message.type);
|
|
629
660
|
if (uiPromise) {
|
|
630
661
|
uiPromise.resolve(message);
|
package/src/device/Device.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
|
|
20
20
|
import type DeviceConnector from './DeviceConnector';
|
|
21
21
|
// eslint-disable-next-line import/no-cycle
|
|
22
|
-
import { DeviceCommands } from './DeviceCommands';
|
|
22
|
+
import { DeviceCommands, PassphrasePromptResponse } from './DeviceCommands';
|
|
23
23
|
|
|
24
24
|
import type { Features, Device as DeviceTyped, UnavailableCapabilities } from '../types';
|
|
25
25
|
import { DEVICE, DeviceButtonRequestPayload, DeviceFeaturesPayload } from '../events';
|
|
@@ -32,6 +32,7 @@ export type InitOptions = {
|
|
|
32
32
|
initSession?: boolean;
|
|
33
33
|
deviceId?: string;
|
|
34
34
|
passphraseState?: string;
|
|
35
|
+
skipPassphraseCheck?: boolean;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
export type RunOptions = {
|
|
@@ -50,6 +51,7 @@ export interface DeviceEvents {
|
|
|
50
51
|
[DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
|
|
51
52
|
[DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
|
|
52
53
|
[DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
|
|
54
|
+
[DEVICE.PASSPHRASE]: [Device, (response: PassphrasePromptResponse, error?: Error) => void];
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
export interface Device {
|
|
@@ -113,6 +115,8 @@ export class Device extends EventEmitter {
|
|
|
113
115
|
|
|
114
116
|
passphraseState: string | undefined = undefined;
|
|
115
117
|
|
|
118
|
+
skipPassphraseCheck: boolean | undefined = false;
|
|
119
|
+
|
|
116
120
|
constructor(descriptor: DeviceDescriptor) {
|
|
117
121
|
super();
|
|
118
122
|
this.originalDescriptor = descriptor;
|
|
@@ -255,12 +259,14 @@ export class Device extends EventEmitter {
|
|
|
255
259
|
'getInternalState session param: ',
|
|
256
260
|
`device_id: ${_deviceId}`,
|
|
257
261
|
`features.device_id: ${this.features?.device_id}`,
|
|
258
|
-
`passphraseState: ${this.passphraseState}
|
|
262
|
+
`passphraseState: ${this.passphraseState}`,
|
|
263
|
+
`skipPassphraseCheck: ${this.skipPassphraseCheck}`
|
|
259
264
|
);
|
|
260
265
|
Log.debug('getInternalState session cache: ', deviceSessionCache);
|
|
261
266
|
|
|
262
267
|
const deviceId = _deviceId || this.features?.device_id;
|
|
263
268
|
if (!deviceId) return undefined;
|
|
269
|
+
if (this.skipPassphraseCheck) return deviceSessionCache[deviceId];
|
|
264
270
|
if (!this.passphraseState) return undefined;
|
|
265
271
|
|
|
266
272
|
const usePassKey = `${deviceId}@${this.passphraseState}`;
|
|
@@ -285,7 +291,9 @@ export class Device extends EventEmitter {
|
|
|
285
291
|
);
|
|
286
292
|
|
|
287
293
|
if (!this.features) return;
|
|
288
|
-
if (!this.
|
|
294
|
+
if (!this.skipPassphraseCheck) {
|
|
295
|
+
if (!this.passphraseState && !initSession) return;
|
|
296
|
+
}
|
|
289
297
|
|
|
290
298
|
let key = `${this.features.device_id}`;
|
|
291
299
|
if (this.passphraseState) {
|
|
@@ -315,6 +323,7 @@ export class Device extends EventEmitter {
|
|
|
315
323
|
Log.debug('initialize param:', options);
|
|
316
324
|
|
|
317
325
|
this.passphraseState = options?.passphraseState;
|
|
326
|
+
this.skipPassphraseCheck = options?.skipPassphraseCheck;
|
|
318
327
|
|
|
319
328
|
if (options?.initSession) {
|
|
320
329
|
this.clearInternalState(options?.deviceId);
|
|
@@ -137,10 +137,13 @@ export class DeviceCommands {
|
|
|
137
137
|
|
|
138
138
|
async _commonCall(type: MessageKey, msg?: DefaultMessageResponse['message']) {
|
|
139
139
|
const resp = await this.call(type, msg);
|
|
140
|
-
return this._filterCommonTypes(resp);
|
|
140
|
+
return this._filterCommonTypes(resp, type);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
_filterCommonTypes(
|
|
143
|
+
_filterCommonTypes(
|
|
144
|
+
res: DefaultMessageResponse,
|
|
145
|
+
callType: MessageKey
|
|
146
|
+
): Promise<DefaultMessageResponse> {
|
|
144
147
|
Log.debug('_filterCommonTypes: ', res);
|
|
145
148
|
if (res.type === 'Failure') {
|
|
146
149
|
const { code, message } = res.message;
|
|
@@ -166,6 +169,10 @@ export class DeviceCommands {
|
|
|
166
169
|
error = ERRORS.TypedError(HardwareErrorCode.BlindSignDisabled);
|
|
167
170
|
}
|
|
168
171
|
|
|
172
|
+
if (code === 'Failure_UnexpectedMessage' && callType === 'PassphraseAck') {
|
|
173
|
+
error = ERRORS.TypedError(HardwareErrorCode.UnexpectPassphrase);
|
|
174
|
+
}
|
|
175
|
+
|
|
169
176
|
if (error) {
|
|
170
177
|
return Promise.reject(error);
|
|
171
178
|
}
|
|
@@ -216,19 +223,12 @@ export class DeviceCommands {
|
|
|
216
223
|
}
|
|
217
224
|
|
|
218
225
|
if (res.type === 'PassphraseRequest') {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
HardwareErrorCode.DeviceNotSupportPassphrase,
|
|
226
|
-
'Device not support passphrase',
|
|
227
|
-
{
|
|
228
|
-
require: '2.4.0',
|
|
229
|
-
}
|
|
230
|
-
)
|
|
231
|
-
);
|
|
226
|
+
return this._promptPassphrase().then(response => {
|
|
227
|
+
const { passphrase, passphraseOnDevice } = response;
|
|
228
|
+
return !passphraseOnDevice
|
|
229
|
+
? this._commonCall('PassphraseAck', { passphrase })
|
|
230
|
+
: this._commonCall('PassphraseAck', { on_device: true });
|
|
231
|
+
});
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
// TT fw lower than 2.3.0, device send his current state
|
|
@@ -266,6 +266,34 @@ export class DeviceCommands {
|
|
|
266
266
|
}
|
|
267
267
|
});
|
|
268
268
|
}
|
|
269
|
+
|
|
270
|
+
_promptPassphrase() {
|
|
271
|
+
return new Promise<PassphrasePromptResponse>((resolve, reject) => {
|
|
272
|
+
if (this.device.listenerCount(DEVICE.PASSPHRASE) > 0) {
|
|
273
|
+
this._cancelableRequest = reject;
|
|
274
|
+
this.device.emit(
|
|
275
|
+
DEVICE.PASSPHRASE,
|
|
276
|
+
this.device,
|
|
277
|
+
(response: PassphrasePromptResponse, error?: Error) => {
|
|
278
|
+
this._cancelableRequest = undefined;
|
|
279
|
+
if (error) {
|
|
280
|
+
reject(error);
|
|
281
|
+
} else {
|
|
282
|
+
resolve(response);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
} else {
|
|
287
|
+
Log.error('[DeviceCommands] [call] Passphrase callback not configured, cancelling request');
|
|
288
|
+
reject(
|
|
289
|
+
ERRORS.TypedError(
|
|
290
|
+
HardwareErrorCode.RuntimeError,
|
|
291
|
+
'_promptPassphrase: Passphrase callback not configured'
|
|
292
|
+
)
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
269
297
|
}
|
|
270
298
|
|
|
271
299
|
export type TypedCall = DeviceCommands['typedCall'];
|
package/src/device/DevicePool.ts
CHANGED
|
@@ -30,17 +30,12 @@ const getDiff = (
|
|
|
30
30
|
const changedSessions = descriptors.filter(d => {
|
|
31
31
|
const currentDescriptor = current.find(x => x.path === d.path);
|
|
32
32
|
if (currentDescriptor) {
|
|
33
|
-
// return currentDescriptor.debug ? (currentDescriptor.debugSession !== d.debugSession) : (currentDescriptor.session !== d.session);
|
|
34
33
|
return currentDescriptor.session !== d.session;
|
|
35
34
|
}
|
|
36
35
|
return false;
|
|
37
36
|
});
|
|
38
37
|
const acquired = changedSessions.filter(d => typeof d.session === 'string');
|
|
39
|
-
const released = changedSessions.filter(
|
|
40
|
-
d =>
|
|
41
|
-
// const session = descriptor.debug ? descriptor.debugSession : descriptor.session;
|
|
42
|
-
typeof d.session !== 'string'
|
|
43
|
-
);
|
|
38
|
+
const released = changedSessions.filter(d => typeof d.session !== 'string');
|
|
44
39
|
|
|
45
40
|
const changedDebugSessions = descriptors.filter(d => {
|
|
46
41
|
const currentDescriptor = current.find(x => x.path === d.path);
|
|
@@ -132,7 +127,7 @@ export class DevicePool extends EventEmitter {
|
|
|
132
127
|
|
|
133
128
|
deviceList.push(device);
|
|
134
129
|
}
|
|
135
|
-
Log.debug('get devices result : ', devices, deviceList);
|
|
130
|
+
// Log.debug('get devices result : ', devices, deviceList);
|
|
136
131
|
console.log('device poll -> connected: ', this.connectedPool);
|
|
137
132
|
console.log('device poll -> disconnected: ', this.disconnectPool);
|
|
138
133
|
await this._checkDevicePool(initOptions);
|
package/src/events/ui-request.ts
CHANGED
|
@@ -9,6 +9,7 @@ export const UI_REQUEST = {
|
|
|
9
9
|
REQUEST_PIN: 'ui-request_pin',
|
|
10
10
|
INVALID_PIN: 'ui-invalid_pin',
|
|
11
11
|
REQUEST_BUTTON: 'ui-button',
|
|
12
|
+
REQUEST_PASSPHRASE: 'ui-request_passphrase',
|
|
12
13
|
REQUEST_PASSPHRASE_ON_DEVICE: 'ui-request_passphrase_on_device',
|
|
13
14
|
|
|
14
15
|
CLOSE_UI_WINDOW: 'ui-close_window',
|
|
@@ -45,6 +46,14 @@ export interface UiRequestButton {
|
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
export interface UiRequestPassphrase {
|
|
49
|
+
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
50
|
+
payload: {
|
|
51
|
+
device: Device;
|
|
52
|
+
passphraseState?: string;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface UiRequestPassphraseOnDevice {
|
|
48
57
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
49
58
|
payload: {
|
|
50
59
|
device: Device;
|
|
@@ -64,8 +73,9 @@ export type UiEvent =
|
|
|
64
73
|
| UiRequestWithoutPayload
|
|
65
74
|
| UiRequestDeviceAction
|
|
66
75
|
| UiRequestButton
|
|
67
|
-
|
|
|
68
|
-
| FirmwareProgress
|
|
76
|
+
| UiRequestPassphraseOnDevice
|
|
77
|
+
| FirmwareProgress
|
|
78
|
+
| UiRequestPassphrase;
|
|
69
79
|
|
|
70
80
|
export type UiEventMessage = UiEvent & { event: typeof UI_EVENT };
|
|
71
81
|
|
|
@@ -3,6 +3,7 @@ import type { MessageFactoryFn } from './utils';
|
|
|
3
3
|
|
|
4
4
|
export const UI_RESPONSE = {
|
|
5
5
|
RECEIVE_PIN: 'ui-receive_pin',
|
|
6
|
+
RECEIVE_PASSPHRASE: 'ui-receive_passphrase',
|
|
6
7
|
} as const;
|
|
7
8
|
|
|
8
9
|
export interface UiResponsePin {
|
|
@@ -10,7 +11,16 @@ export interface UiResponsePin {
|
|
|
10
11
|
payload: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export
|
|
14
|
+
export interface UiResponsePassphrase {
|
|
15
|
+
type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;
|
|
16
|
+
payload: {
|
|
17
|
+
value: string;
|
|
18
|
+
passphraseOnDevice?: boolean;
|
|
19
|
+
save?: boolean;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type UiResponseEvent = UiResponsePin | UiResponsePassphrase;
|
|
14
24
|
|
|
15
25
|
export type UiResponseMessage = UiResponseEvent & { event: typeof UI_EVENT };
|
|
16
26
|
|
package/src/types/params.ts
CHANGED
|
@@ -20,6 +20,12 @@ export interface CommonParams {
|
|
|
20
20
|
* Every init session
|
|
21
21
|
*/
|
|
22
22
|
initSession?: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* skip passhprase check
|
|
26
|
+
* !! Use with caution, there are safety risks !!
|
|
27
|
+
*/
|
|
28
|
+
skipPassphraseCheck?: boolean;
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
export type Params<T> = CommonParams & T & { bundle?: undefined };
|