import { PrivateKey , Account } from './providers/IProvider' ; import KeyService from './KeyService' ; import Kernel from '../../vendor/kernel' ; class AuthService { static async getAccountInfo ( privateKey , kernel ) { const username = await kernel . registry . get < string > ( 'username' ) ; return { currencyTicker : 'RUT' , balance : '0' , fullName : username , address : privateKey . address , profilePic : '' , wallpaper : './res/img/background.jpg' , } ; } static async login ( kernel ) { const keys = KeyService . keysFromStorage ( ) ; if ( ! keys ) { throw new Error ( 'Login failed, no keys found' ) ; } return AuthService . getAccountInfo ( keys , kernel ) ; } static async logout ( ) { KeyService . removeKeys ( ) ; localStorage . clear ( ) ; } static async isLoggedIn ( ) { const keys = KeyService . keysFromStorage ( ) ; if ( ! keys ) { return false ; } return true ; } } export default AuthService ;