const blacklist = new Map();
const EXPIRATION_TIME = 24 * 60 * 60 * 1000; // 24 Stunden in Millisekunden

function cleanupBlacklist() {
    const now = Date.now();
    for (const [token, timestamp] of blacklist) {
        if (now - timestamp > EXPIRATION_TIME) {
            blacklist.delete(token);
        }
    }
}

function addTokenToBlacklist(token) {
    cleanupBlacklist(); // Bereinige alte Einträge
    blacklist.set(token, Date.now());
}

function isTokenBlacklisted(token) {
    cleanupBlacklist(); // Bereinige alte Einträge
    return blacklist.has(token);
}

module.exports = {
    addTokenToBlacklist,
    isTokenBlacklisted,
};
