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

passport-okta-oauth20

v1.1.0

Published

An Okta OAuth 2.0 Strategy for Passport with native TypeScript support

Downloads

5,207

Readme

passport-okta-oauth20

GitHub package.json version Licence Code Quality Maintenance

Okta OAuth 2.0 provider for Passport with TypeScript support.

Installation

npm i passport-okta-oauth20 or yarn add passport-okta-oauth20.

Usage

import { Strategy as OktaStrategy } from 'passport-okta-oauth20';

passport.use(
  new OktaStrategy(
    {
      audience: 'https://acme.okta.com',
      clientID: 'oa6qp1vkvrgwABC12345',
      clientSecret: 'qwertyA-fooBazB_DQSS-qqsQSD123',
      scope: ['openid', 'email', 'profile'],
      callbackURL: 'http://localhost:3000/api/auth/okta/callback',
    },
    function (accessToken, refreshToken, profile, done) {
      // Do something with the profile
      return done(null, profile);
    }
  )
);

Custom Authorisation Server

You can also specify the property authorizationId to turn the authorizationURL from https://acme.okta.com/oauth2/v1/authorize to https://acme.okta.com/oauth2/foobar/v1/authorize if:

  • authorizationId is foobar, and
  • audience is https://acme.okta.com

This is optional.

Profile

{
  id: 'azerty12345890',
  displayName: 'Adam Smith',
  username: '[email protected]',
  fullName: 'Adam Smith',
  familyName: 'Smith',
  givenName: 'Adam',
  email: '[email protected]',
  zoneInfo: 'America/Los_Angeles',
  updatedAt: 1625319840,
  emailVerified: true,
  locale: 'en-US',
  _raw: '{"sub":"azerty12345890", ...',
  _json: Object // Raw response from Okta
}

TypeScript

If you are using TypeScript, you can import the following types:

import { OktaProfile, OktaStrategyOptions } from 'passport-okta-oauth20'

Change Log

Version 1.1.0

  • Adding an optional parameter, authorizationId, to use a custom authorisation server. 👏 Thanks @fpunny for the PR (#6).
  • ⏫ Upgrading dependencies

Version 1.0.1

  • Testing on Node 12, 14 and 16
  • Replace .npmignore by a whitelist (files) in package.json
  • Restrict to Node >= 12 (but will probably work with older version.)
  • Testing both the original TypeScript code and the transpiled JS code

Version 1.0.0

  • Functional parity with passport-okta-oauth
  • Full TypeScript support
  • Simplified logic and up-to-date dependencies
  • Very lightweight NPM package (6.2 kB)
  • Test coverage
  • Linting

Prior art

This repository is loosely based on passport-okta-oauth.

That repository was archived a while ago, and this rewrite brings the following changes:

  • Full native TypeScript support
  • Simplified logic
  • Using node-fetch for fetching the profile instead of a private function from oauth.
  • Update to the user profile (Okta added new fields that were not present in the original library)
  • Unit testing
  • Linting
  • CI