You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Rename redecryption-related function arguments for clarity (#2709)
This commit is contained in:
@@ -1795,12 +1795,17 @@ class MegolmDecryption extends DecryptionAlgorithm {
|
|||||||
* @private
|
* @private
|
||||||
* @param {String} senderKey
|
* @param {String} senderKey
|
||||||
* @param {String} sessionId
|
* @param {String} sessionId
|
||||||
* @param {Boolean} keyTrusted
|
* @param {Boolean} forceRedecryptIfUntrusted whether messages that were already
|
||||||
|
* successfully decrypted using untrusted keys should be re-decrypted
|
||||||
*
|
*
|
||||||
* @return {Boolean} whether all messages were successfully
|
* @return {Boolean} whether all messages were successfully
|
||||||
* decrypted with trusted keys
|
* decrypted with trusted keys
|
||||||
*/
|
*/
|
||||||
private async retryDecryption(senderKey: string, sessionId: string, keyTrusted?: boolean): Promise<boolean> {
|
private async retryDecryption(
|
||||||
|
senderKey: string,
|
||||||
|
sessionId: string,
|
||||||
|
forceRedecryptIfUntrusted?: boolean,
|
||||||
|
): Promise<boolean> {
|
||||||
const senderPendingEvents = this.pendingEvents.get(senderKey);
|
const senderPendingEvents = this.pendingEvents.get(senderKey);
|
||||||
if (!senderPendingEvents) {
|
if (!senderPendingEvents) {
|
||||||
return true;
|
return true;
|
||||||
@@ -1815,7 +1820,7 @@ class MegolmDecryption extends DecryptionAlgorithm {
|
|||||||
|
|
||||||
await Promise.all([...pending].map(async (ev) => {
|
await Promise.all([...pending].map(async (ev) => {
|
||||||
try {
|
try {
|
||||||
await ev.attemptDecryption(this.crypto, { isRetry: true, keyTrusted });
|
await ev.attemptDecryption(this.crypto, { isRetry: true, forceRedecryptIfUntrusted });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// don't die if something goes wrong
|
// don't die if something goes wrong
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ interface IKeyRequestRecipient {
|
|||||||
export interface IDecryptOptions {
|
export interface IDecryptOptions {
|
||||||
emit?: boolean;
|
emit?: boolean;
|
||||||
isRetry?: boolean;
|
isRetry?: boolean;
|
||||||
keyTrusted?: boolean;
|
forceRedecryptIfUntrusted?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -678,6 +678,8 @@ export class MatrixEvent extends TypedEventEmitter<EmittedEvents, MatrixEventHan
|
|||||||
* @param {object} options
|
* @param {object} options
|
||||||
* @param {boolean} options.isRetry True if this is a retry (enables more logging)
|
* @param {boolean} options.isRetry True if this is a retry (enables more logging)
|
||||||
* @param {boolean} options.emit Emits "event.decrypted" if set to true
|
* @param {boolean} options.emit Emits "event.decrypted" if set to true
|
||||||
|
* @param {boolean} options.forceRedecryptIfUntrusted whether the message should be
|
||||||
|
* re-decrypted if it was previously successfully decrypted with an untrusted key
|
||||||
*
|
*
|
||||||
* @returns {Promise} promise which resolves (to undefined) when the decryption
|
* @returns {Promise} promise which resolves (to undefined) when the decryption
|
||||||
* attempt is completed.
|
* attempt is completed.
|
||||||
@@ -696,7 +698,9 @@ export class MatrixEvent extends TypedEventEmitter<EmittedEvents, MatrixEventHan
|
|||||||
throw new Error("Attempt to decrypt event which isn't encrypted");
|
throw new Error("Attempt to decrypt event which isn't encrypted");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.clearEvent && !this.isDecryptionFailure() && !(this.isKeySourceUntrusted() && options.keyTrusted)) {
|
const alreadyDecrypted = this.clearEvent && !this.isDecryptionFailure();
|
||||||
|
const forceRedecrypt = options.forceRedecryptIfUntrusted && this.isKeySourceUntrusted();
|
||||||
|
if (alreadyDecrypted && !forceRedecrypt) {
|
||||||
// we may want to just ignore this? let's start with rejecting it.
|
// we may want to just ignore this? let's start with rejecting it.
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Attempt to decrypt event which has already been decrypted",
|
"Attempt to decrypt event which has already been decrypted",
|
||||||
|
|||||||
Reference in New Issue
Block a user