import { ICache , IAuth , IAuthManager } from "../internal" ; export class SessionAuth implements IAuthManager { constructor ( public cache ) { } param id param token param data public async sign < T > ( id , data ? ) { const token = Math . random ( ) . toString ( 36 ) . slice ( 3 ) ; const session = { id , token , data } ; await this . cache . set ( id , session ) ; return session ; } public async verify ( token ) { const session = await this . cache . findOne ( { token } ) ; return session || null ; } }