Skip to content

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

crypto: make imports esm compatible

Abdullah Atta239781eabd6a
diff --git a/packages/sodium/benches/bench.ts b/packages/sodium/benches/bench.ts
index 261a36a63..771bb8807 100644
--- a/packages/sodium/benches/bench.ts
+++ b/packages/sodium/benches/bench.ts
@@ -16,8 +16,8 @@ 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 * as browser from "../src/browser";
-import * as node from "../src/node";
+import * as browser from "../src/browser.js";
+import * as node from "../src/node.js";
import benny from "benny";
import {
decrypt,
@@ -25,7 +25,7 @@ import {
getKey,
hash,
streamingEncrypt
-} from "../tests/utils";
+} from "../tests/utils.js";
async function main() {
await browser.initialize();
diff --git a/packages/sodium/src/browser.ts b/packages/sodium/src/browser.ts
index 78bbe1099..f412ae121 100644
--- a/packages/sodium/src/browser.ts
+++ b/packages/sodium/src/browser.ts
@@ -19,16 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import sodium from "libsodium-wrappers-sumo";
-if (process.env.NODE_ENV === "development") {
- // this is necessary in development otherwise all the exported functions
- // are undefined. Since vite supports direct top-level awaits in development
- // we forcefully ignore typescript.
-
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
- await sodium.ready;
-}
-
export async function initialize() {
await sodium.ready;
}
diff --git a/packages/sodium/tests/compat.test.ts b/packages/sodium/tests/compat.test.ts
index 1da8c1683..e66d0c5e4 100644
--- a/packages/sodium/tests/compat.test.ts
+++ b/packages/sodium/tests/compat.test.ts
@@ -17,8 +17,8 @@ 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 * as browser from "../src/browser";
-import * as node from "../src/node";
+import * as browser from "../src/browser.js";
+import * as node from "../src/node.js";
import { test } from "vitest";
import {
decrypt,
@@ -27,7 +27,7 @@ import {
hash,
streamingDecrypt,
streamingEncrypt
-} from "./utils";
+} from "./utils.js";
test("secretstream tags should be equal on node & browser variants", async (t) => {
t.expect(browser.crypto_secretstream_xchacha20poly1305_TAG_FINAL).toBe(
diff --git a/packages/sodium/tests/utils.ts b/packages/sodium/tests/utils.ts
index b24bfdfd1..211127edb 100644
--- a/packages/sodium/tests/utils.ts
+++ b/packages/sodium/tests/utils.ts
@@ -16,8 +16,8 @@ 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 * as browser from "../src/browser";
-import * as node from "../src/node";
+import * as browser from "../src/browser.js";
+import * as node from "../src/node.js";
export async function streamingEncrypt(
crypto: typeof node | typeof browser,