A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: add hash-wash for hashing and add deleteFile
thecodrr4b2f943c8a1d
diff --git a/apps/web/package.json b/apps/web/package.jsonindex e6b198e05..4e9e2f642 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -24,6 +24,7 @@"eventsource": "^1.0.7","fast-sort": "^2.1.1","framer-motion": "^3.3.0",+ "hash-wasm": "^4.9.0","highlight.js": "^11.1.0","hotkeys-js": "^3.8.3","immer": "^8.0.1",diff --git a/apps/web/src/interfaces/fs.js b/apps/web/src/interfaces/fs.jsindex de0d4ed6e..06be9f4cc 100644--- a/apps/web/src/interfaces/fs.js+++ b/apps/web/src/interfaces/fs.js@@ -1,6 +1,7 @@import NNCrypto from "./nncrypto/index";import localforage from "localforage";import xxhash from "xxhash-wasm";+import { xxhash3 } from "hash-wasm";import axios from "axios";const crypto = new NNCrypto();@@ -47,10 +48,9 @@ async function writeEncrypted(filename, { data, type, key }) {}async function hashBuffer(data) {- const hasher = await xxhash();return {- hash: Buffer.from(hasher.h64Raw(data)).toString("hex"),- type: "xxh64",+ hash: xxhash3(data),+ type: "xxh3",};}@@ -112,7 +112,26 @@ async function downloadFile(filename, requestOptions) {return true;}-const FS = { writeEncrypted, readEncrypted, uploadFile, downloadFile };+async function deleteFile(filename, requestOptions) {+ const { url, headers } = requestOptions;+ console.log("Request to delete file", filename, url, headers);+ if (!(await fs.hasItem(filename))) return true;++ const response = await axios.delete(url, {+ headers: headers,+ });+ const result = isSuccessStatusCode(response.status);+ // if (result) await fs.removeItem(filename);+ return result;+}++const FS = {+ writeEncrypted,+ readEncrypted,+ uploadFile,+ downloadFile,+ deleteFile,+};export default FS;function isSuccessStatusCode(statusCode) {