@netappsng/react-netapps-sso
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

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:

yarn add @netappsng/react-netapps-sso

or

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

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @netappsng/react-netapps-sso

Weekly Downloads

0

Version

1.0.10

License

MIT

Unpacked Size

23.7 kB

Total Files

12

Last publish

Collaborators

  • talktothelaw
  • jerrywap