Add exhaustive UUIDKind checks to MessageReceiver

This commit is contained in:
Fedor Indutny 2021-11-16 01:10:18 +01:00 committed by GitHub
parent c6ee6a038e
commit 5076972c5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -1070,6 +1070,8 @@ export default class MessageReceiver
return undefined;
}
strictAssert(uuidKind === UUIDKind.ACI, 'Sealed non-ACI envelope');
const ciphertext = envelope.content || envelope.legacyMessage;
if (!ciphertext) {
this.removeFromCache(envelope);
@ -1441,6 +1443,11 @@ export default class MessageReceiver
return undefined;
}
strictAssert(
uuidKind === UUIDKind.PNI || uuidKind === UUIDKind.ACI,
`Unsupported uuidKind: ${uuidKind}`
);
if (envelope.type === envelopeTypeEnum.PLAINTEXT_CONTENT) {
log.info(`decrypt/${logId}: plaintext message`);
const buffer = Buffer.from(ciphertext);