@easy-cms/plugin-form-builder 0.63.0 → 0.65.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/dist/index.d.ts +1 -1
- package/dist/index.js +12 -4
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ interface FormBuilderPluginOptions {
|
|
|
11
11
|
readonly defaultTo?: string | readonly string[];
|
|
12
12
|
/**
|
|
13
13
|
* Submissions allowed per visitor (by IP address) and form in `window` seconds. Default
|
|
14
|
-
* 5 in 600. `false` turns it off.
|
|
14
|
+
* 5 in 600. Without the client's IP, all visitors share ten times `max`. `false` turns it off.
|
|
15
15
|
*/
|
|
16
16
|
readonly rateLimit?: {
|
|
17
17
|
readonly max?: number;
|
package/dist/index.js
CHANGED
|
@@ -197,7 +197,7 @@ var INFO = {
|
|
|
197
197
|
name: "@easy-cms/plugin-form-builder",
|
|
198
198
|
// The plugin API it is written for (`PLUGIN_API_VERSION` of @easy-cms/core).
|
|
199
199
|
apiVersion: 1,
|
|
200
|
-
...true ? { version: "0.
|
|
200
|
+
...true ? { version: "0.65.0" } : {}
|
|
201
201
|
};
|
|
202
202
|
|
|
203
203
|
// src/spam.ts
|
|
@@ -334,6 +334,7 @@ function formBuilderPlugin(options = {}) {
|
|
|
334
334
|
const locales = (config.localization || void 0)?.locales ?? [];
|
|
335
335
|
const defaultLocale = (config.localization || void 0)?.defaultLocale ?? locales[0] ?? null;
|
|
336
336
|
const rate = options.rateLimit === false ? null : { max: 5, window: 600, ...options.rateLimit };
|
|
337
|
+
let warnedNoIp = false;
|
|
337
338
|
const minTime = (options.minSubmitSeconds ?? 2) * 1e3;
|
|
338
339
|
const defaultTo = options.defaultTo === void 0 ? [] : typeof options.defaultTo === "string" ? [options.defaultTo] : [...options.defaultTo];
|
|
339
340
|
const loggedIn = ({ user }) => !!user;
|
|
@@ -590,8 +591,15 @@ function formBuilderPlugin(options = {}) {
|
|
|
590
591
|
}
|
|
591
592
|
]);
|
|
592
593
|
let rateKey;
|
|
593
|
-
if (rate
|
|
594
|
-
|
|
594
|
+
if (rate) {
|
|
595
|
+
if (!ip && !warnedNoIp) {
|
|
596
|
+
warnedNoIp = true;
|
|
597
|
+
cms.logger.warn(
|
|
598
|
+
"formBuilderPlugin: the client IP is unknown, so form rate limits count all visitors together. Set trustProxy behind a proxy."
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
const keys = rateKeys(secret, ip ?? "unknown", form.id, rate.window);
|
|
602
|
+
const max = ip ? rate.max : rate.max * 10;
|
|
595
603
|
const since = new Date(Date.now() - rate.window * 1e3).toISOString();
|
|
596
604
|
const recent = await cms.count(submissions, {
|
|
597
605
|
where: {
|
|
@@ -602,7 +610,7 @@ function formBuilderPlugin(options = {}) {
|
|
|
602
610
|
]
|
|
603
611
|
}
|
|
604
612
|
});
|
|
605
|
-
if (recent >=
|
|
613
|
+
if (recent >= max)
|
|
606
614
|
return fail(429, [
|
|
607
615
|
{
|
|
608
616
|
message: locale === "th" ? "\u0E2A\u0E48\u0E07\u0E1A\u0E48\u0E2D\u0E22\u0E40\u0E01\u0E34\u0E19\u0E44\u0E1B \u0E42\u0E1B\u0E23\u0E14\u0E23\u0E2D\u0E2A\u0E31\u0E01\u0E04\u0E23\u0E39\u0E48\u0E41\u0E25\u0E49\u0E27\u0E25\u0E2D\u0E07\u0E43\u0E2B\u0E21\u0E48" : "Too many submissions: wait a few minutes and try again"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-cms/plugin-form-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"description": "Forms for Easy CMS: build forms in the admin, collect submissions, email notifications, spam protection and an <easy-form> element",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@easy-cms/richtext": "^0.
|
|
26
|
+
"@easy-cms/richtext": "^0.65.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@easy-cms/core": "^0.
|
|
29
|
+
"@easy-cms/core": "^0.65.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"happy-dom": "^20.14.5",
|
|
33
|
-
"@easy-cms/core": "^0.
|
|
34
|
-
"@easy-cms/db-sqlite": "^0.
|
|
33
|
+
"@easy-cms/core": "^0.65.0",
|
|
34
|
+
"@easy-cms/db-sqlite": "^0.65.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=22.12"
|