#Can a package made for nodejs be used for nestjs ?

6 messages · Page 1 of 1 (latest)

brittle cloud
#

Hello, I wanna implement magic link authentification but I wasn't able to find one made specifically for nestjs. I found this one but it says for "passport.js" which is nodejs
https://www.npmjs.com/package/passport-magic-login

torpid sluice
#

Hi, yes, you can use any node.js library freely.
With this library you're probably in luck, since Nest.js has a library for working with Passport: https://docs.nestjs.com/security/authentication
You can follow the guide up to a point where the passport local strategy is used: https://docs.nestjs.com/security/authentication#implementing-passport-local
That's where you should by able to plug in the magic-login strategy you found:

import MagicLoginStrategy from "passport-magic-login"
brittle cloud
#

Thank you very much

torpid sluice
#

I mean, you'll probably have to follow both readme of the lib and the nest.js docs completely and mix and match it together, but you get the point 🙂

brittle cloud
#

the nestjs doc explains how to implement passport-local which is for a usernam/password authentication mechanism. I'm not sure to understand, is there something that I should take from it ?

torpid sluice
#

The nestjs/passport package has some helpers to integrate packages from passport ecosystem to nestjs.
The local strategy is for username/password, the magic link is just other of many strategies, but the flow and integration should be similar