mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
crypto: make imports esm compatible
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user