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

@workpathco/client

v1.0.43

Published

OAuth client library for Workpath

Downloads

53

Readme

Workpath Web Client

JavaScript client for OAuth authorization code flow.

This package was created to help single page applications connect to Workpath using oauth's authorization code flow.

Installation

npm install @workpathco/client --save

or

yarn add @workpathco/client

Usage example

First instantiate an authentication object passing the client id and redirect uri you've obtained from the Workpath Client Dashboard.

import { Authenticate } from "@workpathco/client"

const authentication = new Authenticate({
  client_id: "XXXXX-XXXXX-XXXXX-XXXXX", // insert your client id here
  redirect_uri: "https://your-redirect-uri.here", // insert your redirect uri added when creating your client
})

Next, use the instantiated authentication object to login:

authentication.login()

This will create a unique login url and redirect the user to the Workpath login page.

After the user signs in they will be redirected back to the specified redirect_uri where you will consume the request using the consume function as follows:

await authentication.consume()

Immediately after a successful authorization consumption you will be able to access the token by calling getToken as follows:

const token = authentication.memory.getToken()

This token is only set in memory so you will need to manage it's storage yourself. (Note: These token are valid for 24 hours at which point they will expire and the user will need to re-authenticate)

For instance, using session cookies:

cookie.set("_wp_token", JSON.stringify(token));

All subsequent authenticated requests can be made with the access_token added as an Authorization request header as follows:

Authorization: Bearer XXXX-XXXX-XXXX-XXXX

An example react implementation can be found here