From 2e430eb3561da10181487941eac12ddaf4274f02 Mon Sep 17 00:00:00 2001 From: Pinta Date: Mon, 17 Jun 2024 09:56:59 +0000 Subject: [PATCH] use crypto from global. Closes #2 --- deno.jsonc | 2 +- src/cryptokeys.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deno.jsonc b/deno.jsonc index 804bd69..4e93d7b 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,6 +1,6 @@ { "name": "@cross/jwt", - "version": "0.4.8", + "version": "0.4.9", "exports": "./mod.ts", "tasks": { diff --git a/src/cryptokeys.ts b/src/cryptokeys.ts index 4f9829b..360822f 100644 --- a/src/cryptokeys.ts +++ b/src/cryptokeys.ts @@ -228,7 +228,7 @@ export async function exportPEMKey(key: CryptoKey, filePathOrOptions?: string | const keyType = key.type; - const exportedKey = await window.crypto.subtle.exportKey( + const exportedKey = await crypto.subtle.exportKey( keyType === "private" ? "pkcs8" : "spki", key, ); @@ -291,7 +291,7 @@ export async function importPEMKey(keyDataOrPath: string, algorithm: SupportedKe const pemContents = pemString.substring(pemHeader.length, pemString.length - pemFooter.length); const binaryDer = decodeBase64(pemContents); - return await window.crypto.subtle.importKey( + return await crypto.subtle.importKey( keyType === "private" ? "pkcs8" : "spki", binaryDer, { ...algo },