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