npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kraken-paypal-passport

v0.0.3

Published

Simplifies using Passport-based authentication against PayPal in a Kraken.js application

Downloads

7

Readme

This module provides methods to setup one or more PayPal environments in a Kraken Node.js application with passport.js. It provides basic controllers for outbound and incoming auth handling and scaffolding to minimize your duplicated code for multi-environment resolution, etc. It also provides HTTP/S clients to use the credentials you receive and automatically handle token refresh.

Here's a sample script that configures the module for multiple environments based on your config.json:

var util = require('util'),
    PayPalPassport = require('kraken-paypal-passport');

var MePassport = function () {
    MePassport.super_.apply(this, arguments);
};

util.inherits(MePassport, PayPalPassport);

MePassport.prototype.saveToPersistentStore = function (expressRequest, accessToken, refreshToken, profile, done) {
    // Save the profile/token info to a db and then call done
};

function configurePassport(app, config) {
    PayPalPassport.attachToKraken(app, function () {
        // You can now add handlers to the app that require the passport stuff to be sorted out by the time they run
    });

    PayPalPassport.setSerializers(function serializePassportUser(authInfo, done) {
        // Come up with an id that can be saved to the cookie (runs after saveToPersistentStore)
        done(null, some_id);
    }, function deserializePassportUser(authInfo, done) {
        // Take the id and reconstitute the user object (usually from a db)
        done(null, user_object);
    });

    var liwpConfig = config.get('loginWithPayPal');
    for (var env in liwpConfig) {
        log.debug('Creating passport environment %s', env);
        var cfg = util._extend({return_url:config.get('siteBaseUrl')+'/oauth/return'}, liwpConfig[env]);
        // You probably want to store this in some exported variable
        new MePassport(env, cfg);
    }
}

And the sample controllers to send and receive a user from PayPal:

    router.get('/login/:env', function (req, res, next) {
        return passport.environments[req.params.env].sendToPayPal(req, res, next);
    });

    router.get('/return', function (req, res, next) {
        passport.environments[req.session.passportEnv].returnedFromPayPal(req, res, next);
    });