@onekeyfe/hd-core 1.2.0-alpha.68 → 1.2.0-alpha.69

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 (121) hide show
  1. package/__tests__/check-all-firmware-release-protocol-v2.test.ts +28 -0
  2. package/__tests__/connectSettings.test.ts +5 -47
  3. package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +31 -59
  4. package/__tests__/protocol-v2-firmware-targets.test.ts +33 -1
  5. package/__tests__/protocol-v2-resources.test.ts +9 -6
  6. package/__tests__/protocol-v2.test.ts +174 -383
  7. package/__tests__/protocolV2FileWrite.test.ts +48 -7
  8. package/dist/api/CheckAllFirmwareRelease.d.ts +2 -1
  9. package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
  10. package/dist/api/FirmwareUpdate.d.ts.map +1 -1
  11. package/dist/api/FirmwareUpdateV2.d.ts +0 -10
  12. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  13. package/dist/api/FirmwareUpdateV3.d.ts +3 -7
  14. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  15. package/dist/api/FirmwareUpdateV4.d.ts +6 -25
  16. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  17. package/dist/api/device/DeviceUpdateBootloader.d.ts +1 -5
  18. package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
  19. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +0 -8
  20. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  21. package/dist/api/firmware/getBinary.d.ts +0 -7
  22. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  23. package/dist/api/firmware/updateBootloader.d.ts +0 -2
  24. package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
  25. package/dist/api/firmware/uploadFirmware.d.ts +1 -9
  26. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  27. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
  28. package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
  29. package/dist/data-manager/DataManager.d.ts +0 -1
  30. package/dist/data-manager/DataManager.d.ts.map +1 -1
  31. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  32. package/dist/device/Device.d.ts +0 -1
  33. package/dist/device/Device.d.ts.map +1 -1
  34. package/dist/index.d.ts +2 -180
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +1041 -3037
  37. package/dist/inject.d.ts.map +1 -1
  38. package/dist/lowLevelInject.d.ts.map +1 -1
  39. package/dist/protocols/protocol-v2/resources.d.ts +1 -1
  40. package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
  41. package/dist/topLevelInject.d.ts.map +1 -1
  42. package/dist/types/api/checkAllFirmwareRelease.d.ts +0 -4
  43. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  44. package/dist/types/api/deviceUpdateBootloader.d.ts +0 -6
  45. package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
  46. package/dist/types/api/export.d.ts +1 -4
  47. package/dist/types/api/export.d.ts.map +1 -1
  48. package/dist/types/api/firmwareUpdate.d.ts +0 -68
  49. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  50. package/dist/types/api/index.d.ts +1 -9
  51. package/dist/types/api/index.d.ts.map +1 -1
  52. package/dist/types/settings.d.ts +1 -14
  53. package/dist/types/settings.d.ts.map +1 -1
  54. package/dist/utils/deviceFeaturesCompat.d.ts +0 -1
  55. package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
  56. package/package.json +4 -4
  57. package/src/api/CheckAllFirmwareRelease.ts +25 -61
  58. package/src/api/FirmwareUpdate.ts +1 -13
  59. package/src/api/FirmwareUpdateV2.ts +121 -296
  60. package/src/api/FirmwareUpdateV3.ts +57 -263
  61. package/src/api/FirmwareUpdateV4.ts +287 -865
  62. package/src/api/device/DeviceUpdateBootloader.ts +6 -125
  63. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +1 -72
  64. package/src/api/firmware/updateBootloader.ts +4 -19
  65. package/src/api/firmware/uploadFirmware.ts +22 -140
  66. package/src/api/helpers/protocolV2FileWrite.ts +54 -4
  67. package/src/data-manager/DataManager.ts +54 -59
  68. package/src/data-manager/connectSettings.ts +0 -11
  69. package/src/device/Device.ts +1 -6
  70. package/src/index.ts +0 -5
  71. package/src/inject.ts +2 -22
  72. package/src/lowLevelInject.ts +1 -5
  73. package/src/protocols/protocol-v2/resources.ts +5 -1
  74. package/src/topLevelInject.ts +1 -5
  75. package/src/types/api/checkAllFirmwareRelease.ts +0 -4
  76. package/src/types/api/deviceUpdateBootloader.ts +0 -6
  77. package/src/types/api/export.ts +0 -18
  78. package/src/types/api/firmwareUpdate.ts +0 -75
  79. package/src/types/api/index.ts +0 -14
  80. package/src/types/settings.ts +2 -14
  81. package/src/utils/deviceFeaturesCompat.ts +0 -6
  82. package/__tests__/device-initialize-timeout.test.ts +0 -56
  83. package/__tests__/firmware-update/check-all-firmware-release.test.ts +0 -175
  84. package/__tests__/firmware-update/device-update-bootloader.test.ts +0 -87
  85. package/__tests__/firmware-update/firmware-artifact-source.test.ts +0 -119
  86. package/__tests__/firmware-update/firmware-host-binding.test.ts +0 -70
  87. package/__tests__/firmware-update/firmware-preparation-error.test.ts +0 -27
  88. package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +0 -200
  89. package/__tests__/firmware-update/firmware-update-capabilities.test.ts +0 -13
  90. package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +0 -394
  91. package/__tests__/firmware-update/firmware-update-plan.test.ts +0 -593
  92. package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +0 -231
  93. package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +0 -63
  94. package/__tests__/firmware-update/firmware-upload-source.test.ts +0 -70
  95. package/dist/api/firmware/FirmwareArtifactSource.d.ts +0 -25
  96. package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +0 -1
  97. package/dist/api/firmware/FirmwareHostBinding.d.ts +0 -6
  98. package/dist/api/firmware/FirmwareHostBinding.d.ts.map +0 -1
  99. package/dist/api/firmware/FirmwarePreparationError.d.ts +0 -3
  100. package/dist/api/firmware/FirmwarePreparationError.d.ts.map +0 -1
  101. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +0 -3
  102. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +0 -1
  103. package/dist/api/firmware/FirmwareUpdatePlan.d.ts +0 -25
  104. package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +0 -1
  105. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +0 -32
  106. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +0 -1
  107. package/dist/types/api/firmwareUpdateCapabilities.d.ts +0 -9
  108. package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +0 -1
  109. package/dist/types/api/firmwareUpdatePlan.d.ts +0 -28
  110. package/dist/types/api/firmwareUpdatePlan.d.ts.map +0 -1
  111. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +0 -42
  112. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +0 -1
  113. package/src/api/firmware/FirmwareArtifactSource.ts +0 -278
  114. package/src/api/firmware/FirmwareHostBinding.ts +0 -100
  115. package/src/api/firmware/FirmwarePreparationError.ts +0 -12
  116. package/src/api/firmware/FirmwareUpdateCapabilities.ts +0 -9
  117. package/src/api/firmware/FirmwareUpdatePlan.ts +0 -772
  118. package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +0 -449
  119. package/src/types/api/firmwareUpdateCapabilities.ts +0 -9
  120. package/src/types/api/firmwareUpdatePlan.ts +0 -38
  121. package/src/types/api/firmwareUpdatePreparedPlan.ts +0 -53
@@ -9,7 +9,7 @@ import { LoggerNames, getLogger } from '../../utils/logger';
9
9
 
10
10
  import type { DeviceCommands } from '../../device/DeviceCommands';
11
11
 
12
- const Log = getLogger(LoggerNames.Method);
12
+ const Log = getLogger(LoggerNames.Core);
13
13
 
14
14
  export type ProtocolV2FileWriteData = ArrayBuffer | Uint8Array | Blob | string;
15
15
 
@@ -69,22 +69,36 @@ function getFileTransferTransport() {
69
69
  function logFileTransferMetrics({
70
70
  transport,
71
71
  status,
72
+ path,
72
73
  transferredBytes,
73
74
  totalBytes,
74
75
  elapsedMs,
75
76
  rateBytesPerSecond,
77
+ hostWriteElapsedMs,
78
+ responseWaitElapsedMs,
79
+ measuredAttempts,
76
80
  }: {
77
81
  transport: string;
78
82
  status: 'progress' | 'completed' | 'failed';
83
+ path: string;
79
84
  transferredBytes: number;
80
85
  totalBytes: number;
81
86
  elapsedMs: number;
82
87
  rateBytesPerSecond: number;
88
+ hostWriteElapsedMs: number;
89
+ responseWaitElapsedMs: number;
90
+ measuredAttempts: number;
83
91
  }) {
92
+ const segmentedMetrics =
93
+ measuredAttempts > 0
94
+ ? ` hostWriteTotal=${(hostWriteElapsedMs / 1000).toFixed(2)}s responseWaitTotal=${(
95
+ responseWaitElapsedMs / 1000
96
+ ).toFixed(2)}s measuredAttempts=${measuredAttempts}`
97
+ : '';
84
98
  Log.log(
85
- `[FileWrite] metrics transport=${transport} status=${status} bytes=${transferredBytes}/${totalBytes} elapsed=${(
99
+ `[FileWrite] metrics transport=${transport} status=${status} path=${path} bytes=${transferredBytes}/${totalBytes} elapsed=${(
86
100
  elapsedMs / 1000
87
- ).toFixed(2)}s speed=${formatFileTransferRate(rateBytesPerSecond)} KiB/s`
101
+ ).toFixed(2)}s speed=${formatFileTransferRate(rateBytesPerSecond)} KiB/s${segmentedMetrics}`
88
102
  );
89
103
  }
90
104
 
@@ -177,7 +191,13 @@ export async function writeProtocolV2File(options: ProtocolV2FileWriteOptions) {
177
191
  let lastConfirmedAt = startTime;
178
192
  let logWindowStartedAt = startTime;
179
193
  let logWindowStartedBytes = 0;
194
+ let hostWriteElapsedMs = 0;
195
+ let responseWaitElapsedMs = 0;
196
+ let measuredAttempts = 0;
180
197
  const transport = getFileTransferTransport();
198
+ Log.log(
199
+ `[FileWrite] started transport=${transport} path=${options.path} bytes=${dataLength} offset=${startOffset} chunk=${chunkSize}`
200
+ );
181
201
 
182
202
  try {
183
203
  while (written < dataLength) {
@@ -203,13 +223,25 @@ export async function writeProtocolV2File(options: ProtocolV2FileWriteOptions) {
203
223
  let response;
204
224
  let isWritePending = true;
205
225
  while (isWritePending) {
226
+ let currentHostWriteElapsedMs: number | undefined;
227
+ let responseWaitStartedAt: number | undefined;
206
228
  try {
207
229
  const callOptions =
208
230
  options.writeWithResponse === undefined
209
- ? { timeoutMs: options.timeoutMs }
231
+ ? {
232
+ timeoutMs: options.timeoutMs,
233
+ onWriteCompleted: ({ elapsedMs }: { elapsedMs: number }) => {
234
+ currentHostWriteElapsedMs = elapsedMs;
235
+ responseWaitStartedAt = Date.now();
236
+ },
237
+ }
210
238
  : {
211
239
  ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
212
240
  writeWithResponse: options.writeWithResponse,
241
+ onWriteCompleted: ({ elapsedMs }: { elapsedMs: number }) => {
242
+ currentHostWriteElapsedMs = elapsedMs;
243
+ responseWaitStartedAt = Date.now();
244
+ },
213
245
  };
214
246
  response = await options.commands.typedCall(
215
247
  'FilesystemFileWrite',
@@ -222,6 +254,12 @@ export async function writeProtocolV2File(options: ProtocolV2FileWriteOptions) {
222
254
  if (retryCount >= maxChunkRetries || !isProtocolV2ResponseTimeout(error)) throw error;
223
255
  retryCount += 1;
224
256
  options.throwIfAborted?.();
257
+ } finally {
258
+ if (currentHostWriteElapsedMs !== undefined && responseWaitStartedAt !== undefined) {
259
+ hostWriteElapsedMs += currentHostWriteElapsedMs;
260
+ responseWaitElapsedMs += Math.max(Date.now() - responseWaitStartedAt, 0);
261
+ measuredAttempts += 1;
262
+ }
225
263
  }
226
264
  }
227
265
  if (!response) {
@@ -285,10 +323,14 @@ export async function writeProtocolV2File(options: ProtocolV2FileWriteOptions) {
285
323
  logFileTransferMetrics({
286
324
  transport,
287
325
  status: 'progress',
326
+ path: options.path,
288
327
  transferredBytes,
289
328
  totalBytes: dataLength,
290
329
  elapsedMs,
291
330
  rateBytesPerSecond: getAverageFileTransferRate(logWindowBytes, logWindowElapsedMs),
331
+ hostWriteElapsedMs,
332
+ responseWaitElapsedMs,
333
+ measuredAttempts,
292
334
  });
293
335
  logWindowStartedAt = now;
294
336
  logWindowStartedBytes = transferredBytes;
@@ -307,10 +349,14 @@ export async function writeProtocolV2File(options: ProtocolV2FileWriteOptions) {
307
349
  logFileTransferMetrics({
308
350
  transport,
309
351
  status: 'failed',
352
+ path: options.path,
310
353
  transferredBytes: written,
311
354
  totalBytes: dataLength,
312
355
  elapsedMs,
313
356
  rateBytesPerSecond: getAverageFileTransferRate(logWindowBytes, logWindowElapsedMs),
357
+ hostWriteElapsedMs,
358
+ responseWaitElapsedMs,
359
+ measuredAttempts,
314
360
  });
315
361
  throw error;
316
362
  }
@@ -321,10 +367,14 @@ export async function writeProtocolV2File(options: ProtocolV2FileWriteOptions) {
321
367
  logFileTransferMetrics({
322
368
  transport,
323
369
  status: 'completed',
370
+ path: options.path,
324
371
  transferredBytes: written,
325
372
  totalBytes: dataLength,
326
373
  elapsedMs,
327
374
  rateBytesPerSecond: getAverageFileTransferRate(logWindowBytes, logWindowElapsedMs),
375
+ hostWriteElapsedMs,
376
+ responseWaitElapsedMs,
377
+ measuredAttempts,
328
378
  });
329
379
 
330
380
  return {
@@ -408,17 +408,7 @@ export default class DataManager {
408
408
  static async load(settings: ConnectSettings): Promise<boolean> {
409
409
  this.settings = settings;
410
410
  this.protocolV2ResourcesConfigError = undefined;
411
- const manifestMode =
412
- settings.firmwareManifestMode ?? (settings.fetchConfig ? 'sdk-managed' : undefined);
413
- if (settings.preloadedConfig) {
414
- this.applyRemoteConfig(settings.preloadedConfig);
415
- Log.log('[DataConfig] Preloaded firmware config loaded');
416
- return true;
417
- }
418
- if (manifestMode === 'external-only') {
419
- throw new Error('External firmware config snapshot is required');
420
- }
421
- if (manifestMode !== 'sdk-managed') {
411
+ if (!settings.fetchConfig) {
422
412
  return false;
423
413
  }
424
414
 
@@ -429,19 +419,26 @@ export default class DataManager {
429
419
  const urlWithCache = `${url}?noCache=${getTimeStamp()}`;
430
420
  let data: RemoteConfigResponse | null = null;
431
421
  let fetchMethod: 'configFetcher' | 'axios' | 'none' = 'none';
422
+
423
+ // 1. Try custom configFetcher first (client-side IP direct connection support)
432
424
  if (settings.configFetcher) {
433
- Log.debug('[DataConfig] Trying client configFetcher...');
425
+ Log.debug('[DataConfig] Trying configFetcher (client-side fetcher)...');
434
426
  try {
435
427
  data = await settings.configFetcher(urlWithCache);
436
428
  if (data) {
437
429
  fetchMethod = 'configFetcher';
430
+ Log.log('[DataConfig] ConfigFetcher success');
431
+ } else {
432
+ Log.debug('[DataConfig] ConfigFetcher returned null, will fallback to axios');
438
433
  }
439
434
  } catch (e) {
440
- Log.warn('[DataConfig] Client configFetcher failed:', e);
435
+ Log.warn('[DataConfig] ConfigFetcher error, will fallback to axios:', e);
441
436
  }
442
437
  }
438
+
439
+ // 2. Fallback to default axios request
443
440
  if (!data) {
444
- Log.debug('[DataConfig] Trying SDK-managed config request...');
441
+ Log.debug('[DataConfig] Trying axios (SDK default fetcher)...');
445
442
  try {
446
443
  const response = await axios.get<RemoteConfigResponse>(urlWithCache, {
447
444
  // because of iframe timeout is 10000
@@ -449,63 +446,61 @@ export default class DataManager {
449
446
  });
450
447
  data = response.data;
451
448
  fetchMethod = 'axios';
452
- Log.log('[DataConfig] SDK-managed config request succeeded');
449
+ Log.log('[DataConfig] Axios fetch success');
453
450
  } catch (e) {
454
- Log.warn('[DataConfig] SDK-managed config request failed:', e);
451
+ Log.warn('[DataConfig] Axios fetch error:', e);
455
452
  }
456
453
  }
457
454
 
455
+ // 3. Apply config if available
458
456
  if (data) {
459
- this.applyRemoteConfig(data);
457
+ let pro2Resources: IProtocolV2Resources | undefined;
458
+ let neoResources: IProtocolV2Resources | undefined;
459
+ this.protocolV2ResourcesConfigError = undefined;
460
+ try {
461
+ pro2Resources = parseProtocolV2Resources(
462
+ (data.pro2 as { resources?: unknown } | undefined)?.resources
463
+ );
464
+ neoResources = parseProtocolV2Resources(
465
+ (data.neo as { resources?: unknown } | undefined)?.resources
466
+ );
467
+ } catch (error) {
468
+ // Firmware resource metadata is not required for base communication. If the
469
+ // remote config is temporarily incomplete, disable this resource update only.
470
+ this.protocolV2ResourcesConfigError =
471
+ error instanceof Error ? error : new Error(String(error));
472
+ Log.warn('[DataConfig] Ignoring invalid Pro2 resources config:', error);
473
+ }
474
+ const enrichedPro2Config = this.enrichFirmwareReleaseInfo(data.pro2);
475
+ const enrichedNeoConfig = this.enrichFirmwareReleaseInfo(data.neo);
476
+ const { resources: _unvalidatedResources, ...pro2Config } = enrichedPro2Config;
477
+ const { resources: _unvalidatedNeoResources, ...neoConfig } = enrichedNeoConfig;
460
478
  Log.log(`[DataConfig] Config loaded successfully via [${fetchMethod}]`);
479
+ this.deviceMap = {
480
+ [EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
481
+ [EDeviceType.Classic1s]: this.enrichFirmwareReleaseInfo(data.classic1s),
482
+ [EDeviceType.ClassicPure]: this.enrichFirmwareReleaseInfo(data.classicpure),
483
+ [EDeviceType.Mini]: this.enrichFirmwareReleaseInfo(data.mini),
484
+ [EDeviceType.Touch]: this.enrichFirmwareReleaseInfo(data.touch),
485
+ [EDeviceType.Pro]: this.enrichFirmwareReleaseInfo(data.pro),
486
+ [EDeviceType.Pro2]: {
487
+ ...pro2Config,
488
+ ...(pro2Resources ? { resources: pro2Resources } : undefined),
489
+ },
490
+ [EDeviceType.Neo]: {
491
+ ...neoConfig,
492
+ ...(neoResources ? { resources: neoResources } : undefined),
493
+ },
494
+ };
495
+ this.assets = {
496
+ bridge: data.bridge,
497
+ };
461
498
  return true;
462
499
  }
463
500
  Log.warn('[DataConfig] All fetch methods failed, using built-in default config');
464
501
  return false;
465
502
  }
466
503
 
467
- private static applyRemoteConfig(data: RemoteConfigResponse) {
468
- let pro2Resources: IProtocolV2Resources | undefined;
469
- let neoResources: IProtocolV2Resources | undefined;
470
- try {
471
- pro2Resources = parseProtocolV2Resources(
472
- (data.pro2 as { resources?: unknown } | undefined)?.resources
473
- );
474
- neoResources = parseProtocolV2Resources(
475
- (data.neo as { resources?: unknown } | undefined)?.resources
476
- );
477
- } catch (error) {
478
- // Firmware resource metadata is not required for base communication. If the
479
- // remote config is temporarily incomplete, disable this resource update only.
480
- this.protocolV2ResourcesConfigError =
481
- error instanceof Error ? error : new Error(String(error));
482
- Log.warn('[DataConfig] Ignoring invalid Protocol V2 resources config:', error);
483
- }
484
- const enrichedPro2Config = this.enrichFirmwareReleaseInfo(data.pro2);
485
- const enrichedNeoConfig = this.enrichFirmwareReleaseInfo(data.neo);
486
- const { resources: _unvalidatedResources, ...pro2Config } = enrichedPro2Config;
487
- const { resources: _unvalidatedNeoResources, ...neoConfig } = enrichedNeoConfig;
488
- this.deviceMap = {
489
- [EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
490
- [EDeviceType.Classic1s]: this.enrichFirmwareReleaseInfo(data.classic1s),
491
- [EDeviceType.ClassicPure]: this.enrichFirmwareReleaseInfo(data.classicpure),
492
- [EDeviceType.Mini]: this.enrichFirmwareReleaseInfo(data.mini),
493
- [EDeviceType.Touch]: this.enrichFirmwareReleaseInfo(data.touch),
494
- [EDeviceType.Pro]: this.enrichFirmwareReleaseInfo(data.pro),
495
- [EDeviceType.Pro2]: {
496
- ...pro2Config,
497
- ...(pro2Resources ? { resources: pro2Resources } : undefined),
498
- },
499
- [EDeviceType.Neo]: {
500
- ...neoConfig,
501
- ...(neoResources ? { resources: neoResources } : undefined),
502
- },
503
- };
504
- this.assets = {
505
- bridge: data.bridge,
506
- };
507
- }
508
-
509
504
  static updateEnv(newEnv: ConnectSettings['env']) {
510
505
  if (this.settings) {
511
506
  const prevEnv = this.settings.env;
@@ -115,21 +115,10 @@ export const parseConnectSettings = (input: Partial<ConnectSettings> = {}) => {
115
115
  settings.fetchConfig = input.fetchConfig;
116
116
  }
117
117
 
118
- if (
119
- input.firmwareManifestMode === 'sdk-managed' ||
120
- input.firmwareManifestMode === 'external-only'
121
- ) {
122
- settings.firmwareManifestMode = input.firmwareManifestMode;
123
- }
124
-
125
118
  if (input.configFetcher) {
126
119
  settings.configFetcher = input.configFetcher;
127
120
  }
128
121
 
129
- if (input.preloadedConfig) {
130
- settings.preloadedConfig = input.preloadedConfig;
131
- }
132
-
133
122
  return settings;
134
123
  };
135
124
 
@@ -99,11 +99,6 @@ export type InitOptions = {
99
99
  protocolV2DeviceInfoTimeoutMs?: number;
100
100
  /** Refresh Protocol V2 runtime state before returning discovery results. */
101
101
  refreshRuntimeState?: boolean;
102
- /**
103
- * Protocol V1 Initialize response timeout override. Reboot-wait polling passes a
104
- * short value so an unanswered probe settles before the next poll tick.
105
- */
106
- timeoutMs?: number;
107
102
  };
108
103
 
109
104
  export type RunOptions = {
@@ -913,7 +908,7 @@ export class Device extends EventEmitter {
913
908
  const initStartAt = Date.now();
914
909
  const { message } = await this.commands.typedCall('Initialize', 'Features', payload, {
915
910
  // iOS BLE bound devices can need close to 20 seconds.
916
- timeoutMs: options?.timeoutMs ?? 25 * 1000,
911
+ timeoutMs: 25 * 1000,
917
912
  });
918
913
  this.setLastInitializeDuration(Date.now() - initStartAt);
919
914
  this._updateFeatures(message, initSession);
package/src/index.ts CHANGED
@@ -19,11 +19,6 @@ export * from './types';
19
19
  export { whitelist, whitelistExtension } from './data/config';
20
20
  export { executeCallback, cleanupCallback };
21
21
  export { preloadSessionCache } from './device/Device';
22
- export {
23
- getFirmwareUpdateHostBindingGeneration,
24
- registerFirmwareUpdateHostBinding,
25
- unregisterFirmwareUpdateHostBinding,
26
- } from './api/firmware/FirmwareHostBinding';
27
22
 
28
23
  const HardwareSdk = ({
29
24
  init,
package/src/inject.ts CHANGED
@@ -1,18 +1,7 @@
1
- import { getFirmwareUpdateCapabilities } from './api/firmware/FirmwareUpdateCapabilities';
2
- import {
3
- prepareFirmwareUpdatePlan,
4
- validateFirmwareUpdatePreparedPlan,
5
- } from './api/firmware/FirmwareUpdatePreparedPlan';
6
- import {
7
- getFirmwareUpdateHostBindingGeneration,
8
- registerFirmwareUpdateHostBinding,
9
- unregisterFirmwareUpdateHostBinding,
10
- } from './api/firmware/FirmwareHostBinding';
11
-
12
1
  import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
2
+ import type { Unsuccessful } from './types';
13
3
  import type { EventEmitter } from 'events';
14
4
  import type { CallMethod } from './events';
15
- import type { Unsuccessful } from './types';
16
5
  import type { CoreApi } from './types/api';
17
6
  import type { AllNetworkAddress } from './types/api/allNetworkGetAddress';
18
7
 
@@ -127,10 +116,7 @@ export const inject = ({
127
116
 
128
117
  setDeviceConnectProtocol: protocolAwareCall.setDeviceConnectProtocol,
129
118
 
130
- dispose: async () => {
131
- unregisterFirmwareUpdateHostBinding();
132
- await dispose();
133
- },
119
+ dispose,
134
120
 
135
121
  uiResponse,
136
122
 
@@ -162,12 +148,6 @@ export const createCoreApi = (
162
148
  | 'updateSettings'
163
149
  | 'switchTransport'
164
150
  > => ({
165
- getFirmwareUpdateCapabilities,
166
- registerFirmwareUpdateHostBinding,
167
- unregisterFirmwareUpdateHostBinding,
168
- getFirmwareUpdateHostBindingGeneration,
169
- prepareFirmwareUpdatePlan,
170
- validateFirmwareUpdatePreparedPlan,
171
151
  getLogs: () => call({ method: 'getLogs' }),
172
152
  clearSessionCache: params => call({ ...params, method: 'clearSessionCache' }),
173
153
  /**
@@ -1,5 +1,4 @@
1
1
  import { createCoreApi, createProtocolAwareCall } from './inject';
2
- import { unregisterFirmwareUpdateHostBinding } from './api/firmware/FirmwareHostBinding';
3
2
 
4
3
  import type { EventEmitter } from 'events';
5
4
  import type { CallMethod, CoreMessage } from './events';
@@ -47,10 +46,7 @@ export const lowLevelInject = ({
47
46
 
48
47
  setDeviceConnectProtocol: protocolAwareCall.setDeviceConnectProtocol,
49
48
 
50
- dispose: async () => {
51
- unregisterFirmwareUpdateHostBinding();
52
- await dispose();
53
- },
49
+ dispose,
54
50
 
55
51
  uiResponse,
56
52
 
@@ -17,6 +17,7 @@ export const PROTOCOL_V2_RESOURCE_TYPES = [
17
17
  'translations',
18
18
  'roobert',
19
19
  'noto',
20
+ 'firmware_logo',
20
21
  ] as const satisfies readonly IProtocolV2ResourceType[];
21
22
 
22
23
  export const PROTOCOL_V2_RESOURCE_DEVICE_PATHS: Readonly<Record<IProtocolV2ResourceType, string>> =
@@ -27,6 +28,7 @@ export const PROTOCOL_V2_RESOURCE_DEVICE_PATHS: Readonly<Record<IProtocolV2Resou
27
28
  translations: 'vol0:/bundles/translations/translations.okpkg',
28
29
  roobert: 'vol0:/bundles/font/roobert.okpkg',
29
30
  noto: 'vol0:/bundles/font/noto.okpkg',
31
+ firmware_logo: 'vol0:/bundles/firmware_logo.okpkg',
30
32
  };
31
33
 
32
34
  const RESOURCE_TYPE_SET = new Set<string>(PROTOCOL_V2_RESOURCE_TYPES);
@@ -313,7 +315,9 @@ export function parseProtocolV2Resources(value: unknown): IProtocolV2Resources |
313
315
  const stable = config.stable.map(validateResource);
314
316
  const types = new Set(stable.map(resource => resource.type));
315
317
  if (stable.length !== PROTOCOL_V2_RESOURCE_TYPES.length || types.size !== stable.length) {
316
- throw new Error('Invalid Pro2 resources config: stable must contain six unique resource types');
318
+ throw new Error(
319
+ `Invalid Pro2 resources config: stable must contain ${PROTOCOL_V2_RESOURCE_TYPES.length} unique resource types`
320
+ );
317
321
  }
318
322
  for (const type of PROTOCOL_V2_RESOURCE_TYPES) {
319
323
  if (!types.has(type)) {
@@ -1,7 +1,6 @@
1
1
  import EventEmitter from 'events';
2
2
 
3
3
  import { createCoreApi, createProtocolAwareCall } from './inject';
4
- import { unregisterFirmwareUpdateHostBinding } from './api/firmware/FirmwareHostBinding';
5
4
 
6
5
  import type { ConnectSettings } from './types/settings';
7
6
  import type { CoreApi } from './types/api';
@@ -50,10 +49,7 @@ export const topLevelInject = () => {
50
49
  lowLevelApi?.removeAllListeners(type);
51
50
  },
52
51
 
53
- dispose: async () => {
54
- unregisterFirmwareUpdateHostBinding();
55
- await lowLevelApi?.dispose();
56
- },
52
+ dispose: () => lowLevelApi?.dispose(),
57
53
 
58
54
  uiResponse: response => lowLevelApi?.uiResponse(response),
59
55
 
@@ -12,7 +12,6 @@ import type {
12
12
  IProtocolV2FirmwareComponentTarget,
13
13
  } from '../settings';
14
14
  import type { FirmwareUpdateV4Target } from './firmwareUpdate';
15
- import type { FirmwareUpdatePlan, FirmwareUpdatePlanForceTarget } from './firmwareUpdatePlan';
16
15
 
17
16
  export type FirmwareRelease = {
18
17
  shouldUpdate?: boolean;
@@ -65,15 +64,12 @@ export type AllFirmwareRelease = {
65
64
  components?: ProtocolV2FirmwareComponentRelease[];
66
65
  targetsToUpdate?: FirmwareUpdateV4Target[];
67
66
  release?: IFirmwareReleaseInfo;
68
- firmwareUpdatePlan?: FirmwareUpdatePlan;
69
67
  };
70
68
 
71
69
  export type CheckAllFirmwareReleaseParams = {
72
70
  checkBridgeRelease?: boolean;
73
71
  checkFirmwareHash?: boolean;
74
72
  firmwareType?: EFirmwareType;
75
- platform?: 'native' | 'desktop' | 'ext' | 'web' | 'web-embed';
76
- forceUpdateTargets?: FirmwareUpdatePlanForceTarget[];
77
73
  };
78
74
 
79
75
  export declare function checkAllFirmwareRelease(
@@ -1,15 +1,9 @@
1
1
  import type { Success } from '@onekeyfe/hd-transport';
2
2
  import type { EFirmwareType } from '@onekeyfe/hd-shared';
3
- import type { FirmwareArtifactReader, FirmwareArtifactReference } from './firmwareUpdate';
4
- import type { FirmwareUpdatePreparedPlan } from './firmwareUpdatePreparedPlan';
5
3
  import type { Response } from '../params';
6
4
 
7
5
  export type DeviceUpdateBootloaderParams = {
8
- preparedPlan?: FirmwareUpdatePreparedPlan;
9
- hostBindingGeneration?: number;
10
6
  binary?: ArrayBuffer;
11
- artifact?: FirmwareArtifactReference;
12
- artifactReader?: FirmwareArtifactReader;
13
7
  firmwareType?: EFirmwareType;
14
8
  };
15
9
 
@@ -26,30 +26,12 @@ export type {
26
26
  DeviceUploadResourceResponse,
27
27
  } from './deviceUploadResource';
28
28
  export type {
29
- FirmwareArtifactReader,
30
- FirmwareArtifactReference,
31
- FirmwareUpdateHostBinding,
32
- FirmwareUpdateArtifactParams,
33
29
  FirmwareUpdateParams,
34
30
  FirmwareUpdateBinaryParams,
35
31
  FirmwareUpdateV3Params,
36
32
  FirmwareUpdateV4Params,
37
33
  FirmwareUpdateV4Target,
38
34
  } from './firmwareUpdate';
39
- export type {
40
- FirmwareUpdatePlan,
41
- FirmwareUpdatePlanArtifact,
42
- FirmwareUpdatePlanArtifactRole,
43
- FirmwareUpdatePlanForceTarget,
44
- FirmwareUpdatePlanTarget,
45
- } from './firmwareUpdatePlan';
46
- export type {
47
- FirmwareUpdatePreparedArtifact,
48
- FirmwareUpdatePreparedArtifactInput,
49
- FirmwareUpdatePreparedEntry,
50
- FirmwareUpdatePreparedPlan,
51
- } from './firmwareUpdatePreparedPlan';
52
- export type { FirmwareUpdateCapabilities } from './firmwareUpdateCapabilities';
53
35
  export type { AllFirmwareRelease } from './checkAllFirmwareRelease';
54
36
  export type {
55
37
  ProtocolV2FirmwareComponentRelease,
@@ -1,52 +1,14 @@
1
1
  import type { EFirmwareType } from '@onekeyfe/hd-shared';
2
2
  import type { PROTO } from '../../constants';
3
3
  import type { Params, Response } from '../params';
4
- import type { FirmwareUpdatePreparedPlan } from './firmwareUpdatePreparedPlan';
5
4
 
6
5
  type IUpdateType = 'firmware' | 'ble';
7
6
 
8
- export interface FirmwareArtifactReference {
9
- artifactRef: string;
10
- size: number;
11
- sha256: string;
12
- }
13
-
14
- export interface FirmwareArtifactReader {
15
- open(input: { artifactRef: string }): Promise<{
16
- readerId: string;
17
- size: number;
18
- }>;
19
- read(input: { readerId: string; offset: number; length: number }): Promise<{
20
- data: ArrayBuffer;
21
- bytesRead: number;
22
- eof: boolean;
23
- }>;
24
- close(input: { readerId: string }): Promise<void>;
25
- }
26
-
27
- export interface FirmwareUpdateHostBinding {
28
- artifactReader: FirmwareArtifactReader;
29
- }
30
-
31
7
  export interface FirmwareUpdateBinaryParams {
32
8
  binary: ArrayBuffer;
33
9
  updateType: IUpdateType;
34
10
  }
35
11
 
36
- export interface FirmwareUpdateArtifactParams {
37
- preparedPlan: FirmwareUpdatePreparedPlan;
38
- hostBindingGeneration: number;
39
- artifact: FirmwareArtifactReference;
40
- resourceEntries?: Array<{
41
- entryName: string;
42
- artifact: FirmwareArtifactReference;
43
- }>;
44
- updateType: IUpdateType;
45
- forcedUpdateRes?: boolean;
46
- isUpdateBootloader?: boolean;
47
- firmwareType?: EFirmwareType;
48
- }
49
-
50
12
  export interface FirmwareUpdateParams {
51
13
  version?: number[];
52
14
  updateType: IUpdateType;
@@ -75,14 +37,8 @@ export declare function firmwareUpdateV2(
75
37
  connectId: string | undefined,
76
38
  params: Params<FirmwareUpdateBinaryParams & Platform>
77
39
  ): Response<PROTO.Success>;
78
- export declare function firmwareUpdateV2(
79
- connectId: string | undefined,
80
- params: Params<FirmwareUpdateArtifactParams & Platform>
81
- ): Response<PROTO.Success>;
82
40
 
83
41
  export interface FirmwareUpdateV3Params {
84
- preparedPlan?: FirmwareUpdatePreparedPlan;
85
- hostBindingGeneration?: number;
86
42
  bleVersion?: number[];
87
43
  bleBinary?: ArrayBuffer;
88
44
  chunkSize?: number;
@@ -99,17 +55,6 @@ export interface FirmwareUpdateV3Params {
99
55
  firmwareType?: EFirmwareType;
100
56
 
101
57
  platform: IPlatform;
102
-
103
- artifactReader?: FirmwareArtifactReader;
104
- artifacts?: {
105
- ble?: FirmwareArtifactReference;
106
- firmware?: FirmwareArtifactReference;
107
- bootloader?: FirmwareArtifactReference;
108
- resourceEntries?: Array<{
109
- entryName: string;
110
- artifact: FirmwareArtifactReference;
111
- }>;
112
- };
113
58
  }
114
59
 
115
60
  /**
@@ -129,14 +74,10 @@ export type FirmwareUpdateV4Target =
129
74
  | 'se04';
130
75
 
131
76
  export interface FirmwareUpdateV4Params {
132
- preparedPlan?: FirmwareUpdatePreparedPlan;
133
- hostBindingGeneration?: number;
134
77
  platform: IPlatform;
135
- expectedDeviceId?: string;
136
78
  chunkSize?: number;
137
79
  firmwareType?: EFirmwareType;
138
80
  targetsToUpdate?: FirmwareUpdateV4Target[];
139
- expectedTargetVersions?: Partial<Record<FirmwareUpdateV4Target, string>>;
140
81
 
141
82
  /** FW_MGMT_TARGET_ROMLOADER = 2; Pro2 cannot install it through firmwareUpdateV4. */
142
83
  romloaderBinary?: ArrayBuffer;
@@ -164,24 +105,8 @@ export interface FirmwareUpdateV4Params {
164
105
  size?: number;
165
106
  fileHash?: string;
166
107
  }>;
167
- artifactReader?: FirmwareArtifactReader;
168
- componentArtifacts?: Partial<
169
- Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>
170
- >;
171
- resourceBundleArtifacts?: Array<{
172
- name: string;
173
- artifact: FirmwareArtifactReference;
174
- }>;
175
108
  }
176
109
 
177
- export declare function registerFirmwareUpdateHostBinding(
178
- binding: FirmwareUpdateHostBinding
179
- ): number;
180
-
181
- export declare function unregisterFirmwareUpdateHostBinding(generation?: number): boolean;
182
-
183
- export declare function getFirmwareUpdateHostBindingGeneration(): number;
184
-
185
110
  export declare function firmwareUpdateV3(
186
111
  connectId: string | undefined,
187
112
  params: Params<FirmwareUpdateV3Params>