From b66ca1787a21cfff3ce57a40c2850191056392f1 Mon Sep 17 00:00:00 2001 From: eosxx Date: Fri, 28 Apr 2023 07:49:46 +0000 Subject: [PATCH] fix(nip04): crypto.subtle is undefined --- nip04.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nip04.ts b/nip04.ts index aff2b94..3962f8e 100644 --- a/nip04.ts +++ b/nip04.ts @@ -1,9 +1,15 @@ import {randomBytes} from '@noble/hashes/utils' import * as secp256k1 from '@noble/secp256k1' import {base64} from '@scure/base' +import crypto from 'crypto' import {utf8Decoder, utf8Encoder} from './utils' +if (!crypto.subtle) { + // @ts-ignore + crypto.subtle = crypto.webcrypto.subtle +} + export async function encrypt( privkey: string, pubkey: string,