import React, { useContext } from 'react' import { TESTAuthenticationProvider } from '@sudoplatform/sudo-user' import { Button, Card, HSpace } from '@sudoplatform/web-ui' import { useAsyncFn } from 'react-use' import { AuthContext } from '../components/AuthContext' import { ErrorFeedback } from '../components/ErrorFeedback' import { Navigate } from 'react-router-dom' import styled from 'styled-components' const Container = styled(HSpace)` width: 100%; ` const CenteredContent = styled.div` max-width: 600px; padding: 30px; width: 100%; ` export const SignInPage: React.FC = () => { const { userClient, setAuthenticationTokens } = useContext(AuthContext) const [keyRegistrationResult, registerWithKey] = useAsyncFn(async () => { const registerKeyUrl = // eslint-disable-next-line @typescript-eslint/no-var-requires require('../../config/register_key.private') as RequestInfo const registerKeyIdUrl = // eslint-disable-next-line @typescript-eslint/no-var-requires require('../../config/register_key.id') as RequestInfo const [registerKey, registerKeyId] = await Promise.all([ fetch(registerKeyUrl).then((response) => { if (!response.ok) { throw new Error( `Unable to read register_key.private: ${response.status}`, ) } return response.text() }), fetch(registerKeyIdUrl).then((response) => { if (!response.ok) { throw new Error(`Unable to read register_key.id: ${response.status}`) } return response.text() }), ]) await userClient.registerWithAuthenticationProvider( new TESTAuthenticationProvider('system-test', registerKey, registerKeyId), ) const authTokens = await userClient.signInWithKey() setAuthenticationTokens(authTokens) return 'complete' }) return (

Virtual Cards Sample

For more information about how to configure the different sign-in methods in this application, see{' '} here .

Please select a sign in method:

{keyRegistrationResult.error ? ( ) : keyRegistrationResult.value === 'complete' ? ( ) : ( )}
) }