@onekeyfe/hwk-ledger-adapter 1.2.10-alpha.3 → 1.2.10
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.d.mts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +9 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -225,7 +225,7 @@ function isDeviceNotAdvertisingError(err) {
|
|
|
225
225
|
if (!err || typeof err !== "object") return false;
|
|
226
226
|
return err._tag === ERROR_TAG.DeviceNotAdvertising;
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function isBleBondInvalidError(err) {
|
|
229
229
|
const pending = [err];
|
|
230
230
|
const seen = /* @__PURE__ */ new Set();
|
|
231
231
|
while (pending.length > 0) {
|
|
@@ -233,28 +233,19 @@ function someErrorInChain(err, matches) {
|
|
|
233
233
|
if (candidate && typeof candidate === "object" && !seen.has(candidate)) {
|
|
234
234
|
seen.add(candidate);
|
|
235
235
|
const e = candidate;
|
|
236
|
-
if (
|
|
236
|
+
if (e._tag === ERROR_TAG.PeerRemovedPairing || e.iosErrorCode === 14 || e.attErrorCode === 5 || e.nativeErrorDomain === "CBErrorDomain" && e.nativeErrorCode === 14) {
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
const reason = typeof e.reason === "string" ? e.reason : "";
|
|
240
|
+
const message = typeof e.message === "string" ? e.message : "";
|
|
241
|
+
if (/\bCBErrorDomain:14(?:\s|$)/.test(message) || reason.includes("Peer removed pairing information") || reason.includes("GATT_INSUF_AUTHENTICATION")) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
237
244
|
pending.push(e.originalError, e.err);
|
|
238
245
|
}
|
|
239
246
|
}
|
|
240
247
|
return false;
|
|
241
248
|
}
|
|
242
|
-
function isBleBondInvalidError(err) {
|
|
243
|
-
return someErrorInChain(err, (e) => {
|
|
244
|
-
if (e._tag === ERROR_TAG.PeerRemovedPairing || e.iosErrorCode === 14 || e.attErrorCode === 5 || e.nativeErrorDomain === "CBErrorDomain" && e.nativeErrorCode === 14) {
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
const reason = typeof e.reason === "string" ? e.reason : "";
|
|
248
|
-
const message = typeof e.message === "string" ? e.message : "";
|
|
249
|
-
return /\bCBErrorDomain:14(?:\s|$)/.test(message) || /'\$onekey-3p-ble-subscribe': Error: status: 3$/.test(message) || reason.includes("Peer removed pairing information") || reason.includes("GATT_INSUF_AUTHENTICATION");
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
function isBleNotAdvertisingTimeoutError(err) {
|
|
253
|
-
return someErrorInChain(
|
|
254
|
-
err,
|
|
255
|
-
(e) => typeof e.message === "string" && /connect timed out after \d+ms: device not advertising$/.test(e.message)
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
249
|
var PAIRING_FAILURE_TAGS = /* @__PURE__ */ new Set([
|
|
259
250
|
ERROR_TAG.BlePairingTimeout,
|
|
260
251
|
ERROR_TAG.BleGattBondingFailed,
|
|
@@ -948,7 +939,6 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
948
939
|
this._operations = new OperationRegistry({
|
|
949
940
|
vendor: "ledger",
|
|
950
941
|
onEnded: (operation, reason) => {
|
|
951
|
-
debugLog("[LedgerAdapter] operation ended", { operationId: operation.operationId, reason });
|
|
952
942
|
this._discardPendingBinding(this._pendingOperationBindings.get(operation.operationId));
|
|
953
943
|
this._pendingOperationBindings.delete(operation.operationId);
|
|
954
944
|
this.emitter.emit(SDK.OPERATION_ENDED, {
|
|
@@ -5063,11 +5053,6 @@ async function _getDeviceApps(ctx, sessionId) {
|
|
|
5063
5053
|
};
|
|
5064
5054
|
return apps;
|
|
5065
5055
|
}
|
|
5066
|
-
function describeCaller(error) {
|
|
5067
|
-
return (error.stack ?? "").split("\n").slice(2, 6).map(
|
|
5068
|
-
(frame) => frame.trim().replace(/^at /, "").replace(/ \(.*\)$/, "")
|
|
5069
|
-
).join(" <- ");
|
|
5070
|
-
}
|
|
5071
5056
|
var LedgerConnectorBase = class {
|
|
5072
5057
|
constructor(createTransport, options) {
|
|
5073
5058
|
this._deviceManager = null;
|
|
@@ -5303,7 +5288,6 @@ var LedgerConnectorBase = class {
|
|
|
5303
5288
|
_tag: ERROR_TAG.PeerRemovedPairing
|
|
5304
5289
|
});
|
|
5305
5290
|
}
|
|
5306
|
-
if (isBleNotAdvertisingTimeoutError(err)) throwNotAdvertising();
|
|
5307
5291
|
const tag = err?._tag;
|
|
5308
5292
|
if (isKnownConnectionTag(tag) && !isConnectionOpeningTag(tag)) {
|
|
5309
5293
|
throw err;
|
|
@@ -5328,7 +5312,6 @@ var LedgerConnectorBase = class {
|
|
|
5328
5312
|
}
|
|
5329
5313
|
async disconnect(sessionId) {
|
|
5330
5314
|
if (!this._deviceManager) return;
|
|
5331
|
-
debugLog("[DMK] disconnect requested", { sessionId, caller: describeCaller(new Error()) });
|
|
5332
5315
|
const deviceId = this._deviceManager.getDeviceId(sessionId);
|
|
5333
5316
|
this._signerManager?.invalidate(sessionId);
|
|
5334
5317
|
this._unwatchSessionState(sessionId);
|