webauthn-open-source / fido2-lib

A node.js library for performing FIDO 2.0 / WebAuthn server functionality
https://webauthn.io
MIT License
394 stars 118 forks source link

Deprecation warning for punycode #159

Closed paulsutherland closed 3 months ago

paulsutherland commented 4 months ago

Hi,

I receive this warning in my console:

(node:81628) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. 

If you change the import from:

var punycode = require('punycode');

to

var punycode = require('punycode/');

It resolves the issue. See the note on the punycode repo:

⚠️ Note that userland modules don't hide core modules. For example, require('punycode') still imports the deprecated core module even if you executed npm install punycode. Use require('punycode/') to import userland modules rather than core modules.

Cheers...

Paul

JamesCullum commented 4 months ago

Hey Paul, thanks for sharing. Can you create a PR?

paulsutherland commented 4 months ago

Hi James,

I have created a pull request that updates the rollup config.

I was not sure how to update the library. I see punycode being used in toolbox.js in the lib, but this is ES6 and the advice from the punycode repo details cjs. I tried to update the import, but nothing worked.

Since updating the main.cjs file in the dist to var punycode = require('punycode/'); resolves the deprecation warning, the simplest change was to update the rollup config.

I hope that is helpful.

Cheers...

Paul

JamesCullum commented 4 months ago

Thanks for the PR - it doesn't look like that approach is exactly right. Maybe we need some more googling to see how others solved the problem.