Closed aulneau closed 1 year ago
Testing out using the noble libs in react native, and it seems the check for web crypto is not quite specific enough, typeof self === 'object' && 'crypto' in self can sometimes be true even when web crypto is not available.
typeof self === 'object' && 'crypto' in self
Here is the diff that solved my problem:
diff --git a/node_modules/@noble/secp256k1/lib/esm/index.js b/node_modules/@noble/secp256k1/lib/esm/index.js index ff76464..c5506a5 100644 --- a/node_modules/@noble/secp256k1/lib/esm/index.js +++ b/node_modules/@noble/secp256k1/lib/esm/index.js @@ -1046,7 +1046,7 @@ export const schnorr = { Point.BASE._setWindowSize(8); const crypto = { node: nodeCrypto, - web: typeof self === 'object' && 'crypto' in self ? self.crypto : undefined, + web: typeof self === 'object' && 'crypto' in self && 'subtle' in self.crypto ? self.crypto : undefined, }; const TAGS = { challenge: 'BIP0340/challenge', diff --git a/node_modules/@noble/secp256k1/lib/index.js b/node_modules/@noble/secp256k1/lib/index.js index e207e74..18cd75d 100644 --- a/node_modules/@noble/secp256k1/lib/index.js +++ b/node_modules/@noble/secp256k1/lib/index.js @@ -1056,7 +1056,7 @@ exports.schnorr = { Point.BASE._setWindowSize(8); const crypto = { node: nodeCrypto, - web: typeof self === 'object' && 'crypto' in self ? self.crypto : undefined, + web: typeof self === 'object' && 'crypto' in self && 'subtle' in self.crypto ? self.crypto : undefined, }; const TAGS = { challenge: 'BIP0340/challenge',
This issue body was partially generated by patch-package.
Testing out using the noble libs in react native, and it seems the check for web crypto is not quite specific enough,
typeof self === 'object' && 'crypto' in self
can sometimes be true even when web crypto is not available.Here is the diff that solved my problem:
This issue body was partially generated by patch-package.