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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@authorizerdev/authorizer-js

v4.0.0

Published

[`@authorizerdev/authorizer-js`](https://www.npmjs.com/package/@authorizerdev/authorizer-js) is the universal JavaScript/TypeScript SDK for the Authorizer API. Current version: **3.2.1**.

Readme

Authorizer.js

@authorizerdev/authorizer-js is the universal JavaScript/TypeScript SDK for the Authorizer API. Current version: 3.2.1.

It supports:

Migration Guide

2.x -> 3.x

3.x introduces a Protocol type ('graphql' | 'rest') and an optional protocol field on the constructor. The response shape is unchanged from 2.x — all methods return { data: T | undefined, errors: Error[] }.

The config type is now exported as ConfigType.

1.x -> 2.x

2.x introduced the uniform { data, errors } response shape. In 1.x methods returned data directly and threw on error.


Constructor

import { Authorizer } from '@authorizerdev/authorizer-js';

const authRef = new Authorizer({
  authorizerURL: 'https://your-instance.example.com',
  redirectURL: window.location.origin,
  clientID: 'YOUR_CLIENT_ID',
  // optional — 'graphql' (default) or 'rest'
  protocol: 'graphql',
});

| Key | Required | Description | | --------------- | -------- | --------------------------------------------------------- | | authorizerURL | Yes | Base URL of your Authorizer instance | | redirectURL | Yes | URL to redirect to after a successful login | | clientID | Yes | Client ID from the Authorizer dashboard | | protocol | No | Transport protocol: 'graphql' (default) or 'rest' |

The protocol option controls which transport the SDK uses. 'graphql' sends requests to the /graphql endpoint; 'rest' uses the REST API (/api/*). Both expose the same feature set.


Install

npm / yarn

npm i --save @authorizerdev/authorizer-js
# or
yarn add @authorizerdev/authorizer-js

CDN (IIFE / UMD)

<script src="https://unpkg.com/@authorizerdev/[email protected]/lib/authorizer.min.js"></script>

CommonJS

const { Authorizer } = require('@authorizerdev/authorizer-js');

const authRef = new Authorizer({
  authorizerURL: 'https://your-instance.example.com',
  redirectURL: 'https://your-app.example.com',
  clientID: 'YOUR_CLIENT_ID',
});

async function main() {
  const { data, errors } = await authRef.login({
    email: '[email protected]',
    password: 'Abc@123',
  });
  if (errors.length) console.error(errors);
  else console.log(data.access_token);
}

ES Modules

import { Authorizer } from '@authorizerdev/authorizer-js';

const authRef = new Authorizer({
  authorizerURL: 'https://your-instance.example.com',
  redirectURL: 'https://your-app.example.com',
  clientID: 'YOUR_CLIENT_ID',
});

async function main() {
  const { data, errors } = await authRef.login({
    email: '[email protected]',
    password: 'Abc@123',
  });
}

IIFE (Browser)

<script src="https://unpkg.com/@authorizerdev/[email protected]/lib/authorizer.min.js"></script>
<script type="text/javascript">
  const authorizerRef = new authorizerdev.Authorizer({
    authorizerURL: 'AUTHORIZER_URL',
    redirectURL: window.location.origin,
    clientID: 'YOUR_CLIENT_ID',
  });

  async function onLoad() {
    const { data, errors } = await authorizerRef.authorize({
      response_type: 'code',
      use_refresh_token: false,
    });
    if (data && data.access_token) {
      const { data: user } = await authorizerRef.getProfile({
        Authorization: `Bearer ${data.access_token}`,
      });
      console.log(user.email);
    }
  }
  onLoad();
</script>

Fine-grained authorization (FGA)

Authorizer ships an embedded OpenFGA engine for relationship-based access control (ReBAC). You model your domain as object types with relations (viewer, editor, owner…), grant access by writing relationship tuples (user:alice is viewer of document:1), and ask the engine whether access is allowed.

Authoring the model and tuples is an admin task — do it once in the dashboard under Authorization, or via the _fga_* admin GraphQL API. The SDK exposes only the read-side checks an application needs at request time. For every call the subject defaults to the authenticated caller and is pinned server-side from the request (session cookie by default; pass the authorization header in Node.js). The optional user field ("type:id", or a bare id treated as "user:<id>") lets you check on behalf of someone else, but the server honors it only for super-admin callers or when it equals the caller's own token subject.

Check permissions — answers "does the subject have relation on object?" for one or more pairs in a single round trip.

const { data } = await authRef.checkPermissions(
  { checks: [{ relation: 'can_view', object: 'document:1' }] },
  { Authorization: `Bearer ${token}` }, // omit in the browser to use the cookie
);

if (data?.results?.[0]?.allowed) {
  // caller may view document:1
}

Batch several checks at once:

const { data } = await authRef.checkPermissions({
  checks: [
    { relation: 'can_view', object: 'document:1' },
    { relation: 'can_edit', object: 'document:1' },
  ],
});
// data?.results =>
//   [
//     { relation: 'can_view', object: 'document:1', allowed: true },
//     { relation: 'can_edit', object: 'document:1', allowed: false },
//   ]

List accessible objects — returns the ids of every object of a type the subject relates to.

const { data } = await authRef.listPermissions({
  relation: 'can_view',
  object_type: 'document',
});
// data?.objects => ['document:1', 'document:7', ...]

Local Development

Prerequisites

Setup

git clone https://github.com/authorizerdev/authorizer-js
cd authorizer-js
pnpm install
pnpm build
pnpm test

Release

  1. Bump the version in package.json.
  2. Tag the commit: git tag v<version>
  3. Push with tags: git push origin main --tags

The GitHub Actions release workflow handles npm publish and GitHub Release creation automatically.