Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: buffer is not defined

thecodrrdb4a9a43eedf
diff --git a/apps/web/src/interfaces/crypto.js b/apps/web/src/interfaces/crypto.js
index 2d6b5fdb2..2442f223a 100644
--- a/apps/web/src/interfaces/crypto.js
+++ b/apps/web/src/interfaces/crypto.js
@@ -2,11 +2,11 @@
* @return {Promise<Uint8Array>}
*/
function compress(data) {
- return import("lzutf8").then((lzutf8) => {
+ return loadLZUTF8((lzutf8) => {
lzutf8.compress(data, {
blockSize: 64 * 1024 * 1024,
- outputEncoding: "ByteArray",
inputEncoding: "String",
+ outputEncoding: "ByteArray",
});
});
}
@@ -15,8 +15,8 @@ function compress(data) {
* @return {Promise<string>}
*/
function decompress(data) {
- return import("lzutf8").then((lzutf8) => {
- return lzutf8.decompress(data, {
+ loadLZUTF8((lzutf8) => {
+ lzutf8.decompress(data, {
blockSize: 64 * 1024 * 1024,
inputEncoding: "ByteArray",
outputEncoding: "String",
@@ -24,6 +24,12 @@ function decompress(data) {
});
}
+function loadLZUTF8(action) {
+ return new Promise(async (resolve) => {
+ const lzutf8 = await import("lzutf8");
+ resolve(await action(lzutf8));
+ });
+}
class Crypto {
isReady = false;
constructor() {