import { Either , right , left } from '@/shared' ; import { Payload , TokenManager } from '@/use-cases/authentication/ports' ; export class FakeTokenManager implements TokenManager { async sign ( info ) { return info . id + 'token' ; } async verify ( token ) { if ( token . endsWith ( 'token' ) ) { return right ( { id : token . substring ( 0 , token . indexOf ( 'token' ) ) } ) ; } return left ( new Error ( 'Invalid token.' ) ) ; } }