Add option to verify with security key/phrase
This commit is contained in:
parent
416fd02069
commit
34667ae7e4
2 changed files with 50 additions and 5 deletions
|
@ -25,6 +25,7 @@ import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog';
|
||||||
import { useStore } from '../../hooks/useStore';
|
import { useStore } from '../../hooks/useStore';
|
||||||
import { useDeviceList } from '../../hooks/useDeviceList';
|
import { useDeviceList } from '../../hooks/useDeviceList';
|
||||||
import { useCrossSigningStatus } from '../../hooks/useCrossSigningStatus';
|
import { useCrossSigningStatus } from '../../hooks/useCrossSigningStatus';
|
||||||
|
import { accessSecretStorage } from './SecretStorageAccess';
|
||||||
|
|
||||||
const promptDeviceName = async (deviceName) => new Promise((resolve) => {
|
const promptDeviceName = async (deviceName) => new Promise((resolve) => {
|
||||||
let isCompleted = false;
|
let isCompleted = false;
|
||||||
|
@ -127,18 +128,44 @@ function DeviceManage() {
|
||||||
removeFromProcessing(device);
|
removeFromProcessing(device);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const verifyWithKey = async (device) => {
|
||||||
|
const keyData = await accessSecretStorage('Device Verification');
|
||||||
|
if (!keyData) return;
|
||||||
|
addToProcessing(device);
|
||||||
|
await mx.checkOwnCrossSigningTrust();
|
||||||
|
};
|
||||||
|
|
||||||
|
const verifyWithEmojis = async () => {
|
||||||
|
// TODO:
|
||||||
|
};
|
||||||
|
|
||||||
|
const verifyManually = async () => {
|
||||||
|
// TODO:
|
||||||
|
};
|
||||||
|
|
||||||
|
const verify = (deviceId, isCurrentDevice) => {
|
||||||
|
if (isCurrentDevice) {
|
||||||
|
verifyWithKey(deviceId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
verifyManually(deviceId);
|
||||||
|
};
|
||||||
|
|
||||||
const renderDevice = (device, isVerified) => {
|
const renderDevice = (device, isVerified) => {
|
||||||
const deviceId = device.device_id;
|
const deviceId = device.device_id;
|
||||||
const displayName = device.display_name;
|
const displayName = device.display_name;
|
||||||
const lastIP = device.last_seen_ip;
|
const lastIP = device.last_seen_ip;
|
||||||
const lastTS = device.last_seen_ts;
|
const lastTS = device.last_seen_ts;
|
||||||
|
const isCurrentDevice = mx.deviceId === deviceId;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingTile
|
<SettingTile
|
||||||
key={deviceId}
|
key={deviceId}
|
||||||
title={(
|
title={(
|
||||||
<Text style={{ color: isVerified ? '' : 'var(--tc-danger-high)' }}>
|
<Text style={{ color: isVerified !== false ? '' : 'var(--tc-danger-high)' }}>
|
||||||
{displayName}
|
{displayName ? `${displayName} — ` : ''}
|
||||||
<Text variant="b3" span>{` — ${deviceId}${mx.deviceId === deviceId ? ' (current)' : ''}`}</Text>
|
<Text variant="b3" span>{deviceId}</Text>
|
||||||
|
{isCurrentDevice && <Text span className="device-manage__current-label" variant="b3">Current</Text>}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
options={
|
options={
|
||||||
|
@ -146,6 +173,7 @@ function DeviceManage() {
|
||||||
? <Spinner size="small" />
|
? <Spinner size="small" />
|
||||||
: (
|
: (
|
||||||
<>
|
<>
|
||||||
|
{isVerified === false && <Button onClick={() => verify(deviceId, isCurrentDevice)} variant="positive">Verify</Button>}
|
||||||
<IconButton size="small" onClick={() => handleRename(device)} src={PencilIC} tooltip="Rename" />
|
<IconButton size="small" onClick={() => handleRename(device)} src={PencilIC} tooltip="Rename" />
|
||||||
<IconButton size="small" onClick={() => handleRemove(device)} src={BinIC} tooltip="Remove session" />
|
<IconButton size="small" onClick={() => handleRemove(device)} src={BinIC} tooltip="Remove session" />
|
||||||
</>
|
</>
|
||||||
|
@ -200,7 +228,7 @@ function DeviceManage() {
|
||||||
{noEncryption.length > 0 && (
|
{noEncryption.length > 0 && (
|
||||||
<div>
|
<div>
|
||||||
<MenuHeader>Sessions without encryption support</MenuHeader>
|
<MenuHeader>Sessions without encryption support</MenuHeader>
|
||||||
{noEncryption.map((device) => renderDevice(device, true))}
|
{noEncryption.map((device) => renderDevice(device, null))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
|
@ -211,7 +239,7 @@ function DeviceManage() {
|
||||||
if (truncated && index >= TRUNCATED_COUNT) return null;
|
if (truncated && index >= TRUNCATED_COUNT) return null;
|
||||||
return renderDevice(device, true);
|
return renderDevice(device, true);
|
||||||
})
|
})
|
||||||
: <Text className="device-manage__info">No verified session</Text>
|
: <Text className="device-manage__info">No verified sessions</Text>
|
||||||
}
|
}
|
||||||
{ verified.length > TRUNCATED_COUNT && (
|
{ verified.length > TRUNCATED_COUNT && (
|
||||||
<Button className="device-manage__info" onClick={() => setTruncated(!truncated)}>
|
<Button className="device-manage__info" onClick={() => setTruncated(!truncated)}>
|
||||||
|
|
|
@ -15,6 +15,23 @@
|
||||||
& .setting-tile:last-of-type {
|
& .setting-tile:last-of-type {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
& .setting-tile__options {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--sp-ultra-tight);
|
||||||
|
& .btn-positive {
|
||||||
|
padding: 6px var(--sp-tight);
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__current-label {
|
||||||
|
margin: 0 var(--sp-extra-tight);
|
||||||
|
padding: 2px var(--sp-ultra-tight);
|
||||||
|
color: var(--bg-surface);
|
||||||
|
background-color: var(--tc-surface-low);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
&__rename {
|
&__rename {
|
||||||
padding: var(--sp-normal);
|
padding: var(--sp-normal);
|
||||||
|
|
Loading…
Reference in a new issue