ya-express-ntlm
Version:
26 lines • 860 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.userAuthDelayCache = void 0;
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;
}
}
exports.userAuthDelayCache = new UserAuthDelayCache();
//# sourceMappingURL=user-auth-delay-cache.js.map