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

authentic-client

v2.1.0

Published

The client component of Authentic. This helps interact with an `authentic-server` so that you can easily signup, confirm, login, and change-password for users. It will also help send tokens to microservices that require authentication.

Downloads

556

Readme

AuthenticClient

The client component of authentic. This helps interact with an authentic-server so that you can easily signup, confirm, login, and change-password for users. It will also help send tokens to microservices that require authentication.

Example

var Authentic = require('authentic-client')

var auth = Authentic({
  server: 'https://auth.scalehaus.io'
})

var creds = {
  email: '[email protected]',
  password: 'notswordfish'
}

// Step 1: log in
auth.login(creds, function (err) {
  if (err) return console.error(err)

  // Step 2: make a JSON request with authentication
  var url = 'https://reporting.scalehaus.io/report'
  auth.get(url, function (err, data) {
    // show that report
    console.log(data)
  })
})

Installation

npm install --save authentic-client

API

Authentic(opts)

This is the main entry point. Accepts an options object and returns an object with helper methods.

var auth = Authentic({
  server: 'https://auth.scalehaus.io'
})

// auth is now an object with various methods:
auth.signup(opts, cb)
auth.confirm(opts, cb)
auth.login(opts, cb)
auth.changePasswordRequest(opts, cb)
auth.changePassword(opts, cb)
auth.magicRequest(opts, cb)
auth.magicLogin(opts, cb)

options

Authentic() takes an options object as its first argument, one of them is required:

  • server: the url of the authentic-server, e.g. 'http://auth.yourdomain.com'

Optional:

  • prefix: defaults to '/auth' if you set a custom prefix for your authentic-server, use that same prefix here
  • authToken: if you have an authToken from a previous login, you may pass it in for immediate use in get and post

auth.signup(opts, cb)

auth.confirm(opts, cb)

auth.login(opts, cb)

auth.changePasswordRequest(opts, cb)

auth.changePassword(opts, cb)

auth.magicRequest(opts, cb)

auth.magicLogin(opts, cb)

See authentic-server's Server API for usage

auth.get(url, opts, cb)

Will make a request using an authToken if one is available, has the same API as [jsonist.get] (https://github.com/rvagg/jsonist#jsonistgeturl--options--callback)

auth.post(url, data, opts, cb)

Will make a request using an authToken if one is available, has the same API as jsonist.post

auth.put(url, data, opts, cb)

Will make a request using an authToken if one is available, has the same API as jsonist.put

auth.delete(url, opts, cb)

Will make a request using an authToken if one is available, has the same API as [jsonist.delete] (https://github.com/rvagg/jsonist#jsonistdeleteurl--options--callback)

If token is present, it will be verified before request against authentic-server's public key, and options will be extended with authorization header prior to sending request. It will use Bearer ${token} scheme.

You can also call verifyToken explicitly yourself and provide a callback. (In case of invalid token, err is going to be provided by jsonwebtoken)

auth.verifyToken(function(err){ ... })

License

MIT