@vatom/identity-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.0.17 • Public • Published

Vatom™ Identity SDK

This library allows you to embed and use the Vatom™ Identity system to authenticate your users within your web app.

Installation

You can install this library by running npm install @vatom/identity-sdk or yarn add @vatom/identity-sdk

Basic Usage

In order to seamlessly integrate with your own identity system you would need to first obtain an authority and clientId. For more information about this please contact us at support@vatom.com.

Full parameter list

VatomIdentitySDK

Parameter Description Default Value
clientId Required. Client ID used to identify your app. ""
sdkConfig Optional. SDK Configs { loginCallbackUri: '/callback', logoutCallbackUri: '/logout-callback', authority: 'https://id.vatom.com', businessId: '' }

VatomIdentitySDK Methods

Name Description Response
getAccessToken Retrieve your access token {"access_token":"xxx","expires_in":3600,"id_token":"xxx","refresh_token":"xxx","scope":"xxx","token_type":"xxx"}
login Triggers the login process
logout Triggers the logout process
onCallbacks Grants the tokens or remove the tokens. This method should be inside the callbacks components returns "true" if function was triggered in the callbacks otherwise "false"

Example Code using React

import './App.css';
import { useEffect } from 'react';
import { VatomIdentitySDK } from "@vatom/identity-sdk"

function App() {
  const clientId = "identity-sdk-test"
  const sdkConfig = {}
  const identitySdk = new VatomIdentitySDK(clientId, sdkConfig)
  const [accessToken, setAccessToken] = useState(identitySdk.getAccessToken())

  useEffect(() => {
    const triggerCallback = async () => {
      // Put this inside your callback components
      const res = await identitySdk.onCallbacks()
      if (res) {
        setAccessToken(identitySdk.getAccessToken())
      }
    }
    triggerCallback()
  }, [])

  return (
    <div className="App">
      {!accessToken ? (
        <button onClick={identitySdk.login}>Login</button>
      ) : (
        <span>Logged In: </span>
      )}
      {accessToken && <button onClick={identitySdk.logout}>Logout</button>}
    </div>
  )
}

export default App;

Readme

Keywords

none

Package Sidebar

Install

npm i @vatom/identity-sdk

Weekly Downloads

2

Version

0.0.17

License

none

Unpacked Size

33.5 kB

Total Files

8

Last publish

Collaborators

  • funnyenough
  • andrew_rothman
  • afarqu
  • anfernyy
  • varius-ci