@onekeyfe/hwk-trezor-core 1.2.8-alpha.50 → 1.2.8-alpha.51
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 -3
- package/dist/index.d.ts +0 -3
- package/dist/index.js +7 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -206,10 +206,7 @@ type TrezorThpSessionOptions = {
|
|
|
206
206
|
* it back via `knownCredentials` on the next connect to skip pairing UX.
|
|
207
207
|
*/
|
|
208
208
|
onPairingCredentialsChanged?: (payload: {
|
|
209
|
-
/** This device's credentials only, never other devices'. */
|
|
210
209
|
credentials: TrezorThpCredentials[];
|
|
211
|
-
/** Credentials the device rejected; a host keeping one list for all devices drops these. */
|
|
212
|
-
removed?: TrezorThpCredentials[];
|
|
213
210
|
}) => Promise<void> | void;
|
|
214
211
|
logger?: TrezorDebugLogger;
|
|
215
212
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -206,10 +206,7 @@ type TrezorThpSessionOptions = {
|
|
|
206
206
|
* it back via `knownCredentials` on the next connect to skip pairing UX.
|
|
207
207
|
*/
|
|
208
208
|
onPairingCredentialsChanged?: (payload: {
|
|
209
|
-
/** This device's credentials only, never other devices'. */
|
|
210
209
|
credentials: TrezorThpCredentials[];
|
|
211
|
-
/** Credentials the device rejected; a host keeping one list for all devices drops these. */
|
|
212
|
-
removed?: TrezorThpCredentials[];
|
|
213
210
|
}) => Promise<void> | void;
|
|
214
211
|
logger?: TrezorDebugLogger;
|
|
215
212
|
};
|
package/dist/index.js
CHANGED
|
@@ -7901,7 +7901,6 @@ __export(messages_solana_pb_exports, {
|
|
|
7901
7901
|
SolanaGetAddressSchema: () => SolanaGetAddressSchema,
|
|
7902
7902
|
SolanaGetPublicKeySchema: () => SolanaGetPublicKeySchema,
|
|
7903
7903
|
SolanaMessageSignatureSchema: () => SolanaMessageSignatureSchema,
|
|
7904
|
-
SolanaOffchainMessageV1Schema: () => SolanaOffchainMessageV1Schema,
|
|
7905
7904
|
SolanaPublicKeySchema: () => SolanaPublicKeySchema,
|
|
7906
7905
|
SolanaSignMessageSchema: () => SolanaSignMessageSchema,
|
|
7907
7906
|
SolanaSignTxSchema: () => SolanaSignTxSchema,
|
|
@@ -7913,7 +7912,7 @@ __export(messages_solana_pb_exports, {
|
|
|
7913
7912
|
});
|
|
7914
7913
|
init_buffer();
|
|
7915
7914
|
var file_messages_solana = fileDesc(
|
|
7916
|
-
"
|
|
7915
|
+
"ChVtZXNzYWdlcy1zb2xhbmEucHJvdG8SGWh3LnRyZXpvci5tZXNzYWdlcy5zb2xhbmEiPQoSU29sYW5hR2V0UHVibGljS2V5EhEKCWFkZHJlc3NfbhgBIAMoDRIUCgxzaG93X2Rpc3BsYXkYAiABKAgiJQoPU29sYW5hUHVibGljS2V5EhIKCnB1YmxpY19rZXkYASACKAwiTQoQU29sYW5hR2V0QWRkcmVzcxIRCglhZGRyZXNzX24YASADKA0SFAoMc2hvd19kaXNwbGF5GAIgASgIEhAKCGNodW5raWZ5GAMgASgIIi0KDVNvbGFuYUFkZHJlc3MSDwoHYWRkcmVzcxgBIAIoCRILCgNtYWMYAiABKAwicgoYU29sYW5hVHhUb2tlbkFjY291bnRJbmZvEhQKDGJhc2VfYWRkcmVzcxgBIAIoCRIVCg10b2tlbl9wcm9ncmFtGAIgAigJEhIKCnRva2VuX21pbnQYAyACKAkSFQoNdG9rZW5fYWNjb3VudBgEIAIoCSKCAQoWU29sYW5hVHhBZGRpdGlvbmFsSW5mbxJRChR0b2tlbl9hY2NvdW50c19pbmZvcxgBIAMoCzIzLmh3LnRyZXpvci5tZXNzYWdlcy5zb2xhbmEuU29sYW5hVHhUb2tlbkFjY291bnRJbmZvEhUKDWVuY29kZWRfdG9rZW4YAiABKAwi1gEKDFNvbGFuYVNpZ25UeBIRCglhZGRyZXNzX24YASADKA0SFQoNc2VyaWFsaXplZF90eBgCIAIoDBJKCg9hZGRpdGlvbmFsX2luZm8YAyABKAsyMS5ody50cmV6b3IubWVzc2FnZXMuc29sYW5hLlNvbGFuYVR4QWRkaXRpb25hbEluZm8SPgoLcGF5bWVudF9yZXEYBCABKAsyKS5ody50cmV6b3IubWVzc2FnZXMuY29tbW9uLlBheW1lbnRSZXF1ZXN0EhAKCGNodW5raWZ5GAUgASgIIiYKEVNvbGFuYVR4U2lnbmF0dXJlEhEKCXNpZ25hdHVyZRgBIAIoDCJJChFTb2xhbmFTaWduTWVzc2FnZRIRCglhZGRyZXNzX24YASADKA0SDwoHbWVzc2FnZRgCIAIoDBIQCghjaHVua2lmeRgDIAEoCCIrChZTb2xhbmFNZXNzYWdlU2lnbmF0dXJlEhEKCXNpZ25hdHVyZRgBIAIoDCI5ChNTb2xhbmFWZXJpZnlNZXNzYWdlEhAKCGVudmVsb3BlGAEgAigMEhAKCGNodW5raWZ5GAIgASgIQjoKI2NvbS5zYXRvc2hpbGFicy50cmV6b3IubGliLnByb3RvYnVmQhNUcmV6b3JNZXNzYWdlU29sYW5h",
|
|
7917
7916
|
[file_messages_common]
|
|
7918
7917
|
);
|
|
7919
7918
|
var SolanaGetPublicKeySchema = messageDesc(file_messages_solana, 0);
|
|
@@ -7924,10 +7923,9 @@ var SolanaTxTokenAccountInfoSchema = messageDesc(file_messages_solana, 4);
|
|
|
7924
7923
|
var SolanaTxAdditionalInfoSchema = messageDesc(file_messages_solana, 5);
|
|
7925
7924
|
var SolanaSignTxSchema = messageDesc(file_messages_solana, 6);
|
|
7926
7925
|
var SolanaTxSignatureSchema = messageDesc(file_messages_solana, 7);
|
|
7927
|
-
var
|
|
7928
|
-
var
|
|
7929
|
-
var
|
|
7930
|
-
var SolanaVerifyMessageSchema = messageDesc(file_messages_solana, 11);
|
|
7926
|
+
var SolanaSignMessageSchema = messageDesc(file_messages_solana, 8);
|
|
7927
|
+
var SolanaMessageSignatureSchema = messageDesc(file_messages_solana, 9);
|
|
7928
|
+
var SolanaVerifyMessageSchema = messageDesc(file_messages_solana, 10);
|
|
7931
7929
|
|
|
7932
7930
|
// ../hwk-trezor-protobuf/src/definitions/messages-stellar_pb.js
|
|
7933
7931
|
var messages_stellar_pb_exports = {};
|
|
@@ -11276,8 +11274,7 @@ async function receive(receiver, protocol) {
|
|
|
11276
11274
|
} catch (e) {
|
|
11277
11275
|
console.warn("Protocol decode failed", {
|
|
11278
11276
|
error: e.message,
|
|
11279
|
-
|
|
11280
|
-
payloadHead: readResult.payload.subarray(0, 2).toString("hex")
|
|
11277
|
+
payload: readResult.payload.toString("hex")
|
|
11281
11278
|
});
|
|
11282
11279
|
return error({ code: PROTOCOL_MALFORMED, message: e.message });
|
|
11283
11280
|
}
|
|
@@ -12002,9 +11999,6 @@ var normalizeCreateAppSessionOptions = (options = {}) => {
|
|
|
12002
11999
|
passphraseMode
|
|
12003
12000
|
};
|
|
12004
12001
|
};
|
|
12005
|
-
function thpPairingRefused(message) {
|
|
12006
|
-
return Object.assign(new Error(message), { code: "ThpPairingFailed" });
|
|
12007
|
-
}
|
|
12008
12002
|
var TrezorDeviceSession = class {
|
|
12009
12003
|
transport;
|
|
12010
12004
|
connectionType;
|
|
@@ -12088,11 +12082,6 @@ var TrezorDeviceSession = class {
|
|
|
12088
12082
|
this.log("error", "session.initialize.error", { error: errorToLog(error2) });
|
|
12089
12083
|
throw error2;
|
|
12090
12084
|
}
|
|
12091
|
-
if (this.connectionType === "ble" && this.currentFeatures?.bootloader_mode !== true) {
|
|
12092
|
-
this.core = void 0;
|
|
12093
|
-
this.currentFeatures = void 0;
|
|
12094
|
-
throw thpPairingRefused("Trezor Bluetooth requires the encrypted THP protocol");
|
|
12095
|
-
}
|
|
12096
12085
|
this.log("info", "session.initialize.done", {
|
|
12097
12086
|
protocol: this.protocol,
|
|
12098
12087
|
features: summarizeFeatures(this.currentFeatures)
|
|
@@ -12260,36 +12249,6 @@ var TrezorDeviceSession = class {
|
|
|
12260
12249
|
const response = await this.core.call("Initialize", {});
|
|
12261
12250
|
this.currentFeatures = expectMessage(response, "Features").message;
|
|
12262
12251
|
this.thpAppSessionActive = false;
|
|
12263
|
-
if (passphraseMode === "empty" && this.currentFeatures?.passphrase_protection == null) {
|
|
12264
|
-
expectMessage(
|
|
12265
|
-
await this.call("GetAddress", {
|
|
12266
|
-
address_n: [2147483692, 2147483649, 2147483648, 0, 0],
|
|
12267
|
-
coin_name: "Testnet",
|
|
12268
|
-
script_type: "SPENDADDRESS",
|
|
12269
|
-
show_display: false
|
|
12270
|
-
}),
|
|
12271
|
-
"Address"
|
|
12272
|
-
);
|
|
12273
|
-
expectMessage(await this.call("GetFeatures", {}), "Features");
|
|
12274
|
-
if (this.currentFeatures?.passphrase_protection == null) {
|
|
12275
|
-
throw new TrezorFailureError({
|
|
12276
|
-
type: "Failure",
|
|
12277
|
-
message: {
|
|
12278
|
-
code: "Failure_DataError",
|
|
12279
|
-
message: "Empty passphrase cannot be enforced: device did not report its passphrase setting"
|
|
12280
|
-
}
|
|
12281
|
-
});
|
|
12282
|
-
}
|
|
12283
|
-
}
|
|
12284
|
-
if (passphraseMode === "empty" && this.currentFeatures?.passphrase_protection === true && this.currentFeatures?.passphrase_always_on_device === true) {
|
|
12285
|
-
throw new TrezorFailureError({
|
|
12286
|
-
type: "Failure",
|
|
12287
|
-
message: {
|
|
12288
|
-
code: "Failure_DataError",
|
|
12289
|
-
message: "Empty passphrase cannot be enforced with PASSPHRASE_ALWAYS_ON_DEVICE enabled"
|
|
12290
|
-
}
|
|
12291
|
-
});
|
|
12292
|
-
}
|
|
12293
12252
|
this.log("info", "v1.appSession.create.done", {
|
|
12294
12253
|
features: summarizeFeatures(this.currentFeatures)
|
|
12295
12254
|
});
|
|
@@ -12417,8 +12376,7 @@ var TrezorThpSession = class {
|
|
|
12417
12376
|
}
|
|
12418
12377
|
const pairingMethods = getPairingMethods(
|
|
12419
12378
|
properties.pairing_methods,
|
|
12420
|
-
|
|
12421
|
-
this.options.pairingMethods ?? ["CodeEntry", "QrCode", "NFC"]
|
|
12379
|
+
this.options.pairingMethods ?? ["CodeEntry", "QrCode", "NFC", "SkipPairing"]
|
|
12422
12380
|
);
|
|
12423
12381
|
if (pairingMethods.length === 0) {
|
|
12424
12382
|
throw new Error("No compatible THP pairing method");
|
|
@@ -12485,16 +12443,12 @@ var TrezorThpSession = class {
|
|
|
12485
12443
|
"ThpHandshakeCompletionResponse"
|
|
12486
12444
|
);
|
|
12487
12445
|
const completionState = completion.message.state;
|
|
12488
|
-
if (completionState !== 0 && !handshakeCredentials.credentials) {
|
|
12489
|
-
throw thpPairingRefused("Trezor reported a pairing that no stored credential confirms");
|
|
12490
|
-
}
|
|
12491
12446
|
this.thpState.setIsPaired(completionState !== 0);
|
|
12492
12447
|
this.thpState.setPhase("pairing");
|
|
12493
12448
|
if (!completionState && handshakeCredentials.credentials) {
|
|
12494
12449
|
this.thpState.removePairingCredential(handshakeCredentials.credentials);
|
|
12495
12450
|
await this.options.onPairingCredentialsChanged?.({
|
|
12496
|
-
credentials: this.thpState.pairingCredentials
|
|
12497
|
-
removed: [handshakeCredentials.credentials]
|
|
12451
|
+
credentials: this.thpState.pairingCredentials
|
|
12498
12452
|
});
|
|
12499
12453
|
}
|
|
12500
12454
|
this.log("info", "thp.handshake.done", {
|
|
@@ -12528,9 +12482,6 @@ var TrezorThpSession = class {
|
|
|
12528
12482
|
selected_pairing_method: selectedMethod
|
|
12529
12483
|
});
|
|
12530
12484
|
if (selectMethod.type === "ThpEndResponse") {
|
|
12531
|
-
if (selectedMethod !== protocol_thp_exports.ThpPairingMethod.SkipPairing) {
|
|
12532
|
-
throw thpPairingRefused("Trezor ended pairing without completing the selected method");
|
|
12533
|
-
}
|
|
12534
12485
|
this.thpState.setIsPaired(true);
|
|
12535
12486
|
this.thpState.setPhase("paired");
|
|
12536
12487
|
this.log("info", "thp.pair.done", { responseType: selectMethod.type });
|