MasterKale / SimpleWebAuthn

WebAuthn, Simplified. A collection of TypeScript-first libraries for simpler WebAuthn integration. Supports modern browsers, Node, Deno, and more.
https://simplewebauthn.dev
MIT License
1.62k stars 137 forks source link

require is not defined #427

Closed PawelDmochowski closed 1 year ago

PawelDmochowski commented 1 year ago

Describe the issue

Using @simplewebauthn/server@8.0.0 in ESM throws exception require is not defined when executing await generateRegistrationOptions().

Reproduction Steps

Import library in project with { "type": "module" }, execute await generateRegistrationOptions().

Expected behavior

The function should not throw MissingWebCrypto since "node:crypto" is available.

Code Samples + WebAuthn Options and Responses

The issue can be tracked to line 16 of @simplewebauthn\server\esm\helpers\iso\isoCrypto\getWebCrypto.js which uses require.

Dependencies

SimpleWebAuthn Libraries version 8.0.0

Additional context

MasterKale commented 1 year ago

Thanks for the report @PawelDmochowski. Whoops, I see the issue: I used require() when I attempt to dynamically import Node's crypto module instead of import(). 🤦‍♂️

PR #428 will fix this problem.

PawelDmochowski commented 1 year ago

Gosh, you're fast! 😄

MasterKale commented 1 year ago

@PawelDmochowski This should be fixed in the newly published @simplewebauthn/server@8.0.1 ✌️