@onekeyfe/hwk-ledger-adapter 1.1.27 → 1.1.28

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/dist/index.js CHANGED
@@ -3541,15 +3541,30 @@ var AppManager = class {
3541
3541
  command: new import_device_management_kit2.OpenAppCommand({ appName })
3542
3542
  });
3543
3543
  if (!(0, import_device_management_kit2.isSuccessCommandResult)(result)) {
3544
- const { statusCode } = result;
3545
- const hasStatusCode2 = statusCode != null && statusCode !== "";
3546
- debugLog("[AppManager] openApp failed:", appName, "statusCode:", statusCode);
3544
+ const dmkErr = result.error;
3545
+ const errorCode = "errorCode" in dmkErr && dmkErr.errorCode != null ? String(dmkErr.errorCode) : "";
3546
+ const message = "message" in dmkErr && typeof dmkErr.message === "string" ? dmkErr.message : "";
3547
+ debugLog(
3548
+ "[AppManager] openApp failed:",
3549
+ appName,
3550
+ "errorCode:",
3551
+ errorCode,
3552
+ "tag:",
3553
+ dmkErr._tag
3554
+ );
3555
+ let code;
3556
+ if (errorCode === "6807" || /unknown application/i.test(message)) {
3557
+ code = import_hwk_adapter_core10.HardwareErrorCode.AppNotInstalled;
3558
+ } else if (errorCode === "5501" || dmkErr._tag === "ActionRefusedError") {
3559
+ code = import_hwk_adapter_core10.HardwareErrorCode.UserRejected;
3560
+ }
3547
3561
  throw Object.assign(new Error(`Failed to open "${appName}"`), {
3548
3562
  _tag: ERROR_TAG.OpenAppCommand,
3549
- code: hasStatusCode2 ? void 0 : import_hwk_adapter_core10.HardwareErrorCode.AppNotInstalled,
3550
- errorCode: String(statusCode ?? ""),
3551
- statusCode,
3552
- appName
3563
+ code,
3564
+ errorCode,
3565
+ statusCode: errorCode,
3566
+ appName,
3567
+ originalError: dmkErr
3553
3568
  });
3554
3569
  }
3555
3570
  }
@@ -3968,6 +3983,22 @@ var DeviceApps = class {
3968
3983
  async install(appName, onProgress, options) {
3969
3984
  if (!appName) throw new Error("DeviceApps.install: appName is required");
3970
3985
  debugLog("[DeviceApps] install:", appName);
3986
+ const refreshAction = this._dmk.executeDeviceAction({
3987
+ sessionId: this._sessionId,
3988
+ deviceAction: new this._ledgerKit.GetDeviceMetadataDeviceAction({
3989
+ input: {
3990
+ useSecureChannel: true,
3991
+ forceUpdate: true,
3992
+ unlockTimeout: options?.unlockTimeout
3993
+ }
3994
+ })
3995
+ });
3996
+ await deviceActionToPromise(
3997
+ refreshAction,
3998
+ this.onInteraction,
3999
+ INSTALL_TIMEOUT_MS,
4000
+ this.onRegisterCanceller
4001
+ );
3971
4002
  const action = this._dmk.executeDeviceAction({
3972
4003
  sessionId: this._sessionId,
3973
4004
  deviceAction: new this._ledgerKit.InstallOrUpdateAppsDeviceAction({