0.0.15 • Published 8 months ago

@vatom/identity-sdk v0.0.15

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

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

NameDescriptionResponse
getAccessTokenRetrieve your access token{"access_token":"xxx","expires_in":3600,"id_token":"xxx","refresh_token":"xxx","scope":"xxx","token_type":"xxx"}
loginTriggers the login process
logoutTriggers the logout process
onCallbacksGrants the tokens or remove the tokens. This method should be inside the callbacks componentsreturns "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;
0.0.10

10 months ago

0.0.11

10 months ago

0.0.12

10 months ago

0.0.13

9 months ago

0.0.14

9 months ago

0.0.15

8 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

1 year ago