From c27f2d6268a5d2ca4d24fa52e13f59ab1e4edec5 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Wed, 30 Mar 2022 17:14:04 +0530 Subject: [PATCH] Add isCrossVerified func to matrixUtil Signed-off-by: Ajay Bura --- src/app/organisms/settings/DeviceManage.jsx | 13 +------------ src/util/matrixUtil.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/app/organisms/settings/DeviceManage.jsx b/src/app/organisms/settings/DeviceManage.jsx index 8f5110dc..f30397d3 100644 --- a/src/app/organisms/settings/DeviceManage.jsx +++ b/src/app/organisms/settings/DeviceManage.jsx @@ -3,6 +3,7 @@ import './DeviceManage.scss'; import dateFormat from 'dateformat'; import initMatrix from '../../../client/initMatrix'; +import { isCrossVerified } from '../../../util/matrixUtil'; import Text from '../../atoms/text/Text'; import Button from '../../atoms/button/Button'; @@ -17,18 +18,6 @@ import BinIC from '../../../../public/res/ic/outlined/bin.svg'; import { useStore } from '../../hooks/useStore'; import { useDeviceList } from '../../hooks/useDeviceList'; -function isCrossVerified(deviceId) { - try { - const mx = initMatrix.matrixClient; - const crossSignInfo = mx.getStoredCrossSigningForUser(mx.getUserId()); - const deviceInfo = mx.getStoredDevice(mx.getUserId(), deviceId); - const deviceTrust = crossSignInfo.checkDeviceTrust(crossSignInfo, deviceInfo, false, true); - return deviceTrust.isCrossSigningVerified(); - } catch { - return false; - } -} - function DeviceManage() { const TRUNCATED_COUNT = 4; const mx = initMatrix.matrixClient; diff --git a/src/util/matrixUtil.js b/src/util/matrixUtil.js index 1af6cb19..833166b7 100644 --- a/src/util/matrixUtil.js +++ b/src/util/matrixUtil.js @@ -162,3 +162,15 @@ export function genRoomVia(room) { } return via.concat(mostPop3.slice(0, 2)); } + +export function isCrossVerified(deviceId) { + try { + const mx = initMatrix.matrixClient; + const crossSignInfo = mx.getStoredCrossSigningForUser(mx.getUserId()); + const deviceInfo = mx.getStoredDevice(mx.getUserId(), deviceId); + const deviceTrust = crossSignInfo.checkDeviceTrust(crossSignInfo, deviceInfo, false, true); + return deviceTrust.isCrossSigningVerified(); + } catch { + return false; + } +}