Use UUID-only sender certificate when applicable

This commit is contained in:
Evan Hahn 2021-04-05 15:38:36 -05:00 committed by Josh Perez
parent cfd77bf968
commit 18ccda83ba
3 changed files with 70 additions and 25 deletions

View file

@ -26,10 +26,7 @@ import {
UnregisteredUserError,
} from './Errors';
import { isValidNumber } from '../types/PhoneNumber';
import {
SecretSessionCipher,
SerializedCertificateType,
} from '../metadata/SecretSessionCipher';
import { SecretSessionCipher } from '../metadata/SecretSessionCipher';
type OutgoingMessageOptionsType = SendOptionsType & {
online?: boolean;
@ -62,8 +59,6 @@ export default class OutgoingMessage {
sendMetadata?: SendMetadataType;
senderCertificate?: SerializedCertificateType;
online?: boolean;
constructor(
@ -96,9 +91,8 @@ export default class OutgoingMessage {
this.failoverIdentifiers = [];
this.unidentifiedDeliveries = [];
const { sendMetadata, senderCertificate, online } = options;
const { sendMetadata, online } = options;
this.sendMetadata = sendMetadata;
this.senderCertificate = senderCertificate;
this.online = online;
}
@ -344,12 +338,8 @@ export default class OutgoingMessage {
} = {};
const plaintext = this.getPlaintext();
const { sendMetadata, senderCertificate } = this;
const info =
sendMetadata && sendMetadata[identifier]
? sendMetadata[identifier]
: { accessKey: undefined };
const { accessKey } = info;
const { sendMetadata } = this;
const { accessKey, senderCertificate } = sendMetadata?.[identifier] || {};
if (accessKey && !senderCertificate) {
window.log.warn(
@ -442,8 +432,8 @@ export default class OutgoingMessage {
}
// This ensures that we don't hit this codepath the next time through
if (info) {
info.accessKey = undefined;
if (sendMetadata) {
delete sendMetadata[identifier];
}
return this.doSendMessage(identifier, deviceIds, recurse);