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

@authorizerdev/authorizer-js

v2.0.3

Published

[`@authorizerdev/authorizer-js`](https://www.npmjs.com/package/@authorizerdev/authorizer-js) is universal javaScript SDK for Authorizer API. It supports:

Downloads

2,922

Readme

Authorizer.js

@authorizerdev/authorizer-js is universal javaScript SDK for Authorizer API. It supports:

Migration Guide from 1.x -> 2.x

2.x version of @authorizerdev/authorizer-js has a uniform response structure that will help your applications to get right error codes and success response. Methods here have {data, errors} as response objects for methods of this library.

For 1.x version of this library you can get only data in response and error would be thrown so you had to handle that in catch.


All the above versions require Authorizer instance to be instantiated and used. Instance constructor requires an object with the following keys

| Key | Description | | --------------- | ---------------------------------------------------------------------------- | | authorizerURL | Authorizer server endpoint | | redirectURL | URL to which you would like to redirect the user in case of successful login |

Example

const authRef = new Authorizer({
  authorizerURL: 'https://app.herokuapp.com',
  redirectURL: window.location.origin,
});

IIFE

  • Step 1: Load Javascript using CDN
<script src="https://unpkg.com/@authorizerdev/authorizer-js/lib/authorizer.min.js"></script>
  • Step 2: Use the library to instantiate Authorizer instance and access various methods
<script type="text/javascript">
  const authorizerRef = new authorizerdev.Authorizer({
    authorizerURL: `AUTHORIZER_URL`,
    redirectURL: window.location.origin,
    clientID: 'YOUR_CLIENT_ID', // can be obtained from authorizer dashboard
  });

  // use the button selector as per your application
  const logoutBtn = document.getElementById('logout');
  logoutBtn.addEventListener('click', async function () {
    await authorizerRef.logout();
    window.location.href = '/';
  });

  async function onLoad() {
    const { data, errors } = await authorizerRef.authorize({
      response_type: 'code',
      use_refresh_token: false,
    });
    if (data && data.access_token) {
      // get user profile using the access token
      const { data: user, errors } = await authorizerRef.getProfile({
        Authorization: `Bearer ${res.access_token}`,
      });

      // 	logoutSection.classList.toggle('hide');
      // 	userSection.innerHTML = `Welcome, ${user.email}`;
    }
  }
  onLoad();
</script>

CommonJS

  • Step 1: Install dependencies
npm i --save @authorizerdev/authorizer-js
OR
yarn add @authorizerdev/authoirzer-js
  • Step 2: Import and initialize the authorizer instance
const { Authorizer } = require('@authorizerdev/authoirzer-js');

const authRef = new Authorizer({
  authorizerURL: 'https://app.heroku.com',
  redirectURL: 'http://app.heroku.com/app',
});

async function main() {
  await authRef.login({
    email: '[email protected]',
    password: 'test',
  });
}

ES Modules

  • Step 1: Install dependencies
npm i --save @authorizerdev/authorizer-js
OR
yarn add @authorizerdev/authorizer-js
  • Step 2: Import and initialize the authorizer instance
import { Authorizer } from '@authorizerdev/authorizer-js';

const authRef = new Authorizer({
  authorizerURL: 'https://app.heroku.com',
  redirectURL: 'http://app.heroku.com/app',
});

async function main() {
  await authRef.login({
    email: '[email protected]',
    password: 'test',
  });
}

Local Development Setup

Prerequisites

Setup

  • Clone the repository
  • Install dependencies using pnpm install
  • Run pnpm build to build the library
  • Run pnpm test to run the tests

Release

  • Run pnpm release to release a new version of the library