From 34667ae7e4d3e716c84f69183557edb2671005b6 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Sat, 30 Apr 2022 09:20:50 +0530 Subject: [PATCH] Add option to verify with security key/phrase --- src/app/organisms/settings/DeviceManage.jsx | 38 +++++++++++++++++--- src/app/organisms/settings/DeviceManage.scss | 17 +++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/app/organisms/settings/DeviceManage.jsx b/src/app/organisms/settings/DeviceManage.jsx index b6ce307b..c47baa6b 100644 --- a/src/app/organisms/settings/DeviceManage.jsx +++ b/src/app/organisms/settings/DeviceManage.jsx @@ -25,6 +25,7 @@ import { confirmDialog } from '../../molecules/confirm-dialog/ConfirmDialog'; import { useStore } from '../../hooks/useStore'; import { useDeviceList } from '../../hooks/useDeviceList'; import { useCrossSigningStatus } from '../../hooks/useCrossSigningStatus'; +import { accessSecretStorage } from './SecretStorageAccess'; const promptDeviceName = async (deviceName) => new Promise((resolve) => { let isCompleted = false; @@ -127,18 +128,44 @@ function DeviceManage() { 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 deviceId = device.device_id; const displayName = device.display_name; const lastIP = device.last_seen_ip; const lastTS = device.last_seen_ts; + const isCurrentDevice = mx.deviceId === deviceId; + return ( - {displayName} - {` — ${deviceId}${mx.deviceId === deviceId ? ' (current)' : ''}`} + + {displayName ? `${displayName} — ` : ''} + {deviceId} + {isCurrentDevice && Current} )} options={ @@ -146,6 +173,7 @@ function DeviceManage() { ? : ( <> + {isVerified === false && } handleRename(device)} src={PencilIC} tooltip="Rename" /> handleRemove(device)} src={BinIC} tooltip="Remove session" /> @@ -200,7 +228,7 @@ function DeviceManage() { {noEncryption.length > 0 && (
Sessions without encryption support - {noEncryption.map((device) => renderDevice(device, true))} + {noEncryption.map((device) => renderDevice(device, null))}
)}
@@ -211,7 +239,7 @@ function DeviceManage() { if (truncated && index >= TRUNCATED_COUNT) return null; return renderDevice(device, true); }) - : No verified session + : No verified sessions } { verified.length > TRUNCATED_COUNT && (