Allow key backup restore to get the key backup passphrase

And pass this in as the new callback to bootstrap to get the old
key backup passphrase.
This commit is contained in:
David Baker 2020-03-19 20:42:16 +00:00
parent 9bfc19f367
commit c8691c73ff
3 changed files with 33 additions and 0 deletions

View file

@ -162,6 +162,20 @@ export const crossSigningCallbacks = {
onSecretRequested,
};
export async function promptForBackupPassphrase() {
let key;
const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog');
const { finished } = Modal.createTrackedDialog('Restore Backup', '', RestoreKeyBackupDialog, {
showSummary: false, keyCallback: k => key = k,
}, null, /* priority = */ false, /* static = */ false);
const success = await finished;
if (!success) throw new Error("Key backup prompt cancelled");
return key;
}
/**
* This helper should be used whenever you need to access secret storage. It
* ensures that secret storage (and also cross-signing since they each depend on
@ -218,6 +232,7 @@ export async function accessSecretStorage(func = async () => { }, force = false)
throw new Error("Cross-signing key upload auth canceled");
}
},
getBackupPassphrase: promptForBackupPassphrase,
});
}