Clear stale sender certificates

This commit is contained in:
Scott Nonnenberg 2021-09-27 10:31:34 -07:00 committed by GitHub
parent 9888e6d38f
commit cf4c81b11c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 11 deletions

View file

@ -75,6 +75,24 @@ export class SenderCertificateService {
return this.fetchCertificate(mode);
}
// This is intended to be called when our credentials have been deleted, so any fetches
// made until this function is complete would fail anyway.
async clear(): Promise<void> {
log.info(
'Sender certificate service: Clearing in-progress fetches and ' +
'deleting cached certificates'
);
await Promise.all(this.fetchPromises.values());
const { storage } = this;
assert(
storage,
'Sender certificate service method was called before it was initialized'
);
await storage.remove('senderCertificate');
await storage.remove('senderCertificateNoE164');
}
private getStoredCertificate(
mode: SenderCertificateMode
): undefined | SerializedCertificateType {