Core
Import the following dependency in your file, here you will use these function.
import {
isAuthenticated,
isAuthenticationExpired,
generatePayload,
authenticate,
initAuthentication,
clearAuthentication
} from 'TruVideoReactCoreSdk';import {
isAuthenticated,
isAuthenticationExpired,
generatePayload,
authenticate,
initAuthentication,
clearAuthentication
} from '@trunpm/truvideo-react-turbo-core-sdk';Authentication Status
The Truvideo SDK provides two properties that serve to check the authentication status:
isAuthenticated(): Returns true or false indicating whether the client is authenticated. Please note that authentication may be expired.isAuthenticationExpired(): Return true or false indicating whether the authentication is expired. If the client is not authenticated, it always returns false.
const isAuth = await isAuthenticated();
const isAuthExpired = await isAuthenticationExpired();How to authenticate
The authenticate method requires the following inputs:
ApiKey: A string provided by Truvideo upon registration.
Payload: Essential data containing device information, generated internally using the
generatePayload()function.Signature: Encrypt the payload with the provided secret key using the SHA256 algorithm to regenerate the signature.
Upon completion, it triggers the onReady callback or the onError callback in case of an error.
Algorithm for encoding the signature
The encoding algorithm operates by taking the secret key and payload as inputs, generating an encoded string suitable for authentication purposes.
Clear Authentication
To delete the current session and erase all associated authentication data, utilize the clearAuthentication() method
Last updated
Was this helpful?