@atproto/xrpc-server 0.7.19 → 0.9.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 +42 -0
- package/dist/auth.js +11 -11
- package/dist/auth.js.map +1 -1
- package/dist/errors.d.ts +67 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +202 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/rate-limiter.d.ts +95 -26
- package/dist/rate-limiter.d.ts.map +1 -1
- package/dist/rate-limiter.js +179 -85
- package/dist/rate-limiter.js.map +1 -1
- package/dist/server.d.ts +20 -15
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +185 -220
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +80 -175
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +9 -226
- package/dist/types.js.map +1 -1
- package/dist/util.d.ts +12 -9
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +114 -78
- package/dist/util.js.map +1 -1
- package/package.json +4 -3
- package/src/auth.ts +1 -1
- package/src/errors.ts +293 -0
- package/src/index.ts +4 -3
- package/src/rate-limiter.ts +270 -104
- package/src/server.ts +265 -276
- package/src/types.ts +144 -429
- package/src/util.ts +131 -85
- package/tests/auth.test.ts +2 -2
- package/tests/bodies.test.ts +18 -27
- package/tests/errors.test.ts +1 -1
- package/tests/ipld.test.ts +15 -14
- package/tests/parameters.test.ts +4 -7
- package/tests/procedures.test.ts +22 -34
- package/tests/queries.test.ts +9 -12
- package/tests/rate-limiter.test.ts +8 -11
- package/tests/responses.test.ts +12 -15
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @atproto/xrpc-server
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#3999](https://github.com/bluesky-social/atproto/pull/3999) [`8ef976d38`](https://github.com/bluesky-social/atproto/commit/8ef976d3852df4bfa376e515e131cc0810a42f20) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Reorganize naming of exported types
|
|
8
|
+
|
|
9
|
+
- [#3999](https://github.com/bluesky-social/atproto/pull/3999) [`8ef976d38`](https://github.com/bluesky-social/atproto/commit/8ef976d3852df4bfa376e515e131cc0810a42f20) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Allow stronger typing of `auth` result in method and stream handlers
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#4027](https://github.com/bluesky-social/atproto/pull/4027) [`5ed4a8859`](https://github.com/bluesky-social/atproto/commit/5ed4a885963f082a642e2cfb2fcc824e708fff90) Thanks [@devinivy](https://github.com/devinivy)! - Fix json and text uploads: don't parse bodies with input encoding of _/_.
|
|
14
|
+
|
|
15
|
+
- [#3999](https://github.com/bluesky-social/atproto/pull/3999) [`8ef976d38`](https://github.com/bluesky-social/atproto/commit/8ef976d3852df4bfa376e515e131cc0810a42f20) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use a generic to type RateLimiter's context
|
|
16
|
+
|
|
17
|
+
- [#3999](https://github.com/bluesky-social/atproto/pull/3999) [`8ef976d38`](https://github.com/bluesky-social/atproto/commit/8ef976d3852df4bfa376e515e131cc0810a42f20) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Ignore `__proto__` in query string params.
|
|
18
|
+
|
|
19
|
+
- [#3999](https://github.com/bluesky-social/atproto/pull/3999) [`8ef976d38`](https://github.com/bluesky-social/atproto/commit/8ef976d3852df4bfa376e515e131cc0810a42f20) Thanks [@matthieusieben](https://github.com/matthieusieben)! - `catchall` handler will not be triggered if the XRPC method is not a valid NSID
|
|
20
|
+
|
|
21
|
+
- [#3999](https://github.com/bluesky-social/atproto/pull/3999) [`8ef976d38`](https://github.com/bluesky-social/atproto/commit/8ef976d3852df4bfa376e515e131cc0810a42f20) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Make (typed) `params` available during auth
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`8ef976d38`](https://github.com/bluesky-social/atproto/commit/8ef976d3852df4bfa376e515e131cc0810a42f20)]:
|
|
24
|
+
- @atproto/lexicon@0.4.12
|
|
25
|
+
- @atproto/xrpc@0.7.1
|
|
26
|
+
|
|
27
|
+
## 0.8.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- [#3886](https://github.com/bluesky-social/atproto/pull/3886) [`0286f7ee3`](https://github.com/bluesky-social/atproto/commit/0286f7ee3d56ae50cfe0b70add60cf4785587b3c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Remove `bypassSecret` and `bypassIps` from rate limiter options.
|
|
32
|
+
|
|
33
|
+
- [#3886](https://github.com/bluesky-social/atproto/pull/3886) [`0286f7ee3`](https://github.com/bluesky-social/atproto/commit/0286f7ee3d56ae50cfe0b70add60cf4785587b3c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Now applies global rate limiter to every single route. Previously, the global rate limiter was not applied if a route defined a local rate limit option.
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- [#3884](https://github.com/bluesky-social/atproto/pull/3884) [`b675fbbf1`](https://github.com/bluesky-social/atproto/commit/b675fbbf17e000fad2b38a52db550702830a807d) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Return an error if the wrong HTTP verb is used for a known XRPC method, even when a `catchall` is provided.
|
|
38
|
+
|
|
39
|
+
- [#3886](https://github.com/bluesky-social/atproto/pull/3886) [`0286f7ee3`](https://github.com/bluesky-social/atproto/commit/0286f7ee3d56ae50cfe0b70add60cf4785587b3c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add optional `bypass` callback to global rate limits options
|
|
40
|
+
|
|
41
|
+
- [#3886](https://github.com/bluesky-social/atproto/pull/3886) [`0286f7ee3`](https://github.com/bluesky-social/atproto/commit/0286f7ee3d56ae50cfe0b70add60cf4785587b3c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Refactor route rate limiter builder
|
|
42
|
+
|
|
43
|
+
- [#3886](https://github.com/bluesky-social/atproto/pull/3886) [`0286f7ee3`](https://github.com/bluesky-social/atproto/commit/0286f7ee3d56ae50cfe0b70add60cf4785587b3c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Performance improvement: avoid computing rate limit bypass multiple times per request
|
|
44
|
+
|
|
3
45
|
## 0.7.19
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
package/dist/auth.js
CHANGED
|
@@ -38,7 +38,7 @@ const ui8 = __importStar(require("uint8arrays"));
|
|
|
38
38
|
const common = __importStar(require("@atproto/common"));
|
|
39
39
|
const common_1 = require("@atproto/common");
|
|
40
40
|
const crypto = __importStar(require("@atproto/crypto"));
|
|
41
|
-
const
|
|
41
|
+
const errors_1 = require("./errors");
|
|
42
42
|
const createServiceJwt = async (params) => {
|
|
43
43
|
const { iss, aud, keypair } = params;
|
|
44
44
|
const iat = params.iat ?? Math.floor(Date.now() / 1e3);
|
|
@@ -78,7 +78,7 @@ lxm, // null indicates to skip the lxm check
|
|
|
78
78
|
getSigningKey, verifySignatureWithKey = exports.cryptoVerifySignatureWithKey) => {
|
|
79
79
|
const parts = jwtStr.split('.');
|
|
80
80
|
if (parts.length !== 3) {
|
|
81
|
-
throw new
|
|
81
|
+
throw new errors_1.AuthRequiredError('poorly formatted jwt', 'BadJwt');
|
|
82
82
|
}
|
|
83
83
|
const header = parseHeader(parts[0]);
|
|
84
84
|
// The spec does not describe what to do with the "typ" claim. We can,
|
|
@@ -92,18 +92,18 @@ getSigningKey, verifySignatureWithKey = exports.cryptoVerifySignatureWithKey) =>
|
|
|
92
92
|
// "DPoP" proofs are not meant to be used as service tokens
|
|
93
93
|
// https://datatracker.ietf.org/doc/html/rfc9449
|
|
94
94
|
header['typ'] === 'dpop+jwt') {
|
|
95
|
-
throw new
|
|
95
|
+
throw new errors_1.AuthRequiredError(`Invalid jwt type "${header['typ']}"`, 'BadJwtType');
|
|
96
96
|
}
|
|
97
97
|
const payload = parsePayload(parts[1]);
|
|
98
98
|
const sig = parts[2];
|
|
99
99
|
if (Date.now() / 1000 > payload.exp) {
|
|
100
|
-
throw new
|
|
100
|
+
throw new errors_1.AuthRequiredError('jwt expired', 'JwtExpired');
|
|
101
101
|
}
|
|
102
102
|
if (ownDid !== null && payload.aud !== ownDid) {
|
|
103
|
-
throw new
|
|
103
|
+
throw new errors_1.AuthRequiredError('jwt audience does not match service did', 'BadJwtAudience');
|
|
104
104
|
}
|
|
105
105
|
if (lxm !== null && payload.lxm !== lxm) {
|
|
106
|
-
throw new
|
|
106
|
+
throw new errors_1.AuthRequiredError(payload.lxm !== undefined
|
|
107
107
|
? `bad jwt lexicon method ("lxm"). must match: ${lxm}`
|
|
108
108
|
: `missing jwt lexicon method ("lxm"). must match: ${lxm}`, 'BadJwtLexiconMethod');
|
|
109
109
|
}
|
|
@@ -116,7 +116,7 @@ getSigningKey, verifySignatureWithKey = exports.cryptoVerifySignatureWithKey) =>
|
|
|
116
116
|
validSig = await verifySignatureWithKey(signingKey, msgBytes, sigBytes, alg);
|
|
117
117
|
}
|
|
118
118
|
catch (err) {
|
|
119
|
-
throw new
|
|
119
|
+
throw new errors_1.AuthRequiredError('could not verify jwt signature', 'BadJwtSignature');
|
|
120
120
|
}
|
|
121
121
|
if (!validSig) {
|
|
122
122
|
// get fresh signing key in case it failed due to a recent rotation
|
|
@@ -128,11 +128,11 @@ getSigningKey, verifySignatureWithKey = exports.cryptoVerifySignatureWithKey) =>
|
|
|
128
128
|
: false;
|
|
129
129
|
}
|
|
130
130
|
catch (err) {
|
|
131
|
-
throw new
|
|
131
|
+
throw new errors_1.AuthRequiredError('could not verify jwt signature', 'BadJwtSignature');
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
if (!validSig) {
|
|
135
|
-
throw new
|
|
135
|
+
throw new errors_1.AuthRequiredError('jwt signature does not match jwt issuer', 'BadJwtSignature');
|
|
136
136
|
}
|
|
137
137
|
return payload;
|
|
138
138
|
};
|
|
@@ -150,7 +150,7 @@ const parseB64UrlToJson = (b64) => {
|
|
|
150
150
|
const parseHeader = (b64) => {
|
|
151
151
|
const header = parseB64UrlToJson(b64);
|
|
152
152
|
if (!header || typeof header !== 'object' || typeof header.alg !== 'string') {
|
|
153
|
-
throw new
|
|
153
|
+
throw new errors_1.AuthRequiredError('poorly formatted jwt', 'BadJwt');
|
|
154
154
|
}
|
|
155
155
|
return header;
|
|
156
156
|
};
|
|
@@ -163,7 +163,7 @@ const parsePayload = (b64) => {
|
|
|
163
163
|
typeof payload.exp !== 'number' ||
|
|
164
164
|
(payload.lxm && typeof payload.lxm !== 'string') ||
|
|
165
165
|
(payload.nonce && typeof payload.nonce !== 'string')) {
|
|
166
|
-
throw new
|
|
166
|
+
throw new errors_1.AuthRequiredError('poorly formatted jwt', 'BadJwt');
|
|
167
167
|
}
|
|
168
168
|
return payload;
|
|
169
169
|
};
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkC;AAClC,wDAAyC;AACzC,4CAAwC;AACxC,wDAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkC;AAClC,wDAAyC;AACzC,4CAAwC;AACxC,wDAAyC;AACzC,qCAA4C;AAuBrC,MAAM,gBAAgB,GAAG,KAAK,EACnC,MAAwB,EACP,EAAE;IACnB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IACpC,MAAM,GA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AAG,CAAC,CAAA;IACtC,IACE,CAAC,OAAO;QACR,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ;QAC/B,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ;QAC/B,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ;QAC/B,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,CAAC;QAChD,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,EACpD,CAAC;QACD,MAAM,IAAI,0BAAiB,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAA;IAC/D,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResponseType } from '@atproto/xrpc';
|
|
3
|
+
export declare const errorResult: z.ZodObject<{
|
|
4
|
+
status: z.ZodNumber;
|
|
5
|
+
error: z.ZodOptional<z.ZodString>;
|
|
6
|
+
message: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
status: number;
|
|
9
|
+
error?: string | undefined;
|
|
10
|
+
message?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
status: number;
|
|
13
|
+
error?: string | undefined;
|
|
14
|
+
message?: string | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export type ErrorResult = z.infer<typeof errorResult>;
|
|
17
|
+
export declare function isErrorResult(v: unknown): v is ErrorResult;
|
|
18
|
+
export declare function excludeErrorResult<V>(v: V): Exclude<V, ErrorResult>;
|
|
19
|
+
export { ResponseType };
|
|
20
|
+
export declare class XRPCError extends Error {
|
|
21
|
+
type: ResponseType;
|
|
22
|
+
errorMessage?: string | undefined;
|
|
23
|
+
customErrorName?: string | undefined;
|
|
24
|
+
constructor(type: ResponseType, errorMessage?: string | undefined, customErrorName?: string | undefined, options?: ErrorOptions);
|
|
25
|
+
get statusCode(): number;
|
|
26
|
+
get payload(): {
|
|
27
|
+
error: string | undefined;
|
|
28
|
+
message: string | undefined;
|
|
29
|
+
};
|
|
30
|
+
get typeName(): string | undefined;
|
|
31
|
+
get typeStr(): string | undefined;
|
|
32
|
+
static fromError(cause: unknown): XRPCError;
|
|
33
|
+
static fromErrorResult(err: ErrorResult): XRPCError;
|
|
34
|
+
}
|
|
35
|
+
export declare class InvalidRequestError extends XRPCError {
|
|
36
|
+
constructor(errorMessage?: string, customErrorName?: string, options?: ErrorOptions);
|
|
37
|
+
[Symbol.hasInstance](instance: unknown): boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare class AuthRequiredError extends XRPCError {
|
|
40
|
+
constructor(errorMessage?: string, customErrorName?: string, options?: ErrorOptions);
|
|
41
|
+
[Symbol.hasInstance](instance: unknown): boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare class ForbiddenError extends XRPCError {
|
|
44
|
+
constructor(errorMessage?: string, customErrorName?: string, options?: ErrorOptions);
|
|
45
|
+
[Symbol.hasInstance](instance: unknown): boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare class InternalServerError extends XRPCError {
|
|
48
|
+
constructor(errorMessage?: string, customErrorName?: string, options?: ErrorOptions);
|
|
49
|
+
[Symbol.hasInstance](instance: unknown): boolean;
|
|
50
|
+
}
|
|
51
|
+
export declare class UpstreamFailureError extends XRPCError {
|
|
52
|
+
constructor(errorMessage?: string, customErrorName?: string, options?: ErrorOptions);
|
|
53
|
+
[Symbol.hasInstance](instance: unknown): boolean;
|
|
54
|
+
}
|
|
55
|
+
export declare class NotEnoughResourcesError extends XRPCError {
|
|
56
|
+
constructor(errorMessage?: string, customErrorName?: string, options?: ErrorOptions);
|
|
57
|
+
[Symbol.hasInstance](instance: unknown): boolean;
|
|
58
|
+
}
|
|
59
|
+
export declare class UpstreamTimeoutError extends XRPCError {
|
|
60
|
+
constructor(errorMessage?: string, customErrorName?: string, options?: ErrorOptions);
|
|
61
|
+
[Symbol.hasInstance](instance: unknown): boolean;
|
|
62
|
+
}
|
|
63
|
+
export declare class MethodNotImplementedError extends XRPCError {
|
|
64
|
+
constructor(errorMessage?: string, customErrorName?: string, options?: ErrorOptions);
|
|
65
|
+
[Symbol.hasInstance](instance: unknown): boolean;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,YAAY,EAKb,MAAM,eAAe,CAAA;AAKtB,eAAO,MAAM,WAAW;;;;;;;;;;;;EAItB,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AAErD,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,WAAW,CAE1D;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAE5B,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CACpC;AAED,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,qBAAa,SAAU,SAAQ,KAAK;IAEzB,IAAI,EAAE,YAAY;IAClB,YAAY,CAAC,EAAE,MAAM;IACrB,eAAe,CAAC,EAAE,MAAM;gBAFxB,IAAI,EAAE,YAAY,EAClB,YAAY,CAAC,EAAE,MAAM,YAAA,EACrB,eAAe,CAAC,EAAE,MAAM,YAAA,EAC/B,OAAO,CAAC,EAAE,YAAY;IAKxB,IAAI,UAAU,IAAI,MAAM,CAWvB;IAED,IAAI,OAAO;;;MAQV;IAED,IAAI,QAAQ,IAAI,MAAM,GAAG,SAAS,CAEjC;IAED,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEh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M,EACrB,eAAe,CAAC,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,YAAY;IAUxB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO;CAMjD;AAED,qBAAa,oBAAqB,SAAQ,SAAS;gBAE/C,YAAY,CAAC,EAAE,MAAM,EACrB,eAAe,CAAC,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,YAAY;IAKxB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO;CAMjD;AAED,qBAAa,yBAA0B,SAAQ,SAAS;gBAEpD,YAAY,CAAC,EAAE,MAAM,EACrB,eAAe,CAAC,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,YAAY;IAUxB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO;CAMjD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MethodNotImplementedError = exports.UpstreamTimeoutError = exports.NotEnoughResourcesError = exports.UpstreamFailureError = exports.InternalServerError = exports.ForbiddenError = exports.AuthRequiredError = exports.InvalidRequestError = exports.XRPCError = exports.ResponseType = exports.errorResult = void 0;
|
|
4
|
+
exports.isErrorResult = isErrorResult;
|
|
5
|
+
exports.excludeErrorResult = excludeErrorResult;
|
|
6
|
+
const http_errors_1 = require("http-errors");
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const xrpc_1 = require("@atproto/xrpc");
|
|
9
|
+
Object.defineProperty(exports, "ResponseType", { enumerable: true, get: function () { return xrpc_1.ResponseType; } });
|
|
10
|
+
// @NOTE Do not depend (directly or indirectly) on "./types" here, as it would
|
|
11
|
+
// create a circular dependency.
|
|
12
|
+
exports.errorResult = zod_1.z.object({
|
|
13
|
+
status: zod_1.z.number(),
|
|
14
|
+
error: zod_1.z.string().optional(),
|
|
15
|
+
message: zod_1.z.string().optional(),
|
|
16
|
+
});
|
|
17
|
+
function isErrorResult(v) {
|
|
18
|
+
return exports.errorResult.safeParse(v).success;
|
|
19
|
+
}
|
|
20
|
+
function excludeErrorResult(v) {
|
|
21
|
+
if (isErrorResult(v))
|
|
22
|
+
throw XRPCError.fromErrorResult(v);
|
|
23
|
+
return v;
|
|
24
|
+
}
|
|
25
|
+
class XRPCError extends Error {
|
|
26
|
+
constructor(type, errorMessage, customErrorName, options) {
|
|
27
|
+
super(errorMessage, options);
|
|
28
|
+
Object.defineProperty(this, "type", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: type
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(this, "errorMessage", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: errorMessage
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(this, "customErrorName", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: customErrorName
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
get statusCode() {
|
|
48
|
+
const { type } = this;
|
|
49
|
+
// Fool-proofing. `new XRPCError(123.5 as number, '')` does not generate a TypeScript error.
|
|
50
|
+
// Because of this, we can end-up with any numeric value instead of an actual `ResponseType`.
|
|
51
|
+
// For legacy reasons, the `type` argument is not checked in the constructor, so we check it here.
|
|
52
|
+
if (type < 400 || type >= 600 || !Number.isFinite(type)) {
|
|
53
|
+
return 500;
|
|
54
|
+
}
|
|
55
|
+
return type;
|
|
56
|
+
}
|
|
57
|
+
get payload() {
|
|
58
|
+
return {
|
|
59
|
+
error: this.customErrorName ?? this.typeName,
|
|
60
|
+
message: this.type === xrpc_1.ResponseType.InternalServerError
|
|
61
|
+
? this.typeStr // Do not respond with error details for 500s
|
|
62
|
+
: this.errorMessage || this.typeStr,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
get typeName() {
|
|
66
|
+
return xrpc_1.ResponseType[this.type];
|
|
67
|
+
}
|
|
68
|
+
get typeStr() {
|
|
69
|
+
return xrpc_1.ResponseTypeStrings[this.type];
|
|
70
|
+
}
|
|
71
|
+
static fromError(cause) {
|
|
72
|
+
if (cause instanceof XRPCError) {
|
|
73
|
+
return cause;
|
|
74
|
+
}
|
|
75
|
+
if (cause instanceof xrpc_1.XRPCError) {
|
|
76
|
+
const { error, message, type } = mapFromClientError(cause);
|
|
77
|
+
return new XRPCError(type, message, error, { cause });
|
|
78
|
+
}
|
|
79
|
+
if ((0, http_errors_1.isHttpError)(cause)) {
|
|
80
|
+
return new XRPCError(cause.status, cause.message, cause.name, { cause });
|
|
81
|
+
}
|
|
82
|
+
if (isErrorResult(cause)) {
|
|
83
|
+
return this.fromErrorResult(cause);
|
|
84
|
+
}
|
|
85
|
+
if (cause instanceof Error) {
|
|
86
|
+
return new InternalServerError(cause.message, undefined, { cause });
|
|
87
|
+
}
|
|
88
|
+
return new InternalServerError('Unexpected internal server error', undefined, { cause });
|
|
89
|
+
}
|
|
90
|
+
static fromErrorResult(err) {
|
|
91
|
+
return new XRPCError(err.status, err.message, err.error, { cause: err });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.XRPCError = XRPCError;
|
|
95
|
+
class InvalidRequestError extends XRPCError {
|
|
96
|
+
constructor(errorMessage, customErrorName, options) {
|
|
97
|
+
super(xrpc_1.ResponseType.InvalidRequest, errorMessage, customErrorName, options);
|
|
98
|
+
}
|
|
99
|
+
[Symbol.hasInstance](instance) {
|
|
100
|
+
return (instance instanceof XRPCError &&
|
|
101
|
+
instance.type === xrpc_1.ResponseType.InvalidRequest);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.InvalidRequestError = InvalidRequestError;
|
|
105
|
+
class AuthRequiredError extends XRPCError {
|
|
106
|
+
constructor(errorMessage, customErrorName, options) {
|
|
107
|
+
super(xrpc_1.ResponseType.AuthenticationRequired, errorMessage, customErrorName, options);
|
|
108
|
+
}
|
|
109
|
+
[Symbol.hasInstance](instance) {
|
|
110
|
+
return (instance instanceof XRPCError &&
|
|
111
|
+
instance.type === xrpc_1.ResponseType.AuthenticationRequired);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.AuthRequiredError = AuthRequiredError;
|
|
115
|
+
class ForbiddenError extends XRPCError {
|
|
116
|
+
constructor(errorMessage, customErrorName, options) {
|
|
117
|
+
super(xrpc_1.ResponseType.Forbidden, errorMessage, customErrorName, options);
|
|
118
|
+
}
|
|
119
|
+
[Symbol.hasInstance](instance) {
|
|
120
|
+
return (instance instanceof XRPCError && instance.type === xrpc_1.ResponseType.Forbidden);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.ForbiddenError = ForbiddenError;
|
|
124
|
+
class InternalServerError extends XRPCError {
|
|
125
|
+
constructor(errorMessage, customErrorName, options) {
|
|
126
|
+
super(xrpc_1.ResponseType.InternalServerError, errorMessage, customErrorName, options);
|
|
127
|
+
}
|
|
128
|
+
[Symbol.hasInstance](instance) {
|
|
129
|
+
return (instance instanceof XRPCError &&
|
|
130
|
+
instance.type === xrpc_1.ResponseType.InternalServerError);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.InternalServerError = InternalServerError;
|
|
134
|
+
class UpstreamFailureError extends XRPCError {
|
|
135
|
+
constructor(errorMessage, customErrorName, options) {
|
|
136
|
+
super(xrpc_1.ResponseType.UpstreamFailure, errorMessage, customErrorName, options);
|
|
137
|
+
}
|
|
138
|
+
[Symbol.hasInstance](instance) {
|
|
139
|
+
return (instance instanceof XRPCError &&
|
|
140
|
+
instance.type === xrpc_1.ResponseType.UpstreamFailure);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.UpstreamFailureError = UpstreamFailureError;
|
|
144
|
+
class NotEnoughResourcesError extends XRPCError {
|
|
145
|
+
constructor(errorMessage, customErrorName, options) {
|
|
146
|
+
super(xrpc_1.ResponseType.NotEnoughResources, errorMessage, customErrorName, options);
|
|
147
|
+
}
|
|
148
|
+
[Symbol.hasInstance](instance) {
|
|
149
|
+
return (instance instanceof XRPCError &&
|
|
150
|
+
instance.type === xrpc_1.ResponseType.NotEnoughResources);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.NotEnoughResourcesError = NotEnoughResourcesError;
|
|
154
|
+
class UpstreamTimeoutError extends XRPCError {
|
|
155
|
+
constructor(errorMessage, customErrorName, options) {
|
|
156
|
+
super(xrpc_1.ResponseType.UpstreamTimeout, errorMessage, customErrorName, options);
|
|
157
|
+
}
|
|
158
|
+
[Symbol.hasInstance](instance) {
|
|
159
|
+
return (instance instanceof XRPCError &&
|
|
160
|
+
instance.type === xrpc_1.ResponseType.UpstreamTimeout);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.UpstreamTimeoutError = UpstreamTimeoutError;
|
|
164
|
+
class MethodNotImplementedError extends XRPCError {
|
|
165
|
+
constructor(errorMessage, customErrorName, options) {
|
|
166
|
+
super(xrpc_1.ResponseType.MethodNotImplemented, errorMessage, customErrorName, options);
|
|
167
|
+
}
|
|
168
|
+
[Symbol.hasInstance](instance) {
|
|
169
|
+
return (instance instanceof XRPCError &&
|
|
170
|
+
instance.type === xrpc_1.ResponseType.MethodNotImplemented);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.MethodNotImplementedError = MethodNotImplementedError;
|
|
174
|
+
/**
|
|
175
|
+
* Converts an upstream XRPC {@link ResponseType} into a downstream {@link ResponseType}.
|
|
176
|
+
*/
|
|
177
|
+
function mapFromClientError(error) {
|
|
178
|
+
switch (error.status) {
|
|
179
|
+
case xrpc_1.ResponseType.InvalidResponse:
|
|
180
|
+
// Upstream server returned an XRPC response that is not compatible with our internal lexicon definitions for that XRPC method.
|
|
181
|
+
// @NOTE This could be reflected as both a 500 ("we" are at fault) and 502 ("they" are at fault). Let's be gents about it.
|
|
182
|
+
return {
|
|
183
|
+
error: (0, xrpc_1.httpResponseCodeToName)(xrpc_1.ResponseType.InternalServerError),
|
|
184
|
+
message: (0, xrpc_1.httpResponseCodeToString)(xrpc_1.ResponseType.InternalServerError),
|
|
185
|
+
type: xrpc_1.ResponseType.InternalServerError,
|
|
186
|
+
};
|
|
187
|
+
case xrpc_1.ResponseType.Unknown:
|
|
188
|
+
// Typically a network error / unknown host
|
|
189
|
+
return {
|
|
190
|
+
error: (0, xrpc_1.httpResponseCodeToName)(xrpc_1.ResponseType.InternalServerError),
|
|
191
|
+
message: (0, xrpc_1.httpResponseCodeToString)(xrpc_1.ResponseType.InternalServerError),
|
|
192
|
+
type: xrpc_1.ResponseType.InternalServerError,
|
|
193
|
+
};
|
|
194
|
+
default:
|
|
195
|
+
return {
|
|
196
|
+
error: error.error,
|
|
197
|
+
message: error.message,
|
|
198
|
+
type: error.status,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAoBA,sCAEC;AAED,gDAGC;AA3BD,6CAAyC;AACzC,6BAAuB;AACvB,wCAMsB;AAqBb,6FA1BP,mBAAY,OA0BO;AAnBrB,8EAA8E;AAC9E,gCAAgC;AAEnB,QAAA,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAClC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAA;AAGF,SAAgB,aAAa,CAAC,CAAU;IACtC,OAAO,mBAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,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EACf,OAAO,CACR,CAAA;IACH,CAAC;IAED,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAiB;QACpC,OAAO,CACL,QAAQ,YAAY,SAAS;YAC7B,QAAQ,CAAC,IAAI,KAAK,mBAAY,CAAC,oBAAoB,CACpD,CAAA;IACH,CAAC;CACF;AApBD,8DAoBC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,KAAsB;IAKhD,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,mBAAY,CAAC,eAAe;YAC/B,+HAA+H;YAC/H,0HAA0H;YAC1H,OAAO;gBACL,KAAK,EAAE,IAAA,6BAAsB,EAAC,mBAAY,CAAC,mBAAmB,CAAC;gBAC/D,OAAO,EAAE,IAAA,+BAAwB,EAAC,mBAAY,CAAC,mBAAmB,CAAC;gBACnE,IAAI,EAAE,mBAAY,CAAC,mBAAmB;aACvC,CAAA;QACH,KAAK,mBAAY,CAAC,OAAO;YACvB,2CAA2C;YAC3C,OAAO;gBACL,KAAK,EAAE,IAAA,6BAAsB,EAAC,mBAAY,CAAC,mBAAmB,CAAC;gBAC/D,OAAO,EAAE,IAAA,+BAAwB,EAAC,mBAAY,CAAC,mBAAmB,CAAC;gBACnE,IAAI,EAAE,mBAAY,CAAC,mBAAmB;aACvC,CAAA;QACH;YACE,OAAO;gBACL,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,IAAI,EAAE,KAAK,CAAC,MAAM;aACnB,CAAA;IACL,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from './types';
|
|
2
1
|
export * from './auth';
|
|
2
|
+
export * from './errors';
|
|
3
|
+
export * from './rate-limiter';
|
|
3
4
|
export * from './server';
|
|
4
5
|
export * from './stream';
|
|
5
|
-
export * from './
|
|
6
|
-
export type { ServerTiming } from './util';
|
|
6
|
+
export * from './types';
|
|
7
7
|
export { ServerTimer, parseReqNsid, serverTimingHeader } from './util';
|
|
8
|
+
export type { ServerTiming } from './util';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AACtE,YAAY,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -15,11 +15,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.serverTimingHeader = exports.parseReqNsid = exports.ServerTimer = void 0;
|
|
18
|
-
__exportStar(require("./types"), exports);
|
|
19
18
|
__exportStar(require("./auth"), exports);
|
|
19
|
+
__exportStar(require("./errors"), exports);
|
|
20
|
+
__exportStar(require("./rate-limiter"), exports);
|
|
20
21
|
__exportStar(require("./server"), exports);
|
|
21
22
|
__exportStar(require("./stream"), exports);
|
|
22
|
-
__exportStar(require("./
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
23
24
|
var util_1 = require("./util");
|
|
24
25
|
Object.defineProperty(exports, "ServerTimer", { enumerable: true, get: function () { return util_1.ServerTimer; } });
|
|
25
26
|
Object.defineProperty(exports, "parseReqNsid", { enumerable: true, get: function () { return util_1.parseReqNsid; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAAsB;AACtB,2CAAwB;AACxB,iDAA8B;AAC9B,2CAAwB;AACxB,2CAAwB;AACxB,0CAAuB;AAEvB,+BAAsE;AAA7D,mGAAA,WAAW,OAAA;AAAE,oGAAA,YAAY,OAAA;AAAE,0GAAA,kBAAkB,OAAA"}
|
package/dist/rate-limiter.d.ts
CHANGED
|
@@ -1,36 +1,105 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
1
2
|
import { RateLimiterAbstract, RateLimiterRes } from 'rate-limiter-flexible';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
3
|
+
import { XRPCError } from './errors';
|
|
4
|
+
export interface RateLimiterContext {
|
|
5
|
+
req: IncomingMessage;
|
|
6
|
+
res?: ServerResponse;
|
|
7
|
+
}
|
|
8
|
+
export type CalcKeyFn<C extends RateLimiterContext = RateLimiterContext> = (ctx: C) => string | null;
|
|
9
|
+
export type CalcPointsFn<C extends RateLimiterContext = RateLimiterContext> = (ctx: C) => number;
|
|
10
|
+
export interface RateLimiterI<C extends RateLimiterContext = RateLimiterContext> {
|
|
11
|
+
consume: RateLimiterConsume<C>;
|
|
12
|
+
reset: RateLimiterReset<C>;
|
|
13
|
+
}
|
|
14
|
+
export type RateLimiterConsumeOptions<C extends RateLimiterContext = RateLimiterContext> = {
|
|
15
|
+
calcKey?: CalcKeyFn<C>;
|
|
16
|
+
calcPoints?: CalcPointsFn<C>;
|
|
17
|
+
};
|
|
18
|
+
export type RateLimiterConsume<C extends RateLimiterContext = RateLimiterContext> = (ctx: C, opts?: RateLimiterConsumeOptions<C>) => Promise<RateLimiterStatus | RateLimitExceededError | null>;
|
|
19
|
+
export type RateLimiterStatus = {
|
|
20
|
+
limit: number;
|
|
21
|
+
duration: number;
|
|
22
|
+
remainingPoints: number;
|
|
23
|
+
msBeforeNext: number;
|
|
24
|
+
consumedPoints: number;
|
|
25
|
+
isFirstInDuration: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type RateLimiterResetOptions<C extends RateLimiterContext = RateLimiterContext> = {
|
|
28
|
+
calcKey?: CalcKeyFn<C>;
|
|
29
|
+
};
|
|
30
|
+
export type RateLimiterReset<C extends RateLimiterContext = RateLimiterContext> = (ctx: C, opts?: RateLimiterResetOptions<C>) => Promise<void>;
|
|
31
|
+
export type RateLimiterOptions<C extends RateLimiterContext = RateLimiterContext> = {
|
|
4
32
|
keyPrefix: string;
|
|
5
33
|
durationMs: number;
|
|
6
34
|
points: number;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
calcKey?: CalcKeyFn;
|
|
10
|
-
calcPoints?: CalcPointsFn;
|
|
35
|
+
calcKey: CalcKeyFn<C>;
|
|
36
|
+
calcPoints: CalcPointsFn<C>;
|
|
11
37
|
failClosed?: boolean;
|
|
12
38
|
};
|
|
13
|
-
export declare class RateLimiter implements RateLimiterI {
|
|
39
|
+
export declare class RateLimiter<C extends RateLimiterContext = RateLimiterContext> implements RateLimiterI<C> {
|
|
14
40
|
limiter: RateLimiterAbstract;
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
reset(ctx: XRPCReqContext, opts?: {
|
|
28
|
-
calcKey?: CalcKeyFn;
|
|
29
|
-
}): Promise<void>;
|
|
41
|
+
private readonly failClosed?;
|
|
42
|
+
private readonly calcKey;
|
|
43
|
+
private readonly calcPoints;
|
|
44
|
+
constructor(limiter: RateLimiterAbstract, options: RateLimiterOptions<C>);
|
|
45
|
+
consume(ctx: C, opts?: RateLimiterConsumeOptions<C>): Promise<RateLimiterStatus | RateLimitExceededError | null>;
|
|
46
|
+
reset(ctx: C, opts?: RateLimiterResetOptions<C>): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export declare class MemoryRateLimiter<C extends RateLimiterContext = RateLimiterContext> extends RateLimiter<C> {
|
|
49
|
+
constructor(options: RateLimiterOptions<C>);
|
|
50
|
+
}
|
|
51
|
+
export declare class RedisRateLimiter<C extends RateLimiterContext = RateLimiterContext> extends RateLimiter<C> {
|
|
52
|
+
constructor(storeClient: unknown, options: RateLimiterOptions<C>);
|
|
30
53
|
}
|
|
31
54
|
export declare const formatLimiterStatus: (limiter: RateLimiterAbstract, res: RateLimiterRes) => RateLimiterStatus;
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
55
|
+
export type WrappedRateLimiterOptions<C extends RateLimiterContext = RateLimiterContext> = {
|
|
56
|
+
calcKey?: CalcKeyFn<C>;
|
|
57
|
+
calcPoints?: CalcPointsFn<C>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Wraps a {@link RateLimiterI} instance with custom key and points calculation
|
|
61
|
+
* functions.
|
|
62
|
+
*/
|
|
63
|
+
export declare class WrappedRateLimiter<C extends RateLimiterContext = RateLimiterContext> implements RateLimiterI<C> {
|
|
64
|
+
private readonly rateLimiter;
|
|
65
|
+
private readonly options;
|
|
66
|
+
private constructor();
|
|
67
|
+
consume(ctx: C, opts?: RateLimiterConsumeOptions<C>): Promise<RateLimiterStatus | RateLimitExceededError | null>;
|
|
68
|
+
reset(ctx: C, opts?: RateLimiterResetOptions<C>): Promise<void>;
|
|
69
|
+
static from<C extends RateLimiterContext = RateLimiterContext>(rateLimiter: RateLimiterI<C>, { calcKey, calcPoints }?: WrappedRateLimiterOptions<C>): RateLimiterI<C>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Combines multiple rate limiters into one.
|
|
73
|
+
*
|
|
74
|
+
* The combined rate limiter will return the tightest (most restrictive) of all
|
|
75
|
+
* the provided rate limiters.
|
|
76
|
+
*/
|
|
77
|
+
export declare class CombinedRateLimiter<C extends RateLimiterContext = RateLimiterContext> implements RateLimiterI<C> {
|
|
78
|
+
private readonly rateLimiters;
|
|
79
|
+
private constructor();
|
|
80
|
+
consume(ctx: C, opts?: RateLimiterConsumeOptions<C>): Promise<RateLimiterStatus | RateLimitExceededError | null>;
|
|
81
|
+
reset(ctx: C, opts?: RateLimiterResetOptions<C>): Promise<void>;
|
|
82
|
+
static from<C extends RateLimiterContext = RateLimiterContext>(rateLimiters: readonly RateLimiterI<C>[]): RateLimiterI<C> | undefined;
|
|
83
|
+
}
|
|
84
|
+
export type RouteRateLimiterOptions<C extends RateLimiterContext = RateLimiterContext> = {
|
|
85
|
+
bypass?: (ctx: C) => boolean;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Wraps a {@link RateLimiterI} interface into a class that will apply the
|
|
89
|
+
* appropriate headers to the response if a limit is exceeded.
|
|
90
|
+
*/
|
|
91
|
+
export declare class RouteRateLimiter<C extends RateLimiterContext = RateLimiterContext> implements RateLimiterI<C> {
|
|
92
|
+
private readonly rateLimiter;
|
|
93
|
+
private readonly options;
|
|
94
|
+
constructor(rateLimiter: RateLimiterI<C>, options?: Readonly<RouteRateLimiterOptions<C>>);
|
|
95
|
+
handle(ctx: C): Promise<RateLimiterStatus | null>;
|
|
96
|
+
consume(...args: Parameters<RateLimiterConsume<C>>): Promise<RateLimiterStatus | RateLimitExceededError | null>;
|
|
97
|
+
reset(...args: Parameters<RateLimiterReset<C>>): Promise<void>;
|
|
98
|
+
static from<C extends RateLimiterContext = RateLimiterContext>(rateLimiters: readonly RateLimiterI<C>[], { bypass }?: RouteRateLimiterOptions<C>): RouteRateLimiter<C> | undefined;
|
|
99
|
+
}
|
|
100
|
+
export declare class RateLimitExceededError extends XRPCError {
|
|
101
|
+
status: RateLimiterStatus;
|
|
102
|
+
constructor(status: RateLimiterStatus, errorMessage?: string, customErrorName?: string, options?: ErrorOptions);
|
|
103
|
+
[Symbol.hasInstance](instance: unknown): boolean;
|
|
104
|
+
}
|
|
36
105
|
//# sourceMappingURL=rate-limiter.d.ts.map
|