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

fastpass

v0.0.3

Published

A node.js library for getsatsfaction fastpass

Downloads

136

Readme

node-fastpass

A node.js library for getsatisfaction fastpass (single sign-on)

This serves as a drop-in replacement for the existing getsatisfaction fastpass libraries, and implements the same method signatures (with some defaulting for ease of use) as the ruby library. Documentation for existing fastpass libraries can be found on the getsatisfaction help site.


Usage:

Add the dependency:

npm install --save fastpass

Require it:

var FastPass = require('fastpass')

Instantiate it:

var fastPass = new FastPass({
   // optional, defaults to "getsatisfaction.com"
   domain : "getsatisfaction.com",
   // required, your consumer key
   consumer_key : "xi2vaxgpp06m",
   // required, your consumer secret
   consumer_secret : "ly68der0hk8idfr5c73ozyq56jpwstd1",
   // optional at instantiation - email of the user
   email : "[email protected]",
   // optional at instantiation - Name of the user
   name : "Scott",
   // optional at instantiation - unique ID of user (must stay the same for the lifetime the user in your system)
   unique_identifier : "nullstyle",
   // optional boolean, defaults to false
   is_secure : false,
   // optional object, any private fields you like. defaults to {}.
   private_fields : {}
})

Implementation:

Using the Script tag

fastPass.script({
  email : "[email protected]",
  name : "Scott",
  unique_identifier : "nullstyle"
}, function(err,script){
  var outputScript = script
})

or if you passed name, unique_identifier, and email at instantiation:

fastPass.script(function(err,script){
  var outputScript = script
})

Now replace all links to getSatisfaction with calls to GSFN.goto_gsfn()

// for instance, in jQuery
$('body').on('click','a[href="http://getsatisfaction.com"]',function(){ GSFN.goto_gsfn(); return false; })

Using Cookies along with CNAME

Set a cookie named "fastpass" to the URL generated by the FastPass library. Note: This is only available if your company is using the CNAME feature.

// inside of an express route or whatever:
fastPass.url(<options>,function(err,url){
  cookies["fastpass"] = url
})

Using the Query String

Include the generated URL in the param named "fastpass" in all links to Get Satisfaction.

// in some template context
fastPass.url(<options>,function(err,url){
  var linkUrl = "<a href="http://getsatisfaction.com/mycompany?fastpass=" + url + ">Our Support Community</a>"
})

Option Details:

Field         |  Required  |  Notes
Key           |    Yes     |
Secret        |    Yes     |
Email         |    Yes     |
Name          |    Yes     |
Unique Id     |    Yes     | Must remain unchanged for the lifetime of the user's account in your system.
Is Secure     |    No      | (defaults to false)
Private Fields|    No      | Key/value pairs to send along with the user to Get Satisfaction.

Example Setup:

The getSatisfaction setup is bi-directional, the smoothest sign on process happens when you have a CNAME set, a cookie with the current user, and a GSFN script on the page after login.

In an express server, here's how that might look:

// Assumes that you've require'd and instantiated FastPass with your credentials.
// a-la: var fastPass = new FastPass(<options>)

// getsatisfaction middleware
// assumes that you've got authentication middleware before this that sets `req.authenticated` and adds `user` to `req.session`.
// these assumptions can obviously be replaced by however your app works, this should get you most of the way there.
app.use(function(req,res,next){
  if(req.authenticated){
    // add a cookie for getSatisfaction single sign on
    // crudely strips the subdomain - probably should be smarter to avoid clobbering non-subdomain urls.
    var cookieDomain = req.headers.host.replace('^[^\.]*',''),
        user = req.session.user
    fastPass.url({name : user.first_name + " " + user.last_name, email : user.email, unique_identifier : user.id },function(err,url){
      // this is the important part - sets a cookie for your domain.
      res.cookie('fastpass',url, {domain : cookieDomain})
      next()
    })
  } else {
    next()
  }
})

You'll also need to expose the script on all your logged-in pages:

app.get('/some/logged/in/route',function(req,res){
  var user = req.session.user
  fastPass.script({name : user.first_name + " " + user.last_name, email : user.email, unique_identifier : user.id },function(err,script){
    // do your res.send() or whatever, render the script
  })
})