@onekeyfe/hd-core 1.2.0-alpha.1 → 1.2.0-alpha.10

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.
Files changed (153) hide show
  1. package/__tests__/connectSettings.test.ts +19 -0
  2. package/__tests__/device-wallet-session-store.test.ts +131 -0
  3. package/__tests__/preInitialize.test.ts +33 -0
  4. package/__tests__/protocol-v2-firmware-targets.test.ts +19 -0
  5. package/__tests__/protocol-v2.test.ts +1784 -502
  6. package/dist/api/ClearSessionCache.d.ts +9 -0
  7. package/dist/api/ClearSessionCache.d.ts.map +1 -0
  8. package/dist/api/FileRead.d.ts.map +1 -1
  9. package/dist/api/FileWrite.d.ts.map +1 -1
  10. package/dist/api/FirmwareUpdateV4.d.ts +24 -3
  11. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  12. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  13. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +1 -0
  14. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  15. package/dist/api/firmware/getBinary.d.ts +4 -0
  16. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  17. package/dist/api/firmware/progressThrottle.d.ts +3 -0
  18. package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
  19. package/dist/api/index.d.ts +8 -10
  20. package/dist/api/index.d.ts.map +1 -1
  21. package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +6 -0
  22. package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
  23. package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +7 -0
  24. package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -0
  25. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -1
  26. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
  27. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +3 -2
  28. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
  29. package/dist/api/protocol-v2/{DeviceGetDeviceInfo.d.ts → DeviceInfoGet.d.ts} +10 -10
  30. package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -0
  31. package/dist/api/protocol-v2/DeviceSessionGet.d.ts +9 -0
  32. package/dist/api/protocol-v2/DeviceSessionGet.d.ts.map +1 -0
  33. package/dist/api/protocol-v2/DeviceStatusGet.d.ts +6 -0
  34. package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -0
  35. package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
  36. package/dist/api/protocol-v2/{FilesystemFixPermission.d.ts → FilesystemPermissionFix.d.ts} +2 -2
  37. package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
  38. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +6 -0
  39. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
  40. package/dist/api/protocol-v2/helpers.d.ts +27 -18
  41. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  42. package/dist/api/ton/TonSignData.d.ts +1 -5
  43. package/dist/api/ton/TonSignData.d.ts.map +1 -1
  44. package/dist/api/tron/TronSignMessage.d.ts +0 -1
  45. package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
  46. package/dist/api/tron/TronSignTransaction.d.ts +0 -1
  47. package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
  48. package/dist/core/index.d.ts.map +1 -1
  49. package/dist/data-manager/DataManager.d.ts +1 -1
  50. package/dist/data-manager/DataManager.d.ts.map +1 -1
  51. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  52. package/dist/device/Device.d.ts +6 -3
  53. package/dist/device/Device.d.ts.map +1 -1
  54. package/dist/device/DeviceWalletSessionStore.d.ts +15 -0
  55. package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -0
  56. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
  57. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
  58. package/dist/index.d.ts +96 -55
  59. package/dist/index.js +2077 -1609
  60. package/dist/inject.d.ts.map +1 -1
  61. package/dist/protocols/protocol-v2/features.d.ts +12 -14
  62. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  63. package/dist/protocols/protocol-v2/firmware.d.ts +11 -9
  64. package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
  65. package/dist/protocols/protocol-v2/index.d.ts +1 -0
  66. package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
  67. package/dist/protocols/protocol-v2/walletSession.d.ts +13 -0
  68. package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -0
  69. package/dist/types/api/firmwareUpdate.d.ts +4 -6
  70. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  71. package/dist/types/api/getDeviceInfo.d.ts +2 -0
  72. package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
  73. package/dist/types/api/index.d.ts +11 -11
  74. package/dist/types/api/index.d.ts.map +1 -1
  75. package/dist/types/api/protocolV2.d.ts +16 -17
  76. package/dist/types/api/protocolV2.d.ts.map +1 -1
  77. package/dist/types/api/sessionCache.d.ts +10 -0
  78. package/dist/types/api/sessionCache.d.ts.map +1 -0
  79. package/dist/types/device.d.ts +1 -0
  80. package/dist/types/device.d.ts.map +1 -1
  81. package/dist/types/params.d.ts +1 -0
  82. package/dist/types/params.d.ts.map +1 -1
  83. package/dist/types/settings.d.ts +21 -2
  84. package/dist/types/settings.d.ts.map +1 -1
  85. package/dist/utils/deviceFeaturesUtils.d.ts +2 -0
  86. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  87. package/dist/utils/patch.d.ts +1 -1
  88. package/dist/utils/patch.d.ts.map +1 -1
  89. package/package.json +4 -4
  90. package/src/api/ClearSessionCache.ts +28 -0
  91. package/src/api/FileRead.ts +16 -3
  92. package/src/api/FileWrite.ts +14 -1
  93. package/src/api/FirmwareUpdateV4.ts +1075 -264
  94. package/src/api/GetOnekeyFeatures.ts +1 -1
  95. package/src/api/GetPassphraseState.ts +4 -1
  96. package/src/api/device/DeviceRebootToBoardloader.ts +4 -4
  97. package/src/api/device/DeviceRebootToBootloader.ts +4 -4
  98. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +18 -4
  99. package/src/api/firmware/progressThrottle.ts +44 -0
  100. package/src/api/index.ts +8 -10
  101. package/src/api/protocol-v2/{FactoryGetDeviceInfo.ts → DeviceFactoryInfoGet.ts} +3 -3
  102. package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +32 -0
  103. package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +3 -5
  104. package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +39 -5
  105. package/src/api/protocol-v2/{DeviceGetDeviceInfo.ts → DeviceInfoGet.ts} +52 -22
  106. package/src/api/protocol-v2/DeviceReboot.ts +1 -1
  107. package/src/api/protocol-v2/DeviceSessionGet.ts +26 -0
  108. package/src/api/protocol-v2/DeviceStatusGet.ts +14 -0
  109. package/src/api/protocol-v2/FilesystemFormat.ts +4 -1
  110. package/src/api/protocol-v2/{FilesystemFixPermission.ts → FilesystemPermissionFix.ts} +2 -2
  111. package/src/api/protocol-v2/{GetProtoVersion.ts → ProtocolInfoRequest.ts} +2 -2
  112. package/src/api/protocol-v2/helpers.ts +71 -47
  113. package/src/api/ton/TonSignData.ts +1 -5
  114. package/src/api/tron/TronSignMessage.ts +0 -1
  115. package/src/api/tron/TronSignTransaction.ts +0 -1
  116. package/src/core/index.ts +19 -5
  117. package/src/data/messages/messages-protocol-v2.json +599 -1033
  118. package/src/data/messages/messages.json +8 -0
  119. package/src/data-manager/DataManager.ts +7 -0
  120. package/src/data-manager/connectSettings.ts +2 -4
  121. package/src/device/Device.ts +89 -70
  122. package/src/device/DeviceWalletSessionStore.ts +78 -0
  123. package/src/deviceProfile/buildDeviceFeatures.ts +60 -63
  124. package/src/deviceProfile/buildDeviceProfile.ts +77 -58
  125. package/src/inject.ts +13 -16
  126. package/src/protocols/protocol-v2/features.ts +26 -63
  127. package/src/protocols/protocol-v2/firmware.ts +12 -36
  128. package/src/protocols/protocol-v2/index.ts +1 -0
  129. package/src/protocols/protocol-v2/walletSession.ts +83 -0
  130. package/src/types/api/firmwareUpdate.ts +16 -20
  131. package/src/types/api/getDeviceInfo.ts +2 -0
  132. package/src/types/api/index.ts +17 -20
  133. package/src/types/api/protocolV2.ts +36 -40
  134. package/src/types/api/sessionCache.ts +14 -0
  135. package/src/types/device.ts +1 -0
  136. package/src/types/params.ts +4 -0
  137. package/src/types/settings.ts +42 -35
  138. package/src/utils/deviceFeaturesUtils.ts +44 -13
  139. package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
  140. package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
  141. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
  142. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +0 -6
  143. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +0 -1
  144. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
  145. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
  146. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
  147. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
  148. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
  149. package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
  150. package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
  151. package/src/api/protocol-v2/DevReboot.ts +0 -24
  152. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +0 -16
  153. package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -29
@@ -1,18 +1,16 @@
1
- import { DevRebootType } from '@onekeyfe/hd-transport';
1
+ import { DeviceRebootType } from '@onekeyfe/hd-transport';
2
2
 
3
3
  import { invalidParameter, validateNonEmptyString } from '../helpers/filesystemValidation';
4
+ import { ProtocolV2FirmwareTargetType } from '../../protocols/protocol-v2/firmware';
4
5
 
5
6
  import type {
6
- DevFirmwareTarget,
7
- DevFirmwareTargetType,
7
+ DeviceFirmwareTarget,
8
+ DeviceFirmwareTargetType,
9
+ DeviceFirmwareUpdateRecordFields,
8
10
  TransportCallOptions,
9
11
  } from '@onekeyfe/hd-transport';
10
12
 
11
- export type RebootTypeInput =
12
- | DevRebootType
13
- | keyof typeof DevRebootType
14
- | string
15
- | number;
13
+ export type RebootTypeInput = DeviceRebootType | keyof typeof DeviceRebootType | string | number;
16
14
 
17
15
  export type DeviceRebootParams = {
18
16
  rebootType?: RebootTypeInput;
@@ -20,48 +18,58 @@ export type DeviceRebootParams = {
20
18
  };
21
19
 
22
20
  export type DeviceFirmwareTargetInput =
23
- | DevFirmwareTarget
21
+ | DeviceFirmwareTarget
24
22
  | {
25
- targetId?: DevFirmwareTargetType | string | number;
26
- target_id?: DevFirmwareTargetType | string | number;
23
+ targetId?: DeviceFirmwareTargetType | string | number;
24
+ target_id?: DeviceFirmwareTargetType | string | number;
27
25
  path: string;
28
26
  };
29
27
 
30
28
  export type DeviceFirmwareUpdateParams = {
31
29
  targets?: DeviceFirmwareTargetInput[];
32
- targetId?: DevFirmwareTargetType | string | number;
33
- target_id?: DevFirmwareTargetType | string | number;
30
+ targetId?: DeviceFirmwareTargetType | string | number;
31
+ target_id?: DeviceFirmwareTargetType | string | number;
34
32
  path?: string;
35
33
  };
36
34
 
37
- export type FactoryDeviceInfoSettingsParams = {
38
- serial_no?: string;
39
- serialNo?: string;
40
- cpu_info?: string;
41
- cpuInfo?: string;
42
- pre_firmware?: string;
43
- preFirmware?: string;
35
+ export type DeviceFirmwareUpdateStatusGetParams = {
36
+ fields?: DeviceFirmwareUpdateRecordFields;
44
37
  };
45
38
 
46
- const DEV_REBOOT_TYPES: Record<string, DevRebootType> = {
47
- Normal: DevRebootType.Normal,
48
- normal: DevRebootType.Normal,
49
- Romloader: DevRebootType.Boardloader,
50
- romloader: DevRebootType.Boardloader,
51
- Boardloader: DevRebootType.Boardloader,
52
- boardloader: DevRebootType.Boardloader,
53
- Bootloader: DevRebootType.Bootloader,
54
- bootloader: DevRebootType.Bootloader,
39
+ export type DeviceFactoryInfoSetParams = {
40
+ version?: number;
41
+ serial_number?: string;
42
+ burn_in_completed?: boolean;
43
+ factory_test_completed?: boolean;
44
+ manufacture_time?: {
45
+ year: number;
46
+ month: number;
47
+ day: number;
48
+ hour: number;
49
+ minute: number;
50
+ second: number;
51
+ };
52
+ };
53
+
54
+ const DEVICE_REBOOT_TYPES: Record<string, DeviceRebootType> = {
55
+ Normal: DeviceRebootType.Normal,
56
+ normal: DeviceRebootType.Normal,
57
+ Romloader: DeviceRebootType.Romloader,
58
+ romloader: DeviceRebootType.Romloader,
59
+ Boardloader: DeviceRebootType.Romloader,
60
+ boardloader: DeviceRebootType.Romloader,
61
+ Bootloader: DeviceRebootType.Bootloader,
62
+ bootloader: DeviceRebootType.Bootloader,
55
63
  };
56
64
 
57
65
  export const PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS: TransportCallOptions = {
58
- intermediateTypes: ['DevFirmwareInstallProgress'],
66
+ intermediateTypes: ['DeviceFirmwareUpdateStatus'],
59
67
  };
60
68
 
61
69
  export const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES: (
62
70
  | 'Success'
63
- | 'DevFirmwareUpdateStatus'
64
- )[] = ['Success', 'DevFirmwareUpdateStatus'];
71
+ | 'DeviceFirmwareUpdateStatus'
72
+ )[] = ['Success', 'DeviceFirmwareUpdateStatus'];
65
73
 
66
74
  export const getProtocolV2UnknownErrorText = (error: unknown) => {
67
75
  if (!error) {
@@ -120,40 +128,56 @@ export const isProtocolV2DeviceDisconnectedError = (error: unknown) => {
120
128
  );
121
129
  };
122
130
 
123
- export function normalizeRebootType(value: RebootTypeInput | undefined): DevRebootType {
131
+ export function normalizeRebootType(value: RebootTypeInput | undefined): DeviceRebootType {
124
132
  if (typeof value === 'number') return value;
125
133
  if (typeof value === 'string') {
126
134
  const numeric = Number(value);
127
135
  if (Number.isFinite(numeric)) return numeric;
128
- if (value in DEV_REBOOT_TYPES) return DEV_REBOOT_TYPES[value];
136
+ if (value in DEVICE_REBOOT_TYPES) return DEVICE_REBOOT_TYPES[value];
129
137
  }
130
- return DevRebootType.Normal;
138
+ return DeviceRebootType.Normal;
131
139
  }
132
140
 
133
- // 当前 firmware-pro2 子模块的 DevFirmwareTargetType 合法值。
134
- const VALID_FIRMWARE_TARGET_IDS = new Set<number>([0, 1, 2, 3, 4, 5, 6, 10]);
141
+ // firmware-pro2 proto_target_to_firmware_target 安装白名单保持一致。
142
+ const INSTALLABLE_FIRMWARE_TARGET_IDS = new Set<number>([
143
+ ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_CRATE,
144
+ ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER,
145
+ ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1,
146
+ ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2,
147
+ ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_COPROCESSOR,
148
+ ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE01,
149
+ ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE02,
150
+ ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE03,
151
+ ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE04,
152
+ ]);
153
+ const FIRMWARE_TARGET_ID_BY_NAME = new Map<string, DeviceFirmwareTargetType>(
154
+ Object.entries(ProtocolV2FirmwareTargetType).flatMap(([key, value]) =>
155
+ INSTALLABLE_FIRMWARE_TARGET_IDS.has(value) ? [[key, value as DeviceFirmwareTargetType]] : []
156
+ )
157
+ );
135
158
 
136
159
  function normalizeTargetId(
137
- value: DevFirmwareTargetType | string | number | undefined,
160
+ value: DeviceFirmwareTargetType | string | number | undefined,
138
161
  name: string
139
- ): DevFirmwareTargetType {
162
+ ): DeviceFirmwareTargetType {
140
163
  if (value === undefined || value === null) {
141
164
  throw invalidParameter(`Missing required parameter: ${name}`);
142
165
  }
143
- const numeric = typeof value === 'number' ? value : Number(value);
144
- // 校验值域:仅接受 DevFirmwareTargetType 中定义的 target id,
145
- // 不再放行任意非负整数。
146
- if (Number.isSafeInteger(numeric) && VALID_FIRMWARE_TARGET_IDS.has(numeric)) {
147
- return numeric as DevFirmwareTargetType;
166
+ const named = typeof value === 'string' ? FIRMWARE_TARGET_ID_BY_NAME.get(value) : undefined;
167
+ const numeric = named ?? (typeof value === 'number' ? value : Number(value));
168
+ if (Number.isSafeInteger(numeric) && INSTALLABLE_FIRMWARE_TARGET_IDS.has(numeric)) {
169
+ return numeric as DeviceFirmwareTargetType;
148
170
  }
149
171
  throw invalidParameter(
150
- `Parameter [${name}] must be a valid firmware target id (one of ${[
151
- ...VALID_FIRMWARE_TARGET_IDS,
172
+ `Parameter [${name}] must be an installable firmware target id (one of ${[
173
+ ...INSTALLABLE_FIRMWARE_TARGET_IDS,
152
174
  ].join(', ')}).`
153
175
  );
154
176
  }
155
177
 
156
- export function normalizeFirmwareTargets(params: DeviceFirmwareUpdateParams): DevFirmwareTarget[] {
178
+ export function normalizeFirmwareTargets(
179
+ params: DeviceFirmwareUpdateParams
180
+ ): DeviceFirmwareTarget[] {
157
181
  const targets =
158
182
  params.targets ??
159
183
  (params.path
@@ -51,11 +51,7 @@ export default class TonSignData extends BaseMethod<HardwareTonSignData> {
51
51
  }
52
52
 
53
53
  getVersionRange() {
54
- return {
55
- pro2: {
56
- min: '0.0.0',
57
- },
58
- };
54
+ return {};
59
55
  }
60
56
 
61
57
  async run() {
@@ -47,7 +47,6 @@ export default class TronSignMessage extends BaseMethod<HardwareTronSignMessage>
47
47
  return {
48
48
  pro2: {
49
49
  min: '0.0.0',
50
- unsupported: true,
51
50
  },
52
51
  model_mini: {
53
52
  min: '2.5.0',
@@ -150,7 +150,6 @@ export default class TronSignTransaction extends BaseMethod<TronSignTx> {
150
150
  return {
151
151
  pro2: {
152
152
  min: '0.0.0',
153
- unsupported: true,
154
153
  },
155
154
  model_mini: {
156
155
  min: '2.5.0',
package/src/core/index.ts CHANGED
@@ -56,7 +56,6 @@ import TransportManager from '../data-manager/TransportManager';
56
56
  import DeviceConnector from '../device/DeviceConnector';
57
57
  import RequestQueue from './RequestQueue';
58
58
  import { getSynchronize } from '../utils/getSynchronize';
59
- import { setProtocolV2DeviceInfoMock } from '../protocols/protocol-v2/features';
60
59
 
61
60
  import type { ConnectSettings, Features, KnownDevice } from '../types';
62
61
  import type { CoreMessage, IFrameCallMessage, UiPromise, UiPromiseResponse } from '../events';
@@ -96,6 +95,7 @@ const parseInitOptions = (method?: BaseMethod): InitOptions => ({
96
95
  deviceId: method?.payload.deviceId,
97
96
  deriveCardano: method && hasDeriveCardano(method),
98
97
  connectProtocol: method?.payload.connectProtocol,
98
+ protocolV2DeviceInfoTimeoutMs: method?.payload.protocolV2DeviceInfoTimeoutMs,
99
99
  });
100
100
 
101
101
  let _core: Core;
@@ -223,9 +223,15 @@ const handlePreWarmSignal = async (
223
223
  message: CoreMessage,
224
224
  method: BaseMethod
225
225
  ): Promise<any> => {
226
+ const createAckResponse = () => {
227
+ completeMethodRequestContext(method);
228
+ method.dispose();
229
+ return createResponseMessage(method.responseID, true, true);
230
+ };
231
+
226
232
  // no connectId: can't target a device safely, skip pre-warm (ack only)
227
233
  if (!method.connectId) {
228
- return createResponseMessage(method.responseID, true, true);
234
+ return createAckResponse();
229
235
  }
230
236
 
231
237
  const key = method.getPreWarmKey();
@@ -238,12 +244,12 @@ const handlePreWarmSignal = async (
238
244
  } catch {
239
245
  // pre-warm is best-effort; ignore its failure for the coalesced caller
240
246
  }
241
- return createResponseMessage(method.responseID, true, true);
247
+ return createAckResponse();
242
248
  }
243
249
 
244
250
  const doneAt = preWarmDoneAt.get(key);
245
251
  if (typeof doneAt === 'number' && Date.now() - doneAt <= method.preWarmTtl) {
246
- return createResponseMessage(method.responseID, true, true);
252
+ return createAckResponse();
247
253
  }
248
254
 
249
255
  const run = onCallDevice(context, message, method);
@@ -732,6 +738,15 @@ function initDevice(method: BaseMethod) {
732
738
 
733
739
  if (method.connectId) {
734
740
  device = _deviceList.getDevice(method.connectId);
741
+ if (!device && method.name === 'firmwareUpdateV4' && allDevices.length === 1) {
742
+ const [singleDevice] = allDevices;
743
+ if (singleDevice.isBootloader()) {
744
+ Log.debug(
745
+ 'firmwareUpdateV4 uses the only bootloader device when connectId changed after reboot'
746
+ );
747
+ device = singleDevice;
748
+ }
749
+ }
735
750
  } else if (allDevices.length === 1) {
736
751
  [device] = allDevices;
737
752
  } else if (allDevices.length > 1) {
@@ -1439,7 +1454,6 @@ export const init = async (
1439
1454
  try {
1440
1455
  try {
1441
1456
  await DataManager.load(settings);
1442
- setProtocolV2DeviceInfoMock(settings.protocolV2DeviceInfoMockEnabled ?? false);
1443
1457
  initTransport(Transport, plugin);
1444
1458
  } catch {
1445
1459
  Log.error('DataManager.load error');