@onekeyfe/hd-core 0.1.48 → 0.1.50

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.
@@ -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;AA2BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBAyPjD,CAAC;AA2KF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AAuHF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IACtC,aAAa,CAAC,OAAO,EAAE,WAAW;IA6CxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aAAoB,eAAe,aAAa,GAAG,8BAmBnE,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;AA2BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBA0PjD,CAAC;AA2KF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AA6IF,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"}
@@ -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';
@@ -20,6 +20,7 @@ export interface DeviceEvents {
20
20
  [DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
21
21
  [DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
22
22
  [DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
23
+ [DEVICE.PASSPHRASE]: [Device, (response: PassphrasePromptResponse, error?: Error) => void];
23
24
  }
24
25
  export interface Device {
25
26
  on<K extends keyof DeviceEvents>(type: K, listener: (...event: DeviceEvents[K]) => void): this;
@@ -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;AAElD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,WAAW,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,0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AAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,UAAU;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"}
@@ -30,6 +30,7 @@ export declare class DeviceCommands {
30
30
  _commonCall(type: MessageKey, msg?: DefaultMessageResponse['message']): Promise<DefaultMessageResponse>;
31
31
  _filterCommonTypes(res: DefaultMessageResponse): 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,QAAQ,CAAC,WAAW,CAAC;AACxC,aAAK,UAAU,GAAG,MAAM,WAAW,CAAC;AACpC,oBAAY,oBAAoB,CAAC,CAAC,SAAS,UAAU,IAAI;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;CACzB,CAAC;AACF,aAAK,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AAE,CAAM;IAEzC,MAAM,CAAC,aAAa,EAAE,gBAAgB,EAAE,CAAM;IAE9C,MAAM,CAAC,cAAc,EAAE,gBAAgB,EAAE,CAAM;IAE/C,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAEjD,MAAM,CAAC,OAAO,eAAsB;IAEpC,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC;IAElC,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,eAAe;WAIjC,UAAU,CACrB,cAAc,EAAE,gBAAgB,EAAE,EAClC,SAAS,CAAC,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,WAAW;;;;IA+C3B,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM;WAQ7B,aAAa,CAAC,UAAU,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,WAAW;WAYrE,gBAAgB,CAAC,WAAW,CAAC,EAAE,WAAW;WAK1C,mBAAmB,CAAC,WAAW,CAAC,EAAE,WAAW;IAU1D,MAAM,CAAC,sBAAsB;IAW7B,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB,EAAE;IAqCtD,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM;IAInC,MAAM,CAAC,yBAAyB,CAAC,UAAU,EAAE,gBAAgB;IAU7D,MAAM,CAAC,8BAA8B,CAAC,IAAI,EAAE,MAAM;IAOlD,MAAM,CAAC,4BAA4B,CAAC,UAAU,EAAE,gBAAgB;CASjE"}
@@ -7,6 +7,7 @@ export declare const UI_REQUEST: {
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,12 @@ 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
+ };
39
+ }
40
+ export interface UiRequestPassphraseOnDevice {
34
41
  type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
35
42
  payload: {
36
43
  device: Device;
@@ -44,7 +51,7 @@ export interface FirmwareProgress {
44
51
  progress: number;
45
52
  };
46
53
  }
47
- export declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPassphrase | FirmwareProgress;
54
+ export declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPassphraseOnDevice | FirmwareProgress | UiRequestPassphrase;
48
55
  export declare type UiEventMessage = UiEvent & {
49
56
  event: typeof UI_EVENT;
50
57
  };
@@ -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,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,QAAQ,aAAa,CAAC;AAEnC,eAAO,MAAM,UAAU;;;;;;;;;;;CAeb,CAAC;AAEX,MAAM,WAAW,uBAAuB;IACtC,IAAI,EACA,OAAO,UAAU,CAAC,eAAe,GACjC,OAAO,UAAU,CAAC,oBAAoB,GACtC,OAAO,UAAU,CAAC,mBAAmB,GACrC,OAAO,UAAU,CAAC,2BAA2B,CAAC;IAClD,OAAO,CAAC,EAAE,OAAO,SAAS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,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 declare type UiResponseEvent = UiResponsePin;
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;;CAEd,CAAC;AAEX,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,WAAW,CAAC,WAAW,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,oBAAY,eAAe,GAAG,aAAa,CAAC;AAE5C,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"}
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
@@ -1187,6 +1187,7 @@ declare const UI_REQUEST: {
1187
1187
  readonly REQUEST_PIN: "ui-request_pin";
1188
1188
  readonly INVALID_PIN: "ui-invalid_pin";
1189
1189
  readonly REQUEST_BUTTON: "ui-button";
1190
+ readonly REQUEST_PASSPHRASE: "ui-request_passphrase";
1190
1191
  readonly REQUEST_PASSPHRASE_ON_DEVICE: "ui-request_passphrase_on_device";
1191
1192
  readonly CLOSE_UI_WINDOW: "ui-close_window";
1192
1193
  readonly BLUETOOTH_PERMISSION: "ui-bluetooth_permission";
@@ -1211,6 +1212,12 @@ interface UiRequestButton {
1211
1212
  payload: DeviceButtonRequest['payload'];
1212
1213
  }
1213
1214
  interface UiRequestPassphrase {
1215
+ type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
1216
+ payload: {
1217
+ device: Device$1;
1218
+ };
1219
+ }
1220
+ interface UiRequestPassphraseOnDevice {
1214
1221
  type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
1215
1222
  payload: {
1216
1223
  device: Device$1;
@@ -1224,7 +1231,7 @@ interface FirmwareProgress {
1224
1231
  progress: number;
1225
1232
  };
1226
1233
  }
1227
- declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPassphrase | FirmwareProgress;
1234
+ declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPassphraseOnDevice | FirmwareProgress | UiRequestPassphrase;
1228
1235
  declare type UiEventMessage = UiEvent & {
1229
1236
  event: typeof UI_EVENT;
1230
1237
  };
@@ -1299,12 +1306,21 @@ declare type CallMethodKeys = keyof CoreApi;
1299
1306
 
1300
1307
  declare const UI_RESPONSE: {
1301
1308
  readonly RECEIVE_PIN: "ui-receive_pin";
1309
+ readonly RECEIVE_PASSPHRASE: "ui-receive_passphrase";
1302
1310
  };
1303
1311
  interface UiResponsePin {
1304
1312
  type: typeof UI_RESPONSE.RECEIVE_PIN;
1305
1313
  payload: string;
1306
1314
  }
1307
- declare type UiResponseEvent = UiResponsePin;
1315
+ interface UiResponsePassphrase {
1316
+ type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;
1317
+ payload: {
1318
+ value: string;
1319
+ passphraseOnDevice?: boolean;
1320
+ save?: boolean;
1321
+ };
1322
+ }
1323
+ declare type UiResponseEvent = UiResponsePin | UiResponsePassphrase;
1308
1324
  declare type UiResponseMessage = UiResponseEvent & {
1309
1325
  event: typeof UI_EVENT;
1310
1326
  };
@@ -1415,6 +1431,11 @@ declare type TypedCallResponseMap = {
1415
1431
  [K in keyof MessageType]: TypedResponseMessage<K>;
1416
1432
  };
1417
1433
  declare type DefaultMessageResponse = TypedCallResponseMap[keyof MessageType];
1434
+ declare type PassphrasePromptResponse = {
1435
+ passphrase?: string;
1436
+ passphraseOnDevice?: boolean;
1437
+ cache?: boolean;
1438
+ };
1418
1439
  declare class DeviceCommands {
1419
1440
  device: Device;
1420
1441
  transport: Transport;
@@ -1430,6 +1451,7 @@ declare class DeviceCommands {
1430
1451
  _commonCall(type: MessageKey, msg?: DefaultMessageResponse['message']): Promise<DefaultMessageResponse>;
1431
1452
  _filterCommonTypes(res: DefaultMessageResponse): Promise<DefaultMessageResponse>;
1432
1453
  _promptPin(type?: Messages.PinMatrixRequestType): Promise<string>;
1454
+ _promptPassphrase(): Promise<PassphrasePromptResponse>;
1433
1455
  }
1434
1456
 
1435
1457
  declare type InitOptions = {
@@ -1445,6 +1467,7 @@ interface DeviceEvents {
1445
1467
  [DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
1446
1468
  [DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
1447
1469
  [DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
1470
+ [DEVICE.PASSPHRASE]: [Device, (response: PassphrasePromptResponse, error?: Error) => void];
1448
1471
  }
1449
1472
  interface Device {
1450
1473
  on<K extends keyof DeviceEvents>(type: K, listener: (...event: DeviceEvents[K]) => void): this;
@@ -1621,4 +1644,4 @@ declare class DataManager {
1621
1644
 
1622
1645
  declare const HardwareSdk: ({ init, call, dispose, eventEmitter, uiResponse, cancel, }: InjectApi) => CoreApi;
1623
1646
 
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 };
1647
+ 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);
@@ -10949,9 +10950,12 @@ class DeviceCommands {
10949
10950
  }, () => this._commonCall('Cancel', {}));
10950
10951
  }
10951
10952
  if (res.type === 'PassphraseRequest') {
10952
- return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportPassphrase, 'Device not support passphrase', {
10953
- require: '2.4.0',
10954
- }));
10953
+ return this._promptPassphrase().then(response => {
10954
+ const { passphrase, passphraseOnDevice } = response;
10955
+ return !passphraseOnDevice
10956
+ ? this._commonCall('PassphraseAck', { passphrase })
10957
+ : this._commonCall('PassphraseAck', { on_device: true });
10958
+ });
10955
10959
  }
10956
10960
  if (res.type === 'Deprecated_PassphraseStateRequest') ;
10957
10961
  if (res.type === 'WordRequest') ;
@@ -10977,6 +10981,26 @@ class DeviceCommands {
10977
10981
  }
10978
10982
  });
10979
10983
  }
10984
+ _promptPassphrase() {
10985
+ return new Promise((resolve, reject) => {
10986
+ if (this.device.listenerCount(DEVICE.PASSPHRASE) > 0) {
10987
+ this._cancelableRequest = reject;
10988
+ this.device.emit(DEVICE.PASSPHRASE, this.device, (response, error) => {
10989
+ this._cancelableRequest = undefined;
10990
+ if (error) {
10991
+ reject(error);
10992
+ }
10993
+ else {
10994
+ resolve(response);
10995
+ }
10996
+ });
10997
+ }
10998
+ else {
10999
+ Log$5.error('[DeviceCommands] [call] Passphrase callback not configured, cancelling request');
11000
+ reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, '_promptPassphrase: Passphrase callback not configured'));
11001
+ }
11002
+ });
11003
+ }
10980
11004
  }
10981
11005
 
10982
11006
  const UI_REQUEST = {
@@ -15092,7 +15116,8 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
15092
15116
  (_a = method.setDevice) === null || _a === void 0 ? void 0 : _a.call(method, device);
15093
15117
  device.on(DEVICE.PIN, onDevicePinHandler);
15094
15118
  device.on(DEVICE.BUTTON, onDeviceButtonHandler);
15095
- device.on(DEVICE.PASSPHRASE_ON_DEVICE, onDevicePassphraseHandler);
15119
+ device.on(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
15120
+ device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
15096
15121
  device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
15097
15122
  try {
15098
15123
  const inner = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -15383,7 +15408,8 @@ const cleanup = () => {
15383
15408
  const removeDeviceListener = (device) => {
15384
15409
  device.removeListener(DEVICE.PIN, onDevicePinHandler);
15385
15410
  device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
15386
- device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onDevicePassphraseHandler);
15411
+ device.removeListener(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
15412
+ device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
15387
15413
  device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
15388
15414
  DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
15389
15415
  };
@@ -15425,7 +15451,21 @@ const onDeviceButtonHandler = (...[device, request]) => {
15425
15451
  const onDeviceFeaturesHandler = (...[_, features]) => {
15426
15452
  postMessage(createDeviceMessage(DEVICE.FEATURES, Object.assign({}, features)));
15427
15453
  };
15428
- const onDevicePassphraseHandler = (...[device]) => {
15454
+ const onDevicePassphraseHandler = (...[device, callback]) => __awaiter(void 0, void 0, void 0, function* () {
15455
+ Log.debug('onDevicePassphraseHandler');
15456
+ const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PASSPHRASE, device);
15457
+ postMessage(createUiMessage(UI_REQUEST$1.REQUEST_PASSPHRASE, {
15458
+ device: device.toMessageObject(),
15459
+ }));
15460
+ const uiResp = yield uiPromise.promise;
15461
+ const { value, passphraseOnDevice, save } = uiResp.payload;
15462
+ callback({
15463
+ passphrase: value.normalize('NFKD'),
15464
+ passphraseOnDevice,
15465
+ cache: save,
15466
+ });
15467
+ });
15468
+ const onEnterPassphraseOnDeviceHandler = (...[device]) => {
15429
15469
  postMessage(createUiMessage(UI_REQUEST$1.REQUEST_PASSPHRASE_ON_DEVICE, {
15430
15470
  device: device.toMessageObject(),
15431
15471
  passphraseState: device.passphraseState,
@@ -15448,7 +15488,8 @@ class Core extends events.exports {
15448
15488
  var _a, _b, _c, _d;
15449
15489
  return __awaiter(this, void 0, void 0, function* () {
15450
15490
  switch (message.type) {
15451
- case UI_RESPONSE.RECEIVE_PIN: {
15491
+ case UI_RESPONSE.RECEIVE_PIN:
15492
+ case UI_RESPONSE.RECEIVE_PASSPHRASE: {
15452
15493
  const uiPromise = findUiPromise(message.type);
15453
15494
  if (uiPromise) {
15454
15495
  uiPromise.resolve(message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "0.1.48",
3
+ "version": "0.1.50",
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.48",
28
- "@onekeyfe/hd-transport": "^0.1.48",
27
+ "@onekeyfe/hd-shared": "^0.1.50",
28
+ "@onekeyfe/hd-transport": "^0.1.50",
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": "591633098720e2845ecfbe95460b5f7bc2d15e5b"
39
+ "gitHead": "e3e2a8aa77a1bf72d1b26dc9841463a660a2f902"
40
40
  }
package/src/core/index.ts CHANGED
@@ -132,7 +132,8 @@ export const callAPI = async (message: CoreMessage) => {
132
132
 
133
133
  device.on(DEVICE.PIN, onDevicePinHandler);
134
134
  device.on(DEVICE.BUTTON, onDeviceButtonHandler);
135
- device.on(DEVICE.PASSPHRASE_ON_DEVICE, onDevicePassphraseHandler);
135
+ device.on(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
136
+ device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
136
137
  device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
137
138
 
138
139
  try {
@@ -526,7 +527,8 @@ const cleanup = () => {
526
527
  const removeDeviceListener = (device: Device) => {
527
528
  device.removeListener(DEVICE.PIN, onDevicePinHandler);
528
529
  device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
529
- device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onDevicePassphraseHandler);
530
+ device.removeListener(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
531
+ device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
530
532
  device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
531
533
  DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
532
534
  // DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
@@ -587,7 +589,28 @@ const onDeviceFeaturesHandler = (...[_, features]: [...DeviceEvents['features']]
587
589
  postMessage(createDeviceMessage(DEVICE.FEATURES, { ...features }));
588
590
  };
589
591
 
590
- const onDevicePassphraseHandler = (...[device]: [...DeviceEvents['passphrase_on_device']]) => {
592
+ const onDevicePassphraseHandler = async (...[device, callback]: DeviceEvents['passphrase']) => {
593
+ Log.debug('onDevicePassphraseHandler');
594
+ const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PASSPHRASE, device);
595
+ postMessage(
596
+ createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE, {
597
+ device: device.toMessageObject() as KnownDevice,
598
+ })
599
+ );
600
+ // wait for passphrase
601
+ const uiResp = await uiPromise.promise;
602
+ const { value, passphraseOnDevice, save } = uiResp.payload;
603
+ // send as PassphrasePromptResponse
604
+ callback({
605
+ passphrase: value.normalize('NFKD'),
606
+ passphraseOnDevice,
607
+ cache: save,
608
+ });
609
+ };
610
+
611
+ const onEnterPassphraseOnDeviceHandler = (
612
+ ...[device]: [...DeviceEvents['passphrase_on_device']]
613
+ ) => {
591
614
  postMessage(
592
615
  createUiMessage(UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE, {
593
616
  device: device.toMessageObject() as KnownDevice,
@@ -624,7 +647,8 @@ const removeUiPromise = (promise: Deferred<any>) => {
624
647
  export default class Core extends EventEmitter {
625
648
  async handleMessage(message: CoreMessage) {
626
649
  switch (message.type) {
627
- case UI_RESPONSE.RECEIVE_PIN: {
650
+ case UI_RESPONSE.RECEIVE_PIN:
651
+ case UI_RESPONSE.RECEIVE_PASSPHRASE: {
628
652
  const uiPromise = findUiPromise(message.type);
629
653
  if (uiPromise) {
630
654
  uiPromise.resolve(message);
@@ -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';
@@ -50,6 +50,7 @@ export interface DeviceEvents {
50
50
  [DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
51
51
  [DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
52
52
  [DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
53
+ [DEVICE.PASSPHRASE]: [Device, (response: PassphrasePromptResponse, error?: Error) => void];
53
54
  }
54
55
 
55
56
  export interface Device {
@@ -216,19 +216,12 @@ export class DeviceCommands {
216
216
  }
217
217
 
218
218
  if (res.type === 'PassphraseRequest') {
219
- /**
220
- * Temporary, do not support passphrase
221
- */
222
- // return this._commonCall('PassphraseAck', { passphrase: '' });
223
- return Promise.reject(
224
- ERRORS.TypedError(
225
- HardwareErrorCode.DeviceNotSupportPassphrase,
226
- 'Device not support passphrase',
227
- {
228
- require: '2.4.0',
229
- }
230
- )
231
- );
219
+ return this._promptPassphrase().then(response => {
220
+ const { passphrase, passphraseOnDevice } = response;
221
+ return !passphraseOnDevice
222
+ ? this._commonCall('PassphraseAck', { passphrase })
223
+ : this._commonCall('PassphraseAck', { on_device: true });
224
+ });
232
225
  }
233
226
 
234
227
  // TT fw lower than 2.3.0, device send his current state
@@ -266,6 +259,34 @@ export class DeviceCommands {
266
259
  }
267
260
  });
268
261
  }
262
+
263
+ _promptPassphrase() {
264
+ return new Promise<PassphrasePromptResponse>((resolve, reject) => {
265
+ if (this.device.listenerCount(DEVICE.PASSPHRASE) > 0) {
266
+ this._cancelableRequest = reject;
267
+ this.device.emit(
268
+ DEVICE.PASSPHRASE,
269
+ this.device,
270
+ (response: PassphrasePromptResponse, error?: Error) => {
271
+ this._cancelableRequest = undefined;
272
+ if (error) {
273
+ reject(error);
274
+ } else {
275
+ resolve(response);
276
+ }
277
+ }
278
+ );
279
+ } else {
280
+ Log.error('[DeviceCommands] [call] Passphrase callback not configured, cancelling request');
281
+ reject(
282
+ ERRORS.TypedError(
283
+ HardwareErrorCode.RuntimeError,
284
+ '_promptPassphrase: Passphrase callback not configured'
285
+ )
286
+ );
287
+ }
288
+ });
289
+ }
269
290
  }
270
291
 
271
292
  export type TypedCall = DeviceCommands['typedCall'];
@@ -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);
@@ -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,13 @@ 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
+ };
53
+ }
54
+
55
+ export interface UiRequestPassphraseOnDevice {
48
56
  type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
49
57
  payload: {
50
58
  device: Device;
@@ -64,8 +72,9 @@ export type UiEvent =
64
72
  | UiRequestWithoutPayload
65
73
  | UiRequestDeviceAction
66
74
  | UiRequestButton
67
- | UiRequestPassphrase
68
- | FirmwareProgress;
75
+ | UiRequestPassphraseOnDevice
76
+ | FirmwareProgress
77
+ | UiRequestPassphrase;
69
78
 
70
79
  export type UiEventMessage = UiEvent & { event: typeof UI_EVENT };
71
80
 
@@ -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 type UiResponseEvent = UiResponsePin;
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