npm package: @netappsng/react-netapps-sso
Description: Add netapps auth to your react based product
Author: Lawrence Nwoko
Latest version: 1.0.10

# Using @netappsng/react-netapps-sso

`@netappsng/react-netapps-sso` is a React library for integrating with NetApp SSO. This document will guide you through the installation and usage of the library.

## Installation

To install the library, run the following command in your terminal:

```sh
yarn add @netappsng/react-netapps-sso
```
or
```sh
npm install @netappsng/react-netapps-sso
```

### Usage

To use the library, import `useNetAppsSso` from the package and use it in your React component.


| Option                           | Default Value | Description                                                                                                                                |
|----------------------------------|-------|--------------------------------------------------------------------------------------------------------------------------------------------|
| displayInAuthError               | true  | If set to true, error messages will be displayed on the authentication modal.                                                              |
| displayLoginButtonOnVerification | false | If set to true, a login button will be displayed on the reset password and phone number verification screens.                              |
| onReady                          | null  | This callback function is called when the authentication modal is ready.                                                                   |
| close                            | null  | This is use to close the auth modal.                                                                                                       |
| onSuccessful                     | null  | This callback function is called when authentication is successful. The error parameter will contain any error messages if there were any. |
| onFailed                         | null  | This callback function is called when authentication fails. The success parameter will contain any success messages if there were any.     |



Here is full example

```javascript
import React from "react";
import { useNetAppsSso } from "@netappsng/react-netapps-sso";

const App = () => {
  const { initAuth, acceptInvite, isReady, close } = useNetAppsSso({
    publicKey: "NA_PUB_TEST-03e37a6509fdc66d478fbaa8926a3170",
    onError: (res: any) => console.log({ res }),
    onSuccess: (res: any) => console.log({ res })
  });

  const handleAuth = () => {
    if(!isReady) return alert('Gateway not ready')
    initAuth({
      displayInAuthError: false,
      displayLoginButtonOnVerification: false
    });
  };

  const handleInvite = () => {
    if(!isReady) return alert('Gateway not ready')
    acceptInvite({
      displayInAuthError: false,
      displayLoginButtonOnVerification: false,
      token: "invite token"
    });
  };

  useEffect(()=>{
    setTimeout(()=>{
      console.log('Test close');
      close()
    }, 6000)
  },[])

  return (
    <>
      <button style={{height:100}} onClick={handleAuth}>Test Auth</button>
      <button style={{height:100}} onClick={handleInvite}>Test Invite</button>
    </>
  );
};

export default App;
```

useNetAppsSso Hook

The useNetAppsSso hook returns an object with the following properties:

initAuth(options: Object): Function that initializes the authentication flow with NetApp SSO.