@onekeyfe/hd-core 1.2.8-alpha.9 → 1.2.8
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/__tests__/DeviceCommands.test.ts +13 -66
- package/__tests__/core-error-output.test.ts +3 -34
- package/__tests__/device-lifecycle-events.test.ts +17 -64
- package/__tests__/device-pool-state.test.ts +0 -50
- package/__tests__/protocol-v2-bootloader-mode.test.ts +2 -43
- package/__tests__/protocol-v2.test.ts +47 -0
- package/__tests__/refresh-device-state.test.ts +17 -19
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +0 -2
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/index.d.ts +2 -6
- package/dist/index.js +28 -39
- package/dist/types/params.d.ts +0 -1
- package/dist/types/params.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +25 -8
- package/src/api/GetDeviceState.ts +5 -2
- package/src/api/protocol-v2/DeviceReboot.ts +0 -2
- package/src/core/index.ts +7 -3
- package/src/device/Device.ts +1 -11
- package/src/device/DeviceCommands.ts +1 -15
- package/src/device/DevicePool.ts +2 -12
- package/src/events/core.ts +2 -2
- package/src/types/params.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceCommands.d.ts","sourceRoot":"","sources":["../../src/device/DeviceCommands.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,oBAAoB,EAG1B,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAU,KAAK,wBAA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82
|
payload: {
|
|
83
83
|
error: string;
|
|
84
84
|
code?: string | number;
|
|
85
|
-
params?: Record<string, unknown>;
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
87
|
interface Success<T> {
|
|
@@ -145,7 +144,7 @@ declare class DeviceCommands {
|
|
|
145
144
|
};
|
|
146
145
|
} | {
|
|
147
146
|
success: boolean;
|
|
148
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902
|
|
147
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
149
148
|
payload: {
|
|
150
149
|
message: string;
|
|
151
150
|
};
|
|
@@ -164,7 +163,7 @@ declare class DeviceCommands {
|
|
|
164
163
|
};
|
|
165
164
|
} | {
|
|
166
165
|
success: boolean;
|
|
167
|
-
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902
|
|
166
|
+
error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
168
167
|
payload: {
|
|
169
168
|
message: string;
|
|
170
169
|
};
|
|
@@ -822,8 +821,6 @@ declare class Device extends EventEmitter {
|
|
|
822
821
|
private interruptedAttempt;
|
|
823
822
|
/** Canonical device-state cache; legacy Features is a compatibility projection. */
|
|
824
823
|
private stateStore;
|
|
825
|
-
/** Retain the old public identity only for disconnect notifications after wipe. */
|
|
826
|
-
private deviceBeforeWipe;
|
|
827
824
|
/** Force the next initialization to reload DeviceInfo after reconnect or reboot. */
|
|
828
825
|
private protocolV2StateNeedsReload;
|
|
829
826
|
/** Runtime context negotiated once per active Protocol V2 link. */
|
|
@@ -863,7 +860,6 @@ declare class Device extends EventEmitter {
|
|
|
863
860
|
constructor(descriptor: OneKeyDeviceInfo, sdkInstanceId?: string);
|
|
864
861
|
static fromDescriptor(originalDescriptor: OneKeyDeviceInfo, sdkInstanceId?: string): Device;
|
|
865
862
|
toMessageObject(): Device$1 | null;
|
|
866
|
-
toDisconnectMessageObject(): Device$1 | null;
|
|
867
863
|
/**
|
|
868
864
|
* Device connect
|
|
869
865
|
* @returns {Promise<boolean>}
|
package/dist/index.js
CHANGED
|
@@ -41534,7 +41534,7 @@ const parseMessage = (messageData) => {
|
|
|
41534
41534
|
const createErrorMessage = (error) => {
|
|
41535
41535
|
let payload = { error: error.message, code: error.code };
|
|
41536
41536
|
if (error instanceof hdShared.HardwareError) {
|
|
41537
|
-
payload = { error: error.message, code: error.errorCode
|
|
41537
|
+
payload = { error: error.message, code: error.errorCode };
|
|
41538
41538
|
}
|
|
41539
41539
|
return {
|
|
41540
41540
|
success: false,
|
|
@@ -43466,9 +43466,7 @@ class DevicePool extends events.exports {
|
|
|
43466
43466
|
const exist = canPathIdentifyDevice(cachedPath)
|
|
43467
43467
|
? descriptorList.find(d => d.path === cachedPath)
|
|
43468
43468
|
: undefined;
|
|
43469
|
-
if (exist &&
|
|
43470
|
-
!(initOptions === null || initOptions === void 0 ? void 0 : initOptions.forceProtocolDetection) &&
|
|
43471
|
-
!(device.needReloadDevice && device.isUnacquired())) {
|
|
43469
|
+
if (exist && !(initOptions === null || initOptions === void 0 ? void 0 : initOptions.forceProtocolDetection)) {
|
|
43472
43470
|
device.updateDescriptor(exist, true);
|
|
43473
43471
|
yield this._refreshRuntimeState(device, initOptions);
|
|
43474
43472
|
devices[connectId] = device;
|
|
@@ -43524,11 +43522,7 @@ class DevicePool extends events.exports {
|
|
|
43524
43522
|
const forceProtocolDetection = (initOptions === null || initOptions === void 0 ? void 0 : initOptions.forceProtocolDetection) === true;
|
|
43525
43523
|
const isNewDevice = !cachedDevice;
|
|
43526
43524
|
const device = cachedDevice !== null && cachedDevice !== void 0 ? cachedDevice : Device.fromDescriptor(descriptor);
|
|
43527
|
-
if (isNewDevice ||
|
|
43528
|
-
forceProtocolDetection ||
|
|
43529
|
-
(device.needReloadDevice && device.isUnacquired())) {
|
|
43530
|
-
if (cachedDevice)
|
|
43531
|
-
device.updateDescriptor(descriptor, true);
|
|
43525
|
+
if (isNewDevice || forceProtocolDetection) {
|
|
43532
43526
|
device.deviceConnector = this.connector;
|
|
43533
43527
|
(_a = device.beginConnectionAttempt) === null || _a === void 0 ? void 0 : _a.call(device);
|
|
43534
43528
|
if (forceProtocolDetection && !isNewDevice) {
|
|
@@ -44215,12 +44209,6 @@ class DeviceCommands {
|
|
|
44215
44209
|
const isProtocolV2DeviceBusyFailure = this.device.isProtocolV2() &&
|
|
44216
44210
|
DEVICE_CONTROL_CALLS.has(callType) &&
|
|
44217
44211
|
subcode === hdTransport.DeviceErrorCode.DeviceError_Busy;
|
|
44218
|
-
const isProtocolV2PinCancelledBusyFailure = this.device.isProtocolV2() &&
|
|
44219
|
-
!DEVICE_SESSION_CALLS.has(callType) &&
|
|
44220
|
-
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_UserCancelled &&
|
|
44221
|
-
/^pin cancelled$/i.test(normalizedMessage);
|
|
44222
|
-
const isProtocolV2FirmwareUpdateBusyFailure = this.device.isProtocolV2() &&
|
|
44223
|
-
/^requested command not allowed while a firmware update is in progress$/i.test(normalizedMessage);
|
|
44224
44212
|
const isLegacyProtocolV2LockedFailure = this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(normalizedMessage);
|
|
44225
44213
|
if (DEVICE_SESSION_CALLS.has(callType) &&
|
|
44226
44214
|
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_InvalidSession) {
|
|
@@ -44271,9 +44259,7 @@ class DeviceCommands {
|
|
|
44271
44259
|
firmwareMessage: message,
|
|
44272
44260
|
});
|
|
44273
44261
|
}
|
|
44274
|
-
else if (isProtocolV2DeviceBusyFailure
|
|
44275
|
-
isProtocolV2PinCancelledBusyFailure ||
|
|
44276
|
-
isProtocolV2FirmwareUpdateBusyFailure) {
|
|
44262
|
+
else if (isProtocolV2DeviceBusyFailure) {
|
|
44277
44263
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceBusy, message, {
|
|
44278
44264
|
failureCode: code,
|
|
44279
44265
|
subcode,
|
|
@@ -45500,7 +45486,6 @@ class Device extends events.exports {
|
|
|
45500
45486
|
this.connectionAttempt = 0;
|
|
45501
45487
|
this.interruptedAttempt = null;
|
|
45502
45488
|
this.stateStore = new DeviceStateStore();
|
|
45503
|
-
this.deviceBeforeWipe = null;
|
|
45504
45489
|
this.protocolV2StateNeedsReload = false;
|
|
45505
45490
|
this.protocolV2UiInteractionCounter = 0;
|
|
45506
45491
|
this.externalState = [];
|
|
@@ -45524,7 +45509,6 @@ class Device extends events.exports {
|
|
|
45524
45509
|
var _a;
|
|
45525
45510
|
if (this.isUnacquired() || !this.features)
|
|
45526
45511
|
return null;
|
|
45527
|
-
this.deviceBeforeWipe = null;
|
|
45528
45512
|
const env = DataManager.getSettings('env');
|
|
45529
45513
|
const deviceType = this.getCurrentDeviceType();
|
|
45530
45514
|
const bleName = this.getCurrentBleName();
|
|
@@ -45558,10 +45542,6 @@ class Device extends events.exports {
|
|
|
45558
45542
|
unavailableCapabilities: this.unavailableCapabilities,
|
|
45559
45543
|
};
|
|
45560
45544
|
}
|
|
45561
|
-
toDisconnectMessageObject() {
|
|
45562
|
-
var _a;
|
|
45563
|
-
return (_a = this.toMessageObject()) !== null && _a !== void 0 ? _a : this.deviceBeforeWipe;
|
|
45564
|
-
}
|
|
45565
45545
|
connect(connectProtocol, options) {
|
|
45566
45546
|
const env = DataManager.getSettings('env');
|
|
45567
45547
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -46313,8 +46293,6 @@ class Device extends events.exports {
|
|
|
46313
46293
|
this.invalidateProtocolV2RuntimeState();
|
|
46314
46294
|
}
|
|
46315
46295
|
invalidateAfterWipe() {
|
|
46316
|
-
var _a;
|
|
46317
|
-
this.deviceBeforeWipe = (_a = this.toMessageObject()) !== null && _a !== void 0 ? _a : this.deviceBeforeWipe;
|
|
46318
46296
|
const deviceId = this.getCurrentDeviceId();
|
|
46319
46297
|
if (deviceId) {
|
|
46320
46298
|
deviceWalletSessionStore.deleteDevice(deviceId);
|
|
@@ -46683,7 +46661,7 @@ class Device extends events.exports {
|
|
|
46683
46661
|
}
|
|
46684
46662
|
hasUnexpectedMode(allow, require) {
|
|
46685
46663
|
if (!this.isUnacquired()) {
|
|
46686
|
-
if (
|
|
46664
|
+
if (this.isBootloader() && !this.isProtocolV2() && !allow.includes(UI_REQUEST.BOOTLOADER)) {
|
|
46687
46665
|
return UI_REQUEST.BOOTLOADER;
|
|
46688
46666
|
}
|
|
46689
46667
|
if (!this.isInitialized() && !allow.includes(UI_REQUEST.NOT_INITIALIZE)) {
|
|
@@ -47494,7 +47472,7 @@ class GetDeviceState extends BaseMethod {
|
|
|
47494
47472
|
if (this.params.scope === 'settings' &&
|
|
47495
47473
|
this.device.isProtocolV2() &&
|
|
47496
47474
|
isLoaderMode(state.status.mode)) {
|
|
47497
|
-
throw hdShared.
|
|
47475
|
+
throw hdShared.createDeviceNotSupportMethodError(`${this.name}:${this.params.scope}`, this.device.getCurrentFirmwareType());
|
|
47498
47476
|
}
|
|
47499
47477
|
return state;
|
|
47500
47478
|
});
|
|
@@ -52613,11 +52591,12 @@ const getProtocolV2ErrorCode = (error) => {
|
|
|
52613
52591
|
};
|
|
52614
52592
|
const isProtocolV2TerminalInstallStatusError = (error) => {
|
|
52615
52593
|
var _a;
|
|
52616
|
-
return
|
|
52617
|
-
(error
|
|
52618
|
-
error.errorCode === hdShared.HardwareErrorCode.
|
|
52619
|
-
|
|
52620
|
-
|
|
52594
|
+
return hdShared.isBleStaleBondHardwareError(error) ||
|
|
52595
|
+
(error instanceof hdShared.HardwareError &&
|
|
52596
|
+
(error.errorCode === hdShared.HardwareErrorCode.ActionCancelled ||
|
|
52597
|
+
error.errorCode === hdShared.HardwareErrorCode.FirmwareError ||
|
|
52598
|
+
error.errorCode === hdShared.HardwareErrorCode.FirmwareVerificationFailed ||
|
|
52599
|
+
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) === PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE));
|
|
52621
52600
|
};
|
|
52622
52601
|
const isProtocolV2TargetStatusFinished = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_FINISHED;
|
|
52623
52602
|
const isProtocolV2TargetStatusInProgress = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_PENDING ||
|
|
@@ -53711,6 +53690,9 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53711
53690
|
return true;
|
|
53712
53691
|
}
|
|
53713
53692
|
catch (error) {
|
|
53693
|
+
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
53694
|
+
throw error;
|
|
53695
|
+
}
|
|
53714
53696
|
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
53715
53697
|
return false;
|
|
53716
53698
|
}
|
|
@@ -53795,7 +53777,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53795
53777
|
lastError = new Error('Protocol V2 device is reachable but is not in bootloader mode');
|
|
53796
53778
|
}
|
|
53797
53779
|
catch (error) {
|
|
53798
|
-
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
53780
|
+
if (hdShared.isBleStaleBondHardwareError(error) || this.isProtocolV2ReconnectIdentityError(error)) {
|
|
53799
53781
|
throw error;
|
|
53800
53782
|
}
|
|
53801
53783
|
shouldReconnect = true;
|
|
@@ -54012,6 +53994,9 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54012
53994
|
}
|
|
54013
53995
|
catch (error) {
|
|
54014
53996
|
this.throwIfAborted();
|
|
53997
|
+
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
53998
|
+
throw error;
|
|
53999
|
+
}
|
|
54015
54000
|
lastError = error;
|
|
54016
54001
|
if (attempt < PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT) {
|
|
54017
54002
|
yield this.recoverProtocolV2FileTransfer();
|
|
@@ -54500,6 +54485,9 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54500
54485
|
}
|
|
54501
54486
|
}
|
|
54502
54487
|
catch (error) {
|
|
54488
|
+
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
54489
|
+
throw error;
|
|
54490
|
+
}
|
|
54503
54491
|
Log$6.log('[FirmwareUpdateV4] unable to confirm App mode before Normal reboot: ', error);
|
|
54504
54492
|
}
|
|
54505
54493
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
@@ -54574,7 +54562,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54574
54562
|
lastError = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, 'Protocol V2 device is still in bootloader mode');
|
|
54575
54563
|
}
|
|
54576
54564
|
catch (error) {
|
|
54577
|
-
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
54565
|
+
if (hdShared.isBleStaleBondHardwareError(error) || this.isProtocolV2ReconnectIdentityError(error)) {
|
|
54578
54566
|
throw error;
|
|
54579
54567
|
}
|
|
54580
54568
|
shouldReconnect = true;
|
|
@@ -54852,7 +54840,6 @@ class DeviceReboot extends BaseMethod {
|
|
|
54852
54840
|
return ['V2'];
|
|
54853
54841
|
}
|
|
54854
54842
|
init() {
|
|
54855
|
-
this.allowDeviceMode.push(UI_REQUEST.BOOTLOADER);
|
|
54856
54843
|
this.skipForceUpdateCheck = true;
|
|
54857
54844
|
this.useDevicePassphraseState = false;
|
|
54858
54845
|
this.unlockPolicy = 'unlock-before-run';
|
|
@@ -66696,6 +66683,9 @@ function isMissingDetectedProtocolV2Error(method, error) {
|
|
|
66696
66683
|
typeof typedError.message === 'string' &&
|
|
66697
66684
|
typedError.message.includes('Device protocol has not been detected'));
|
|
66698
66685
|
}
|
|
66686
|
+
function isTerminalBleStaleBondError(error) {
|
|
66687
|
+
return hdShared.isBleStaleBondHardwareError(error);
|
|
66688
|
+
}
|
|
66699
66689
|
function isDeviceIdentityMismatchError(error) {
|
|
66700
66690
|
return ((error === null || error === void 0 ? void 0 : error.errorCode) === hdShared.HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
66701
66691
|
}
|
|
@@ -66860,7 +66850,6 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
66860
66850
|
hdShared.HardwareErrorCode.BridgeNotInstalled,
|
|
66861
66851
|
hdShared.HardwareErrorCode.BridgeTimeoutError,
|
|
66862
66852
|
hdShared.HardwareErrorCode.BridgeNeedsPermission,
|
|
66863
|
-
hdShared.HardwareErrorCode.WebUsbDeviceAccessError,
|
|
66864
66853
|
].includes(error.errorCode)) {
|
|
66865
66854
|
_deviceList = undefined;
|
|
66866
66855
|
reject(error);
|
|
@@ -66935,12 +66924,12 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
66935
66924
|
hdShared.HardwareErrorCode.DeviceDetectInBootloaderMode,
|
|
66936
66925
|
hdShared.HardwareErrorCode.BleCharacteristicNotifyChangeFailure,
|
|
66937
66926
|
hdShared.HardwareErrorCode.BridgeNeedsPermission,
|
|
66938
|
-
hdShared.HardwareErrorCode.WebUsbDeviceAccessError,
|
|
66939
66927
|
hdShared.HardwareErrorCode.DeviceInterruptedFromUser,
|
|
66940
66928
|
hdShared.HardwareErrorCode.CallQueueActionCancelled,
|
|
66941
66929
|
].includes(error.errorCode) ||
|
|
66942
66930
|
(env === 'react-native' &&
|
|
66943
66931
|
[hdShared.HardwareErrorCode.BleDeviceDisconnected, hdShared.HardwareErrorCode.PollingTimeout].includes(error.errorCode)) ||
|
|
66932
|
+
isTerminalBleStaleBondError(error) ||
|
|
66944
66933
|
isDeviceIdentityMismatchError(error)) {
|
|
66945
66934
|
reject(error);
|
|
66946
66935
|
return;
|
|
@@ -67100,7 +67089,7 @@ const onDeviceConnectHandler = (device) => {
|
|
|
67100
67089
|
};
|
|
67101
67090
|
const onDeviceDisconnectHandler = (device) => {
|
|
67102
67091
|
device.clearPreInitialized();
|
|
67103
|
-
const deviceObject = device.
|
|
67092
|
+
const deviceObject = device.toMessageObject();
|
|
67104
67093
|
if (!deviceObject)
|
|
67105
67094
|
return;
|
|
67106
67095
|
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject }));
|
package/dist/types/params.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/types/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,MAAM,WAAW,YAAY;IAQ3B,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,UAAU,CAAC,EAAE,MAAM,CAAC;IAIpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,6BAA6B,CAAC,EAAE,MAAM,CAAC;IAIvC,eAAe,CA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AmB,CAAC,EAAE,OAAO,CAAC;IAK9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAK9B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAK/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAM3B,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAM1C,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,YAAY,GAAG,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD;AAED,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.8
|
|
3
|
+
"version": "1.2.8",
|
|
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.2.8
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.8
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.8",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.8",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"buffer": "^6.0.3",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/w3c-web-usb": "^1.0.10",
|
|
47
47
|
"@types/web-bluetooth": "^0.0.21"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "9f016278a7f395bf66b8502815dc63191e162fd3"
|
|
50
50
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
EDeviceType,
|
|
3
|
+
ERRORS,
|
|
4
|
+
HardwareError,
|
|
5
|
+
HardwareErrorCode,
|
|
6
|
+
isBleStaleBondHardwareError,
|
|
7
|
+
wait,
|
|
8
|
+
} from '@onekeyfe/hd-shared';
|
|
2
9
|
import JSZip from 'jszip';
|
|
3
10
|
import {
|
|
4
11
|
DeviceRebootType,
|
|
@@ -386,11 +393,12 @@ const getProtocolV2ErrorCode = (error: unknown): number | string | undefined =>
|
|
|
386
393
|
};
|
|
387
394
|
|
|
388
395
|
const isProtocolV2TerminalInstallStatusError = (error: unknown) =>
|
|
389
|
-
error
|
|
390
|
-
(error
|
|
391
|
-
error.errorCode === HardwareErrorCode.
|
|
392
|
-
|
|
393
|
-
|
|
396
|
+
isBleStaleBondHardwareError(error) ||
|
|
397
|
+
(error instanceof HardwareError &&
|
|
398
|
+
(error.errorCode === HardwareErrorCode.ActionCancelled ||
|
|
399
|
+
error.errorCode === HardwareErrorCode.FirmwareError ||
|
|
400
|
+
error.errorCode === HardwareErrorCode.FirmwareVerificationFailed ||
|
|
401
|
+
error.params?.firmwareUpdateCode === PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE));
|
|
394
402
|
|
|
395
403
|
const isProtocolV2TargetStatusFinished = (status: ProtocolV2FirmwareUpdateStatusTarget['status']) =>
|
|
396
404
|
normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_FINISHED;
|
|
@@ -1872,6 +1880,9 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1872
1880
|
if (!expectedHeaderHash || header.headerHash !== expectedHeaderHash) return false;
|
|
1873
1881
|
return true;
|
|
1874
1882
|
} catch (error) {
|
|
1883
|
+
if (isBleStaleBondHardwareError(error)) {
|
|
1884
|
+
throw error;
|
|
1885
|
+
}
|
|
1875
1886
|
Log.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
1876
1887
|
return false;
|
|
1877
1888
|
}
|
|
@@ -1965,7 +1976,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1965
1976
|
}
|
|
1966
1977
|
lastError = new Error('Protocol V2 device is reachable but is not in bootloader mode');
|
|
1967
1978
|
} catch (error) {
|
|
1968
|
-
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
1979
|
+
if (isBleStaleBondHardwareError(error) || this.isProtocolV2ReconnectIdentityError(error)) {
|
|
1969
1980
|
throw error;
|
|
1970
1981
|
}
|
|
1971
1982
|
shouldReconnect = true;
|
|
@@ -2263,6 +2274,9 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2263
2274
|
return processedSize + source.size;
|
|
2264
2275
|
} catch (error) {
|
|
2265
2276
|
this.throwIfAborted();
|
|
2277
|
+
if (isBleStaleBondHardwareError(error)) {
|
|
2278
|
+
throw error;
|
|
2279
|
+
}
|
|
2266
2280
|
lastError = error;
|
|
2267
2281
|
if (attempt < PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT) {
|
|
2268
2282
|
await this.recoverProtocolV2FileTransfer();
|
|
@@ -2930,6 +2944,9 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2930
2944
|
return;
|
|
2931
2945
|
}
|
|
2932
2946
|
} catch (error) {
|
|
2947
|
+
if (isBleStaleBondHardwareError(error)) {
|
|
2948
|
+
throw error;
|
|
2949
|
+
}
|
|
2933
2950
|
Log.log('[FirmwareUpdateV4] unable to confirm App mode before Normal reboot: ', error);
|
|
2934
2951
|
}
|
|
2935
2952
|
await this.protocolV2Reboot(DeviceRebootType.Normal);
|
|
@@ -3022,7 +3039,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
3022
3039
|
'Protocol V2 device is still in bootloader mode'
|
|
3023
3040
|
);
|
|
3024
3041
|
} catch (error) {
|
|
3025
|
-
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
3042
|
+
if (isBleStaleBondHardwareError(error) || this.isProtocolV2ReconnectIdentityError(error)) {
|
|
3026
3043
|
throw error;
|
|
3027
3044
|
}
|
|
3028
3045
|
shouldReconnect = true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
1
|
+
import { ERRORS, HardwareErrorCode, createDeviceNotSupportMethodError } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
4
4
|
import { BaseMethod } from './BaseMethod';
|
|
@@ -49,7 +49,10 @@ export default class GetDeviceState extends BaseMethod<
|
|
|
49
49
|
this.device.isProtocolV2() &&
|
|
50
50
|
isLoaderMode(state.status.mode)
|
|
51
51
|
) {
|
|
52
|
-
throw
|
|
52
|
+
throw createDeviceNotSupportMethodError(
|
|
53
|
+
`${this.name}:${this.params.scope}`,
|
|
54
|
+
this.device.getCurrentFirmwareType()
|
|
55
|
+
);
|
|
53
56
|
}
|
|
54
57
|
return state;
|
|
55
58
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DeviceSessionPinType } from '@onekeyfe/hd-transport';
|
|
2
2
|
|
|
3
|
-
import { UI_REQUEST } from '../../constants/ui-request';
|
|
4
3
|
import { BaseMethod } from '../BaseMethod';
|
|
5
4
|
import { normalizeRebootType } from './helpers';
|
|
6
5
|
|
|
@@ -12,7 +11,6 @@ export default class DeviceReboot extends BaseMethod<DeviceRebootParams> {
|
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
init() {
|
|
15
|
-
this.allowDeviceMode.push(UI_REQUEST.BOOTLOADER);
|
|
16
14
|
this.skipForceUpdateCheck = true;
|
|
17
15
|
this.useDevicePassphraseState = false;
|
|
18
16
|
this.unlockPolicy = 'unlock-before-run';
|
package/src/core/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
createNeedUpgradeFirmwareHardwareError,
|
|
24
24
|
createNewFirmwareForceUpdateHardwareError,
|
|
25
25
|
createNewFirmwareUnReleaseHardwareError,
|
|
26
|
+
isBleStaleBondHardwareError,
|
|
26
27
|
} from '@onekeyfe/hd-shared';
|
|
27
28
|
|
|
28
29
|
import { LoggerNames, enableLog, getLogger, setLoggerPostMessage, wait } from '../utils';
|
|
@@ -1034,6 +1035,10 @@ export function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unkn
|
|
|
1034
1035
|
);
|
|
1035
1036
|
}
|
|
1036
1037
|
|
|
1038
|
+
export function isTerminalBleStaleBondError(error: unknown) {
|
|
1039
|
+
return isBleStaleBondHardwareError(error);
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1037
1042
|
export function isDeviceIdentityMismatchError(error: unknown) {
|
|
1038
1043
|
return (
|
|
1039
1044
|
(error as { errorCode?: unknown })?.errorCode === HardwareErrorCode.DeviceCheckDeviceIdError
|
|
@@ -1272,7 +1277,6 @@ const ensureConnected = async (
|
|
|
1272
1277
|
HardwareErrorCode.BridgeNotInstalled,
|
|
1273
1278
|
HardwareErrorCode.BridgeTimeoutError,
|
|
1274
1279
|
HardwareErrorCode.BridgeNeedsPermission,
|
|
1275
|
-
HardwareErrorCode.WebUsbDeviceAccessError,
|
|
1276
1280
|
].includes(error.errorCode)
|
|
1277
1281
|
) {
|
|
1278
1282
|
_deviceList = undefined;
|
|
@@ -1359,7 +1363,6 @@ const ensureConnected = async (
|
|
|
1359
1363
|
HardwareErrorCode.DeviceDetectInBootloaderMode,
|
|
1360
1364
|
HardwareErrorCode.BleCharacteristicNotifyChangeFailure,
|
|
1361
1365
|
HardwareErrorCode.BridgeNeedsPermission,
|
|
1362
|
-
HardwareErrorCode.WebUsbDeviceAccessError,
|
|
1363
1366
|
HardwareErrorCode.DeviceInterruptedFromUser,
|
|
1364
1367
|
HardwareErrorCode.CallQueueActionCancelled,
|
|
1365
1368
|
].includes(error.errorCode) ||
|
|
@@ -1367,6 +1370,7 @@ const ensureConnected = async (
|
|
|
1367
1370
|
[HardwareErrorCode.BleDeviceDisconnected, HardwareErrorCode.PollingTimeout].includes(
|
|
1368
1371
|
error.errorCode
|
|
1369
1372
|
)) ||
|
|
1373
|
+
isTerminalBleStaleBondError(error) ||
|
|
1370
1374
|
isDeviceIdentityMismatchError(error)
|
|
1371
1375
|
) {
|
|
1372
1376
|
reject(error);
|
|
@@ -1589,7 +1593,7 @@ const onDeviceConnectHandler = (device: Device) => {
|
|
|
1589
1593
|
|
|
1590
1594
|
const onDeviceDisconnectHandler = (device: Device) => {
|
|
1591
1595
|
device.clearPreInitialized();
|
|
1592
|
-
const deviceObject = device.
|
|
1596
|
+
const deviceObject = device.toMessageObject();
|
|
1593
1597
|
if (!deviceObject) return;
|
|
1594
1598
|
postMessage(createDeviceMessage(DEVICE.DISCONNECT, { device: deviceObject }));
|
|
1595
1599
|
};
|
package/src/device/Device.ts
CHANGED
|
@@ -248,9 +248,6 @@ export class Device extends EventEmitter {
|
|
|
248
248
|
/** Canonical device-state cache; legacy Features is a compatibility projection. */
|
|
249
249
|
private stateStore = new DeviceStateStore();
|
|
250
250
|
|
|
251
|
-
/** Retain the old public identity only for disconnect notifications after wipe. */
|
|
252
|
-
private deviceBeforeWipe: DeviceTyped | null = null;
|
|
253
|
-
|
|
254
251
|
/** Force the next initialization to reload DeviceInfo after reconnect or reboot. */
|
|
255
252
|
private protocolV2StateNeedsReload = false;
|
|
256
253
|
|
|
@@ -354,8 +351,6 @@ export class Device extends EventEmitter {
|
|
|
354
351
|
toMessageObject(): DeviceTyped | null {
|
|
355
352
|
if (this.isUnacquired() || !this.features) return null;
|
|
356
353
|
|
|
357
|
-
this.deviceBeforeWipe = null;
|
|
358
|
-
|
|
359
354
|
const env = DataManager.getSettings('env');
|
|
360
355
|
const deviceType = this.getCurrentDeviceType();
|
|
361
356
|
|
|
@@ -400,10 +395,6 @@ export class Device extends EventEmitter {
|
|
|
400
395
|
};
|
|
401
396
|
}
|
|
402
397
|
|
|
403
|
-
toDisconnectMessageObject(): DeviceTyped | null {
|
|
404
|
-
return this.toMessageObject() ?? this.deviceBeforeWipe;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
398
|
/**
|
|
408
399
|
* Device connect
|
|
409
400
|
* @returns {Promise<boolean>}
|
|
@@ -1373,7 +1364,6 @@ export class Device extends EventEmitter {
|
|
|
1373
1364
|
}
|
|
1374
1365
|
|
|
1375
1366
|
invalidateAfterWipe() {
|
|
1376
|
-
this.deviceBeforeWipe = this.toMessageObject() ?? this.deviceBeforeWipe;
|
|
1377
1367
|
const deviceId = this.getCurrentDeviceId();
|
|
1378
1368
|
if (deviceId) {
|
|
1379
1369
|
deviceWalletSessionStore.deleteDevice(deviceId);
|
|
@@ -1811,7 +1801,7 @@ export class Device extends EventEmitter {
|
|
|
1811
1801
|
// both allow and require cases might generate single unexpected mode
|
|
1812
1802
|
if (!this.isUnacquired()) {
|
|
1813
1803
|
// allow cases
|
|
1814
|
-
if (
|
|
1804
|
+
if (this.isBootloader() && !this.isProtocolV2() && !allow.includes(UI_REQUEST.BOOTLOADER)) {
|
|
1815
1805
|
return UI_REQUEST.BOOTLOADER;
|
|
1816
1806
|
}
|
|
1817
1807
|
if (!this.isInitialized() && !allow.includes(UI_REQUEST.NOT_INITIALIZE)) {
|
|
@@ -549,16 +549,6 @@ export class DeviceCommands {
|
|
|
549
549
|
this.device.isProtocolV2() &&
|
|
550
550
|
DEVICE_CONTROL_CALLS.has(callType) &&
|
|
551
551
|
subcode === DeviceErrorCode.DeviceError_Busy;
|
|
552
|
-
const isProtocolV2PinCancelledBusyFailure =
|
|
553
|
-
this.device.isProtocolV2() &&
|
|
554
|
-
!DEVICE_SESSION_CALLS.has(callType) &&
|
|
555
|
-
subcode === DeviceSessionErrorCode.DeviceSessionError_UserCancelled &&
|
|
556
|
-
/^pin cancelled$/i.test(normalizedMessage);
|
|
557
|
-
const isProtocolV2FirmwareUpdateBusyFailure =
|
|
558
|
-
this.device.isProtocolV2() &&
|
|
559
|
-
/^requested command not allowed while a firmware update is in progress$/i.test(
|
|
560
|
-
normalizedMessage
|
|
561
|
-
);
|
|
562
552
|
const isLegacyProtocolV2LockedFailure =
|
|
563
553
|
this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(normalizedMessage);
|
|
564
554
|
if (
|
|
@@ -616,11 +606,7 @@ export class DeviceCommands {
|
|
|
616
606
|
subcode,
|
|
617
607
|
firmwareMessage: message,
|
|
618
608
|
});
|
|
619
|
-
} else if (
|
|
620
|
-
isProtocolV2DeviceBusyFailure ||
|
|
621
|
-
isProtocolV2PinCancelledBusyFailure ||
|
|
622
|
-
isProtocolV2FirmwareUpdateBusyFailure
|
|
623
|
-
) {
|
|
609
|
+
} else if (isProtocolV2DeviceBusyFailure) {
|
|
624
610
|
error = ERRORS.TypedError(HardwareErrorCode.DeviceBusy, message, {
|
|
625
611
|
failureCode: code,
|
|
626
612
|
subcode,
|
package/src/device/DevicePool.ts
CHANGED
|
@@ -114,11 +114,7 @@ export class DevicePool extends EventEmitter {
|
|
|
114
114
|
const exist = canPathIdentifyDevice(cachedPath)
|
|
115
115
|
? descriptorList.find(d => d.path === cachedPath)
|
|
116
116
|
: undefined;
|
|
117
|
-
if (
|
|
118
|
-
exist &&
|
|
119
|
-
!initOptions?.forceProtocolDetection &&
|
|
120
|
-
!(device.needReloadDevice && device.isUnacquired())
|
|
121
|
-
) {
|
|
117
|
+
if (exist && !initOptions?.forceProtocolDetection) {
|
|
122
118
|
// Log.debug('find existed Device: ', connectId);
|
|
123
119
|
device.updateDescriptor(exist, true);
|
|
124
120
|
await this._refreshRuntimeState(device, initOptions);
|
|
@@ -174,13 +170,7 @@ export class DevicePool extends EventEmitter {
|
|
|
174
170
|
const forceProtocolDetection = initOptions?.forceProtocolDetection === true;
|
|
175
171
|
const isNewDevice = !cachedDevice;
|
|
176
172
|
const device = cachedDevice ?? Device.fromDescriptor(descriptor);
|
|
177
|
-
if (
|
|
178
|
-
isNewDevice ||
|
|
179
|
-
forceProtocolDetection ||
|
|
180
|
-
(device.needReloadDevice && device.isUnacquired())
|
|
181
|
-
) {
|
|
182
|
-
// Wipe invalidates state while the same USB path can remain discoverable.
|
|
183
|
-
if (cachedDevice) device.updateDescriptor(descriptor, true);
|
|
173
|
+
if (isNewDevice || forceProtocolDetection) {
|
|
184
174
|
device.deviceConnector = this.connector;
|
|
185
175
|
// Search/discovery acquires outside Device.run(). Start a new attempt so
|
|
186
176
|
// a previous user cancel does not hide this device from later searches.
|
package/src/events/core.ts
CHANGED
|
@@ -54,9 +54,9 @@ export const parseMessage = (messageData: any): CoreMessage => {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
export const createErrorMessage = (error: Error & { code?: string | number }): Unsuccessful => {
|
|
57
|
-
let payload
|
|
57
|
+
let payload = { error: error.message, code: error.code };
|
|
58
58
|
if (error instanceof HardwareError) {
|
|
59
|
-
payload = { error: error.message, code: error.errorCode
|
|
59
|
+
payload = { error: error.message, code: error.errorCode };
|
|
60
60
|
}
|
|
61
61
|
return {
|
|
62
62
|
success: false,
|
package/src/types/params.ts
CHANGED
|
@@ -83,7 +83,7 @@ export type Params<T> = CommonParams & T & { bundle?: undefined };
|
|
|
83
83
|
|
|
84
84
|
export interface Unsuccessful {
|
|
85
85
|
success: false;
|
|
86
|
-
payload: { error: string; code?: string | number
|
|
86
|
+
payload: { error: string; code?: string | number };
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export interface Success<T> {
|