UNPKG

onairos

Version:

The Onairos Library is a collection of functions that enable Applications to connect and communicate data with Onairos Identities via User Authorization. Integration for developers is seamless, simple and effective for all applications. LLM SDK capabiliti

48 lines (41 loc) 1.45 kB
import { useState, useEffect } from 'react'; import OnairosAppButton from './OnairosAppButton.jsx'; // import GoogleButton from './GoogleButton'; import TestTelegramButton from './TestTelegramButton.js'; export default function AuthButtons({ onLoginSuccess, setOthent, setHashedOthentSub, setEncryptedPin }) { const [hasSavedCredentials, setHasSavedCredentials] = useState(false); useEffect(() => { checkSavedCredentials(); }, []); const checkSavedCredentials = async () => { const credentials = localStorage.getItem('onairosCredentials'); setHasSavedCredentials(!!credentials); }; const handleOthentSuccess = async (othentData) => { // Set Othent-specific state setOthent(true); setHashedOthentSub(othentData.hashedOthentSub); setEncryptedPin(othentData.encryptedPin); // Call general login success handler await onLoginSuccess(othentData.userDetails); }; const othentLogin = async (data) =>{ onLoginSuccess(data,true); } return ( <div className="flex flex-row justify-center items-center space-x-4"> {/* <OthentButton onSuccess={handleOthentSuccess} onLoginSuccess={othentLogin}/> */} {/* <GoogleButton onLoginSuccess={othentLogin}/> */} <TestTelegramButton /> <OnairosAppButton hasSavedCredentials={hasSavedCredentials} onSuccess={onLoginSuccess} /> </div> ); }