You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
Fix the message for messages from unknown devices (#3743)
This commit is contained in:
committed by
GitHub
parent
fde6cebc20
commit
f134d6db01
@ -258,7 +258,7 @@ describe("Crypto", function () {
|
|||||||
const event = await buildEncryptedEvent();
|
const event = await buildEncryptedEvent();
|
||||||
expect(await client.getCrypto()!.getEncryptionInfoForEvent(event)).toEqual({
|
expect(await client.getCrypto()!.getEncryptionInfoForEvent(event)).toEqual({
|
||||||
shieldColour: EventShieldColour.RED,
|
shieldColour: EventShieldColour.RED,
|
||||||
shieldReason: EventShieldReason.UNVERIFIED_IDENTITY,
|
shieldReason: EventShieldReason.UNSIGNED_DEVICE,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2738,6 +2738,8 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
|||||||
const senderId = event.getSender();
|
const senderId = event.getSender();
|
||||||
if (!senderId || encryptionInfo.mismatchedSender) {
|
if (!senderId || encryptionInfo.mismatchedSender) {
|
||||||
// something definitely wrong is going on here
|
// something definitely wrong is going on here
|
||||||
|
|
||||||
|
// previously: E2EState.Warning -> E2ePadlockUnverified -> Red/"Encrypted by an unverified session"
|
||||||
return {
|
return {
|
||||||
shieldColour: EventShieldColour.RED,
|
shieldColour: EventShieldColour.RED,
|
||||||
shieldReason: EventShieldReason.MISMATCHED_SENDER_KEY,
|
shieldReason: EventShieldReason.MISMATCHED_SENDER_KEY,
|
||||||
@ -2750,11 +2752,13 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
|||||||
// shield, otherwise if the user isn't cross-signed then
|
// shield, otherwise if the user isn't cross-signed then
|
||||||
// nothing's needed
|
// nothing's needed
|
||||||
if (!encryptionInfo.authenticated) {
|
if (!encryptionInfo.authenticated) {
|
||||||
|
// previously: E2EState.Unauthenticated -> E2ePadlockUnauthenticated -> Grey/"The authenticity of this encrypted message can't be guaranteed on this device."
|
||||||
return {
|
return {
|
||||||
shieldColour: EventShieldColour.GREY,
|
shieldColour: EventShieldColour.GREY,
|
||||||
shieldReason: EventShieldReason.AUTHENTICITY_NOT_GUARANTEED,
|
shieldReason: EventShieldReason.AUTHENTICITY_NOT_GUARANTEED,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
// previously: E2EState.Normal -> no icon
|
||||||
return { shieldColour: EventShieldColour.NONE, shieldReason: null };
|
return { shieldColour: EventShieldColour.NONE, shieldReason: null };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2765,6 +2769,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
|||||||
(await this.getDeviceVerificationStatus(senderId, encryptionInfo.sender.deviceId));
|
(await this.getDeviceVerificationStatus(senderId, encryptionInfo.sender.deviceId));
|
||||||
|
|
||||||
if (!eventSenderTrust) {
|
if (!eventSenderTrust) {
|
||||||
|
// previously: E2EState.Unknown -> E2ePadlockUnknown -> Grey/"Encrypted by a deleted session"
|
||||||
return {
|
return {
|
||||||
shieldColour: EventShieldColour.GREY,
|
shieldColour: EventShieldColour.GREY,
|
||||||
shieldReason: EventShieldReason.UNKNOWN_DEVICE,
|
shieldReason: EventShieldReason.UNKNOWN_DEVICE,
|
||||||
@ -2772,19 +2777,22 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!eventSenderTrust.isVerified()) {
|
if (!eventSenderTrust.isVerified()) {
|
||||||
|
// previously: E2EState.Warning -> E2ePadlockUnverified -> Red/"Encrypted by an unverified session"
|
||||||
return {
|
return {
|
||||||
shieldColour: EventShieldColour.RED,
|
shieldColour: EventShieldColour.RED,
|
||||||
shieldReason: EventShieldReason.UNVERIFIED_IDENTITY,
|
shieldReason: EventShieldReason.UNSIGNED_DEVICE,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!encryptionInfo.authenticated) {
|
if (!encryptionInfo.authenticated) {
|
||||||
|
// previously: E2EState.Unauthenticated -> E2ePadlockUnauthenticated -> Grey/"The authenticity of this encrypted message can't be guaranteed on this device."
|
||||||
return {
|
return {
|
||||||
shieldColour: EventShieldColour.GREY,
|
shieldColour: EventShieldColour.GREY,
|
||||||
shieldReason: EventShieldReason.AUTHENTICITY_NOT_GUARANTEED,
|
shieldReason: EventShieldReason.AUTHENTICITY_NOT_GUARANTEED,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// previously: E2EState.Verified -> no icon
|
||||||
return { shieldColour: EventShieldColour.NONE, shieldReason: null };
|
return { shieldColour: EventShieldColour.NONE, shieldReason: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1649,6 +1649,7 @@ function rustEncryptionInfoToJsEncryptionInfo(
|
|||||||
if (shieldState.message === null) {
|
if (shieldState.message === null) {
|
||||||
shieldReason = null;
|
shieldReason = null;
|
||||||
} else if (shieldState.message === "Encrypted by an unverified user.") {
|
} else if (shieldState.message === "Encrypted by an unverified user.") {
|
||||||
|
// this case isn't actually used with lax shield semantics.
|
||||||
shieldReason = EventShieldReason.UNVERIFIED_IDENTITY;
|
shieldReason = EventShieldReason.UNVERIFIED_IDENTITY;
|
||||||
} else if (shieldState.message === "Encrypted by a device not verified by its owner.") {
|
} else if (shieldState.message === "Encrypted by a device not verified by its owner.") {
|
||||||
shieldReason = EventShieldReason.UNSIGNED_DEVICE;
|
shieldReason = EventShieldReason.UNSIGNED_DEVICE;
|
||||||
|
Reference in New Issue
Block a user