This PR refines the changes made to getWebCrypto() in #468 by moving the try / catch into _getWebCryptoInternals.stubThisImportNodeCrypto. This should prevent non-Node runtimes from A) getting hung up on the use of import() or B) trying to use it to import a Node-specific identifier.
Fixes #471.
In an effort to confirm the fix, I tested these changes in the following "edge runtimes":
A simple Astro project, and also with npx astro add cloudflare added in for CF support (as per #471)
npm start wouldn't recreate the original issue, but I confirmed that npm run build experienced the error described in #471 with @simplewebauthn/server@8.3.4 but not with these changes
A basic CloudFlare Worker project, and again with compatibility_flags = [ "nodejs_compat" ] in wrangler.toml
This PR refines the changes made to
getWebCrypto()
in #468 by moving thetry / catch
into_getWebCryptoInternals.stubThisImportNodeCrypto
. This should prevent non-Node runtimes from A) getting hung up on the use ofimport()
or B) trying to use it to import a Node-specific identifier.Fixes #471.
In an effort to confirm the fix, I tested these changes in the following "edge runtimes":
npx astro add cloudflare
added in for CF support (as per #471)npm start
wouldn't recreate the original issue, but I confirmed thatnpm run build
experienced the error described in #471 with @simplewebauthn/server@8.3.4 but not with these changescompatibility_flags = [ "nodejs_compat" ]
in wrangler.tomlI tested with the following code:
Proof
Astro
CloudFlare Worker