@onekeyfe/hd-core 1.2.0-alpha.74 → 1.2.0-alpha.75

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 (120) hide show
  1. package/__tests__/connectSettings.test.ts +5 -45
  2. package/__tests__/devicePoolBootloaderPath.test.ts +64 -0
  3. package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +31 -59
  4. package/__tests__/protocol-v2.test.ts +100 -405
  5. package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
  6. package/dist/api/FirmwareUpdate.d.ts.map +1 -1
  7. package/dist/api/FirmwareUpdateV2.d.ts +0 -10
  8. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  9. package/dist/api/FirmwareUpdateV3.d.ts +3 -7
  10. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  11. package/dist/api/FirmwareUpdateV4.d.ts +5 -25
  12. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  13. package/dist/api/device/DeviceUpdateBootloader.d.ts +1 -5
  14. package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
  15. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +0 -8
  16. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  17. package/dist/api/firmware/getBinary.d.ts +0 -7
  18. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  19. package/dist/api/firmware/updateBootloader.d.ts +0 -2
  20. package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
  21. package/dist/api/firmware/uploadFirmware.d.ts +1 -9
  22. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  23. package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
  24. package/dist/core/index.d.ts.map +1 -1
  25. package/dist/data-manager/DataManager.d.ts +0 -1
  26. package/dist/data-manager/DataManager.d.ts.map +1 -1
  27. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  28. package/dist/device/Device.d.ts +0 -1
  29. package/dist/device/Device.d.ts.map +1 -1
  30. package/dist/device/DeviceConnector.d.ts +1 -1
  31. package/dist/device/DeviceConnector.d.ts.map +1 -1
  32. package/dist/device/DevicePool.d.ts +1 -0
  33. package/dist/device/DevicePool.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 +1078 -3083
  37. package/dist/inject.d.ts.map +1 -1
  38. package/dist/lowLevelInject.d.ts.map +1 -1
  39. package/dist/topLevelInject.d.ts.map +1 -1
  40. package/dist/types/api/checkAllFirmwareRelease.d.ts +0 -4
  41. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  42. package/dist/types/api/deviceUpdateBootloader.d.ts +0 -6
  43. package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
  44. package/dist/types/api/export.d.ts +1 -4
  45. package/dist/types/api/export.d.ts.map +1 -1
  46. package/dist/types/api/firmwareUpdate.d.ts +0 -68
  47. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  48. package/dist/types/api/index.d.ts +1 -9
  49. package/dist/types/api/index.d.ts.map +1 -1
  50. package/dist/types/settings.d.ts +0 -13
  51. package/dist/types/settings.d.ts.map +1 -1
  52. package/dist/utils/deviceFeaturesCompat.d.ts +0 -1
  53. package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
  54. package/package.json +4 -4
  55. package/src/api/CheckAllFirmwareRelease.ts +6 -57
  56. package/src/api/FirmwareUpdate.ts +1 -13
  57. package/src/api/FirmwareUpdateV2.ts +121 -296
  58. package/src/api/FirmwareUpdateV3.ts +57 -263
  59. package/src/api/FirmwareUpdateV4.ts +349 -881
  60. package/src/api/device/DeviceUpdateBootloader.ts +6 -125
  61. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +1 -72
  62. package/src/api/firmware/updateBootloader.ts +4 -19
  63. package/src/api/firmware/uploadFirmware.ts +22 -140
  64. package/src/core/index.ts +16 -0
  65. package/src/data-manager/DataManager.ts +54 -62
  66. package/src/data-manager/connectSettings.ts +0 -11
  67. package/src/device/Device.ts +3 -7
  68. package/src/device/DeviceConnector.ts +2 -2
  69. package/src/device/DevicePool.ts +15 -1
  70. package/src/index.ts +0 -5
  71. package/src/inject.ts +2 -22
  72. package/src/lowLevelInject.ts +1 -5
  73. package/src/topLevelInject.ts +1 -5
  74. package/src/types/api/checkAllFirmwareRelease.ts +0 -4
  75. package/src/types/api/deviceUpdateBootloader.ts +0 -6
  76. package/src/types/api/export.ts +0 -18
  77. package/src/types/api/firmwareUpdate.ts +0 -75
  78. package/src/types/api/index.ts +0 -14
  79. package/src/types/settings.ts +0 -13
  80. package/src/utils/deviceFeaturesCompat.ts +0 -6
  81. package/__tests__/device-initialize-timeout.test.ts +0 -56
  82. package/__tests__/firmware-update/check-all-firmware-release.test.ts +0 -175
  83. package/__tests__/firmware-update/device-update-bootloader.test.ts +0 -87
  84. package/__tests__/firmware-update/firmware-artifact-source.test.ts +0 -119
  85. package/__tests__/firmware-update/firmware-host-binding.test.ts +0 -70
  86. package/__tests__/firmware-update/firmware-preparation-error.test.ts +0 -27
  87. package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +0 -200
  88. package/__tests__/firmware-update/firmware-update-capabilities.test.ts +0 -13
  89. package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +0 -394
  90. package/__tests__/firmware-update/firmware-update-plan.test.ts +0 -593
  91. package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +0 -231
  92. package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +0 -64
  93. package/__tests__/firmware-update/firmware-upload-source.test.ts +0 -70
  94. package/dist/api/firmware/FirmwareArtifactSource.d.ts +0 -25
  95. package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +0 -1
  96. package/dist/api/firmware/FirmwareHostBinding.d.ts +0 -6
  97. package/dist/api/firmware/FirmwareHostBinding.d.ts.map +0 -1
  98. package/dist/api/firmware/FirmwarePreparationError.d.ts +0 -3
  99. package/dist/api/firmware/FirmwarePreparationError.d.ts.map +0 -1
  100. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +0 -3
  101. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +0 -1
  102. package/dist/api/firmware/FirmwareUpdatePlan.d.ts +0 -25
  103. package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +0 -1
  104. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +0 -32
  105. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +0 -1
  106. package/dist/types/api/firmwareUpdateCapabilities.d.ts +0 -9
  107. package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +0 -1
  108. package/dist/types/api/firmwareUpdatePlan.d.ts +0 -28
  109. package/dist/types/api/firmwareUpdatePlan.d.ts.map +0 -1
  110. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +0 -42
  111. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +0 -1
  112. package/src/api/firmware/FirmwareArtifactSource.ts +0 -278
  113. package/src/api/firmware/FirmwareHostBinding.ts +0 -100
  114. package/src/api/firmware/FirmwarePreparationError.ts +0 -12
  115. package/src/api/firmware/FirmwareUpdateCapabilities.ts +0 -9
  116. package/src/api/firmware/FirmwareUpdatePlan.ts +0 -772
  117. package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +0 -449
  118. package/src/types/api/firmwareUpdateCapabilities.ts +0 -9
  119. package/src/types/api/firmwareUpdatePlan.ts +0 -38
  120. package/src/types/api/firmwareUpdatePreparedPlan.ts +0 -53
@@ -408,20 +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
- Log.warn(
420
- '[DataConfig] External firmware config is unavailable; SDK-managed networking remains disabled'
421
- );
422
- return false;
423
- }
424
- if (manifestMode !== 'sdk-managed') {
411
+ if (!settings.fetchConfig) {
425
412
  return false;
426
413
  }
427
414
 
@@ -432,19 +419,26 @@ export default class DataManager {
432
419
  const urlWithCache = `${url}?noCache=${getTimeStamp()}`;
433
420
  let data: RemoteConfigResponse | null = null;
434
421
  let fetchMethod: 'configFetcher' | 'axios' | 'none' = 'none';
422
+
423
+ // 1. Try custom configFetcher first (client-side IP direct connection support)
435
424
  if (settings.configFetcher) {
436
- Log.debug('[DataConfig] Trying client configFetcher...');
425
+ Log.debug('[DataConfig] Trying configFetcher (client-side fetcher)...');
437
426
  try {
438
427
  data = await settings.configFetcher(urlWithCache);
439
428
  if (data) {
440
429
  fetchMethod = 'configFetcher';
430
+ Log.log('[DataConfig] ConfigFetcher success');
431
+ } else {
432
+ Log.debug('[DataConfig] ConfigFetcher returned null, will fallback to axios');
441
433
  }
442
434
  } catch (e) {
443
- Log.warn('[DataConfig] Client configFetcher failed:', e);
435
+ Log.warn('[DataConfig] ConfigFetcher error, will fallback to axios:', e);
444
436
  }
445
437
  }
438
+
439
+ // 2. Fallback to default axios request
446
440
  if (!data) {
447
- Log.debug('[DataConfig] Trying SDK-managed config request...');
441
+ Log.debug('[DataConfig] Trying axios (SDK default fetcher)...');
448
442
  try {
449
443
  const response = await axios.get<RemoteConfigResponse>(urlWithCache, {
450
444
  // because of iframe timeout is 10000
@@ -452,63 +446,61 @@ export default class DataManager {
452
446
  });
453
447
  data = response.data;
454
448
  fetchMethod = 'axios';
455
- Log.log('[DataConfig] SDK-managed config request succeeded');
449
+ Log.log('[DataConfig] Axios fetch success');
456
450
  } catch (e) {
457
- Log.warn('[DataConfig] SDK-managed config request failed:', e);
451
+ Log.warn('[DataConfig] Axios fetch error:', e);
458
452
  }
459
453
  }
460
454
 
455
+ // 3. Apply config if available
461
456
  if (data) {
462
- 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;
463
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
+ };
464
498
  return true;
465
499
  }
466
500
  Log.warn('[DataConfig] All fetch methods failed, using built-in default config');
467
501
  return false;
468
502
  }
469
503
 
470
- private static applyRemoteConfig(data: RemoteConfigResponse) {
471
- let pro2Resources: IProtocolV2Resources | undefined;
472
- let neoResources: IProtocolV2Resources | undefined;
473
- try {
474
- pro2Resources = parseProtocolV2Resources(
475
- (data.pro2 as { resources?: unknown } | undefined)?.resources
476
- );
477
- neoResources = parseProtocolV2Resources(
478
- (data.neo as { resources?: unknown } | undefined)?.resources
479
- );
480
- } catch (error) {
481
- // Firmware resource metadata is not required for base communication. If the
482
- // remote config is temporarily incomplete, disable this resource update only.
483
- this.protocolV2ResourcesConfigError =
484
- error instanceof Error ? error : new Error(String(error));
485
- Log.warn('[DataConfig] Ignoring invalid Protocol V2 resources config:', error);
486
- }
487
- const enrichedPro2Config = this.enrichFirmwareReleaseInfo(data.pro2);
488
- const enrichedNeoConfig = this.enrichFirmwareReleaseInfo(data.neo);
489
- const { resources: _unvalidatedResources, ...pro2Config } = enrichedPro2Config;
490
- const { resources: _unvalidatedNeoResources, ...neoConfig } = enrichedNeoConfig;
491
- this.deviceMap = {
492
- [EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
493
- [EDeviceType.Classic1s]: this.enrichFirmwareReleaseInfo(data.classic1s),
494
- [EDeviceType.ClassicPure]: this.enrichFirmwareReleaseInfo(data.classicpure),
495
- [EDeviceType.Mini]: this.enrichFirmwareReleaseInfo(data.mini),
496
- [EDeviceType.Touch]: this.enrichFirmwareReleaseInfo(data.touch),
497
- [EDeviceType.Pro]: this.enrichFirmwareReleaseInfo(data.pro),
498
- [EDeviceType.Pro2]: {
499
- ...pro2Config,
500
- ...(pro2Resources ? { resources: pro2Resources } : undefined),
501
- },
502
- [EDeviceType.Neo]: {
503
- ...neoConfig,
504
- ...(neoResources ? { resources: neoResources } : undefined),
505
- },
506
- };
507
- this.assets = {
508
- bridge: data.bridge,
509
- };
510
- }
511
-
512
504
  static updateEnv(newEnv: ConnectSettings['env']) {
513
505
  if (this.settings) {
514
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 = {
@@ -543,7 +538,8 @@ export class Device extends EventEmitter {
543
538
  }
544
539
  }
545
540
  try {
546
- await this.deviceConnector?.release(this.mainId, false);
541
+ // BLE releases even when keepSession is set, so forward the intent.
542
+ await this.deviceConnector?.release(this.mainId, false, this.keepSession);
547
543
  this.updateDescriptor({ session: null } as DeviceDescriptor);
548
544
  } catch (err) {
549
545
  Log.error('[Device] release error: ', err);
@@ -913,7 +909,7 @@ export class Device extends EventEmitter {
913
909
  const initStartAt = Date.now();
914
910
  const { message } = await this.commands.typedCall('Initialize', 'Features', payload, {
915
911
  // iOS BLE bound devices can need close to 20 seconds.
916
- timeoutMs: options?.timeoutMs ?? 25 * 1000,
912
+ timeoutMs: 25 * 1000,
917
913
  });
918
914
  this.setLastInitializeDuration(Date.now() - initStartAt);
919
915
  this._updateFeatures(message, initSession);
@@ -138,9 +138,9 @@ export default class DeviceConnector {
138
138
  }
139
139
  }
140
140
 
141
- async release(session: string, onclose: boolean) {
141
+ async release(session: string, onclose: boolean, keepSession?: boolean) {
142
142
  try {
143
- const res = await this.getActiveTransport().release(session, onclose);
143
+ const res = await this.getActiveTransport().release(session, onclose, keepSession);
144
144
  return res;
145
145
  } catch (error) {
146
146
  safeThrowError(error);
@@ -11,6 +11,14 @@ import type DeviceConnector from './DeviceConnector';
11
11
 
12
12
  const Log = getLogger(LoggerNames.DevicePool);
13
13
 
14
+ /**
15
+ * A bootloader device's descriptor path is an all-zero placeholder serial, and
16
+ * bootloader product ids are shared across models — so the path identifies
17
+ * nothing. Matching the cache by it returns whichever device was seen first
18
+ * (plug in a Mini then a Classic, and the Classic reports as a Mini).
19
+ */
20
+ export const canPathIdentifyDevice = (path?: string) => !!path && !/^0+$/.test(path);
21
+
14
22
  export type DeviceDescriptorDiff = {
15
23
  didUpdate: boolean;
16
24
  connected: DeviceDescriptor[];
@@ -102,7 +110,10 @@ export class DevicePool extends EventEmitter {
102
110
  if (connectId) {
103
111
  const device = this.devicesCache[connectId];
104
112
  if (device) {
105
- const exist = descriptorList.find(d => d.path === device.originalDescriptor.path);
113
+ const cachedPath = device.originalDescriptor.path;
114
+ const exist = canPathIdentifyDevice(cachedPath)
115
+ ? descriptorList.find(d => d.path === cachedPath)
116
+ : undefined;
106
117
  if (exist && !initOptions?.forceProtocolDetection) {
107
118
  // Log.debug('find existed Device: ', connectId);
108
119
  device.updateDescriptor(exist, true);
@@ -283,6 +294,9 @@ export class DevicePool extends EventEmitter {
283
294
  }
284
295
 
285
296
  static getDeviceByPath(path: string) {
297
+ // A path that cannot identify a device would match an arbitrary cache entry,
298
+ // so report a miss and let the caller read the device instead.
299
+ if (!canPathIdentifyDevice(path)) return undefined;
286
300
  return Object.values(this.devicesCache).find(d => d.originalDescriptor.path === path);
287
301
  }
288
302
 
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
 
@@ -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;
@@ -165,24 +106,8 @@ export interface FirmwareUpdateV4Params {
165
106
  size?: number;
166
107
  fileHash?: string;
167
108
  }>;
168
- artifactReader?: FirmwareArtifactReader;
169
- componentArtifacts?: Partial<
170
- Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>
171
- >;
172
- resourceBundleArtifacts?: Array<{
173
- name: string;
174
- artifact: FirmwareArtifactReference;
175
- }>;
176
109
  }
177
110
 
178
- export declare function registerFirmwareUpdateHostBinding(
179
- binding: FirmwareUpdateHostBinding
180
- ): number;
181
-
182
- export declare function unregisterFirmwareUpdateHostBinding(generation?: number): boolean;
183
-
184
- export declare function getFirmwareUpdateHostBindingGeneration(): number;
185
-
186
111
  export declare function firmwareUpdateV3(
187
112
  connectId: string | undefined,
188
113
  params: Params<FirmwareUpdateV3Params>
@@ -32,15 +32,7 @@ import type {
32
32
  firmwareUpdateV2,
33
33
  firmwareUpdateV3,
34
34
  firmwareUpdateV4,
35
- getFirmwareUpdateHostBindingGeneration,
36
- registerFirmwareUpdateHostBinding,
37
- unregisterFirmwareUpdateHostBinding,
38
35
  } from './firmwareUpdate';
39
- import type { getFirmwareUpdateCapabilities } from './firmwareUpdateCapabilities';
40
- import type {
41
- prepareFirmwareUpdatePlan,
42
- validateFirmwareUpdatePreparedPlan,
43
- } from './firmwareUpdatePreparedPlan';
44
36
  import type { promptWebDeviceAccess } from './promptWebDeviceAccess';
45
37
  import type { deviceReset } from './deviceReset';
46
38
  import type { deviceRecovery } from './deviceRecovery';
@@ -247,12 +239,6 @@ export type CoreApi = {
247
239
  firmwareUpdateV2: typeof firmwareUpdateV2;
248
240
  firmwareUpdateV3: typeof firmwareUpdateV3;
249
241
  firmwareUpdateV4: typeof firmwareUpdateV4;
250
- registerFirmwareUpdateHostBinding: typeof registerFirmwareUpdateHostBinding;
251
- unregisterFirmwareUpdateHostBinding: typeof unregisterFirmwareUpdateHostBinding;
252
- getFirmwareUpdateHostBindingGeneration: typeof getFirmwareUpdateHostBindingGeneration;
253
- getFirmwareUpdateCapabilities: typeof getFirmwareUpdateCapabilities;
254
- prepareFirmwareUpdatePlan: typeof prepareFirmwareUpdatePlan;
255
- validateFirmwareUpdatePreparedPlan: typeof validateFirmwareUpdatePreparedPlan;
256
242
  cipherKeyValue: typeof cipherKeyValue;
257
243
 
258
244
  /**
@@ -31,8 +31,6 @@ export type ConnectSettings = {
31
31
  timestamp: number;
32
32
  isFrame?: boolean;
33
33
  preRelease?: boolean;
34
- firmwareManifestMode?: 'sdk-managed' | 'external-only';
35
- preloadedConfig?: RemoteConfigResponse;
36
34
  fetchConfig?: boolean;
37
35
  extension?: string;
38
36
  configFetcher?: (url: string) => Promise<RemoteConfigResponse | null>;
@@ -60,7 +58,6 @@ export type IProtocolV2FirmwareComponent = {
60
58
  fingerprint?: string;
61
59
  /** OKPP payload hash, used to detect same-version package changes. */
62
60
  payloadHash?: string;
63
- expectedSize?: number;
64
61
  version?: IVersionArray;
65
62
  };
66
63
 
@@ -114,8 +111,6 @@ export type IProtocolV2ResourceBundle = {
114
111
  name: string;
115
112
  /** Download URL. */
116
113
  url: string;
117
- fingerprint?: string;
118
- expectedSize?: number;
119
114
  /** Device target path, such as vol0:/bundles/images/images.okpkg. */
120
115
  devicePath: string;
121
116
  /** okpkg payload_version used to skip matching content after FileRead. */
@@ -137,16 +132,10 @@ export type IFirmwareReleaseInfo = {
137
132
  firmwareType?: EFirmwareType;
138
133
  /** Firmware UI resource */
139
134
  resource?: string;
140
- resourceFingerprint?: string;
141
- resourceExpectedSize?: number;
142
135
  /** Firmware full UI resource */
143
136
  fullResource?: string;
144
- fullResourceFingerprint?: string;
145
- fullResourceExpectedSize?: number;
146
137
  fullResourceRange?: string[];
147
138
  bootloaderResource?: string;
148
- bootloaderFingerprint?: string;
149
- bootloaderExpectedSize?: number;
150
139
  bootloaderVersion?: IVersionArray;
151
140
  displayBootloaderVersion?: IVersionArray;
152
141
  bootloaderRelatedFirmwareVersion?: IVersionArray;
@@ -159,7 +148,6 @@ export type IFirmwareReleaseInfo = {
159
148
  [k in ILocale]: string;
160
149
  };
161
150
  fingerprint: string;
162
- expectedSize?: number;
163
151
  version: IVersionArray;
164
152
  changelog: {
165
153
  [k in ILocale]: string;
@@ -175,7 +163,6 @@ export type IBLEFirmwareReleaseInfo = {
175
163
  webUpdate: string;
176
164
  fingerprint: string;
177
165
  fingerprintWeb: string;
178
- expectedSize?: number;
179
166
  version: IVersionArray;
180
167
  changelog: {
181
168
  [k in ILocale]: string;
@@ -37,12 +37,6 @@ export const resolveDeviceSerialNo = (features?: DeviceFeaturesInput): string =>
37
37
  );
38
38
  };
39
39
 
40
- export const resolveDeviceBootloaderMode = (features?: DeviceFeaturesInput): boolean => {
41
- if (!features) return false;
42
- const compatible = asCompatibleFeatures(features);
43
- return (compatible.bootloaderMode ?? compatible.bootloader_mode) === true;
44
- };
45
-
46
40
  export const resolveDeviceType = (features?: DeviceFeaturesInput): IDeviceType => {
47
41
  if (!features || typeof features !== 'object') {
48
42
  return EDeviceType.Unknown;