@onekeyfe/hd-core 1.1.21-alpha.2 → 1.1.21-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/FirmwareUpdateV3.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 +19 -0
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV3.ts +0 -1
- package/src/device/Device.ts +26 -16
- package/src/device/DeviceConnector.ts +16 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV3.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV3.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAI/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,qBAAqB,CAAC;AAKnE,eAAO,MAAM,gCAAgC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV3.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV3.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAI/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,qBAAqB,CAAC;AAKnE,eAAO,MAAM,gCAAgC,UAAU,CAAC;AAaxD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,wBAAwB,CAAC,sBAAsB,CAAC;IAC5F,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAE1C,IAAI;IAmCE,GAAG;;;;;IA8CT,OAAO,CAAC,wBAAwB;YAiBlB,qBAAqB;YAoBrB,uBAAuB;YAiBvB,2BAA2B;YAiD3B,aAAa;IA2M3B,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,yBAAyB;IAQjC,OAAO,CAAC,qBAAqB;IAuBvB,sBAAsB,CAAC,OAAO,EAAE,MAAM;CA0E7C"}
|
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,O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+
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;IAWnD,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
|
|
|
@@ -2897,35 +2897,6 @@ declare const createErrorMessage: (error: Error & {
|
|
|
2897
2897
|
code?: string | number;
|
|
2898
2898
|
}) => Unsuccessful;
|
|
2899
2899
|
|
|
2900
|
-
type DeviceDescriptorDiff = {
|
|
2901
|
-
didUpdate: boolean;
|
|
2902
|
-
connected: OneKeyDeviceInfo[];
|
|
2903
|
-
disconnected: OneKeyDeviceInfo[];
|
|
2904
|
-
changedSessions: OneKeyDeviceInfo[];
|
|
2905
|
-
changedDebugSessions: OneKeyDeviceInfo[];
|
|
2906
|
-
acquired: OneKeyDeviceInfo[];
|
|
2907
|
-
debugAcquired: OneKeyDeviceInfo[];
|
|
2908
|
-
released: OneKeyDeviceInfo[];
|
|
2909
|
-
debugReleased: OneKeyDeviceInfo[];
|
|
2910
|
-
descriptors: OneKeyDeviceInfo[];
|
|
2911
|
-
};
|
|
2912
|
-
|
|
2913
|
-
declare class DeviceConnector {
|
|
2914
|
-
transport: Transport;
|
|
2915
|
-
listenTimestamp: number;
|
|
2916
|
-
current: OneKeyDeviceInfo[] | null;
|
|
2917
|
-
upcoming: OneKeyDeviceInfo[];
|
|
2918
|
-
listening: boolean;
|
|
2919
|
-
constructor();
|
|
2920
|
-
enumerate(): Promise<DeviceDescriptorDiff | undefined>;
|
|
2921
|
-
listen(): Promise<void>;
|
|
2922
|
-
stop(): void;
|
|
2923
|
-
acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean): Promise<string | undefined>;
|
|
2924
|
-
release(session: string, onclose: boolean): Promise<void>;
|
|
2925
|
-
promptDeviceAccess(): Promise<USBDevice | BluetoothDevice | null>;
|
|
2926
|
-
_reportDevicesChange(): void;
|
|
2927
|
-
}
|
|
2928
|
-
|
|
2929
2900
|
type PassphrasePromptResponse = {
|
|
2930
2901
|
passphrase?: string;
|
|
2931
2902
|
passphraseOnDevice?: boolean;
|
|
@@ -3001,6 +2972,36 @@ declare class DeviceCommands {
|
|
|
3001
2972
|
_promptPassphrase(options: PassphraseRequestPayload): Promise<PassphrasePromptResponse>;
|
|
3002
2973
|
}
|
|
3003
2974
|
|
|
2975
|
+
type DeviceDescriptorDiff = {
|
|
2976
|
+
didUpdate: boolean;
|
|
2977
|
+
connected: OneKeyDeviceInfo[];
|
|
2978
|
+
disconnected: OneKeyDeviceInfo[];
|
|
2979
|
+
changedSessions: OneKeyDeviceInfo[];
|
|
2980
|
+
changedDebugSessions: OneKeyDeviceInfo[];
|
|
2981
|
+
acquired: OneKeyDeviceInfo[];
|
|
2982
|
+
debugAcquired: OneKeyDeviceInfo[];
|
|
2983
|
+
released: OneKeyDeviceInfo[];
|
|
2984
|
+
debugReleased: OneKeyDeviceInfo[];
|
|
2985
|
+
descriptors: OneKeyDeviceInfo[];
|
|
2986
|
+
};
|
|
2987
|
+
|
|
2988
|
+
declare class DeviceConnector {
|
|
2989
|
+
transport: Transport;
|
|
2990
|
+
listenTimestamp: number;
|
|
2991
|
+
current: OneKeyDeviceInfo[] | null;
|
|
2992
|
+
upcoming: OneKeyDeviceInfo[];
|
|
2993
|
+
listening: boolean;
|
|
2994
|
+
constructor();
|
|
2995
|
+
enumerate(): Promise<DeviceDescriptorDiff | undefined>;
|
|
2996
|
+
listen(): Promise<void>;
|
|
2997
|
+
stop(): void;
|
|
2998
|
+
acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean): Promise<string | undefined>;
|
|
2999
|
+
release(session: string, onclose: boolean): Promise<void>;
|
|
3000
|
+
disconnect(session: string | undefined | null): Promise<void>;
|
|
3001
|
+
promptDeviceAccess(): Promise<USBDevice | BluetoothDevice | null>;
|
|
3002
|
+
_reportDevicesChange(): void;
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3004
3005
|
type InitOptions = {
|
|
3005
3006
|
initSession?: boolean;
|
|
3006
3007
|
deviceId?: string;
|
package/dist/index.js
CHANGED
|
@@ -27401,6 +27401,7 @@ class Device extends events.exports {
|
|
|
27401
27401
|
});
|
|
27402
27402
|
}
|
|
27403
27403
|
_runInner(fn, options) {
|
|
27404
|
+
var _a;
|
|
27404
27405
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27405
27406
|
if (!this.isUsedHere() || this.commands.disposed) {
|
|
27406
27407
|
const env = DataManager.getSettings('env');
|
|
@@ -27442,6 +27443,7 @@ class Device extends events.exports {
|
|
|
27442
27443
|
if (this.runPromise) {
|
|
27443
27444
|
this.runPromise.reject(e);
|
|
27444
27445
|
}
|
|
27446
|
+
Log$a.debug('=====>>>>>> _runInner error: ', e);
|
|
27445
27447
|
if (e instanceof hdShared.HardwareError &&
|
|
27446
27448
|
(e.errorCode === hdShared.HardwareErrorCode.DeviceInitializeFailed ||
|
|
27447
27449
|
e.errorCode === hdShared.HardwareErrorCode.DeviceInterruptedFromOutside ||
|
|
@@ -27451,6 +27453,10 @@ class Device extends events.exports {
|
|
|
27451
27453
|
e.errorCode === hdShared.HardwareErrorCode.PinInvalid ||
|
|
27452
27454
|
e.errorCode === hdShared.HardwareErrorCode.PinCancelled ||
|
|
27453
27455
|
e.errorCode === hdShared.HardwareErrorCode.UnexpectPassphrase)) {
|
|
27456
|
+
if (e.errorCode === hdShared.HardwareErrorCode.DeviceInitializeFailed ||
|
|
27457
|
+
e.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError) {
|
|
27458
|
+
yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.disconnect(this.mainId));
|
|
27459
|
+
}
|
|
27454
27460
|
yield this.release();
|
|
27455
27461
|
Log$a.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
|
|
27456
27462
|
}
|
|
@@ -39603,6 +39609,19 @@ class DeviceConnector {
|
|
|
39603
39609
|
}
|
|
39604
39610
|
});
|
|
39605
39611
|
}
|
|
39612
|
+
disconnect(session) {
|
|
39613
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39614
|
+
try {
|
|
39615
|
+
Log$2.debug('=====>>>>>> disconnect: ', session);
|
|
39616
|
+
if (this.transport.disconnect && !!session) {
|
|
39617
|
+
yield this.transport.disconnect(session);
|
|
39618
|
+
}
|
|
39619
|
+
}
|
|
39620
|
+
catch (error) {
|
|
39621
|
+
safeThrowError(error);
|
|
39622
|
+
}
|
|
39623
|
+
});
|
|
39624
|
+
}
|
|
39606
39625
|
promptDeviceAccess() {
|
|
39607
39626
|
if (!this.transport.promptDeviceAccess) {
|
|
39608
39627
|
return Promise.resolve(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.1.21-alpha.
|
|
3
|
+
"version": "1.1.21-alpha.5",
|
|
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.21-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.1.21-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.1.21-alpha.5",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.1.21-alpha.5",
|
|
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": "0252084f01f06a7a6f305a45853c1f21dd2b4755"
|
|
48
48
|
}
|
package/src/device/Device.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
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,
|
|
8
6
|
ERRORS,
|
|
9
7
|
HardwareError,
|
|
10
8
|
HardwareErrorCode,
|
|
9
|
+
createDeferred,
|
|
11
10
|
} from '@onekeyfe/hd-shared';
|
|
11
|
+
|
|
12
12
|
import {
|
|
13
|
+
LoggerNames,
|
|
13
14
|
getDeviceBLEFirmwareVersion,
|
|
14
15
|
getDeviceBleName,
|
|
15
16
|
getDeviceFirmwareVersion,
|
|
@@ -18,7 +19,6 @@ import {
|
|
|
18
19
|
getDeviceUUID,
|
|
19
20
|
getLogger,
|
|
20
21
|
getMethodVersionRange,
|
|
21
|
-
LoggerNames,
|
|
22
22
|
} from '../utils';
|
|
23
23
|
import {
|
|
24
24
|
fixFeaturesFirmwareVersion,
|
|
@@ -26,30 +26,32 @@ import {
|
|
|
26
26
|
} from '../utils/deviceFeaturesUtils';
|
|
27
27
|
import { generateInstanceId } from '../utils/tracing';
|
|
28
28
|
|
|
29
|
-
import type DeviceConnector from './DeviceConnector';
|
|
30
29
|
// eslint-disable-next-line import/no-cycle
|
|
31
|
-
import { DeviceCommands
|
|
32
|
-
|
|
30
|
+
import { DeviceCommands } from './DeviceCommands';
|
|
33
31
|
import {
|
|
34
32
|
type DeviceFirmwareRange,
|
|
35
|
-
EOneKeyDeviceMode,
|
|
36
33
|
type Device as DeviceTyped,
|
|
34
|
+
EOneKeyDeviceMode,
|
|
37
35
|
type Features,
|
|
38
36
|
type UnavailableCapabilities,
|
|
39
37
|
} from '../types';
|
|
40
|
-
import {
|
|
41
|
-
DEVICE,
|
|
42
|
-
DeviceButtonRequestPayload,
|
|
43
|
-
DeviceFeaturesPayload,
|
|
44
|
-
PassphraseRequestPayload,
|
|
45
|
-
UI_REQUEST,
|
|
46
|
-
} from '../events';
|
|
47
|
-
import { PROTO } from '../constants';
|
|
38
|
+
import { DEVICE, UI_REQUEST } from '../events';
|
|
48
39
|
import { DataManager } from '../data-manager';
|
|
49
40
|
import TransportManager from '../data-manager/TransportManager';
|
|
50
41
|
import { toHardened } from '../api/helpers/pathUtils';
|
|
51
42
|
import { existCapability } from '../utils/capabilitieUtils';
|
|
52
43
|
|
|
44
|
+
import type { PROTO } from '../constants';
|
|
45
|
+
import type {
|
|
46
|
+
DeviceButtonRequestPayload,
|
|
47
|
+
DeviceFeaturesPayload,
|
|
48
|
+
PassphraseRequestPayload,
|
|
49
|
+
} from '../events';
|
|
50
|
+
import type { PassphrasePromptResponse } from './DeviceCommands';
|
|
51
|
+
import type { Deferred } from '@onekeyfe/hd-shared';
|
|
52
|
+
import type { OneKeyDeviceInfo as DeviceDescriptor } from '@onekeyfe/hd-transport';
|
|
53
|
+
import type DeviceConnector from './DeviceConnector';
|
|
54
|
+
|
|
53
55
|
export type InitOptions = {
|
|
54
56
|
initSession?: boolean;
|
|
55
57
|
deviceId?: string;
|
|
@@ -589,6 +591,8 @@ export class Device extends EventEmitter {
|
|
|
589
591
|
this.runPromise.reject(e);
|
|
590
592
|
}
|
|
591
593
|
|
|
594
|
+
Log.debug('=====>>>>>> _runInner error: ', e);
|
|
595
|
+
|
|
592
596
|
if (
|
|
593
597
|
e instanceof HardwareError &&
|
|
594
598
|
(e.errorCode === HardwareErrorCode.DeviceInitializeFailed ||
|
|
@@ -600,6 +604,12 @@ export class Device extends EventEmitter {
|
|
|
600
604
|
e.errorCode === HardwareErrorCode.PinCancelled ||
|
|
601
605
|
e.errorCode === HardwareErrorCode.UnexpectPassphrase)
|
|
602
606
|
) {
|
|
607
|
+
if (
|
|
608
|
+
e.errorCode === HardwareErrorCode.DeviceInitializeFailed ||
|
|
609
|
+
e.errorCode === HardwareErrorCode.ResponseUnexpectTypeError
|
|
610
|
+
) {
|
|
611
|
+
await this.deviceConnector?.disconnect(this.mainId);
|
|
612
|
+
}
|
|
603
613
|
await this.release();
|
|
604
614
|
Log.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
|
|
605
615
|
}
|
|
@@ -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,17 @@ export default class DeviceConnector {
|
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
|
|
104
|
+
async disconnect(session: string | undefined | null) {
|
|
105
|
+
try {
|
|
106
|
+
Log.debug('=====>>>>>> disconnect: ', session);
|
|
107
|
+
if (this.transport.disconnect && !!session) {
|
|
108
|
+
await this.transport.disconnect(session);
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
safeThrowError(error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
102
115
|
promptDeviceAccess(): Promise<USBDevice | BluetoothDevice | null> {
|
|
103
116
|
if (!this.transport.promptDeviceAccess) {
|
|
104
117
|
return Promise.resolve(null);
|