Adds backup functionality

This commit is contained in:
Alicia Sykes
2021-05-24 17:25:16 +01:00
parent 8ffbfb8123
commit 44b2594dfa
9 changed files with 150 additions and 16 deletions

View File

@@ -1,9 +1,10 @@
/* eslint-disable */
import sha256 from 'crypto-js/sha256';
import aes from 'crypto-js/aes';
import Base64 from 'crypto-js/enc-base64';
import Hex from 'crypto-js/enc-hex';
import Utf8 from 'crypto-js/enc-utf8';
import axios from 'axios';
const ENDPOINT = 'https://dashy-sync-service.as93.net/';
/* Stringify, encrypt and encode data for transmission */
const encryptData = (data, password) => {
@@ -22,11 +23,16 @@ const makeSubHash = (pass) => sha256(pass).toString().slice(0, 14);
/* Makes the backup */
export const backup = (data, password) => {
// const subHash = makeSubHash(password);
const encryptedData = encryptData(data, password);
console.log(encryptedData);
console.log(decryptData(encryptedData, password));
return axios.post(ENDPOINT, {
userData: encryptData(data, password),
subHash: makeSubHash(password),
});
};
/* Restores the backup */
export const restore = (backupId, password) => { };
export const restore = (backupId, password) => {
// return axios.get(ENDPOINT, {
// backupId,
// subHash: makeSubHash(password),
// });
};

View File

@@ -47,6 +47,8 @@ module.exports = {
CONF_SECTIONS: 'confSections',
PAGE_INFO: 'pageInfo',
APP_CONFIG: 'appConfig',
BACKUP_ID: 'backupId',
BACKUP_HASH: 'backupHash',
},
topLevelConfKeys: {
PAGE_INFO: 'pageInfo',
@@ -55,7 +57,7 @@ module.exports = {
},
toastedOptions: {
position: 'bottom-center',
duration: 2000,
duration: 2500,
keepOnHover: true,
className: 'toast-message',
iconPack: 'fontawesome',