@onekeyfe/hwk-trezor-connector 1.2.4 → 1.2.5-alpha.0
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 +0 -6
- package/dist/index.d.ts +0 -6
- package/dist/index.js +106 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -44,12 +44,6 @@ declare abstract class TrezorConnectorBase implements IConnector {
|
|
|
44
44
|
* the change too — we mutate, not replace.
|
|
45
45
|
*/
|
|
46
46
|
setKnownCredentials(credentials: TrezorThpCredentials[]): void;
|
|
47
|
-
/**
|
|
48
|
-
* Push new credentials minted during pairing into the in-memory array.
|
|
49
|
-
* Deduplicates by the device-minted `credential` blob — the host has no
|
|
50
|
-
* other stable identity for a credential.
|
|
51
|
-
*/
|
|
52
|
-
private mergeKnownCredentials;
|
|
53
47
|
protected abstract enumerateDevices(): Promise<ConnectorDevice[]>;
|
|
54
48
|
protected abstract createByteTransport(device: ConnectorDevice): Promise<TrezorConnectorByteTransport>;
|
|
55
49
|
protected resolveUnlistedDevice(_deviceId: string): ConnectorDevice | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -44,12 +44,6 @@ declare abstract class TrezorConnectorBase implements IConnector {
|
|
|
44
44
|
* the change too — we mutate, not replace.
|
|
45
45
|
*/
|
|
46
46
|
setKnownCredentials(credentials: TrezorThpCredentials[]): void;
|
|
47
|
-
/**
|
|
48
|
-
* Push new credentials minted during pairing into the in-memory array.
|
|
49
|
-
* Deduplicates by the device-minted `credential` blob — the host has no
|
|
50
|
-
* other stable identity for a credential.
|
|
51
|
-
*/
|
|
52
|
-
private mergeKnownCredentials;
|
|
53
47
|
protected abstract enumerateDevices(): Promise<ConnectorDevice[]>;
|
|
54
48
|
protected abstract createByteTransport(device: ConnectorDevice): Promise<TrezorConnectorByteTransport>;
|
|
55
49
|
protected resolveUnlistedDevice(_deviceId: string): ConnectorDevice | undefined;
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
shouldLogTrezorDebugEntry: () => import_hwk_trezor_core2.shouldLogTrezorDebugEntry
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
var
|
|
29
|
+
var import_hwk_adapter_core3 = require("@onekeyfe/hwk-adapter-core");
|
|
30
30
|
var import_hwk_trezor_core = require("@onekeyfe/hwk-trezor-core");
|
|
31
31
|
|
|
32
32
|
// src/chains/utils.ts
|
|
@@ -2666,6 +2666,7 @@ function normalizeEthMessage(message, isHex) {
|
|
|
2666
2666
|
}
|
|
2667
2667
|
|
|
2668
2668
|
// src/chains/sol.ts
|
|
2669
|
+
var import_hwk_adapter_core2 = require("@onekeyfe/hwk-adapter-core");
|
|
2669
2670
|
async function solGetAddress(ctx, params) {
|
|
2670
2671
|
const request = readSolGetAddressParams(params);
|
|
2671
2672
|
const response = await ctx.deviceSession.call("SolanaGetAddress", {
|
|
@@ -2712,10 +2713,37 @@ async function solSignTransaction(ctx, params) {
|
|
|
2712
2713
|
}
|
|
2713
2714
|
return { signature };
|
|
2714
2715
|
}
|
|
2715
|
-
async function solSignMessage(
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2716
|
+
async function solSignMessage(ctx, params) {
|
|
2717
|
+
const request = readSolSignMsgParams(params);
|
|
2718
|
+
if (request.messageVersion !== 1) {
|
|
2719
|
+
throw createMethodNotSupportedError(
|
|
2720
|
+
"Trezor supports finalized Solana off-chain message version 1 only"
|
|
2721
|
+
);
|
|
2722
|
+
}
|
|
2723
|
+
const preparedMessage = (0, import_hwk_adapter_core2.prepareSolanaOffchainMessageV1)({
|
|
2724
|
+
message: (0, import_hwk_adapter_core2.hexToBytes)(request.message),
|
|
2725
|
+
requiredSigners: request.requiredSigners
|
|
2726
|
+
});
|
|
2727
|
+
const response = await ctx.deviceSession.call("SolanaSignMessage", {
|
|
2728
|
+
address_n: parseBip32Path(request.path),
|
|
2729
|
+
message: {
|
|
2730
|
+
message: preparedMessage.messageText,
|
|
2731
|
+
signers: preparedMessage.requiredSigners
|
|
2732
|
+
}
|
|
2733
|
+
});
|
|
2734
|
+
if (response.type !== "SolanaMessageSignature") {
|
|
2735
|
+
throw new Error(`Expected SolanaMessageSignature response, received ${response.type}`);
|
|
2736
|
+
}
|
|
2737
|
+
const signature = readString(response.message, "signature");
|
|
2738
|
+
if (!signature) {
|
|
2739
|
+
throw new Error("SolanaMessageSignature response did not include a signature");
|
|
2740
|
+
}
|
|
2741
|
+
const signedData = readString(response.message, "signed_data");
|
|
2742
|
+
const expectedSignedData = (0, import_hwk_adapter_core2.bytesToHex)(preparedMessage.serializedMessage);
|
|
2743
|
+
if (!signedData || stripHexPrefix2(signedData).toLowerCase() !== expectedSignedData) {
|
|
2744
|
+
throw new Error("Trezor signed data does not match the requested Solana off-chain message");
|
|
2745
|
+
}
|
|
2746
|
+
return { signature: stripHexPrefix2(signature).toLowerCase() };
|
|
2719
2747
|
}
|
|
2720
2748
|
function readSolGetAddressParams(params) {
|
|
2721
2749
|
if (!params || typeof params !== "object") {
|
|
@@ -2746,6 +2774,25 @@ function readSolSignTxParams(params) {
|
|
|
2746
2774
|
assertHexString("serializedTx", serializedTx);
|
|
2747
2775
|
return params;
|
|
2748
2776
|
}
|
|
2777
|
+
function readSolSignMsgParams(params) {
|
|
2778
|
+
if (!params || typeof params !== "object") {
|
|
2779
|
+
throw createInvalidParamsError("solSignMessage params must be an object");
|
|
2780
|
+
}
|
|
2781
|
+
const request = params;
|
|
2782
|
+
if (typeof request.path !== "string" || request.path.trim().length === 0) {
|
|
2783
|
+
throw createInvalidParamsError("solSignMessage requires a non-empty path");
|
|
2784
|
+
}
|
|
2785
|
+
if (typeof request.message !== "string" || request.message.length === 0) {
|
|
2786
|
+
throw createInvalidParamsError("solSignMessage requires message as a hex string");
|
|
2787
|
+
}
|
|
2788
|
+
assertHexString("message", request.message);
|
|
2789
|
+
if (request.messageVersion === 1 && !Array.isArray(request.requiredSigners)) {
|
|
2790
|
+
throw createInvalidParamsError(
|
|
2791
|
+
"Solana off-chain message version 1 requires signer public keys"
|
|
2792
|
+
);
|
|
2793
|
+
}
|
|
2794
|
+
return request;
|
|
2795
|
+
}
|
|
2749
2796
|
function stripHexPrefix2(value) {
|
|
2750
2797
|
return value.startsWith("0x") || value.startsWith("0X") ? value.slice(2) : value;
|
|
2751
2798
|
}
|
|
@@ -7668,8 +7715,8 @@ var REQUIRED_DEVICE_CAPABILITIES = {
|
|
|
7668
7715
|
function normalizePassphraseMode(passphraseMode) {
|
|
7669
7716
|
if (passphraseMode === void 0) return "prompt";
|
|
7670
7717
|
if (passphraseMode === "prompt" || passphraseMode === "empty") return passphraseMode;
|
|
7671
|
-
throw (0,
|
|
7672
|
-
code:
|
|
7718
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
7719
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.InvalidParams,
|
|
7673
7720
|
message: `Invalid Trezor passphrase mode: ${String(passphraseMode)}`
|
|
7674
7721
|
});
|
|
7675
7722
|
}
|
|
@@ -7685,8 +7732,8 @@ var MAX_AUTHENTICITY_PROOF_PART_SIZE = 64 * 1024;
|
|
|
7685
7732
|
var MAX_AUTHENTICITY_CERTIFICATE_COUNT = 4;
|
|
7686
7733
|
var validateAuthenticityProofPartSize = (size) => {
|
|
7687
7734
|
if (typeof size !== "number" || !Number.isSafeInteger(size) || size < 0 || size > MAX_AUTHENTICITY_PROOF_PART_SIZE) {
|
|
7688
|
-
throw (0,
|
|
7689
|
-
code:
|
|
7735
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
7736
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.UnknownError,
|
|
7690
7737
|
message: `Invalid Trezor authenticity proof part size: ${String(size)}`
|
|
7691
7738
|
});
|
|
7692
7739
|
}
|
|
@@ -7714,15 +7761,15 @@ var readAuthenticityProofPart = async ({
|
|
|
7714
7761
|
request
|
|
7715
7762
|
);
|
|
7716
7763
|
if (response.type !== "AuthenticityProofChunk") {
|
|
7717
|
-
throw (0,
|
|
7718
|
-
code:
|
|
7764
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
7765
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.UnknownError,
|
|
7719
7766
|
message: `Expected AuthenticityProofChunk, received ${response.type}`
|
|
7720
7767
|
});
|
|
7721
7768
|
}
|
|
7722
7769
|
const chunk = response.message?.chunk;
|
|
7723
7770
|
if (typeof chunk !== "string" || chunk.length !== requestedSize * 2) {
|
|
7724
|
-
throw (0,
|
|
7725
|
-
code:
|
|
7771
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
7772
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.UnknownError,
|
|
7726
7773
|
message: "Trezor returned an invalid authenticity proof chunk"
|
|
7727
7774
|
});
|
|
7728
7775
|
}
|
|
@@ -7734,14 +7781,14 @@ var readAuthenticityProofPart = async ({
|
|
|
7734
7781
|
var readAuthenticityProofStream = async (deviceSession, sizes) => {
|
|
7735
7782
|
const readCertificates = async (proofType, values) => {
|
|
7736
7783
|
if (!Array.isArray(values)) {
|
|
7737
|
-
throw (0,
|
|
7738
|
-
code:
|
|
7784
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
7785
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.UnknownError,
|
|
7739
7786
|
message: "Trezor returned invalid authenticity certificate sizes"
|
|
7740
7787
|
});
|
|
7741
7788
|
}
|
|
7742
7789
|
if (values.length > MAX_AUTHENTICITY_CERTIFICATE_COUNT) {
|
|
7743
|
-
throw (0,
|
|
7744
|
-
code:
|
|
7790
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
7791
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.UnknownError,
|
|
7745
7792
|
message: `Trezor authenticity proof contains too many certificates: ${values.length}`
|
|
7746
7793
|
});
|
|
7747
7794
|
}
|
|
@@ -7790,13 +7837,13 @@ var TrezorConnectorBase = class {
|
|
|
7790
7837
|
chunkSize;
|
|
7791
7838
|
thp;
|
|
7792
7839
|
// Single owned array — passed by reference into every TrezorThpSession via
|
|
7793
|
-
// `createThpOptions`.
|
|
7794
|
-
//
|
|
7795
|
-
//
|
|
7840
|
+
// `createThpOptions`. Both host updates and authoritative device updates
|
|
7841
|
+
// replace its contents in-place so the next handshake sees fresh credentials
|
|
7842
|
+
// without a connector rebuild.
|
|
7796
7843
|
knownCredentials = [];
|
|
7797
7844
|
deviceSessionFactory;
|
|
7798
7845
|
eventHandlers = /* @__PURE__ */ new Map();
|
|
7799
|
-
uiRequests = new
|
|
7846
|
+
uiRequests = new import_hwk_adapter_core3.UiRequestRegistry();
|
|
7800
7847
|
devices = /* @__PURE__ */ new Map();
|
|
7801
7848
|
sessions = /* @__PURE__ */ new Map();
|
|
7802
7849
|
constructor(options = {}) {
|
|
@@ -7829,21 +7876,6 @@ var TrezorConnectorBase = class {
|
|
|
7829
7876
|
this.knownCredentials.push(...credentials);
|
|
7830
7877
|
}
|
|
7831
7878
|
}
|
|
7832
|
-
/**
|
|
7833
|
-
* Push new credentials minted during pairing into the in-memory array.
|
|
7834
|
-
* Deduplicates by the device-minted `credential` blob — the host has no
|
|
7835
|
-
* other stable identity for a credential.
|
|
7836
|
-
*/
|
|
7837
|
-
mergeKnownCredentials(incoming) {
|
|
7838
|
-
for (const cred of incoming) {
|
|
7839
|
-
const blob = cred.credential;
|
|
7840
|
-
if (!blob) continue;
|
|
7841
|
-
const exists2 = this.knownCredentials.some(
|
|
7842
|
-
(existing) => existing.credential === blob
|
|
7843
|
-
);
|
|
7844
|
-
if (!exists2) this.knownCredentials.push(cred);
|
|
7845
|
-
}
|
|
7846
|
-
}
|
|
7847
7879
|
resolveUnlistedDevice(_deviceId) {
|
|
7848
7880
|
return void 0;
|
|
7849
7881
|
}
|
|
@@ -7979,14 +8011,14 @@ var TrezorConnectorBase = class {
|
|
|
7979
8011
|
durationMs: Date.now() - startedAt,
|
|
7980
8012
|
error: errorToLog(error)
|
|
7981
8013
|
});
|
|
7982
|
-
return { success: false, error: (0,
|
|
8014
|
+
return { success: false, error: (0, import_hwk_adapter_core3.serializeConnectorError)(error) };
|
|
7983
8015
|
}
|
|
7984
8016
|
}
|
|
7985
8017
|
async dispatchCall(sessionId, method, params) {
|
|
7986
8018
|
const session = this.sessions.get(sessionId);
|
|
7987
8019
|
if (!session) {
|
|
7988
|
-
throw (0,
|
|
7989
|
-
code:
|
|
8020
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
8021
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.DeviceNotFound,
|
|
7990
8022
|
message: `Trezor session not found: ${sessionId}`
|
|
7991
8023
|
});
|
|
7992
8024
|
}
|
|
@@ -8039,8 +8071,8 @@ var TrezorConnectorBase = class {
|
|
|
8039
8071
|
return getTrezorResponseMessage(response);
|
|
8040
8072
|
}
|
|
8041
8073
|
if (response.type !== "AuthenticityProofSizes") {
|
|
8042
|
-
throw (0,
|
|
8043
|
-
code:
|
|
8074
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
8075
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.UnknownError,
|
|
8044
8076
|
message: `Expected Trezor authenticity proof, received ${response.type}`
|
|
8045
8077
|
});
|
|
8046
8078
|
}
|
|
@@ -8072,8 +8104,8 @@ var TrezorConnectorBase = class {
|
|
|
8072
8104
|
}
|
|
8073
8105
|
const p = params ?? {};
|
|
8074
8106
|
if (!p.thpSessionId) {
|
|
8075
|
-
throw (0,
|
|
8076
|
-
code:
|
|
8107
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
8108
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.InvalidParams,
|
|
8077
8109
|
message: "__thpSelectSession requires a thpSessionId"
|
|
8078
8110
|
});
|
|
8079
8111
|
}
|
|
@@ -8118,8 +8150,8 @@ var TrezorConnectorBase = class {
|
|
|
8118
8150
|
case "tronSignMessage":
|
|
8119
8151
|
return tronSignMessage(ctx, params);
|
|
8120
8152
|
default:
|
|
8121
|
-
throw (0,
|
|
8122
|
-
code:
|
|
8153
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
8154
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.MethodNotSupported,
|
|
8123
8155
|
message: `TrezorConnector: method "${method}" is not implemented`
|
|
8124
8156
|
});
|
|
8125
8157
|
}
|
|
@@ -8143,8 +8175,8 @@ var TrezorConnectorBase = class {
|
|
|
8143
8175
|
};
|
|
8144
8176
|
this.log(hasAllRequired ? "info" : "warn", "capability.check", checkPayload);
|
|
8145
8177
|
if (hasAllRequired) return;
|
|
8146
|
-
throw (0,
|
|
8147
|
-
code:
|
|
8178
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
8179
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.MethodNotSupported,
|
|
8148
8180
|
message: `Trezor device is missing required capability for ${method}: ${required.map((capability) => capability.name).join(", ")}`,
|
|
8149
8181
|
params: {
|
|
8150
8182
|
method,
|
|
@@ -8156,7 +8188,7 @@ var TrezorConnectorBase = class {
|
|
|
8156
8188
|
async cancel(_sessionId) {
|
|
8157
8189
|
}
|
|
8158
8190
|
uiResponse(_response) {
|
|
8159
|
-
if (_response.type ===
|
|
8191
|
+
if (_response.type === import_hwk_adapter_core3.UI_RESPONSE.CANCEL) {
|
|
8160
8192
|
this.uiRequests.cancel();
|
|
8161
8193
|
return;
|
|
8162
8194
|
}
|
|
@@ -8202,8 +8234,8 @@ var TrezorConnectorBase = class {
|
|
|
8202
8234
|
return device;
|
|
8203
8235
|
}
|
|
8204
8236
|
if (!device) {
|
|
8205
|
-
throw (0,
|
|
8206
|
-
code:
|
|
8237
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
8238
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.DeviceNotFound,
|
|
8207
8239
|
message: deviceId ? `Trezor device not found: ${deviceId}` : "No Trezor device found"
|
|
8208
8240
|
});
|
|
8209
8241
|
}
|
|
@@ -8221,8 +8253,9 @@ var TrezorConnectorBase = class {
|
|
|
8221
8253
|
if (this.thp?.onPairingRequest) {
|
|
8222
8254
|
return this.thp.onPairingRequest(payload);
|
|
8223
8255
|
}
|
|
8256
|
+
const pairingPromise = this.uiRequests.wait(import_hwk_adapter_core3.UI_REQUEST.REQUEST_TREZOR_THP_PAIRING);
|
|
8224
8257
|
this.emit("ui-request", {
|
|
8225
|
-
type:
|
|
8258
|
+
type: import_hwk_adapter_core3.UI_REQUEST.REQUEST_TREZOR_THP_PAIRING,
|
|
8226
8259
|
payload: {
|
|
8227
8260
|
connectId: device.connectId,
|
|
8228
8261
|
availableMethods: payload.availableMethods,
|
|
@@ -8230,12 +8263,12 @@ var TrezorConnectorBase = class {
|
|
|
8230
8263
|
nfcData: payload.nfcData
|
|
8231
8264
|
}
|
|
8232
8265
|
});
|
|
8233
|
-
return
|
|
8266
|
+
return pairingPromise;
|
|
8234
8267
|
},
|
|
8235
8268
|
onButtonRequest: async (payload) => {
|
|
8236
8269
|
await this.thp?.onButtonRequest?.(payload);
|
|
8237
8270
|
this.emit("ui-request", {
|
|
8238
|
-
type:
|
|
8271
|
+
type: import_hwk_adapter_core3.UI_REQUEST.REQUEST_BUTTON,
|
|
8239
8272
|
payload: {
|
|
8240
8273
|
connectId: device.connectId,
|
|
8241
8274
|
...payload
|
|
@@ -8244,20 +8277,19 @@ var TrezorConnectorBase = class {
|
|
|
8244
8277
|
},
|
|
8245
8278
|
onButtonRequestComplete: async (payload) => {
|
|
8246
8279
|
await this.thp?.onButtonRequestComplete?.(payload);
|
|
8280
|
+
if (payload.responseType === "ButtonRequest") return;
|
|
8247
8281
|
this.emit("ui-event", {
|
|
8248
|
-
type:
|
|
8249
|
-
payload: {
|
|
8250
|
-
sessionId: device.connectId
|
|
8251
|
-
}
|
|
8282
|
+
type: import_hwk_adapter_core3.EConnectorInteraction.InteractionComplete,
|
|
8283
|
+
payload: { sessionId: "" }
|
|
8252
8284
|
});
|
|
8253
8285
|
},
|
|
8254
8286
|
onPinMatrixRequest: async (payload) => {
|
|
8255
8287
|
if (this.thp?.onPinMatrixRequest) {
|
|
8256
8288
|
return this.thp.onPinMatrixRequest(payload);
|
|
8257
8289
|
}
|
|
8258
|
-
const pinPromise = this.uiRequests.wait(
|
|
8290
|
+
const pinPromise = this.uiRequests.wait(import_hwk_adapter_core3.UI_REQUEST.REQUEST_PIN);
|
|
8259
8291
|
this.emit("ui-request", {
|
|
8260
|
-
type:
|
|
8292
|
+
type: import_hwk_adapter_core3.UI_REQUEST.REQUEST_PIN,
|
|
8261
8293
|
payload: {
|
|
8262
8294
|
connectId: device.connectId,
|
|
8263
8295
|
type: payload.type
|
|
@@ -8269,9 +8301,9 @@ var TrezorConnectorBase = class {
|
|
|
8269
8301
|
if (this.thp?.onPassphraseRequest) {
|
|
8270
8302
|
return this.thp.onPassphraseRequest(payload);
|
|
8271
8303
|
}
|
|
8272
|
-
const passphrasePromise = this.uiRequests.wait(
|
|
8304
|
+
const passphrasePromise = this.uiRequests.wait(import_hwk_adapter_core3.UI_REQUEST.REQUEST_PASSPHRASE);
|
|
8273
8305
|
this.emit("ui-request", {
|
|
8274
|
-
type:
|
|
8306
|
+
type: import_hwk_adapter_core3.UI_REQUEST.REQUEST_PASSPHRASE,
|
|
8275
8307
|
payload: {
|
|
8276
8308
|
connectId: device.connectId,
|
|
8277
8309
|
...payload
|
|
@@ -8281,7 +8313,15 @@ var TrezorConnectorBase = class {
|
|
|
8281
8313
|
return res?.passphraseOnDevice ? { on_device: true } : { passphrase: res?.value ?? "" };
|
|
8282
8314
|
},
|
|
8283
8315
|
onPairingCredentialsChanged: async (payload) => {
|
|
8284
|
-
|
|
8316
|
+
const blob = (cred) => cred.credential;
|
|
8317
|
+
const rejected = new Set((payload.removed ?? []).map(blob));
|
|
8318
|
+
const merged = this.knownCredentials.filter((cred) => !rejected.has(blob(cred)));
|
|
8319
|
+
for (const cred of payload.credentials) {
|
|
8320
|
+
if (blob(cred) && !merged.some((existing) => blob(existing) === blob(cred))) {
|
|
8321
|
+
merged.push(cred);
|
|
8322
|
+
}
|
|
8323
|
+
}
|
|
8324
|
+
this.setKnownCredentials(merged);
|
|
8285
8325
|
await this.thp?.onPairingCredentialsChanged?.(payload);
|
|
8286
8326
|
this.emit("device-trezor-thp-credentials-changed", {
|
|
8287
8327
|
connectId: device.connectId,
|
|
@@ -8302,7 +8342,7 @@ var TrezorConnectorBase = class {
|
|
|
8302
8342
|
emitSupportFeatures(session) {
|
|
8303
8343
|
const features = session.deviceSession.features ?? session.features;
|
|
8304
8344
|
session.features = features;
|
|
8305
|
-
this.emit(
|
|
8345
|
+
this.emit(import_hwk_adapter_core3.DEVICE.FEATURES, {
|
|
8306
8346
|
device: {
|
|
8307
8347
|
...session.device,
|
|
8308
8348
|
deviceId: readString(features, "device_id") ?? session.device.deviceId,
|
|
@@ -8325,9 +8365,9 @@ function connectorSessionToDevice(session) {
|
|
|
8325
8365
|
};
|
|
8326
8366
|
}
|
|
8327
8367
|
function rejectKnownNonTrezorDevice(features) {
|
|
8328
|
-
if (!(0,
|
|
8329
|
-
throw (0,
|
|
8330
|
-
code:
|
|
8368
|
+
if (!(0, import_hwk_adapter_core3.isKnownNonTargetHardwareVendor)(features, "trezor")) return;
|
|
8369
|
+
throw (0, import_hwk_adapter_core3.createHwkError)({
|
|
8370
|
+
code: import_hwk_adapter_core3.HardwareErrorCode.DeviceMismatch,
|
|
8331
8371
|
message: "Selected device is not a supported Trezor device.",
|
|
8332
8372
|
params: {
|
|
8333
8373
|
vendor: features.vendor,
|