mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: writeEncrypted -> writeEncryptedBase64
This commit is contained in:
committed by
Abdullah Atta
parent
7a773937c2
commit
29608099db
@@ -98,18 +98,19 @@ async function writeEncryptedFile(file, key, hash) {
|
||||
|
||||
/**
|
||||
* We perform 4 steps here:
|
||||
* 1. We convert base64 to Uint8Array (if we get base64, that is)
|
||||
* 1. We convert base64 to Uint8Array
|
||||
* 2. We hash the Uint8Array.
|
||||
* 3. We encrypt the Uint8Array
|
||||
* 4. We save the encrypted Uint8Array
|
||||
*/
|
||||
async function writeEncrypted(filename, { data, type, key, mimeType }) {
|
||||
if (type === "base64") data = new Uint8Array(Buffer.from(data, "base64"));
|
||||
async function writeEncryptedBase64(metadata) {
|
||||
const { data, key, mimeType } = metadata;
|
||||
|
||||
const { hash, type: hashType } = await hashBuffer(data);
|
||||
if (!filename) filename = hash;
|
||||
const bytes = new Uint8Array(Buffer.from(data, "base64"));
|
||||
|
||||
const file = new File([data.buffer], filename, {
|
||||
const { hash, type: hashType } = await hashBuffer(bytes);
|
||||
|
||||
const file = new File([bytes.buffer], hash, {
|
||||
type: mimeType || "application/octet-stream"
|
||||
});
|
||||
|
||||
@@ -461,7 +462,7 @@ function clearFileStorage() {
|
||||
}
|
||||
|
||||
const FS = {
|
||||
writeEncrypted,
|
||||
writeEncryptedBase64,
|
||||
readEncrypted,
|
||||
uploadFile: cancellable(uploadFile),
|
||||
downloadFile: cancellable(downloadFile),
|
||||
|
||||
Reference in New Issue
Block a user