@sharadox/form-web-library 0.3.0 → 0.4.1

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
@@ -25,14 +25,33 @@ pnpm add @sharadox/form-web-library
25
25
  // the site's library
26
26
  export const sendContact = createContactAction({
27
27
  to: "contact@example.com",
28
- senderName: "Example Web Application",
28
+ company: "Example", // from "Example Web Application", subject "Example Web Application · Contact · Ana (Café)"
29
29
  site: "example.com",
30
- subject: (message) =>
31
- separate(SEPARATOR, "Contact", message.company ? `${message.name} (${message.company})` : message.name),
32
30
  choices: { website: "Website", logo: "Logo", other: "Others" },
31
+ logo: async () => ({ content: await readFile(LOGO), contentType: "image/png", filename: "logo.png" }),
32
+ theme: { background: "#000000", foreground: "#ffffff", accent: "#ffffff" },
33
+ acknowledgement: {
34
+ en: {
35
+ subject: "Example · We received your message",
36
+ eyebrow: "Message received",
37
+ heading: (name) => `Thank you, ${name}.`,
38
+ paragraphs: ["We'll get back to you shortly."],
39
+ messageLabel: "Your message",
40
+ },
41
+ },
33
42
  });
34
43
  ```
35
44
 
45
+ Every email has the same layout: the company's logo and name on its colors at the top, then the visitor's name
46
+ (and company), every detail they gave, their message, and at the bottom the page the form was sent from, the
47
+ language, the time and the IP address. Replying answers the visitor. With `acknowledgement`, a visitor who left an
48
+ email also gets an automatic reply in their language, with their message, and replying to it reaches the company.
49
+ `…/contact-email` (`brandedEmailHtml`) draws the layout, for any other email a site sends.
50
+
51
+ ```ts
52
+
53
+ ```
54
+
36
55
  ```ts
37
56
  // the application's server action
38
57
  "use server";
@@ -45,7 +64,7 @@ export async function sendContactAction(_: ContactState, form: FormData) {
45
64
  The form sends these fields:
46
65
 
47
66
  - **text:** `name`, `email`, `phone`, `company`, `message`, plus any `fields` the site adds
48
- - **hidden:** `locale`, and `started-at` (`Date.now()` when the visitor started)
67
+ - **hidden:** `locale`, `started-at` (`Date.now()` when the visitor started) and `page` (`location.href` when sending; shown only when it's on the site's domain)
49
68
  - **checkboxes:** `need`
50
69
  - **honeypot:** `website`, kept off screen
51
70
 
@@ -53,14 +72,15 @@ The email server comes from `EMAIL_SERVER_*` and `EMAIL_SENDER_ADDRESS`.
53
72
 
54
73
  ## API
55
74
 
56
- | Import | Export |
57
- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
58
- | `…/contact-action` | `createContactAction(options)` → `(form, ip) => Promise<ContactState>`; `ENGLISH_LABELS`; `ContactState`, `ContactActionOptions` and `ContactLabels` in `…/contact-action/type` |
59
- | `…/parse-contact` | `parseContact(form, { choices?, choiceField?, reach?, requireMessage?, minimumMessageLength?, requireChoice?, fields?, now? })` → `bot`, `invalid` or `valid` |
60
- | `…/contact-check` | `isEmail(text)`, `isPhone(text)`: the rules the action uses, safe in the browser for checks before sending |
61
- | `…/bot-check` | `isLikelyBot(form, { honeypotField?, startedAtField?, minimumFillTime?, now? })` |
62
- | `…/rate-limit` | `createRateLimiter({ window, maximum })` → `(key, now?) => boolean` (kept in memory, per server instance) |
63
- | `…/field` | `readField(form, name, maximumLength)` |
75
+ | Import | Export |
76
+ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
+ | `…/contact-action` | `createContactAction(options)` → `(form, ip) => Promise<ContactState>`; `ENGLISH_LABELS`, `PLAIN_THEME`, `LANGUAGE_NAMES`, `formPage(value, site)`; `ContactState`, `ContactActionOptions`, `ContactLabels`, `ContactAcknowledgement` and `EmailLogo` in `…/contact-action/type` |
78
+ | `…/contact-email` | `brandedEmailHtml({ company, theme, logo, language, preview, eyebrow, heading, paragraphs?, rows?, quote?, footer? })`: the company's email layout (logo as `cid:logo`) |
79
+ | `…/parse-contact` | `parseContact(form, { choices?, choiceField?, reach?, requireMessage?, minimumMessageLength?, requireChoice?, fields?, now? })` → `bot`, `invalid` or `valid` |
80
+ | `…/contact-check` | `isEmail(text)`, `isPhone(text)`: the rules the action uses, safe in the browser for checks before sending |
81
+ | `…/bot-check` | `isLikelyBot(form, { honeypotField?, startedAtField?, minimumFillTime?, now? })` |
82
+ | `…/rate-limit` | `createRateLimiter({ window, maximum })` → `(key, now?) => boolean` (kept in memory, per server instance) |
83
+ | `…/field` | `readField(form, name, maximumLength)` |
64
84
 
65
85
  ## Develop
66
86
 
@@ -1,17 +1,30 @@
1
+ import type { EmailTheme } from "@sharadox/form-web-library/contact-email/type";
1
2
  import type { ContactActionOptions, ContactLabels, ContactState } from "@sharadox/form-web-library/contact-action/type";
2
3
  /** The email's words when the site gives none. */
3
4
  export declare const ENGLISH_LABELS: ContactLabels;
5
+ /** Black and white, when the site gives no colors. */
6
+ export declare const PLAIN_THEME: EmailTheme;
7
+ /** Common languages' names, when the site gives none. */
8
+ export declare const LANGUAGE_NAMES: Readonly<Record<string, string>>;
9
+ /**
10
+ * The page the form was sent from, when it is a web address on the site's domain (or a subdomain of it); anything
11
+ * else is left out, so a forged field can't put a link of someone else's in the inbox.
12
+ */
13
+ export declare function formPage(value: ReturnType<FormData["get"]>, site: string): string | undefined;
4
14
  /**
5
15
  * Builds the work of a contact form's server action: checks for bots (they get a fake success), validates, limits
6
- * each address and everyone together per day (`dailyMaximum`, so a flood can't run up the email bill), then emails the message in plain text and HTML (user input escaped), with the visitor as reply-to
7
- * when they left an email. Sites can accept a phone instead of an email (`reach`), make the message optional, add
8
- * fields and write the email in their own language (`labels`).
16
+ * each address and everyone together per day (`dailyMaximum`, so a flood can't run up the email bill), then emails
17
+ * the company in its own layout: the logo and name at the top, every detail the visitor gave, their message, and the
18
+ * page, language, time and IP at the bottom. It comes from "<company> Web Application" with the subject
19
+ * "<company> Web Application · Contact · Name (Company)", and replying answers the visitor. When the visitor left an
20
+ * email and the site gives an `acknowledgement`, they get an automatic reply in their language with their message,
21
+ * which the company can be reached by replying to. Sites can accept a phone instead of an email (`reach`), make the
22
+ * message optional, add fields and write the email in their own language (`labels`).
9
23
  *
10
24
  * @example
11
- * const sendContact = createContactAction({ to: "contact@sharadox.com", senderName: "Sharadox Web Application",
12
- * site: "sharadox.com", subject: (message) => separate(SEPARATOR, "Contact", message.name) });
25
+ * const sendContact = createContactAction({ to: "contact@sharadox.com", company: "Sharadox", site: "sharadox.com" });
13
26
  * // in a "use server" file:
14
27
  * export async function sendContactAction(_: ContactState, form: FormData) { return sendContact(form, ip); }
15
28
  */
16
- export declare function createContactAction({ to, senderName, senderAddress, subject, choices, site, reach, requireMessage, minimumMessageLength, requireChoice, fields, labels: givenLabels, rateLimit, dailyMaximum, readConfiguration, createSender, reportError, }: ContactActionOptions): (form: FormData, ip: string) => Promise<ContactState>;
29
+ export declare function createContactAction({ to, company, senderAddress, logo, theme, languageNames, acknowledgement, choices, site, reach, requireMessage, minimumMessageLength, requireChoice, fields, labels: givenLabels, rateLimit, dailyMaximum, readConfiguration, createSender, reportError, now, }: ContactActionOptions): (form: FormData, ip: string) => Promise<ContactState>;
17
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/contact-action/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAIxH,kDAAkD;AAClD,eAAO,MAAM,cAAc,EAAE,aAQ5B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,EAAE,EACF,UAAU,EACV,aAAa,EACb,OAAO,EACP,OAAY,EACZ,IAAI,EACJ,KAAe,EACf,cAAqB,EACrB,oBAAwB,EACxB,aAAqB,EACrB,MAAW,EACX,MAAM,EAAE,WAAgB,EACxB,SAAkD,EAClD,YAAiB,EACjB,iBAAgD,EAChD,YAAgC,EAChC,WAA+D,GAChE,EAAE,oBAAoB,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CAgE9E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/contact-action/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAY,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAG1F,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAIxH,kDAAkD;AAClD,eAAO,MAAM,cAAc,EAAE,aAW5B,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,WAAW,EAAE,UAAgF,CAAC;AAE3G,yDAAyD;AACzD,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO3D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAS7F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,EAAE,EACF,OAAO,EACP,aAAa,EACb,IAAI,EACJ,KAAmB,EACnB,aAA8B,EAC9B,eAAe,EACf,OAAY,EACZ,IAAI,EACJ,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,GAAsB,GACvB,EAAE,oBAAoB,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CA4H9E"}
@@ -1,7 +1,7 @@
1
1
  import { createEmailSender, EmailError, readEmailServerConfiguration } from "@sharadox/email-web-library";
2
- import { escapeHtml } from "@sharadox/web-library/html/escape";
3
2
  import { separate } from "@sharadox/web-library/text/separate";
4
3
  import { SEPARATOR } from "@sharadox/web-library/text/separator";
4
+ import { brandedEmailHtml } from "@sharadox/form-web-library/contact-email";
5
5
  import { createRateLimiter } from "@sharadox/form-web-library/rate-limit";
6
6
  import { parseContact } from "@sharadox/form-web-library/parse-contact";
7
7
  const oneLine = (text) => text.replace(/[\r\n]+/g, " ");
@@ -13,24 +13,58 @@ export const ENGLISH_LABELS = {
13
13
  company: "Company",
14
14
  needs: "Needs",
15
15
  language: "Language",
16
- from: "New message from",
16
+ contact: "Contact",
17
+ message: "Message",
18
+ page: "Form",
19
+ sent: "Sent",
17
20
  };
21
+ /** Black and white, when the site gives no colors. */
22
+ export const PLAIN_THEME = { background: "#000000", foreground: "#ffffff", accent: "#ffffff" };
23
+ /** Common languages' names, when the site gives none. */
24
+ export const LANGUAGE_NAMES = {
25
+ en: "English",
26
+ pt: "Português",
27
+ es: "Español",
28
+ fr: "Français",
29
+ de: "Deutsch",
30
+ it: "Italiano",
31
+ };
32
+ /**
33
+ * The page the form was sent from, when it is a web address on the site's domain (or a subdomain of it); anything
34
+ * else is left out, so a forged field can't put a link of someone else's in the inbox.
35
+ */
36
+ export function formPage(value, site) {
37
+ if (typeof value !== "string" || value.length > 500)
38
+ return undefined;
39
+ try {
40
+ const url = new URL(value);
41
+ const host = url.hostname;
42
+ return url.protocol === "https:" && (host === site || host.endsWith(`.${site}`)) ? url.href : undefined;
43
+ }
44
+ catch {
45
+ return undefined;
46
+ }
47
+ }
18
48
  /**
19
49
  * Builds the work of a contact form's server action: checks for bots (they get a fake success), validates, limits
20
- * each address and everyone together per day (`dailyMaximum`, so a flood can't run up the email bill), then emails the message in plain text and HTML (user input escaped), with the visitor as reply-to
21
- * when they left an email. Sites can accept a phone instead of an email (`reach`), make the message optional, add
22
- * fields and write the email in their own language (`labels`).
50
+ * each address and everyone together per day (`dailyMaximum`, so a flood can't run up the email bill), then emails
51
+ * the company in its own layout: the logo and name at the top, every detail the visitor gave, their message, and the
52
+ * page, language, time and IP at the bottom. It comes from "<company> Web Application" with the subject
53
+ * "<company> Web Application · Contact · Name (Company)", and replying answers the visitor. When the visitor left an
54
+ * email and the site gives an `acknowledgement`, they get an automatic reply in their language with their message,
55
+ * which the company can be reached by replying to. Sites can accept a phone instead of an email (`reach`), make the
56
+ * message optional, add fields and write the email in their own language (`labels`).
23
57
  *
24
58
  * @example
25
- * const sendContact = createContactAction({ to: "contact@sharadox.com", senderName: "Sharadox Web Application",
26
- * site: "sharadox.com", subject: (message) => separate(SEPARATOR, "Contact", message.name) });
59
+ * const sendContact = createContactAction({ to: "contact@sharadox.com", company: "Sharadox", site: "sharadox.com" });
27
60
  * // in a "use server" file:
28
61
  * export async function sendContactAction(_: ContactState, form: FormData) { return sendContact(form, ip); }
29
62
  */
30
- export function createContactAction({ to, senderName, senderAddress, subject, choices = {}, site, 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), }) {
63
+ export function createContactAction({ to, company, senderAddress, logo, theme = PLAIN_THEME, languageNames = LANGUAGE_NAMES, acknowledgement, choices = {}, site, 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), now = () => new Date(), }) {
31
64
  const allow = createRateLimiter(rateLimit);
32
65
  const allowToday = createRateLimiter({ window: 24 * 60 * 60 * 1000, maximum: dailyMaximum });
33
66
  const labels = { ...ENGLISH_LABELS, ...givenLabels };
67
+ const senderName = `${company} Web Application`;
34
68
  return async (form, ip) => {
35
69
  const parsed = parseContact(form, {
36
70
  choices: Object.keys(choices),
@@ -48,45 +82,105 @@ export function createContactAction({ to, senderName, senderAddress, subject, ch
48
82
  if (!allow(ip) || !allowToday("everyone"))
49
83
  return { status: "rate-limited" };
50
84
  const message = parsed.value;
85
+ const page = formPage(form.get("page"), site);
86
+ const language = languageNames[message.locale] ?? message.locale;
87
+ const sent = `${now().toISOString().slice(0, 16).replace("T", " ")} UTC`;
51
88
  const named = message.choices.map((choice) => choices[choice]);
52
- const extra = Object.entries(fields).map(([field, label]) => [label, message.fields[field]]);
53
- const lines = [
54
- [labels.name, message.name],
55
- [labels.email, message.email || "—"],
56
- ...(message.phone ? [[labels.phone, message.phone]] : []),
57
- [labels.company, message.company || "—"],
58
- ...extra.map(([label, value]) => [label, value || "—"]),
59
- [labels.needs, named.join(", ") || "—"],
60
- [labels.language, message.locale],
61
- ["IP", ip],
89
+ const who = message.company ? `${message.name} (${message.company})` : message.name;
90
+ const rows = [
91
+ { label: labels.name, value: message.name },
92
+ ...(message.email ? [{ label: labels.email, value: message.email, href: `mailto:${message.email}` }] : []),
93
+ ...(message.phone
94
+ ? [{ label: labels.phone, value: message.phone, href: `tel:${message.phone.replace(/[^\d+]/g, "")}` }]
95
+ : []),
96
+ ...(message.company ? [{ label: labels.company, value: message.company }] : []),
97
+ ...Object.entries(fields)
98
+ .filter(([field]) => message.fields[field])
99
+ .map(([field, label]) => ({ label, value: message.fields[field] })),
100
+ ...(named.length ? [{ label: labels.needs, value: named.join(", ") }] : []),
62
101
  ];
63
- const text = `${lines.map(([label, value]) => `${label}: ${value}`).join("\n")}${message.message ? `\n\n${message.message}` : ""}`;
64
- const contacts = [
65
- message.email && `<a href="mailto:${escapeHtml(message.email)}">${escapeHtml(message.email)}</a>`,
66
- message.phone &&
67
- `<a href="tel:${escapeHtml(message.phone.replace(/[^\d+]/g, ""))}">${escapeHtml(message.phone)}</a>`,
102
+ const footer = [
103
+ ...(page ? [{ label: labels.page, value: page, href: page }] : [{ label: labels.page, value: site }]),
104
+ { label: labels.language, value: language },
105
+ { label: labels.sent, value: sent },
106
+ { label: "IP", value: ip },
68
107
  ];
69
- const details = extra.filter(([, value]) => value);
70
- const html = `<div style="font-family:-apple-system,Segoe UI,sans-serif;font-size:15px;line-height:1.6;color:#111">
71
- <p style="color:#666;font-size:13px;margin:0 0 16px">${escapeHtml(labels.from)} ${escapeHtml(site)} (${escapeHtml(message.locale)})</p>
72
- <p style="margin:0">${separate(SEPARATOR, `<b>${escapeHtml(message.name)}</b>`, message.company && escapeHtml(message.company))}<br>${separate(SEPARATOR, ...contacts)}</p>
73
- ${details.length ? `<p style="margin:12px 0 0;color:#444">${details.map(([label, value]) => `${escapeHtml(label)}: ${escapeHtml(value)}`).join("<br>")}</p>` : ""}
74
- ${named.length ? `<p style="margin:12px 0 0;color:#444">${escapeHtml(named.join(", "))}</p>` : ""}
75
- ${message.message ? `<hr style="border:0;border-top:1px solid #eee;margin:18px 0">\n <p style="white-space:pre-wrap;margin:0">${escapeHtml(message.message)}</p>` : ""}</div>`;
108
+ const text = [
109
+ ...rows.map((row) => `${row.label}: ${row.value}`),
110
+ ...(message.message ? ["", `${labels.message}:`, message.message] : []),
111
+ "",
112
+ ...footer.map((row) => `${row.label}: ${row.value}`),
113
+ ].join("\n");
76
114
  try {
115
+ const image = logo ? await logo() : undefined;
116
+ const inlineImages = image ? [{ id: "logo", ...image }] : [];
77
117
  const configuration = readConfiguration();
78
- await createSender(configuration).send({
79
- from: {
80
- name: senderName,
81
- address: senderAddress || process.env.EMAIL_SENDER_ADDRESS || configuration.username,
82
- },
118
+ const sender = createSender(configuration);
119
+ const from = {
120
+ name: senderName,
121
+ address: senderAddress || process.env.EMAIL_SENDER_ADDRESS || configuration.username,
122
+ };
123
+ await sender.send({
124
+ from,
83
125
  to,
84
126
  // Replying to the email answers the visitor at the address they typed.
85
127
  ...(message.email ? { replyTo: { name: oneLine(message.name), address: message.email } } : {}),
86
- subject: oneLine(subject(message)).slice(0, 300),
128
+ subject: oneLine(separate(SEPARATOR, senderName, labels.contact, who)).slice(0, 300),
87
129
  text,
88
- html,
130
+ html: brandedEmailHtml({
131
+ company,
132
+ theme,
133
+ logo: Boolean(image),
134
+ language: "en",
135
+ preview: separate(SEPARATOR, who, named.join(", ")),
136
+ eyebrow: labels.contact,
137
+ heading: who,
138
+ rows,
139
+ ...(message.message ? { quote: { label: labels.message, text: message.message } } : {}),
140
+ footer,
141
+ }),
142
+ inlineImages,
89
143
  });
144
+ // The automatic reply: never stops the message itself from counting as sent.
145
+ const reply = acknowledgement?.[message.locale] ?? Object.values(acknowledgement ?? {})[0];
146
+ if (reply && message.email) {
147
+ try {
148
+ await sender.send({
149
+ from,
150
+ to: { name: oneLine(message.name), address: message.email },
151
+ replyTo: to,
152
+ subject: oneLine(reply.subject).slice(0, 300),
153
+ text: [
154
+ reply.heading(message.name),
155
+ "",
156
+ ...reply.paragraphs,
157
+ ...(message.message ? ["", `${reply.messageLabel}:`, message.message] : []),
158
+ ].join("\n"),
159
+ html: brandedEmailHtml({
160
+ company,
161
+ theme,
162
+ logo: Boolean(image),
163
+ language: message.locale,
164
+ preview: reply.paragraphs[0] ?? reply.subject,
165
+ eyebrow: reply.eyebrow,
166
+ heading: reply.heading(message.name),
167
+ paragraphs: reply.paragraphs,
168
+ ...(message.message ? { quote: { label: reply.messageLabel, text: message.message } } : {}),
169
+ footer: [
170
+ {
171
+ label: company,
172
+ value: page ? new URL(page).origin.replace("https://", "") : site,
173
+ href: page ? new URL(page).origin : `https://${site}`,
174
+ },
175
+ ],
176
+ }),
177
+ inlineImages,
178
+ });
179
+ }
180
+ catch (error) {
181
+ reportError("contact: the automatic reply failed", error);
182
+ }
183
+ }
90
184
  return { status: "sent" };
91
185
  }
92
186
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/contact-action/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC1G,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,sC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EAAE,CAAC;4BAC3F,MAAM,EAAE;gCACN;oCACE,KAAK,EAAE,OAAO;oCACd,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;oCACjE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,IAAI,EAAE;iCACtD;6BACF;yBACF,CAAC;wBACF,YAAY;qBACb,CAAC,CAAC;gBACL,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,WAAW,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,UAAU,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB;gBAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;YAClG,WAAW,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAC9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { EmailSender, EmailServerConfiguration } from "@sharadox/email-web-library";
2
- import type { ContactMessage, ContactReach } from "@sharadox/form-web-library/parse-contact/type";
2
+ import type { EmailTheme } from "@sharadox/form-web-library/contact-email/type";
3
+ import type { ContactReach } from "@sharadox/form-web-library/parse-contact/type";
3
4
  /** What the form shows after a submission. */
4
5
  export interface ContactState {
5
6
  status: "idle" | "sent" | "invalid" | "rate-limited" | "failed";
@@ -12,21 +13,61 @@ export interface ContactLabels {
12
13
  company: string;
13
14
  needs: string;
14
15
  language: string;
15
- /** Before the site's name: "New message from". */
16
- from: string;
16
+ /** The small capitals above the visitor's name: "Contact". */
17
+ contact: string;
18
+ /** Above the visitor's message: "Message". */
19
+ message: string;
20
+ /** The page the form was sent from: "Form". */
21
+ page: string;
22
+ /** When it was sent: "Sent". */
23
+ sent: string;
24
+ }
25
+ /** The automatic reply to the visitor, in one language: thanks, what happens next, and their message back. */
26
+ export interface ContactAcknowledgement {
27
+ /** For example "Sharadox · We received your message". */
28
+ subject: string;
29
+ /** The heading, from the visitor's name, for example `Thank you, ${name}.`. */
30
+ heading: (name: string) => string;
31
+ /** What happens next. */
32
+ paragraphs: readonly string[];
33
+ /** Above their message: "Your message". */
34
+ messageLabel: string;
35
+ /** The small capitals above the heading, for example "Message received". */
36
+ eyebrow: string;
37
+ }
38
+ /** The company's logo at the top of every email: a square image (PNG), sent inside the email. */
39
+ export interface EmailLogo {
40
+ content: Uint8Array;
41
+ contentType: string;
42
+ filename: string;
17
43
  }
18
44
  export interface ContactActionOptions {
19
45
  /** Where messages go, for example "contact@sharadox.com". */
20
46
  to: string;
21
- /** The sender's display name, for example "Sharadox Web Application". */
22
- senderName: string;
47
+ /**
48
+ * The company, for example "Sharadox". Its emails come from "<company> Web Application", with the subject
49
+ * "<company> Web Application · Contact · Name (Company)", and carry its name beside the logo.
50
+ */
51
+ company: string;
23
52
  /** The sender address (an address the email server may send from); `EMAIL_SENDER_ADDRESS` or the server user. */
24
53
  senderAddress?: string;
25
- /** The email subject for a message, for example `Contact · Ana (Café)`. */
26
- subject: (message: ContactMessage) => string;
54
+ /** The company's logo, at the top of every email. */
55
+ logo?: () => Promise<EmailLogo>;
56
+ /** The brand's colors for the top of every email; black and white by default. */
57
+ theme?: EmailTheme;
58
+ /** Each language's name in the email, by code; English names of common languages by default. */
59
+ languageNames?: Readonly<Record<string, string>>;
60
+ /**
61
+ * The automatic reply to visitors who left an email, by language (the form's locale; the first one otherwise). It
62
+ * comes from the same sender, and replying to it reaches `to`. None by default.
63
+ */
64
+ acknowledgement?: Readonly<Record<string, ContactAcknowledgement>>;
27
65
  /** Choices the form may send, and how each is named in the email; none by default. */
28
66
  choices?: Readonly<Record<string, string>>;
29
- /** Where the email says the message came from, for example "sharadox.com". */
67
+ /**
68
+ * The site's domain, for example "sharadox.com". The page the form was sent from (the "page" field) is shown only
69
+ * when it is on this domain or one of its subdomains.
70
+ */
30
71
  site: string;
31
72
  /** "email" (the default) requires an email; "email-or-phone" accepts either way of answering. */
32
73
  reach?: ContactReach;
@@ -55,5 +96,7 @@ export interface ContactActionOptions {
55
96
  createSender?: (configuration: EmailServerConfiguration) => EmailSender;
56
97
  /** Where failures are reported; `console.error` by default. */
57
98
  reportError?: (message: string, error: unknown) => void;
99
+ /** Now, for the time the email shows (tests). */
100
+ now?: () => Date;
58
101
  }
59
102
  //# 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,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAElG,8CAA8C;AAC9C,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,cAAc,GAAG,QAAQ,CAAC;CACjE;AAED,2GAA2G;AAC3G,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,6DAA6D;IAC7D,EAAE,EAAE,MAAM,CAAC;IACX,yEAAyE;IACzE,UAAU,EAAE,MAAM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AAI,CAAC;IACxD,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB"}
@@ -0,0 +1,12 @@
1
+ import type { BrandedEmailOptions } from "@sharadox/form-web-library/contact-email/type";
2
+ /**
3
+ * A company's email, the same in every inbox: the logo and the company's name on its own colors at the top, a thin
4
+ * accent line, then the heading, any paragraphs, a table of details, a quoted text and small print at the bottom.
5
+ * Built from tables with inline styles, as email clients need; everything given is escaped.
6
+ *
7
+ * @example
8
+ * brandedEmailHtml({ company: "Sharadox", theme, logo: true, language: "en", preview: "Ana sent a message",
9
+ * eyebrow: "Contact", heading: "Ana (Café)", rows: [{ label: "Email", value: "ana@example.com" }] });
10
+ */
11
+ export declare function brandedEmailHtml(options: BrandedEmailOptions): string;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/contact-email/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAY,MAAM,+CAA+C,CAAC;AAUnG;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA6CrE"}
@@ -0,0 +1,47 @@
1
+ import { escapeHtml } from "@sharadox/web-library/html/escape";
2
+ const FONT = "-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif";
3
+ /** A value, as a link when it has one. */
4
+ const value = ({ value: text, href }, color) => href
5
+ ? `<a href="${escapeHtml(href)}" style="color:${color};text-decoration:underline">${escapeHtml(text)}</a>`
6
+ : escapeHtml(text);
7
+ /**
8
+ * A company's email, the same in every inbox: the logo and the company's name on its own colors at the top, a thin
9
+ * accent line, then the heading, any paragraphs, a table of details, a quoted text and small print at the bottom.
10
+ * Built from tables with inline styles, as email clients need; everything given is escaped.
11
+ *
12
+ * @example
13
+ * brandedEmailHtml({ company: "Sharadox", theme, logo: true, language: "en", preview: "Ana sent a message",
14
+ * eyebrow: "Contact", heading: "Ana (Café)", rows: [{ label: "Email", value: "ana@example.com" }] });
15
+ */
16
+ export function brandedEmailHtml(options) {
17
+ const { company, theme, logo, language, preview, eyebrow, heading, paragraphs = [], rows = [], quote, footer = [], } = options;
18
+ const mark = logo
19
+ ? `<td style="padding:0 14px 0 0;vertical-align:middle"><img src="cid:logo" width="44" height="44" alt="${escapeHtml(company)}" style="display:block;width:44px;height:44px;border:0;border-radius:10px"></td>`
20
+ : "";
21
+ const table = rows.length
22
+ ? `<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="border-collapse:collapse;margin:24px 0 0">${rows
23
+ .map((row) => `<tr><td style="padding:12px 16px 12px 0;border-top:1px solid #ececec;width:132px;vertical-align:top;font:500 13px/1.5 ${FONT};color:#71717a">${escapeHtml(row.label)}</td><td style="padding:12px 0;border-top:1px solid #ececec;vertical-align:top;font:400 15px/1.5 ${FONT};color:#18181b;word-break:break-word">${value(row, "#18181b")}</td></tr>`)
24
+ .join("")}</table>`
25
+ : "";
26
+ const text = quote
27
+ ? `<p style="margin:28px 0 8px;font:500 13px/1.5 ${FONT};color:#71717a">${escapeHtml(quote.label)}</p><div style="padding:18px 20px;background:#f6f6f7;border-radius:12px;font:400 15px/1.65 ${FONT};color:#18181b;white-space:pre-wrap;word-break:break-word">${escapeHtml(quote.text)}</div>`
28
+ : "";
29
+ const small = footer.length
30
+ ? `<tr><td style="padding:20px 32px;background:#fafafa;border-top:1px solid #ececec;font:400 12px/1.7 ${FONT};color:#71717a">${footer
31
+ .map((row) => `${escapeHtml(row.label)}: ${value(row, "#52525b")}`)
32
+ .join("<br>")}</td></tr>`
33
+ : "";
34
+ return `<!doctype html><html lang="${escapeHtml(language)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="color-scheme" content="light"><title>${escapeHtml(heading)}</title></head><body style="margin:0;padding:0;background:#f4f4f5">
35
+ <div style="display:none;max-height:0;overflow:hidden;opacity:0">${escapeHtml(preview)}</div>
36
+ <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5"><tr><td align="center" style="padding:32px 12px">
37
+ <table role="presentation" width="600" cellpadding="0" cellspacing="0" style="width:100%;max-width:600px;background:#ffffff;border:1px solid #e4e4e7;border-radius:16px;overflow:hidden">
38
+ <tr><td style="background:${theme.background};padding:24px 32px"><table role="presentation" cellpadding="0" cellspacing="0"><tr>${mark}<td style="vertical-align:middle;font:600 18px/1.2 ${FONT};letter-spacing:-0.01em;color:${theme.foreground}">${escapeHtml(company)}</td></tr></table></td></tr>
39
+ <tr><td style="height:3px;line-height:3px;font-size:0;background:${theme.accent}">&nbsp;</td></tr>
40
+ <tr><td style="padding:32px">
41
+ <p style="margin:0 0 10px;font:600 11px/1.4 ${FONT};letter-spacing:0.12em;text-transform:uppercase;color:#71717a">${escapeHtml(eyebrow)}</p>
42
+ <h1 style="margin:0;font:600 24px/1.3 ${FONT};letter-spacing:-0.02em;color:#09090b">${escapeHtml(heading)}</h1>
43
+ ${paragraphs.map((paragraph) => `<p style="margin:16px 0 0;font:400 15px/1.65 ${FONT};color:#3f3f46">${escapeHtml(paragraph)}</p>`).join("")}${table}${text}
44
+ </td></tr>${small}
45
+ </table></td></tr></table></body></html>`;
46
+ }
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/contact-email/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAG/D,MAAM,IAAI,GAAG,+EAA+E,CAAC;AAE7F,0CAA0C;AAC1C,MAAM,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAY,EAAE,KAAa,EAAE,EAAE,CAC/D,IAAI;IACF,CAAC,CAAC,YAAY,UAAU,CAAC,IAAI,CAAC,kBAAkB,KAAK,+BAA+B,UAAU,CAAC,IAAI,CAAC,MAAM;IAC1G,CAAC,CAAC,UAAU,CAAC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,UAAU,CAAC,QAAQ,CAAC,qJAAqJ,UAAU,CAAC,OAAO,CAAC;mEAChK,UAAU,CAAC,OAAO,CAAC;;;4BAG1D,KAAK,CAAC,UAAU,sFAAsF,IAAI,sDAAsD,IAAI,iCAAiC,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,OAAO,CAAC;mEACtM,KAAK,CAAC,MAAM;;8CAEjC,IAAI,kEAAkE,UAAU,CAAC,OAAO,CAAC;wCAC/F,IAAI,0CAA0C,UAAU,CAAC,OAAO,CAAC;EACvG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,gDAAgD,IAAI,mBAAmB,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,IAAI;YAC/I,KAAK;yCACwB,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,41 @@
1
+ /** A brand's colors for its emails: the band at the top and the thin line under it. */
2
+ export interface EmailTheme {
3
+ /** The top band's color, behind the logo, for example "#000000". */
4
+ background: string;
5
+ /** The company name's color on the band, for example "#ffffff". */
6
+ foreground: string;
7
+ /** The thin line under the band, for example the brand's gold. */
8
+ accent: string;
9
+ }
10
+ /** One line of the details table: a label and its value (plain text, or `href` to make it a link). */
11
+ export interface EmailRow {
12
+ label: string;
13
+ value: string;
14
+ href?: string;
15
+ }
16
+ export interface BrandedEmailOptions {
17
+ /** The company, beside the logo in the top band. */
18
+ company: string;
19
+ theme: EmailTheme;
20
+ /** True when a logo is sent with the email as the inline image "logo". */
21
+ logo: boolean;
22
+ /** The language of the email, for the html's `lang`. */
23
+ language: string;
24
+ /** The line shown in the inbox's preview, before the email is opened. */
25
+ preview: string;
26
+ /** The small capitals above the heading, for example "Contact". */
27
+ eyebrow: string;
28
+ heading: string;
29
+ /** Paragraphs under the heading. */
30
+ paragraphs?: readonly string[];
31
+ /** The details table. */
32
+ rows?: EmailRow[];
33
+ /** A longer text in its own box, keeping its line breaks (the visitor's message), with its label. */
34
+ quote?: {
35
+ label: string;
36
+ text: string;
37
+ };
38
+ /** Small print at the bottom: where it came from, when, and so on. */
39
+ footer?: EmailRow[];
40
+ }
41
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/contact-email/type.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,WAAW,UAAU;IACzB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,sGAAsG;AACtG,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;IAClB,0EAA0E;IAC1E,IAAI,EAAE,OAAO,CAAC;IACd,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,yBAAyB;IACzB,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB,qGAAqG;IACrG,KAAK,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,sEAAsE;IACtE,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/contact-email/type.ts"],"names":[],"mappings":""}
package/llms.txt CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  > Server-side forms: bot checks, rate limit, contact action emailing via @sharadox/email-web-library.
4
4
 
5
- - /contact-action: createContactAction({ to, senderName, senderAddress?, site, subject(message), choices?: { key: label }, reach? = 'email' | 'email-or-phone', requireMessage? = true, minimumMessageLength? = 1, requireChoice? = false, fields?: { name: label }, labels?: Partial<ContactLabels> (English default, ENGLISH_LABELS), rateLimit? = 5/hour per address, dailyMaximum? = 50 emails/day from everyone (per server instance; caps email cost under a flood), readConfiguration?, createSender?, reportError? }) → (form, ip) => { status: idle|sent|invalid|rate-limited|failed }. Reply-to = visitor when they gave an email; bots get fake 'sent'.
6
- - Form fields: name, email, phone (valid: + digits spaces ().- with ≥7 digits), company, message, extra fields, locale, started-at, website (honeypot), need (checkboxes).
5
+ - /contact-action: createContactAction({ to, company (sender "<company> Web Application", subject "<company> Web Application · <labels.contact> · Name (Company)"), senderAddress?, site (domain; the form's `page` field is shown only on it or a subdomain), logo?: () => Promise<{ content, contentType, filename }> (inline cid:logo at the top), theme? { background, foreground, accent }, languageNames?, acknowledgement?: { [locale]: { subject, eyebrow, heading(name), paragraphs, messageLabel } } (automatic reply to the visitor's email, in their language, reply-to = to; a failed reply never fails the send), choices?: { key: label }, reach? = 'email' | 'email-or-phone', requireMessage? = true, minimumMessageLength? = 1, requireChoice? = false, fields?: { name: label }, labels?: Partial<ContactLabels> (English default, ENGLISH_LABELS), rateLimit? = 5/hour per address, dailyMaximum? = 50 emails/day from everyone (per server instance; caps email cost under a flood), readConfiguration?, createSender?, reportError? }) → (form, ip) => { status: idle|sent|invalid|rate-limited|failed }. Reply-to = visitor when they gave an email; bots get fake 'sent'. The email: branded layout (logo + company on the theme, accent line), every detail, the message, then Form (page), Language (name), Sent (UTC), IP.
6
+ - /contact-email brandedEmailHtml(options): the layout, for any email (tables, inline styles, escaped)
7
+ - 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).
7
8
  - /parse-contact: parseContact(form, { choices, choiceField='need', reach, requireMessage, minimumMessageLength, requireChoice, fields, now }) → value { name, email, phone, company, message, locale, choices, fields }
8
9
  - /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)
9
10
  - Env: EMAIL_SERVER_HOST/PORT/USERNAME/PASSWORD, EMAIL_SENDER_ADDRESS. License: Sharadox Open Source License 0.1.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sharadox/form-web-library",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Forms 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.",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENCA.md",
@@ -64,7 +64,7 @@
64
64
  "vitest": "^5.1.0"
65
65
  },
66
66
  "dependencies": {
67
- "@sharadox/email-web-library": "^0.2.1",
67
+ "@sharadox/email-web-library": "^0.3.0",
68
68
  "@sharadox/web-library": "^0.7.0"
69
69
  },
70
70
  "scripts": {