@nestjs/throttler 6.4.0 → 6.5.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/README.md
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
|
|
19
19
|
A Rate-Limiter for NestJS, regardless of the context.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Throttler ensures that users can only make `limit` requests per `ttl` to each endpoint. By default, users are identified by their IP address. This behavior can be customized by providing your own `getTracker` function. See [Proxies](#proxies) for an example where this is useful.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Throttler comes with a built-in in-memory cache to keep track of the requests. It supports alternate storage providers. For an overview, see [Community Storage Providers](#community-storage-providers).
|
|
24
24
|
|
|
25
25
|
## Installation
|
|
26
26
|
|
|
@@ -32,23 +32,7 @@ $ npm i --save @nestjs/throttler
|
|
|
32
32
|
|
|
33
33
|
`@nestjs/throttler@^1` is compatible with Nest v7 while `@nestjs/throttler@^2` is compatible with Nest v7 and Nest v8, but it is suggested to be used with only v8 in case of breaking changes against v7 that are unseen.
|
|
34
34
|
|
|
35
|
-
For NestJS v10, please use version 4.1.0 or above
|
|
36
|
-
|
|
37
|
-
<div id="toc"></div>
|
|
38
|
-
|
|
39
|
-
## Table of Contents
|
|
40
|
-
|
|
41
|
-
- [Description](#description)
|
|
42
|
-
- [Versions](#versions)
|
|
43
|
-
- [Table of Contents](#table-of-contents)
|
|
44
|
-
- [Usage](#usage)
|
|
45
|
-
- [ThrottlerModule](#throttlermodule)
|
|
46
|
-
- [Customization](#customization)
|
|
47
|
-
- [ThrottlerStorage](#storages)
|
|
48
|
-
- [Proxies](#proxies)
|
|
49
|
-
- [Working with Websockets](#websockets)
|
|
50
|
-
- [Working with GraphQL](#graphql)
|
|
51
|
-
- [Community Storage Providers](#community-storage-providers)
|
|
35
|
+
For NestJS v10, please use version 4.1.0 or above.
|
|
52
36
|
|
|
53
37
|
## Usage
|
|
54
38
|
|
|
@@ -110,9 +94,9 @@ There may come upon times where you want to set up multiple throttling definitio
|
|
|
110
94
|
export class AppModule {}
|
|
111
95
|
```
|
|
112
96
|
|
|
113
|
-
|
|
97
|
+
### Customization
|
|
114
98
|
|
|
115
|
-
There may be a time where you want to bind the guard to a controller or globally, but want to disable rate limiting for one or more of your endpoints. For that, you can use the `@SkipThrottle()` decorator, to negate the throttler for an entire class or a single route. The `@SkipThrottle()` decorator can also take in an object of string keys with boolean values
|
|
99
|
+
There may be a time where you want to bind the guard to a controller or globally, but want to disable rate limiting for one or more of your endpoints. For that, you can use the `@SkipThrottle()` decorator, to negate the throttler for an entire class or a single route. The `@SkipThrottle()` decorator can also take in an object of string keys with boolean values, if you have more than one throttler set. If you do not pass an object, the default is to use `{ default: true }`
|
|
116
100
|
|
|
117
101
|
```typescript
|
|
118
102
|
@SkipThrottle()
|
|
@@ -149,9 +133,11 @@ findAll() {
|
|
|
149
133
|
}
|
|
150
134
|
```
|
|
151
135
|
|
|
152
|
-
|
|
136
|
+
### Proxies
|
|
153
137
|
|
|
154
|
-
If your application runs behind a proxy server, check the specific HTTP adapter options ([express](http://expressjs.com/en/guide/behind-proxies.html) and [fastify](https://www.fastify.io/docs/latest/Reference/Server/#trustproxy)) for the `trust proxy` option and enable it. Doing so will allow you to get the original IP address from the `X-Forwarded-For` header
|
|
138
|
+
If your application runs behind a proxy server, check the specific HTTP adapter options ([express](http://expressjs.com/en/guide/behind-proxies.html) and [fastify](https://www.fastify.io/docs/latest/Reference/Server/#trustproxy)) for the `trust proxy` option and enable it. Doing so will allow you to get the original IP address from the `X-Forwarded-For` header.
|
|
139
|
+
|
|
140
|
+
For express, no further configuration is needed because express sets `req.ip` to the client IP if `trust proxy` is enabled. For fastify, you need to read the client IP from `req.ips` instead. The following example is only needed for fastify, but works with both engines:
|
|
155
141
|
|
|
156
142
|
```typescript
|
|
157
143
|
// throttler-behind-proxy.guard.ts
|
|
@@ -161,10 +147,10 @@ import { Injectable } from '@nestjs/common';
|
|
|
161
147
|
@Injectable()
|
|
162
148
|
export class ThrottlerBehindProxyGuard extends ThrottlerGuard {
|
|
163
149
|
protected getTracker(req: Record<string, any>): Promise<string> {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
150
|
+
// The client IP is the leftmost IP in req.ips. You can individualize IP
|
|
151
|
+
// extraction to meet your own needs.
|
|
152
|
+
const tracker = req.ips.length > 0 ? req.ips[0] : req.ip;
|
|
153
|
+
return Promise.resolve(tracker);
|
|
168
154
|
}
|
|
169
155
|
}
|
|
170
156
|
|
|
@@ -174,9 +160,9 @@ import { ThrottlerBehindProxyGuard } from './throttler-behind-proxy.guard';
|
|
|
174
160
|
@UseGuards(ThrottlerBehindProxyGuard)
|
|
175
161
|
```
|
|
176
162
|
|
|
177
|
-
>
|
|
163
|
+
> **Hint:** You can find the API of the `req` Request object for express [here](https://expressjs.com/en/api.html#req.ips) and for fastify [here](https://www.fastify.io/docs/latest/Reference/Request/).
|
|
178
164
|
|
|
179
|
-
|
|
165
|
+
### Websockets
|
|
180
166
|
|
|
181
167
|
This module can work with websockets, but it requires some class extension. You can extend the `ThrottlerGuard` and override the `handleRequest` method like so:
|
|
182
168
|
|
|
@@ -184,7 +170,7 @@ This module can work with websockets, but it requires some class extension. You
|
|
|
184
170
|
@Injectable()
|
|
185
171
|
export class WsThrottlerGuard extends ThrottlerGuard {
|
|
186
172
|
async handleRequest(requestProps: ThrottlerRequest): Promise<boolean> {
|
|
187
|
-
const { context, limit, ttl, throttler, blockDuration,
|
|
173
|
+
const { context, limit, ttl, throttler, blockDuration, generateKey } = requestProps;
|
|
188
174
|
|
|
189
175
|
const client = context.switchToWs().getClient();
|
|
190
176
|
const tracker = client._socket.remoteAddress;
|
|
@@ -192,8 +178,6 @@ export class WsThrottlerGuard extends ThrottlerGuard {
|
|
|
192
178
|
const { totalHits, timeToExpire, isBlocked, timeToBlockExpire } =
|
|
193
179
|
await this.storageService.increment(key, ttl, limit, blockDuration, throttler.name);
|
|
194
180
|
|
|
195
|
-
const getThrottlerSuffix = (name: string) => (name === 'default' ? '' : `-${name}`);
|
|
196
|
-
|
|
197
181
|
// Throw an error when the user reached their limit.
|
|
198
182
|
if (isBlocked) {
|
|
199
183
|
await this.throwThrottlingException(context, {
|
|
@@ -213,18 +197,18 @@ export class WsThrottlerGuard extends ThrottlerGuard {
|
|
|
213
197
|
}
|
|
214
198
|
```
|
|
215
199
|
|
|
216
|
-
>
|
|
200
|
+
> **Hint:** If you are using ws, it is necessary to replace the `_socket` with `conn`.
|
|
217
201
|
|
|
218
202
|
There's a few things to keep in mind when working with WebSockets:
|
|
219
203
|
|
|
220
204
|
- Guard cannot be registered with the `APP_GUARD` or `app.useGlobalGuards()`
|
|
221
205
|
- When a limit is reached, Nest will emit an `exception` event, so make sure there is a listener ready for this
|
|
222
206
|
|
|
223
|
-
>
|
|
207
|
+
> **Hint:** If you are using the `@nestjs/platform-ws` package you can use `client._socket.remoteAddress` instead.
|
|
224
208
|
|
|
225
|
-
|
|
209
|
+
### GraphQL
|
|
226
210
|
|
|
227
|
-
The `ThrottlerGuard` can also be used to work with GraphQL requests. Again, the guard can be extended, but this time the `getRequestResponse` method will be overridden
|
|
211
|
+
The `ThrottlerGuard` can also be used to work with GraphQL requests. Again, the guard can be extended, but this time the `getRequestResponse` method will be overridden:
|
|
228
212
|
|
|
229
213
|
```typescript
|
|
230
214
|
@Injectable()
|
|
@@ -261,7 +245,7 @@ GraphQLModule.forRoot({
|
|
|
261
245
|
});
|
|
262
246
|
```
|
|
263
247
|
|
|
264
|
-
|
|
248
|
+
### Configuration
|
|
265
249
|
|
|
266
250
|
The following options are valid for the object passed to the array of the `ThrottlerModule`'s options:
|
|
267
251
|
|
|
@@ -280,7 +264,7 @@ The following options are valid for the object passed to the array of the `Throt
|
|
|
280
264
|
</tr>
|
|
281
265
|
<tr>
|
|
282
266
|
<td><code>blockDuration</code></td>
|
|
283
|
-
<td>the number of milliseconds
|
|
267
|
+
<td>the number of milliseconds the request will be blocked</td>
|
|
284
268
|
</tr>
|
|
285
269
|
<tr>
|
|
286
270
|
<td><code>ignoreUserAgents</code></td>
|
|
@@ -292,11 +276,11 @@ The following options are valid for the object passed to the array of the `Throt
|
|
|
292
276
|
</tr>
|
|
293
277
|
<tr>
|
|
294
278
|
<td><code>getTracker</code></td>
|
|
295
|
-
<td>a function that takes in the <code>Request</code> and returns a <code>string</code> to override the default logic of the <code>getTracker</code> method</td>
|
|
279
|
+
<td>a function that takes in the <code>Request</code> and <code>ExecutionContext</code>, and returns a <code>string</code> to override the default logic of the <code>getTracker</code> method</td>
|
|
296
280
|
</tr>
|
|
297
281
|
<tr>
|
|
298
282
|
<td><code>generateKey</code></td>
|
|
299
|
-
<td>a function that takes in the <code>ExecutionContext</code>, the
|
|
283
|
+
<td>a function that takes in the <code>ExecutionContext</code>, the tracker <code>string</code> and the throttler name as a <code>string</code> and returns a <code>string</code> to override the final key which will be used to store the rate limit value. This overrides the default logic of the <code>generateKey</code> method</td>
|
|
300
284
|
</tr>
|
|
301
285
|
</table>
|
|
302
286
|
|
|
@@ -305,7 +289,7 @@ If you need to set up storages instead, or want to use a some of the above optio
|
|
|
305
289
|
<table>
|
|
306
290
|
<tr>
|
|
307
291
|
<td><code>storage</code></td>
|
|
308
|
-
<td>a custom storage service for where the throttling should be kept track. <a href="
|
|
292
|
+
<td>a custom storage service for where the throttling should be kept track. <a href="#storages">See Storages below.</a></td>
|
|
309
293
|
</tr>
|
|
310
294
|
<tr>
|
|
311
295
|
<td><code>ignoreUserAgents</code></td>
|
|
@@ -325,11 +309,11 @@ If you need to set up storages instead, or want to use a some of the above optio
|
|
|
325
309
|
</tr>
|
|
326
310
|
<tr>
|
|
327
311
|
<td><code>getTracker</code></td>
|
|
328
|
-
<td>a function that takes in the <code>Request</code> and returns a <code>string</code> to override the default logic of the <code>getTracker</code> method</td>
|
|
312
|
+
<td>a function that takes in the <code>Request</code> and <code>ExecutionContext</code>, and returns a <code>string</code> to override the default logic of the <code>getTracker</code> method</td>
|
|
329
313
|
</tr>
|
|
330
314
|
<tr>
|
|
331
315
|
<td><code>generateKey</code></td>
|
|
332
|
-
<td>a function that takes in the <code>ExecutionContext</code>, the
|
|
316
|
+
<td>a function that takes in the <code>ExecutionContext</code>, the tracker <code>string</code> and the throttler name as a <code>string</code> and returns a <code>string</code> to override the final key which will be used to store the rate limit value. This overrides the default logic of the <code>generateKey</code> method</td>
|
|
333
317
|
</tr>
|
|
334
318
|
</table>
|
|
335
319
|
|
|
@@ -373,40 +357,34 @@ export class AppModule {}
|
|
|
373
357
|
|
|
374
358
|
This is doable, as long as `ThrottlerConfigService` implements the interface `ThrottlerOptionsFactory`.
|
|
375
359
|
|
|
376
|
-
|
|
360
|
+
### Storages
|
|
377
361
|
|
|
378
362
|
The built in storage is an in memory cache that keeps track of the requests made until they have passed the TTL set by the global options. You can drop in your own storage option to the `storage` option of the `ThrottlerModule` so long as the class implements the `ThrottlerStorage` interface.
|
|
379
363
|
|
|
380
|
-
>
|
|
364
|
+
> **Note:** `ThrottlerStorage` can be imported from `@nestjs/throttler`.
|
|
381
365
|
|
|
382
|
-
|
|
366
|
+
### Time Helpers
|
|
383
367
|
|
|
384
368
|
There are a couple of helper methods to make the timings more readable if you prefer to use them over the direct definition. `@nestjs/throttler` exports five different helpers, `seconds`, `minutes`, `hours`, `days`, and `weeks`. To use them, simply call `seconds(5)` or any of the other helpers, and the correct number of milliseconds will be returned.
|
|
385
369
|
|
|
386
|
-
|
|
370
|
+
### Migrating to v5 from earlier versions
|
|
387
371
|
|
|
388
|
-
|
|
372
|
+
If you migrate to v5 from earlier versions, you need to wrap your options in an array.
|
|
389
373
|
|
|
390
|
-
If you are using a custom storage, you should wrap you `ttl` and `limit` in an
|
|
391
|
-
array and assign it to the `throttlers` property of the options object.
|
|
374
|
+
If you are using a custom storage, you should wrap you `ttl` and `limit` in an array and assign it to the `throttlers` property of the options object.
|
|
392
375
|
|
|
393
|
-
Any `@ThrottleSkip()` should now take in an object with `string: boolean` props.
|
|
394
|
-
The strings are the names of the throttlers. If you do not have a name, pass the
|
|
395
|
-
string `'default'`, as this is what will be used under the hood otherwise.
|
|
376
|
+
Any `@ThrottleSkip()` should now take in an object with `string: boolean` props. The strings are the names of the throttlers. If you do not have a name, pass the string `'default'`, as this is what will be used under the hood otherwise.
|
|
396
377
|
|
|
397
|
-
Any `@Throttle()` decorators should also now take in an object with string keys,
|
|
398
|
-
relating to the names of the throttler contexts (again, `'default'` if no name)
|
|
399
|
-
and values of objects that have `limit` and `ttl` keys.
|
|
378
|
+
Any `@Throttle()` decorators should also now take in an object with string keys, relating to the names of the throttler contexts (again, `'default'` if no name) and values of objects that have `limit` and `ttl` keys.
|
|
400
379
|
|
|
401
|
-
>
|
|
402
|
-
> in seconds for readability, use the `seconds` helper from this package. It just
|
|
403
|
-
> multiplies the ttl by 1000 to make it in milliseconds.
|
|
380
|
+
> **Important:** The `ttl` is now in **milliseconds**. If you want to keep your ttl in seconds for readability, use the `seconds` helper from this package. It just multiplies the ttl by 1000 to make it in milliseconds.
|
|
404
381
|
|
|
405
382
|
For more info, see the [Changelog](https://github.com/nestjs/throttler/blob/master/CHANGELOG.md#500)
|
|
406
383
|
|
|
407
384
|
## Community Storage Providers
|
|
408
385
|
|
|
409
|
-
- [Redis](https://github.com/
|
|
386
|
+
- [Redis](https://github.com/CSenshi/nestjs-redis/tree/main/packages/throttler-storage) (`node-redis` based)
|
|
387
|
+
- [Redis](https://github.com/jmcdo29/nest-lab/tree/main/packages/throttler-storage-redis) (`ioredis` based)
|
|
410
388
|
- [Mongo](https://www.npmjs.com/package/nestjs-throttler-storage-mongo)
|
|
411
389
|
|
|
412
390
|
Feel free to submit a PR with your custom storage provider being added to this list.
|
|
@@ -11,15 +11,17 @@ export interface ThrottlerOptions {
|
|
|
11
11
|
skipIf?: (context: ExecutionContext) => boolean;
|
|
12
12
|
getTracker?: ThrottlerGetTrackerFunction;
|
|
13
13
|
generateKey?: ThrottlerGenerateKeyFunction;
|
|
14
|
+
setHeaders?: boolean;
|
|
14
15
|
}
|
|
15
16
|
export type ThrottlerModuleOptions = Array<ThrottlerOptions> | {
|
|
16
|
-
skipIf?: (context: ExecutionContext) => boolean;
|
|
17
17
|
ignoreUserAgents?: RegExp[];
|
|
18
|
+
skipIf?: (context: ExecutionContext) => boolean;
|
|
18
19
|
getTracker?: ThrottlerGetTrackerFunction;
|
|
19
20
|
generateKey?: ThrottlerGenerateKeyFunction;
|
|
20
21
|
errorMessage?: string | ((context: ExecutionContext, throttlerLimitDetail: ThrottlerLimitDetail) => string);
|
|
21
22
|
storage?: ThrottlerStorage;
|
|
22
23
|
throttlers: Array<ThrottlerOptions>;
|
|
24
|
+
setHeaders?: boolean;
|
|
23
25
|
};
|
|
24
26
|
export interface ThrottlerOptionsFactory {
|
|
25
27
|
createThrottlerOptions(): Promise<ThrottlerModuleOptions> | ThrottlerModuleOptions;
|
|
@@ -10,7 +10,7 @@ export declare class ThrottlerGuard implements CanActivate {
|
|
|
10
10
|
protected headerPrefix: string;
|
|
11
11
|
protected errorMessage: string;
|
|
12
12
|
protected throttlers: Array<ThrottlerOptions>;
|
|
13
|
-
protected commonOptions: Pick<ThrottlerOptions, 'skipIf' | 'ignoreUserAgents' | 'getTracker' | 'generateKey'>;
|
|
13
|
+
protected commonOptions: Pick<ThrottlerOptions, 'skipIf' | 'ignoreUserAgents' | 'getTracker' | 'generateKey' | 'setHeaders'>;
|
|
14
14
|
constructor(options: ThrottlerModuleOptions, storageService: ThrottlerStorage, reflector: Reflector);
|
|
15
15
|
onModuleInit(): Promise<void>;
|
|
16
16
|
canActivate(context: ExecutionContext): Promise<boolean>;
|
package/dist/throttler.guard.js
CHANGED
|
@@ -51,6 +51,7 @@ let ThrottlerGuard = class ThrottlerGuard {
|
|
|
51
51
|
ignoreUserAgents: this.options.ignoreUserAgents,
|
|
52
52
|
getTracker: this.options.getTracker,
|
|
53
53
|
generateKey: this.options.generateKey,
|
|
54
|
+
setHeaders: this.options.setHeaders,
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
(_a = (_c = this.commonOptions).getTracker) !== null && _a !== void 0 ? _a : (_c.getTracker = this.getTracker.bind(this));
|
|
@@ -99,7 +100,7 @@ let ThrottlerGuard = class ThrottlerGuard {
|
|
|
99
100
|
return false;
|
|
100
101
|
}
|
|
101
102
|
async handleRequest(requestProps) {
|
|
102
|
-
var _a;
|
|
103
|
+
var _a, _b, _c;
|
|
103
104
|
const { context, limit, ttl, throttler, blockDuration, getTracker, generateKey } = requestProps;
|
|
104
105
|
const { req, res } = this.getRequestResponse(context);
|
|
105
106
|
const ignoreUserAgents = (_a = throttler.ignoreUserAgents) !== null && _a !== void 0 ? _a : this.commonOptions.ignoreUserAgents;
|
|
@@ -114,8 +115,11 @@ let ThrottlerGuard = class ThrottlerGuard {
|
|
|
114
115
|
const key = generateKey(context, tracker, throttler.name);
|
|
115
116
|
const { totalHits, timeToExpire, isBlocked, timeToBlockExpire } = await this.storageService.increment(key, ttl, limit, blockDuration, throttler.name);
|
|
116
117
|
const getThrottlerSuffix = (name) => (name === 'default' ? '' : `-${name}`);
|
|
118
|
+
const setHeaders = (_c = (_b = throttler.setHeaders) !== null && _b !== void 0 ? _b : this.commonOptions.setHeaders) !== null && _c !== void 0 ? _c : true;
|
|
117
119
|
if (isBlocked) {
|
|
118
|
-
|
|
120
|
+
if (setHeaders) {
|
|
121
|
+
res.header(`Retry-After${getThrottlerSuffix(throttler.name)}`, timeToBlockExpire);
|
|
122
|
+
}
|
|
119
123
|
await this.throwThrottlingException(context, {
|
|
120
124
|
limit,
|
|
121
125
|
ttl,
|
|
@@ -127,9 +131,11 @@ let ThrottlerGuard = class ThrottlerGuard {
|
|
|
127
131
|
timeToBlockExpire,
|
|
128
132
|
});
|
|
129
133
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
if (setHeaders) {
|
|
135
|
+
res.header(`${this.headerPrefix}-Limit${getThrottlerSuffix(throttler.name)}`, limit);
|
|
136
|
+
res.header(`${this.headerPrefix}-Remaining${getThrottlerSuffix(throttler.name)}`, Math.max(0, limit - totalHits));
|
|
137
|
+
res.header(`${this.headerPrefix}-Reset${getThrottlerSuffix(throttler.name)}`, timeToExpire);
|
|
138
|
+
}
|
|
133
139
|
return true;
|
|
134
140
|
}
|
|
135
141
|
async getTracker(req) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttler.guard.js","sourceRoot":"","sources":["../src/throttler.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2E;AAC3E,uCAAyC;AACzC,iCAAgC;AAQhC,+EAAiE;AACjE,+DAO+B;AAC/B,+DAAuF;AACvF,+DAA6E;AAOtE,IAAM,cAAc,GAApB,MAAM,cAAc;IASzB,YAC4B,OAAkD,EAClD,cAAmD,EAC1D,SAAoB;QAFM,YAAO,GAAP,OAAO,CAAwB;QAC/B,mBAAc,GAAd,cAAc,CAAkB;QAC1D,cAAS,GAAT,SAAS,CAAW;QAX/B,iBAAY,GAAG,aAAa,CAAC;QAC7B,iBAAY,GAAG,sCAAgB,CAAC;IAWvC,CAAC;IAEJ,KAAK,CAAC,YAAY;;;QAChB,IAAI,CAAC,UAAU,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;aACrF,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YACtB,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;gBACpC,OAAO,CAAC,CAAC;YACX,CAAC;YACD,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;gBACrC,OAAO,CAAC,CAAC;YACX,CAAC;YACD,OAAO,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC;aACD,GAAG,CA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