github / webauthn-json

🔏 A small WebAuthn API wrapper that translates to/from pure JSON using base64url.
https://github.github.com/webauthn-json/demo/
MIT License
759 stars 61 forks source link

NextJS App Router - Server-Side Compatibility #80

Open renchris opened 1 year ago

renchris commented 1 year ago

Hello,

I'm looking to use this library in my NextJS app router project. Is there any way to make and use this library to be server-side environment compatible?

This library is client-side per the description: @github/webauthn-json is a client-side Javascript library, however, the application logic for WebAuthN authentication is server-side, so the usage is currently not usable.

renchris commented 1 year ago

The current error I am with is

Unhandled Runtime Error Error: navigator is not defined

on

const credential = await create({

lgarron commented 1 year ago

I'm looking to use this library in my NextJS app router project. Is there any way to make and use this library to be server-side environment compatible?

Do you have a specific goal for this?

This library is designed specifically for client WebAuthn authentication, without any server-specific functionality. I don't know of a use case for a server to act like a WebAuthn client.

If you want to perform server-side WebAuthn logic in JavaScript, you may want to look at another library like: https://simplewebauthn.dev/

kaszeba commented 3 days ago

@renchris you are trying to use browser (client-side) specific code (that needs window object to be present) on the server. This will not work