Migrate to SQLCipher for messages/cache

Quite a few other fixes, including:
  - Sending to contact with no avatar yet (not synced from mobile)
  - Left pane doesn't update quickly or at all on new message
  - Left pane doesn't show sent or error status

Also:
 - Contributing.md: Ensure set of linux dev dependencies is complete
This commit is contained in:
Scott Nonnenberg 2018-07-26 18:13:56 -07:00
commit 3105b77475
29 changed files with 2006 additions and 716 deletions

View file

@ -2,21 +2,7 @@
// eslint-disable-next-line func-names
(function() {
const registeredFunctions = {};
const Type = {
ENCRYPT_MESSAGE: 1,
INIT_SESSION: 2,
TRANSMIT_MESSAGE: 3,
REBUILD_MESSAGE: 4,
RETRY_SEND_MESSAGE_PROTO: 5,
};
window.textsecure = window.textsecure || {};
window.textsecure.replay = {
Type,
registerFunction(func, functionCode) {
registeredFunctions[functionCode] = func;
},
};
function inherit(Parent, Child) {
// eslint-disable-next-line no-param-reassign
@ -46,23 +32,15 @@
}
this.functionCode = options.functionCode;
this.args = options.args;
}
inherit(Error, ReplayableError);
ReplayableError.prototype.replay = function replay(...argumentsAsArray) {
const args = this.args.concat(argumentsAsArray);
return registeredFunctions[this.functionCode].apply(window, args);
};
function IncomingIdentityKeyError(number, message, key) {
// eslint-disable-next-line prefer-destructuring
this.number = number.split('.')[0];
this.identityKey = key;
ReplayableError.call(this, {
functionCode: Type.INIT_SESSION,
args: [number, message],
name: 'IncomingIdentityKeyError',
message: `The identity of ${this.number} has changed.`,
});
@ -75,8 +53,6 @@
this.identityKey = identityKey;
ReplayableError.call(this, {
functionCode: Type.ENCRYPT_MESSAGE,
args: [number, message, timestamp],
name: 'OutgoingIdentityKeyError',
message: `The identity of ${this.number} has changed.`,
});
@ -84,9 +60,10 @@
inherit(ReplayableError, OutgoingIdentityKeyError);
function OutgoingMessageError(number, message, timestamp, httpError) {
// eslint-disable-next-line prefer-destructuring
this.number = number.split('.')[0];
ReplayableError.call(this, {
functionCode: Type.ENCRYPT_MESSAGE,
args: [number, message, timestamp],
name: 'OutgoingMessageError',
message: httpError ? httpError.message : 'no http error',
});
@ -98,13 +75,11 @@
}
inherit(ReplayableError, OutgoingMessageError);
function SendMessageNetworkError(number, jsonData, httpError, timestamp) {
function SendMessageNetworkError(number, jsonData, httpError) {
this.number = number;
this.code = httpError.code;
ReplayableError.call(this, {
functionCode: Type.TRANSMIT_MESSAGE,
args: [number, jsonData, timestamp],
name: 'SendMessageNetworkError',
message: httpError.message,
});
@ -113,10 +88,8 @@
}
inherit(ReplayableError, SendMessageNetworkError);
function SignedPreKeyRotationError(numbers, message, timestamp) {
function SignedPreKeyRotationError() {
ReplayableError.call(this, {
functionCode: Type.RETRY_SEND_MESSAGE_PROTO,
args: [numbers, message, timestamp],
name: 'SignedPreKeyRotationError',
message: 'Too many signed prekey rotation failures',
});
@ -127,8 +100,6 @@
this.code = httpError.code;
ReplayableError.call(this, {
functionCode: Type.REBUILD_MESSAGE,
args: [message],
name: 'MessageError',
message: httpError.message,
});