@onekeyfe/hwk-keystone-adapter 1.2.3-alpha.1 → 1.2.3-alpha.2

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
@@ -170,6 +170,11 @@ function fromSdkUr(ur) {
170
170
  return { urType: ur.type, urData: ur.cbor.toString("hex") };
171
171
  }
172
172
  function splitSignature65(hex) {
173
+ if (hex.length !== 130) {
174
+ throw new Error(
175
+ `Keystone returned a ${hex.length / 2}-byte signature; expected 65 bytes (r|s|v)`
176
+ );
177
+ }
173
178
  return { r: hex.slice(0, 64), s: hex.slice(64, 128), v: hex.slice(128) };
174
179
  }
175
180
  function requireBip32MasterFingerprint(value) {
@@ -583,12 +588,8 @@ function placeholderDeviceInfo() {
583
588
  var COLD_START_JOB_LABEL = "keystone-cold-start";
584
589
  var KEYSTONE_USB_REATTACH_PROBE_ATTEMPTS = 4;
585
590
  var KEYSTONE_USB_REATTACH_PROBE_INTERVAL_MS = 500;
586
- function resolveHardwareOperationTarget(positionalTargetId, interactionId) {
587
- const result = (0, import_hwk_adapter_core3.resolveHardwareOperationTarget)(
588
- positionalTargetId,
589
- interactionId,
590
- "keystone"
591
- );
591
+ function resolveHardwareOperationTarget(positionalTargetId, operationId) {
592
+ const result = (0, import_hwk_adapter_core3.resolveHardwareOperationTarget)(positionalTargetId, operationId, "keystone");
592
593
  return result;
593
594
  }
594
595
  function waitForKeystoneUsbReattachProbe() {
@@ -596,10 +597,8 @@ function waitForKeystoneUsbReattachProbe() {
596
597
  setTimeout(resolve, KEYSTONE_USB_REATTACH_PROBE_INTERVAL_MS);
597
598
  });
598
599
  }
599
- function isKeystoneUsbReconnectableError(error) {
600
- if (!error || typeof error !== "object") return false;
601
- const { code } = error;
602
- return code === import_hwk_adapter_core3.HardwareErrorCode.DeviceNotFound || code === import_hwk_adapter_core3.HardwareErrorCode.DeviceDisconnected;
600
+ function getKeystoneJobId(connectId, deviceId) {
601
+ return (0, import_hwk_adapter_core3.isHardwareOperationId)(connectId) ? connectId : deviceId || connectId || COLD_START_JOB_LABEL;
603
602
  }
604
603
  var BIP44_COIN_TYPE_TO_CHAIN = {
605
604
  60: "evm",
@@ -615,20 +614,20 @@ var KeystoneAdapter = class _KeystoneAdapter {
615
614
  constructor(options) {
616
615
  this.vendor = "keystone";
617
616
  this.emitter = new import_hwk_adapter_core3.TypedEventEmitter();
618
- this._interactionRoutes = /* @__PURE__ */ new Map();
619
- this._interactions = new import_hwk_adapter_core3.InteractionRegistry({
617
+ this._operationRoutes = /* @__PURE__ */ new Map();
618
+ this._operations = new import_hwk_adapter_core3.OperationRegistry({
620
619
  vendor: "keystone",
621
- onEnded: (interaction, reason) => {
622
- const route = this._interactionRoutes.get(interaction.connectId);
623
- if (route?.interactionId === interaction.interactionId) {
624
- this._interactionRoutes.delete(interaction.connectId);
620
+ onEnded: (operation, reason) => {
621
+ const route = this._operationRoutes.get(operation.connectId);
622
+ if (route?.operationId === operation.operationId) {
623
+ this._operationRoutes.delete(operation.connectId);
625
624
  }
626
- this.emitter.emit(import_hwk_adapter_core3.SDK.INTERACTION_ENDED, {
627
- type: import_hwk_adapter_core3.SDK.INTERACTION_ENDED,
628
- payload: { interactionId: interaction.interactionId, reason }
625
+ this.emitter.emit(import_hwk_adapter_core3.SDK.OPERATION_ENDED, {
626
+ type: import_hwk_adapter_core3.SDK.OPERATION_ENDED,
627
+ payload: { operationId: operation.operationId, reason }
629
628
  });
630
629
  if (reason === "timeout") {
631
- this._releaseInteractionConnection(interaction).catch(() => void 0);
630
+ this._releaseOperationConnection(operation).catch(() => void 0);
632
631
  }
633
632
  }
634
633
  });
@@ -644,8 +643,8 @@ var KeystoneAdapter = class _KeystoneAdapter {
644
643
  this._handleUsbDisconnect = ({ connectId }) => {
645
644
  const record = Array.from(this._devices.values()).find((item) => item.usbSessionId === connectId);
646
645
  if (!record) return;
647
- this._interactions.endByConnectionKey(connectId, "disconnect");
648
- this._interactions.endByConnectionKey(record.connectId, "disconnect");
646
+ this._operations.endByConnectionKey(connectId, "disconnect");
647
+ this._operations.endByConnectionKey(record.connectId, "disconnect");
649
648
  record.usbSessionId = void 0;
650
649
  const info = toDeviceInfo(record);
651
650
  if (record.qrSynced) {
@@ -663,10 +662,10 @@ var KeystoneAdapter = class _KeystoneAdapter {
663
662
  // there's exactly one implementation of each chain's address logic.
664
663
  // ---------------------------------------------------------------------------
665
664
  this.allNetworkGetAddress = async (connectId, deviceId, params) => {
666
- const operationTarget = resolveHardwareOperationTarget(connectId, params.interactionId);
665
+ const operationTarget = resolveHardwareOperationTarget(connectId, params.operationId);
667
666
  if (!operationTarget.success) return operationTarget;
668
667
  const effectiveConnectId = operationTarget.payload.targetId ?? "";
669
- const { interactionId } = operationTarget.payload;
668
+ const { operationId } = operationTarget.payload;
670
669
  try {
671
670
  const prefetched = await this._prefetchAllNetworkAccounts(
672
671
  effectiveConnectId,
@@ -683,7 +682,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
683
682
  const commonArgs = {
684
683
  path: item.path,
685
684
  showOnDevice: item.showOnDevice,
686
- interactionId
685
+ operationId
687
686
  };
688
687
  switch (method) {
689
688
  case "evmGetAddress":
@@ -752,7 +751,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
752
751
  return Promise.resolve();
753
752
  }
754
753
  async dispose() {
755
- this._interactions.endAll("runtime-reset");
754
+ this._operations.endAll("runtime-reset");
756
755
  this._uiRegistry.cancel();
757
756
  this._jobQueue.clear();
758
757
  this._searchDeviceTargets.clear();
@@ -787,10 +786,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
787
786
  }
788
787
  const known = Array.from(this._devices.values()).map(toDeviceInfo);
789
788
  if (options?.transportType === "qr") {
790
- const searchTargetId = (0, import_hwk_adapter_core3.createHardwareSearchTargetId)({
791
- vendor: "keystone",
792
- connectionType: "qr"
793
- });
789
+ const searchTargetId = (0, import_hwk_adapter_core3.createHardwareSearchTargetId)("keystone");
794
790
  this._searchDeviceTargets.set(searchTargetId, "qr");
795
791
  return [
796
792
  {
@@ -838,7 +834,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
838
834
  async _resetUsbSessions() {
839
835
  await this._runUsbTeardown(async () => {
840
836
  await this._usbConnectTail;
841
- this._interactions.endAll("runtime-reset");
837
+ this._operations.endAll("runtime-reset");
842
838
  if (!this._usbConnector) return;
843
839
  const sessionIds = new Set(
844
840
  Array.from(this._devices.values()).map((record) => record.usbSessionId).filter((sessionId) => Boolean(sessionId))
@@ -917,18 +913,18 @@ var KeystoneAdapter = class _KeystoneAdapter {
917
913
  }
918
914
  if (!connected.success) return connected;
919
915
  const record = this._devices.get(connected.payload.deviceId);
920
- this._interactions.endByConnectionKey(connected.payload.connectId, "explicit");
921
- const interaction = this._interactions.create({
916
+ this._operations.endByConnectionKey(connected.payload.connectId, "explicit");
917
+ const operation = this._operations.create({
922
918
  searchTargetId,
923
919
  connectId: connected.payload.connectId,
924
920
  device: connected.payload,
925
921
  connectionKeys: selectedConnectionType === "usb" && record?.usbSessionId ? [record.usbSessionId] : []
926
922
  });
927
- this._interactionRoutes.set(connected.payload.connectId, {
928
- interactionId: interaction.interactionId,
923
+ this._operationRoutes.set(connected.payload.connectId, {
924
+ operationId: operation.operationId,
929
925
  connectionType: selectedConnectionType
930
926
  });
931
- return (0, import_hwk_adapter_core3.success)(interaction.interactionId);
927
+ return (0, import_hwk_adapter_core3.success)(operation.operationId);
932
928
  } catch (err) {
933
929
  return this._errorToFailure(err);
934
930
  }
@@ -940,25 +936,25 @@ var KeystoneAdapter = class _KeystoneAdapter {
940
936
  * QR-only (if it was ever QR-synced) or removes it entirely (pure-USB
941
937
  * wallet that was never seen over QR) — see §4.2 of the design doc.
942
938
  */
943
- async releaseInteraction(interactionId) {
944
- const interaction = this._interactions.find(interactionId);
945
- if (!interaction) {
946
- this._interactions.resolve(interactionId);
939
+ async releaseOperation(operationId) {
940
+ const operation = this._operations.find(operationId);
941
+ if (!operation) {
942
+ this._operations.resolve(operationId);
947
943
  return;
948
944
  }
949
- const endedInteraction = this._interactions.end(interactionId, "explicit");
950
- if (!endedInteraction) return;
951
- await this._releaseInteractionConnection(endedInteraction);
945
+ const endedOperation = this._operations.end(operationId, "explicit");
946
+ if (!endedOperation) return;
947
+ await this._releaseOperationConnection(endedOperation);
952
948
  }
953
- async _releaseInteractionConnection(interaction) {
954
- const { connectId } = interaction;
949
+ async _releaseOperationConnection(operation) {
950
+ const { connectId } = operation;
955
951
  let record;
956
952
  try {
957
953
  record = this._resolveTarget(connectId).record;
958
954
  } catch {
959
955
  return;
960
956
  }
961
- if (!record?.usbSessionId || !interaction.connectionKeys.includes(record.usbSessionId)) {
957
+ if (!record?.usbSessionId || !operation.connectionKeys.includes(record.usbSessionId)) {
962
958
  return;
963
959
  }
964
960
  const { usbSessionId } = record;
@@ -972,9 +968,9 @@ var KeystoneAdapter = class _KeystoneAdapter {
972
968
  this._handleUsbDisconnect({ connectId: usbSessionId });
973
969
  });
974
970
  }
975
- getDeviceInfo(connectIdOrInteractionId, deviceId) {
971
+ getDeviceInfo(connectIdOrOperationId, deviceId) {
976
972
  try {
977
- const connectId = (0, import_hwk_adapter_core3.isHardwareInteractionId)(connectIdOrInteractionId) ? this._interactions.resolve(connectIdOrInteractionId).connectId : connectIdOrInteractionId;
973
+ const connectId = (0, import_hwk_adapter_core3.isHardwareOperationId)(connectIdOrOperationId) ? this._operations.resolve(connectIdOrOperationId).connectId : connectIdOrOperationId;
978
974
  const { record } = this._resolveTarget(connectId, deviceId);
979
975
  if (!record) {
980
976
  return Promise.resolve(
@@ -989,21 +985,26 @@ var KeystoneAdapter = class _KeystoneAdapter {
989
985
  return Promise.resolve(this._errorToFailure(err));
990
986
  }
991
987
  }
992
- getSupportedChains() {
993
- return ["evm", "btc", "sol", "tron"];
994
- }
995
988
  cancel(connectId) {
996
989
  const reason = (0, import_hwk_adapter_core3.createHwkError)({
997
990
  code: import_hwk_adapter_core3.HardwareErrorCode.UserAborted,
998
991
  message: "User aborted operation"
999
992
  });
1000
- this._uiRegistry.cancel();
1001
993
  const activeJobId = this._jobQueue.getActiveJob()?.deviceId;
1002
- const targetId = connectId ?? activeJobId;
1003
- this._jobQueue.cancelActiveAndPending(
1004
- targetId && (0, import_hwk_adapter_core3.isHardwareInteractionId)(targetId) ? activeJobId ?? targetId : targetId,
1005
- reason
1006
- );
994
+ if (connectId) {
995
+ if (!activeJobId || activeJobId !== connectId && activeJobId !== this._walletIdFromIdentifier(connectId)) {
996
+ this._jobQueue.cancelActiveAndPending(connectId, reason);
997
+ const walletId = this._walletIdFromIdentifier(connectId);
998
+ if (walletId && walletId !== connectId) {
999
+ this._jobQueue.cancelActiveAndPending(walletId, reason);
1000
+ }
1001
+ return;
1002
+ }
1003
+ this._jobQueue.cancelActiveAndPending(activeJobId, reason);
1004
+ } else {
1005
+ this._jobQueue.cancelActiveAndPending(void 0, reason);
1006
+ }
1007
+ this._uiRegistry.cancel();
1007
1008
  }
1008
1009
  getChainFingerprint(connectId, deviceId, chain) {
1009
1010
  try {
@@ -1066,7 +1067,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
1066
1067
  // EVM
1067
1068
  // ---------------------------------------------------------------------------
1068
1069
  async evmGetAddress(connectIdArg, deviceIdArg, paramsArg, book) {
1069
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1070
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1070
1071
  if (!operationTarget.success) return operationTarget;
1071
1072
  const connectId = operationTarget.payload.targetId;
1072
1073
  const deviceId = deviceIdArg ?? void 0;
@@ -1082,37 +1083,34 @@ var KeystoneAdapter = class _KeystoneAdapter {
1082
1083
  );
1083
1084
  }
1084
1085
  try {
1085
- return await this._jobQueue.enqueue(
1086
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1087
- async (signal) => {
1088
- const { account } = await this._fetchAccount(
1089
- connectId,
1090
- deviceId,
1091
- "evm",
1092
- accountPath,
1093
- signal,
1094
- { book }
1095
- );
1096
- _KeystoneAdapter._throwIfAborted(signal);
1097
- if (!account.extendedPublicKey) {
1098
- throw (0, import_hwk_adapter_core3.createHwkError)({
1099
- code: import_hwk_adapter_core3.HardwareErrorCode.MethodNotSupported,
1100
- message: "Keystone did not return an extended public key for this account path"
1101
- });
1102
- }
1103
- const address = this.urEngine.deriveEvmAddressFromXpub(
1104
- account.extendedPublicKey,
1105
- relativeDerivePath
1106
- );
1107
- return (0, import_hwk_adapter_core3.success)({ address, path: normalizePath(params.path) });
1086
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1087
+ const { account } = await this._fetchAccount(
1088
+ connectId,
1089
+ deviceId,
1090
+ "evm",
1091
+ accountPath,
1092
+ signal,
1093
+ { book }
1094
+ );
1095
+ _KeystoneAdapter._throwIfAborted(signal);
1096
+ if (!account.extendedPublicKey) {
1097
+ throw (0, import_hwk_adapter_core3.createHwkError)({
1098
+ code: import_hwk_adapter_core3.HardwareErrorCode.MethodNotSupported,
1099
+ message: "Keystone did not return an extended public key for this account path"
1100
+ });
1108
1101
  }
1109
- );
1102
+ const address = this.urEngine.deriveEvmAddressFromXpub(
1103
+ account.extendedPublicKey,
1104
+ relativeDerivePath
1105
+ );
1106
+ return (0, import_hwk_adapter_core3.success)({ address, path: normalizePath(params.path) });
1107
+ });
1110
1108
  } catch (err) {
1111
1109
  return this._errorToFailure(err);
1112
1110
  }
1113
1111
  }
1114
1112
  async evmSignTransaction(connectIdArg, deviceIdArg, paramsArg) {
1115
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1113
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1116
1114
  if (!operationTarget.success) return operationTarget;
1117
1115
  const connectId = operationTarget.payload.targetId;
1118
1116
  const deviceId = deviceIdArg ?? void 0;
@@ -1131,45 +1129,42 @@ var KeystoneAdapter = class _KeystoneAdapter {
1131
1129
  const rawTxHex = (0, import_hwk_adapter_core3.stripHex)(params.serializedTx);
1132
1130
  const path = normalizePath(params.path);
1133
1131
  try {
1134
- return await this._jobQueue.enqueue(
1135
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1136
- async (signal) => {
1137
- const { record } = await this._ensureWalletKnown(connectId, deviceId, "evm", signal);
1138
- _KeystoneAdapter._throwIfAborted(signal);
1139
- const requestId = (0, import_uuid2.v4)();
1140
- const dataType = parseInt(rawTxHex.slice(0, 2), 16) < 192 ? "typedTransaction" : "transaction";
1141
- const requestUr = this.urEngine.buildEthSignRequest({
1142
- requestId,
1143
- unsignedTxHex: rawTxHex,
1144
- dataType,
1145
- path,
1146
- xfp: record.masterFingerprint,
1147
- chainId: params.chainId
1148
- });
1149
- const responseUr = await this._resolveUr(
1150
- record,
1151
- requestUr,
1152
- true,
1153
- connectId,
1154
- signal,
1155
- "evmSignTransaction"
1156
- );
1157
- _KeystoneAdapter._throwIfAborted(signal);
1158
- const sig = this.urEngine.parseEthSignature(responseUr);
1159
- _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1160
- return (0, import_hwk_adapter_core3.success)({
1161
- v: (0, import_hwk_adapter_core3.ensure0x)(sig.v),
1162
- r: (0, import_hwk_adapter_core3.ensure0x)(sig.r),
1163
- s: (0, import_hwk_adapter_core3.ensure0x)(sig.s)
1164
- });
1165
- }
1166
- );
1132
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1133
+ const { record } = await this._ensureWalletKnown(connectId, deviceId, "evm", signal);
1134
+ _KeystoneAdapter._throwIfAborted(signal);
1135
+ const requestId = (0, import_uuid2.v4)();
1136
+ const dataType = parseInt(rawTxHex.slice(0, 2), 16) < 192 ? "typedTransaction" : "transaction";
1137
+ const requestUr = this.urEngine.buildEthSignRequest({
1138
+ requestId,
1139
+ unsignedTxHex: rawTxHex,
1140
+ dataType,
1141
+ path,
1142
+ xfp: record.masterFingerprint,
1143
+ chainId: params.chainId
1144
+ });
1145
+ const responseUr = await this._resolveUr(
1146
+ record,
1147
+ requestUr,
1148
+ true,
1149
+ connectId,
1150
+ signal,
1151
+ "evmSignTransaction"
1152
+ );
1153
+ _KeystoneAdapter._throwIfAborted(signal);
1154
+ const sig = this.urEngine.parseEthSignature(responseUr);
1155
+ _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1156
+ return (0, import_hwk_adapter_core3.success)({
1157
+ v: (0, import_hwk_adapter_core3.ensure0x)(sig.v),
1158
+ r: (0, import_hwk_adapter_core3.ensure0x)(sig.r),
1159
+ s: (0, import_hwk_adapter_core3.ensure0x)(sig.s)
1160
+ });
1161
+ });
1167
1162
  } catch (err) {
1168
1163
  return this._errorToFailure(err);
1169
1164
  }
1170
1165
  }
1171
1166
  async evmSignMessage(connectIdArg, deviceIdArg, paramsArg) {
1172
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1167
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1173
1168
  if (!operationTarget.success) return operationTarget;
1174
1169
  const connectId = operationTarget.payload.targetId;
1175
1170
  const deviceId = deviceIdArg ?? void 0;
@@ -1184,40 +1179,37 @@ var KeystoneAdapter = class _KeystoneAdapter {
1184
1179
  const messageHex = params.hex ? (0, import_hwk_adapter_core3.stripHex)(params.message) : Buffer.from(params.message, "utf8").toString("hex");
1185
1180
  const path = normalizePath(params.path);
1186
1181
  try {
1187
- return await this._jobQueue.enqueue(
1188
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1189
- async (signal) => {
1190
- const { record } = await this._ensureWalletKnown(connectId, deviceId, "evm", signal);
1191
- _KeystoneAdapter._throwIfAborted(signal);
1192
- const requestId = (0, import_uuid2.v4)();
1193
- const requestUr = this.urEngine.buildEthSignRequest({
1194
- requestId,
1195
- unsignedTxHex: messageHex,
1196
- dataType: "personalMessage",
1197
- path,
1198
- xfp: record.masterFingerprint,
1199
- chainId: params.chainId
1200
- });
1201
- const responseUr = await this._resolveUr(
1202
- record,
1203
- requestUr,
1204
- true,
1205
- connectId,
1206
- signal,
1207
- "evmSignMessage"
1208
- );
1209
- _KeystoneAdapter._throwIfAborted(signal);
1210
- const sig = this.urEngine.parseEthSignature(responseUr);
1211
- _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1212
- return (0, import_hwk_adapter_core3.success)({ signature: (0, import_hwk_adapter_core3.ensure0x)(sig.r + sig.s + sig.v) });
1213
- }
1214
- );
1182
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1183
+ const { record } = await this._ensureWalletKnown(connectId, deviceId, "evm", signal);
1184
+ _KeystoneAdapter._throwIfAborted(signal);
1185
+ const requestId = (0, import_uuid2.v4)();
1186
+ const requestUr = this.urEngine.buildEthSignRequest({
1187
+ requestId,
1188
+ unsignedTxHex: messageHex,
1189
+ dataType: "personalMessage",
1190
+ path,
1191
+ xfp: record.masterFingerprint,
1192
+ chainId: params.chainId
1193
+ });
1194
+ const responseUr = await this._resolveUr(
1195
+ record,
1196
+ requestUr,
1197
+ true,
1198
+ connectId,
1199
+ signal,
1200
+ "evmSignMessage"
1201
+ );
1202
+ _KeystoneAdapter._throwIfAborted(signal);
1203
+ const sig = this.urEngine.parseEthSignature(responseUr);
1204
+ _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1205
+ return (0, import_hwk_adapter_core3.success)({ signature: (0, import_hwk_adapter_core3.ensure0x)(sig.r + sig.s + sig.v) });
1206
+ });
1215
1207
  } catch (err) {
1216
1208
  return this._errorToFailure(err);
1217
1209
  }
1218
1210
  }
1219
1211
  async evmSignTypedData(connectIdArg, deviceIdArg, paramsArg) {
1220
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1212
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1221
1213
  if (!operationTarget.success) return operationTarget;
1222
1214
  const connectId = operationTarget.payload.targetId;
1223
1215
  const deviceId = deviceIdArg ?? void 0;
@@ -1233,37 +1225,37 @@ var KeystoneAdapter = class _KeystoneAdapter {
1233
1225
  "Keystone always displays the full EIP-712 payload for on-device review \u2014 pre-hashed signing is not supported"
1234
1226
  );
1235
1227
  }
1236
- const signDataHex = Buffer.from(JSON.stringify(params.data), "utf8").toString("hex");
1228
+ const signDataHex = Buffer.from(
1229
+ params.dataJson ?? JSON.stringify(params.data),
1230
+ "utf8"
1231
+ ).toString("hex");
1237
1232
  const path = normalizePath(params.path);
1238
1233
  try {
1239
- return await this._jobQueue.enqueue(
1240
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1241
- async (signal) => {
1242
- const { record } = await this._ensureWalletKnown(connectId, deviceId, "evm", signal);
1243
- _KeystoneAdapter._throwIfAborted(signal);
1244
- const requestId = (0, import_uuid2.v4)();
1245
- const requestUr = this.urEngine.buildEthSignRequest({
1246
- requestId,
1247
- unsignedTxHex: signDataHex,
1248
- dataType: "typedData",
1249
- path,
1250
- xfp: record.masterFingerprint,
1251
- chainId: params.chainId
1252
- });
1253
- const responseUr = await this._resolveUr(
1254
- record,
1255
- requestUr,
1256
- true,
1257
- connectId,
1258
- signal,
1259
- "evmSignTypedData"
1260
- );
1261
- _KeystoneAdapter._throwIfAborted(signal);
1262
- const sig = this.urEngine.parseEthSignature(responseUr);
1263
- _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1264
- return (0, import_hwk_adapter_core3.success)({ signature: (0, import_hwk_adapter_core3.ensure0x)(sig.r + sig.s + sig.v) });
1265
- }
1266
- );
1234
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1235
+ const { record } = await this._ensureWalletKnown(connectId, deviceId, "evm", signal);
1236
+ _KeystoneAdapter._throwIfAborted(signal);
1237
+ const requestId = (0, import_uuid2.v4)();
1238
+ const requestUr = this.urEngine.buildEthSignRequest({
1239
+ requestId,
1240
+ unsignedTxHex: signDataHex,
1241
+ dataType: "typedData",
1242
+ path,
1243
+ xfp: record.masterFingerprint,
1244
+ chainId: params.chainId
1245
+ });
1246
+ const responseUr = await this._resolveUr(
1247
+ record,
1248
+ requestUr,
1249
+ true,
1250
+ connectId,
1251
+ signal,
1252
+ "evmSignTypedData"
1253
+ );
1254
+ _KeystoneAdapter._throwIfAborted(signal);
1255
+ const sig = this.urEngine.parseEthSignature(responseUr);
1256
+ _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1257
+ return (0, import_hwk_adapter_core3.success)({ signature: (0, import_hwk_adapter_core3.ensure0x)(sig.r + sig.s + sig.v) });
1258
+ });
1267
1259
  } catch (err) {
1268
1260
  return this._errorToFailure(err);
1269
1261
  }
@@ -1275,7 +1267,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
1275
1267
  // PSBT construction. Both are real, bounded follow-ups, not silent gaps.
1276
1268
  // ---------------------------------------------------------------------------
1277
1269
  async btcGetAddress(connectIdArg, deviceIdArg, paramsArg, book) {
1278
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1270
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1279
1271
  if (!operationTarget.success) return operationTarget;
1280
1272
  const connectId = operationTarget.payload.targetId;
1281
1273
  const deviceId = deviceIdArg ?? void 0;
@@ -1308,32 +1300,29 @@ var KeystoneAdapter = class _KeystoneAdapter {
1308
1300
  return (0, import_hwk_adapter_core3.failure)(import_hwk_adapter_core3.HardwareErrorCode.DevicePathForbidden, KEYSTONE_BTC_ACCOUNT_FORBIDDEN_MESSAGE);
1309
1301
  }
1310
1302
  try {
1311
- return await this._jobQueue.enqueue(
1312
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1313
- async (signal) => {
1314
- const { account } = await this._fetchAccount(
1315
- connectId,
1316
- deviceId,
1317
- "btc",
1318
- accountPath,
1319
- signal,
1320
- { book }
1321
- );
1322
- _KeystoneAdapter._throwIfAborted(signal);
1323
- if (!account.extendedPublicKey) {
1324
- throw (0, import_hwk_adapter_core3.createHwkError)({
1325
- code: import_hwk_adapter_core3.HardwareErrorCode.MethodNotSupported,
1326
- message: "Keystone did not return an extended public key for this account path"
1327
- });
1328
- }
1329
- const address = this.urEngine.deriveBtcAddressFromXpub(
1330
- account.extendedPublicKey,
1331
- relativeDerivePath,
1332
- scriptType
1333
- );
1334
- return (0, import_hwk_adapter_core3.success)({ address, path: normalizedPath });
1303
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1304
+ const { account } = await this._fetchAccount(
1305
+ connectId,
1306
+ deviceId,
1307
+ "btc",
1308
+ accountPath,
1309
+ signal,
1310
+ { book }
1311
+ );
1312
+ _KeystoneAdapter._throwIfAborted(signal);
1313
+ if (!account.extendedPublicKey) {
1314
+ throw (0, import_hwk_adapter_core3.createHwkError)({
1315
+ code: import_hwk_adapter_core3.HardwareErrorCode.MethodNotSupported,
1316
+ message: "Keystone did not return an extended public key for this account path"
1317
+ });
1335
1318
  }
1336
- );
1319
+ const address = this.urEngine.deriveBtcAddressFromXpub(
1320
+ account.extendedPublicKey,
1321
+ relativeDerivePath,
1322
+ scriptType
1323
+ );
1324
+ return (0, import_hwk_adapter_core3.success)({ address, path: normalizedPath });
1325
+ });
1337
1326
  } catch (err) {
1338
1327
  return this._errorToFailure(err);
1339
1328
  }
@@ -1348,7 +1337,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
1348
1337
  * this package doesn't wire in.
1349
1338
  */
1350
1339
  async btcGetPublicKey(connectIdArg, deviceIdArg, paramsArg, book) {
1351
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1340
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1352
1341
  if (!operationTarget.success) return operationTarget;
1353
1342
  const connectId = operationTarget.payload.targetId;
1354
1343
  const deviceId = deviceIdArg ?? void 0;
@@ -1367,35 +1356,32 @@ var KeystoneAdapter = class _KeystoneAdapter {
1367
1356
  return (0, import_hwk_adapter_core3.failure)(import_hwk_adapter_core3.HardwareErrorCode.DevicePathForbidden, KEYSTONE_BTC_ACCOUNT_FORBIDDEN_MESSAGE);
1368
1357
  }
1369
1358
  try {
1370
- return await this._jobQueue.enqueue(
1371
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1372
- async (signal) => {
1373
- const { account } = await this._fetchAccount(
1374
- connectId,
1375
- deviceId,
1376
- "btc",
1377
- accountPath,
1378
- signal,
1379
- { book }
1380
- );
1381
- _KeystoneAdapter._throwIfAborted(signal);
1382
- if (!account.extendedPublicKey) {
1383
- throw (0, import_hwk_adapter_core3.createHwkError)({
1384
- code: import_hwk_adapter_core3.HardwareErrorCode.MethodNotSupported,
1385
- message: "Keystone did not return an extended public key for this account path"
1386
- });
1387
- }
1388
- const meta = this.urEngine.parseXpubMeta(account.extendedPublicKey);
1389
- return (0, import_hwk_adapter_core3.success)({
1390
- xpub: account.extendedPublicKey,
1391
- publicKey: meta.publicKey,
1392
- chainCode: meta.chainCode,
1393
- depth: meta.depth,
1394
- fingerprint: meta.parentFingerprint,
1395
- path: normalizePath(accountPath)
1359
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1360
+ const { account } = await this._fetchAccount(
1361
+ connectId,
1362
+ deviceId,
1363
+ "btc",
1364
+ accountPath,
1365
+ signal,
1366
+ { book }
1367
+ );
1368
+ _KeystoneAdapter._throwIfAborted(signal);
1369
+ if (!account.extendedPublicKey) {
1370
+ throw (0, import_hwk_adapter_core3.createHwkError)({
1371
+ code: import_hwk_adapter_core3.HardwareErrorCode.MethodNotSupported,
1372
+ message: "Keystone did not return an extended public key for this account path"
1396
1373
  });
1397
1374
  }
1398
- );
1375
+ const meta = this.urEngine.parseXpubMeta(account.extendedPublicKey);
1376
+ return (0, import_hwk_adapter_core3.success)({
1377
+ xpub: account.extendedPublicKey,
1378
+ publicKey: meta.publicKey,
1379
+ chainCode: meta.chainCode,
1380
+ depth: meta.depth,
1381
+ fingerprint: meta.parentFingerprint,
1382
+ path: normalizePath(accountPath)
1383
+ });
1384
+ });
1399
1385
  } catch (err) {
1400
1386
  return this._errorToFailure(err);
1401
1387
  }
@@ -1407,7 +1393,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
1407
1393
  );
1408
1394
  }
1409
1395
  async btcSignPsbt(connectIdArg, deviceIdArg, paramsArg) {
1410
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1396
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1411
1397
  if (!operationTarget.success) return operationTarget;
1412
1398
  const connectId = operationTarget.payload.targetId;
1413
1399
  const deviceId = deviceIdArg ?? void 0;
@@ -1419,31 +1405,28 @@ var KeystoneAdapter = class _KeystoneAdapter {
1419
1405
  return (0, import_hwk_adapter_core3.failure)(import_hwk_adapter_core3.HardwareErrorCode.DevicePathForbidden, KEYSTONE_BTC_ACCOUNT_FORBIDDEN_MESSAGE);
1420
1406
  }
1421
1407
  try {
1422
- return await this._jobQueue.enqueue(
1423
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1424
- async (signal) => {
1425
- const { record } = await this._ensureWalletKnown(connectId, deviceId, "btc", signal);
1426
- _KeystoneAdapter._throwIfAborted(signal);
1427
- const requestUr = this.urEngine.buildBtcPsbtRequest((0, import_hwk_adapter_core3.stripHex)(params.psbt));
1428
- const responseUr = await this._resolveUr(
1429
- record,
1430
- requestUr,
1431
- true,
1432
- connectId,
1433
- signal,
1434
- "btcSignPsbt"
1435
- );
1436
- _KeystoneAdapter._throwIfAborted(signal);
1437
- const signedPsbt = this.urEngine.parseBtcPsbt(responseUr);
1438
- return (0, import_hwk_adapter_core3.success)({ signedPsbt });
1439
- }
1440
- );
1408
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1409
+ const { record } = await this._ensureWalletKnown(connectId, deviceId, "btc", signal);
1410
+ _KeystoneAdapter._throwIfAborted(signal);
1411
+ const requestUr = this.urEngine.buildBtcPsbtRequest((0, import_hwk_adapter_core3.stripHex)(params.psbt));
1412
+ const responseUr = await this._resolveUr(
1413
+ record,
1414
+ requestUr,
1415
+ true,
1416
+ connectId,
1417
+ signal,
1418
+ "btcSignPsbt"
1419
+ );
1420
+ _KeystoneAdapter._throwIfAborted(signal);
1421
+ const signedPsbt = this.urEngine.parseBtcPsbt(responseUr);
1422
+ return (0, import_hwk_adapter_core3.success)({ signedPsbt });
1423
+ });
1441
1424
  } catch (err) {
1442
1425
  return this._errorToFailure(err);
1443
1426
  }
1444
1427
  }
1445
1428
  async btcSignMessage(connectIdArg, deviceIdArg, paramsArg) {
1446
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1429
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1447
1430
  if (!operationTarget.success) return operationTarget;
1448
1431
  const connectId = operationTarget.payload.targetId;
1449
1432
  const deviceId = deviceIdArg ?? void 0;
@@ -1461,48 +1444,42 @@ var KeystoneAdapter = class _KeystoneAdapter {
1461
1444
  return (0, import_hwk_adapter_core3.failure)(import_hwk_adapter_core3.HardwareErrorCode.DevicePathForbidden, KEYSTONE_BTC_ACCOUNT_FORBIDDEN_MESSAGE);
1462
1445
  }
1463
1446
  try {
1464
- return await this._jobQueue.enqueue(
1465
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1466
- async (signal) => {
1467
- const { record } = await this._ensureWalletKnown(connectId, deviceId, "btc", signal);
1468
- _KeystoneAdapter._throwIfAborted(signal);
1469
- const requestId = (0, import_uuid2.v4)();
1470
- const requestUr = this.urEngine.buildBtcMessageSignRequest({
1471
- requestId,
1472
- messageHex,
1473
- accounts: [{ path, xfp: record.masterFingerprint }]
1474
- });
1475
- const responseUr = await this._resolveUr(
1476
- record,
1477
- requestUr,
1478
- true,
1479
- connectId,
1480
- signal,
1481
- "btcSignMessage"
1482
- );
1483
- _KeystoneAdapter._throwIfAborted(signal);
1484
- const sig = this.urEngine.parseBtcSignature(responseUr);
1485
- _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1486
- return (0, import_hwk_adapter_core3.success)({ signature: sig.signature });
1487
- }
1488
- );
1447
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1448
+ const { record } = await this._ensureWalletKnown(connectId, deviceId, "btc", signal);
1449
+ _KeystoneAdapter._throwIfAborted(signal);
1450
+ const requestId = (0, import_uuid2.v4)();
1451
+ const requestUr = this.urEngine.buildBtcMessageSignRequest({
1452
+ requestId,
1453
+ messageHex,
1454
+ accounts: [{ path, xfp: record.masterFingerprint }]
1455
+ });
1456
+ const responseUr = await this._resolveUr(
1457
+ record,
1458
+ requestUr,
1459
+ true,
1460
+ connectId,
1461
+ signal,
1462
+ "btcSignMessage"
1463
+ );
1464
+ _KeystoneAdapter._throwIfAborted(signal);
1465
+ const sig = this.urEngine.parseBtcSignature(responseUr);
1466
+ _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1467
+ return (0, import_hwk_adapter_core3.success)({ signature: sig.signature });
1468
+ });
1489
1469
  } catch (err) {
1490
1470
  return this._errorToFailure(err);
1491
1471
  }
1492
1472
  }
1493
1473
  async btcGetMasterFingerprint(connectIdArg, deviceIdArg, paramsArg) {
1494
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1474
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1495
1475
  if (!operationTarget.success) return operationTarget;
1496
1476
  const connectId = operationTarget.payload.targetId;
1497
1477
  const deviceId = deviceIdArg ?? void 0;
1498
1478
  try {
1499
- return await this._jobQueue.enqueue(
1500
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1501
- async (signal) => {
1502
- const { record } = await this._ensureWalletKnown(connectId, deviceId, "btc", signal);
1503
- return (0, import_hwk_adapter_core3.success)({ masterFingerprint: record.masterFingerprint });
1504
- }
1505
- );
1479
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1480
+ const { record } = await this._ensureWalletKnown(connectId, deviceId, "btc", signal);
1481
+ return (0, import_hwk_adapter_core3.success)({ masterFingerprint: record.masterFingerprint });
1482
+ });
1506
1483
  } catch (err) {
1507
1484
  return this._errorToFailure(err);
1508
1485
  }
@@ -1511,7 +1488,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
1511
1488
  // SOL
1512
1489
  // ---------------------------------------------------------------------------
1513
1490
  async solGetAddress(connectIdArg, deviceIdArg, paramsArg, book) {
1514
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1491
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1515
1492
  if (!operationTarget.success) return operationTarget;
1516
1493
  const connectId = operationTarget.payload.targetId;
1517
1494
  const deviceId = deviceIdArg ?? void 0;
@@ -1521,23 +1498,20 @@ var KeystoneAdapter = class _KeystoneAdapter {
1521
1498
  return (0, import_hwk_adapter_core3.failure)(import_hwk_adapter_core3.HardwareErrorCode.InvalidParams, "solGetAddress requires params.path");
1522
1499
  const path = normalizePath(params.path);
1523
1500
  try {
1524
- return await this._jobQueue.enqueue(
1525
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1526
- async (signal) => {
1527
- const { account } = await this._fetchAccount(connectId, deviceId, "sol", path, signal, {
1528
- book
1529
- });
1530
- _KeystoneAdapter._throwIfAborted(signal);
1531
- const address = import_bs58.default.encode(Buffer.from(account.publicKey, "hex"));
1532
- return (0, import_hwk_adapter_core3.success)({ address, path });
1533
- }
1534
- );
1501
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1502
+ const { account } = await this._fetchAccount(connectId, deviceId, "sol", path, signal, {
1503
+ book
1504
+ });
1505
+ _KeystoneAdapter._throwIfAborted(signal);
1506
+ const address = import_bs58.default.encode(Buffer.from(account.publicKey, "hex"));
1507
+ return (0, import_hwk_adapter_core3.success)({ address, path });
1508
+ });
1535
1509
  } catch (err) {
1536
1510
  return this._errorToFailure(err);
1537
1511
  }
1538
1512
  }
1539
1513
  async solSignTransaction(connectIdArg, deviceIdArg, paramsArg) {
1540
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1514
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1541
1515
  if (!operationTarget.success) return operationTarget;
1542
1516
  const connectId = operationTarget.payload.targetId;
1543
1517
  const deviceId = deviceIdArg ?? void 0;
@@ -1552,39 +1526,36 @@ var KeystoneAdapter = class _KeystoneAdapter {
1552
1526
  }
1553
1527
  const path = normalizePath(params.path);
1554
1528
  try {
1555
- return await this._jobQueue.enqueue(
1556
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1557
- async (signal) => {
1558
- const { record } = await this._ensureWalletKnown(connectId, deviceId, "sol", signal);
1559
- _KeystoneAdapter._throwIfAborted(signal);
1560
- const requestId = (0, import_uuid2.v4)();
1561
- const requestUr = this.urEngine.buildSolSignRequest({
1562
- requestId,
1563
- unsignedPayloadHex: (0, import_hwk_adapter_core3.stripHex)(params.serializedTx),
1564
- dataType: "transaction",
1565
- path,
1566
- xfp: record.masterFingerprint
1567
- });
1568
- const responseUr = await this._resolveUr(
1569
- record,
1570
- requestUr,
1571
- true,
1572
- connectId,
1573
- signal,
1574
- "solSignTransaction"
1575
- );
1576
- _KeystoneAdapter._throwIfAborted(signal);
1577
- const sig = this.urEngine.parseSolSignature(responseUr);
1578
- _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1579
- return (0, import_hwk_adapter_core3.success)({ signature: sig.signature });
1580
- }
1581
- );
1529
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1530
+ const { record } = await this._ensureWalletKnown(connectId, deviceId, "sol", signal);
1531
+ _KeystoneAdapter._throwIfAborted(signal);
1532
+ const requestId = (0, import_uuid2.v4)();
1533
+ const requestUr = this.urEngine.buildSolSignRequest({
1534
+ requestId,
1535
+ unsignedPayloadHex: (0, import_hwk_adapter_core3.stripHex)(params.serializedTx),
1536
+ dataType: "transaction",
1537
+ path,
1538
+ xfp: record.masterFingerprint
1539
+ });
1540
+ const responseUr = await this._resolveUr(
1541
+ record,
1542
+ requestUr,
1543
+ true,
1544
+ connectId,
1545
+ signal,
1546
+ "solSignTransaction"
1547
+ );
1548
+ _KeystoneAdapter._throwIfAborted(signal);
1549
+ const sig = this.urEngine.parseSolSignature(responseUr);
1550
+ _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1551
+ return (0, import_hwk_adapter_core3.success)({ signature: sig.signature });
1552
+ });
1582
1553
  } catch (err) {
1583
1554
  return this._errorToFailure(err);
1584
1555
  }
1585
1556
  }
1586
1557
  async solSignMessage(connectIdArg, deviceIdArg, paramsArg) {
1587
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1558
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1588
1559
  if (!operationTarget.success) return operationTarget;
1589
1560
  const connectId = operationTarget.payload.targetId;
1590
1561
  const deviceId = deviceIdArg ?? void 0;
@@ -1598,33 +1569,30 @@ var KeystoneAdapter = class _KeystoneAdapter {
1598
1569
  }
1599
1570
  const path = normalizePath(params.path);
1600
1571
  try {
1601
- return await this._jobQueue.enqueue(
1602
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1603
- async (signal) => {
1604
- const { record } = await this._ensureWalletKnown(connectId, deviceId, "sol", signal);
1605
- _KeystoneAdapter._throwIfAborted(signal);
1606
- const requestId = (0, import_uuid2.v4)();
1607
- const requestUr = this.urEngine.buildSolSignRequest({
1608
- requestId,
1609
- unsignedPayloadHex: (0, import_hwk_adapter_core3.stripHex)(params.message),
1610
- dataType: "message",
1611
- path,
1612
- xfp: record.masterFingerprint
1613
- });
1614
- const responseUr = await this._resolveUr(
1615
- record,
1616
- requestUr,
1617
- true,
1618
- connectId,
1619
- signal,
1620
- "solSignMessage"
1621
- );
1622
- _KeystoneAdapter._throwIfAborted(signal);
1623
- const sig = this.urEngine.parseSolSignature(responseUr);
1624
- _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1625
- return (0, import_hwk_adapter_core3.success)({ signature: sig.signature });
1626
- }
1627
- );
1572
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1573
+ const { record } = await this._ensureWalletKnown(connectId, deviceId, "sol", signal);
1574
+ _KeystoneAdapter._throwIfAborted(signal);
1575
+ const requestId = (0, import_uuid2.v4)();
1576
+ const requestUr = this.urEngine.buildSolSignRequest({
1577
+ requestId,
1578
+ unsignedPayloadHex: (0, import_hwk_adapter_core3.stripHex)(params.message),
1579
+ dataType: "message",
1580
+ path,
1581
+ xfp: record.masterFingerprint
1582
+ });
1583
+ const responseUr = await this._resolveUr(
1584
+ record,
1585
+ requestUr,
1586
+ true,
1587
+ connectId,
1588
+ signal,
1589
+ "solSignMessage"
1590
+ );
1591
+ _KeystoneAdapter._throwIfAborted(signal);
1592
+ const sig = this.urEngine.parseSolSignature(responseUr);
1593
+ _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1594
+ return (0, import_hwk_adapter_core3.success)({ signature: sig.signature });
1595
+ });
1628
1596
  } catch (err) {
1629
1597
  return this._errorToFailure(err);
1630
1598
  }
@@ -1637,7 +1605,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
1637
1605
  // unverified response semantics).
1638
1606
  // ---------------------------------------------------------------------------
1639
1607
  async tronGetAddress(connectIdArg, deviceIdArg, paramsArg, book) {
1640
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1608
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1641
1609
  if (!operationTarget.success) return operationTarget;
1642
1610
  const connectId = operationTarget.payload.targetId;
1643
1611
  const deviceId = deviceIdArg ?? void 0;
@@ -1653,37 +1621,34 @@ var KeystoneAdapter = class _KeystoneAdapter {
1653
1621
  );
1654
1622
  }
1655
1623
  try {
1656
- return await this._jobQueue.enqueue(
1657
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1658
- async (signal) => {
1659
- const { account } = await this._fetchAccount(
1660
- connectId,
1661
- deviceId,
1662
- "tron",
1663
- accountPath,
1664
- signal,
1665
- { book }
1666
- );
1667
- _KeystoneAdapter._throwIfAborted(signal);
1668
- if (!account.extendedPublicKey) {
1669
- throw (0, import_hwk_adapter_core3.createHwkError)({
1670
- code: import_hwk_adapter_core3.HardwareErrorCode.MethodNotSupported,
1671
- message: "Keystone did not return an extended public key for this account path"
1672
- });
1673
- }
1674
- const address = this.urEngine.deriveTronAddressFromXpub(
1675
- account.extendedPublicKey,
1676
- relativeDerivePath
1677
- );
1678
- return (0, import_hwk_adapter_core3.success)({ address, path: normalizePath(params.path) });
1624
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1625
+ const { account } = await this._fetchAccount(
1626
+ connectId,
1627
+ deviceId,
1628
+ "tron",
1629
+ accountPath,
1630
+ signal,
1631
+ { book }
1632
+ );
1633
+ _KeystoneAdapter._throwIfAborted(signal);
1634
+ if (!account.extendedPublicKey) {
1635
+ throw (0, import_hwk_adapter_core3.createHwkError)({
1636
+ code: import_hwk_adapter_core3.HardwareErrorCode.MethodNotSupported,
1637
+ message: "Keystone did not return an extended public key for this account path"
1638
+ });
1679
1639
  }
1680
- );
1640
+ const address = this.urEngine.deriveTronAddressFromXpub(
1641
+ account.extendedPublicKey,
1642
+ relativeDerivePath
1643
+ );
1644
+ return (0, import_hwk_adapter_core3.success)({ address, path: normalizePath(params.path) });
1645
+ });
1681
1646
  } catch (err) {
1682
1647
  return this._errorToFailure(err);
1683
1648
  }
1684
1649
  }
1685
1650
  async tronSignTransaction(connectIdArg, deviceIdArg, paramsArg) {
1686
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1651
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1687
1652
  if (!operationTarget.success) return operationTarget;
1688
1653
  const connectId = operationTarget.payload.targetId;
1689
1654
  const deviceId = deviceIdArg ?? void 0;
@@ -1702,38 +1667,35 @@ var KeystoneAdapter = class _KeystoneAdapter {
1702
1667
  const rawTxHex = (0, import_hwk_adapter_core3.stripHex)(params.rawTxHex);
1703
1668
  const path = normalizePath(params.path);
1704
1669
  try {
1705
- return await this._jobQueue.enqueue(
1706
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1707
- async (signal) => {
1708
- const { record } = await this._ensureWalletKnown(connectId, deviceId, "tron", signal);
1709
- _KeystoneAdapter._throwIfAborted(signal);
1710
- const requestId = (0, import_uuid2.v4)();
1711
- const requestUr = this.urEngine.buildTronSignRequest({
1712
- requestId,
1713
- rawTxHex,
1714
- path,
1715
- xfp: record.masterFingerprint
1716
- });
1717
- const responseUr = await this._resolveUr(
1718
- record,
1719
- requestUr,
1720
- true,
1721
- connectId,
1722
- signal,
1723
- "tronSignTransaction"
1724
- );
1725
- _KeystoneAdapter._throwIfAborted(signal);
1726
- const sig = this.urEngine.parseTronSignature(responseUr);
1727
- _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1728
- return (0, import_hwk_adapter_core3.success)({ signature: sig.signature });
1729
- }
1730
- );
1670
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1671
+ const { record } = await this._ensureWalletKnown(connectId, deviceId, "tron", signal);
1672
+ _KeystoneAdapter._throwIfAborted(signal);
1673
+ const requestId = (0, import_uuid2.v4)();
1674
+ const requestUr = this.urEngine.buildTronSignRequest({
1675
+ requestId,
1676
+ rawTxHex,
1677
+ path,
1678
+ xfp: record.masterFingerprint
1679
+ });
1680
+ const responseUr = await this._resolveUr(
1681
+ record,
1682
+ requestUr,
1683
+ true,
1684
+ connectId,
1685
+ signal,
1686
+ "tronSignTransaction"
1687
+ );
1688
+ _KeystoneAdapter._throwIfAborted(signal);
1689
+ const sig = this.urEngine.parseTronSignature(responseUr);
1690
+ _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1691
+ return (0, import_hwk_adapter_core3.success)({ signature: sig.signature });
1692
+ });
1731
1693
  } catch (err) {
1732
1694
  return this._errorToFailure(err);
1733
1695
  }
1734
1696
  }
1735
1697
  async tronSignMessage(connectIdArg, deviceIdArg, paramsArg) {
1736
- const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.interactionId);
1698
+ const operationTarget = resolveHardwareOperationTarget(connectIdArg, paramsArg?.operationId);
1737
1699
  if (!operationTarget.success) return operationTarget;
1738
1700
  const connectId = operationTarget.payload.targetId;
1739
1701
  const deviceId = deviceIdArg ?? void 0;
@@ -1754,33 +1716,30 @@ var KeystoneAdapter = class _KeystoneAdapter {
1754
1716
  const messageHex = (0, import_hwk_adapter_core3.stripHex)(params.messageHex);
1755
1717
  const path = normalizePath(params.path);
1756
1718
  try {
1757
- return await this._jobQueue.enqueue(
1758
- deviceId ?? connectId ?? COLD_START_JOB_LABEL,
1759
- async (signal) => {
1760
- const { record } = await this._ensureWalletKnown(connectId, deviceId, "tron", signal);
1761
- _KeystoneAdapter._throwIfAborted(signal);
1762
- const requestId = (0, import_uuid2.v4)();
1763
- const requestUr = this.urEngine.buildTronSignRequest({
1764
- requestId,
1765
- rawTxHex: messageHex,
1766
- path,
1767
- xfp: record.masterFingerprint,
1768
- signType: 2 /* PersonalMessage */
1769
- });
1770
- const responseUr = await this._resolveUr(
1771
- record,
1772
- requestUr,
1773
- true,
1774
- connectId,
1775
- signal,
1776
- "tronSignMessage"
1777
- );
1778
- _KeystoneAdapter._throwIfAborted(signal);
1779
- const sig = this.urEngine.parseTronSignature(responseUr);
1780
- _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1781
- return (0, import_hwk_adapter_core3.success)({ signature: sig.signature });
1782
- }
1783
- );
1719
+ return await this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1720
+ const { record } = await this._ensureWalletKnown(connectId, deviceId, "tron", signal);
1721
+ _KeystoneAdapter._throwIfAborted(signal);
1722
+ const requestId = (0, import_uuid2.v4)();
1723
+ const requestUr = this.urEngine.buildTronSignRequest({
1724
+ requestId,
1725
+ rawTxHex: messageHex,
1726
+ path,
1727
+ xfp: record.masterFingerprint,
1728
+ signType: 2 /* PersonalMessage */
1729
+ });
1730
+ const responseUr = await this._resolveUr(
1731
+ record,
1732
+ requestUr,
1733
+ true,
1734
+ connectId,
1735
+ signal,
1736
+ "tronSignMessage"
1737
+ );
1738
+ _KeystoneAdapter._throwIfAborted(signal);
1739
+ const sig = this.urEngine.parseTronSignature(responseUr);
1740
+ _KeystoneAdapter._assertRequestIdMatches(requestId, sig.requestId);
1741
+ return (0, import_hwk_adapter_core3.success)({ signature: sig.signature });
1742
+ });
1784
1743
  } catch (err) {
1785
1744
  return this._errorToFailure(err);
1786
1745
  }
@@ -1819,7 +1778,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
1819
1778
  * one-path-at-a-time export flow because the device limits that channel.
1820
1779
  */
1821
1780
  async _prefetchAllNetworkAccounts(connectId, deviceId, params) {
1822
- return this._jobQueue.enqueue(deviceId || connectId || COLD_START_JOB_LABEL, async (signal) => {
1781
+ return this._jobQueue.enqueue(getKeystoneJobId(connectId, deviceId), async (signal) => {
1823
1782
  const target = this._resolveTarget(connectId, deviceId);
1824
1783
  const { record: targetRecord } = target;
1825
1784
  let record = targetRecord;
@@ -1840,19 +1799,29 @@ var KeystoneAdapter = class _KeystoneAdapter {
1840
1799
  _KeystoneAdapter._throwIfAborted(signal);
1841
1800
  }
1842
1801
  if (this._forcedTransport !== "qr" && record?.usbSessionId) {
1802
+ const bundleSessionId = record.usbSessionId;
1803
+ const assertBundleSession = () => {
1804
+ if (record?.usbSessionId !== bundleSessionId) {
1805
+ throw (0, import_hwk_adapter_core3.createHwkError)({
1806
+ code: import_hwk_adapter_core3.HardwareErrorCode.TransportNotAvailable,
1807
+ message: "Keystone USB connection was lost during account export"
1808
+ });
1809
+ }
1810
+ };
1843
1811
  const missingSchemas2 = Array.from(requestedByKey.values());
1844
- for (const [index, schema] of missingSchemas2.entries()) {
1812
+ for (const schema of missingSchemas2) {
1845
1813
  if (!book.has(accountKey(schema.hwkChain, schema.path))) {
1814
+ assertBundleSession();
1846
1815
  const synced = await this._fetchAccount(
1847
1816
  connectId,
1848
1817
  deviceId,
1849
1818
  schema.hwkChain,
1850
1819
  schema.path,
1851
1820
  signal,
1852
- { qrFallbackSchemaPaths: missingSchemas2.slice(index), book }
1821
+ { book }
1853
1822
  );
1854
1823
  record = synced.record;
1855
- if (!record.usbSessionId) break;
1824
+ assertBundleSession();
1856
1825
  }
1857
1826
  }
1858
1827
  for (const schema of missingSchemas2) {
@@ -1921,8 +1890,8 @@ var KeystoneAdapter = class _KeystoneAdapter {
1921
1890
  */
1922
1891
  _resolveTarget(connectId, deviceId) {
1923
1892
  let resolvedConnectId = connectId;
1924
- if ((0, import_hwk_adapter_core3.isHardwareInteractionId)(connectId)) {
1925
- resolvedConnectId = this._interactions.resolve(connectId).connectId;
1893
+ if ((0, import_hwk_adapter_core3.isHardwareOperationId)(connectId)) {
1894
+ resolvedConnectId = this._operations.resolve(connectId).connectId;
1926
1895
  }
1927
1896
  const identifiers = [deviceId, resolvedConnectId].filter(
1928
1897
  (identifier) => Boolean(identifier)
@@ -1978,7 +1947,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
1978
1947
  * already has a live session, so this must NOT unconditionally mark
1979
1948
  * `qrSynced`, or a USB-only wallet would wrongly survive a later USB
1980
1949
  * disconnect as a "QR-synced, demote to QR-only" entry instead of being
1981
- * dropped outright (see `releaseInteraction`).
1950
+ * dropped outright (see `releaseOperation`).
1982
1951
  */
1983
1952
  _upsertDeviceRecord(parsed, options) {
1984
1953
  const walletId = deriveKeystoneWalletId(parsed.accounts);
@@ -2116,7 +2085,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
2116
2085
  * then attach and verify the requested wallet when one is present. This is
2117
2086
  * used both after an adapter restart and after a QR-only period, so plugging
2118
2087
  * USB back in affects the next business call without changing an in-flight
2119
- * QR interaction.
2088
+ * QR operation.
2120
2089
  */
2121
2090
  async _tryUsbAttach(expectedWalletId, expectedMasterFingerprint, options) {
2122
2091
  if (!expectedWalletId || this._forcedTransport === "qr" || !this._usbConnector) {
@@ -2170,32 +2139,32 @@ var KeystoneAdapter = class _KeystoneAdapter {
2170
2139
  * `switchTransport('usb')` on a wallet with no live USB session fails
2171
2140
  * closed rather than silently falling back to QR.
2172
2141
  */
2173
- async _resolveUr(record, requestUr, animated, interactionId, signal, operationName) {
2174
- const releaseInteractionRetention = (0, import_hwk_adapter_core3.isHardwareInteractionId)(interactionId) ? this._interactions.retain(interactionId) : void 0;
2142
+ async _resolveUr(record, requestUr, animated, operationId, signal, operationName) {
2143
+ const releaseOperationRetention = (0, import_hwk_adapter_core3.isHardwareOperationId)(operationId) ? this._operations.retain(operationId) : void 0;
2175
2144
  try {
2176
2145
  return await this._resolveUrWithRoute(
2177
2146
  record,
2178
2147
  requestUr,
2179
2148
  animated,
2180
- interactionId,
2149
+ operationId,
2181
2150
  signal,
2182
2151
  operationName
2183
2152
  );
2184
2153
  } finally {
2185
- releaseInteractionRetention?.();
2154
+ releaseOperationRetention?.();
2186
2155
  }
2187
2156
  }
2188
- async _resolveUrWithRoute(record, requestUr, animated, interactionId, signal, operationName) {
2157
+ async _resolveUrWithRoute(record, requestUr, animated, operationId, signal, operationName) {
2189
2158
  let interactionRoute;
2190
- if ((0, import_hwk_adapter_core3.isHardwareInteractionId)(interactionId)) {
2191
- const interaction = this._interactions.resolve(interactionId);
2192
- const route = this._interactionRoutes.get(interaction.connectId);
2193
- if (!route || route.interactionId !== interactionId) {
2194
- this._interactions.end(interactionId, "disconnect");
2159
+ if ((0, import_hwk_adapter_core3.isHardwareOperationId)(operationId)) {
2160
+ const operation = this._operations.resolve(operationId);
2161
+ const route = this._operationRoutes.get(operation.connectId);
2162
+ if (!route || route.operationId !== operationId) {
2163
+ this._operations.end(operationId, "disconnect");
2195
2164
  throw (0, import_hwk_adapter_core3.createHwkError)({
2196
- code: import_hwk_adapter_core3.HardwareErrorCode.InteractionEnded,
2197
- message: "Keystone hardware interaction is no longer connected",
2198
- params: { interactionId, reason: "disconnect" }
2165
+ code: import_hwk_adapter_core3.HardwareErrorCode.OperationEnded,
2166
+ message: "Keystone hardware operation is no longer connected",
2167
+ params: { operationId, reason: "disconnect" }
2199
2168
  });
2200
2169
  }
2201
2170
  interactionRoute = route;
@@ -2209,12 +2178,12 @@ var KeystoneAdapter = class _KeystoneAdapter {
2209
2178
  if (wantUsb) {
2210
2179
  if (!record?.usbSessionId || !this._usbConnector) {
2211
2180
  if (interactionRoute) {
2212
- this._interactions.end(interactionRoute.interactionId, "disconnect");
2181
+ this._operations.end(interactionRoute.operationId, "disconnect");
2213
2182
  throw (0, import_hwk_adapter_core3.createHwkError)({
2214
- code: import_hwk_adapter_core3.HardwareErrorCode.InteractionEnded,
2215
- message: "Keystone interaction USB connection was lost",
2183
+ code: import_hwk_adapter_core3.HardwareErrorCode.OperationEnded,
2184
+ message: "Keystone operation USB connection was lost",
2216
2185
  params: {
2217
- interactionId: interactionRoute.interactionId,
2186
+ operationId: interactionRoute.operationId,
2218
2187
  reason: "disconnect"
2219
2188
  }
2220
2189
  });
@@ -2249,16 +2218,16 @@ var KeystoneAdapter = class _KeystoneAdapter {
2249
2218
  }
2250
2219
  record.usbSessionId = void 0;
2251
2220
  if (interactionRoute) {
2252
- this._interactions.end(interactionRoute.interactionId, "disconnect");
2221
+ this._operations.end(interactionRoute.operationId, "disconnect");
2253
2222
  throw (0, import_hwk_adapter_core3.createHwkError)({
2254
- code: import_hwk_adapter_core3.HardwareErrorCode.InteractionEnded,
2255
- message: operationName ? `Keystone ${operationName} may have completed before the USB connection was lost` : "Keystone interaction USB connection was lost",
2223
+ code: import_hwk_adapter_core3.HardwareErrorCode.OperationEnded,
2224
+ message: operationName ? `Keystone ${operationName} may have completed before the USB connection was lost` : "Keystone operation USB connection was lost",
2256
2225
  recovery: operationName ? { scope: "unknown" } : void 0,
2257
2226
  params: operationName ? (0, import_hwk_adapter_core3.operationMayHaveCompletedParams)(operationName, {
2258
- interactionId: interactionRoute.interactionId,
2227
+ operationId: interactionRoute.operationId,
2259
2228
  reason: "disconnect"
2260
2229
  }) : {
2261
- interactionId: interactionRoute.interactionId,
2230
+ operationId: interactionRoute.operationId,
2262
2231
  reason: "disconnect"
2263
2232
  }
2264
2233
  });
@@ -2297,8 +2266,8 @@ var KeystoneAdapter = class _KeystoneAdapter {
2297
2266
  /**
2298
2267
  * Fetch one account's key material from the device for this operation only.
2299
2268
  * `book` lets earlier fetches of the same operation be reused; nothing is
2300
- * retained on the record. On a USB drop the remaining paths fall back to one
2301
- * QR request.
2269
+ * retained on the record. A failed USB export ends this operation without
2270
+ * replaying the request or switching transports.
2302
2271
  */
2303
2272
  async _fetchAccount(connectId, deviceId, hwkChain, syncPath, signal, options) {
2304
2273
  const target = this._resolveTarget(connectId, deviceId);
@@ -2333,56 +2302,8 @@ var KeystoneAdapter = class _KeystoneAdapter {
2333
2302
  })),
2334
2303
  origin: this._origin
2335
2304
  });
2336
- let resolvedViaUsb = useSinglePathUsbExport;
2337
- let responseUr;
2338
- try {
2339
- responseUr = await this._resolveUr(existingRecord, requestUr, false, connectId, signal);
2340
- } catch (error) {
2341
- if ((0, import_hwk_adapter_core3.isHardwareInteractionId)(connectId) || !useSinglePathUsbExport || !isKeystoneUsbReconnectableError(error)) {
2342
- throw error;
2343
- }
2344
- await waitForKeystoneUsbReattachProbe();
2345
- _KeystoneAdapter._throwIfAborted(signal);
2346
- const recoveredRecord = await this._tryUsbAttach(
2347
- existingRecord?.walletId,
2348
- existingRecord?.masterFingerprint,
2349
- { waitForReenumeration: true }
2350
- );
2351
- _KeystoneAdapter._throwIfAborted(signal);
2352
- if (recoveredRecord?.usbSessionId) {
2353
- try {
2354
- responseUr = await this._resolveUr(recoveredRecord, requestUr, false, connectId, signal);
2355
- existingRecord = recoveredRecord;
2356
- } catch (retryError) {
2357
- if (!isKeystoneUsbReconnectableError(retryError)) throw retryError;
2358
- }
2359
- }
2360
- if (!responseUr) {
2361
- if (this._forcedTransport === "usb") throw error;
2362
- const fallbackSchemaPaths = options?.qrFallbackSchemaPaths ?? [
2363
- { hwkChain, path: syncPath }
2364
- ];
2365
- const qrFallbackSchemas = [
2366
- { hwkChain: "evm", path: KEYSTONE_WALLET_ID_PATH },
2367
- ...fallbackSchemaPaths.filter(
2368
- (schema) => normalizePath(schema.path) !== KEYSTONE_WALLET_ID_PATH
2369
- )
2370
- ].map((schema) => ({
2371
- path: schema.path,
2372
- curve: schema.hwkChain === "sol" ? "ed25519" : "secp256k1"
2373
- }));
2374
- const qrRequestUr = this.urEngine.buildKeyDerivationRequest({
2375
- schemas: qrFallbackSchemas,
2376
- origin: this._origin
2377
- });
2378
- const displayDevice = existingRecord ? toDeviceInfo(existingRecord) : placeholderDeviceInfo();
2379
- responseUr = await this._requestQrDisplayAndAwaitResponse(displayDevice, {
2380
- ...qrRequestUr,
2381
- animated: false
2382
- });
2383
- resolvedViaUsb = false;
2384
- }
2385
- }
2305
+ const resolvedViaUsb = useSinglePathUsbExport;
2306
+ const responseUr = await this._resolveUr(existingRecord, requestUr, false, connectId, signal);
2386
2307
  _KeystoneAdapter._throwIfAborted(signal);
2387
2308
  const parsed = this.urEngine.parseAccountResponse(responseUr);
2388
2309
  let record;
@@ -2611,13 +2532,13 @@ var KeystoneAdapter = class _KeystoneAdapter {
2611
2532
  if (e._tag === import_hwk_adapter_core3.UI_REQUEST_CANCELLED_TAG || e._tag === import_hwk_adapter_core3.UI_REQUEST_PREEMPTED_TAG) {
2612
2533
  return (0, import_hwk_adapter_core3.failure)(
2613
2534
  import_hwk_adapter_core3.HardwareErrorCode.UserAborted,
2614
- e.message ?? "Keystone QR interaction was cancelled"
2535
+ e.message ?? "Keystone QR operation was cancelled"
2615
2536
  );
2616
2537
  }
2617
2538
  if (e._tag === import_hwk_adapter_core3.UI_REQUEST_TIMEOUT_TAG) {
2618
2539
  return (0, import_hwk_adapter_core3.failure)(
2619
2540
  import_hwk_adapter_core3.HardwareErrorCode.OperationTimeout,
2620
- e.message ?? "Keystone QR interaction timed out"
2541
+ e.message ?? "Keystone QR operation timed out"
2621
2542
  );
2622
2543
  }
2623
2544
  }