Merge remote-tracking branch 'upstream/clearnet' into clean-en-translation

pull/1300/head
Audric Ackermann 5 years ago
commit 80946c0ea5
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1116,22 +1116,6 @@
"message": "Typing Indicators", "message": "Typing Indicators",
"description": "Title of the typing indicators setting" "description": "Title of the typing indicators setting"
}, },
"multiDeviceDisabledTemporary": {
"message": "MultiDevice disabled temporarily",
"description": "Description of why multi device is disabled"
},
"multiDeviceDisabledTemporaryTitle": {
"message": "Changes to Multi-device",
"description": "Description of why multi device is disabled on app start"
},
"multiDeviceDisabledTemporaryDescriptionPrimary": {
"message": "Youre seeing this because you have a secondary device linked to your Session ID. To improve reliability and stability, weve decided to temporarily disable Sessions multi-device functionality. Device linking has been disabled, and existing secondary clients will be erased on <span style=\"color:#00f782\">August 6th</span>.</br></br>To read more about this change, visit the Session FAQ at <a href=\"https://getsession.org/faq\">getsession.org/faq</a>.",
"description": "Description of why multi device is disabled on app start for a primary device"
},
"multiDeviceDisabledTemporaryDescriptionSecondary": {
"message": "Youre seeing this because this is a secondary device in a multi-device setup. To improve reliability and stability, weve decided to temporarily disable Sessions multi-device functionality. Device linking has been disabled, and existing secondary clients will be erased on <span style=\"color:#00f782\">August 6th</span>.</br></br>To read more about this change, visit the Session FAQ at <a href=\"https://getsession.org/faq\">getsession.org/faq</a>.",
"description": "Description of why multi device is disabled on app start for a secondary device"
},
"messageTTL": { "messageTTL": {
"message": "Message TTL", "message": "Message TTL",
"description": "Title of the Message TTL setting" "description": "Title of the Message TTL setting"

@ -810,6 +810,7 @@ const LOKI_SCHEMA_VERSIONS = [
updateToLokiSchemaVersion4, updateToLokiSchemaVersion4,
updateToLokiSchemaVersion5, updateToLokiSchemaVersion5,
updateToLokiSchemaVersion6, updateToLokiSchemaVersion6,
updateToLokiSchemaVersion7,
]; ];
async function updateToLokiSchemaVersion1(currentVersion, instance) { async function updateToLokiSchemaVersion1(currentVersion, instance) {
@ -1027,6 +1028,30 @@ async function updateToLokiSchemaVersion6(currentVersion, instance) {
console.log('updateToLokiSchemaVersion6: success!'); console.log('updateToLokiSchemaVersion6: success!');
} }
async function updateToLokiSchemaVersion7(currentVersion, instance) {
if (currentVersion >= 7) {
return;
}
console.log('updateToLokiSchemaVersion7: starting...');
await instance.run('BEGIN TRANSACTION;');
// Remove multi device data
await instance.run('DELETE FROM pairingAuthorisations;');
await instance.run(
`INSERT INTO loki_schema (
version
) values (
7
);`
);
await instance.run('COMMIT TRANSACTION;');
console.log('updateToLokiSchemaVersion7: success!');
}
async function updateLokiSchema(instance) { async function updateLokiSchema(instance) {
const result = await instance.get( const result = await instance.get(
"SELECT name FROM sqlite_master WHERE type = 'table' AND name='loki_schema';" "SELECT name FROM sqlite_master WHERE type = 'table' AND name='loki_schema';"

@ -300,6 +300,12 @@
storage.put('primaryDevicePubKey', textsecure.storage.user.getNumber()); storage.put('primaryDevicePubKey', textsecure.storage.user.getNumber());
} }
// 4th August 2020 - Force wipe of secondary devices as multi device is being disabled.
if (storage.get('isSecondaryDevice')) {
await window.deleteAccount();
return;
}
// These make key operations available to IPC handlers created in preload.js // These make key operations available to IPC handlers created in preload.js
window.Events = { window.Events = {
getThemeSetting: () => 'dark', // storage.get('theme-setting', 'dark') getThemeSetting: () => 'dark', // storage.get('theme-setting', 'dark')
@ -803,27 +809,6 @@
// Get memberlist. This function is not accurate >> // Get memberlist. This function is not accurate >>
// window.getMemberList = window.lokiPublicChatAPI.getListOfMembers(); // window.getMemberList = window.lokiPublicChatAPI.getListOfMembers();
window.deleteAccount = async () => {
try {
window.log.info('Deleting everything!');
const { Logs } = window.Signal;
await Logs.deleteAll();
await window.Signal.Data.removeAll();
await window.Signal.Data.close();
await window.Signal.Data.removeDB();
await window.Signal.Data.removeOtherData();
} catch (error) {
window.log.error(
'Something went wrong deleting all data:',
error && error.stack ? error.stack : error
);
}
window.restart();
};
window.toggleTheme = () => { window.toggleTheme = () => {
const theme = window.Events.getThemeSetting(); const theme = window.Events.getThemeSetting();
const updatedTheme = theme === 'dark' ? 'light' : 'dark'; const updatedTheme = theme === 'dark' ? 'light' : 'dark';

@ -1710,8 +1710,9 @@ class LokiPublicChannelAPI {
sigString += [...attachmentAnnotations, ...previewAnnotations] sigString += [...attachmentAnnotations, ...previewAnnotations]
.map(data => data.id || data.image.id) .map(data => data.id || data.image.id)
.sort() .sort()
.join(); .join('');
sigString += sigVer; sigString += sigVer;
return dcodeIO.ByteBuffer.wrap(sigString, 'utf8').toArrayBuffer(); return dcodeIO.ByteBuffer.wrap(sigString, 'utf8').toArrayBuffer();
} }

@ -218,6 +218,10 @@ class LokiHomeServerInstance extends LokiFileServerInstance {
} }
async updateOurDeviceMapping() { async updateOurDeviceMapping() {
if (!window.lokiFeatureFlags.useMultiDevice) {
return undefined;
}
const isPrimary = !storage.get('isSecondaryDevice'); const isPrimary = !storage.get('isSecondaryDevice');
const authorisations = await window.libsession.Protocols.MultiDeviceProtocol.getPairingAuthorisations( const authorisations = await window.libsession.Protocols.MultiDeviceProtocol.getPairingAuthorisations(
this.ourKey this.ourKey

@ -456,6 +456,7 @@ window.lokiFeatureFlags = {
enableSenderKeys: false, enableSenderKeys: false,
onionRequestHops: 3, onionRequestHops: 3,
debugMessageLogs: process.env.ENABLE_MESSAGE_LOGS, debugMessageLogs: process.env.ENABLE_MESSAGE_LOGS,
useMultiDevice: false,
}; };
// eslint-disable-next-line no-extend-native,func-names // eslint-disable-next-line no-extend-native,func-names
@ -492,6 +493,7 @@ if (config.environment.includes('test-integration')) {
useFileOnionRequests: false, useFileOnionRequests: false,
debugMessageLogs: true, debugMessageLogs: true,
enableSenderKeys: true, enableSenderKeys: true,
useMultiDevice: false,
}; };
} }
@ -502,3 +504,24 @@ const {
} = require('./ts/util/blockedNumberController'); } = require('./ts/util/blockedNumberController');
window.BlockedNumberController = BlockedNumberController; window.BlockedNumberController = BlockedNumberController;
window.deleteAccount = async () => {
try {
window.log.info('Deleting everything!');
const { Logs } = window.Signal;
await Logs.deleteAll();
await window.Signal.Data.removeAll();
await window.Signal.Data.close();
await window.Signal.Data.removeDB();
await window.Signal.Data.removeOtherData();
} catch (error) {
window.log.error(
'Something went wrong deleting all data:',
error && error.stack ? error.stack : error
);
}
window.restart();
};

@ -59,48 +59,6 @@ export class ActionsPanel extends React.Component<Props, State> {
}, },
'refreshAvatarCallback' 'refreshAvatarCallback'
); );
setTimeout(async () => {
const disabledMultiDeviceCountDb = await getItemById(
'disabledMultiDeviceCount'
);
const disabledMultiDeviceCount =
Number(disabledMultiDeviceCountDb?.value) || 0;
const data = {
id: 'disabledMultiDeviceCount',
value: String(disabledMultiDeviceCount + 1),
};
await createOrUpdateItem(data);
if (disabledMultiDeviceCount % 5 !== 0) {
return;
}
const currentDevice = await UserUtil.getCurrentDevicePubKey();
if (!currentDevice) {
return;
}
const secondaryDevices = await MultiDeviceProtocol.getSecondaryDevices(
currentDevice
);
const isSecondary =
secondaryDevices.find(s => s.key === currentDevice) ||
!!window.textsecure.storage.get('isSecondaryDevice');
const hasMultipleDevices =
(await MultiDeviceProtocol.getOurDevices()).length > 1;
const primaryWithSecondary = !isSecondary && hasMultipleDevices;
if (!primaryWithSecondary && !isSecondary) {
return;
}
const opts = {
hideCancel: true,
title: window.i18n('multiDeviceDisabledTemporaryTitle'),
message: primaryWithSecondary
? window.i18n('multiDeviceDisabledTemporaryDescriptionPrimary')
: window.i18n('multiDeviceDisabledTemporaryDescriptionSecondary'),
};
window.Whisper.events.trigger('showConfirmationDialog', opts);
}, 1000);
} }
); );
} }

@ -225,7 +225,7 @@ export class LeftPaneSettingSection extends React.Component<Props, State> {
{ {
id: SessionSettingCategory.Devices, id: SessionSettingCategory.Devices,
title: window.i18n('devicesSettingsTitle'), title: window.i18n('devicesSettingsTitle'),
hidden: isSecondaryDevice, hidden: !window.lokiFeatureFlags.useMultiDevice || isSecondaryDevice,
}, },
]; ];
} }

@ -557,9 +557,12 @@ export class RegistrationTabs extends React.Component<{}, State> {
SessionButtonType.BrandOutline, SessionButtonType.BrandOutline,
SessionButtonColor.Green SessionButtonColor.Green
)} )}
{/*<h4>{or}</h4>*/} {window.lokiFeatureFlags.useMultiDevice && (
{/* FIXME enable back to allow linking of device <>
this.renderLinkDeviceToExistingAccountButton() */} <h4>{or}</h4>
{this.renderLinkDeviceToExistingAccountButton()}
</>
)}
</div> </div>
); );
} }
@ -584,9 +587,12 @@ export class RegistrationTabs extends React.Component<{}, State> {
return ( return (
<div> <div>
{this.renderContinueYourSessionButton()} {this.renderContinueYourSessionButton()}
{/*<h4>{or}</h4>*/} {window.lokiFeatureFlags.useMultiDevice && (
{/* FIXME enable back to allow linking of device <>
this.renderLinkDeviceToExistingAccountButton()*/} <h4>{or}</h4>
{this.renderLinkDeviceToExistingAccountButton()}
</>
)}
</div> </div>
); );
} }

@ -644,7 +644,7 @@ export class SettingsView extends React.Component<SettingsViewProps, State> {
id: 'no-linked-device', id: 'no-linked-device',
title: noPairedDeviceText, title: noPairedDeviceText,
type: undefined, type: undefined,
description: window.i18n('multiDeviceDisabledTemporary'), description: '',
category: SessionSettingCategory.Devices, category: SessionSettingCategory.Devices,
content: {}, content: {},
comparisonValue: undefined, comparisonValue: undefined,

@ -74,12 +74,9 @@ export class SettingsHeader extends React.Component<Props, any> {
? `${categoryTitlePrefix.slice(0, -1)} Settings` ? `${categoryTitlePrefix.slice(0, -1)} Settings`
: `${categoryTitlePrefix} Settings`; : `${categoryTitlePrefix} Settings`;
const showSearch = false; const showSearch = false;
const showAddDevice = false; const showAddDevice =
/* FIXME enable back to allow linking of device
const showAddDevice =
category === SessionSettingCategory.Devices && category === SessionSettingCategory.Devices &&
this.props.showLinkDeviceButton; this.props.showLinkDeviceButton;
*/
return ( return (
<div className="session-settings-header"> <div className="session-settings-header">

@ -87,6 +87,14 @@ export async function handlePairingAuthorisationMessage(
pairingAuthorisation: SignalService.IPairingAuthorisationMessage, pairingAuthorisation: SignalService.IPairingAuthorisationMessage,
dataMessage: SignalService.IDataMessage | undefined | null dataMessage: SignalService.IDataMessage | undefined | null
): Promise<void> { ): Promise<void> {
if (!window.lokiFeatureFlags.useMultiDevice) {
window.log.info(
`Received a pairing authorisation message from ${envelope.source} while multi device is disabled.`
);
await removeFromCache(envelope);
return;
}
const { secondaryDevicePubKey, grantSignature } = pairingAuthorisation; const { secondaryDevicePubKey, grantSignature } = pairingAuthorisation;
const isGrant = const isGrant =
grantSignature && grantSignature &&

@ -28,6 +28,11 @@ export class MultiDeviceProtocol {
public static async fetchPairingAuthorisationsIfNeeded( public static async fetchPairingAuthorisationsIfNeeded(
device: PubKey device: PubKey
): Promise<void> { ): Promise<void> {
// Disable fetching if we don't want to use multi device
if (!window.lokiFeatureFlags.useMultiDevice) {
return;
}
// This return here stops an infinite loop when we get all our other devices // This return here stops an infinite loop when we get all our other devices
const ourKey = await UserUtil.getCurrentDevicePubKey(); const ourKey = await UserUtil.getCurrentDevicePubKey();
if (!ourKey || device.key === ourKey) { if (!ourKey || device.key === ourKey) {

@ -25,6 +25,13 @@ function generateFakeAuthorisations(
describe('MultiDeviceProtocol', () => { describe('MultiDeviceProtocol', () => {
const sandbox = sinon.createSandbox(); const sandbox = sinon.createSandbox();
beforeEach(() => {
// Enable multidevice for tests
TestUtils.stubWindow('lokiFeatureFlags', {
useMultiDevice: true,
});
});
afterEach(() => { afterEach(() => {
TestUtils.restoreStubs(); TestUtils.restoreStubs();
sandbox.restore(); sandbox.restore();

12
ts/window.d.ts vendored

@ -51,7 +51,17 @@ declare global {
libloki: Libloki; libloki: Libloki;
libsignal: LibsignalProtocol; libsignal: LibsignalProtocol;
log: any; log: any;
lokiFeatureFlags: any; lokiFeatureFlags: {
multiDeviceUnpairing: boolean;
privateGroupChats: boolean;
useSnodeProxy: boolean;
useOnionRequests: boolean;
useFileOnionRequests: boolean;
enableSenderKeys: boolean;
onionRequestHops: number;
debugMessageLogs: boolean;
useMultiDevice: boolean;
};
lokiFileServerAPI: LokiFileServerInstance; lokiFileServerAPI: LokiFileServerInstance;
lokiMessageAPI: LokiMessageInterface; lokiMessageAPI: LokiMessageInterface;
lokiPublicChatAPI: LokiPublicChatFactoryInterface; lokiPublicChatAPI: LokiPublicChatFactoryInterface;

Loading…
Cancel
Save