passwordless-id / webauthn

Webauthn / passkeys helper library to make your life easier. Client side, server side and demo included.
https://webauthn.passwordless.id
MIT License
454 stars 53 forks source link

Missing crypto import? #58

Closed asbjornenge closed 3 months ago

asbjornenge commented 3 months ago

Hi there,

I'm trying to use this module with Node v16.16.0. Doing

    const auth = await server.verifyAuthentication(payload.authentication, key.credential, challenge)

I'm getting:

ReferenceError: crypto is not defined
    at parseCryptoKey (file:///home/asbjorn/srv/chainborn/v3/api/node_modules/@passwordless-id/webauthn/dist/esm/server.js:93:5)
    at verifySignature (file:///home/asbjorn/srv/chainborn/v3/api/node_modules/@passwordless-id/webauthn/dist/esm/server.js:108:27)

And even adding import crypto from 'crypto' to the server.js file it still fails since there is no crypto.subtle :sweat_smile: :thinking:

dagnelies commented 3 months ago

Node 16 has reached end-of-life last year already. Wouldn't it be better to update your node version instead? Just my 2 cents.

See https://github.com/passwordless-id/webauthn?tab=readme-ov-file#runs-in and Arch's Fork for outdated node environments

dagnelies commented 3 months ago

There are also a couple of related issues and workarounds in this repo by the way.

asbjornenge commented 3 months ago

@dagnelies upgraded to node 22, works like a charm 🥳 thanks!