@onekeyfe/hwk-trezor-core 1.2.8-alpha.9 → 1.2.9
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 +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +61 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -7886,6 +7886,7 @@ __export(messages_solana_pb_exports, {
|
|
|
7886
7886
|
SolanaGetAddressSchema: () => SolanaGetAddressSchema,
|
|
7887
7887
|
SolanaGetPublicKeySchema: () => SolanaGetPublicKeySchema,
|
|
7888
7888
|
SolanaMessageSignatureSchema: () => SolanaMessageSignatureSchema,
|
|
7889
|
+
SolanaOffchainMessageV1Schema: () => SolanaOffchainMessageV1Schema,
|
|
7889
7890
|
SolanaPublicKeySchema: () => SolanaPublicKeySchema,
|
|
7890
7891
|
SolanaSignMessageSchema: () => SolanaSignMessageSchema,
|
|
7891
7892
|
SolanaSignTxSchema: () => SolanaSignTxSchema,
|
|
@@ -7897,7 +7898,7 @@ __export(messages_solana_pb_exports, {
|
|
|
7897
7898
|
});
|
|
7898
7899
|
init_buffer();
|
|
7899
7900
|
var file_messages_solana = fileDesc(
|
|
7900
|
-
"
|
|
7901
|
+
"ChVtZXNzYWdlcy1zb2xhbmEucHJvdG8SGWh3LnRyZXpvci5tZXNzYWdlcy5zb2xhbmEiPQoSU29sYW5hR2V0UHVibGljS2V5EhEKCWFkZHJlc3NfbhgBIAMoDRIUCgxzaG93X2Rpc3BsYXkYAiABKAgiJQoPU29sYW5hUHVibGljS2V5EhIKCnB1YmxpY19rZXkYASACKAwiTQoQU29sYW5hR2V0QWRkcmVzcxIRCglhZGRyZXNzX24YASADKA0SFAoMc2hvd19kaXNwbGF5GAIgASgIEhAKCGNodW5raWZ5GAMgASgIIi0KDVNvbGFuYUFkZHJlc3MSDwoHYWR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5TWVzc2FnZRIQCghjaHVua2lmeRgCIAEoCBJDCgdtZXNzYWdlGAMgAigLMjIuaHcudHJlem9yLm1lc3NhZ2VzLnNvbGFuYS5Tb2xhbmFPZmZjaGFpbk1lc3NhZ2VWMRISCgpzaWduYXR1cmVzGAQgAygMSgQIARACQjoKI2NvbS5zYXRvc2hpbGFicy50cmV6b3IubGliLnByb3RvYnVmQhNUcmV6b3JNZXNzYWdlU29sYW5h",
|
|
7901
7902
|
[file_messages_common]
|
|
7902
7903
|
);
|
|
7903
7904
|
var SolanaGetPublicKeySchema = messageDesc(file_messages_solana, 0);
|
|
@@ -7908,9 +7909,10 @@ var SolanaTxTokenAccountInfoSchema = messageDesc(file_messages_solana, 4);
|
|
|
7908
7909
|
var SolanaTxAdditionalInfoSchema = messageDesc(file_messages_solana, 5);
|
|
7909
7910
|
var SolanaSignTxSchema = messageDesc(file_messages_solana, 6);
|
|
7910
7911
|
var SolanaTxSignatureSchema = messageDesc(file_messages_solana, 7);
|
|
7911
|
-
var
|
|
7912
|
-
var
|
|
7913
|
-
var
|
|
7912
|
+
var SolanaOffchainMessageV1Schema = messageDesc(file_messages_solana, 8);
|
|
7913
|
+
var SolanaSignMessageSchema = messageDesc(file_messages_solana, 9);
|
|
7914
|
+
var SolanaMessageSignatureSchema = messageDesc(file_messages_solana, 10);
|
|
7915
|
+
var SolanaVerifyMessageSchema = messageDesc(file_messages_solana, 11);
|
|
7914
7916
|
|
|
7915
7917
|
// ../hwk-trezor-protobuf/src/definitions/messages-stellar_pb.js
|
|
7916
7918
|
var messages_stellar_pb_exports = {};
|
|
@@ -11259,7 +11261,8 @@ async function receive(receiver, protocol) {
|
|
|
11259
11261
|
} catch (e) {
|
|
11260
11262
|
console.warn("Protocol decode failed", {
|
|
11261
11263
|
error: e.message,
|
|
11262
|
-
|
|
11264
|
+
payloadLength: readResult.payload.length,
|
|
11265
|
+
payloadHead: readResult.payload.subarray(0, 2).toString("hex")
|
|
11263
11266
|
});
|
|
11264
11267
|
return error({ code: PROTOCOL_MALFORMED, message: e.message });
|
|
11265
11268
|
}
|
|
@@ -11984,6 +11987,9 @@ var normalizeCreateAppSessionOptions = (options = {}) => {
|
|
|
11984
11987
|
passphraseMode
|
|
11985
11988
|
};
|
|
11986
11989
|
};
|
|
11990
|
+
function thpPairingRefused(message) {
|
|
11991
|
+
return Object.assign(new Error(message), { code: "ThpPairingFailed" });
|
|
11992
|
+
}
|
|
11987
11993
|
var TrezorDeviceSession = class {
|
|
11988
11994
|
transport;
|
|
11989
11995
|
connectionType;
|
|
@@ -12067,6 +12073,11 @@ var TrezorDeviceSession = class {
|
|
|
12067
12073
|
this.log("error", "session.initialize.error", { error: errorToLog(error2) });
|
|
12068
12074
|
throw error2;
|
|
12069
12075
|
}
|
|
12076
|
+
if (this.connectionType === "ble" && this.currentFeatures?.bootloader_mode !== true) {
|
|
12077
|
+
this.core = void 0;
|
|
12078
|
+
this.currentFeatures = void 0;
|
|
12079
|
+
throw thpPairingRefused("Trezor Bluetooth requires the encrypted THP protocol");
|
|
12080
|
+
}
|
|
12070
12081
|
this.log("info", "session.initialize.done", {
|
|
12071
12082
|
protocol: this.protocol,
|
|
12072
12083
|
features: summarizeFeatures(this.currentFeatures)
|
|
@@ -12114,6 +12125,11 @@ var TrezorDeviceSession = class {
|
|
|
12114
12125
|
requestData = {};
|
|
12115
12126
|
continue;
|
|
12116
12127
|
}
|
|
12128
|
+
if ((response.type === "PinMatrixRequest" || response.type === "PassphraseRequest") && this.connectionType === "ble" && this.protocol === "v1") {
|
|
12129
|
+
this.core = void 0;
|
|
12130
|
+
this.currentFeatures = void 0;
|
|
12131
|
+
throw thpPairingRefused("Trezor Bluetooth requires the encrypted THP protocol");
|
|
12132
|
+
}
|
|
12117
12133
|
if (response.type === "PinMatrixRequest") {
|
|
12118
12134
|
const pin = await this.handlePinMatrixRequest(
|
|
12119
12135
|
response.message
|
|
@@ -12234,6 +12250,36 @@ var TrezorDeviceSession = class {
|
|
|
12234
12250
|
const response = await this.core.call("Initialize", {});
|
|
12235
12251
|
this.currentFeatures = expectMessage(response, "Features").message;
|
|
12236
12252
|
this.thpAppSessionActive = false;
|
|
12253
|
+
if (passphraseMode === "empty") {
|
|
12254
|
+
expectMessage(
|
|
12255
|
+
await this.call("GetAddress", {
|
|
12256
|
+
address_n: [2147483692, 2147483649, 2147483648, 0, 0],
|
|
12257
|
+
coin_name: "Testnet",
|
|
12258
|
+
script_type: "SPENDADDRESS",
|
|
12259
|
+
show_display: false
|
|
12260
|
+
}),
|
|
12261
|
+
"Address"
|
|
12262
|
+
);
|
|
12263
|
+
expectMessage(await this.call("GetFeatures", {}), "Features");
|
|
12264
|
+
if (this.currentFeatures?.passphrase_protection == null) {
|
|
12265
|
+
throw new TrezorFailureError({
|
|
12266
|
+
type: "Failure",
|
|
12267
|
+
message: {
|
|
12268
|
+
code: "Failure_DataError",
|
|
12269
|
+
message: "Empty passphrase cannot be enforced: device did not report its passphrase setting"
|
|
12270
|
+
}
|
|
12271
|
+
});
|
|
12272
|
+
}
|
|
12273
|
+
}
|
|
12274
|
+
if (passphraseMode === "empty" && this.currentFeatures?.passphrase_protection === true && this.currentFeatures?.passphrase_always_on_device === true) {
|
|
12275
|
+
throw new TrezorFailureError({
|
|
12276
|
+
type: "Failure",
|
|
12277
|
+
message: {
|
|
12278
|
+
code: "Failure_DataError",
|
|
12279
|
+
message: "Empty passphrase cannot be enforced with PASSPHRASE_ALWAYS_ON_DEVICE enabled"
|
|
12280
|
+
}
|
|
12281
|
+
});
|
|
12282
|
+
}
|
|
12237
12283
|
this.log("info", "v1.appSession.create.done", {
|
|
12238
12284
|
features: summarizeFeatures(this.currentFeatures)
|
|
12239
12285
|
});
|
|
@@ -12361,7 +12407,8 @@ var TrezorThpSession = class {
|
|
|
12361
12407
|
}
|
|
12362
12408
|
const pairingMethods = getPairingMethods(
|
|
12363
12409
|
properties.pairing_methods,
|
|
12364
|
-
|
|
12410
|
+
// SkipPairing is for emulators and debug firmware only; production devices offer CodeEntry.
|
|
12411
|
+
this.options.pairingMethods ?? ["CodeEntry", "QrCode", "NFC"]
|
|
12365
12412
|
);
|
|
12366
12413
|
if (pairingMethods.length === 0) {
|
|
12367
12414
|
throw new Error("No compatible THP pairing method");
|
|
@@ -12428,12 +12475,16 @@ var TrezorThpSession = class {
|
|
|
12428
12475
|
"ThpHandshakeCompletionResponse"
|
|
12429
12476
|
);
|
|
12430
12477
|
const completionState = completion.message.state;
|
|
12478
|
+
if (completionState !== 0 && !handshakeCredentials.credentials) {
|
|
12479
|
+
throw thpPairingRefused("Trezor reported a pairing that no stored credential confirms");
|
|
12480
|
+
}
|
|
12431
12481
|
this.thpState.setIsPaired(completionState !== 0);
|
|
12432
12482
|
this.thpState.setPhase("pairing");
|
|
12433
12483
|
if (!completionState && handshakeCredentials.credentials) {
|
|
12434
12484
|
this.thpState.removePairingCredential(handshakeCredentials.credentials);
|
|
12435
12485
|
await this.options.onPairingCredentialsChanged?.({
|
|
12436
|
-
credentials: this.thpState.pairingCredentials
|
|
12486
|
+
credentials: this.thpState.pairingCredentials,
|
|
12487
|
+
removed: [handshakeCredentials.credentials]
|
|
12437
12488
|
});
|
|
12438
12489
|
}
|
|
12439
12490
|
this.log("info", "thp.handshake.done", {
|
|
@@ -12467,6 +12518,9 @@ var TrezorThpSession = class {
|
|
|
12467
12518
|
selected_pairing_method: selectedMethod
|
|
12468
12519
|
});
|
|
12469
12520
|
if (selectMethod.type === "ThpEndResponse") {
|
|
12521
|
+
if (selectedMethod !== protocol_thp_exports.ThpPairingMethod.SkipPairing) {
|
|
12522
|
+
throw thpPairingRefused("Trezor ended pairing without completing the selected method");
|
|
12523
|
+
}
|
|
12470
12524
|
this.thpState.setIsPaired(true);
|
|
12471
12525
|
this.thpState.setPhase("paired");
|
|
12472
12526
|
this.log("info", "thp.pair.done", { responseType: selectMethod.type });
|