rename desktop service to safe storage
This commit is contained in:
parent
dcc9d5a486
commit
fdcbe6d915
|
@ -25,7 +25,7 @@ import FormPaperFooter from 'components/Form/FormPaper/Footer';
|
|||
import LinkButton from 'components/pages/gallery/LinkButton';
|
||||
import { CustomError } from 'utils/error';
|
||||
import isElectron from 'is-electron';
|
||||
import desktopService from 'services/desktopService';
|
||||
import safeStorageService from 'services/safeStorageService';
|
||||
import VerticallyCentered from 'components/Container';
|
||||
import EnteSpinner from 'components/EnteSpinner';
|
||||
import { Input } from '@mui/material';
|
||||
|
@ -43,7 +43,7 @@ export default function Credentials() {
|
|||
const keyAttributes = getData(LS_KEYS.KEY_ATTRIBUTES);
|
||||
let key = getKey(SESSION_KEYS.ENCRYPTION_KEY);
|
||||
if (!key && isElectron()) {
|
||||
key = await desktopService.getEncryptionKey();
|
||||
key = await safeStorageService.getEncryptionKey();
|
||||
if (key) {
|
||||
await saveKeyInSessionStore(
|
||||
SESSION_KEYS.ENCRYPTION_KEY,
|
||||
|
|
|
@ -13,7 +13,7 @@ import { logError } from 'utils/sentry';
|
|||
import { getAlbumSiteHost, PAGES } from 'constants/pages';
|
||||
import { EnteLogo } from 'components/EnteLogo';
|
||||
import isElectron from 'is-electron';
|
||||
import desktopService from 'services/desktopService';
|
||||
import safeStorageService from 'services/safeStorageService';
|
||||
import { saveKeyInSessionStore } from 'utils/crypto';
|
||||
import { getKey, SESSION_KEYS } from 'utils/storage/sessionStorage';
|
||||
|
||||
|
@ -128,7 +128,7 @@ export default function LandingPage() {
|
|||
const user = getData(LS_KEYS.USER);
|
||||
let key = getKey(SESSION_KEYS.ENCRYPTION_KEY);
|
||||
if (!key && isElectron()) {
|
||||
key = await desktopService.getEncryptionKey();
|
||||
key = await safeStorageService.getEncryptionKey();
|
||||
if (key) {
|
||||
await saveKeyInSessionStore(
|
||||
SESSION_KEYS.ENCRYPTION_KEY,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { runningInBrowser } from 'utils/common';
|
||||
import { logError } from 'utils/sentry';
|
||||
|
||||
class DesktopService {
|
||||
class SafeStorageService {
|
||||
private ElectronAPIs: any;
|
||||
private allElectronAPIsExist: boolean = false;
|
||||
constructor() {
|
||||
|
@ -35,8 +35,8 @@ class DesktopService {
|
|||
return await this.ElectronAPIs.clearElectronStore();
|
||||
}
|
||||
} catch (e) {
|
||||
logError(e, 'getEncryptionKey failed');
|
||||
logError(e, 'clearElectronStore failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
export default new DesktopService();
|
||||
export default new SafeStorageService();
|
|
@ -20,7 +20,7 @@ import {
|
|||
import { getLocalFamilyData, isPartOfFamily } from 'utils/billing';
|
||||
import { ServerErrorCodes } from 'utils/error';
|
||||
import isElectron from 'is-electron';
|
||||
import desktopService from './desktopService';
|
||||
import safeStorageService from './safeStorageService';
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
|
@ -124,7 +124,7 @@ export const logoutUser = async () => {
|
|||
}
|
||||
await clearFiles();
|
||||
if (isElectron()) {
|
||||
desktopService.clearElectronStore();
|
||||
safeStorageService.clearElectronStore();
|
||||
}
|
||||
router.push(PAGES.ROOT);
|
||||
} catch (e) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import { setRecoveryKey } from 'services/userService';
|
|||
import { logError } from 'utils/sentry';
|
||||
import { ComlinkWorker } from 'utils/comlink';
|
||||
import isElectron from 'is-electron';
|
||||
import desktopService from 'services/desktopService';
|
||||
import safeStorageService from 'services/safeStorageService';
|
||||
|
||||
export interface B64EncryptionResult {
|
||||
encryptedData: string;
|
||||
|
@ -103,7 +103,7 @@ export const saveKeyInSessionStore = async (
|
|||
const sessionKeyAttributes = await cryptoWorker.encryptToB64(key);
|
||||
setKey(keyType, sessionKeyAttributes);
|
||||
if (isElectron() && !fromDesktop) {
|
||||
desktopService.setEncryptionKey(key);
|
||||
safeStorageService.setEncryptionKey(key);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue