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
crypto: lazily import sodium
Abdullah Attabc9cbbc1f68d
diff --git a/packages/crypto/src/decryption.ts b/packages/crypto/src/decryption.tsindex 5ad97f921..ee55d38cc 100644--- a/packages/crypto/src/decryption.ts+++ b/packages/crypto/src/decryption.ts@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { base64_variants, ISodium } from "@notesnook/sodium";-import KeyUtils from "./keyutils.js";+import { ISodium } from "@notesnook/sodium";+import KeyUtils, { base64_variants } from "./keyutils.js";import {Cipher,Output,diff --git a/packages/crypto/src/encryption.ts b/packages/crypto/src/encryption.tsindex 99cdc9d17..c5c236e8f 100644--- a/packages/crypto/src/encryption.ts+++ b/packages/crypto/src/encryption.ts@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { ISodium, base64_variants } from "@notesnook/sodium";-import KeyUtils from "./keyutils.js";+import { ISodium } from "@notesnook/sodium";+import KeyUtils, { base64_variants } from "./keyutils.js";import { Chunk, Cipher, Input, DataFormat, SerializedKey } from "./types.js";const encoder = new TextEncoder();diff --git a/packages/crypto/src/index.ts b/packages/crypto/src/index.tsindex ce8f23fb3..4af8962f7 100644--- a/packages/crypto/src/index.ts+++ b/packages/crypto/src/index.ts@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { ISodium, Sodium } from "@notesnook/sodium";+import { ISodium } from "@notesnook/sodium";import Decryption from "./decryption.js";import Encryption from "./encryption.js";import { INNCrypto } from "./interfaces.js";@@ -37,10 +37,11 @@ import {export class NNCrypto implements INNCrypto {private isReady = false;- private sodium: ISodium = new Sodium();+ private sodium!: ISodium;private async init() {if (this.isReady) return;+ this.sodium = new (await import("@notesnook/sodium")).Sodium();await this.sodium.initialize();this.isReady = true;}diff --git a/packages/crypto/src/keyutils.ts b/packages/crypto/src/keyutils.tsindex 059f32367..a0f502ed9 100644--- a/packages/crypto/src/keyutils.ts+++ b/packages/crypto/src/keyutils.ts@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { base64_variants, ISodium } from "@notesnook/sodium";+import { ISodium } from "@notesnook/sodium";import {EncryptionKey,EncryptionKeyPair,@@ -25,6 +25,13 @@ import {SerializedKeyPair} from "./types.js";+export enum base64_variants {+ ORIGINAL = 1,+ ORIGINAL_NO_PADDING = 3,+ URLSAFE = 5,+ URLSAFE_NO_PADDING = 7+}+export default class KeyUtils {static deriveKey(sodium: ISodium,