@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.mjs CHANGED
@@ -3511,15 +3511,30 @@ var AppManager = class {
3511
3511
  command: new OpenAppCommand({ appName })
3512
3512
  });
3513
3513
  if (!isSuccessCommandResult(result)) {
3514
- const { statusCode } = result;
3515
- const hasStatusCode2 = statusCode != null && statusCode !== "";
3516
- debugLog("[AppManager] openApp failed:", appName, "statusCode:", statusCode);
3514
+ const dmkErr = result.error;
3515
+ const errorCode = "errorCode" in dmkErr && dmkErr.errorCode != null ? String(dmkErr.errorCode) : "";
3516
+ const message = "message" in dmkErr && typeof dmkErr.message === "string" ? dmkErr.message : "";
3517
+ debugLog(
3518
+ "[AppManager] openApp failed:",
3519
+ appName,
3520
+ "errorCode:",
3521
+ errorCode,
3522
+ "tag:",
3523
+ dmkErr._tag
3524
+ );
3525
+ let code;
3526
+ if (errorCode === "6807" || /unknown application/i.test(message)) {
3527
+ code = HardwareErrorCode6.AppNotInstalled;
3528
+ } else if (errorCode === "5501" || dmkErr._tag === "ActionRefusedError") {
3529
+ code = HardwareErrorCode6.UserRejected;
3530
+ }
3517
3531
  throw Object.assign(new Error(`Failed to open "${appName}"`), {
3518
3532
  _tag: ERROR_TAG.OpenAppCommand,
3519
- code: hasStatusCode2 ? void 0 : HardwareErrorCode6.AppNotInstalled,
3520
- errorCode: String(statusCode ?? ""),
3521
- statusCode,
3522
- appName
3533
+ code,
3534
+ errorCode,
3535
+ statusCode: errorCode,
3536
+ appName,
3537
+ originalError: dmkErr
3523
3538
  });
3524
3539
  }
3525
3540
  }
@@ -3938,6 +3953,22 @@ var DeviceApps = class {
3938
3953
  async install(appName, onProgress, options) {
3939
3954
  if (!appName) throw new Error("DeviceApps.install: appName is required");
3940
3955
  debugLog("[DeviceApps] install:", appName);
3956
+ const refreshAction = this._dmk.executeDeviceAction({
3957
+ sessionId: this._sessionId,
3958
+ deviceAction: new this._ledgerKit.GetDeviceMetadataDeviceAction({
3959
+ input: {
3960
+ useSecureChannel: true,
3961
+ forceUpdate: true,
3962
+ unlockTimeout: options?.unlockTimeout
3963
+ }
3964
+ })
3965
+ });
3966
+ await deviceActionToPromise(
3967
+ refreshAction,
3968
+ this.onInteraction,
3969
+ INSTALL_TIMEOUT_MS,
3970
+ this.onRegisterCanceller
3971
+ );
3941
3972
  const action = this._dmk.executeDeviceAction({
3942
3973
  sessionId: this._sessionId,
3943
3974
  deviceAction: new this._ledgerKit.InstallOrUpdateAppsDeviceAction({