web-gatekeeper-js 1.2.0 → 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-gatekeeper-js",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Redis based rate limiter and throttler using sliding window and token bucket algorithms",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -73,10 +73,10 @@ if (maxToken <= 0) {
73
73
  const result = await this.#store.evalScript(
74
74
  slidingWindowScript,
75
75
  key,
76
- this.#windowSize,
77
- this.#limit,
78
- now,
79
- ttl,
76
+ Math.floor(this.#windowSize),
77
+ Math.floor(this.#limit),
78
+ Math.floor(now),
79
+ Math.floor(ttl),
80
80
  );
81
81
 
82
82
  return {
@@ -101,10 +101,10 @@ if (maxToken <= 0) {
101
101
  const result = await this.#store.evalScript(
102
102
  tokenBucketScript,
103
103
  key,
104
- now,
105
- this.#maxToken,
104
+ Math.floor(now),
105
+ Math.floor(this.#maxToken),
106
106
  this.#refillRate,
107
- ttl,
107
+ Math.floor(ttl),
108
108
  );
109
109
 
110
110
  return {
package/src/Throttler.js CHANGED
@@ -26,10 +26,10 @@ export class Throttler {
26
26
  const result = await this.#store.evalScript(
27
27
  throttlerScript,
28
28
  key,
29
- now,
29
+ Math.floor(now),
30
30
  this.#refillRate,
31
- this.#maxWait,
32
- ttl
31
+ Math.floor(this.#maxWait),
32
+ Math.floor(ttl)
33
33
  )
34
34
 
35
35
  const allowed = result[0] === 1