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:
-
Install the library
npm i -S @guestlinelabs/react-auth
-
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
- Use the hooks from within your code
const tokenResult = useTokens();
const userInfoResult = useUserInfo();
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
npm login
use your username from npm.js, you need to be part of guestlinelabs organisationnpm install
npm publish