Eliminate remaining Electron 8 deprecations
* Change systemPreferences.isDarkMode() to nativeTheme.shouldUseDarkColors * Remove vibrancy parameter to BrowserWindow * Update curve25519-n; removes context-aware deprecation warning * Set app.allowRendererProcessReuse = true to remove warning * Move from deprecated setters to direct property set * Serialized sender certificates: Store less, store plain object * isMenuBarAutoHide -> autoHideMenuBar * UUID: Fix sealed sender indicator on message details screen * Data._cleanData: Remove function keys, handle null in array Also: - run _cleanData when saving attachment download jobs - remove job from jobs table when the send itself throws error * _cleanData: Don't dig into strings, booleans, or numbers * getPropsForMessageDetail: Make it clear what we're reducing Co-authored-by: Ken Powers <ken@signal.org>
This commit is contained in:
parent
841461934d
commit
8d6cba1b43
11 changed files with 108 additions and 107 deletions
|
@ -43,28 +43,27 @@ function initialize({ events, storage, navigator, logger }) {
|
|||
function scheduleNextRotation() {
|
||||
const now = Date.now();
|
||||
const certificate = storage.get('senderCertificate');
|
||||
if (!certificate) {
|
||||
if (!certificate || !certificate.expires) {
|
||||
setTimeoutForNextRun(scheduledTime || now);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// The useful information in a SenderCertificate is all serialized, so we
|
||||
// need to do another layer of decoding.
|
||||
const decoded = textsecure.protobuf.SenderCertificate.Certificate.decode(
|
||||
certificate.certificate
|
||||
);
|
||||
const expires = decoded.expires.toNumber();
|
||||
|
||||
// If we have a time in place and it's already before the safety zone before expire,
|
||||
// we keep it
|
||||
if (scheduledTime && scheduledTime <= expires - MINIMUM_TIME_LEFT) {
|
||||
if (
|
||||
scheduledTime &&
|
||||
scheduledTime <= certificate.expires - MINIMUM_TIME_LEFT
|
||||
) {
|
||||
setTimeoutForNextRun(scheduledTime);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, we reset every day, or earlier if the safety zone requires it
|
||||
const time = Math.min(now + ONE_DAY, expires - MINIMUM_TIME_LEFT);
|
||||
const time = Math.min(
|
||||
now + ONE_DAY,
|
||||
certificate.expires - MINIMUM_TIME_LEFT
|
||||
);
|
||||
setTimeoutForNextRun(time);
|
||||
}
|
||||
|
||||
|
@ -88,18 +87,21 @@ function initialize({ events, storage, navigator, logger }) {
|
|||
const arrayBuffer = window.Signal.Crypto.base64ToArrayBuffer(
|
||||
certificate
|
||||
);
|
||||
const decoded = textsecure.protobuf.SenderCertificate.decode(
|
||||
const decodedContainer = textsecure.protobuf.SenderCertificate.decode(
|
||||
arrayBuffer
|
||||
);
|
||||
|
||||
decoded.certificate = decoded.certificate.toArrayBuffer();
|
||||
decoded.signature = decoded.signature.toArrayBuffer();
|
||||
decoded.serialized = arrayBuffer;
|
||||
|
||||
storage.put(
|
||||
`senderCertificate${withUuid ? 'WithUuid' : ''}`,
|
||||
decoded
|
||||
const decodedCert = textsecure.protobuf.SenderCertificate.Certificate.decode(
|
||||
decodedContainer.certificate
|
||||
);
|
||||
|
||||
// We don't want to send a protobuf-generated object across IPC, so we make
|
||||
// our own object.
|
||||
const toSave = {
|
||||
expires: decodedCert.expires.toNumber(),
|
||||
serialized: arrayBuffer,
|
||||
};
|
||||
|
||||
storage.put(`senderCertificate${withUuid ? 'WithUuid' : ''}`, toSave);
|
||||
})
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue