Skip to content

Commit ad7d8f9

Browse files
committed
Support new ShieldStateCode.MismatchedSender
1 parent 99523d2 commit ad7d8f9

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

spec/unit/rust-crypto/rust-crypto.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,11 @@ describe("RustCrypto", () => {
11401140
RustSdkCryptoJs.ShieldStateCode.VerificationViolation,
11411141
EventShieldReason.VERIFICATION_VIOLATION,
11421142
],
1143+
[
1144+
"Mismatched sender",
1145+
RustSdkCryptoJs.ShieldStateCode.MismatchedSender,
1146+
EventShieldReason.MISMATCHED_SENDER,
1147+
],
11431148
])("gets the right shield reason (%s)", async (rustReason, rustCode, expectedReason) => {
11441149
// suppress the warning from the unknown shield reason
11451150
jest.spyOn(console, "warn").mockImplementation(() => {});

src/crypto-api/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,12 @@ export enum EventShieldReason {
13551355
* The sender was previously verified but changed their identity.
13561356
*/
13571357
VERIFICATION_VIOLATION,
1358+
1359+
/**
1360+
* The `sender` field on the event does not match the owner of the device
1361+
* that established the Megolm session.
1362+
*/
1363+
MISMATCHED_SENDER,
13581364
}
13591365

13601366
/** The result of a call to {@link CryptoApi.getOwnDeviceKeys} */

src/rust-crypto/rust-crypto.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,6 +2277,12 @@ function rustEncryptionInfoToJsEncryptionInfo(
22772277
case RustSdkCryptoJs.ShieldStateCode.VerificationViolation:
22782278
shieldReason = EventShieldReason.VERIFICATION_VIOLATION;
22792279
break;
2280+
case RustSdkCryptoJs.ShieldStateCode.MismatchedSender:
2281+
shieldReason = EventShieldReason.MISMATCHED_SENDER;
2282+
break;
2283+
default:
2284+
shieldReason = EventShieldReason.UNKNOWN_DEVICE;
2285+
break;
22802286
}
22812287

22822288
return { shieldColour, shieldReason };

0 commit comments

Comments
 (0)