- We will generate a Security Key,
+ We will generate a Security Key ,
which you can use to manage messages backup and session verification.
{genWithPhrase !== false && setup()} disabled={genWithPhrase !== undefined}>Generate Key }
@@ -133,7 +142,7 @@ function CrossSigningSetup() {
disabled={genWithPhrase !== undefined}
>
- Alternatively you can also set a Security Phrase
+ Alternatively you can also set a Security Phrase
so you don't have to remember long Security Key,
and optionally save the Key as backup.
@@ -181,7 +190,8 @@ function CrossSigningReset() {
Anyone you have verified with will see security alerts and your message backup will lost.
You almost certainly do not want to do this,
- unless you have lost Security Key or Phrase and every session you can cross-sign from.
+ unless you have lost Security Key or Phrase and
+ every session you can cross-sign from.
Reset
@@ -196,12 +206,13 @@ const resetDialog = () => {
};
function CrossSignin() {
+ const isCSEnabled = useCrossSigningStatus();
return (
Setup to verify and keep track of all your sessions. Also required to backup encrypted message.}
options={(
- hasCrossSigningAccountData()
+ isCSEnabled
? Reset
: Setup
)}
diff --git a/src/app/organisms/settings/CrossSigning.scss b/src/app/organisms/settings/CrossSigning.scss
index 494fa977..b4b606d0 100644
--- a/src/app/organisms/settings/CrossSigning.scss
+++ b/src/app/organisms/settings/CrossSigning.scss
@@ -45,10 +45,11 @@
}
}
+.cross-signing__failure,
.cross-signing__reset {
padding: var(--sp-normal);
padding-top: var(--sp-extra-loose);
& > .text {
- padding-bottom: var(--sp-loose);
+ padding-bottom: var(--sp-normal);
}
}
\ No newline at end of file
diff --git a/src/app/organisms/settings/DeviceManage.jsx b/src/app/organisms/settings/DeviceManage.jsx
index ea768fdf..5c60bf0a 100644
--- a/src/app/organisms/settings/DeviceManage.jsx
+++ b/src/app/organisms/settings/DeviceManage.jsx
@@ -17,6 +17,8 @@ import PencilIC from '../../../../public/res/ic/outlined/pencil.svg';
import BinIC from '../../../../public/res/ic/outlined/bin.svg';
import InfoIC from '../../../../public/res/ic/outlined/info.svg';
+import { authRequest } from './AuthRequest';
+
import { useStore } from '../../hooks/useStore';
import { useDeviceList } from '../../hooks/useDeviceList';
import { useCrossSigningStatus } from '../../hooks/useCrossSigningStatus';
@@ -71,38 +73,15 @@ function DeviceManage() {
}
};
- const handleRemove = async (device, auth = undefined) => {
- if (auth === undefined
- ? window.confirm(`You are about to logout "${device.display_name}" session.`)
- : true
- ) {
+ const handleRemove = async (device) => {
+ if (window.confirm(`You are about to logout "${device.display_name}" session.`)) {
addToProcessing(device);
- try {
+ await authRequest(`Logout "${device.display_name}"`, async (auth) => {
await mx.deleteDevice(device.device_id, auth);
- } catch (e) {
- if (e.httpStatus === 401 && e.data?.flows) {
- const { flows } = e.data;
- const flow = flows.find((f) => f.stages.includes('m.login.password'));
- if (flow) {
- const password = window.prompt('Please enter account password', '');
- if (password && password.trim() !== '') {
- handleRemove(device, {
- session: e.data.session,
- type: 'm.login.password',
- password,
- identifier: {
- type: 'm.id.user',
- user: mx.getUserId(),
- },
- });
- return;
- }
- }
- }
- window.alert('Failed to remove session!');
- if (!mountStore.getItem()) return;
- removeFromProcessing(device);
- }
+ });
+
+ if (!mountStore.getItem()) return;
+ removeFromProcessing(device);
}
};
diff --git a/src/app/organisms/settings/KeyBackup.jsx b/src/app/organisms/settings/KeyBackup.jsx
index 50080a6e..5d2f4ed7 100644
--- a/src/app/organisms/settings/KeyBackup.jsx
+++ b/src/app/organisms/settings/KeyBackup.jsx
@@ -82,7 +82,7 @@ CreateKeyBackupDialog.propTypes = {
keyData: PropTypes.shape({}).isRequired,
};
-function RestoreKeyBackupDialog({ keyData, backupInfo }) {
+function RestoreKeyBackupDialog({ keyData }) {
const [status, setStatus] = useState(false);
const mx = initMatrix.matrixClient;
const mountStore = useStore();
@@ -103,6 +103,7 @@ function RestoreKeyBackupDialog({ keyData, backupInfo }) {
};
try {
+ const backupInfo = await mx.getKeyBackupVersion();
const info = await mx.restoreKeyBackupWithSecretStorage(
backupInfo,
undefined,
@@ -115,7 +116,7 @@ function RestoreKeyBackupDialog({ keyData, backupInfo }) {
if (!mountStore.getItem()) return;
if (e.errcode === 'RESTORE_BACKUP_ERROR_BAD_KEY') {
deletePrivateKey(keyData.keyId);
- setStatus({ error: 'Failed to restore backup. Key is invalid', errorCode: 'BAD_KEY' });
+ setStatus({ error: 'Failed to restore backup. Key is invalid!', errorCode: 'BAD_KEY' });
} else {
setStatus({ error: 'Failed to restore backup.', errCode: 'UNKNOWN' });
}
@@ -152,10 +153,9 @@ function RestoreKeyBackupDialog({ keyData, backupInfo }) {
}
RestoreKeyBackupDialog.propTypes = {
keyData: PropTypes.shape({}).isRequired,
- backupInfo: PropTypes.shape({}).isRequired,
};
-function DeleteKeyBackupDialog({ version, requestClose }) {
+function DeleteKeyBackupDialog({ requestClose }) {
const [isDeleting, setIsDeleting] = useState(false);
const mx = initMatrix.matrixClient;
const mountStore = useStore();
@@ -164,7 +164,8 @@ function DeleteKeyBackupDialog({ version, requestClose }) {
const deleteBackup = async () => {
setIsDeleting(true);
try {
- await mx.deleteKeyBackupVersion(version);
+ const backupInfo = await mx.getKeyBackupVersion();
+ if (backupInfo) await mx.deleteKeyBackupVersion(backupInfo.version);
if (!mountStore.getItem()) return;
requestClose(true);
} catch {
@@ -187,7 +188,6 @@ function DeleteKeyBackupDialog({ version, requestClose }) {
);
}
DeleteKeyBackupDialog.propTypes = {
- version: PropTypes.string.isRequired,
requestClose: PropTypes.func.isRequired,
};
@@ -217,7 +217,7 @@ function KeyBackup() {
return () => {
mx.removeListener('accountData', handleAccountData);
};
- }, []);
+ }, [isCSEnabled]);
const openCreateKeyBackup = async () => {
const keyData = await accessSecretStorage('Create Key Backup');
@@ -236,7 +236,7 @@ function KeyBackup() {
openReusableDialog(
Restore Key Backup ,
- () => ,
+ () => ,
);
};
@@ -244,7 +244,6 @@ function KeyBackup() {
Delete Key Backup ,
(requestClose) => (
{
if (isDone) setKeyBackup(null);
requestClose();
diff --git a/src/app/organisms/settings/SecretStorageAccess.jsx b/src/app/organisms/settings/SecretStorageAccess.jsx
index a381cc74..f0131b14 100644
--- a/src/app/organisms/settings/SecretStorageAccess.jsx
+++ b/src/app/organisms/settings/SecretStorageAccess.jsx
@@ -116,7 +116,14 @@ export const accessSecretStorage = (title) => new Promise((resolve) => {
openReusableDialog(
{title} ,
- () => ,
+ (requestClose) => (
+ {
+ handleComplete(keyData);
+ requestClose(requestClose);
+ }}
+ />
+ ),
() => {
if (!isCompleted) resolve(null);
},