import './style.css' ; import { getIsAuthenticationFailure , getUser } from './auth' ; import { initSwagger } from './swagger' ; import Auth from '@aws-amplify/auth' ; getUser ( ) . then ( user => { if ( ! user ) { throw new Error ( 'User not resolved' ) ; } const email = user . getSignInUserSession ( ) ?. getIdToken ( ) . payload . email ; document . getElementById ( 'username' ) ! . innerText = email ; document . getElementById ( 'logout' ) ! . addEventListener ( 'click' , ( ) => { Auth . signOut ( ) ; } ) ; } ) . catch ( ( ) => { if ( ! getIsAuthenticationFailure ( ) ) { Auth . federatedSignIn ( ) ; } } ) ; initSwagger ( ) . catch ( e => console . error ( 'Swagger init error:' , e ) ) ;