Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with Node #8

Open
AlexGustafsson opened this issue Jun 5, 2017 · 8 comments
Open

Help with Node #8

AlexGustafsson opened this issue Jun 5, 2017 · 8 comments

Comments

@AlexGustafsson
Copy link

I could start offer some help with the NodeJS implementation in about a week from now. Is there any known implementation already or has anyone started to work on it?

@homakov
Copy link
Member

homakov commented Jun 5, 2017

No, no one is working on Node now, and it's great if you can help. I can contact you in a week (messenger?) and we will do a generic node.js integration and maybe some plugins for popular passport.js?

@andrewda
Copy link
Contributor

andrewda commented Jun 5, 2017

I would also love to help out with a Node implementation!

@andrewda
Copy link
Contributor

Posted this on the Slack but I'll post it here too for visibility:

Here's a minimal Node.js SecureLogin module: https://github.com/andrewda/node-securelogin
And here's a Passport/Express module: https://github.com/andrewda/passport-securelogin

I would love some help with these!

@AlexGustafsson
Copy link
Author

Would you feel comfortable in posting issues regarding what you want done with some tag "help-needed" or the like?

@andrewda
Copy link
Contributor

Sure, I'll look over and see what still needs to be done in a bit.

@homakov
Copy link
Member

homakov commented Jun 29, 2017

I wonder what's best way to implement cred rotation endpoint /securelogin? Should it be copy pasted by every app or just baked in npm module? If it's baked in then we need a common way to interact with user db to find user by pubkey and then replace it. Is there some common interface/ORM?

@andrewda
Copy link
Contributor

I made something in passport-securelogin that handles mostly everything for the /securelogin endpoint (see https://github.com/andrewda/passport-securelogin#profile-change). I eventually want it to be more baked in so developers don't have to worry about it as much.

@andrewda
Copy link
Contributor

andrewda commented Jun 29, 2017

For example, I eventually want to refactor the entire module to look something like this:

const sl = new SecureLogin({
  origins: ['localhost:3001', 'http://c.dev'],
  changeCredentials: (err, newUser, oldPublicKey) => {
    if (err) {
      console.log(err);
    } else {
      // do database stuff to update the user
    }
  }
});

// now you can access all SecureLogin methods through `sl`

passport.use(new sl.Strategy({ domains: 'http://c.dev:3001' }));

app.post('/login', passport.authenticate('securelogin', { session: true }),
  (req, res) => res.sendStatus(200));

app.post('/sendmoney', sl.ScopeMiddleware({ domains: 'http://c.dev:3001' }),
  (req, res) => {
    console.log(`${req.user.authkeys.public} -> $${req.securelogin.scope.amount} -> ${req.securelogin.scope.address}`);
    res.json(req.securelogin.scope);
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants