Prompt for recovery key on login rather than passphrase
Only show passphrase options at all if the user has a passphrase on their SSSS key.
This commit is contained in:
parent
631184c661
commit
e06ba2003b
9 changed files with 224 additions and 20 deletions
|
@ -20,10 +20,11 @@ import { accessSecretStorage, AccessCancelledError } from '../CrossSigningManage
|
|||
import { PHASE_DONE as VERIF_PHASE_DONE } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||
|
||||
export const PHASE_INTRO = 0;
|
||||
export const PHASE_BUSY = 1;
|
||||
export const PHASE_DONE = 2; //final done stage, but still showing UX
|
||||
export const PHASE_CONFIRM_SKIP = 3;
|
||||
export const PHASE_FINISHED = 4; //UX can be closed
|
||||
export const PHASE_RECOVERY_KEY = 1;
|
||||
export const PHASE_BUSY = 2;
|
||||
export const PHASE_DONE = 3; //final done stage, but still showing UX
|
||||
export const PHASE_CONFIRM_SKIP = 4;
|
||||
export const PHASE_FINISHED = 5; //UX can be closed
|
||||
|
||||
export class SetupEncryptionStore extends EventEmitter {
|
||||
static sharedInstance() {
|
||||
|
@ -36,11 +37,19 @@ export class SetupEncryptionStore extends EventEmitter {
|
|||
return;
|
||||
}
|
||||
this._started = true;
|
||||
this.phase = PHASE_INTRO;
|
||||
this.phase = PHASE_BUSY;
|
||||
this.verificationRequest = null;
|
||||
this.backupInfo = null;
|
||||
|
||||
// ID of the key that the secrets we want are encrypted with
|
||||
this.keyId = null;
|
||||
// Descriptor of the key that the secrets we want are encrypted with
|
||||
this.keyInfo = null;
|
||||
|
||||
MatrixClientPeg.get().on("crypto.verification.request", this.onVerificationRequest);
|
||||
MatrixClientPeg.get().on('userTrustStatusChanged', this._onUserTrustStatusChanged);
|
||||
|
||||
this.fetchKeyInfo();
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
@ -57,7 +66,40 @@ export class SetupEncryptionStore extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
async fetchKeyInfo() {
|
||||
const keys = await MatrixClientPeg.get().isSecretStored('m.cross_signing.master', false);
|
||||
if (Object.keys(keys).length === 0) {
|
||||
this.keyId = null;
|
||||
this.keyInfo = null;
|
||||
} else {
|
||||
// If the secret is stored under more than one key, we just pick an arbitrary one
|
||||
this.keyId = Object.keys(keys)[0];
|
||||
this.keyInfo = keys[this.keyId];
|
||||
}
|
||||
|
||||
this.phase = PHASE_INTRO;
|
||||
this.emit("update");
|
||||
}
|
||||
|
||||
async useRecoveryKey() {
|
||||
this.phase = PHASE_RECOVERY_KEY;
|
||||
this.emit("update");
|
||||
}
|
||||
|
||||
cancelUseRecoveryKey() {
|
||||
this.phase = PHASE_INTRO;
|
||||
this.emit("update");
|
||||
}
|
||||
|
||||
async setupWithRecoveryKey(recoveryKey) {
|
||||
this.startTrustCheck({[this.keyId]: recoveryKey});
|
||||
}
|
||||
|
||||
async usePassPhrase() {
|
||||
this.startTrustCheck();
|
||||
}
|
||||
|
||||
async startTrustCheck(withKeys) {
|
||||
this.phase = PHASE_BUSY;
|
||||
this.emit("update");
|
||||
const cli = MatrixClientPeg.get();
|
||||
|
@ -84,6 +126,9 @@ export class SetupEncryptionStore extends EventEmitter {
|
|||
// to advance before this.
|
||||
await cli.restoreKeyBackupWithSecretStorage(backupInfo);
|
||||
}
|
||||
}, {
|
||||
withKeys,
|
||||
passphraseOnly: true,
|
||||
}).catch(reject);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue