@sharadox/form-web-library 0.8.3 → 0.9.0-development.65
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 +4 -0
- package/LICENSE.md +14 -69
- package/README.md +29 -14
- package/distribution/bot-identification/index.d.ts +12 -0
- package/distribution/bot-identification/index.d.ts.map +1 -0
- package/distribution/bot-identification/index.js +17 -0
- package/distribution/bot-identification/index.js.map +1 -0
- package/distribution/bot-identification/type.d.ts +17 -0
- package/distribution/bot-identification/type.d.ts.map +1 -0
- package/distribution/bot-identification/type.js +2 -0
- package/distribution/bot-identification/type.js.map +1 -0
- package/distribution/calling-code/index.d.ts +1 -1
- package/distribution/calling-code/index.js +1 -1
- package/distribution/contact-action/index.d.ts +3 -2
- package/distribution/contact-action/index.d.ts.map +1 -1
- package/distribution/contact-action/index.js +14 -2
- package/distribution/contact-action/index.js.map +1 -1
- package/distribution/contact-action/type.d.ts +6 -0
- package/distribution/contact-action/type.d.ts.map +1 -1
- package/distribution/form-protection/index.d.ts +14 -0
- package/distribution/form-protection/index.d.ts.map +1 -0
- package/distribution/form-protection/index.js +18 -0
- package/distribution/form-protection/index.js.map +1 -0
- package/distribution/form-protection/type.d.ts +17 -0
- package/distribution/form-protection/type.d.ts.map +1 -0
- package/distribution/form-protection/type.js +2 -0
- package/distribution/form-protection/type.js.map +1 -0
- package/llms.txt +3 -1
- package/package.json +6 -6
- package/source/license/english.md +76 -0
- package/{LICENCA.md → source/license/portuguese.md} +4 -4
- package/NOTICE.md +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
What changed in each version of `@sharadox/form-web-library`, newest first.
|
|
4
4
|
|
|
5
|
+
## 0.9.0
|
|
6
|
+
|
|
7
|
+
Vercel BotID for contact forms: protectFormSubmissions (form-protection) starts BotID in the browser for the form submissions to the given paths (on Vercel only), isUnwantedBot (bot-identification) asks BotID's free Basic check on the server (verified bots get through), and createContactAction refuses what BotID calls a bot like a failed sending, before rate limits, sending nothing (option isUnwantedBot). The honeypot and fill-time checks stay.
|
|
8
|
+
|
|
5
9
|
## 0.8.3
|
|
6
10
|
|
|
7
11
|
Workflows from git-hub-action-library v0.2.2: npm Trusted Publishing only
|
package/LICENSE.md
CHANGED
|
@@ -1,76 +1,21 @@
|
|
|
1
|
-
# Sharadox Open Source License
|
|
1
|
+
# Licença Sharadox de Código Aberto · Sharadox Open Source License
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Direitos de autor © 2026 Micael Pires (Sharadox).\
|
|
4
|
+
Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.2.0.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Copyright © 2026 Micael Pires (Sharadox).\
|
|
7
|
+
Licensed under the Sharadox Open Source License, version 0.2.0.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
O texto em português é o original e o único vinculativo; a tradução para inglês existe apenas por conveniência.\
|
|
10
|
+
The Portuguese text is the original and the only binding one; the English translation is for convenience only.
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
- [Português (texto vinculativo)](source/license/portuguese.md)
|
|
13
|
+
- [English (translation)](source/license/english.md)
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
2. **"Licensor"** — the copyright holder identified in the copyright notice that accompanies the Work.
|
|
13
|
-
3. **"Licensee"** — any natural or legal person exercising the rights granted by this license.
|
|
14
|
-
4. **"Derivative Work"** — any work based on or incorporating the Work, in whole or in part, with or without modifications, including translations, adaptations and programs that integrate it.
|
|
15
|
-
5. **"Notice"** — the Licensor's copyright notice and the statement that the Work is licensed under this license, including its version.
|
|
16
|
-
|
|
17
|
-
## 2. Grant of rights
|
|
18
|
-
|
|
19
|
-
1. Under this license, the Licensor grants the Licensee a worldwide, royalty-free, non-exclusive license, for the whole term of copyright protection, to:
|
|
20
|
-
1. use the Work for any purpose, including commercial purposes;
|
|
21
|
-
2. reproduce the Work, in whole or in part, by any means and in any form;
|
|
22
|
-
3. modify, translate, adapt and transform the Work and create Derivative Works;
|
|
23
|
-
4. distribute, publish, communicate to the public, make available, sell and sublicense the Work and Derivative Works.
|
|
24
|
-
2. To the extent the Licensor holds patents necessarily infringed by the Work as made available by it, the Licensor also grants the Licensee, on the same terms, a license to use those patents in exercising the rights in the previous paragraph.
|
|
25
|
-
3. This license does not transfer ownership of any rights, which remain with the Licensor.
|
|
26
|
-
|
|
27
|
-
## 3. Conditions
|
|
28
|
-
|
|
29
|
-
The exercise of the rights granted is subject to the following conditions:
|
|
30
|
-
|
|
31
|
-
1. Every copy of the Work, or of substantial parts of it, and every distributed Derivative Work must include the Notice and a copy of this license or a stable link to its text.
|
|
32
|
-
2. Anyone distributing a modified version of the Work must state visibly that it has been modified and may not present it as the Licensor's original version.
|
|
33
|
-
3. The Licensee may license their own modifications under other terms, provided the part of the Work included in them remains subject to the conditions of this license.
|
|
34
|
-
|
|
35
|
-
## 4. Names and trademarks
|
|
36
|
-
|
|
37
|
-
This license grants no rights to the Licensor's name, trademarks, logos or other distinctive signs, including the name "Sharadox", except as strictly necessary to comply with the duty to include the Notice. Using them to promote or suggest the Licensor's endorsement of Derivative Works or of any products or services without prior written permission is prohibited.
|
|
38
|
-
|
|
39
|
-
## 5. Disclaimer of warranties
|
|
40
|
-
|
|
41
|
-
The Work is provided "as is" and "as available", without any warranty, express or implied, including in particular warranties of merchantability, fitness for a particular purpose, absence of errors or non-infringement of third-party rights, to the maximum extent permitted by applicable law.
|
|
42
|
-
|
|
43
|
-
## 6. Limitation of liability
|
|
44
|
-
|
|
45
|
-
1. To the maximum extent permitted by applicable law, the Licensor is not liable for any damages, direct or indirect, including loss of profits, loss of data or business interruption, arising from the use of or inability to use the Work, even if advised of the possibility of such damages.
|
|
46
|
-
2. Nothing in this license excludes or limits the Licensor's liability where such exclusion or limitation is not permitted by law, in particular for acts committed with intent or gross negligence, under article 809 and article 800(2) of the Portuguese Civil Code, nor does it affect rights that the law mandatorily grants to consumers.
|
|
47
|
-
|
|
48
|
-
## 7. Termination
|
|
49
|
-
|
|
50
|
-
1. The rights granted by this license terminate automatically if the Licensee breaches any of its conditions.
|
|
51
|
-
2. The rights are reinstated if the breach is remedied within 30 days of the Licensee becoming aware of it, unless the Licensor has meanwhile objected in writing.
|
|
52
|
-
3. Termination does not affect licenses validly granted by the Licensee to third parties who comply with this license.
|
|
53
|
-
|
|
54
|
-
## 8. Governing law and jurisdiction
|
|
55
|
-
|
|
56
|
-
1. This license is governed by Portuguese law, in particular the Code of Copyright and Related Rights, approved by Decree-Law no. 63/85 of 14 March, and Decree-Law no. 252/94 of 20 October on the legal protection of computer programs.
|
|
57
|
-
2. The Judicial Court of the District of Faro has jurisdiction over any dispute arising from this license, without prejudice to applicable mandatory rules of jurisdiction, in particular those protecting consumers.
|
|
58
|
-
|
|
59
|
-
## 9. License versions
|
|
60
|
-
|
|
61
|
-
The Licensor may publish new versions of this license, identified by a version number. The Work is subject to the version stated in the Notice. If the Notice allows it, the Licensee may choose any later version.
|
|
62
|
-
|
|
63
|
-
## 10. Final provisions
|
|
64
|
-
|
|
65
|
-
1. If any provision of this license is held invalid or unenforceable, the remaining provisions stay in force, and the affected provision shall be interpreted as closely as possible to its original intent.
|
|
66
|
-
2. Failure to enforce any provision of this license at any time does not waive the right to enforce it later.
|
|
67
|
-
|
|
68
|
-
## How to apply this license
|
|
15
|
+
https://github.com/Sharadox/sharadox-open-source-license
|
|
69
16
|
|
|
70
|
-
|
|
17
|
+
## Avisos de terceiros · Third-party notices
|
|
71
18
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
https://github.com/Sharadox/sharadox-open-source-license
|
|
76
|
-
```
|
|
19
|
+
Os indicativos internacionais (`source/calling-code`) vêm dos metadados da libphonenumber, da Google, sob a licença Apache 2.0:
|
|
20
|
+
The international calling codes (`source/calling-code`) come from Google's libphonenumber metadata, under the Apache License 2.0:
|
|
21
|
+
https://github.com/google/libphonenumber · https://www.apache.org/licenses/LICENSE-2.0
|
package/README.md
CHANGED
|
@@ -4,14 +4,15 @@ Forms, written once for every site.
|
|
|
4
4
|
|
|
5
5
|
In the browser:
|
|
6
6
|
|
|
7
|
+
- **Bot protection for form submissions (`form-protection`):** starts Vercel BotID for the requests a form sends (a server action posts to its page's path), so the server can tell people from bots without a puzzle. Pages stay open to everyone, search engines and AI crawlers included.
|
|
7
8
|
- **A phone field (`phone-field`):** a button with the country's flag and calling code opens a searchable list of every country, named in the page's language, and the number box beside it takes digits only. Pasting "+44…" or "0044…" picks the country. The form receives one field with "+351 912345678". Its colors come from the text and the `--phone-field-*` variables (`-line`, `-accent`, `-surface`, `-popover`, `-radius`, `-gap`). Flags come from `@sharadox/icon-web-library` and load on their own, after the field.
|
|
8
9
|
|
|
9
10
|
On the server:
|
|
10
11
|
|
|
11
12
|
- **Field reading:** trimmed and capped in length.
|
|
12
|
-
- **Bot checks:** a hidden honeypot field, and a minimum time to fill the form.
|
|
13
|
+
- **Bot checks:** Vercel BotID's free Basic check (`bot-identification`; verified bots, agents acting for someone, get through), a hidden honeypot field, and a minimum time to fill the form.
|
|
13
14
|
- **Rate limiting:** a sliding window per key.
|
|
14
|
-
- **A contact form action:** it validates, fakes success for bots, limits each address and everyone together per day (50 emails by default, `dailyMaximum`, so a flood from many addresses can't run up the email bill), and emails the message in text and HTML with the visitor as reply-to, through `@sharadox/email-web-library`.
|
|
15
|
+
- **A contact form action:** it validates, fakes success for bots caught by the honeypot or the fill time, refuses what BotID calls a bot like a failed sending (nothing sent, nothing counted; a person it got wrong still sees the company's address), limits each address and everyone together per day (50 emails by default, `dailyMaximum`, so a flood from many addresses can't run up the email bill), and emails the message in text and HTML with the visitor as reply-to, through `@sharadox/email-web-library`.
|
|
15
16
|
- **Options per site:**
|
|
16
17
|
- accept a phone instead of an email (`reach: "email-or-phone"`)
|
|
17
18
|
- make the message optional (`requireMessage: false`) or ask for a longer one (`minimumMessageLength`)
|
|
@@ -72,6 +73,18 @@ export async function sendContactAction(_: ContactState, form: FormData) {
|
|
|
72
73
|
}
|
|
73
74
|
```
|
|
74
75
|
|
|
76
|
+
Protect the form's submissions in the site's `src/instrumentation-client.ts`, one path for each page that has the form
|
|
77
|
+
(the server action posts to the page it runs on). Without it, BotID calls every submission a bot. It works on Vercel
|
|
78
|
+
only (a local or continuous integration `next start` skips BotID on both sides), needs no Next.js configuration
|
|
79
|
+
wrapper (Vercel routes BotID's requests itself), and uses Basic only: never turn on Deep Analysis, which is paid.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
// src/instrumentation-client.ts
|
|
83
|
+
import { protectFormSubmissions } from "@sharadox/form-web-library/form-protection";
|
|
84
|
+
|
|
85
|
+
protectFormSubmissions(["/en", "/pt"]); // the pages with the contact form
|
|
86
|
+
```
|
|
87
|
+
|
|
75
88
|
The form sends these fields:
|
|
76
89
|
|
|
77
90
|
- **text:** `name`, `email`, `phone`, `company`, `message`, plus any `fields` the site adds
|
|
@@ -83,17 +96,19 @@ The email server comes from `EMAIL_SERVER_*` and `EMAIL_SENDER_ADDRESS`.
|
|
|
83
96
|
|
|
84
97
|
## API
|
|
85
98
|
|
|
86
|
-
| Import
|
|
87
|
-
|
|
|
88
|
-
| `…/contact-problem`
|
|
89
|
-
| `…/choice-request`
|
|
90
|
-
| `…/bot-field`
|
|
91
|
-
| `…/contact-action`
|
|
92
|
-
| `…/parse-contact`
|
|
93
|
-
| `…/contact-check`
|
|
94
|
-
| `…/
|
|
95
|
-
| `…/
|
|
96
|
-
| `…/
|
|
99
|
+
| Import | Export |
|
|
100
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
101
|
+
| `…/contact-problem` | `contactProblems({ name, email, phone })`: what a form's contact details still lack |
|
|
102
|
+
| `…/choice-request` | `requestChoices(event, choices)`, `useChoiceRequests(event, onRequest)`: a button elsewhere asks the form to tick choices |
|
|
103
|
+
| `…/bot-field` | `<BotFields />`: the honeypot and fill-time fields `isLikelyBot` reads |
|
|
104
|
+
| `…/contact-action` | `createContactAction(options)` → `(form, ip) => Promise<ContactState>`; `ENGLISH_LABELS`, `PORTUGUESE_LABELS`, `CONTACT_LABELS`, `plainDesign(company)`, `textIn(text, locale)`; `ContactState`, `ContactActionOptions`, `ContactLabels`, `ContactText` and `EmailLogo` in `…/contact-action/type` |
|
|
105
|
+
| `…/parse-contact` | `parseContact(form, { choices?, choiceField?, reach?, requireMessage?, minimumMessageLength?, requireChoice?, fields?, now? })` → `bot`, `invalid` or `valid` |
|
|
106
|
+
| `…/contact-check` | `isEmail(text)`, `isPhone(text)`: the rules the action uses, safe in the browser for checks before sending |
|
|
107
|
+
| `…/form-protection` | `protectFormSubmissions(paths, { onVercel?, initialize? })`: Vercel BotID in the browser for the form submissions (POST) to those paths; nothing off Vercel |
|
|
108
|
+
| `…/bot-identification` | `isUnwantedBot({ onVercel?, allowVerifiedBots?, check? })` → `Promise<boolean>`: BotID's Basic verdict on the current request (server); `BotVerdict`, `BotIdentificationOptions` in `…/bot-identification/type` |
|
|
109
|
+
| `…/bot-check` | `isLikelyBot(form, { honeypotField?, startedAtField?, minimumFillTime?, now? })` |
|
|
110
|
+
| `…/rate-limit` | `createRateLimiter({ window, maximum })` → `(key, now?) => boolean` (kept in memory, per server instance) |
|
|
111
|
+
| `…/field` | `readField(form, name, maximumLength)` |
|
|
97
112
|
|
|
98
113
|
## Develop
|
|
99
114
|
|
|
@@ -101,4 +116,4 @@ The email server comes from `EMAIL_SERVER_*` and `EMAIL_SENDER_ADDRESS`.
|
|
|
101
116
|
|
|
102
117
|
## License
|
|
103
118
|
|
|
104
|
-
Licença Sharadox de Código Aberto, versão 0.
|
|
119
|
+
Licença Sharadox de Código Aberto (Sharadox Open Source License), versão 0.2.0. See [LICENSE.md](LICENSE.md): the [Portuguese text](source/license/portuguese.md) is the binding one, the [English translation](source/license/english.md) is for convenience.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BotIdentificationOptions } from "@sharadox/form-web-library/bot-identification/type";
|
|
2
|
+
/**
|
|
3
|
+
* Whether the current request comes from a bot that shouldn't get through, according to Vercel BotID (its free Basic
|
|
4
|
+
* check, never Deep Analysis). Call it on the server, inside the request (a server action or route handler) whose path
|
|
5
|
+
* the page protects with `protectFormSubmissions`. Verified bots get through by default: agents acting for someone,
|
|
6
|
+
* signed by their operators. Off Vercel it says no without asking; a failing check throws, for the caller to refuse.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* if (await isUnwantedBot()) return { status: "failed" };
|
|
10
|
+
*/
|
|
11
|
+
export declare function isUnwantedBot({ onVercel, allowVerifiedBots, check, }?: BotIdentificationOptions): Promise<boolean>;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/bot-identification/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAEnG;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,EAClC,QAAqC,EACrC,iBAAwB,EACxB,KAA0B,GAC3B,GAAE,wBAA6B,GAAG,OAAO,CAAC,OAAO,CAAC,CAIlD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { checkBotId } from "botid/server";
|
|
2
|
+
/**
|
|
3
|
+
* Whether the current request comes from a bot that shouldn't get through, according to Vercel BotID (its free Basic
|
|
4
|
+
* check, never Deep Analysis). Call it on the server, inside the request (a server action or route handler) whose path
|
|
5
|
+
* the page protects with `protectFormSubmissions`. Verified bots get through by default: agents acting for someone,
|
|
6
|
+
* signed by their operators. Off Vercel it says no without asking; a failing check throws, for the caller to refuse.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* if (await isUnwantedBot()) return { status: "failed" };
|
|
10
|
+
*/
|
|
11
|
+
export async function isUnwantedBot({ onVercel = process.env.VERCEL === "1", allowVerifiedBots = true, check = () => checkBotId(), } = {}) {
|
|
12
|
+
if (!onVercel)
|
|
13
|
+
return false;
|
|
14
|
+
const verdict = await check();
|
|
15
|
+
return verdict.isBot && !(allowVerifiedBots && verdict.isVerifiedBot);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/bot-identification/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,EAClC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,GAAG,EACrC,iBAAiB,GAAG,IAAI,EACxB,KAAK,GAAG,GAAG,EAAE,CAAC,UAAU,EAAE,MACE,EAAE;IAC9B,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,MAAM,OAAO,GAAG,MAAM,KAAK,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** What BotID says about a request: botid/server's `checkBotId()` answer, the parts read here. */
|
|
2
|
+
export interface BotVerdict {
|
|
3
|
+
isBot: boolean;
|
|
4
|
+
isVerifiedBot: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface BotIdentificationOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the code runs on Vercel, where BotID works; `VERCEL` is "1" there. Elsewhere (a local or continuous
|
|
9
|
+
* integration `next start`) there is no BotID to ask, so nothing is called a bot.
|
|
10
|
+
*/
|
|
11
|
+
onVercel?: boolean;
|
|
12
|
+
/** Lets verified bots (agents acting for someone, signed by their operators) through; true by default. */
|
|
13
|
+
allowVerifiedBots?: boolean;
|
|
14
|
+
/** Asks BotID about the current request; botid/server's `checkBotId` (Basic, free) by default. */
|
|
15
|
+
check?: () => Promise<BotVerdict>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/bot-identification/type.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0GAA0G;IAC1G,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kGAAkG;IAClG,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/bot-identification/type.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Every country's international calling code (digits after the "+"), by ISO 3166-1 alpha-2 code. Countries sharing
|
|
3
3
|
* a code (the United States, Canada and the Caribbean share 1) each have it. From libphonenumber's metadata (Apache
|
|
4
|
-
* 2.0, see
|
|
4
|
+
* 2.0, see LICENSE.md).
|
|
5
5
|
*/
|
|
6
6
|
export declare const CALLING_CODES: {
|
|
7
7
|
readonly AC: "247";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Every country's international calling code (digits after the "+"), by ISO 3166-1 alpha-2 code. Countries sharing
|
|
3
3
|
* a code (the United States, Canada and the Caribbean share 1) each have it. From libphonenumber's metadata (Apache
|
|
4
|
-
* 2.0, see
|
|
4
|
+
* 2.0, see LICENSE.md).
|
|
5
5
|
*/
|
|
6
6
|
export const CALLING_CODES = {
|
|
7
7
|
AC: "247",
|
|
@@ -11,7 +11,8 @@ export declare function textIn(text: ContactText, locale: string): string;
|
|
|
11
11
|
/** The logo (when the site gives one) and the company's name beside it, when the site gives no design of its own. */
|
|
12
12
|
export declare const plainDesign: (company: string) => EmailDesign;
|
|
13
13
|
/**
|
|
14
|
-
* Builds the work of a contact form's server action: checks for bots (
|
|
14
|
+
* Builds the work of a contact form's server action: checks for bots (the honeypot and fill time get a fake success;
|
|
15
|
+
* what Vercel BotID calls a bot, a refusal like a failed sending, with nothing sent), validates, limits
|
|
15
16
|
* each address and everyone together per day (`dailyMaximum`, so a flood can't run up the email bill), then sends one
|
|
16
17
|
* email to both the visitor and the company (`to`), so they share one conversation: replying, the visitor reaches the
|
|
17
18
|
* company; replying to all, the company reaches the visitor (the sending address is never in the way: replies go to
|
|
@@ -27,5 +28,5 @@ export declare const plainDesign: (company: string) => EmailDesign;
|
|
|
27
28
|
* // in a "use server" file:
|
|
28
29
|
* export async function sendContactAction(_: ContactState, form: FormData) { return sendContact(form, ip); }
|
|
29
30
|
*/
|
|
30
|
-
export declare function createContactAction({ to, company, senderName, senderAddress, logo, darkLogo, design: givenDesign, choices, reach, requireMessage, minimumMessageLength, requireChoice, fields, labels: givenLabels, rateLimit, dailyMaximum, readConfiguration, createSender, reportError, identifier, }: ContactActionOptions): (form: FormData, ip: string) => Promise<ContactState>;
|
|
31
|
+
export declare function createContactAction({ to, company, senderName, senderAddress, logo, darkLogo, design: givenDesign, choices, reach, requireMessage, minimumMessageLength, requireChoice, fields, labels: givenLabels, rateLimit, dailyMaximum, readConfiguration, createSender, reportError, identifier, isUnwantedBot, }: ContactActionOptions): (form: FormData, ip: string) => Promise<ContactState>;
|
|
31
32
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/contact-action/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAyB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/contact-action/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAyB,MAAM,6BAA6B,CAAC;AAMtF,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,WAAW,EACZ,MAAM,gDAAgD,CAAC;AAIxD,oCAAoC;AACpC,eAAO,MAAM,cAAc,EAAE,aAe5B,CAAC;AAEF,uCAAuC;AACvC,eAAO,MAAM,iBAAiB,EAAE,aAe/B,CAAC;AAEF,uCAAuC;AACvC,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAiD,CAAC;AAErH,6GAA6G;AAC7G,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,qHAAqH;AACrH,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,WAI5C,CAAC;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,EAAE,EACF,OAAO,EACP,UAAoB,EACpB,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,MAAM,EAAE,WAAW,EACnB,OAAY,EACZ,KAAe,EACf,cAAqB,EACrB,oBAAwB,EACxB,aAAqB,EACrB,MAAW,EACX,MAAM,EAAE,WAAgB,EACxB,SAAkD,EAClD,YAAiB,EACjB,iBAAgD,EAChD,YAAgC,EAChC,WAA+D,EAC/D,UAAiC,EACjC,aAAoC,GACrC,EAAE,oBAAoB,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CA6G9E"}
|
|
@@ -3,6 +3,7 @@ import { uuidVersion7 } from "@sharadox/web-library/identifier/uuid-version-7";
|
|
|
3
3
|
import { separated } from "@sharadox/web-library/text/separated";
|
|
4
4
|
import { createRateLimiter } from "@sharadox/form-web-library/rate-limit";
|
|
5
5
|
import { parseContact } from "@sharadox/form-web-library/parse-contact";
|
|
6
|
+
import { isUnwantedBot as askBotIdentification } from "@sharadox/form-web-library/bot-identification";
|
|
6
7
|
const oneLine = (text) => text.replace(/[\r\n]+/g, " ");
|
|
7
8
|
/** The email's words in English. */
|
|
8
9
|
export const ENGLISH_LABELS = {
|
|
@@ -53,7 +54,8 @@ export const plainDesign = (company) => ({
|
|
|
53
54
|
wordmark: true,
|
|
54
55
|
});
|
|
55
56
|
/**
|
|
56
|
-
* Builds the work of a contact form's server action: checks for bots (
|
|
57
|
+
* Builds the work of a contact form's server action: checks for bots (the honeypot and fill time get a fake success;
|
|
58
|
+
* what Vercel BotID calls a bot, a refusal like a failed sending, with nothing sent), validates, limits
|
|
57
59
|
* each address and everyone together per day (`dailyMaximum`, so a flood can't run up the email bill), then sends one
|
|
58
60
|
* email to both the visitor and the company (`to`), so they share one conversation: replying, the visitor reaches the
|
|
59
61
|
* company; replying to all, the company reaches the visitor (the sending address is never in the way: replies go to
|
|
@@ -69,7 +71,7 @@ export const plainDesign = (company) => ({
|
|
|
69
71
|
* // in a "use server" file:
|
|
70
72
|
* export async function sendContactAction(_: ContactState, form: FormData) { return sendContact(form, ip); }
|
|
71
73
|
*/
|
|
72
|
-
export function createContactAction({ to, company, senderName = company, senderAddress, logo, darkLogo, design: givenDesign, choices = {}, reach = "email", requireMessage = true, minimumMessageLength = 1, requireChoice = false, fields = {}, labels: givenLabels = {}, rateLimit = { window: 60 * 60 * 1000, maximum: 5 }, dailyMaximum = 50, readConfiguration = readEmailServerConfiguration, createSender = createEmailSender, reportError = (message, error) => console.error(message, error), identifier = () => uuidVersion7(), }) {
|
|
74
|
+
export function createContactAction({ to, company, senderName = company, senderAddress, logo, darkLogo, design: givenDesign, choices = {}, reach = "email", requireMessage = true, minimumMessageLength = 1, requireChoice = false, fields = {}, labels: givenLabels = {}, rateLimit = { window: 60 * 60 * 1000, maximum: 5 }, dailyMaximum = 50, readConfiguration = readEmailServerConfiguration, createSender = createEmailSender, reportError = (message, error) => console.error(message, error), identifier = () => uuidVersion7(), isUnwantedBot = askBotIdentification, }) {
|
|
73
75
|
const allow = createRateLimiter(rateLimit);
|
|
74
76
|
const allowToday = createRateLimiter({ window: 24 * 60 * 60 * 1000, maximum: dailyMaximum });
|
|
75
77
|
const design = givenDesign ?? plainDesign(company);
|
|
@@ -86,6 +88,16 @@ export function createContactAction({ to, company, senderName = company, senderA
|
|
|
86
88
|
return { status: "sent" };
|
|
87
89
|
if (parsed.kind === "invalid")
|
|
88
90
|
return { status: "invalid" };
|
|
91
|
+
// Vercel BotID, before anything is counted or sent: a bot is refused like a failed sending (a person it got wrong
|
|
92
|
+
// still sees the company's address), and uses up nobody's messages.
|
|
93
|
+
try {
|
|
94
|
+
if (await isUnwantedBot())
|
|
95
|
+
return { status: "failed" };
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
reportError("contact: bot check failed", error);
|
|
99
|
+
return { status: "failed" };
|
|
100
|
+
}
|
|
89
101
|
// Each address first, so one address can't use up everyone's daily emails.
|
|
90
102
|
if (!allow(ip) || !allowToday("everyone"))
|
|
91
103
|
return { status: "rate-limited" };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/contact-action/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,WAAW,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAEvH,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/contact-action/index.ts"],"names":[],"mappings":"AAAA,OAAO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9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -96,5 +96,11 @@ export interface ContactActionOptions {
|
|
|
96
96
|
reportError?: (message: string, error: unknown) => void;
|
|
97
97
|
/** A new conversation identifier, a UUID version 7 by default (tests give their own). */
|
|
98
98
|
identifier?: () => string;
|
|
99
|
+
/**
|
|
100
|
+
* Whether the request comes from a bot to refuse: Vercel BotID's free Basic check by default (`isUnwantedBot`, which
|
|
101
|
+
* lets verified bots through and asks nothing off Vercel). The page must protect its form submissions with
|
|
102
|
+
* `protectFormSubmissions`, or every request looks like a bot.
|
|
103
|
+
*/
|
|
104
|
+
isUnwantedBot?: () => Promise<boolean>;
|
|
99
105
|
}
|
|
100
106
|
//# sourceMappingURL=type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/contact-action/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACtG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAElF,8CAA8C;AAC9C,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,cAAc,GAAG,QAAQ,CAAC;CACjE;AAED,yGAAyG;AACzG,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEpE,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,2GAA2G;IAC3G,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY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C,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC1D,8DAA8D;IAC9D,SAAS,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,iBAAiB,CAAC,EAAE,MAAM,wBAAwB,CAAC;IACnD,YAAY,CAAC,EAAE,CAAC,aAAa,EAAE,wBAAwB,KAAK,WAAW,CAAC;IACxE,+DAA+D;IAC/D,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACxD,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACxC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FormProtectionOptions } from "@sharadox/form-web-library/form-protection/type";
|
|
2
|
+
/**
|
|
3
|
+
* Starts Vercel BotID in the browser for the form submissions to the given paths: a server action posts to the path
|
|
4
|
+
* of the page it runs on, so give each page that has a form (`*` matches anything, `/` included). BotID adds its
|
|
5
|
+
* proof to those requests only; pages themselves stay open to everyone, search engines and AI crawlers included. Call
|
|
6
|
+
* it from the site's `src/instrumentation-client.ts`; the server checks with `isUnwantedBot` (createContactAction does).
|
|
7
|
+
* Off Vercel it does nothing.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // src/instrumentation-client.ts
|
|
11
|
+
* protectFormSubmissions(["/en", "/pt"]);
|
|
12
|
+
*/
|
|
13
|
+
export declare function protectFormSubmissions(paths: readonly string[], { onVercel, initialize }?: FormProtectionOptions): void;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/form-protection/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AAE7F;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,EAAE,QAAsD,EAAE,UAAsB,EAAE,GAAE,qBAA0B,GAC7G,IAAI,CAGN"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { initBotId } from "botid/client/core";
|
|
2
|
+
/**
|
|
3
|
+
* Starts Vercel BotID in the browser for the form submissions to the given paths: a server action posts to the path
|
|
4
|
+
* of the page it runs on, so give each page that has a form (`*` matches anything, `/` included). BotID adds its
|
|
5
|
+
* proof to those requests only; pages themselves stay open to everyone, search engines and AI crawlers included. Call
|
|
6
|
+
* it from the site's `src/instrumentation-client.ts`; the server checks with `isUnwantedBot` (createContactAction does).
|
|
7
|
+
* Off Vercel it does nothing.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // src/instrumentation-client.ts
|
|
11
|
+
* protectFormSubmissions(["/en", "/pt"]);
|
|
12
|
+
*/
|
|
13
|
+
export function protectFormSubmissions(paths, { onVercel = Boolean(process.env.NEXT_PUBLIC_VERCEL_ENV), initialize = initBotId } = {}) {
|
|
14
|
+
if (!onVercel)
|
|
15
|
+
return;
|
|
16
|
+
initialize({ protect: paths.map((path) => ({ path, method: "POST" })) });
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/form-protection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAwB,EACxB,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,EAAE,UAAU,GAAG,SAAS,KAA4B,EAAE;IAE9G,IAAI,CAAC,QAAQ;QAAE,OAAO;IACtB,UAAU,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** One request BotID's browser script vouches for: botid/client/core's `initBotId` entry. */
|
|
2
|
+
export interface ProtectedRequest {
|
|
3
|
+
path: string;
|
|
4
|
+
method: string;
|
|
5
|
+
}
|
|
6
|
+
export interface FormProtectionOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the page runs on Vercel, which serves BotID's script; `NEXT_PUBLIC_VERCEL_ENV` is set there. Elsewhere
|
|
9
|
+
* the script isn't served and would stop the form's request, so nothing is started.
|
|
10
|
+
*/
|
|
11
|
+
onVercel?: boolean;
|
|
12
|
+
/** Starts BotID in the browser; botid/client/core's `initBotId` by default. */
|
|
13
|
+
initialize?: (options: {
|
|
14
|
+
protect: ProtectedRequest[];
|
|
15
|
+
}) => void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/form-protection/type.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,gBAAgB,EAAE,CAAA;KAAE,KAAK,IAAI,CAAC;CACjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/form-protection/type.ts"],"names":[],"mappings":""}
|
package/llms.txt
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
- /contact-problem: contactProblems({ name, email, phone }) → ("name" | "reach" | "email" | "phone")[]: a name and a valid way to reply, same rules on page and server
|
|
6
6
|
- /choice-request: requestChoices(event, choices) and useChoiceRequests(event, onRequest): a button elsewhere on the page asks the form to tick choices
|
|
7
7
|
- /bot-field: <BotFields honeypotField? startedAtField? honeypotLabel? />: the hidden honeypot and fill-time fields isLikelyBot reads
|
|
8
|
-
- /contact-action: createContactAction({ to (company address: the email goes to it and the visitor; Reply-To), company (sender name unless senderName?; sign-off "Best regards, Company."), senderAddress? (EMAIL_SENDER_ADDRESS), logo?/darkLogo?: () => Promise<{ content, contentType, filename }> (cid:logo black with white outline, cid:logo-dark white), design? EmailDesign (default plainDesign(company)), choices?: { key: label | { [locale]: label } }, reach? = email | email-or-phone, requireMessage? = true, minimumMessageLength? = 1, requireChoice? = false, fields?: { name: label | { [locale]: label } }, labels?: { [locale]: Partial<ContactLabels> } (over CONTACT_LABELS en/pt), rateLimit? = 5/hour per address, dailyMaximum? = 50/day, identifier? = uuidVersion7, readConfiguration?, createSender?, reportError? }) → (form, ip) => { status }. ONE email to [visitor (if email), to], Reply-To: to (visitor replies reach the company; company replies-all reach the visitor; one thread). Subject "<contact> · Name (Organization) · <UUIDv7>" in the visitor's form language. Body: logo, CONTACT eyebrow, "Thank you, Name.", 2 paragraphs, rows Name / Organization / Email / Phone / site fields / Needs (dotted list) / Message (line breaks kept) / Conversation identifier, "Best regards," + bold company. Phone-only visitor: only the company gets it.
|
|
8
|
+
- /contact-action: createContactAction({ to (company address: the email goes to it and the visitor; Reply-To), company (sender name unless senderName?; sign-off "Best regards, Company."), senderAddress? (EMAIL_SENDER_ADDRESS), logo?/darkLogo?: () => Promise<{ content, contentType, filename }> (cid:logo black with white outline, cid:logo-dark white), design? EmailDesign (default plainDesign(company)), choices?: { key: label | { [locale]: label } }, reach? = email | email-or-phone, requireMessage? = true, minimumMessageLength? = 1, requireChoice? = false, fields?: { name: label | { [locale]: label } }, labels?: { [locale]: Partial<ContactLabels> } (over CONTACT_LABELS en/pt), rateLimit? = 5/hour per address, dailyMaximum? = 50/day, identifier? = uuidVersion7, isUnwantedBot? = Vercel BotID Basic, readConfiguration?, createSender?, reportError? }) → (form, ip) => { status }. ONE email to [visitor (if email), to], Reply-To: to (visitor replies reach the company; company replies-all reach the visitor; one thread). Subject "<contact> · Name (Organization) · <UUIDv7>" in the visitor's form language. Body: logo, CONTACT eyebrow, "Thank you, Name.", 2 paragraphs, rows Name / Organization / Email / Phone / site fields / Needs (dotted list) / Message (line breaks kept) / Conversation identifier, "Best regards," + bold company. Phone-only visitor: only the company gets it. Honeypot/fill-time bots get a fake "sent"; what BotID calls a bot gets "failed" before rate limits (nothing sent); a failing BotID check: "failed" + reportError.
|
|
9
9
|
- Form fields: name, email, phone (valid: + digits spaces ().- with ≥7 digits), company, message, extra fields, locale, started-at, page (location.href at sending), website (honeypot), need (checkboxes).
|
|
10
|
+
- /form-protection (browser): protectFormSubmissions(paths, { onVercel? = Boolean(NEXT_PUBLIC_VERCEL_ENV), initialize? = initBotId }) → initBotId({ protect: paths as POST }); call in src/instrumentation-client.ts with every page path that has the form (server actions POST to the page's path; `*` wildcard). Required, or BotID calls every submission a bot. No withBotId needed. Basic only, never Deep Analysis (paid).
|
|
11
|
+
- /bot-identification (server): isUnwantedBot({ onVercel? = VERCEL === "1", allowVerifiedBots? = true, check? = checkBotId }) → Promise<boolean>; off Vercel always false; check errors propagate
|
|
10
12
|
- /parse-contact: parseContact(form, { choices, choiceField='need', reach, requireMessage, minimumMessageLength, requireChoice, fields, now }) → value { name, email, phone, company, message, locale, choices, fields }
|
|
11
13
|
- /contact-check isEmail(text), isPhone(text) (browser-safe, same rules as the server); /bot-check isLikelyBot; /rate-limit createRateLimiter({ window, maximum }); /field readField(form, name, max)
|
|
12
14
|
- Env: EMAIL_SERVER_HOST/PORT/USERNAME/PASSWORD, EMAIL_SENDER_ADDRESS. License: Sharadox Open Source License 0.1.0
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sharadox/form-web-library",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Forms: a phone field with every country's flag and calling code, and on the server field reading, honeypot and fill-time bot checks, rate limiting and a contact form action that emails messages with the visitor as reply-to.",
|
|
3
|
+
"version": "0.9.0-development.65",
|
|
4
|
+
"description": "Forms: a phone field with every country's flag and calling code, Vercel BotID for form submissions, and on the server field reading, BotID, honeypot and fill-time bot checks, rate limiting and a contact form action that emails messages with the visitor as reply-to.",
|
|
5
5
|
"private": false,
|
|
6
|
-
"license": "SEE LICENSE IN
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
7
|
"author": "Sharadox <contact@sharadox.com>",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
@@ -22,9 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"distribution",
|
|
25
|
-
"LICENCA.md",
|
|
26
25
|
"LICENSE.md",
|
|
27
|
-
"
|
|
26
|
+
"source/license",
|
|
28
27
|
"llms.txt",
|
|
29
28
|
"CHANGELOG.md"
|
|
30
29
|
],
|
|
@@ -77,7 +76,8 @@
|
|
|
77
76
|
"dependencies": {
|
|
78
77
|
"@sharadox/email-web-library": "^0.7.1",
|
|
79
78
|
"@sharadox/icon-web-library": "^0.6.2",
|
|
80
|
-
"@sharadox/web-library": "^0.11.1"
|
|
79
|
+
"@sharadox/web-library": "^0.11.1",
|
|
80
|
+
"botid": "^1.5.14"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"react": ">=19"
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Sharadox Open Source License
|
|
2
|
+
|
|
3
|
+
Version 0.2.0
|
|
4
|
+
|
|
5
|
+
This English translation is provided for convenience only. The Portuguese text is the only original and binding text of this license; if the two differ, the Portuguese text prevails.
|
|
6
|
+
|
|
7
|
+
## 1. Definitions
|
|
8
|
+
|
|
9
|
+
For the purposes of this license:
|
|
10
|
+
|
|
11
|
+
1. **"Work"** — the computer program, its documentation and any other content made available by the Licensor under this license, in source code or in any other form.
|
|
12
|
+
2. **"Licensor"** — the copyright holder identified in the copyright notice that accompanies the Work.
|
|
13
|
+
3. **"Licensee"** — any natural or legal person exercising the rights granted by this license.
|
|
14
|
+
4. **"Derivative Work"** — any work based on or incorporating the Work, in whole or in part, with or without modifications, including translations, adaptations and programs that integrate it.
|
|
15
|
+
5. **"Notice"** — the Licensor's copyright notice and the statement that the Work is licensed under this license, including its version.
|
|
16
|
+
|
|
17
|
+
## 2. Grant of rights
|
|
18
|
+
|
|
19
|
+
1. Under this license, the Licensor grants the Licensee a worldwide, royalty-free, non-exclusive license, for the whole term of copyright protection, to:
|
|
20
|
+
1. use the Work for any purpose, including commercial purposes;
|
|
21
|
+
2. reproduce the Work, in whole or in part, by any means and in any form;
|
|
22
|
+
3. modify, translate, adapt and transform the Work and create Derivative Works;
|
|
23
|
+
4. distribute, publish, communicate to the public, make available, sell and sublicense the Work and Derivative Works.
|
|
24
|
+
2. To the extent the Licensor holds patents necessarily infringed by the Work as made available by it, the Licensor also grants the Licensee, on the same terms, a license to use those patents in exercising the rights in the previous paragraph.
|
|
25
|
+
3. This license does not transfer ownership of any rights, which remain with the Licensor.
|
|
26
|
+
|
|
27
|
+
## 3. Conditions
|
|
28
|
+
|
|
29
|
+
The exercise of the rights granted is subject to the following conditions:
|
|
30
|
+
|
|
31
|
+
1. Every copy of the Work, or of substantial parts of it, and every distributed Derivative Work must include the Notice and a copy of this license or a stable link to its text.
|
|
32
|
+
2. Anyone distributing a modified version of the Work must state visibly that it has been modified and may not present it as the Licensor's original version.
|
|
33
|
+
3. The Licensee may license their own modifications under other terms, provided the part of the Work included in them remains subject to the conditions of this license.
|
|
34
|
+
|
|
35
|
+
## 4. Names and trademarks
|
|
36
|
+
|
|
37
|
+
This license grants no rights to the Licensor's name, trademarks, logos or other distinctive signs, including the name "Sharadox", except as strictly necessary to comply with the duty to include the Notice. Using them to promote or suggest the Licensor's endorsement of Derivative Works or of any products or services without prior written permission is prohibited.
|
|
38
|
+
|
|
39
|
+
## 5. Disclaimer of warranties
|
|
40
|
+
|
|
41
|
+
The Work is provided "as is" and "as available", without any warranty, express or implied, including in particular warranties of merchantability, fitness for a particular purpose, absence of errors or non-infringement of third-party rights, to the maximum extent permitted by applicable law.
|
|
42
|
+
|
|
43
|
+
## 6. Limitation of liability
|
|
44
|
+
|
|
45
|
+
1. To the maximum extent permitted by applicable law, the Licensor is not liable for any damages, direct or indirect, including loss of profits, loss of data or business interruption, arising from the use of or inability to use the Work, even if advised of the possibility of such damages.
|
|
46
|
+
2. Nothing in this license excludes or limits the Licensor's liability where such exclusion or limitation is not permitted by law, in particular for acts committed with intent or gross negligence, under article 809 and article 800(2) of the Portuguese Civil Code, nor does it affect rights that the law mandatorily grants to consumers.
|
|
47
|
+
|
|
48
|
+
## 7. Termination
|
|
49
|
+
|
|
50
|
+
1. The rights granted by this license terminate automatically if the Licensee breaches any of its conditions.
|
|
51
|
+
2. The rights are reinstated if the breach is remedied within 30 days of the Licensee becoming aware of it, unless the Licensor has meanwhile objected in writing.
|
|
52
|
+
3. Termination does not affect licenses validly granted by the Licensee to third parties who comply with this license.
|
|
53
|
+
|
|
54
|
+
## 8. Governing law and jurisdiction
|
|
55
|
+
|
|
56
|
+
1. This license is governed by Portuguese law, in particular the Code of Copyright and Related Rights, approved by Decree-Law no. 63/85 of 14 March, and Decree-Law no. 252/94 of 20 October on the legal protection of computer programs.
|
|
57
|
+
2. The Judicial Court of the District of Faro has jurisdiction over any dispute arising from this license, without prejudice to applicable mandatory rules of jurisdiction, in particular those protecting consumers.
|
|
58
|
+
|
|
59
|
+
## 9. License versions
|
|
60
|
+
|
|
61
|
+
The Licensor may publish new versions of this license, identified by a version number. The Work is subject to the version stated in the Notice. If the Notice allows it, the Licensee may choose any later version.
|
|
62
|
+
|
|
63
|
+
## 10. Final provisions
|
|
64
|
+
|
|
65
|
+
1. If any provision of this license is held invalid or unenforceable, the remaining provisions stay in force, and the affected provision shall be interpreted as closely as possible to its original intent.
|
|
66
|
+
2. Failure to enforce any provision of this license at any time does not waive the right to enforce it later.
|
|
67
|
+
|
|
68
|
+
## How to apply this license
|
|
69
|
+
|
|
70
|
+
Put at the root of the Work a `LICENSE.md` file with the Notice, filling in the year and holder, a statement that the Portuguese text is the only binding one, and links to the Portuguese text (`source/license/portuguese.md`) and to this translation (`source/license/english.md`), kept in the Work:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
Direitos de autor © <ano> <titular>.
|
|
74
|
+
Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.2.0.
|
|
75
|
+
https://github.com/Sharadox/sharadox-open-source-license
|
|
76
|
+
```
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Licença Sharadox de Código Aberto
|
|
2
2
|
|
|
3
|
-
Versão 0.
|
|
3
|
+
Versão 0.2.0
|
|
4
4
|
|
|
5
|
-
O texto em língua portuguesa é o único texto original e vinculativo desta licença. A tradução para inglês
|
|
5
|
+
O texto em língua portuguesa é o único texto original e vinculativo desta licença. A tradução para inglês existe apenas por conveniência; em caso de divergência prevalece o texto em português.
|
|
6
6
|
|
|
7
7
|
## 1. Definições
|
|
8
8
|
|
|
@@ -67,10 +67,10 @@ O Licenciante pode publicar novas versões desta licença, identificadas por um
|
|
|
67
67
|
|
|
68
68
|
## Como aplicar esta licença
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Coloque na raiz da Obra um ficheiro `LICENSE.md` com o Aviso, preenchendo o ano e o titular, a indicação de que o texto em português é o único vinculativo e ligações para este texto (`source/license/portuguese.md`) e para a sua tradução para inglês (`source/license/english.md`), guardados na Obra:
|
|
71
71
|
|
|
72
72
|
```
|
|
73
73
|
Direitos de autor © <ano> <titular>.
|
|
74
|
-
Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.
|
|
74
|
+
Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.2.0.
|
|
75
75
|
https://github.com/Sharadox/sharadox-open-source-license
|
|
76
76
|
```
|
package/NOTICE.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
Direitos de autor © 2026 Micael Pires (Sharadox).
|
|
2
|
-
Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.1.0.
|
|
3
|
-
https://github.com/Sharadox/sharadox-open-source-license
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
Os indicativos internacionais (`source/calling-code`) vêm dos metadados da libphonenumber, da Google, sob a licença Apache 2.0:
|
|
8
|
-
The international calling codes (`source/calling-code`) come from Google's libphonenumber metadata, under the Apache License 2.0:
|
|
9
|
-
https://github.com/google/libphonenumber · https://www.apache.org/licenses/LICENSE-2.0
|