New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@i-360/auth-ui

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@i-360/auth-ui

i360 Auth UI

  • 0.1.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
0
Weekly downloads
 
Created
Source

i360 Auth UI

Package for authenticating a user using their Koch ID

Setup

  • Clone this repo locally => git clone git@gitlab.com: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()

FAQs

Package last updated on 06 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc