@onekeyfe/hd-core 1.1.22-alpha.1 → 1.1.22-alpha.2
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 +8 -6
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +3 -2
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/index.d.ts +31 -30
- package/dist/index.js +21 -8
- package/package.json +4 -4
- package/src/core/index.ts +9 -0
- package/src/device/Device.ts +24 -24
- package/src/device/DeviceConnector.ts +15 -3
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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAwClC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAiB1C,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAIxD,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAmD,MAAM,WAAW,CAAC;AAI9F,OAAO,KAAK,EAEV,6BAA6B,EAE9B,MAAM,wBAAwB,CAAC;AAKhC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AA8D7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBAuEvE,CAAC;AAoqBF,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,SAkF9D,CAAC;AAsEF,eAAO,MAAM,qBAAqB,gFAejC,CAAC;AA0GF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IAC5C,OAAO,CAAC,cAAc,CAAoB;IAE1C,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,OAAO,CAAC,YAAY,CAAsB;IAG1C,OAAO,CAAC,qBAAqB,CAA4B;IAEzD,OAAO,CAAC,iBAAiB,CAAoB;;IAS7C,OAAO,CAAC,cAAc;IAoBhB,aAAa,CAAC,OAAO,EAAE,WAAW;IA2DxC,OAAO;CAMR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aACL,eAAe,aACd,GAAG,WACL,6BAA6B,8BAoBvC,CAAC;AAEF,eAAO,MAAM,eAAe;SAKrB,eAAe,CAAC,KAAK,CAAC;eAChB,GAAG;;UASf,CAAC"}
|
package/dist/device/Device.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { DeviceCommands } from './DeviceCommands';
|
|
4
|
+
import { type DeviceFirmwareRange, type Device as DeviceTyped, EOneKeyDeviceMode, type Features, type UnavailableCapabilities } from '../types';
|
|
5
|
+
import { DEVICE } from '../events';
|
|
6
|
+
import type { PROTO } from '../constants';
|
|
7
|
+
import type { DeviceButtonRequestPayload, DeviceFeaturesPayload, PassphraseRequestPayload } from '../events';
|
|
8
|
+
import type { PassphrasePromptResponse } from './DeviceCommands';
|
|
9
|
+
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
10
|
+
import type { OneKeyDeviceInfo as DeviceDescriptor } from '@onekeyfe/hd-transport';
|
|
5
11
|
import type DeviceConnector from './DeviceConnector';
|
|
6
|
-
import { DeviceCommands, PassphrasePromptResponse } from './DeviceCommands';
|
|
7
|
-
import { type DeviceFirmwareRange, EOneKeyDeviceMode, type Device as DeviceTyped, type Features, type UnavailableCapabilities } from '../types';
|
|
8
|
-
import { DEVICE, DeviceButtonRequestPayload, DeviceFeaturesPayload, PassphraseRequestPayload } from '../events';
|
|
9
|
-
import { PROTO } from '../constants';
|
|
10
12
|
export type InitOptions = {
|
|
11
13
|
initSession?: boolean;
|
|
12
14
|
deviceId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../src/device/Device.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../src/device/Device.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AA+BlC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,MAAM,IAAI,WAAW,EAC1B,iBAAiB,EACjB,KAAK,QAAQ,EACb,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,MAAM,EAAc,MAAM,WAAW,CAAC;AAM/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EACV,0BAA0B,EAC1B,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM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,EAAE,MAAM;IAOxB,UAAU;IAKhB,yBAAyB,IAAI,mBAAmB;IAQ1C,YAAY;IAgDZ,0BAA0B,CAC9B,eAAe,CAAC,EAAE,MAAM,EACxB,kBAAkB,CAAC,EAAE,OAAO,EAC5B,mBAAmB,CAAC,EAAE,OAAO;CA2ChC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="w3c-web-usb" />
|
|
2
2
|
/// <reference types="web-bluetooth" />
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import type { DeviceDescriptorDiff } from './DevicePool';
|
|
4
|
+
import type { OneKeyDeviceInfo as DeviceDescriptor, Transport } from '@onekeyfe/hd-transport';
|
|
5
5
|
export default class DeviceConnector {
|
|
6
6
|
transport: Transport;
|
|
7
7
|
listenTimestamp: number;
|
|
@@ -14,6 +14,7 @@ export default class DeviceConnector {
|
|
|
14
14
|
stop(): void;
|
|
15
15
|
acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean): Promise<string | undefined>;
|
|
16
16
|
release(session: string, onclose: boolean): Promise<void>;
|
|
17
|
+
disconnect(session: string | undefined | null): Promise<void>;
|
|
17
18
|
promptDeviceAccess(): Promise<USBDevice | BluetoothDevice | null>;
|
|
18
19
|
_reportDevicesChange(): void;
|
|
19
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceConnector.d.ts","sourceRoot":"","sources":["../../src/device/DeviceConnector.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"DeviceConnector.d.ts","sourceRoot":"","sources":["../../src/device/DeviceConnector.ts"],"names":[],"mappings":";;AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAI9F,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAS,EAAE,SAAS,CAAC;IAErB,eAAe,SAAK;IAEpB,OAAO,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAQ;IAE1C,QAAQ,EAAE,gBAAgB,EAAE,CAAM;IAElC,SAAS,UAAS;;IAQZ,SAAS;IAWT,MAAM;IAiCZ,IAAI;IAIE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,oBAAoB,CAAC,EAAE,OAAO;IAiB7E,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IASzC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAUnD,kBAAkB,IAAI,OAAO,CAAC,SAAS,GAAG,eAAe,GAAG,IAAI,CAAC;IAOjE,oBAAoB;CAGrB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter$1, { EventEmitter } from 'events';
|
|
2
2
|
import * as _onekeyfe_hd_transport from '@onekeyfe/hd-transport';
|
|
3
|
-
import { OneKeyDeviceCommType, Messages, LowlevelTransportSharedPlugin, Features as Features$1, Success as Success$1, RecoveryDeviceType, SafetyCheckLevel, ResourceType, NextU2FCounter, SetU2FCounter, CipheredKeyValue as CipheredKeyValue$1, UintType, EthereumPublicKey, EthereumMessageSignature, Address, MultisigRedeemScriptType, InputScriptType, PublicKey, MessageSignature, SignedPsbt, PrevInput, TxOutputBinType, TxInput, TxOutputType, TxInputType, StarcoinAddress as StarcoinAddress$1, StarcoinPublicKey as StarcoinPublicKey$1, StarcoinMessageSignature, StarcoinSignedTx, NEMAddress as NEMAddress$1, NEMSignedTx, SolanaAddress as SolanaAddress$1, SolanaSignedTx as SolanaSignedTx$1, SolanaOffChainMessageVersion, SolanaOffChainMessageFormat, StellarAddress as StellarAddress$1, StellarSignedTx, TronAddress as TronAddress$1, TronResourceCode, TronSignedTx, TronMessageSignature, ConfluxAddress as ConfluxAddress$1, ConfluxMessageSignature, NearAddress as NearAddress$1, NearSignedTx, AptosAddress as AptosAddress$1, AptosMessageSignature as AptosMessageSignature$1, AptosSignedTx as AptosSignedTx$1, AlgorandAddress, AlgorandSignedTx, CosmosAddress as CosmosAddress$1, CosmosSignedTx as CosmosSignedTx$1, SuiAddress as SuiAddress$1, SuiMessageSignature, CardanoAddressParametersType, CardanoMessageSignature, FilecoinAddress as FilecoinAddress$1, FilecoinSignedTx as FilecoinSignedTx$1, PolkadotAddress as PolkadotAddress$1, PolkadotSignedTx as PolkadotSignedTx$1, KaspaAddress as KaspaAddress$1, NervosAddress as NervosAddress$1, NervosSignedTx as NervosSignedTx$1, DnxAddress as DnxAddress$1, TonWalletVersion, TonWorkChain, TonSignedMessage, TonSignedProof, ScdoAddress as ScdoAddress$1, ScdoSignedMessage, ScdoSignedTx as ScdoSignedTx$1, AlephiumMessageSignature, AlephiumSignedTx as AlephiumSignedTx$1, BenfenAddress as BenfenAddress$1, BenfenMessageSignature,
|
|
3
|
+
import { OneKeyDeviceCommType, Messages, LowlevelTransportSharedPlugin, Features as Features$1, Success as Success$1, RecoveryDeviceType, SafetyCheckLevel, ResourceType, NextU2FCounter, SetU2FCounter, CipheredKeyValue as CipheredKeyValue$1, UintType, EthereumPublicKey, EthereumMessageSignature, Address, MultisigRedeemScriptType, InputScriptType, PublicKey, MessageSignature, SignedPsbt, PrevInput, TxOutputBinType, TxInput, TxOutputType, TxInputType, StarcoinAddress as StarcoinAddress$1, StarcoinPublicKey as StarcoinPublicKey$1, StarcoinMessageSignature, StarcoinSignedTx, NEMAddress as NEMAddress$1, NEMSignedTx, SolanaAddress as SolanaAddress$1, SolanaSignedTx as SolanaSignedTx$1, SolanaOffChainMessageVersion, SolanaOffChainMessageFormat, StellarAddress as StellarAddress$1, StellarSignedTx, TronAddress as TronAddress$1, TronResourceCode, TronSignedTx, TronMessageSignature, ConfluxAddress as ConfluxAddress$1, ConfluxMessageSignature, NearAddress as NearAddress$1, NearSignedTx, AptosAddress as AptosAddress$1, AptosMessageSignature as AptosMessageSignature$1, AptosSignedTx as AptosSignedTx$1, AlgorandAddress, AlgorandSignedTx, CosmosAddress as CosmosAddress$1, CosmosSignedTx as CosmosSignedTx$1, SuiAddress as SuiAddress$1, SuiMessageSignature, CardanoAddressParametersType, CardanoMessageSignature, FilecoinAddress as FilecoinAddress$1, FilecoinSignedTx as FilecoinSignedTx$1, PolkadotAddress as PolkadotAddress$1, PolkadotSignedTx as PolkadotSignedTx$1, KaspaAddress as KaspaAddress$1, NervosAddress as NervosAddress$1, NervosSignedTx as NervosSignedTx$1, DnxAddress as DnxAddress$1, TonWalletVersion, TonWorkChain, TonSignedMessage, TonSignedProof, ScdoAddress as ScdoAddress$1, ScdoSignedMessage, ScdoSignedTx as ScdoSignedTx$1, AlephiumMessageSignature, AlephiumSignedTx as AlephiumSignedTx$1, BenfenAddress as BenfenAddress$1, BenfenMessageSignature, Transport, OneKeyDeviceInfo, ChangeOutputScriptType } from '@onekeyfe/hd-transport';
|
|
4
4
|
export { Messages as PROTO } from '@onekeyfe/hd-transport';
|
|
5
5
|
import { EDeviceType, EFirmwareType, Deferred } from '@onekeyfe/hd-shared';
|
|
6
6
|
|
|
@@ -2913,35 +2913,6 @@ declare const createErrorMessage: (error: Error & {
|
|
|
2913
2913
|
code?: string | number;
|
|
2914
2914
|
}) => Unsuccessful;
|
|
2915
2915
|
|
|
2916
|
-
type DeviceDescriptorDiff = {
|
|
2917
|
-
didUpdate: boolean;
|
|
2918
|
-
connected: OneKeyDeviceInfo[];
|
|
2919
|
-
disconnected: OneKeyDeviceInfo[];
|
|
2920
|
-
changedSessions: OneKeyDeviceInfo[];
|
|
2921
|
-
changedDebugSessions: OneKeyDeviceInfo[];
|
|
2922
|
-
acquired: OneKeyDeviceInfo[];
|
|
2923
|
-
debugAcquired: OneKeyDeviceInfo[];
|
|
2924
|
-
released: OneKeyDeviceInfo[];
|
|
2925
|
-
debugReleased: OneKeyDeviceInfo[];
|
|
2926
|
-
descriptors: OneKeyDeviceInfo[];
|
|
2927
|
-
};
|
|
2928
|
-
|
|
2929
|
-
declare class DeviceConnector {
|
|
2930
|
-
transport: Transport;
|
|
2931
|
-
listenTimestamp: number;
|
|
2932
|
-
current: OneKeyDeviceInfo[] | null;
|
|
2933
|
-
upcoming: OneKeyDeviceInfo[];
|
|
2934
|
-
listening: boolean;
|
|
2935
|
-
constructor();
|
|
2936
|
-
enumerate(): Promise<DeviceDescriptorDiff | undefined>;
|
|
2937
|
-
listen(): Promise<void>;
|
|
2938
|
-
stop(): void;
|
|
2939
|
-
acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean): Promise<string | undefined>;
|
|
2940
|
-
release(session: string, onclose: boolean): Promise<void>;
|
|
2941
|
-
promptDeviceAccess(): Promise<USBDevice | BluetoothDevice | null>;
|
|
2942
|
-
_reportDevicesChange(): void;
|
|
2943
|
-
}
|
|
2944
|
-
|
|
2945
2916
|
type PassphrasePromptResponse = {
|
|
2946
2917
|
passphrase?: string;
|
|
2947
2918
|
passphraseOnDevice?: boolean;
|
|
@@ -3017,6 +2988,36 @@ declare class DeviceCommands {
|
|
|
3017
2988
|
_promptPassphrase(options: PassphraseRequestPayload): Promise<PassphrasePromptResponse>;
|
|
3018
2989
|
}
|
|
3019
2990
|
|
|
2991
|
+
type DeviceDescriptorDiff = {
|
|
2992
|
+
didUpdate: boolean;
|
|
2993
|
+
connected: OneKeyDeviceInfo[];
|
|
2994
|
+
disconnected: OneKeyDeviceInfo[];
|
|
2995
|
+
changedSessions: OneKeyDeviceInfo[];
|
|
2996
|
+
changedDebugSessions: OneKeyDeviceInfo[];
|
|
2997
|
+
acquired: OneKeyDeviceInfo[];
|
|
2998
|
+
debugAcquired: OneKeyDeviceInfo[];
|
|
2999
|
+
released: OneKeyDeviceInfo[];
|
|
3000
|
+
debugReleased: OneKeyDeviceInfo[];
|
|
3001
|
+
descriptors: OneKeyDeviceInfo[];
|
|
3002
|
+
};
|
|
3003
|
+
|
|
3004
|
+
declare class DeviceConnector {
|
|
3005
|
+
transport: Transport;
|
|
3006
|
+
listenTimestamp: number;
|
|
3007
|
+
current: OneKeyDeviceInfo[] | null;
|
|
3008
|
+
upcoming: OneKeyDeviceInfo[];
|
|
3009
|
+
listening: boolean;
|
|
3010
|
+
constructor();
|
|
3011
|
+
enumerate(): Promise<DeviceDescriptorDiff | undefined>;
|
|
3012
|
+
listen(): Promise<void>;
|
|
3013
|
+
stop(): void;
|
|
3014
|
+
acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean): Promise<string | undefined>;
|
|
3015
|
+
release(session: string, onclose: boolean): Promise<void>;
|
|
3016
|
+
disconnect(session: string | undefined | null): Promise<void>;
|
|
3017
|
+
promptDeviceAccess(): Promise<USBDevice | BluetoothDevice | null>;
|
|
3018
|
+
_reportDevicesChange(): void;
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3020
3021
|
type InitOptions = {
|
|
3021
3022
|
initSession?: boolean;
|
|
3022
3023
|
deviceId?: string;
|
package/dist/index.js
CHANGED
|
@@ -27405,6 +27405,7 @@ class Device extends events.exports {
|
|
|
27405
27405
|
});
|
|
27406
27406
|
}
|
|
27407
27407
|
_runInner(fn, options) {
|
|
27408
|
+
var _a;
|
|
27408
27409
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27409
27410
|
if (!this.isUsedHere() || this.commands.disposed) {
|
|
27410
27411
|
const env = DataManager.getSettings('env');
|
|
@@ -27447,14 +27448,10 @@ class Device extends events.exports {
|
|
|
27447
27448
|
this.runPromise.reject(e);
|
|
27448
27449
|
}
|
|
27449
27450
|
if (e instanceof hdShared.HardwareError &&
|
|
27450
|
-
(e.errorCode
|
|
27451
|
-
|
|
27452
|
-
|
|
27453
|
-
|
|
27454
|
-
e.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError ||
|
|
27455
|
-
e.errorCode === hdShared.HardwareErrorCode.PinInvalid ||
|
|
27456
|
-
e.errorCode === hdShared.HardwareErrorCode.PinCancelled ||
|
|
27457
|
-
e.errorCode === hdShared.HardwareErrorCode.UnexpectPassphrase)) {
|
|
27451
|
+
hdShared.ERROR_CODES_REQUIRE_RELEASE.includes(e.errorCode)) {
|
|
27452
|
+
if (hdShared.ERROR_CODES_REQUIRE_DISCONNECT.includes(e.errorCode)) {
|
|
27453
|
+
yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.disconnect(this.mainId));
|
|
27454
|
+
}
|
|
27458
27455
|
yield this.release();
|
|
27459
27456
|
Log$a.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
|
|
27460
27457
|
}
|
|
@@ -39634,6 +39631,18 @@ class DeviceConnector {
|
|
|
39634
39631
|
}
|
|
39635
39632
|
});
|
|
39636
39633
|
}
|
|
39634
|
+
disconnect(session) {
|
|
39635
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39636
|
+
try {
|
|
39637
|
+
if (this.transport.disconnect && !!session) {
|
|
39638
|
+
yield this.transport.disconnect(session);
|
|
39639
|
+
}
|
|
39640
|
+
}
|
|
39641
|
+
catch (error) {
|
|
39642
|
+
safeThrowError(error);
|
|
39643
|
+
}
|
|
39644
|
+
});
|
|
39645
|
+
}
|
|
39637
39646
|
promptDeviceAccess() {
|
|
39638
39647
|
if (!this.transport.promptDeviceAccess) {
|
|
39639
39648
|
return Promise.resolve(null);
|
|
@@ -40076,6 +40085,10 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
40076
40085
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
40077
40086
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
40078
40087
|
completeMethodRequestContext(method, error);
|
|
40088
|
+
if (error instanceof hdShared.HardwareError &&
|
|
40089
|
+
hdShared.ERROR_CODES_REQUIRE_RELEASE.includes(error.errorCode)) {
|
|
40090
|
+
throw error;
|
|
40091
|
+
}
|
|
40079
40092
|
}
|
|
40080
40093
|
});
|
|
40081
40094
|
Log.debug('Call API - Device Run: ', device.mainId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.1.22-alpha.
|
|
3
|
+
"version": "1.1.22-alpha.2",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
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": "1.1.22-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.1.22-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.1.22-alpha.2",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.1.22-alpha.2",
|
|
30
30
|
"axios": "1.12.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@types/w3c-web-usb": "^1.0.10",
|
|
45
45
|
"@types/web-bluetooth": "^0.0.21"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "a619ea24331a5c59b2d9b4b251c95a56a420739a"
|
|
48
48
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
3
|
import {
|
|
4
|
+
ERROR_CODES_REQUIRE_RELEASE,
|
|
4
5
|
ERRORS,
|
|
5
6
|
HardwareError,
|
|
6
7
|
HardwareErrorCode,
|
|
@@ -533,6 +534,14 @@ const onCallDevice = async (
|
|
|
533
534
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
534
535
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
535
536
|
completeMethodRequestContext(method, error);
|
|
537
|
+
|
|
538
|
+
// Re-throw errors that need to trigger device release/disconnect in Device._runInner
|
|
539
|
+
if (
|
|
540
|
+
error instanceof HardwareError &&
|
|
541
|
+
ERROR_CODES_REQUIRE_RELEASE.includes(error.errorCode as any)
|
|
542
|
+
) {
|
|
543
|
+
throw error;
|
|
544
|
+
}
|
|
536
545
|
}
|
|
537
546
|
};
|
|
538
547
|
Log.debug('Call API - Device Run: ', device.mainId);
|
package/src/device/Device.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import EventEmitter from 'events';
|
|
2
2
|
import semver from 'semver';
|
|
3
|
-
import {
|
|
3
|
+
import { Enum_Capability } from '@onekeyfe/hd-transport';
|
|
4
4
|
import {
|
|
5
|
-
createDeferred,
|
|
6
|
-
Deferred,
|
|
7
5
|
EDeviceType,
|
|
6
|
+
ERROR_CODES_REQUIRE_DISCONNECT,
|
|
7
|
+
ERROR_CODES_REQUIRE_RELEASE,
|
|
8
8
|
ERRORS,
|
|
9
9
|
HardwareError,
|
|
10
10
|
HardwareErrorCode,
|
|
11
|
+
createDeferred,
|
|
11
12
|
} from '@onekeyfe/hd-shared';
|
|
13
|
+
|
|
12
14
|
import {
|
|
15
|
+
LoggerNames,
|
|
13
16
|
getDeviceBLEFirmwareVersion,
|
|
14
17
|
getDeviceBleName,
|
|
15
18
|
getDeviceFirmwareVersion,
|
|
@@ -18,7 +21,6 @@ import {
|
|
|
18
21
|
getDeviceUUID,
|
|
19
22
|
getLogger,
|
|
20
23
|
getMethodVersionRange,
|
|
21
|
-
LoggerNames,
|
|
22
24
|
} from '../utils';
|
|
23
25
|
import {
|
|
24
26
|
fixFeaturesFirmwareVersion,
|
|
@@ -26,30 +28,32 @@ import {
|
|
|
26
28
|
} from '../utils/deviceFeaturesUtils';
|
|
27
29
|
import { generateInstanceId } from '../utils/tracing';
|
|
28
30
|
|
|
29
|
-
import type DeviceConnector from './DeviceConnector';
|
|
30
31
|
// eslint-disable-next-line import/no-cycle
|
|
31
|
-
import { DeviceCommands
|
|
32
|
-
|
|
32
|
+
import { DeviceCommands } from './DeviceCommands';
|
|
33
33
|
import {
|
|
34
34
|
type DeviceFirmwareRange,
|
|
35
|
-
EOneKeyDeviceMode,
|
|
36
35
|
type Device as DeviceTyped,
|
|
36
|
+
EOneKeyDeviceMode,
|
|
37
37
|
type Features,
|
|
38
38
|
type UnavailableCapabilities,
|
|
39
39
|
} from '../types';
|
|
40
|
-
import {
|
|
41
|
-
DEVICE,
|
|
42
|
-
DeviceButtonRequestPayload,
|
|
43
|
-
DeviceFeaturesPayload,
|
|
44
|
-
PassphraseRequestPayload,
|
|
45
|
-
UI_REQUEST,
|
|
46
|
-
} from '../events';
|
|
47
|
-
import { PROTO } from '../constants';
|
|
40
|
+
import { DEVICE, UI_REQUEST } from '../events';
|
|
48
41
|
import { DataManager } from '../data-manager';
|
|
49
42
|
import TransportManager from '../data-manager/TransportManager';
|
|
50
43
|
import { toHardened } from '../api/helpers/pathUtils';
|
|
51
44
|
import { existCapability } from '../utils/capabilitieUtils';
|
|
52
45
|
|
|
46
|
+
import type { PROTO } from '../constants';
|
|
47
|
+
import type {
|
|
48
|
+
DeviceButtonRequestPayload,
|
|
49
|
+
DeviceFeaturesPayload,
|
|
50
|
+
PassphraseRequestPayload,
|
|
51
|
+
} from '../events';
|
|
52
|
+
import type { PassphrasePromptResponse } from './DeviceCommands';
|
|
53
|
+
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
54
|
+
import type { OneKeyDeviceInfo as DeviceDescriptor } from '@onekeyfe/hd-transport';
|
|
55
|
+
import type DeviceConnector from './DeviceConnector';
|
|
56
|
+
|
|
53
57
|
export type InitOptions = {
|
|
54
58
|
initSession?: boolean;
|
|
55
59
|
deviceId?: string;
|
|
@@ -595,15 +599,11 @@ export class Device extends EventEmitter {
|
|
|
595
599
|
|
|
596
600
|
if (
|
|
597
601
|
e instanceof HardwareError &&
|
|
598
|
-
(e.errorCode
|
|
599
|
-
e.errorCode === HardwareErrorCode.DeviceInterruptedFromOutside ||
|
|
600
|
-
e.errorCode === HardwareErrorCode.DeviceInterruptedFromUser ||
|
|
601
|
-
e.errorCode === HardwareErrorCode.DeviceCheckPassphraseStateError ||
|
|
602
|
-
e.errorCode === HardwareErrorCode.ResponseUnexpectTypeError ||
|
|
603
|
-
e.errorCode === HardwareErrorCode.PinInvalid ||
|
|
604
|
-
e.errorCode === HardwareErrorCode.PinCancelled ||
|
|
605
|
-
e.errorCode === HardwareErrorCode.UnexpectPassphrase)
|
|
602
|
+
ERROR_CODES_REQUIRE_RELEASE.includes(e.errorCode as any)
|
|
606
603
|
) {
|
|
604
|
+
if (ERROR_CODES_REQUIRE_DISCONNECT.includes(e.errorCode as any)) {
|
|
605
|
+
await this.deviceConnector?.disconnect(this.mainId);
|
|
606
|
+
}
|
|
607
607
|
await this.release();
|
|
608
608
|
Log.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
|
|
609
609
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Transport, OneKeyDeviceInfo as DeviceDescriptor } from '@onekeyfe/hd-transport';
|
|
2
1
|
import { safeThrowError } from '../constants';
|
|
3
2
|
import { DataManager } from '../data-manager';
|
|
4
3
|
import TransportManager from '../data-manager/TransportManager';
|
|
5
|
-
import { DevicePool
|
|
4
|
+
import { DevicePool } from './DevicePool';
|
|
6
5
|
import { resolveAfter } from '../utils/promiseUtils';
|
|
7
|
-
import {
|
|
6
|
+
import { LoggerNames, getLogger } from '../utils';
|
|
7
|
+
|
|
8
|
+
import type { DeviceDescriptorDiff } from './DevicePool';
|
|
9
|
+
import type { OneKeyDeviceInfo as DeviceDescriptor, Transport } from '@onekeyfe/hd-transport';
|
|
8
10
|
|
|
9
11
|
const Log = getLogger(LoggerNames.DeviceConnector);
|
|
10
12
|
|
|
@@ -99,6 +101,16 @@ export default class DeviceConnector {
|
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
|
|
104
|
+
async disconnect(session: string | undefined | null) {
|
|
105
|
+
try {
|
|
106
|
+
if (this.transport.disconnect && !!session) {
|
|
107
|
+
await this.transport.disconnect(session);
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
safeThrowError(error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
102
114
|
promptDeviceAccess(): Promise<USBDevice | BluetoothDevice | null> {
|
|
103
115
|
if (!this.transport.promptDeviceAccess) {
|
|
104
116
|
return Promise.resolve(null);
|