@adminforth/two-factors-auth 7.4.0 → 7.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,8 +21,8 @@ export class TotpService {
21
21
  this.options = options;
22
22
  this.userRepository = userRepository;
23
23
  this.adminforth = adminforth;
24
- this.codeAttemptLimiters = ((_a = this.options.totpRateLimit) !== null && _a !== void 0 ? _a : DEFAULT_TOTP_RATE_LIMIT).map((rate) => new RateLimiter(rate));
25
24
  this.lastUsedCodeSteps = new Map();
25
+ this.codeAttemptLimiters = ((_a = options.totpRateLimit) !== null && _a !== void 0 ? _a : DEFAULT_TOTP_RATE_LIMIT).map((rate) => new RateLimiter(rate));
26
26
  }
27
27
  generateSecret(issuerName, userName) {
28
28
  return twofactor.generateSecret({ name: issuerName, account: userName }).secret;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "7.4.0",
3
+ "version": "7.4.1",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,14 +12,16 @@ const TOTP_STEP_SECONDS = 30;
12
12
  const RATE_LIMITED_ERROR = "Too many attempts to enter the code. Try again later.";
13
13
 
14
14
  export class TotpService {
15
- private readonly codeAttemptLimiters = (this.options.totpRateLimit ?? DEFAULT_TOTP_RATE_LIMIT).map((rate) => new RateLimiter(rate));
15
+ private readonly codeAttemptLimiters: RateLimiter[];
16
16
  private readonly lastUsedCodeSteps = new Map<string, number>();
17
17
 
18
18
  constructor(
19
19
  private readonly options: PluginOptions,
20
20
  private readonly userRepository: UserRepository,
21
21
  private readonly adminforth: IAdminForth,
22
- ) {}
22
+ ) {
23
+ this.codeAttemptLimiters = (options.totpRateLimit ?? DEFAULT_TOTP_RATE_LIMIT).map((rate) => new RateLimiter(rate));
24
+ }
23
25
 
24
26
  public generateSecret(issuerName: string, userName: string): string {
25
27
  return twofactor.generateSecret({ name: issuerName, account: userName }).secret;