UNPKG

ya-express-ntlm

Version:
23 lines 751 B
class UserAuthDelayCache { constructor() { // timestamp of the next available authentication challenge this.cache = {}; } set(userData, rsn) { this.cache[`${userData.domain}\${${userData.username}}`] = Date.now() + rsn.options.getAuthDelay(rsn); } // Number of seconds until next login attempt get(userData) { const id = `${userData.domain}\${${userData.username}}`; let n = this.cache[id] || 0; if (n) { n = Math.floor(Math.max(0, (n - Date.now()) / 1000)); } if (!n) { delete this.cache[id]; } return n; } } export const userAuthDelayCache = new UserAuthDelayCache(); //# sourceMappingURL=user-auth-delay-cache.js.map