@adminforth/upload 2.3.2 → 2.3.3

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/build.log CHANGED
@@ -11,5 +11,5 @@ custom/preview.vue
11
11
  custom/tsconfig.json
12
12
  custom/uploader.vue
13
13
 
14
- sent 46,947 bytes received 134 bytes 94,162.00 bytes/sec
14
+ sent 46,954 bytes received 134 bytes 94,176.00 bytes/sec
15
15
  total size is 46,465 speedup is 0.99
package/dist/index.js CHANGED
@@ -307,8 +307,13 @@ export default class UploadPlugin extends AdminForthPlugin {
307
307
  const { prompt, recordId } = body;
308
308
  if ((_b = this.options.generation.rateLimit) === null || _b === void 0 ? void 0 : _b.limit) {
309
309
  // rate limit
310
- const { error } = RateLimiter.checkRateLimit(this.pluginInstanceId, (_c = this.options.generation.rateLimit) === null || _c === void 0 ? void 0 : _c.limit, this.adminforth.auth.getClientIp(headers));
311
- if (error) {
310
+ // const { error } = RateLimiter.checkRateLimit(
311
+ // this.pluginInstanceId,
312
+ // this.options.generation.rateLimit?.limit,
313
+ // this.adminforth.auth.getClientIp(headers),
314
+ // );
315
+ const rateLimiter = new RateLimiter((_c = this.options.generation.rateLimit) === null || _c === void 0 ? void 0 : _c.limit);
316
+ if (!rateLimiter.consume(`${this.pluginInstanceId}-${this.adminforth.auth.getClientIp(headers)}`)) {
312
317
  return { error: this.options.generation.rateLimit.errorMessage };
313
318
  }
314
319
  }
package/index.ts CHANGED
@@ -346,12 +346,13 @@ export default class UploadPlugin extends AdminForthPlugin {
346
346
  const { prompt, recordId } = body;
347
347
  if (this.options.generation.rateLimit?.limit) {
348
348
  // rate limit
349
- const { error } = RateLimiter.checkRateLimit(
350
- this.pluginInstanceId,
351
- this.options.generation.rateLimit?.limit,
352
- this.adminforth.auth.getClientIp(headers),
353
- );
354
- if (error) {
349
+ // const { error } = RateLimiter.checkRateLimit(
350
+ // this.pluginInstanceId,
351
+ // this.options.generation.rateLimit?.limit,
352
+ // this.adminforth.auth.getClientIp(headers),
353
+ // );
354
+ const rateLimiter = new RateLimiter(this.options.generation.rateLimit?.limit);
355
+ if (!rateLimiter.consume(`${this.pluginInstanceId}-${this.adminforth.auth.getClientIp(headers)}`)) {
355
356
  return { error: this.options.generation.rateLimit.errorMessage };
356
357
  }
357
358
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/upload",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "description": "Plugin for uploading files for adminforth",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,7 +21,8 @@
21
21
  "license": "ISC",
22
22
  "dependencies": {
23
23
  "@aws-sdk/client-s3": "^3.629.0",
24
- "@aws-sdk/s3-request-presigner": "^3.629.0"
24
+ "@aws-sdk/s3-request-presigner": "^3.629.0",
25
+ "adminforth": "^2.4.0-next.222"
25
26
  },
26
27
  "keywords": [
27
28
  "adminforth",