Skip to content

Commit 4c5868d

Browse files
committed
Attempt fix for fix for missing global crypto in Node.js 18
1 parent e8e535d commit 4c5868d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/token.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ async function sign(
2020
encodedPayload: string
2121
): Promise<string> {
2222
// missing crypto global for Node.js 18
23-
const localCrypto = crypto ?? (await import('node:crypto')).webcrypto
23+
const localCrypto =
24+
typeof crypto === 'undefined'
25+
? (await import('node:crypto')).webcrypto
26+
: crypto
2427

2528
const textEncoder = new TextEncoder()
2629

0 commit comments

Comments
 (0)