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

@guestlinelabs/react-auth

Package Overview
Dependencies
Maintainers
8
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@guestlinelabs/react-auth

TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.

  • 2.0.2
  • npm
  • Socket score

Version published
Weekly downloads
526
increased by17.94%
Maintainers
8
Weekly downloads
 
Created
Source

Introduction

This library wraps the interface provided by token-manager and exposed on window. It allows for a seemless integration with react.

How to use it?

There is a step-by-step tutorial on setting up OC component with this library here: https://dev.azure.com/guestlinelabs/Sugoi/_git/hello-oc-sso?path=%2FREADME.md&_a=preview Short documentation follows:

  1. Install the library npm i -S @guestlinelabs/react-auth

  2. Import hooks exposed by the library import { useTokens, useUserInfo } from "@guestlinelabs/react-auth";

If you're not using hooks you can use higher order components withTokens and withUserInfo that are also imported from @guestlinelabs/react-auth

  1. Use the hooks from within your code
// use useTokens hook when you need to authenticate with external api
const tokenResult = useTokens();
/*
tokenResult.loading - true when tokens are not yet available, wait for tokens to be provided
tokenResult.error - not null when an error happened when fetching tokens, wait for the library to resolve the error
tokenResult.idToken - this is what you want to use most of the time, JWT token signed by Auth0 with all bells and whistles
tokenResult.accessToken - this token can be used for calling /userinfo endpoint on auth0
*/

// use useUserInfo hook when you need information about the user like their email or permissions
const userInfoResult = useUserInfo();
/*
userInfoResult.loading - true when user info is not yet available, wait for it to be provided
userInfoResult.error - not null when an error happened, wait for library to resolve the error
userInfoResult.userInfo - object containing information about the user like family_name, or an email
*/

If you're not using hooks wrap your component with withTokens or withUserInfo before exporting. These functions will inject into your component props the same properties as the hooks

Contributing

Build and Test

Before working with this library run npm i. To build it run npm run build. To run tests use npm test command.

How to publish new version

From react-auth folder

  1. npm login use your username from npm.js, you need to be part of guestlinelabs organisation
  2. npm install
  3. npm publish

FAQs

Package last updated on 22 Oct 2020

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