@onekeyfe/hwk-trezor-core 1.2.8-alpha.5 → 1.2.8-alpha.50
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 +56 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -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
|
+
"ChVtZXNzYWdlcy1zb2xhbmEucHJvdG8SGWh3LnRyZXpvci5tZXNzYWdlcy5zb2xhbmEiPQoSU29sYW5hR2V0UHVibGljS2V5EhEKCWFkZHJlc3NfbhgBIAMoDRIUCgxzaG93X2Rpc3BsYXkYAiABKAgiJQoPU29sYW5hUHVibGljS2V5EhIKCnB1YmxpY19rZXkYASACKAwiTQoQU29sYW5hR2V0QWRkcmVzcxIRCglhZGRyZXNzX24YASADKA0SFAoMc2hvd19kaXNwbGF5GAIgASgIEhAKCGNodW5raWZ5GAMgASgIIi0KDVNvbGFuYUFkZHJlc3MSD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VyaWZ5TWVzc2FnZRIQCghjaHVua2lmeRgCIAEoCBJDCgdtZXNzYWdlGAMgAigLMjIuaHcudHJlem9yLm1lc3NhZ2VzLnNvbGFuYS5Tb2xhbmFPZmZjaGFpbk1lc3NhZ2VWMRISCgpzaWduYXR1cmVzGAQgAygMSgQIARACQjoKI2NvbS5zYXRvc2hpbGFicy50cmV6b3IubGliLnByb3RvYnVmQhNUcmV6b3JNZXNzYWdlU29sYW5h",
|
|
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)
|
|
@@ -12234,6 +12245,36 @@ var TrezorDeviceSession = class {
|
|
|
12234
12245
|
const response = await this.core.call("Initialize", {});
|
|
12235
12246
|
this.currentFeatures = expectMessage(response, "Features").message;
|
|
12236
12247
|
this.thpAppSessionActive = false;
|
|
12248
|
+
if (passphraseMode === "empty" && this.currentFeatures?.passphrase_protection == null) {
|
|
12249
|
+
expectMessage(
|
|
12250
|
+
await this.call("GetAddress", {
|
|
12251
|
+
address_n: [2147483692, 2147483649, 2147483648, 0, 0],
|
|
12252
|
+
coin_name: "Testnet",
|
|
12253
|
+
script_type: "SPENDADDRESS",
|
|
12254
|
+
show_display: false
|
|
12255
|
+
}),
|
|
12256
|
+
"Address"
|
|
12257
|
+
);
|
|
12258
|
+
expectMessage(await this.call("GetFeatures", {}), "Features");
|
|
12259
|
+
if (this.currentFeatures?.passphrase_protection == null) {
|
|
12260
|
+
throw new TrezorFailureError({
|
|
12261
|
+
type: "Failure",
|
|
12262
|
+
message: {
|
|
12263
|
+
code: "Failure_DataError",
|
|
12264
|
+
message: "Empty passphrase cannot be enforced: device did not report its passphrase setting"
|
|
12265
|
+
}
|
|
12266
|
+
});
|
|
12267
|
+
}
|
|
12268
|
+
}
|
|
12269
|
+
if (passphraseMode === "empty" && this.currentFeatures?.passphrase_protection === true && this.currentFeatures?.passphrase_always_on_device === true) {
|
|
12270
|
+
throw new TrezorFailureError({
|
|
12271
|
+
type: "Failure",
|
|
12272
|
+
message: {
|
|
12273
|
+
code: "Failure_DataError",
|
|
12274
|
+
message: "Empty passphrase cannot be enforced with PASSPHRASE_ALWAYS_ON_DEVICE enabled"
|
|
12275
|
+
}
|
|
12276
|
+
});
|
|
12277
|
+
}
|
|
12237
12278
|
this.log("info", "v1.appSession.create.done", {
|
|
12238
12279
|
features: summarizeFeatures(this.currentFeatures)
|
|
12239
12280
|
});
|
|
@@ -12361,7 +12402,8 @@ var TrezorThpSession = class {
|
|
|
12361
12402
|
}
|
|
12362
12403
|
const pairingMethods = getPairingMethods(
|
|
12363
12404
|
properties.pairing_methods,
|
|
12364
|
-
|
|
12405
|
+
// SkipPairing is for emulators and debug firmware only; production devices offer CodeEntry.
|
|
12406
|
+
this.options.pairingMethods ?? ["CodeEntry", "QrCode", "NFC"]
|
|
12365
12407
|
);
|
|
12366
12408
|
if (pairingMethods.length === 0) {
|
|
12367
12409
|
throw new Error("No compatible THP pairing method");
|
|
@@ -12428,12 +12470,16 @@ var TrezorThpSession = class {
|
|
|
12428
12470
|
"ThpHandshakeCompletionResponse"
|
|
12429
12471
|
);
|
|
12430
12472
|
const completionState = completion.message.state;
|
|
12473
|
+
if (completionState !== 0 && !handshakeCredentials.credentials) {
|
|
12474
|
+
throw thpPairingRefused("Trezor reported a pairing that no stored credential confirms");
|
|
12475
|
+
}
|
|
12431
12476
|
this.thpState.setIsPaired(completionState !== 0);
|
|
12432
12477
|
this.thpState.setPhase("pairing");
|
|
12433
12478
|
if (!completionState && handshakeCredentials.credentials) {
|
|
12434
12479
|
this.thpState.removePairingCredential(handshakeCredentials.credentials);
|
|
12435
12480
|
await this.options.onPairingCredentialsChanged?.({
|
|
12436
|
-
credentials: this.thpState.pairingCredentials
|
|
12481
|
+
credentials: this.thpState.pairingCredentials,
|
|
12482
|
+
removed: [handshakeCredentials.credentials]
|
|
12437
12483
|
});
|
|
12438
12484
|
}
|
|
12439
12485
|
this.log("info", "thp.handshake.done", {
|
|
@@ -12467,6 +12513,9 @@ var TrezorThpSession = class {
|
|
|
12467
12513
|
selected_pairing_method: selectedMethod
|
|
12468
12514
|
});
|
|
12469
12515
|
if (selectMethod.type === "ThpEndResponse") {
|
|
12516
|
+
if (selectedMethod !== protocol_thp_exports.ThpPairingMethod.SkipPairing) {
|
|
12517
|
+
throw thpPairingRefused("Trezor ended pairing without completing the selected method");
|
|
12518
|
+
}
|
|
12470
12519
|
this.thpState.setIsPaired(true);
|
|
12471
12520
|
this.thpState.setPhase("paired");
|
|
12472
12521
|
this.log("info", "thp.pair.done", { responseType: selectMethod.type });
|