@onekeyfe/hd-core 1.2.0-alpha.131 → 1.2.0-alpha.133

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.2.0-alpha.131",
3
+ "version": "1.2.0-alpha.133",
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.0-alpha.131",
29
- "@onekeyfe/hd-transport": "1.2.0-alpha.131",
28
+ "@onekeyfe/hd-shared": "1.2.0-alpha.133",
29
+ "@onekeyfe/hd-transport": "1.2.0-alpha.133",
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": "81b472e983e80e6aa771b991dc9c0c9b1bdcf07b"
49
+ "gitHead": "b6d3307b47c535c876655afd99a6681399453508"
50
50
  }
@@ -200,20 +200,7 @@ export default class DeviceSettings extends BaseMethod<ApplySettings> {
200
200
  const res = await this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', {
201
201
  page: DeviceSettingsPage.DevicePassphrase,
202
202
  });
203
- const updated = await refreshStatusAndSettings();
204
- const lockedAfterDisabling =
205
- requestedPassphrase === false &&
206
- current.status.unlocked === true &&
207
- updated.status.unlocked === false;
208
- if (
209
- updated.status.passphraseProtection !== requestedPassphrase &&
210
- !lockedAfterDisabling
211
- ) {
212
- throw TypedError(
213
- HardwareErrorCode.RuntimeError,
214
- 'Protocol V2 passphrase setting did not reach the requested value.'
215
- );
216
- }
203
+ await refreshStatusAndSettings();
217
204
  return res.message;
218
205
  }
219
206
  if (requestedAirgap !== undefined) {
@@ -8,6 +8,7 @@ import { invalidParameter } from '../helpers/filesystemValidation';
8
8
  import { writeProtocolV2File } from '../helpers/protocolV2FileWrite';
9
9
  import { UI_REQUEST, createUiMessage } from '../../events/ui-request';
10
10
  import { supportsProtocolV2Message } from '../../protocols/protocol-v2/features';
11
+ import { LoggerNames, getLogger } from '../../utils';
11
12
  import {
12
13
  PRO2_WALLPAPER_HEIGHT,
13
14
  PRO2_WALLPAPER_WIDTH,
@@ -33,6 +34,7 @@ const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
33
34
  const DEVICE_SETTINGS_SET_MESSAGE_TYPE = 60412;
34
35
  const FILESYSTEM_FILE_WRITE_MESSAGE_TYPE = 60805;
35
36
  const FILESYSTEM_DIR_MAKE_MESSAGE_TYPE = 60809;
37
+ const Log = getLogger(LoggerNames.Method);
36
38
 
37
39
  function normalizeFileName(fileName: string | undefined, data: Uint8Array): string {
38
40
  if (fileName !== undefined && (!fileName || !SAFE_FILE_NAME.test(fileName))) {
@@ -143,7 +145,15 @@ export default class DeviceUploadWallpaper extends BaseMethod<DeviceUploadWallpa
143
145
  const response = await this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
144
146
  settings: { wallpaper_path: this.path },
145
147
  });
146
- await this.device.refreshProtocolV2SettingsAfterMutation();
148
+ try {
149
+ await this.device.refreshProtocolV2SettingsAfterMutation();
150
+ } catch (error) {
151
+ // The wallpaper is already applied. A transient read-back failure must not
152
+ // make callers retry the completed file upload.
153
+ Log.warn('Protocol V2 wallpaper settings refresh failed after apply', {
154
+ error: error instanceof Error ? error.message : String(error),
155
+ });
156
+ }
147
157
  return {
148
158
  path: this.path,
149
159
  size: encoded.data.byteLength,
package/src/core/index.ts CHANGED
@@ -924,9 +924,10 @@ function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: unknown)
924
924
  );
925
925
  }
926
926
 
927
- function isMissingDetectedProtocolError(error: unknown) {
927
+ export function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unknown) {
928
928
  const typedError = error as { errorCode?: unknown; message?: unknown };
929
929
  return (
930
+ method.payload.connectProtocol === 'V2' &&
930
931
  typedError?.errorCode === HardwareErrorCode.RuntimeError &&
931
932
  typeof typedError.message === 'string' &&
932
933
  typedError.message.includes('Device protocol has not been detected')
@@ -970,7 +971,7 @@ async function connectDeviceForBle(method: BaseMethod, device: Device, retryCoun
970
971
  DevicePool.emitter.emit(DEVICE.CONNECT, device);
971
972
  }
972
973
  } catch (err) {
973
- const requiresColdReconnect = isMissingDetectedProtocolError(err);
974
+ const requiresColdReconnect = isMissingDetectedProtocolV2Error(method, err);
974
975
  // Device.run()'s REQUIRE_DISCONNECT handling never sees acquire/initialize
975
976
  // failures, so with keep-alive a wedged link would be reused by every retry
976
977
  // (field case: Initialize timing out at 25s per attempt, forever). Drop it