@easy-cms/plugin-form-builder 0.45.0 → 0.46.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.js +10 -41
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -195,50 +195,19 @@ function fieldBlocks(localized, kinds) {
|
|
|
195
195
|
// src/info.ts
|
|
196
196
|
var INFO = {
|
|
197
197
|
name: "@easy-cms/plugin-form-builder",
|
|
198
|
-
...true ? { version: "0.
|
|
198
|
+
...true ? { version: "0.46.0" } : {}
|
|
199
199
|
};
|
|
200
200
|
|
|
201
201
|
// src/spam.ts
|
|
202
|
-
import {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const issued = Number(time);
|
|
212
|
-
if (!Number.isFinite(issued) || !signature) return "invalid";
|
|
213
|
-
const expected = Buffer.from(sign(secret, `easy-form:${slug}:${issued}`));
|
|
214
|
-
const given = Buffer.from(signature);
|
|
215
|
-
if (expected.length !== given.length || !timingSafeEqual(expected, given)) return "invalid";
|
|
216
|
-
if (now - issued < minTime) return "too-fast";
|
|
217
|
-
if (now - issued > MAX_AGE) return "expired";
|
|
218
|
-
return "ok";
|
|
219
|
-
}
|
|
220
|
-
function rateKeys(secret, ip, form, window, now = Date.now()) {
|
|
221
|
-
const bucket = Math.floor(now / (window * 1e3));
|
|
222
|
-
const key = (b) => sign(secret, `easy-form-rate:${ip}:${String(form)}:${b}`).slice(0, 32);
|
|
223
|
-
return { current: key(bucket), previous: key(bucket - 1) };
|
|
224
|
-
}
|
|
225
|
-
function honeypotName(names) {
|
|
226
|
-
return ["website", "homepage", "url_address"].find((n) => !names.includes(n)) ?? "hp_field";
|
|
227
|
-
}
|
|
228
|
-
async function verifyTurnstile(secretKey, response, ip, fetcher = fetch) {
|
|
229
|
-
if (typeof response !== "string" || !response) return false;
|
|
230
|
-
const body = new URLSearchParams({ secret: secretKey, response, ...ip ? { remoteip: ip } : {} });
|
|
231
|
-
try {
|
|
232
|
-
const result = await fetcher("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
|
|
233
|
-
method: "POST",
|
|
234
|
-
body,
|
|
235
|
-
signal: AbortSignal.timeout(1e4)
|
|
236
|
-
});
|
|
237
|
-
return (await result.json()).success === true;
|
|
238
|
-
} catch {
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
202
|
+
import {
|
|
203
|
+
checkFormToken,
|
|
204
|
+
formToken as coreFormToken,
|
|
205
|
+
rateKeys as coreRateKeys
|
|
206
|
+
} from "@easy-cms/core";
|
|
207
|
+
import { honeypotName, verifyTurnstile } from "@easy-cms/core";
|
|
208
|
+
var formToken = (secret, slug, now = Date.now()) => coreFormToken(secret, `easy-form:${slug}`, now);
|
|
209
|
+
var checkToken = (secret, slug, token, minTime, now = Date.now()) => checkFormToken(secret, `easy-form:${slug}`, token, minTime, now);
|
|
210
|
+
var rateKeys = (secret, ip, form, window, now = Date.now()) => coreRateKeys(secret, `easy-form-rate:${ip}:${String(form)}`, window, now);
|
|
242
211
|
|
|
243
212
|
// src/validate.ts
|
|
244
213
|
var MESSAGES = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-cms/plugin-form-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.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.46.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@easy-cms/core": "^0.
|
|
29
|
+
"@easy-cms/core": "^0.46.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.46.0",
|
|
34
|
+
"@easy-cms/db-sqlite": "^0.46.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=22.12"
|