@onekeyfe/hd-core 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +2 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/events/device.d.ts +8 -2
- package/dist/events/device.d.ts.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.js +8 -2
- package/package.json +4 -4
- package/src/core/index.ts +7 -2
- package/src/device/Device.ts +3 -1
- package/src/events/device.ts +11 -2
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;AAQlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAoBxD,eAAO,MAAM,OAAO,YAAmB,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAQlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAoBxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBA6KjD,CAAC;AA2JF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AA2EF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IACtC,aAAa,CAAC,OAAO,EAAE,WAAW;IA+BxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAGzB,CAAC;AAMF,eAAO,MAAM,IAAI,aAAoB,eAAe,aAAa,GAAG,8BAmBnE,CAAC"}
|
package/dist/device/Device.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Deferred } from '@onekeyfe/hd-shared';
|
|
|
5
5
|
import DeviceConnector from './DeviceConnector';
|
|
6
6
|
import { DeviceCommands } from './DeviceCommands';
|
|
7
7
|
import type { Features, Device as DeviceTyped, UnavailableCapabilities } from '../types';
|
|
8
|
-
import { DEVICE, DeviceButtonRequestPayload } from '../events';
|
|
8
|
+
import { DEVICE, DeviceButtonRequestPayload, DeviceFeaturesPayload } from '../events';
|
|
9
9
|
import { PROTO } from '../constants';
|
|
10
10
|
declare type RunOptions = {
|
|
11
11
|
keepSession?: boolean;
|
|
@@ -14,6 +14,7 @@ export interface DeviceEvents {
|
|
|
14
14
|
[DEVICE.PIN]: [Device, PROTO.PinMatrixRequestType | undefined, (err: any, pin: string) => void];
|
|
15
15
|
[DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
|
|
16
16
|
[DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
|
|
17
|
+
[DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
|
|
17
18
|
}
|
|
18
19
|
export interface Device {
|
|
19
20
|
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,EAAkB,QAAQ,EAA6B,MAAM,qBAAqB,CAAC;AAE1F,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAUlD,OAAO,KAAK,EAAE,QAAQ,EA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C,IAAI,EAAE,QAAQ;IAiB9B,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,EAAE,WAAW,UAAQ;IAiBlE,eAAe,CAAC,MAAM,EAAE,MAAM;IASxB,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU;IAYlD,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,UAAU;IA0CpE,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,aAAa,CAAC,QAAQ,EAAE,MAAM;CAM/B;AAED,eAAe,MAAM,CAAC"}
|
package/dist/events/device.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PROTO } from '../constants';
|
|
2
|
-
import type { KnownDevice as Device } from '../types/device';
|
|
2
|
+
import type { Features, KnownDevice as Device } from '../types/device';
|
|
3
3
|
import { MessageFactoryFn } from './utils';
|
|
4
4
|
export declare const DEVICE_EVENT = "DEVICE_EVENT";
|
|
5
5
|
export declare const DEVICE: {
|
|
@@ -19,6 +19,7 @@ export declare const DEVICE: {
|
|
|
19
19
|
readonly PASSPHRASE: "passphrase";
|
|
20
20
|
readonly PASSPHRASE_ON_DEVICE: "passphrase_on_device";
|
|
21
21
|
readonly WORD: "word";
|
|
22
|
+
readonly FEATURES: "features";
|
|
22
23
|
};
|
|
23
24
|
export interface DeviceButtonRequestPayload extends Omit<PROTO.ButtonRequest, 'code'> {
|
|
24
25
|
code?: PROTO.ButtonRequest['code'] | 'ButtonRequest_FirmwareUpdate';
|
|
@@ -29,7 +30,12 @@ export interface DeviceButtonRequest {
|
|
|
29
30
|
device: Device | null;
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
|
-
export declare type
|
|
33
|
+
export declare type DeviceFeaturesPayload = Features;
|
|
34
|
+
export interface DeviceSendFeatures {
|
|
35
|
+
type: typeof DEVICE.FEATURES;
|
|
36
|
+
payload: DeviceFeaturesPayload;
|
|
37
|
+
}
|
|
38
|
+
export declare type DeviceEvent = DeviceButtonRequest | DeviceSendFeatures;
|
|
33
39
|
export declare type DeviceEventMessage = DeviceEvent & {
|
|
34
40
|
event: typeof DEVICE_EVENT;
|
|
35
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/events/device.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/events/device.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;CAuBT,CAAC;AAEX,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC;IACnF,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,8BAA8B,CAAC;CACrE;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,MAAM,CAAC,MAAM,CAAC;IAC3B,OAAO,EAAE,0BAA0B,GAAG;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CACjE;AAED,oBAAY,qBAAqB,GAAG,QAAQ,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,MAAM,CAAC,QAAQ,CAAC;IAC7B,OAAO,EAAE,qBAAqB,CAAC;CAChC;AAED,oBAAY,WAAW,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAEnE,oBAAY,kBAAkB,GAAG,WAAW,GAAG;IAAE,KAAK,EAAE,OAAO,YAAY,CAAA;CAAE,CAAC;AAE9E,oBAAY,qBAAqB,GAAG,CAClC,IAAI,EAAE,OAAO,YAAY,EACzB,EAAE,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,KACpC,IAAI,CAAC;AAEV,eAAO,MAAM,mBAAmB,EAAE,gBAAgB,CAAC,OAAO,YAAY,EAAE,WAAW,CAQxE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -968,6 +968,7 @@ declare const DEVICE: {
|
|
|
968
968
|
readonly PASSPHRASE: "passphrase";
|
|
969
969
|
readonly PASSPHRASE_ON_DEVICE: "passphrase_on_device";
|
|
970
970
|
readonly WORD: "word";
|
|
971
|
+
readonly FEATURES: "features";
|
|
971
972
|
};
|
|
972
973
|
interface DeviceButtonRequestPayload extends Omit<Messages.ButtonRequest, 'code'> {
|
|
973
974
|
code?: Messages.ButtonRequest['code'] | 'ButtonRequest_FirmwareUpdate';
|
|
@@ -978,7 +979,12 @@ interface DeviceButtonRequest {
|
|
|
978
979
|
device: KnownDevice | null;
|
|
979
980
|
};
|
|
980
981
|
}
|
|
981
|
-
declare type
|
|
982
|
+
declare type DeviceFeaturesPayload = Features;
|
|
983
|
+
interface DeviceSendFeatures {
|
|
984
|
+
type: typeof DEVICE.FEATURES;
|
|
985
|
+
payload: DeviceFeaturesPayload;
|
|
986
|
+
}
|
|
987
|
+
declare type DeviceEvent = DeviceButtonRequest | DeviceSendFeatures;
|
|
982
988
|
declare type DeviceEventMessage = DeviceEvent & {
|
|
983
989
|
event: typeof DEVICE_EVENT;
|
|
984
990
|
};
|
|
@@ -1226,6 +1232,7 @@ interface DeviceEvents {
|
|
|
1226
1232
|
[DEVICE.PIN]: [Device, Messages.PinMatrixRequestType | undefined, (err: any, pin: string) => void];
|
|
1227
1233
|
[DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
|
|
1228
1234
|
[DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
|
|
1235
|
+
[DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
|
|
1229
1236
|
}
|
|
1230
1237
|
interface Device {
|
|
1231
1238
|
on<K extends keyof DeviceEvents>(type: K, listener: (...event: DeviceEvents[K]) => void): this;
|
|
@@ -1393,4 +1400,4 @@ declare class DataManager {
|
|
|
1393
1400
|
|
|
1394
1401
|
declare const HardwareSdk: ({ init, call, dispose, eventEmitter, uiResponse, cancel, }: InjectApi) => CoreApi;
|
|
1395
1402
|
|
|
1396
|
-
export { AccountAddress, AccountAddresses, AssetsMap, BTCAddress, BTCGetAddressParams, BTCGetPublicKeyParams, BTCPublicKey, BTCSignMessageParams, BTCSignTransactionParams, BTCVerifyMessageParams, BleReleaseInfoEvent, CORE_EVENT, CallMethod, CallMethodAnyResponse, CallMethodKeys, CallMethodPayload, CallMethodResponse, CallMethodUnion, CipheredKeyValue, CipheredKeyValueParams, CommonParams, ConnectSettings, Core, CoreApi, CoreMessage, DEFAULT_PRIORITY, DEVICE, DEVICE_EVENT, DataManager, Device$1 as Device, DeviceButtonRequest, DeviceButtonRequestPayload, DeviceChangePinParams, DeviceEvent, DeviceEventListenerFn, DeviceEventMessage, DeviceFirmwareRange, DeviceFlagsParams, DeviceMode, DeviceRecoveryParams, DeviceResetParams, DeviceSettingsParams, DeviceStatus, 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, 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, Params, PostMessageEvent, RESPONSE_EVENT, RefTransaction, ReleaseInfo, ReleaseInfoEvent, RemoteConfigResponse, Response, SearchDevice, SignedTransaction, SolanaAddress, SolanaGetAddressParams, SolanaSignTransactionParams, SolanaSignedTx, StarcoinAddress, StarcoinGetAddressParams, StarcoinGetPublicKeyParams, StarcoinPublicKey, StarcoinSignMessageParams, StarcoinSignTransactionParams, StarcoinVerifyMessageParams, StellarAddress, StellarAsset, StellarGetAddressParams, StellarOperation, StellarSignTransactionParams, StellarTransaction, StrictFeatures, Success, TransactionOptions, TransportReleaseStatus, UI_EVENT, UI_REQUEST, UI_RESPONSE, UiEvent, UiEventMessage, UiPromise, UiPromiseResponse, UiRequestButton, UiRequestDeviceAction, 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, getScriptType, getTimeStamp, httpRequest, init as initCore, isValidVersionArray, isValidVersionString, normalizeVersionArray, parseConnectSettings, parseMessage, patchFeatures, safeThrowError, setLoggerPostMessage, versionCompare, versionSplit };
|
|
1403
|
+
export { AccountAddress, AccountAddresses, AssetsMap, BTCAddress, BTCGetAddressParams, BTCGetPublicKeyParams, BTCPublicKey, BTCSignMessageParams, BTCSignTransactionParams, BTCVerifyMessageParams, BleReleaseInfoEvent, CORE_EVENT, CallMethod, CallMethodAnyResponse, CallMethodKeys, CallMethodPayload, CallMethodResponse, CallMethodUnion, CipheredKeyValue, CipheredKeyValueParams, CommonParams, ConnectSettings, Core, CoreApi, CoreMessage, DEFAULT_PRIORITY, DEVICE, DEVICE_EVENT, DataManager, Device$1 as Device, DeviceButtonRequest, DeviceButtonRequestPayload, DeviceChangePinParams, DeviceEvent, DeviceEventListenerFn, DeviceEventMessage, DeviceFeaturesPayload, DeviceFirmwareRange, DeviceFlagsParams, DeviceMode, DeviceRecoveryParams, DeviceResetParams, DeviceSendFeatures, DeviceSettingsParams, DeviceStatus, 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, 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, Params, PostMessageEvent, RESPONSE_EVENT, RefTransaction, ReleaseInfo, ReleaseInfoEvent, RemoteConfigResponse, Response, SearchDevice, SignedTransaction, SolanaAddress, SolanaGetAddressParams, SolanaSignTransactionParams, SolanaSignedTx, StarcoinAddress, StarcoinGetAddressParams, StarcoinGetPublicKeyParams, StarcoinPublicKey, StarcoinSignMessageParams, StarcoinSignTransactionParams, StarcoinVerifyMessageParams, StellarAddress, StellarAsset, StellarGetAddressParams, StellarOperation, StellarSignTransactionParams, StellarTransaction, StrictFeatures, Success, TransactionOptions, TransportReleaseStatus, UI_EVENT, UI_REQUEST, UI_RESPONSE, UiEvent, UiEventMessage, UiPromise, UiPromiseResponse, UiRequestButton, UiRequestDeviceAction, 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, getScriptType, getTimeStamp, httpRequest, init as initCore, isValidVersionArray, isValidVersionString, normalizeVersionArray, parseConnectSettings, parseMessage, patchFeatures, safeThrowError, setLoggerPostMessage, versionCompare, versionSplit };
|
package/dist/index.js
CHANGED
|
@@ -10090,6 +10090,7 @@ const DEVICE = {
|
|
|
10090
10090
|
PASSPHRASE: 'passphrase',
|
|
10091
10091
|
PASSPHRASE_ON_DEVICE: 'passphrase_on_device',
|
|
10092
10092
|
WORD: 'word',
|
|
10093
|
+
FEATURES: 'features',
|
|
10093
10094
|
};
|
|
10094
10095
|
const createDeviceMessage = (type, payload) => ({
|
|
10095
10096
|
event: DEVICE_EVENT,
|
|
@@ -10528,6 +10529,7 @@ class Device extends events.exports {
|
|
|
10528
10529
|
feat.unlocked = feat.unlocked || true;
|
|
10529
10530
|
this.features = feat;
|
|
10530
10531
|
this.featuresNeedsReload = false;
|
|
10532
|
+
this.emit(DEVICE.FEATURES, this, feat);
|
|
10531
10533
|
}
|
|
10532
10534
|
updateDescriptor(descriptor, forceUpdate = false) {
|
|
10533
10535
|
const env = DataManager.getSettings('env');
|
|
@@ -13696,6 +13698,7 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
13696
13698
|
device.on(DEVICE.BUTTON, (d, code) => {
|
|
13697
13699
|
onDeviceButtonHandler(d, code);
|
|
13698
13700
|
});
|
|
13701
|
+
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
13699
13702
|
try {
|
|
13700
13703
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
13701
13704
|
const deviceType = getDeviceType(device.features);
|
|
@@ -13842,14 +13845,14 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
|
|
|
13842
13845
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13843
13846
|
if (!pollingState[pollingId]) {
|
|
13844
13847
|
Log.debug('EnsureConnected function stop, polling id: ', pollingId);
|
|
13845
|
-
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
13848
|
+
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.PollingStop));
|
|
13846
13849
|
return;
|
|
13847
13850
|
}
|
|
13848
13851
|
if (timer) {
|
|
13849
13852
|
clearTimeout(timer);
|
|
13850
13853
|
}
|
|
13851
13854
|
timer = setTimeout(() => {
|
|
13852
|
-
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
13855
|
+
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.PollingTimeout));
|
|
13853
13856
|
}, TIME_OUT);
|
|
13854
13857
|
tryCount += 1;
|
|
13855
13858
|
Log.debug('EnsureConnected function try count: ', tryCount, ' poll interval time: ', time);
|
|
@@ -13957,6 +13960,9 @@ const onDeviceButtonHandler = (...[device, request]) => {
|
|
|
13957
13960
|
postMessage(createUiMessage(UI_REQUEST$1.REQUEST_BUTTON, { device: device.toMessageObject() }));
|
|
13958
13961
|
}
|
|
13959
13962
|
};
|
|
13963
|
+
const onDeviceFeaturesHandler = (...[_, features]) => {
|
|
13964
|
+
postMessage(createDeviceMessage(DEVICE.FEATURES, Object.assign({}, features)));
|
|
13965
|
+
};
|
|
13960
13966
|
const postMessage = (message) => {
|
|
13961
13967
|
_core.emit(CORE_EVENT, message);
|
|
13962
13968
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "^0.1.
|
|
29
|
-
"@onekeyfe/hd-transport": "^0.1.
|
|
28
|
+
"@onekeyfe/hd-shared": "^0.1.19",
|
|
29
|
+
"@onekeyfe/hd-transport": "^0.1.19",
|
|
30
30
|
"axios": "^0.27.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"js-sha256": "^0.9.0",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"@types/parse-uri": "^1.0.0",
|
|
38
38
|
"@types/semver": "^7.3.9"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "bec3f099bb54a945e46941796e24ab7e7b739566"
|
|
41
41
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -98,6 +98,7 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
98
98
|
device.on(DEVICE.BUTTON, (d, code) => {
|
|
99
99
|
onDeviceButtonHandler(d, code);
|
|
100
100
|
});
|
|
101
|
+
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
101
102
|
|
|
102
103
|
try {
|
|
103
104
|
const inner = async (): Promise<void> => {
|
|
@@ -298,7 +299,7 @@ const ensureConnected = async (method: BaseMethod, pollingId: number) => {
|
|
|
298
299
|
new Promise(async (resolve, reject) => {
|
|
299
300
|
if (!pollingState[pollingId]) {
|
|
300
301
|
Log.debug('EnsureConnected function stop, polling id: ', pollingId);
|
|
301
|
-
reject(ERRORS.TypedError(HardwareErrorCode.
|
|
302
|
+
reject(ERRORS.TypedError(HardwareErrorCode.PollingStop));
|
|
302
303
|
return;
|
|
303
304
|
}
|
|
304
305
|
|
|
@@ -307,7 +308,7 @@ const ensureConnected = async (method: BaseMethod, pollingId: number) => {
|
|
|
307
308
|
clearTimeout(timer);
|
|
308
309
|
}
|
|
309
310
|
timer = setTimeout(() => {
|
|
310
|
-
reject(ERRORS.TypedError(HardwareErrorCode.
|
|
311
|
+
reject(ERRORS.TypedError(HardwareErrorCode.PollingTimeout));
|
|
311
312
|
}, TIME_OUT);
|
|
312
313
|
|
|
313
314
|
tryCount += 1;
|
|
@@ -435,6 +436,10 @@ const onDeviceButtonHandler = (...[device, request]: [...DeviceEvents['button']]
|
|
|
435
436
|
}
|
|
436
437
|
};
|
|
437
438
|
|
|
439
|
+
const onDeviceFeaturesHandler = (...[_, features]: [...DeviceEvents['features']]) => {
|
|
440
|
+
postMessage(createDeviceMessage(DEVICE.FEATURES, { ...features }));
|
|
441
|
+
};
|
|
442
|
+
|
|
438
443
|
/**
|
|
439
444
|
* Emit message to listener (parent).
|
|
440
445
|
* Clear method reference from _callMethods
|
package/src/device/Device.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
getDeviceTypeOnBootloader,
|
|
15
15
|
} from '../utils/deviceFeaturesUtils';
|
|
16
16
|
import type { Features, Device as DeviceTyped, UnavailableCapabilities } from '../types';
|
|
17
|
-
import { DEVICE, DeviceButtonRequestPayload } from '../events';
|
|
17
|
+
import { DEVICE, DeviceButtonRequestPayload, DeviceFeaturesPayload } from '../events';
|
|
18
18
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
19
19
|
import { PROTO } from '../constants';
|
|
20
20
|
import { getLogger, LoggerNames } from '../utils';
|
|
@@ -35,6 +35,7 @@ export interface DeviceEvents {
|
|
|
35
35
|
[DEVICE.PIN]: [Device, PROTO.PinMatrixRequestType | undefined, (err: any, pin: string) => void];
|
|
36
36
|
[DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
|
|
37
37
|
[DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
|
|
38
|
+
[DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
export interface Device {
|
|
@@ -263,6 +264,7 @@ export class Device extends EventEmitter {
|
|
|
263
264
|
|
|
264
265
|
this.features = feat;
|
|
265
266
|
this.featuresNeedsReload = false;
|
|
267
|
+
this.emit(DEVICE.FEATURES, this, feat);
|
|
266
268
|
}
|
|
267
269
|
|
|
268
270
|
/**
|
package/src/events/device.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PROTO } from '../constants';
|
|
2
|
-
import type { KnownDevice as Device } from '../types/device';
|
|
2
|
+
import type { Features, KnownDevice as Device } from '../types/device';
|
|
3
3
|
import { MessageFactoryFn } from './utils';
|
|
4
4
|
|
|
5
5
|
export const DEVICE_EVENT = 'DEVICE_EVENT';
|
|
@@ -24,6 +24,8 @@ export const DEVICE = {
|
|
|
24
24
|
PASSPHRASE: 'passphrase',
|
|
25
25
|
PASSPHRASE_ON_DEVICE: 'passphrase_on_device',
|
|
26
26
|
WORD: 'word',
|
|
27
|
+
|
|
28
|
+
FEATURES: 'features',
|
|
27
29
|
} as const;
|
|
28
30
|
|
|
29
31
|
export interface DeviceButtonRequestPayload extends Omit<PROTO.ButtonRequest, 'code'> {
|
|
@@ -35,7 +37,14 @@ export interface DeviceButtonRequest {
|
|
|
35
37
|
payload: DeviceButtonRequestPayload & { device: Device | null };
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
export type
|
|
40
|
+
export type DeviceFeaturesPayload = Features;
|
|
41
|
+
|
|
42
|
+
export interface DeviceSendFeatures {
|
|
43
|
+
type: typeof DEVICE.FEATURES;
|
|
44
|
+
payload: DeviceFeaturesPayload;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type DeviceEvent = DeviceButtonRequest | DeviceSendFeatures;
|
|
39
48
|
|
|
40
49
|
export type DeviceEventMessage = DeviceEvent & { event: typeof DEVICE_EVENT };
|
|
41
50
|
|