UNPKG

authkit-js

Version:

Express auth toolkit (JWT, Sessions with Redis, Google/GitHub OAuth) in JavaScript

26 lines (15 loc) 520 B
class MemoryRefreshStore { constructor() { this.map = new Map(); } async get(userId) { const e = this.map.get(userId); if (!e) return null; if (e.expiresAt && Date.now() > e.expiresAt) { this.map.delete(userId); return null; } return e.token; } async set(userId, token, ttlSec) { const expiresAt = ttlSec ? (Date.now() + ttlSec * 1000) : undefined; this.map.set(userId, { token, expiresAt }); } async del(userId) { this.map.delete(userId); } } module.exports = { MemoryRefreshStore };