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

@i-360/auth-ui

v0.1.2

Published

i360 Auth UI

Downloads

5

Readme

i360 Auth UI

Package for authenticating a user using their Koch ID

Setup

  • Clone this repo locally => git clone [email protected]:i-360/dataops/auth-ui.git
  • Install dependencies => pnpm install (from repo root directory)
  • Run the example app => pnpm example

Use

The package is published to the NPM registry and can be installed with your preferred package manager:

  • NPM => npm i @i-360/auth-ui
  • Yarn => yarn add @i-360/auth-ui
  • PNPM => pnpm add @i-360/auth-ui

AuthService

After installing, import the Auth class into the application and initialize it. Then call the login method.

  • user<Object|undefined> => The user object or undefined when not logged in (getter only, can not be set)
  • token<string|undefined> => The users token or undefined when not logged in (getter only, can not be set)
  • login<function> => Start the login flow for the user
  • logout<function> => Log a user out of the application
  • status<function> => Check the login status of the User
  • expired<function> => Validate if the user token is expired
  • onToken<function> => Should be called with the idToken from within the pop-window when redirected
  • decode<function> => Helper for decoding JWT tokens (Not commonly used)

Example


// Initialize the Auth class
const auth = new Auth({
  // URL used to login the user
  loginUrl: `https://example.i-360.com/kochid/login`,

  // URL used to logout the user
  logoutUrl: `https://example.i-360.com/kochid/logout`,

  // URL to redirect to once authenticated
  redirectUri: `my-application.com`,

  // Login callback called when the user is logged in
  onLogin: (user, token) => { /* Handle user and token */ },

  // Error callback called when the there is an error during authentication
  onError: (error) => { /* Handle authentication error */ },

  // Logout callback called when the user is logged out
  onLogout: () => { /* Handle User logout */ },
})

// Call the login method to log the user into the application
// Calls the passed in `onLogin` callback after logging in the user
await auth.login()

// Get the current user or token, both are undefined if not logged in
const user = auth.user
const token = auth.token

// Setting the user or token manually will NOT work. A warning will be printed to the console
auth.user = {}
auth.token = `custom-token`

// Check if the token is expired, returned false if no user or token, or the token is expired
const isExpired = auth.expired()


// Call the logout method to log the user out of the application
// Calls the passed in `onLogout` callback after logging out the user
auth.logout()