Assert that the crypto module is defined
parent
b20579d796
commit
24c537cdb7
|
@ -65,13 +65,7 @@ export function ChangeRecoveryKey({
|
||||||
const [state, setState] = useState<State>(isSetupFlow ? "inform_user" : "save_key_change_flow");
|
const [state, setState] = useState<State>(isSetupFlow ? "inform_user" : "save_key_change_flow");
|
||||||
|
|
||||||
// We create a new recovery key, the recovery key will be displayed to the user
|
// We create a new recovery key, the recovery key will be displayed to the user
|
||||||
const recoveryKey = useAsyncMemo(() => {
|
const recoveryKey = useAsyncMemo(() => matrixClient.getCrypto()!.createRecoveryKeyFromPassphrase(), []);
|
||||||
const crypto = matrixClient.getCrypto();
|
|
||||||
if (!crypto) return Promise.resolve(undefined);
|
|
||||||
|
|
||||||
return crypto.createRecoveryKeyFromPassphrase();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (!recoveryKey?.encodedPrivateKey) return null;
|
if (!recoveryKey?.encodedPrivateKey) return null;
|
||||||
|
|
||||||
let content: JSX.Element;
|
let content: JSX.Element;
|
||||||
|
|
|
@ -46,8 +46,7 @@ export function RecoveryPanel({ onSetUpRecoveryClick, onChangingRecoveryKeyClick
|
||||||
const matrixClient = useMatrixClientContext();
|
const matrixClient = useMatrixClientContext();
|
||||||
|
|
||||||
const checkEncryption = useCallback(async () => {
|
const checkEncryption = useCallback(async () => {
|
||||||
const crypto = matrixClient.getCrypto();
|
const crypto = matrixClient.getCrypto()!;
|
||||||
if (!crypto) return;
|
|
||||||
|
|
||||||
// Check if the user has a backup
|
// Check if the user has a backup
|
||||||
const hasBackup = Boolean(await crypto.checkKeyBackupAndEnable());
|
const hasBackup = Boolean(await crypto.checkKeyBackupAndEnable());
|
||||||
|
|
|
@ -78,9 +78,7 @@ function useVerificationRequired(setState: (state: State) => void): () => Promis
|
||||||
const matrixClient = useMatrixClientContext();
|
const matrixClient = useMatrixClientContext();
|
||||||
|
|
||||||
const checkVerificationRequired = useCallback(async () => {
|
const checkVerificationRequired = useCallback(async () => {
|
||||||
const crypto = matrixClient.getCrypto();
|
const crypto = matrixClient.getCrypto()!;
|
||||||
if (!crypto) return;
|
|
||||||
|
|
||||||
const isCrossSigningReady = await crypto.isCrossSigningReady();
|
const isCrossSigningReady = await crypto.isCrossSigningReady();
|
||||||
if (isCrossSigningReady) setState("main");
|
if (isCrossSigningReady) setState("main");
|
||||||
else setState("verification_required");
|
else setState("verification_required");
|
||||||
|
|
Loading…
Reference in New Issue