You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Improve decryption failure logging (#2453)
* Improve typing * Log the actual errors to include call stacks
This commit is contained in:
committed by
GitHub
parent
aaf508e309
commit
4897bccdc9
@@ -92,7 +92,7 @@ export interface InboundGroupSessionData {
|
|||||||
sharedHistory?: boolean;
|
sharedHistory?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IDecryptedGroupMessage {
|
export interface IDecryptedGroupMessage {
|
||||||
result: string;
|
result: string;
|
||||||
keysClaimed: Record<string, string>;
|
keysClaimed: Record<string, string>;
|
||||||
senderKey: string;
|
senderKey: string;
|
||||||
@@ -100,6 +100,11 @@ interface IDecryptedGroupMessage {
|
|||||||
untrusted: boolean;
|
untrusted: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IInboundSession {
|
||||||
|
payload: string;
|
||||||
|
session_id: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IExportedDevice {
|
export interface IExportedDevice {
|
||||||
pickleKey: string;
|
pickleKey: string;
|
||||||
pickledAccount: string;
|
pickledAccount: string;
|
||||||
@@ -620,7 +625,7 @@ export class OlmDevice {
|
|||||||
theirDeviceIdentityKey: string,
|
theirDeviceIdentityKey: string,
|
||||||
messageType: number,
|
messageType: number,
|
||||||
ciphertext: string,
|
ciphertext: string,
|
||||||
): Promise<{ payload: string, session_id: string }> { // eslint-disable-line camelcase
|
): Promise<IInboundSession> {
|
||||||
if (messageType !== 0) {
|
if (messageType !== 0) {
|
||||||
throw new Error("Need messageType == 0 to create inbound session");
|
throw new Error("Need messageType == 0 to create inbound session");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import {
|
|||||||
registerAlgorithm,
|
registerAlgorithm,
|
||||||
UnknownDeviceError,
|
UnknownDeviceError,
|
||||||
} from "./base";
|
} from "./base";
|
||||||
import { WITHHELD_MESSAGES } from '../OlmDevice';
|
import { IDecryptedGroupMessage, WITHHELD_MESSAGES } from '../OlmDevice';
|
||||||
import { Room } from '../../models/room';
|
import { Room } from '../../models/room';
|
||||||
import { DeviceInfo } from "../deviceinfo";
|
import { DeviceInfo } from "../deviceinfo";
|
||||||
import { IOlmSessionResult } from "../olmlib";
|
import { IOlmSessionResult } from "../olmlib";
|
||||||
@@ -1280,7 +1280,7 @@ class MegolmDecryption extends DecryptionAlgorithm {
|
|||||||
// (fixes https://github.com/vector-im/element-web/issues/5001)
|
// (fixes https://github.com/vector-im/element-web/issues/5001)
|
||||||
this.addEventToPendingList(event);
|
this.addEventToPendingList(event);
|
||||||
|
|
||||||
let res;
|
let res: IDecryptedGroupMessage;
|
||||||
try {
|
try {
|
||||||
res = await this.olmDevice.decryptGroupMessage(
|
res = await this.olmDevice.decryptGroupMessage(
|
||||||
event.getRoomId(), content.sender_key, content.session_id, content.ciphertext,
|
event.getRoomId(), content.sender_key, content.session_id, content.ciphertext,
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import {
|
|||||||
import { Room } from '../../models/room';
|
import { Room } from '../../models/room';
|
||||||
import { MatrixEvent } from "../..";
|
import { MatrixEvent } from "../..";
|
||||||
import { IEventDecryptionResult } from "../index";
|
import { IEventDecryptionResult } from "../index";
|
||||||
|
import { IInboundSession } from "../OlmDevice";
|
||||||
|
|
||||||
const DeviceVerification = DeviceInfo.DeviceVerification;
|
const DeviceVerification = DeviceInfo.DeviceVerification;
|
||||||
|
|
||||||
@@ -331,7 +332,7 @@ class OlmDecryption extends DecryptionAlgorithm {
|
|||||||
// prekey message which doesn't match any existing sessions: make a new
|
// prekey message which doesn't match any existing sessions: make a new
|
||||||
// session.
|
// session.
|
||||||
|
|
||||||
let res;
|
let res: IInboundSession;
|
||||||
try {
|
try {
|
||||||
res = await this.olmDevice.createInboundSession(
|
res = await this.olmDevice.createInboundSession(
|
||||||
theirDeviceIdentityKey, message.type, message.body,
|
theirDeviceIdentityKey, message.type, message.body,
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ export async function ensureOlmSessionsForDevices(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const oneTimeKeyAlgorithm = "signed_curve25519";
|
const oneTimeKeyAlgorithm = "signed_curve25519";
|
||||||
let res;
|
let res: IClaimOTKsResult;
|
||||||
let taskDetail = `one-time keys for ${devicesWithoutSession.length} devices`;
|
let taskDetail = `one-time keys for ${devicesWithoutSession.length} devices`;
|
||||||
try {
|
try {
|
||||||
log.debug(`Claiming ${taskDetail}`);
|
log.debug(`Claiming ${taskDetail}`);
|
||||||
|
|||||||
@@ -823,18 +823,13 @@ export class MatrixEvent extends TypedEventEmitter<EmittedEvents, MatrixEventHan
|
|||||||
//
|
//
|
||||||
if (this.retryDecryption) {
|
if (this.retryDecryption) {
|
||||||
// decryption error, but we have a retry queued.
|
// decryption error, but we have a retry queued.
|
||||||
logger.log(
|
logger.log(`Got error decrypting event (id=${this.getId()}: ${e.detailedString}), but retrying`, e);
|
||||||
`Got error decrypting event (id=${this.getId()}: ` +
|
|
||||||
`${e}), but retrying`,
|
|
||||||
);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// decryption error, no retries queued. Warn about the error and
|
// decryption error, no retries queued. Warn about the error and
|
||||||
// set it to m.bad.encrypted.
|
// set it to m.bad.encrypted.
|
||||||
logger.warn(
|
logger.warn(`Got error decrypting event (id=${this.getId()}: ${e.detailedString})`, e);
|
||||||
`Error decrypting event (id=${this.getId()}): ${e.detailedString}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
res = this.badEncryptedMessage(e.message);
|
res = this.badEncryptedMessage(e.message);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user