Add tool to migrate logins between origins
App checks at startup for an existing session, if there isn't one, it will start the tool to check for a login in the file:// origin. If there is one, it will copy the login over to the vector://vector origin. In principle this could also be used to migrate logins between other origins on the web if this were ever required. This includes a minified copy of the browserified js-sdk with a getAllEndToEndSessions() function added to the crypto store (https://github.com/matrix-org/matrix-js-sdk/pull/812). This is not great, but for a short-lived tool this seems better than introducing more entry points into webpack only used for the electron app.
This commit is contained in:
parent
b6d70f4434
commit
751a1dc543
11 changed files with 486 additions and 10 deletions
|
@ -224,7 +224,16 @@ async function loadApp() {
|
|||
// set the platform for react sdk
|
||||
if (window.ipcRenderer) {
|
||||
console.log("Using Electron platform");
|
||||
PlatformPeg.set(new ElectronPlatform());
|
||||
const plaf = new ElectronPlatform();
|
||||
PlatformPeg.set(plaf);
|
||||
|
||||
// Electron only: see if we need to do a one-time data
|
||||
// migration
|
||||
if (window.localStorage.getItem('mx_user_id') === null) {
|
||||
console.log("Migrating session from old origin...");
|
||||
await plaf.migrateFromOldOrigin();
|
||||
console.log("Origin migration complete");
|
||||
}
|
||||
} else {
|
||||
console.log("Using Web platform");
|
||||
PlatformPeg.set(new WebPlatform());
|
||||
|
|
|
@ -224,6 +224,10 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
window.location.reload(false);
|
||||
}
|
||||
|
||||
async migrateFromOldOrigin() {
|
||||
return this._ipcCall('origin_migrate');
|
||||
}
|
||||
|
||||
async _ipcCall(name, ...args) {
|
||||
const ipcCallId = ++this._nextIpcCallId;
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
@ -149,4 +149,12 @@ export default class VectorBasePlatform extends BasePlatform {
|
|||
getDefaultDeviceDisplayName(): string {
|
||||
return _t("Unknown device");
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate account data from a previous origin
|
||||
* Used only for the electron app
|
||||
*/
|
||||
async migrateFromOldOrigin() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue