@voltro/plugin-ratelimit 0.83.1 → 0.85.0
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/CHANGELOG.md +1191 -0
- package/THIRD-PARTY-NOTICES.md +1 -57
- package/dist/errors.d.ts +8 -9
- package/dist/index.d.ts +8 -9
- package/dist/index.js +3 -3
- package/dist/{postgresStore-CDP61pxx.js → postgresStore-D_oHSGXq.js} +1 -1
- package/dist/postgresStore.js +1 -1
- package/dist/redisStore.js +1 -1
- package/package.json +6 -9
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -5,66 +5,10 @@ property of its respective copyright holders and is used under the terms of
|
|
|
5
5
|
its license. This file is provided for attribution; it grants no rights in
|
|
6
6
|
@voltro/plugin-ratelimit itself, which is proprietary (see LICENSE).
|
|
7
7
|
|
|
8
|
-
Generated from the resolved runtime dependency closure (
|
|
8
|
+
Generated from the resolved runtime dependency closure (16 packages).
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
## @effect/experimental@0.61.1
|
|
13
|
-
|
|
14
|
-
License: MIT
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
MIT License
|
|
18
|
-
|
|
19
|
-
Copyright (c) 2023-present The Contributors
|
|
20
|
-
|
|
21
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
22
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
23
|
-
in the Software without restriction, including without limitation the rights
|
|
24
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
25
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
26
|
-
furnished to do so, subject to the following conditions:
|
|
27
|
-
|
|
28
|
-
The above copyright notice and this permission notice shall be included in all
|
|
29
|
-
copies or substantial portions of the Software.
|
|
30
|
-
|
|
31
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
32
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
33
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
34
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
35
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
36
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
|
-
SOFTWARE.
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## @effect/sql@0.52.1
|
|
41
|
-
|
|
42
|
-
License: MIT
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
MIT License
|
|
46
|
-
|
|
47
|
-
Copyright (c) 2023-present The Contributors
|
|
48
|
-
|
|
49
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
50
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
51
|
-
in the Software without restriction, including without limitation the rights
|
|
52
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
53
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
54
|
-
furnished to do so, subject to the following conditions:
|
|
55
|
-
|
|
56
|
-
The above copyright notice and this permission notice shall be included in all
|
|
57
|
-
copies or substantial portions of the Software.
|
|
58
|
-
|
|
59
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
60
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
61
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
62
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
63
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
64
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
65
|
-
SOFTWARE.
|
|
66
|
-
```
|
|
67
|
-
|
|
68
12
|
## @ioredis/commands@1.10.0
|
|
69
13
|
|
|
70
14
|
License: MIT
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
+
import { YieldableError } from 'effect/Cause';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Raised on the RPC error channel when a call exceeds its limit. The
|
|
@@ -18,19 +19,17 @@ import { Schema } from 'effect';
|
|
|
18
19
|
export declare class RateLimited extends RateLimited_base {
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
declare const RateLimited_base: Schema.
|
|
22
|
-
readonly _tag: Schema.tag<"RateLimited">;
|
|
23
|
-
} & {
|
|
22
|
+
declare const RateLimited_base: Schema.Class<RateLimited, Schema.TaggedStruct<"RateLimited", {
|
|
24
23
|
/** The rpc tag that was limited, e.g. `'todos.create'`. */
|
|
25
|
-
tag:
|
|
24
|
+
readonly tag: Schema.String;
|
|
26
25
|
/** The effective limit that was hit. */
|
|
27
|
-
limit:
|
|
26
|
+
readonly limit: Schema.Number;
|
|
28
27
|
/** The window the limit applies over, in ms. */
|
|
29
|
-
windowMs:
|
|
28
|
+
readonly windowMs: Schema.Number;
|
|
30
29
|
/** Suggested wait before retrying, in ms. */
|
|
31
|
-
retryAfterMs:
|
|
30
|
+
readonly retryAfterMs: Schema.Number;
|
|
32
31
|
/** Epoch-ms when the bucket is expected to be replenished. */
|
|
33
|
-
resetAtMs:
|
|
34
|
-
}>;
|
|
32
|
+
readonly resetAtMs: Schema.Number;
|
|
33
|
+
}>, YieldableError>;
|
|
35
34
|
|
|
36
35
|
export { }
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Schema } from 'effect';
|
|
|
8
8
|
import { Subject } from '@voltro/protocol';
|
|
9
9
|
import { Table } from '@voltro/database';
|
|
10
10
|
import { VoltroPlugin } from '@voltro/protocol';
|
|
11
|
+
import { YieldableError } from 'effect/Cause';
|
|
11
12
|
|
|
12
13
|
export declare type Algorithm = 'fixed-window' | 'sliding-window' | 'token-bucket';
|
|
13
14
|
|
|
@@ -146,20 +147,18 @@ export declare interface RateLimitDecision {
|
|
|
146
147
|
export declare class RateLimited extends RateLimited_base {
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
declare const RateLimited_base: Schema.
|
|
150
|
-
readonly _tag: Schema.tag<"RateLimited">;
|
|
151
|
-
} & {
|
|
150
|
+
declare const RateLimited_base: Schema.Class<RateLimited, Schema.TaggedStruct<"RateLimited", {
|
|
152
151
|
/** The rpc tag that was limited, e.g. `'todos.create'`. */
|
|
153
|
-
tag:
|
|
152
|
+
readonly tag: Schema.String;
|
|
154
153
|
/** The effective limit that was hit. */
|
|
155
|
-
limit:
|
|
154
|
+
readonly limit: Schema.Number;
|
|
156
155
|
/** The window the limit applies over, in ms. */
|
|
157
|
-
windowMs:
|
|
156
|
+
readonly windowMs: Schema.Number;
|
|
158
157
|
/** Suggested wait before retrying, in ms. */
|
|
159
|
-
retryAfterMs:
|
|
158
|
+
readonly retryAfterMs: Schema.Number;
|
|
160
159
|
/** Epoch-ms when the bucket is expected to be replenished. */
|
|
161
|
-
resetAtMs:
|
|
162
|
-
}>;
|
|
160
|
+
readonly resetAtMs: Schema.Number;
|
|
161
|
+
}>, YieldableError>;
|
|
163
162
|
|
|
164
163
|
export declare const rateLimitPlugin: (options?: RateLimitPluginOptions) => VoltroPlugin;
|
|
165
164
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RateLimited as e } from "./errors.js";
|
|
2
|
-
import { a as t, i as n, n as r, r as i, t as a } from "./postgresStore-
|
|
2
|
+
import { a as t, i as n, n as r, r as i, t as a } from "./postgresStore-D_oHSGXq.js";
|
|
3
3
|
import { redisStore as o } from "./redisStore.js";
|
|
4
4
|
import { Effect as s } from "effect";
|
|
5
5
|
import { createLogger as c } from "@voltro/logger";
|
|
@@ -217,13 +217,13 @@ var f = (e) => typeof e == "function" ? "dynamic" : e, p = (e) => typeof e == "f
|
|
|
217
217
|
return h(i, l).pipe(s.flatMap((n) => {
|
|
218
218
|
if (n === "exempt") return f.bypass(), t;
|
|
219
219
|
let r = k(o, i);
|
|
220
|
-
return c.consume(r, n, Date.now()).pipe(s.
|
|
220
|
+
return c.consume(r, n, Date.now()).pipe(s.catchDefect((e) => s.as(s.logWarning(`[ratelimit] store error — failing open for ${i.tag}: ${String(e)}`), {
|
|
221
221
|
allowed: !0,
|
|
222
222
|
failOpenReason: "store-error",
|
|
223
223
|
remaining: n.limit,
|
|
224
224
|
resetAtMs: Date.now(),
|
|
225
225
|
retryAfterMs: 0
|
|
226
|
-
})), s.tap((e) => s.sync(() => f.record("rpc", e))), s.flatMap((a) => a.allowed ? t : s.
|
|
226
|
+
})), s.tap((e) => s.sync(() => f.record("rpc", e))), s.flatMap((a) => a.allowed ? t : s.andThen(s.sync(() => m(i, r, n, a)), s.fail(new e({
|
|
227
227
|
tag: i.tag,
|
|
228
228
|
limit: n.limit,
|
|
229
229
|
windowMs: n.windowMs,
|
|
@@ -144,7 +144,7 @@ var u = {
|
|
|
144
144
|
return {
|
|
145
145
|
consume: (t, n, r) => {
|
|
146
146
|
let a = i;
|
|
147
|
-
return a ? e.tryPromise(() => c(a, t, n, r)).pipe(e.
|
|
147
|
+
return a ? e.tryPromise(() => c(a, t, n, r)).pipe(e.catch(() => e.succeed(s(n, r, "store-error")))) : e.succeed(s(n, r, "unbound"));
|
|
148
148
|
},
|
|
149
149
|
sweep: (e) => {
|
|
150
150
|
let t = i;
|
package/dist/postgresStore.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./postgresStore-
|
|
1
|
+
import { n as e, r as t, t as n } from "./postgresStore-D_oHSGXq.js";
|
|
2
2
|
export { n as RATELIMIT_TABLE, e as postgresStore, t as rateLimitTable };
|
package/dist/redisStore.js
CHANGED
|
@@ -24,7 +24,7 @@ var n = "\nlocal key = KEYS[1]\nlocal algo = ARGV[1]\nlocal limit = tonumber(ARG
|
|
|
24
24
|
return c ? e.tryPromise(async () => {
|
|
25
25
|
let e = await c.eval(n, 1, `${i}${t}`, r.algorithm, r.limit, r.windowMs, r.burst, o);
|
|
26
26
|
return JSON.parse(String(e));
|
|
27
|
-
}).pipe(e.
|
|
27
|
+
}).pipe(e.catch(() => e.succeed(s(r, o, "store-error")))) : e.succeed(s(r, o, "unbound"));
|
|
28
28
|
};
|
|
29
29
|
return {
|
|
30
30
|
consume: (t, n, r) => a ? d(t, n, r) : l(process.env) === void 0 ? e.succeed(s(n, r, "unbound")) : e.tryPromise(() => u(process.env)).pipe(e.matchEffect({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/plugin-ratelimit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.85.0",
|
|
4
4
|
"description": "Rate-limiting plugin — per-endpoint, per-subject and per-tenant request limits via the RPC interceptors. Highly configurable rules (fixed-window / sliding-window / token-bucket), composite keying, static per-tenant overrides and a dynamic resolve() hook. Stores: memory (default, single-node), postgres + redis (multi-node, atomic).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -48,16 +48,13 @@
|
|
|
48
48
|
"node": ">=24.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@voltro/database": "0.
|
|
52
|
-
"@voltro/kv": "0.
|
|
53
|
-
"@voltro/logger": "0.
|
|
54
|
-
"@voltro/protocol": "0.
|
|
55
|
-
},
|
|
56
|
-
"optionalDependencies": {
|
|
57
|
-
"@effect/sql": "^0.52.1"
|
|
51
|
+
"@voltro/database": "0.85.0",
|
|
52
|
+
"@voltro/kv": "0.85.0",
|
|
53
|
+
"@voltro/logger": "0.85.0",
|
|
54
|
+
"@voltro/protocol": "0.85.0"
|
|
58
55
|
},
|
|
59
56
|
"peerDependencies": {
|
|
60
|
-
"effect": "
|
|
57
|
+
"effect": "4.0.1"
|
|
61
58
|
},
|
|
62
59
|
"publishConfig": {
|
|
63
60
|
"access": "public"
|