mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Remove multi device data.
Force wipe secondary devices.
This commit is contained in:
parent
c0fca99485
commit
49b994367d
6 changed files with 72 additions and 30 deletions
25
app/sql.js
25
app/sql.js
|
@ -810,6 +810,7 @@ const LOKI_SCHEMA_VERSIONS = [
|
|||
updateToLokiSchemaVersion4,
|
||||
updateToLokiSchemaVersion5,
|
||||
updateToLokiSchemaVersion6,
|
||||
updateToLokiSchemaVersion7,
|
||||
];
|
||||
|
||||
async function updateToLokiSchemaVersion1(currentVersion, instance) {
|
||||
|
@ -1027,6 +1028,30 @@ async function updateToLokiSchemaVersion6(currentVersion, instance) {
|
|||
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) {
|
||||
const result = await instance.get(
|
||||
"SELECT name FROM sqlite_master WHERE type = 'table' AND name='loki_schema';"
|
||||
|
|
|
@ -300,6 +300,12 @@
|
|||
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
|
||||
window.Events = {
|
||||
getThemeSetting: () => 'dark', // storage.get('theme-setting', 'dark')
|
||||
|
@ -803,27 +809,6 @@
|
|||
// Get memberlist. This function is not accurate >>
|
||||
// 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 = () => {
|
||||
const theme = window.Events.getThemeSetting();
|
||||
const updatedTheme = theme === 'dark' ? 'light' : 'dark';
|
||||
|
|
|
@ -218,6 +218,10 @@ class LokiHomeServerInstance extends LokiFileServerInstance {
|
|||
}
|
||||
|
||||
async updateOurDeviceMapping() {
|
||||
if (!window.lokiFeatureFlags.useMultiDevice) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const isPrimary = !storage.get('isSecondaryDevice');
|
||||
const authorisations = await window.libsession.Protocols.MultiDeviceProtocol.getPairingAuthorisations(
|
||||
this.ourKey
|
||||
|
|
21
preload.js
21
preload.js
|
@ -504,3 +504,24 @@ const {
|
|||
} = require('./ts/util/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();
|
||||
};
|
||||
|
|
|
@ -25,6 +25,13 @@ function generateFakeAuthorisations(
|
|||
describe('MultiDeviceProtocol', () => {
|
||||
const sandbox = sinon.createSandbox();
|
||||
|
||||
beforeEach(() => {
|
||||
// Enable multidevice for tests
|
||||
TestUtils.stubWindow('lokiFeatureFlags', {
|
||||
useMultiDevice: true,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
TestUtils.restoreStubs();
|
||||
sandbox.restore();
|
||||
|
|
18
ts/window.d.ts
vendored
18
ts/window.d.ts
vendored
|
@ -52,15 +52,15 @@ declare global {
|
|||
libsignal: LibsignalProtocol;
|
||||
log: any;
|
||||
lokiFeatureFlags: {
|
||||
multiDeviceUnpairing: boolean,
|
||||
privateGroupChats: boolean,
|
||||
useSnodeProxy: boolean,
|
||||
useOnionRequests: boolean,
|
||||
useFileOnionRequests: boolean,
|
||||
enableSenderKeys: boolean,
|
||||
onionRequestHops: number,
|
||||
debugMessageLogs: boolean,
|
||||
useMultiDevice: boolean,
|
||||
multiDeviceUnpairing: boolean;
|
||||
privateGroupChats: boolean;
|
||||
useSnodeProxy: boolean;
|
||||
useOnionRequests: boolean;
|
||||
useFileOnionRequests: boolean;
|
||||
enableSenderKeys: boolean;
|
||||
onionRequestHops: number;
|
||||
debugMessageLogs: boolean;
|
||||
useMultiDevice: boolean;
|
||||
};
|
||||
lokiFileServerAPI: LokiFileServerInstance;
|
||||
lokiMessageAPI: LokiMessageInterface;
|
||||
|
|
Loading…
Reference in a new issue