From 57c1d9e612fa5ffbd3ae0b7c43fc1e20ec748030 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Tue, 3 Sep 2024 01:26:52 +0000 Subject: [PATCH] webcrypto: detect subtle, copy from secp256k1 --- index.js | 2 +- index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index ab45032..3d27c39 100644 --- a/index.js +++ b/index.js @@ -305,7 +305,7 @@ const _verify = (sig, msg, pub, opts = dvo) => { const verifyAsync = async (s, m, p, opts = dvo) => hashFinish(true, _verify(s, m, p, opts)); const verify = (s, m, p, opts = dvo) => hashFinish(false, _verify(s, m, p, opts)); const cr = () => // We support: 1) browsers 2) node.js 19+ - typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined; + typeof globalThis === 'object' && 'crypto' in globalThis && 'subtle' in globalThis.crypto ? globalThis.crypto : undefined; const etc = { bytesToHex: b2h, hexToBytes: h2b, concatBytes: concatB, mod, invert, diff --git a/index.ts b/index.ts index 52cc620..0515e67 100644 --- a/index.ts +++ b/index.ts @@ -272,7 +272,7 @@ const verify = (s: Hex, m: Hex, p: Hex, opts = dvo) => hashFinish(false, _verify(s, m, p, opts)); declare const globalThis: Record | undefined; // Typescript symbol present in browsers const cr = () => // We support: 1) browsers 2) node.js 19+ - typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined; + typeof globalThis === 'object' && 'crypto' in globalThis && 'subtle' in globalThis.crypto ? globalThis.crypto : undefined; const etc = { bytesToHex: b2h, hexToBytes: h2b, concatBytes: concatB, mod, invert,