mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
feat: minor cleanups and fixes
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import Hashes from "jshashes";
|
import Hashes from "jshashes";
|
||||||
const sha256 = new Hashes.SHA256();
|
const md5 = new Hashes.MD5();
|
||||||
|
|
||||||
const invalidKeys = ["user", "t", "lastBackup"];
|
const invalidKeys = ["user", "t", "lastBackupTime"];
|
||||||
const validTypes = ["mobile", "web", "node"];
|
const validTypes = ["mobile", "web", "node"];
|
||||||
export default class Backup {
|
export default class Backup {
|
||||||
/**
|
/**
|
||||||
@@ -30,7 +30,7 @@ export default class Backup {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const db = Object.fromEntries(await this._db.context.readMulti(keys));
|
const db = Object.fromEntries(await this._db.context.readMulti(keys));
|
||||||
db.h = sha256.hex(JSON.stringify(db));
|
db.h = md5.hex(JSON.stringify(db));
|
||||||
|
|
||||||
if (encrypt) {
|
if (encrypt) {
|
||||||
const key = await this._db.user.key();
|
const key = await this._db.user.key();
|
||||||
@@ -90,6 +90,6 @@ export default class Backup {
|
|||||||
_verify(db) {
|
_verify(db) {
|
||||||
const hash = db.h;
|
const hash = db.h;
|
||||||
delete db.h;
|
delete db.h;
|
||||||
return hash == sha256.hex(JSON.stringify(db));
|
return hash == md5.hex(JSON.stringify(db));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ const SUCCESS_LOGIN_RESPONSE = {
|
|||||||
username: "thecodrr",
|
username: "thecodrr",
|
||||||
email: process.env.EMAIL,
|
email: process.env.EMAIL,
|
||||||
},
|
},
|
||||||
scopes: "sync",
|
|
||||||
expiry: 36000,
|
expiry: 36000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ export default class User {
|
|||||||
await this.set({
|
await this.set({
|
||||||
...user,
|
...user,
|
||||||
...serverUser,
|
...serverUser,
|
||||||
notesnook: { ...user.notesnook, ...serverUser.notesnook },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// propogate event
|
// propogate event
|
||||||
@@ -122,7 +121,6 @@ function userFromResponse(response, key) {
|
|||||||
...response.payload,
|
...response.payload,
|
||||||
accessToken: response.access_token,
|
accessToken: response.access_token,
|
||||||
refreshToken: response.refresh_token,
|
refreshToken: response.refresh_token,
|
||||||
scopes: response.scopes,
|
|
||||||
expiry: Date.now() + response.expiry * 100,
|
expiry: Date.now() + response.expiry * 100,
|
||||||
key,
|
key,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user