Skip to content

Commit

Permalink
Update src/test/index_node.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mryhryki committed Aug 5, 2023
1 parent 860fbc5 commit 4da97a6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/test/index_node.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { webcrypto } from "node:crypto";
import * as crypto from "crypto";
import { test } from "./index.js";
import { decrypt, encrypt } from "@mryhryki/simple-encryption";

globalThis.crypto = webcrypto;
// Node.js v19 and later, there is `crypto` in `globalThis`.
//
// Ref:
// - https://github.com/nodejs/node/pull/42083
// - https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V19.md#19.0.0
if (!("crypto" in globalThis)) {
globalThis.crypto = crypto.webcrypto;
}

test({ encrypt, decrypt });

0 comments on commit 4da97a6

Please sign in to comment.