@onekeyfe/hwk-trezor-adapter 1.2.3-alpha.3 → 1.2.3-alpha.4

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
@@ -2153,19 +2153,23 @@ var _TrezorAdapter = class _TrezorAdapter {
2153
2153
  return _hwkadaptercore.success.call(void 0, result);
2154
2154
  } catch (error) {
2155
2155
  if (signal.aborted) {
2156
- if (pendingBindingRequestId)
2156
+ if (pendingBindingRequestId) {
2157
2157
  this._emitter.emit(_hwkadaptercore.UI_REQUEST.DEVICE_BINDING_STATUS, {
2158
2158
  type: _hwkadaptercore.UI_REQUEST.DEVICE_BINDING_STATUS,
2159
2159
  payload: { selectionRequestId: pendingBindingRequestId, status: "cancelled" }
2160
2160
  });
2161
+ pendingBindingRequestId = void 0;
2162
+ }
2161
2163
  return this._errorToFailure(error);
2162
2164
  }
2163
2165
  const code = _TrezorAdapter._errorCode(error);
2164
- if (pendingBindingRequestId && !(allowRetry && (passphraseState || useEmptyPassphrase === true) && _TrezorAdapter._isStaleSessionError(code))) {
2166
+ const willRetryStaleSession = allowRetry && (passphraseState || useEmptyPassphrase === true) && _TrezorAdapter._isStaleSessionError(code);
2167
+ if (pendingBindingRequestId && !willRetryStaleSession) {
2165
2168
  this._emitter.emit(_hwkadaptercore.UI_REQUEST.DEVICE_BINDING_STATUS, {
2166
2169
  type: _hwkadaptercore.UI_REQUEST.DEVICE_BINDING_STATUS,
2167
2170
  payload: { selectionRequestId: pendingBindingRequestId, status: "failed" }
2168
2171
  });
2172
+ pendingBindingRequestId = void 0;
2169
2173
  }
2170
2174
  const ambiguousTransportFailure = code === _hwkadaptercore.HardwareErrorCode.DeviceDisconnected || code === _hwkadaptercore.HardwareErrorCode.OperationTimeout || code === _hwkadaptercore.HardwareErrorCode.TransportError;
2171
2175
  if (operationId && ambiguousTransportFailure) {
@@ -2196,10 +2200,12 @@ var _TrezorAdapter = class _TrezorAdapter {
2196
2200
  );
2197
2201
  }
2198
2202
  }
2199
- if (allowRetry && (passphraseState || useEmptyPassphrase === true) && _TrezorAdapter._isStaleSessionError(code)) {
2203
+ if (willRetryStaleSession) {
2200
2204
  if (passphraseState) {
2201
2205
  this._forgetVerifiedPassphraseSession(connectId, passphraseState);
2202
2206
  }
2207
+ const retryBindingRequestId = pendingBindingRequestId;
2208
+ pendingBindingRequestId = void 0;
2203
2209
  return await this._callWithRetry(
2204
2210
  connectId,
2205
2211
  methodName,
@@ -2209,7 +2215,7 @@ var _TrezorAdapter = class _TrezorAdapter {
2209
2215
  false,
2210
2216
  signal,
2211
2217
  operationId,
2212
- pendingBindingRequestId,
2218
+ retryBindingRequestId,
2213
2219
  bundleContext
2214
2220
  );
2215
2221
  }
@@ -2221,6 +2227,16 @@ var _TrezorAdapter = class _TrezorAdapter {
2221
2227
  return this._errorToFailure(error);
2222
2228
  } finally {
2223
2229
  restorePassphraseRequestContext();
2230
+ if (pendingBindingRequestId) {
2231
+ this._emitter.emit(_hwkadaptercore.UI_REQUEST.DEVICE_BINDING_STATUS, {
2232
+ type: _hwkadaptercore.UI_REQUEST.DEVICE_BINDING_STATUS,
2233
+ payload: {
2234
+ selectionRequestId: pendingBindingRequestId,
2235
+ status: signal.aborted ? "cancelled" : "failed"
2236
+ }
2237
+ });
2238
+ pendingBindingRequestId = void 0;
2239
+ }
2224
2240
  }
2225
2241
  }
2226
2242
  async _ensureSession(connectId, signal, transportType) {