Skip to content

Commit

Permalink
retracted shim, jwt lib also requires crypto.subtle, shim has to come
Browse files Browse the repository at this point in the history
from client that wants to use esm on node.
  • Loading branch information
aricart committed Jul 14, 2022
1 parent d4323ed commit 39dcfc7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
17 changes: 1 addition & 16 deletions bin/tweetnacl-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,7 @@ async function copyFromModulesDir(

await copyFromModulesDir(
"nacl.js",
`
// added by nkeys.js
// shim for crypto.randomBytes on nodejs when using the
// esm module of the nkeys.js library
if (!globalThis.crypto) {
if (typeof module === "undefined") {
globalThis.crypto = {
randomBytes: (a) => {
for (let i = 0; i < a.length; i++) {
a[i] = Math.floor(256 * Math.random());
}
},
};
}
}
`,
"",
`
//added by nkeys.js export it
export const nacl = globalThis.nacl;
Expand Down
15 changes: 0 additions & 15 deletions modules/esm/nacl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@
// deno-lint-ignore-file
// deno-fmt-ignore-file


// added by nkeys.js
// shim for crypto.randomBytes on nodejs when using the
// esm module of the nkeys.js library
if (!globalThis.crypto) {
if (typeof module === "undefined") {
globalThis.crypto = {
randomBytes: (a) => {
for (let i = 0; i < a.length; i++) {
a[i] = Math.floor(256 * Math.random());
}
},
};
}
}
(function(nacl) {
'use strict';

Expand Down

0 comments on commit 39dcfc7

Please sign in to comment.