mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
This should not affect the items or their server representation. This change is necessary to allow multiple items with same id that live in different collections. For example, shortcuts have the same id as the inner reference they point to. This was not possible before and would cause an overwrite of the original value.
81 lines
1.9 KiB
JavaScript
81 lines
1.9 KiB
JavaScript
/*
|
|
This file is part of the Notesnook project (https://notesnook.com/)
|
|
|
|
Copyright (C) 2022 Streetwriters (Private) Limited
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
import { randomBytes } from "../utils/random";
|
|
|
|
export default class Storage {
|
|
constructor(storage) {
|
|
this.storage = storage;
|
|
}
|
|
|
|
write(key, data) {
|
|
return this.storage.write(key, data);
|
|
}
|
|
|
|
readMulti(keys) {
|
|
return this.storage.readMulti(keys);
|
|
}
|
|
|
|
read(key, isArray = false) {
|
|
return this.storage.read(key, isArray);
|
|
}
|
|
|
|
clear() {
|
|
return this.storage.clear();
|
|
}
|
|
|
|
remove(key) {
|
|
return this.storage.remove(key);
|
|
}
|
|
|
|
getAllKeys() {
|
|
return this.storage.getAllKeys();
|
|
}
|
|
|
|
encrypt(password, data) {
|
|
return this.storage.encrypt(password, data);
|
|
}
|
|
|
|
decrypt(password, cipher) {
|
|
return this.storage.decrypt(password, cipher);
|
|
}
|
|
|
|
deriveCryptoKey(name, data) {
|
|
return this.storage.deriveCryptoKey(name, data);
|
|
}
|
|
|
|
hash(password, userId) {
|
|
return this.storage.hash(password, userId);
|
|
}
|
|
|
|
getCryptoKey(name) {
|
|
return this.storage.getCryptoKey(name);
|
|
}
|
|
|
|
generateCryptoKey(password, salt) {
|
|
return this.storage.generateCryptoKey(password, salt);
|
|
}
|
|
|
|
async generateRandomKey() {
|
|
const passwordBytes = randomBytes(124);
|
|
const password = passwordBytes.toString("base64");
|
|
return await this.storage.generateCryptoKey(password);
|
|
}
|
|
}
|