@brandlab-digital/site-next 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -134,6 +134,41 @@ the sender domain verified in Resend and the inbox not suppressed. Run `brandlab
134
134
  and a full-access key (`RESEND_LOOKUP_API_KEY`) set in the shell for that run, never written to a file. Without them H13
135
135
  reports "not run" and names what to set: in an ordinary run that does not block the tier, and under `--launch` it fails.
136
136
 
137
+ ## Contact route: shared spam filter (4.1.0)
138
+
139
+ Every site on the shared contact handler screens enquiries for sales pitches after validation and before delivery.
140
+ A blocked enquiry gets the normal silent success: the visitor sees the usual thank-you, nothing is sent to Resend,
141
+ `contact_form` does not fire, and the server logs one redacted line with the site and signals only:
142
+ `{"event":"brandlab_contact_spam_blocked","site":"abloom","signals":["pitch-marketing","foreign-suburb"]}`.
143
+
144
+ - **Strong signals:** pitch wording (SEO and rankings, Google review selling or removal, take-off and estimating,
145
+ "reach me via email" lures, website audits and redesigns), wa.me / WhatsApp / Telegram links, look-alike Unicode
146
+ letters, and a known spam sender (SHA-256 of the trimmed, lower-cased address; raw addresses are never stored).
147
+ - **Weak signals:** any link in the message, an overseas phone number in the text, and a suburb that is clearly
148
+ foreign or random characters ("IN", "Dhaka", "cvsfewf"). Typos, abbreviations ("Nth Ryde", "St Ives"), postcodes and
149
+ interstate places are fine. Only the field whose key is `suburb` is read; street-address fields are never scored.
150
+ - **Rule:** block only with at least two signals, at least one of them strong. A second hit in the same pitch
151
+ category counts as another signal. Weak signals never block on their own or together, and a filter fault always
152
+ delivers.
153
+ - **Fill time:** the shared form stamps `formStartedAt` when it renders. A submission under 3 seconds later is dropped
154
+ silently (`signals:["fill-time"]`). A form without the stamp is never dropped on time. Scripted live or preview test
155
+ enquiries must wait at least 3 seconds after the page loads before sending.
156
+
157
+ Site overrides go through `spamFilter` on `createBrandlabContactRouteHandler`: `extraPhrases`, `knownSenderHashes`,
158
+ `ignoreSignals`, `minFillMs`, or `false` to turn the filter off. There is no bypass word; a genuine test enquiry passes
159
+ on its own wording.
160
+
161
+ ## Contact route: Preview test enquiries reach only Brandlab (4.2.0)
162
+
163
+ On a Preview deployment (`VERCEL_ENV` other than production) a marked test enquiry (`bl_test=1`) is sent only to
164
+ `BRANDLAB_PREVIEW_TEST_RECIPIENT` (info@brandlabdigital.com.au), whatever the deployment's `CONTACT_EMAIL` says, with
165
+ "[Test]" in the subject and a silent success. It works on a Preview with no recipient set; real enquiries there still
166
+ fail until one is. The marker is not a spam-filter bypass: the enquiry must pass the shared filter like any other.
167
+ Every answer of a Preview's contact route carries `x-brandlab-contact-mode: preview; test-inbox=brandlab`
168
+ (`BRANDLAB_PREVIEW_CONTACT_HEADER`); production never sends it. Production keeps the 3.10.0 behaviour: a marked
169
+ enquiry goes to the configured recipients with "[Test]". Send the release test with conformance's
170
+ `brandlab-preview-enquiry`, which checks that header before it sends anything.
171
+
137
172
  ## Contact route: abuse limits and the test marker (3.10.0)
138
173
 
139
174
  `createBrandlabContactRouteHandler` limits distinct enquiries per client IP and per email address where enquiries are
@@ -18,6 +18,8 @@ export interface ContactHttpSubmissionControllerOptions {
18
18
  contactEndpoint?: string;
19
19
  fetcher?: typeof fetch;
20
20
  now?: () => Date;
21
+ /** When the form first rendered; kept across controller re-creation so the server's fill-time check is fair. */
22
+ startedAt?: Date;
21
23
  /** Reports an accepted enquiry, once per confirmation ID, with the attempt's fields. */
22
24
  reportAccepted?: (result: Extract<ContactActionResult, {
23
25
  ok: true;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/contact/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,qCAAqC,CAAA;AAG5C,OAAO,EAGL,yBAAyB,EAC1B,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,yBAAyB,EAAE,CAAA;AAEpC,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,IAAI,E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B,wFAAwF;IACxF,cAAc,CAAC,EAAE,CACf,MAAM,EAAE,OAAO,CAAC,mBAAmB,EAAE;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE,CAAC,EAClE,QAAQ,EAAE,QAAQ,KACf,IAAI,CAAA;IACT,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAA;CACxD;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,IAAI,sBAAsB,CAAA;IAClC;;;;OAIG;IACH,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACxD,yDAAyD;IACzD,KAAK,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACrC,KAAK,IAAI,IAAI,CAAA;CACd;AA8DD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,GAAG,OAAO,CAEvF;AA2CD,wBAAgB,qCAAqC,CACnD,OAAO,EAAE,sCAAsC,GAC9C,2BAA2B,CAwI7B"}
@@ -188,6 +188,9 @@ function addSubmissionMetadata(formData, options) {
188
188
  : getInitialContactAttribution(window);
189
189
  formData.set(CONTACT_FORM_FIELDS.clientSubmissionId, createContactSubmissionId());
190
190
  formData.set(CONTACT_FORM_FIELDS.submittedAt, options.now.toISOString());
191
+ if (options.startedAt && Number.isFinite(options.startedAt.getTime())) {
192
+ formData.set(CONTACT_FORM_FIELDS.formStartedAt, options.startedAt.toISOString());
193
+ }
191
194
  formData.set(CONTACT_FORM_FIELDS.pagePath, options.pagePath);
192
195
  if (options.pageLabel) {
193
196
  formData.set(CONTACT_FORM_FIELDS.pageLabel, options.pageLabel);
@@ -213,6 +216,8 @@ export function createContactHttpSubmissionController(options) {
213
216
  throw new TypeError('reportAccepted must be a function.');
214
217
  }
215
218
  const trackedConfirmations = new Set();
219
+ // The minimum fill time (4.1.0) measures from here: the form's controller is created when the form renders.
220
+ const startedAt = options.startedAt ?? options.now?.() ?? new Date();
216
221
  let attempt;
217
222
  let attemptFields;
218
223
  let inFlight;
@@ -311,6 +316,7 @@ export function createContactHttpSubmissionController(options) {
311
316
  pagePath,
312
317
  ...(pageLabel ? { pageLabel } : {}),
313
318
  now,
319
+ startedAt,
314
320
  });
315
321
  return run(attempt);
316
322
  },
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/contact/client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EACL,4BAA4B,EAC5B,oCAAoC,GAErC,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,EACL,+BAA+B,EAC/B,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,yBAAyB,EAAE,CAAA;AAEpC,MAAM,UAAU,0BAA0B,CAAC,QAAc,EAAE,SAAe;IACxE,IAAI,CAAC,CAAC,QAAQ,YAAY,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,YAAY,IAAI,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,SAAS,CAAC,oEAAoE,CAAC,CAAA;IAC3F,CAAC;IACD,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAA;IACnD,MAAM,YAAY,GAAG,4BAA4B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChE,MAAM,aAAa,GAAG,4BAA4B,CAAC,EAAE,EAAE,WAAW,CAAC,CAAA;IACnE,MAAM,sBAAsB,GAAG,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAA;IACzF,MAAM,uBAAuB,GAAG,aAAa,KAAK,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAA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CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnC,GAAG;aACJ,CAAC,CAAA;YACF,OAAO,GAAG,CAAC,OAAO,CAAC,CAAA;QACrB,CAAC;QACD,KAAK;YACH,IAAI,QAAQ;gBAAE,OAAO,QAAQ,CAAA;YAC7B,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,KAAK,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;gBAC3D,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC,CAAA;YACnF,CAAC;YACD,OAAO,GAAG,CAAC,OAAO,CAAC,CAAA;QACrB,CAAC;QACD,KAAK;YACH,IAAI,QAAQ;gBAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;YAC9E,OAAO,GAAG,SAAS,CAAA;YACnB,aAAa,GAAG,SAAS,CAAA;YACzB,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;QAC7D,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\nimport {\n resolveContactAttachmentType,\n detectContactTransportAttachmentType,\n type ContactActionResult,\n} from '@brandlab-digital/site-core/contact'\nimport { normalizeBrandlabRoutePath } from '@brandlab-digital/site-core/routes'\nimport { getInitialContactAttribution } from '../instrumentation-client.js'\nimport {\n CONTACT_CONFIRMATION_ID_PATTERN,\n CONTACT_FORM_FIELDS,\n createContactSubmissionId,\n} from './shared.js'\n\nexport { createContactSubmissionId }\n\nexport function normalizeContactUploadFile(original: File, processed: Blob): File {\n if (!(original instanceof File) || !(processed instanceof Blob)) {\n throw new TypeError('Contact image normalisation requires browser File and Blob values.')\n }\n const contentType = processed.type || original.type\n const filenameType = resolveContactAttachmentType(original.name)\n const processedType = resolveContactAttachmentType('', contentType)\n const normalizedFilenameType = filenameType === 'image/jpg' ? 'image/jpeg' : filenameType\n const normalizedProcessedType = processedType === 'image/jpg' ? 'image/jpeg' : processedType\n if (!normalizedFilenameType || normalizedFilenameType !== normalizedProcessedType) {\n throw new TypeError('The processed contact image does not match its reviewed filename.')\n }\n return new File([processed], original.name, {\n type: normalizedFilenameType,\n lastModified: original.lastModified,\n })\n}\n\n/** Explicit format-changing path; never relabel the original HEIC bytes as JPEG. */\nexport async function normalizeContactConvertedUploadFile(original: File, processed: Blob): Promise<File> {\n if (!(original instanceof File) || !(processed instanceof Blob)) {\n throw new TypeError('Contact image conversion requires browser File and Blob values.')\n }\n const selectedType = resolveContactAttachmentType(original.name, original.type)\n if (\n !['image/heic', 'image/heif'].includes(selectedType ?? '') ||\n processed.type !== 'image/jpeg' || processed.size === 0 ||\n detectContactTransportAttachmentType(new Uint8Array(await processed.slice(0, 12).arrayBuffer())) !== 'image/jpeg'\n ) {\n throw new TypeError('The converted contact image must contain JPEG bytes.')\n }\n return new File([processed], `${original.name.replace(/\\.[^.]*$/, '') || 'photo'}.jpg`, {\n type: 'image/jpeg', lastModified: original.lastModified,\n })\n}\n\nconst CONTACT_FIELD_ERROR_KEY_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/\nconst CONTACT_ERROR_CODES = new Set([\n 'validation',\n 'attachment_rejected',\n 'delivery_unavailable',\n])\n\nfunction objectRecord(value: unknown): Record<string, unknown> | undefined {\n return value && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined\n}\n\nfunction hasOnlyKeys(record: Record<string, unknown>, allowed: readonly string[]) {\n const keys = new Set(allowed)\n return Object.keys(record).every((key) => keys.has(key))\n}\n\nfunction parseFieldErrors(value: unknown) {\n if (value === undefined) return undefined\n const record = objectRecord(value)\n if (!record || Object.keys(record).length > 48) return undefined\n const result: Record<string, string[]> = {}\n for (const [field, messages] of Object.entries(record)) {\n if (\n !CONTACT_FIELD_ERROR_KEY_PATTERN.test(field) ||\n !Array.isArray(messages) ||\n messages.length < 1 ||\n messages.length > 5 ||\n messages.some(\n (message) =>\n typeof message !== 'string' ||\n !message.trim() ||\n message.length > 200 ||\n /[\\u0000-\\u001f\\u007f]/.test(message),\n )\n ) {\n return undefined\n }\n result[field] = [...messages]\n }\n return result\n}\n\nexport function parseContactActionResult(value: unknown): ContactActionResult | undefined {\n const record = objectRecord(value)\n if (!record || typeof record.ok !== 'boolean') return undefined\n if (record.ok) {\n if (record.accepted === true) {\n if (\n !hasOnlyKeys(record, ['ok', 'accepted', 'trackConversion', 'confirmationId']) ||\n record.trackConversion !== true ||\n typeof record.confirmationId !== 'string' ||\n !CONTACT_CONFIRMATION_ID_PATTERN.test(record.confirmationId)\n ) {\n return undefined\n }\n return {\n ok: true,\n accepted: true,\n trackConversion: true,\n confirmationId: record.confirmationId,\n }\n }\n if (\n record.accepted !== false ||\n record.trackConversion !== false ||\n !hasOnlyKeys(record, ['ok', 'accepted', 'trackConversion'])\n ) {\n return undefined\n }\n return { ok: true, accepted: false, trackConversion: false }\n }\n\n if (\n !hasOnlyKeys(record, ['ok', 'code', 'retryable', 'fieldErrors']) ||\n typeof record.code !== 'string' ||\n !CONTACT_ERROR_CODES.has(record.code) ||\n typeof record.retryable !== 'boolean'\n ) {\n return undefined\n }\n const fieldErrors = parseFieldErrors(record.fieldErrors)\n if (record.fieldErrors !== undefined && !fieldErrors) return undefined\n if (record.code !== 'validation' && fieldErrors) return undefined\n return {\n ok: false,\n code: record.code as Extract<ContactActionResult, { ok: false }>['code'],\n retryable: record.retryable,\n ...(fieldErrors ? { fieldErrors } : {}),\n }\n}\n\nexport type ContactSubmissionPhase =\n | 'idle'\n | 'submitting'\n | 'accepted'\n | 'accepted-silently'\n | 'error'\n\nexport interface ContactSubmissionState {\n phase: ContactSubmissionPhase\n pending: boolean\n canRetry: boolean\n result?: ContactActionResult\n}\n\nexport interface ContactHttpSubmissionControllerOptions {\n pagePath: string\n pageLabel?: string\n contactEndpoint?: string\n fetcher?: typeof fetch\n now?: () => Date\n /** Reports an accepted enquiry, once per confirmation ID, with the attempt's fields. */\n reportAccepted?: (\n result: Extract<ContactActionResult, { ok: true; accepted: true }>,\n formData: FormData,\n ) => void\n onStateChange?: (state: ContactSubmissionState) => void\n}\n\nexport interface ContactSubmissionController {\n getState(): ContactSubmissionState\n /**\n * Sends the fields. After a retryable failure, fields identical to the failed\n * attempt resend that attempt with its submission ID; changed fields start a\n * new submission.\n */\n submit(formData: FormData): Promise<ContactActionResult>\n /** Resends the failed attempt with its submission ID. */\n retry(): Promise<ContactActionResult>\n reset(): void\n}\n\ntype FormDataFields = readonly (readonly [string, FormDataEntryValue])[]\n\nfunction sameEntryValue(left: FormDataEntryValue, right: FormDataEntryValue) {\n if (typeof left === 'string' || typeof right === 'string') return left === right\n return left === right || (\n left.name === right.name &&\n left.size === right.size &&\n left.type === right.type &&\n left.lastModified === right.lastModified\n )\n}\n\nfunction sameFields(left: FormDataFields, right: FormDataFields) {\n return left.length === right.length && left.every(([name, value], index) =>\n name === right[index]![0] && sameEntryValue(value, right[index]![1]))\n}\n\nfunction copyFormData(formData: FormData) {\n if (!formData || typeof formData.entries !== 'function') {\n throw new TypeError('A FormData submission is required.')\n }\n const copy = new FormData()\n for (const [name, value] of formData.entries()) copy.append(name, value)\n return copy\n}\n\nfunction rootRelativeEndpoint(value: string | undefined, fallback: string) {\n const endpoint = value ?? fallback\n if (\n !/^\\/[a-z0-9/_-]+$/.test(endpoint) ||\n endpoint.includes('//') ||\n endpoint.endsWith('/')\n ) {\n throw new TypeError('Contact endpoints must be canonical root-relative paths.')\n }\n return endpoint\n}\n\nasync function boundedJson(response: Response, maximumBytes: number) {\n const contentType = response.headers\n .get('content-type')\n ?.split(';', 1)[0]\n ?.trim()\n .toLowerCase()\n if (contentType !== 'application/json') {\n throw new Error('The contact response did not use the required JSON media type.')\n }\n const text = await response.text()\n if (new TextEncoder().encode(text).byteLength > maximumBytes) {\n throw new Error('The contact response exceeded its safe bound.')\n }\n return JSON.parse(text) as unknown\n}\n\nconst RETRYABLE_CLIENT_FAILURE: ContactActionResult = Object.freeze({\n ok: false,\n code: 'delivery_unavailable',\n retryable: true,\n})\n\n/**\n * True for the result the controller reports when the browser could not complete\n * the request or read a valid answer (offline, blocked, a platform error page or\n * malformed JSON), as opposed to a delivery failure the server reported.\n */\nexport function isContactClientFailure(result: ContactActionResult | undefined): boolean {\n return result === RETRYABLE_CLIENT_FAILURE\n}\n\nfunction reviewedPageLabel(value: string | undefined) {\n const label = value?.trim()\n if (\n label !== undefined &&\n (!label || label.length > 160 || /[\\u0000-\\u001f\\u007f]/.test(label))\n ) {\n throw new TypeError('pageLabel must be bounded reviewed text.')\n }\n return label\n}\n\nfunction addSubmissionMetadata(\n formData: FormData,\n options: {\n pagePath: string\n pageLabel?: string\n now: Date\n },\n) {\n const attribution =\n typeof window === 'undefined'\n ? { initialLandingPath: options.pagePath, visitSource: 'direct-or-unknown' as const }\n : getInitialContactAttribution(window)\n formData.set(CONTACT_FORM_FIELDS.clientSubmissionId, createContactSubmissionId())\n formData.set(CONTACT_FORM_FIELDS.submittedAt, options.now.toISOString())\n formData.set(CONTACT_FORM_FIELDS.pagePath, options.pagePath)\n if (options.pageLabel) {\n formData.set(CONTACT_FORM_FIELDS.pageLabel, options.pageLabel)\n }\n formData.set(CONTACT_FORM_FIELDS.initialLandingPath, attribution.initialLandingPath)\n formData.set(CONTACT_FORM_FIELDS.visitSource, attribution.visitSource)\n if (attribution.visitSourceDetail) {\n formData.set(CONTACT_FORM_FIELDS.visitSourceDetail, attribution.visitSourceDetail)\n }\n return formData\n}\n\nexport function createContactHttpSubmissionController(\n options: ContactHttpSubmissionControllerOptions,\n): ContactSubmissionController {\n const contactEndpoint = rootRelativeEndpoint(options.contactEndpoint, '/api/contact')\n const pagePath = normalizeBrandlabRoutePath(options.pagePath)\n const pageLabel = reviewedPageLabel(options.pageLabel)\n const fetcher = options.fetcher ?? fetch\n if (typeof fetcher !== 'function') throw new TypeError('A fetch implementation is required.')\n if (options.onStateChange !== undefined && typeof options.onStateChange !== 'function') {\n throw new TypeError('onStateChange must be a function.')\n }\n if (options.reportAccepted !== undefined && typeof options.reportAccepted !== 'function') {\n throw new TypeError('reportAccepted must be a function.')\n }\n\n const trackedConfirmations = new Set<string>()\n let attempt: FormData | undefined\n let attemptFields: FormDataFields | undefined\n let inFlight: Promise<ContactActionResult> | undefined\n let state: ContactSubmissionState = {\n phase: 'idle',\n pending: false,\n canRetry: false,\n }\n\n const publish = (next: ContactSubmissionState) => {\n state = Object.freeze({ ...next })\n options.onStateChange?.(state)\n }\n\n const post = async (formData: FormData) => {\n publish({ phase: 'submitting', pending: true, canRetry: false })\n let result: ContactActionResult\n try {\n const response = await fetcher(contactEndpoint, {\n method: 'POST',\n credentials: 'same-origin',\n cache: 'no-store',\n body: copyFormData(formData),\n })\n result =\n parseContactActionResult(await boundedJson(response, 64 * 1_024)) ??\n RETRYABLE_CLIENT_FAILURE\n } catch {\n result = RETRYABLE_CLIENT_FAILURE\n }\n\n if (!result.ok) {\n publish({\n phase: 'error',\n pending: false,\n canRetry: result.retryable,\n result,\n })\n return result\n }\n\n if (result.accepted && !trackedConfirmations.has(result.confirmationId)) {\n trackedConfirmations.add(result.confirmationId)\n try {\n options.reportAccepted?.(result, copyFormData(formData))\n } catch {\n // Delivery has already succeeded; analytics cannot change that result.\n }\n }\n\n attempt = undefined\n attemptFields = undefined\n publish({\n phase: result.accepted ? 'accepted' : 'accepted-silently',\n pending: false,\n canRetry: false,\n result,\n })\n return result\n }\n\n const run = (formData: FormData) => {\n if (inFlight) return inFlight\n let wrapped: Promise<ContactActionResult>\n wrapped = post(formData).finally(() => {\n if (inFlight === wrapped) inFlight = undefined\n })\n inFlight = wrapped\n return wrapped\n }\n\n return {\n getState: () => ({ ...state }),\n submit(formData) {\n if (inFlight) return inFlight\n const fields = [...copyFormData(formData).entries()]\n if (\n attempt &&\n attemptFields &&\n state.phase === 'error' &&\n state.canRetry &&\n sameFields(attemptFields, fields)\n ) {\n return run(attempt)\n }\n const now = options.now?.() ?? new Date()\n if (!Number.isFinite(now.getTime())) {\n attempt = undefined\n attemptFields = undefined\n publish({\n phase: 'error',\n pending: false,\n canRetry: false,\n result: RETRYABLE_CLIENT_FAILURE,\n })\n return Promise.resolve(RETRYABLE_CLIENT_FAILURE)\n }\n attemptFields = fields\n attempt = addSubmissionMetadata(copyFormData(formData), {\n pagePath,\n ...(pageLabel ? { pageLabel } : {}),\n now,\n })\n return run(attempt)\n },\n retry() {\n if (inFlight) return inFlight\n if (!attempt || state.phase !== 'error' || !state.canRetry) {\n return Promise.reject(new Error('No retryable contact submission is available.'))\n }\n return run(attempt)\n },\n reset() {\n if (inFlight) throw new Error('A pending contact submission cannot be reset.')\n attempt = undefined\n attemptFields = undefined\n publish({ phase: 'idle', pending: false, canRetry: false })\n },\n }\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/contact/client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EACL,4BAA4B,EAC5B,oCAAoC,GAErC,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,EACL,+BAA+B,EAC/B,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,yBAAyB,EAAE,CAAA;AAEpC,MAAM,UAAU,0BAA0B,CAAC,QAAc,EAAE,SAAe;IACxE,IAAI,CAAC,CAAC,QAAQ,YAAY,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,YAAY,IAAI,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,SAAS,CAAC,oEAAoE,CAAC,CAAA;IAC3F,CAAC;IACD,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAA;IACnD,MAAM,YAAY,GAAG,4BAA4B,CAAC,QAAQ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YACzB,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;QAC7D,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\nimport {\n resolveContactAttachmentType,\n detectContactTransportAttachmentType,\n type ContactActionResult,\n} from '@brandlab-digital/site-core/contact'\nimport { normalizeBrandlabRoutePath } from '@brandlab-digital/site-core/routes'\nimport { getInitialContactAttribution } from '../instrumentation-client.js'\nimport {\n CONTACT_CONFIRMATION_ID_PATTERN,\n CONTACT_FORM_FIELDS,\n createContactSubmissionId,\n} from './shared.js'\n\nexport { createContactSubmissionId }\n\nexport function normalizeContactUploadFile(original: File, processed: Blob): File {\n if (!(original instanceof File) || !(processed instanceof Blob)) {\n throw new TypeError('Contact image normalisation requires browser File and Blob values.')\n }\n const contentType = processed.type || original.type\n const filenameType = resolveContactAttachmentType(original.name)\n const processedType = resolveContactAttachmentType('', contentType)\n const normalizedFilenameType = filenameType === 'image/jpg' ? 'image/jpeg' : filenameType\n const normalizedProcessedType = processedType === 'image/jpg' ? 'image/jpeg' : processedType\n if (!normalizedFilenameType || normalizedFilenameType !== normalizedProcessedType) {\n throw new TypeError('The processed contact image does not match its reviewed filename.')\n }\n return new File([processed], original.name, {\n type: normalizedFilenameType,\n lastModified: original.lastModified,\n })\n}\n\n/** Explicit format-changing path; never relabel the original HEIC bytes as JPEG. */\nexport async function normalizeContactConvertedUploadFile(original: File, processed: Blob): Promise<File> {\n if (!(original instanceof File) || !(processed instanceof Blob)) {\n throw new TypeError('Contact image conversion requires browser File and Blob values.')\n }\n const selectedType = resolveContactAttachmentType(original.name, original.type)\n if (\n !['image/heic', 'image/heif'].includes(selectedType ?? '') ||\n processed.type !== 'image/jpeg' || processed.size === 0 ||\n detectContactTransportAttachmentType(new Uint8Array(await processed.slice(0, 12).arrayBuffer())) !== 'image/jpeg'\n ) {\n throw new TypeError('The converted contact image must contain JPEG bytes.')\n }\n return new File([processed], `${original.name.replace(/\\.[^.]*$/, '') || 'photo'}.jpg`, {\n type: 'image/jpeg', lastModified: original.lastModified,\n })\n}\n\nconst CONTACT_FIELD_ERROR_KEY_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/\nconst CONTACT_ERROR_CODES = new Set([\n 'validation',\n 'attachment_rejected',\n 'delivery_unavailable',\n])\n\nfunction objectRecord(value: unknown): Record<string, unknown> | undefined {\n return value && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined\n}\n\nfunction hasOnlyKeys(record: Record<string, unknown>, allowed: readonly string[]) {\n const keys = new Set(allowed)\n return Object.keys(record).every((key) => keys.has(key))\n}\n\nfunction parseFieldErrors(value: unknown) {\n if (value === undefined) return undefined\n const record = objectRecord(value)\n if (!record || Object.keys(record).length > 48) return undefined\n const result: Record<string, string[]> = {}\n for (const [field, messages] of Object.entries(record)) {\n if (\n !CONTACT_FIELD_ERROR_KEY_PATTERN.test(field) ||\n !Array.isArray(messages) ||\n messages.length < 1 ||\n messages.length > 5 ||\n messages.some(\n (message) =>\n typeof message !== 'string' ||\n !message.trim() ||\n message.length > 200 ||\n /[\\u0000-\\u001f\\u007f]/.test(message),\n )\n ) {\n return undefined\n }\n result[field] = [...messages]\n }\n return result\n}\n\nexport function parseContactActionResult(value: unknown): ContactActionResult | undefined {\n const record = objectRecord(value)\n if (!record || typeof record.ok !== 'boolean') return undefined\n if (record.ok) {\n if (record.accepted === true) {\n if (\n !hasOnlyKeys(record, ['ok', 'accepted', 'trackConversion', 'confirmationId']) ||\n record.trackConversion !== true ||\n typeof record.confirmationId !== 'string' ||\n !CONTACT_CONFIRMATION_ID_PATTERN.test(record.confirmationId)\n ) {\n return undefined\n }\n return {\n ok: true,\n accepted: true,\n trackConversion: true,\n confirmationId: record.confirmationId,\n }\n }\n if (\n record.accepted !== false ||\n record.trackConversion !== false ||\n !hasOnlyKeys(record, ['ok', 'accepted', 'trackConversion'])\n ) {\n return undefined\n }\n return { ok: true, accepted: false, trackConversion: false }\n }\n\n if (\n !hasOnlyKeys(record, ['ok', 'code', 'retryable', 'fieldErrors']) ||\n typeof record.code !== 'string' ||\n !CONTACT_ERROR_CODES.has(record.code) ||\n typeof record.retryable !== 'boolean'\n ) {\n return undefined\n }\n const fieldErrors = parseFieldErrors(record.fieldErrors)\n if (record.fieldErrors !== undefined && !fieldErrors) return undefined\n if (record.code !== 'validation' && fieldErrors) return undefined\n return {\n ok: false,\n code: record.code as Extract<ContactActionResult, { ok: false }>['code'],\n retryable: record.retryable,\n ...(fieldErrors ? { fieldErrors } : {}),\n }\n}\n\nexport type ContactSubmissionPhase =\n | 'idle'\n | 'submitting'\n | 'accepted'\n | 'accepted-silently'\n | 'error'\n\nexport interface ContactSubmissionState {\n phase: ContactSubmissionPhase\n pending: boolean\n canRetry: boolean\n result?: ContactActionResult\n}\n\nexport interface ContactHttpSubmissionControllerOptions {\n pagePath: string\n pageLabel?: string\n contactEndpoint?: string\n fetcher?: typeof fetch\n now?: () => Date\n /** When the form first rendered; kept across controller re-creation so the server's fill-time check is fair. */\n startedAt?: Date\n /** Reports an accepted enquiry, once per confirmation ID, with the attempt's fields. */\n reportAccepted?: (\n result: Extract<ContactActionResult, { ok: true; accepted: true }>,\n formData: FormData,\n ) => void\n onStateChange?: (state: ContactSubmissionState) => void\n}\n\nexport interface ContactSubmissionController {\n getState(): ContactSubmissionState\n /**\n * Sends the fields. After a retryable failure, fields identical to the failed\n * attempt resend that attempt with its submission ID; changed fields start a\n * new submission.\n */\n submit(formData: FormData): Promise<ContactActionResult>\n /** Resends the failed attempt with its submission ID. */\n retry(): Promise<ContactActionResult>\n reset(): void\n}\n\ntype FormDataFields = readonly (readonly [string, FormDataEntryValue])[]\n\nfunction sameEntryValue(left: FormDataEntryValue, right: FormDataEntryValue) {\n if (typeof left === 'string' || typeof right === 'string') return left === right\n return left === right || (\n left.name === right.name &&\n left.size === right.size &&\n left.type === right.type &&\n left.lastModified === right.lastModified\n )\n}\n\nfunction sameFields(left: FormDataFields, right: FormDataFields) {\n return left.length === right.length && left.every(([name, value], index) =>\n name === right[index]![0] && sameEntryValue(value, right[index]![1]))\n}\n\nfunction copyFormData(formData: FormData) {\n if (!formData || typeof formData.entries !== 'function') {\n throw new TypeError('A FormData submission is required.')\n }\n const copy = new FormData()\n for (const [name, value] of formData.entries()) copy.append(name, value)\n return copy\n}\n\nfunction rootRelativeEndpoint(value: string | undefined, fallback: string) {\n const endpoint = value ?? fallback\n if (\n !/^\\/[a-z0-9/_-]+$/.test(endpoint) ||\n endpoint.includes('//') ||\n endpoint.endsWith('/')\n ) {\n throw new TypeError('Contact endpoints must be canonical root-relative paths.')\n }\n return endpoint\n}\n\nasync function boundedJson(response: Response, maximumBytes: number) {\n const contentType = response.headers\n .get('content-type')\n ?.split(';', 1)[0]\n ?.trim()\n .toLowerCase()\n if (contentType !== 'application/json') {\n throw new Error('The contact response did not use the required JSON media type.')\n }\n const text = await response.text()\n if (new TextEncoder().encode(text).byteLength > maximumBytes) {\n throw new Error('The contact response exceeded its safe bound.')\n }\n return JSON.parse(text) as unknown\n}\n\nconst RETRYABLE_CLIENT_FAILURE: ContactActionResult = Object.freeze({\n ok: false,\n code: 'delivery_unavailable',\n retryable: true,\n})\n\n/**\n * True for the result the controller reports when the browser could not complete\n * the request or read a valid answer (offline, blocked, a platform error page or\n * malformed JSON), as opposed to a delivery failure the server reported.\n */\nexport function isContactClientFailure(result: ContactActionResult | undefined): boolean {\n return result === RETRYABLE_CLIENT_FAILURE\n}\n\nfunction reviewedPageLabel(value: string | undefined) {\n const label = value?.trim()\n if (\n label !== undefined &&\n (!label || label.length > 160 || /[\\u0000-\\u001f\\u007f]/.test(label))\n ) {\n throw new TypeError('pageLabel must be bounded reviewed text.')\n }\n return label\n}\n\nfunction addSubmissionMetadata(\n formData: FormData,\n options: {\n pagePath: string\n pageLabel?: string\n now: Date\n startedAt?: Date\n },\n) {\n const attribution =\n typeof window === 'undefined'\n ? { initialLandingPath: options.pagePath, visitSource: 'direct-or-unknown' as const }\n : getInitialContactAttribution(window)\n formData.set(CONTACT_FORM_FIELDS.clientSubmissionId, createContactSubmissionId())\n formData.set(CONTACT_FORM_FIELDS.submittedAt, options.now.toISOString())\n if (options.startedAt && Number.isFinite(options.startedAt.getTime())) {\n formData.set(CONTACT_FORM_FIELDS.formStartedAt, options.startedAt.toISOString())\n }\n formData.set(CONTACT_FORM_FIELDS.pagePath, options.pagePath)\n if (options.pageLabel) {\n formData.set(CONTACT_FORM_FIELDS.pageLabel, options.pageLabel)\n }\n formData.set(CONTACT_FORM_FIELDS.initialLandingPath, attribution.initialLandingPath)\n formData.set(CONTACT_FORM_FIELDS.visitSource, attribution.visitSource)\n if (attribution.visitSourceDetail) {\n formData.set(CONTACT_FORM_FIELDS.visitSourceDetail, attribution.visitSourceDetail)\n }\n return formData\n}\n\nexport function createContactHttpSubmissionController(\n options: ContactHttpSubmissionControllerOptions,\n): ContactSubmissionController {\n const contactEndpoint = rootRelativeEndpoint(options.contactEndpoint, '/api/contact')\n const pagePath = normalizeBrandlabRoutePath(options.pagePath)\n const pageLabel = reviewedPageLabel(options.pageLabel)\n const fetcher = options.fetcher ?? fetch\n if (typeof fetcher !== 'function') throw new TypeError('A fetch implementation is required.')\n if (options.onStateChange !== undefined && typeof options.onStateChange !== 'function') {\n throw new TypeError('onStateChange must be a function.')\n }\n if (options.reportAccepted !== undefined && typeof options.reportAccepted !== 'function') {\n throw new TypeError('reportAccepted must be a function.')\n }\n\n const trackedConfirmations = new Set<string>()\n // The minimum fill time (4.1.0) measures from here: the form's controller is created when the form renders.\n const startedAt = options.startedAt ?? options.now?.() ?? new Date()\n let attempt: FormData | undefined\n let attemptFields: FormDataFields | undefined\n let inFlight: Promise<ContactActionResult> | undefined\n let state: ContactSubmissionState = {\n phase: 'idle',\n pending: false,\n canRetry: false,\n }\n\n const publish = (next: ContactSubmissionState) => {\n state = Object.freeze({ ...next })\n options.onStateChange?.(state)\n }\n\n const post = async (formData: FormData) => {\n publish({ phase: 'submitting', pending: true, canRetry: false })\n let result: ContactActionResult\n try {\n const response = await fetcher(contactEndpoint, {\n method: 'POST',\n credentials: 'same-origin',\n cache: 'no-store',\n body: copyFormData(formData),\n })\n result =\n parseContactActionResult(await boundedJson(response, 64 * 1_024)) ??\n RETRYABLE_CLIENT_FAILURE\n } catch {\n result = RETRYABLE_CLIENT_FAILURE\n }\n\n if (!result.ok) {\n publish({\n phase: 'error',\n pending: false,\n canRetry: result.retryable,\n result,\n })\n return result\n }\n\n if (result.accepted && !trackedConfirmations.has(result.confirmationId)) {\n trackedConfirmations.add(result.confirmationId)\n try {\n options.reportAccepted?.(result, copyFormData(formData))\n } catch {\n // Delivery has already succeeded; analytics cannot change that result.\n }\n }\n\n attempt = undefined\n attemptFields = undefined\n publish({\n phase: result.accepted ? 'accepted' : 'accepted-silently',\n pending: false,\n canRetry: false,\n result,\n })\n return result\n }\n\n const run = (formData: FormData) => {\n if (inFlight) return inFlight\n let wrapped: Promise<ContactActionResult>\n wrapped = post(formData).finally(() => {\n if (inFlight === wrapped) inFlight = undefined\n })\n inFlight = wrapped\n return wrapped\n }\n\n return {\n getState: () => ({ ...state }),\n submit(formData) {\n if (inFlight) return inFlight\n const fields = [...copyFormData(formData).entries()]\n if (\n attempt &&\n attemptFields &&\n state.phase === 'error' &&\n state.canRetry &&\n sameFields(attemptFields, fields)\n ) {\n return run(attempt)\n }\n const now = options.now?.() ?? new Date()\n if (!Number.isFinite(now.getTime())) {\n attempt = undefined\n attemptFields = undefined\n publish({\n phase: 'error',\n pending: false,\n canRetry: false,\n result: RETRYABLE_CLIENT_FAILURE,\n })\n return Promise.resolve(RETRYABLE_CLIENT_FAILURE)\n }\n attemptFields = fields\n attempt = addSubmissionMetadata(copyFormData(formData), {\n pagePath,\n ...(pageLabel ? { pageLabel } : {}),\n now,\n startedAt,\n })\n return run(attempt)\n },\n retry() {\n if (inFlight) return inFlight\n if (!attempt || state.phase !== 'error' || !state.canRetry) {\n return Promise.reject(new Error('No retryable contact submission is available.'))\n }\n return run(attempt)\n },\n reset() {\n if (inFlight) throw new Error('A pending contact submission cannot be reset.')\n attempt = undefined\n attemptFields = undefined\n publish({ phase: 'idle', pending: false, canRetry: false })\n },\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"form-client.d.ts","sourceRoot":"","sources":["../../src/contact/form-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACzB,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAOL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,iBAAiB,EAA2C,MAAM,iBAAiB,CAAA;AAGjG,OAAO,EAEL,KAAK,oCAAoC,EACzC,KAAK,mCAAmC,EACzC,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAGL,KAAK,sBAAsB,EAE5B,MAAM,aAAa,CAAA;AAGpB,iGAAiG;AACjG,MAAM,MAAM,6BAA6B,GAAG,OAAO,CAAC,mBAAmB,EAAE;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AACtF,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAAC,mBAAmB,EAAE;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC,CAAA;AAErF,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,eAAe,CAAA;IACrB;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,aAAa,EAAE,SAAS,MAAM,EAAE,CAAA;CACjC;AAED,MAAM,WAAW,6BAA6B;IAC5C,uDAAuD;IACvD,QAAQ,EAAE,uBAAuB,CAAA;IACjC,wHAAwH;IACxH,SAAS,CAAC,EAAE,iBAAiB,CAAA;IAC7B,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAA;IAChB,uDAAuD;IACvD,SAAS,CA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;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,6BAA6B,GAAG,4BAA4B,CAuM3G;AAED,MAAM,WAAW,wBAAwB;IACvC,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,4BAA4B,EAClC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,wBAA6B;;;;;EAevC"}
@@ -133,6 +133,9 @@ export function useBrandlabContactForm(options) {
133
133
  const pagePath = safePagePath(rawPagePath);
134
134
  const formRef = useRef(null);
135
135
  const statusRef = useRef(null);
136
+ // The render time survives controller re-creation (a new analytics object or consent change), so a quick but
137
+ // genuine sender is never dropped by the server's minimum fill time.
138
+ const [formStartedAt] = useState(() => new Date());
136
139
  const [state, setState] = useState(INITIAL_STATE);
137
140
  const lockRef = useRef(false);
138
141
  const startedRef = useRef(false);
@@ -153,6 +156,7 @@ export function useBrandlabContactForm(options) {
153
156
  const lead = leadBindingFor(analytics);
154
157
  return createContactHttpSubmissionController({
155
158
  pagePath,
159
+ startedAt: formStartedAt,
156
160
  ...(pageLabel ? { pageLabel } : {}),
157
161
  ...(contactEndpoint ? { contactEndpoint } : {}),
158
162
  ...(fetcher ? { fetcher } : {}),
@@ -174,7 +178,7 @@ export function useBrandlabContactForm(options) {
174
178
  : {}),
175
179
  onStateChange: setState,
176
180
  });
177
- }, [adUserDataConsent, analytics, contactEndpoint, fetcher, pageLabel, pagePath, rawPagePath, roles]);
181
+ }, [adUserDataConsent, analytics, contactEndpoint, fetcher, formStartedAt, pageLabel, pagePath, rawPagePath, roles]);
178
182
  useEffect(() => () => clearTimeout(redirectTimerRef.current), []);
179
183
  useEffect(() => {
180
184
  if (state.phase !== 'error')
@@ -1 +1 @@
1
- {"version":3,"file":"form-client.js","sourceRoot":"","sources":["../../src/contact/form-client.ts"],"names":[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CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACpD,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,IAAI,QAAQ;QACpD,SAAS;QACT,KAAK;QACL,WAAW;QACX,UAAU;KACX,CAAA;AACH,CAAC;AASD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAkC,EAClC,IAAY,EACZ,UAAoC,EAAE;IAEtC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,2CAA2C,CAAC,CAAA;IACtE,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;SAC9E,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAA;IACZ,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO;QAC1C,cAAc,EAAE,KAAK,CAAC,CAAC,CAAE,IAAc,CAAC,CAAC,CAAC,SAAS;QACnD,kBAAkB,EAAE,WAAW,IAAI,SAAS;KAC7C,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\nimport {\n DEFAULT_CONTACT_ATTACHMENT_POLICY,\n DOCUMENT_CONTACT_ATTACHMENT_POLICY,\n defineContactContract,\n type BrandlabContactContract,\n type ContactActionResult,\n} from '@brandlab-digital/site-core/contact'\nimport { normalizeBrandlabRoutePath } from '@brandlab-digital/site-core/routes'\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type FormEvent,\n type RefObject,\n} from 'react'\nimport type { BrandlabAnalytics, LeadFormErrorReason, LeadFormErrorStage } from '../analytics.js'\nimport { leadBindingFor, safeSlug } from '../lead-registry.js'\nimport { contactFormDataHasPhotos, reportAcceptedLead } from '../lead-reporting.js'\nimport {\n useBrandlabContactAttachments,\n type UseBrandlabContactAttachmentsOptions,\n type UseBrandlabContactAttachmentsResult,\n} from './attachments-client.js'\nimport {\n createContactHttpSubmissionController,\n isContactClientFailure,\n type ContactSubmissionPhase,\n type ContactSubmissionState,\n} from './client.js'\nimport { BRANDLAB_CONTACT_TEST_MARKER, CONTACT_FORM_FIELDS } from './shared.js'\n\n/** An accepted enquiry, or a silently accepted spam-protected submission (`accepted: false`). */\nexport type BrandlabContactAcceptedResult = Extract<ContactActionResult, { ok: true }>\nexport type BrandlabContactFailedResult = Extract<ContactActionResult, { ok: false }>\n\nexport interface BrandlabContactSubmitStart {\n form: HTMLFormElement\n /**\n * The fields about to be sent, read from the form. Add or replace entries\n * here (for example `service_interest`); prepared photos are appended after.\n */\n formData: FormData\n}\n\n/**\n * Returned by onSubmitStart to cancel because the form's own checks failed (3.18.0): the failing keys in the order\n * the visitor sees them. Nothing is sent, and lead_form_error goes out with stage `validation` and reason `field`\n * naming the first contract field; a key that isn't a contract field (the photos) gives reason `attachment`.\n */\nexport interface BrandlabContactClientInvalid {\n invalidFields: readonly string[]\n}\n\nexport interface UseBrandlabContactFormOptions {\n /** The contact contract from src/config/contact.ts. */\n contract: BrandlabContactContract\n /** The site's defineBrandlabAnalytics binding: the declared lead after each accepted enquiry, plus lead diagnostics. */\n analytics?: BrandlabAnalytics\n /** The current pathname, for example `usePathname()`. */\n pagePath: string\n /** Reviewed label for the enquiry email's page row. */\n pageLabel?: string\n /**\n * The form element's id and the lead diagnostics' form_id. Without it the form\n * gets no id (the hook never takes a React id, so the form's own ids are\n * unchanged), diagnostics use `contact-form` and error ids start `contact-form-`.\n * The element keeps the id exactly as given; diagnostics report it as a slug\n * (React `useId()` parts removed, see `contactFormSlug`).\n */\n formId?: string\n /** Page to open after an accepted enquiry; `null` or omitted keeps the visitor on the page. */\n redirectTo?: string | null\n /** Client navigation such as `router.push`; defaults to `window.location.assign`. */\n navigate?: (href: string) => void\n /** Delay before the redirect, in milliseconds (default 1500); 0 navigates at once. */\n redirectDelayMs?: number\n /**\n * Runs when the visitor submits, before anything is sent: clear the form's\n * own notices, adjust `formData`, or return `false` to cancel (for example\n * after `form.reportValidity()`). Return `{ invalidFields }` instead to\n * cancel and report the failed checks as lead_form_error. An unchanged\n * resubmission runs it too; `retry()` does not.\n */\n onSubmitStart?: (submission: BrandlabContactSubmitStart) => void | false | BrandlabContactClientInvalid\n /**\n * Runs after every attempt, before onAccepted or onFailed: an accepted\n * enquiry, a silently accepted submission (even when ignored) or a failure.\n */\n onSettled?: (result: ContactActionResult) => void\n /** Runs after an accepted enquiry, once the form has been reset and before any redirect. */\n onAccepted?: (result: BrandlabContactAcceptedResult) => void\n /** Runs after a failed attempt; typed values and prepared photos are kept. */\n onFailed?: (result: BrandlabContactFailedResult) => void\n /**\n * A silently accepted submission (spam protection): `complete` (default)\n * resets, runs onAccepted and redirects like an accepted enquiry; `ignore`\n * leaves the form as it is and runs only onSettled.\n */\n silentAcceptance?: 'complete' | 'ignore'\n /** Photo preparation options; the policy follows the contract's attachment mode by default. */\n attachments?: UseBrandlabContactAttachmentsOptions\n /** Multipart field prefix for prepared files (default `attachments`, sent as `attachments[0]` …). */\n attachmentFieldPrefix?: string\n /** Live Consent Mode decision for ad_user_data; without it Enhanced Conversions stay off, unless the analytics contract's mode is `disclosed`. */\n adUserDataConsent?: boolean\n contactEndpoint?: string\n fetcher?: typeof fetch\n}\n\n/**\n * Spread onto the `<form>`: `method=\"post\"` with no `action` or `encType`, so a\n * submission before hydration posts back to the page and never puts fields in\n * a URL; the hook submits through fetch. `id` only when `formId` is given.\n */\nexport interface BrandlabContactFormProps {\n id?: string\n ref: RefObject<HTMLFormElement | null>\n method: 'post'\n 'aria-busy': boolean\n onSubmit: (event: FormEvent<HTMLFormElement>) => void\n onFocusCapture: () => void\n}\n\n/** Spread onto the submit button: disabled until hydration, while sending or preparing photos. */\nexport interface BrandlabContactSubmitProps {\n type: 'submit'\n disabled: boolean\n}\n\nexport interface UseBrandlabContactFormResult {\n /** The `formId` option, or `contact-form` when none was given. */\n formId: string\n formProps: BrandlabContactFormProps\n submitProps: BrandlabContactSubmitProps\n /** False during server rendering and hydration. */\n hydrated: boolean\n /** The submit button's `disabled` (also in submitProps): until hydration, while sending or preparing photos. */\n submitDisabled: boolean\n pending: boolean\n phase: ContactSubmissionPhase\n result: ContactActionResult | undefined\n /** An accepted enquiry (a silently accepted spam-protected submission looks the same). */\n succeeded: boolean\n /** A retryable failure: retry(), or submitting the same fields again, reuses its submission ID. */\n canRetry: boolean\n fieldErrors: Readonly<Record<string, readonly string[]>>\n fieldError(name: string): string | undefined\n /** Id for a field's error message element: `${formId}-${name}-error`. */\n errorId(name: string): string\n /** Attach to the status element; it receives focus when an error has no invalid field. */\n statusRef: RefObject<HTMLElement | null>\n /** Resends the failed enquiry with the same submission ID. */\n retry(): Promise<ContactActionResult | undefined>\n attachments: UseBrandlabContactAttachmentsResult\n /** Contract field keys accepted by contactFieldProps. */\n fieldNames: ReadonlySet<string>\n}\n\nconst INITIAL_STATE: ContactSubmissionState = {\n phase: 'idle',\n pending: false,\n canRetry: false,\n}\nconst DEFAULT_REDIRECT_DELAY_MS = 1_500\nconst FOCUSABLE_INVALID_FIELD = [\n 'input[aria-invalid=\"true\"]:not([disabled]):not([type=\"hidden\"])',\n 'select[aria-invalid=\"true\"]:not([disabled])',\n 'textarea[aria-invalid=\"true\"]:not([disabled])',\n 'button[aria-invalid=\"true\"]:not([disabled])',\n '[aria-invalid=\"true\"][tabindex]:not([aria-disabled=\"true\"])',\n].join(',')\n\nconst subscribeToNothing = () => () => undefined\nconst getClientSnapshot = () => true\nconst getServerSnapshot = () => false\n\n/** React `useId()` values: `_R_1a_`/`_r_1a_` (19.2), `«r1a»` (19.0 and 19.1), `:r1a:` (18). */\nconst REACT_ID = /_[rR]_[0-9A-Za-z]*_|«[rR][0-9A-Za-z]*»|:[rR][0-9A-Za-z]*:/g\n\n/**\n * The lead diagnostics' form_id for any formId. A valid slug is kept (trimmed and\n * lowercased). Otherwise React `useId()` parts are removed, so an id made unique for\n * the page still reports as one stable form, every run of other characters becomes\n * one hyphen, and the result is at most 80 characters; `contact-form` when nothing\n * is left. Without this, a formId such as `contact-form-_R_5e35f9db_` silently\n * dropped lead_form_start and lead_form_error.\n */\nexport function contactFormSlug(formId: string): string {\n const slug = safeSlug(String(formId))\n if (slug) return slug\n const derived = String(formId)\n .replace(REACT_ID, '-')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+/, '')\n .slice(0, 80)\n .replace(/-+$/, '')\n return derived || 'contact-form'\n}\n\n/**\n * A Brandlab test visit: a page opened with `?bl_test=1` (a launch proof or canary), remembered for the tab so the\n * marker survives moving to the quote form; `?bl_test=0` ends it. Its enquiries carry the `bl_test` marker.\n */\nfunction brandlabTestVisit() {\n if (typeof window === 'undefined') return false\n try {\n const flag = new URLSearchParams(window.location.search).get(CONTACT_FORM_FIELDS.testMarker)\n if (flag === BRANDLAB_CONTACT_TEST_MARKER) window.sessionStorage.setItem(CONTACT_FORM_FIELDS.testMarker, flag)\n if (flag === '0') window.sessionStorage.removeItem(CONTACT_FORM_FIELDS.testMarker)\n return window.sessionStorage.getItem(CONTACT_FORM_FIELDS.testMarker) === BRANDLAB_CONTACT_TEST_MARKER ||\n flag === BRANDLAB_CONTACT_TEST_MARKER\n } catch {\n return false\n }\n}\n\nfunction isTestSubmission(formData: FormData) {\n return formData.get(CONTACT_FORM_FIELDS.testMarker) === BRANDLAB_CONTACT_TEST_MARKER\n}\n\nfunction safePagePath(pagePath: string) {\n try {\n return normalizeBrandlabRoutePath(pagePath.split(/[?#]/, 1)[0] || '/')\n } catch {\n return '/'\n }\n}\n\nfunction errorStage(result: BrandlabContactFailedResult): LeadFormErrorStage {\n return result.code === 'validation' ? 'validation' : 'delivery'\n}\n\n/**\n * Separates a field the visitor can correct from a request the server refused,\n * rejected photos, a server delivery failure and a browser-side failure, which\n * error_stage alone reports as only `validation` or `delivery`.\n */\nfunction errorReason(result: BrandlabContactFailedResult): LeadFormErrorReason {\n if (result.code === 'validation') {\n return Object.keys(result.fieldErrors ?? {}).length > 0 ? 'field' : 'request'\n }\n if (result.code === 'attachment_rejected') return 'attachment'\n return isContactClientFailure(result) ? 'network' : 'delivery'\n}\n\n/** The first rejected field in contract order: a contract key, never a value. */\nfunction firstErrorField(result: BrandlabContactFailedResult, fieldOrder: readonly string[]) {\n const fieldErrors = result.fieldErrors ?? {}\n return fieldOrder.find((key) => fieldErrors[key]?.length) ?? Object.keys(fieldErrors)[0]\n}\n\nfunction assertLifecycleOptions(options: UseBrandlabContactFormOptions) {\n const delay = options.redirectDelayMs\n if (delay !== undefined && (!Number.isInteger(delay) || delay < 0 || delay > 60_000)) {\n throw new TypeError('redirectDelayMs must be a whole number of milliseconds from 0 to 60000.')\n }\n if (options.silentAcceptance !== undefined && !['complete', 'ignore'].includes(options.silentAcceptance)) {\n throw new TypeError('silentAcceptance must be \"complete\" or \"ignore\".')\n }\n if (options.analytics !== undefined && !leadBindingFor(options.analytics)) {\n throw new TypeError('analytics must be the binding returned by defineBrandlabAnalytics.')\n }\n}\n\n/**\n * Contact form behaviour for project-owned markup and copy. The form posts\n * through fetch with FormData; before hydration the submit button stays\n * disabled. Typed values (uncontrolled fields) and prepared photos are kept\n * after any failure, retry() and an unchanged resubmission reuse the same\n * submission ID (so a resend cannot duplicate the email), the first invalid\n * field is focused, and an accepted enquiry resets the form and redirects.\n * The lead is reported exactly as the site's defineBrandlabAnalytics binding\n * declares, once per accepted enquiry, with contact_form's `has_photos`. On a\n * Brandlab test visit (`?bl_test=1`) each enquiry carries the `bl_test` marker\n * and is never reported (no lead diagnostics either). Browser validation is left exactly as the form's own\n * markup declares it.\n */\nexport function useBrandlabContactForm(options: UseBrandlabContactFormOptions): UseBrandlabContactFormResult {\n const contract = useMemo(() => defineContactContract(options.contract), [options.contract])\n assertLifecycleOptions(options)\n const hydrated = useSyncExternalStore(subscribeToNothing, getClientSnapshot, getServerSnapshot)\n const formId = options.formId ?? 'contact-form'\n const diagnosticsFormId = contactFormSlug(formId)\n const rawPagePath = options.pagePath\n const pagePath = safePagePath(rawPagePath)\n const formRef = useRef<HTMLFormElement>(null)\n const statusRef = useRef<HTMLElement>(null)\n const [state, setState] = useState<ContactSubmissionState>(INITIAL_STATE)\n const lockRef = useRef(false)\n const startedRef = useRef(false)\n const redirectTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const latest = useRef(options)\n latest.current = options\n\n const policy = options.attachments?.policy ??\n (contract.attachments.mode === 'images-and-pdfs-optional'\n ? DOCUMENT_CONTACT_ATTACHMENT_POLICY\n : DEFAULT_CONTACT_ATTACHMENT_POLICY)\n const attachments = useBrandlabContactAttachments({ ...options.attachments, policy })\n const attachmentPrefix = options.attachmentFieldPrefix ?? 'attachments'\n\n const fieldOrder = useMemo(() => contract.fields.map((field) => field.key), [contract])\n const fieldNames = useMemo(() => new Set(fieldOrder), [fieldOrder])\n const roles = useMemo(\n () => ({ fields: contract.fields.map((field) => ({ name: field.key, role: field.role })) }),\n [contract],\n )\n const { analytics, pageLabel, contactEndpoint, fetcher, adUserDataConsent } = options\n const controller = useMemo(() => {\n const lead = leadBindingFor(analytics)\n return createContactHttpSubmissionController({\n pagePath,\n ...(pageLabel ? { pageLabel } : {}),\n ...(contactEndpoint ? { contactEndpoint } : {}),\n ...(fetcher ? { fetcher } : {}),\n ...(lead\n ? {\n reportAccepted: (result, formData) => {\n // The server answers a test enquiry without a confirmation; this only guards that rule.\n if (isTestSubmission(formData)) return\n reportAcceptedLead(lead, result, {\n pagePath: rawPagePath,\n formData,\n fieldRoles: roles,\n hasPhotos: contactFormDataHasPhotos(formData),\n ...(adUserDataConsent !== undefined ? { adUserDataConsent } : {}),\n })\n },\n }\n : {}),\n onStateChange: setState,\n })\n }, [adUserDataConsent, analytics, contactEndpoint, fetcher, pageLabel, pagePath, rawPagePath, roles])\n\n useEffect(() => () => clearTimeout(redirectTimerRef.current), [])\n\n useEffect(() => {\n if (state.phase !== 'error') return\n const invalid = formRef.current?.querySelector<HTMLElement>(FOCUSABLE_INVALID_FIELD)\n ;(invalid ?? statusRef.current)?.focus()\n }, [state])\n\n const trackStart = useCallback(() => {\n if (startedRef.current) return\n startedRef.current = true\n // A Brandlab test visit is never a starter: no diagnostics.\n if (brandlabTestVisit()) return\n latest.current.analytics?.trackLeadFormStart({ pagePath: rawPagePath, formId: diagnosticsFormId })\n }, [diagnosticsFormId, rawPagePath])\n\n const handleResult = useCallback(\n (result: ContactActionResult) => {\n const current = latest.current\n current.onSettled?.(result)\n if (!result.ok) {\n const reason = errorReason(result)\n const field = reason === 'field' ? firstErrorField(result, fieldOrder) : undefined\n if (!brandlabTestVisit()) current.analytics?.trackLeadFormError({\n pagePath: rawPagePath,\n formId: diagnosticsFormId,\n stage: errorStage(result),\n errorCount: result.code === 'validation'\n ? Math.min(50, Math.max(1, Object.keys(result.fieldErrors ?? {}).length))\n : 1,\n reason,\n ...(field ? { field } : {}),\n })\n current.onFailed?.(result)\n return\n }\n if (!result.accepted && current.silentAcceptance === 'ignore') return\n formRef.current?.reset()\n attachments.clearImages()\n current.onAccepted?.(result)\n const redirectTo = current.redirectTo\n if (!redirectTo) return\n const navigate = current.navigate ?? ((href: string) => window.location.assign(href))\n const delay = current.redirectDelayMs ?? DEFAULT_REDIRECT_DELAY_MS\n clearTimeout(redirectTimerRef.current)\n if (delay === 0) {\n navigate(redirectTo)\n return\n }\n redirectTimerRef.current = setTimeout(() => navigate(redirectTo), delay)\n },\n [attachments, diagnosticsFormId, fieldOrder, rawPagePath],\n )\n\n const send = useCallback(\n async (attempt: () => Promise<ContactActionResult>) => {\n lockRef.current = true\n try {\n const result = await attempt()\n handleResult(result)\n return result\n } finally {\n lockRef.current = false\n }\n },\n [handleResult],\n )\n\n const onSubmit = useCallback(\n (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault()\n if (lockRef.current || attachments.isProcessing) return\n const form = event.currentTarget\n const formData = new FormData(form)\n const started = latest.current.onSubmitStart?.({ form, formData })\n if (started === false) return\n if (started && typeof started === 'object') {\n trackStart()\n const keys = started.invalidFields\n const field = keys.find((key) => fieldOrder.includes(key))\n if (!brandlabTestVisit()) latest.current.analytics?.trackLeadFormError({\n pagePath: rawPagePath,\n formId: diagnosticsFormId,\n stage: 'validation',\n errorCount: Math.min(50, Math.max(1, keys.length)),\n reason: field ? 'field' : 'attachment',\n ...(field ? { field } : {}),\n })\n return\n }\n if (brandlabTestVisit()) formData.set(CONTACT_FORM_FIELDS.testMarker, BRANDLAB_CONTACT_TEST_MARKER)\n trackStart()\n attachments.clearErrorMessage()\n attachments.images.forEach((image, index) => {\n formData.append(`${attachmentPrefix}[${index}]`, image.file)\n })\n // The controller reports every failure as a result; nothing is left to handle here.\n send(() => controller.submit(formData)).catch(() => undefined)\n },\n [attachmentPrefix, attachments, controller, diagnosticsFormId, fieldOrder, rawPagePath, send, trackStart],\n )\n\n const retry = useCallback(async () => {\n if (lockRef.current || !controller.getState().canRetry) return undefined\n return send(() => controller.retry())\n }, [controller, send])\n\n const fieldErrors = state.result && !state.result.ok && state.result.code === 'validation'\n ? state.result.fieldErrors ?? {}\n : {}\n\n const submitDisabled = !hydrated || state.pending || attachments.isProcessing\n return {\n formId,\n formProps: {\n ...(options.formId ? { id: options.formId } : {}),\n ref: formRef,\n method: 'post',\n 'aria-busy': state.pending || attachments.isProcessing,\n onSubmit,\n onFocusCapture: trackStart,\n },\n submitProps: { type: 'submit', disabled: submitDisabled },\n hydrated,\n submitDisabled,\n pending: state.pending,\n phase: state.phase,\n result: state.result,\n succeeded: state.result?.ok === true,\n canRetry: state.canRetry,\n fieldErrors,\n fieldError: (name: string) => fieldErrors[name]?.[0],\n errorId: (name: string) => `${formId}-${name}-error`,\n statusRef,\n retry,\n attachments,\n fieldNames,\n }\n}\n\nexport interface ContactFieldPropsOptions {\n /** Ids of help text already describing the field; the error id is appended. */\n describedBy?: string\n /** Defaults to disabled while an enquiry is sending. */\n disabled?: boolean\n}\n\n/**\n * Props for one uncontrolled contract field: name, disabled while sending and\n * the error relationship. It never adds value, required or length attributes,\n * so the form's existing validation is unchanged.\n */\nexport function contactFieldProps(\n form: UseBrandlabContactFormResult,\n name: string,\n options: ContactFieldPropsOptions = {},\n) {\n if (!form.fieldNames.has(name)) {\n throw new Error(`\"${name}\" is not a field in the contact contract.`)\n }\n const error = form.fieldError(name)\n const describedBy = [options.describedBy, error ? form.errorId(name) : undefined]\n .filter(Boolean)\n .join(' ')\n return {\n name,\n disabled: options.disabled ?? form.pending,\n 'aria-invalid': error ? (true as const) : undefined,\n 'aria-describedby': describedBy || undefined,\n }\n}\n"]}
1
+ {"version":3,"file":"form-client.js","sourceRoot":"","sources":["../../src/contact/form-client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EACL,iCAAiC,EACjC,kCAAkC,EAClC,qBAAqB,GAGtB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AAC/E,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACR,oBAAoB,GAGrB,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,EACL,6BAA6B,GAG9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,qCAAqC,EACrC,sBAAsB,GAGvB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAiI/E,MAAM,aAAa,GAA2B;IAC5C,KAAK,EAAE,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,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;SAC9E,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAA;IACZ,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO;QAC1C,cAAc,EAAE,KAAK,CAAC,CAAC,CAAE,IAAc,CAAC,CAAC,CAAC,SAAS;QACnD,kBAAkB,EAAE,WAAW,IAAI,SAAS;KAC7C,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\nimport {\n DEFAULT_CONTACT_ATTACHMENT_POLICY,\n DOCUMENT_CONTACT_ATTACHMENT_POLICY,\n defineContactContract,\n type BrandlabContactContract,\n type ContactActionResult,\n} from '@brandlab-digital/site-core/contact'\nimport { normalizeBrandlabRoutePath } from '@brandlab-digital/site-core/routes'\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type FormEvent,\n type RefObject,\n} from 'react'\nimport type { BrandlabAnalytics, LeadFormErrorReason, LeadFormErrorStage } from '../analytics.js'\nimport { leadBindingFor, safeSlug } from '../lead-registry.js'\nimport { contactFormDataHasPhotos, reportAcceptedLead } from '../lead-reporting.js'\nimport {\n useBrandlabContactAttachments,\n type UseBrandlabContactAttachmentsOptions,\n type UseBrandlabContactAttachmentsResult,\n} from './attachments-client.js'\nimport {\n createContactHttpSubmissionController,\n isContactClientFailure,\n type ContactSubmissionPhase,\n type ContactSubmissionState,\n} from './client.js'\nimport { BRANDLAB_CONTACT_TEST_MARKER, CONTACT_FORM_FIELDS } from './shared.js'\n\n/** An accepted enquiry, or a silently accepted spam-protected submission (`accepted: false`). */\nexport type BrandlabContactAcceptedResult = Extract<ContactActionResult, { ok: true }>\nexport type BrandlabContactFailedResult = Extract<ContactActionResult, { ok: false }>\n\nexport interface BrandlabContactSubmitStart {\n form: HTMLFormElement\n /**\n * The fields about to be sent, read from the form. Add or replace entries\n * here (for example `service_interest`); prepared photos are appended after.\n */\n formData: FormData\n}\n\n/**\n * Returned by onSubmitStart to cancel because the form's own checks failed (3.18.0): the failing keys in the order\n * the visitor sees them. Nothing is sent, and lead_form_error goes out with stage `validation` and reason `field`\n * naming the first contract field; a key that isn't a contract field (the photos) gives reason `attachment`.\n */\nexport interface BrandlabContactClientInvalid {\n invalidFields: readonly string[]\n}\n\nexport interface UseBrandlabContactFormOptions {\n /** The contact contract from src/config/contact.ts. */\n contract: BrandlabContactContract\n /** The site's defineBrandlabAnalytics binding: the declared lead after each accepted enquiry, plus lead diagnostics. */\n analytics?: BrandlabAnalytics\n /** The current pathname, for example `usePathname()`. */\n pagePath: string\n /** Reviewed label for the enquiry email's page row. */\n pageLabel?: string\n /**\n * The form element's id and the lead diagnostics' form_id. Without it the form\n * gets no id (the hook never takes a React id, so the form's own ids are\n * unchanged), diagnostics use `contact-form` and error ids start `contact-form-`.\n * The element keeps the id exactly as given; diagnostics report it as a slug\n * (React `useId()` parts removed, see `contactFormSlug`).\n */\n formId?: string\n /** Page to open after an accepted enquiry; `null` or omitted keeps the visitor on the page. */\n redirectTo?: string | null\n /** Client navigation such as `router.push`; defaults to `window.location.assign`. */\n navigate?: (href: string) => void\n /** Delay before the redirect, in milliseconds (default 1500); 0 navigates at once. */\n redirectDelayMs?: number\n /**\n * Runs when the visitor submits, before anything is sent: clear the form's\n * own notices, adjust `formData`, or return `false` to cancel (for example\n * after `form.reportValidity()`). Return `{ invalidFields }` instead to\n * cancel and report the failed checks as lead_form_error. An unchanged\n * resubmission runs it too; `retry()` does not.\n */\n onSubmitStart?: (submission: BrandlabContactSubmitStart) => void | false | BrandlabContactClientInvalid\n /**\n * Runs after every attempt, before onAccepted or onFailed: an accepted\n * enquiry, a silently accepted submission (even when ignored) or a failure.\n */\n onSettled?: (result: ContactActionResult) => void\n /** Runs after an accepted enquiry, once the form has been reset and before any redirect. */\n onAccepted?: (result: BrandlabContactAcceptedResult) => void\n /** Runs after a failed attempt; typed values and prepared photos are kept. */\n onFailed?: (result: BrandlabContactFailedResult) => void\n /**\n * A silently accepted submission (spam protection): `complete` (default)\n * resets, runs onAccepted and redirects like an accepted enquiry; `ignore`\n * leaves the form as it is and runs only onSettled.\n */\n silentAcceptance?: 'complete' | 'ignore'\n /** Photo preparation options; the policy follows the contract's attachment mode by default. */\n attachments?: UseBrandlabContactAttachmentsOptions\n /** Multipart field prefix for prepared files (default `attachments`, sent as `attachments[0]` …). */\n attachmentFieldPrefix?: string\n /** Live Consent Mode decision for ad_user_data; without it Enhanced Conversions stay off, unless the analytics contract's mode is `disclosed`. */\n adUserDataConsent?: boolean\n contactEndpoint?: string\n fetcher?: typeof fetch\n}\n\n/**\n * Spread onto the `<form>`: `method=\"post\"` with no `action` or `encType`, so a\n * submission before hydration posts back to the page and never puts fields in\n * a URL; the hook submits through fetch. `id` only when `formId` is given.\n */\nexport interface BrandlabContactFormProps {\n id?: string\n ref: RefObject<HTMLFormElement | null>\n method: 'post'\n 'aria-busy': boolean\n onSubmit: (event: FormEvent<HTMLFormElement>) => void\n onFocusCapture: () => void\n}\n\n/** Spread onto the submit button: disabled until hydration, while sending or preparing photos. */\nexport interface BrandlabContactSubmitProps {\n type: 'submit'\n disabled: boolean\n}\n\nexport interface UseBrandlabContactFormResult {\n /** The `formId` option, or `contact-form` when none was given. */\n formId: string\n formProps: BrandlabContactFormProps\n submitProps: BrandlabContactSubmitProps\n /** False during server rendering and hydration. */\n hydrated: boolean\n /** The submit button's `disabled` (also in submitProps): until hydration, while sending or preparing photos. */\n submitDisabled: boolean\n pending: boolean\n phase: ContactSubmissionPhase\n result: ContactActionResult | undefined\n /** An accepted enquiry (a silently accepted spam-protected submission looks the same). */\n succeeded: boolean\n /** A retryable failure: retry(), or submitting the same fields again, reuses its submission ID. */\n canRetry: boolean\n fieldErrors: Readonly<Record<string, readonly string[]>>\n fieldError(name: string): string | undefined\n /** Id for a field's error message element: `${formId}-${name}-error`. */\n errorId(name: string): string\n /** Attach to the status element; it receives focus when an error has no invalid field. */\n statusRef: RefObject<HTMLElement | null>\n /** Resends the failed enquiry with the same submission ID. */\n retry(): Promise<ContactActionResult | undefined>\n attachments: UseBrandlabContactAttachmentsResult\n /** Contract field keys accepted by contactFieldProps. */\n fieldNames: ReadonlySet<string>\n}\n\nconst INITIAL_STATE: ContactSubmissionState = {\n phase: 'idle',\n pending: false,\n canRetry: false,\n}\nconst DEFAULT_REDIRECT_DELAY_MS = 1_500\nconst FOCUSABLE_INVALID_FIELD = [\n 'input[aria-invalid=\"true\"]:not([disabled]):not([type=\"hidden\"])',\n 'select[aria-invalid=\"true\"]:not([disabled])',\n 'textarea[aria-invalid=\"true\"]:not([disabled])',\n 'button[aria-invalid=\"true\"]:not([disabled])',\n '[aria-invalid=\"true\"][tabindex]:not([aria-disabled=\"true\"])',\n].join(',')\n\nconst subscribeToNothing = () => () => undefined\nconst getClientSnapshot = () => true\nconst getServerSnapshot = () => false\n\n/** React `useId()` values: `_R_1a_`/`_r_1a_` (19.2), `«r1a»` (19.0 and 19.1), `:r1a:` (18). */\nconst REACT_ID = /_[rR]_[0-9A-Za-z]*_|«[rR][0-9A-Za-z]*»|:[rR][0-9A-Za-z]*:/g\n\n/**\n * The lead diagnostics' form_id for any formId. A valid slug is kept (trimmed and\n * lowercased). Otherwise React `useId()` parts are removed, so an id made unique for\n * the page still reports as one stable form, every run of other characters becomes\n * one hyphen, and the result is at most 80 characters; `contact-form` when nothing\n * is left. Without this, a formId such as `contact-form-_R_5e35f9db_` silently\n * dropped lead_form_start and lead_form_error.\n */\nexport function contactFormSlug(formId: string): string {\n const slug = safeSlug(String(formId))\n if (slug) return slug\n const derived = String(formId)\n .replace(REACT_ID, '-')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+/, '')\n .slice(0, 80)\n .replace(/-+$/, '')\n return derived || 'contact-form'\n}\n\n/**\n * A Brandlab test visit: a page opened with `?bl_test=1` (a launch proof or canary), remembered for the tab so the\n * marker survives moving to the quote form; `?bl_test=0` ends it. Its enquiries carry the `bl_test` marker.\n */\nfunction brandlabTestVisit() {\n if (typeof window === 'undefined') return false\n try {\n const flag = new URLSearchParams(window.location.search).get(CONTACT_FORM_FIELDS.testMarker)\n if (flag === BRANDLAB_CONTACT_TEST_MARKER) window.sessionStorage.setItem(CONTACT_FORM_FIELDS.testMarker, flag)\n if (flag === '0') window.sessionStorage.removeItem(CONTACT_FORM_FIELDS.testMarker)\n return window.sessionStorage.getItem(CONTACT_FORM_FIELDS.testMarker) === BRANDLAB_CONTACT_TEST_MARKER ||\n flag === BRANDLAB_CONTACT_TEST_MARKER\n } catch {\n return false\n }\n}\n\nfunction isTestSubmission(formData: FormData) {\n return formData.get(CONTACT_FORM_FIELDS.testMarker) === BRANDLAB_CONTACT_TEST_MARKER\n}\n\nfunction safePagePath(pagePath: string) {\n try {\n return normalizeBrandlabRoutePath(pagePath.split(/[?#]/, 1)[0] || '/')\n } catch {\n return '/'\n }\n}\n\nfunction errorStage(result: BrandlabContactFailedResult): LeadFormErrorStage {\n return result.code === 'validation' ? 'validation' : 'delivery'\n}\n\n/**\n * Separates a field the visitor can correct from a request the server refused,\n * rejected photos, a server delivery failure and a browser-side failure, which\n * error_stage alone reports as only `validation` or `delivery`.\n */\nfunction errorReason(result: BrandlabContactFailedResult): LeadFormErrorReason {\n if (result.code === 'validation') {\n return Object.keys(result.fieldErrors ?? {}).length > 0 ? 'field' : 'request'\n }\n if (result.code === 'attachment_rejected') return 'attachment'\n return isContactClientFailure(result) ? 'network' : 'delivery'\n}\n\n/** The first rejected field in contract order: a contract key, never a value. */\nfunction firstErrorField(result: BrandlabContactFailedResult, fieldOrder: readonly string[]) {\n const fieldErrors = result.fieldErrors ?? {}\n return fieldOrder.find((key) => fieldErrors[key]?.length) ?? Object.keys(fieldErrors)[0]\n}\n\nfunction assertLifecycleOptions(options: UseBrandlabContactFormOptions) {\n const delay = options.redirectDelayMs\n if (delay !== undefined && (!Number.isInteger(delay) || delay < 0 || delay > 60_000)) {\n throw new TypeError('redirectDelayMs must be a whole number of milliseconds from 0 to 60000.')\n }\n if (options.silentAcceptance !== undefined && !['complete', 'ignore'].includes(options.silentAcceptance)) {\n throw new TypeError('silentAcceptance must be \"complete\" or \"ignore\".')\n }\n if (options.analytics !== undefined && !leadBindingFor(options.analytics)) {\n throw new TypeError('analytics must be the binding returned by defineBrandlabAnalytics.')\n }\n}\n\n/**\n * Contact form behaviour for project-owned markup and copy. The form posts\n * through fetch with FormData; before hydration the submit button stays\n * disabled. Typed values (uncontrolled fields) and prepared photos are kept\n * after any failure, retry() and an unchanged resubmission reuse the same\n * submission ID (so a resend cannot duplicate the email), the first invalid\n * field is focused, and an accepted enquiry resets the form and redirects.\n * The lead is reported exactly as the site's defineBrandlabAnalytics binding\n * declares, once per accepted enquiry, with contact_form's `has_photos`. On a\n * Brandlab test visit (`?bl_test=1`) each enquiry carries the `bl_test` marker\n * and is never reported (no lead diagnostics either). Browser validation is left exactly as the form's own\n * markup declares it.\n */\nexport function useBrandlabContactForm(options: UseBrandlabContactFormOptions): UseBrandlabContactFormResult {\n const contract = useMemo(() => defineContactContract(options.contract), [options.contract])\n assertLifecycleOptions(options)\n const hydrated = useSyncExternalStore(subscribeToNothing, getClientSnapshot, getServerSnapshot)\n const formId = options.formId ?? 'contact-form'\n const diagnosticsFormId = contactFormSlug(formId)\n const rawPagePath = options.pagePath\n const pagePath = safePagePath(rawPagePath)\n const formRef = useRef<HTMLFormElement>(null)\n const statusRef = useRef<HTMLElement>(null)\n // The render time survives controller re-creation (a new analytics object or consent change), so a quick but\n // genuine sender is never dropped by the server's minimum fill time.\n const [formStartedAt] = useState(() => new Date())\n const [state, setState] = useState<ContactSubmissionState>(INITIAL_STATE)\n const lockRef = useRef(false)\n const startedRef = useRef(false)\n const redirectTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const latest = useRef(options)\n latest.current = options\n\n const policy = options.attachments?.policy ??\n (contract.attachments.mode === 'images-and-pdfs-optional'\n ? DOCUMENT_CONTACT_ATTACHMENT_POLICY\n : DEFAULT_CONTACT_ATTACHMENT_POLICY)\n const attachments = useBrandlabContactAttachments({ ...options.attachments, policy })\n const attachmentPrefix = options.attachmentFieldPrefix ?? 'attachments'\n\n const fieldOrder = useMemo(() => contract.fields.map((field) => field.key), [contract])\n const fieldNames = useMemo(() => new Set(fieldOrder), [fieldOrder])\n const roles = useMemo(\n () => ({ fields: contract.fields.map((field) => ({ name: field.key, role: field.role })) }),\n [contract],\n )\n const { analytics, pageLabel, contactEndpoint, fetcher, adUserDataConsent } = options\n const controller = useMemo(() => {\n const lead = leadBindingFor(analytics)\n return createContactHttpSubmissionController({\n pagePath,\n startedAt: formStartedAt,\n ...(pageLabel ? { pageLabel } : {}),\n ...(contactEndpoint ? { contactEndpoint } : {}),\n ...(fetcher ? { fetcher } : {}),\n ...(lead\n ? {\n reportAccepted: (result, formData) => {\n // The server answers a test enquiry without a confirmation; this only guards that rule.\n if (isTestSubmission(formData)) return\n reportAcceptedLead(lead, result, {\n pagePath: rawPagePath,\n formData,\n fieldRoles: roles,\n hasPhotos: contactFormDataHasPhotos(formData),\n ...(adUserDataConsent !== undefined ? { adUserDataConsent } : {}),\n })\n },\n }\n : {}),\n onStateChange: setState,\n })\n }, [adUserDataConsent, analytics, contactEndpoint, fetcher, formStartedAt, pageLabel, pagePath, rawPagePath, roles])\n\n useEffect(() => () => clearTimeout(redirectTimerRef.current), [])\n\n useEffect(() => {\n if (state.phase !== 'error') return\n const invalid = formRef.current?.querySelector<HTMLElement>(FOCUSABLE_INVALID_FIELD)\n ;(invalid ?? statusRef.current)?.focus()\n }, [state])\n\n const trackStart = useCallback(() => {\n if (startedRef.current) return\n startedRef.current = true\n // A Brandlab test visit is never a starter: no diagnostics.\n if (brandlabTestVisit()) return\n latest.current.analytics?.trackLeadFormStart({ pagePath: rawPagePath, formId: diagnosticsFormId })\n }, [diagnosticsFormId, rawPagePath])\n\n const handleResult = useCallback(\n (result: ContactActionResult) => {\n const current = latest.current\n current.onSettled?.(result)\n if (!result.ok) {\n const reason = errorReason(result)\n const field = reason === 'field' ? firstErrorField(result, fieldOrder) : undefined\n if (!brandlabTestVisit()) current.analytics?.trackLeadFormError({\n pagePath: rawPagePath,\n formId: diagnosticsFormId,\n stage: errorStage(result),\n errorCount: result.code === 'validation'\n ? Math.min(50, Math.max(1, Object.keys(result.fieldErrors ?? {}).length))\n : 1,\n reason,\n ...(field ? { field } : {}),\n })\n current.onFailed?.(result)\n return\n }\n if (!result.accepted && current.silentAcceptance === 'ignore') return\n formRef.current?.reset()\n attachments.clearImages()\n current.onAccepted?.(result)\n const redirectTo = current.redirectTo\n if (!redirectTo) return\n const navigate = current.navigate ?? ((href: string) => window.location.assign(href))\n const delay = current.redirectDelayMs ?? DEFAULT_REDIRECT_DELAY_MS\n clearTimeout(redirectTimerRef.current)\n if (delay === 0) {\n navigate(redirectTo)\n return\n }\n redirectTimerRef.current = setTimeout(() => navigate(redirectTo), delay)\n },\n [attachments, diagnosticsFormId, fieldOrder, rawPagePath],\n )\n\n const send = useCallback(\n async (attempt: () => Promise<ContactActionResult>) => {\n lockRef.current = true\n try {\n const result = await attempt()\n handleResult(result)\n return result\n } finally {\n lockRef.current = false\n }\n },\n [handleResult],\n )\n\n const onSubmit = useCallback(\n (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault()\n if (lockRef.current || attachments.isProcessing) return\n const form = event.currentTarget\n const formData = new FormData(form)\n const started = latest.current.onSubmitStart?.({ form, formData })\n if (started === false) return\n if (started && typeof started === 'object') {\n trackStart()\n const keys = started.invalidFields\n const field = keys.find((key) => fieldOrder.includes(key))\n if (!brandlabTestVisit()) latest.current.analytics?.trackLeadFormError({\n pagePath: rawPagePath,\n formId: diagnosticsFormId,\n stage: 'validation',\n errorCount: Math.min(50, Math.max(1, keys.length)),\n reason: field ? 'field' : 'attachment',\n ...(field ? { field } : {}),\n })\n return\n }\n if (brandlabTestVisit()) formData.set(CONTACT_FORM_FIELDS.testMarker, BRANDLAB_CONTACT_TEST_MARKER)\n trackStart()\n attachments.clearErrorMessage()\n attachments.images.forEach((image, index) => {\n formData.append(`${attachmentPrefix}[${index}]`, image.file)\n })\n // The controller reports every failure as a result; nothing is left to handle here.\n send(() => controller.submit(formData)).catch(() => undefined)\n },\n [attachmentPrefix, attachments, controller, diagnosticsFormId, fieldOrder, rawPagePath, send, trackStart],\n )\n\n const retry = useCallback(async () => {\n if (lockRef.current || !controller.getState().canRetry) return undefined\n return send(() => controller.retry())\n }, [controller, send])\n\n const fieldErrors = state.result && !state.result.ok && state.result.code === 'validation'\n ? state.result.fieldErrors ?? {}\n : {}\n\n const submitDisabled = !hydrated || state.pending || attachments.isProcessing\n return {\n formId,\n formProps: {\n ...(options.formId ? { id: options.formId } : {}),\n ref: formRef,\n method: 'post',\n 'aria-busy': state.pending || attachments.isProcessing,\n onSubmit,\n onFocusCapture: trackStart,\n },\n submitProps: { type: 'submit', disabled: submitDisabled },\n hydrated,\n submitDisabled,\n pending: state.pending,\n phase: state.phase,\n result: state.result,\n succeeded: state.result?.ok === true,\n canRetry: state.canRetry,\n fieldErrors,\n fieldError: (name: string) => fieldErrors[name]?.[0],\n errorId: (name: string) => `${formId}-${name}-error`,\n statusRef,\n retry,\n attachments,\n fieldNames,\n }\n}\n\nexport interface ContactFieldPropsOptions {\n /** Ids of help text already describing the field; the error id is appended. */\n describedBy?: string\n /** Defaults to disabled while an enquiry is sending. */\n disabled?: boolean\n}\n\n/**\n * Props for one uncontrolled contract field: name, disabled while sending and\n * the error relationship. It never adds value, required or length attributes,\n * so the form's existing validation is unchanged.\n */\nexport function contactFieldProps(\n form: UseBrandlabContactFormResult,\n name: string,\n options: ContactFieldPropsOptions = {},\n) {\n if (!form.fieldNames.has(name)) {\n throw new Error(`\"${name}\" is not a field in the contact contract.`)\n }\n const error = form.fieldError(name)\n const describedBy = [options.describedBy, error ? form.errorId(name) : undefined]\n .filter(Boolean)\n .join(' ')\n return {\n name,\n disabled: options.disabled ?? form.pending,\n 'aria-invalid': error ? (true as const) : undefined,\n 'aria-describedby': describedBy || undefined,\n }\n}\n"]}
@@ -6,11 +6,16 @@ import { type BrandlabContactDeliveryAlert, type BrandlabContactSuppressionCheck
6
6
  import { type ResendContactSend } from './resend.js';
7
7
  import { type BrandlabContactRuntimeDefinitionOptions } from './server.js';
8
8
  import type { ContactBotGuard } from './shared.js';
9
+ import type { BrandlabContactSpamFilterOptions } from './spam-filter.js';
9
10
  export interface BrandlabContactRouteHandlerOptions {
10
11
  contract: BrandlabContactContract;
11
12
  /** Labels, brand name, canonical site URL, email style and attachment settings. */
12
13
  runtime: BrandlabContactRuntimeDefinitionOptions;
13
14
  botGuard?: ContactBotGuard;
15
+ /**
16
+ * The shared spam filter (4.1.0), on by default. Sites add phrases or relax a rule here; `false` turns it off.
17
+ */
18
+ spamFilter?: BrandlabContactSpamFilterOptions | false;
14
19
  /** Defaults to process.env, read on every request. */
15
20
  environment?: BrandlabEnvironment;
16
21
  now?: () => Date;
@@ -1 +1 @@
1
- {"version":3,"file":"route-handler.d.ts","sourceRoot":"","sources":["../../src/contact/route-handler.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAC3E,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,+BAA+B,EACrC,MAAM,eAAe,CAAA;AACtB,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAChF,OAAO,EAGL,KAAK,uCAAuC,EAC7C,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK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MAAM,aAAa,CAAA;AAChF,OAAO,EAGL,KAAK,uCAAuC,EAC7C,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAA;AAExE,MAAM,WAAW,kCAAkC;IACjD,QAAQ,EAAE,uBAAuB,CAAA;IACjC,mFAAmF;IACnF,OAAO,EAAE,uCAAuC,CAAA;IAChD,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,gCAAgC,GAAG,KAAK,CAAA;IACrD,sDAAsD;IACtD,WAAW,CAAC,EAAE,mBAAmB,CAAA;IACjC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;IAChB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,iBAAiB,CAAA;IACxD;;;OAGG;IACH,SAAS,CAAC,EAAE,+BAA+B,GAAG,KAAK,CAAA;IACnD;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,+BAA+B,GAAG,KAAK,CAAA;IAC1D;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,yFAAyF;IACzF,iBAAiB,CAAC,EAAE,4BAA4B,CAAA;CACjD;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAQ7E;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,kCAAkC,GAC1C,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAoCzC"}
@@ -43,6 +43,7 @@ export function createBrandlabContactRouteHandler(options) {
43
43
  deploymentMode: detectBrandlabContactDeploymentMode(environment),
44
44
  createResendSend,
45
45
  ...(options.botGuard ? { botGuard: options.botGuard } : {}),
46
+ ...(options.spamFilter !== undefined ? { spamFilter: options.spamFilter } : {}),
46
47
  ...(options.now ? { now: options.now } : {}),
47
48
  rateLimit,
48
49
  ...(suppressionCheck ? { suppressionCheck } : {}),
@@ -1 +1 @@
1
- {"version":3,"file":"route-handler.js","sourceRoot":"","sources":["../../src/contact/route-handler.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAIpB,OAAO,EACL,gCAAgC,GAEjC,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,4BAA4B,GAG7B,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,0BAA0B,EAA0B,MAAM,aAAa,CAAA;AAChF,OAAO,EACL,4BAA4B,EAC5B,mCAAmC,GAEpC,MAAM,aAAa,CAAA;AAmCpB;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAc;IACxD,IAAI,IAA4C,CAAA;IAChD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;QAChC,IAAI,KAAK,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAC5C,0BAA0B,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAC/C,CAAA;QACD,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACvC,CAAC,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iCAAiC,CAC/C,OAA2C;IAE3C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,SAAS,CAAC,sEAAsE,CAAC,CAAA;IAC7F,CAAC;IACD,IAAI,OAAO,CAAC,gBAAgB,KAAK,SAAS,IAAI,OAAO,OAAO,CAAC,gBAAgB,KAAK,UAAU,EAAE,CAAC;QAC7F,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAA;IAC7D,CAAC;IACD,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,2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C,CAAC,EAAE,CAAC;KACvF,CAAC,CAAA;IAEJ,0DAA0D;IAC1D,UAAU,CAAC,EAAE,CAAC,CAAA;IAEd,OAAO,CAAC,OAAgB,EAAE,EAAE,CAC1B,UAAU,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;AAC/E,CAAC","sourcesContent":["import 'server-only'\n\nimport type { BrandlabContactContract } from '@brandlab-digital/site-core/contact'\nimport type { BrandlabEnvironment } from '@brandlab-digital/site-core/site'\nimport {\n createBrandlabContactRateLimiter,\n type BrandlabContactRateLimitOptions,\n} from './rate-limit.js'\nimport {\n createResendSuppressionCheck,\n type BrandlabContactDeliveryAlert,\n type BrandlabContactSuppressionCheck,\n} from './delivery.js'\nimport { createResendSdkContactSend, type ResendContactSend } from './resend.js'\nimport {\n createBrandlabContactRuntime,\n detectBrandlabContactDeploymentMode,\n type BrandlabContactRuntimeDefinitionOptions,\n} from './server.js'\nimport type { ContactBotGuard } from './shared.js'\n\nexport interface BrandlabContactRouteHandlerOptions {\n contract: BrandlabContactContract\n /** Labels, brand name, canonical site URL, email style and attachment settings. */\n runtime: BrandlabContactRuntimeDefinitionOptions\n botGuard?: ContactBotGuard\n /** Defaults to process.env, read on every request. */\n environment?: BrandlabEnvironment\n now?: () => Date\n /** Replaces the Resend SDK in synthetic tests; production code omits it. */\n createResendSend?: (apiKey: string) => ResendContactSend\n /**\n * Abuse limits per client IP and per email address, held for the life of the route module (BRANDLAB_CONTACT_RATE_LIMITS\n * by default; `false` turns them off). They apply only where enquiries are delivered (production and Preview).\n */\n rateLimit?: BrandlabContactRateLimitOptions | false\n /**\n * The pre-send check of each business inbox against Resend's suppression list (3.14.0), held for the life of the\n * route module so its answers are cached (5 minutes per inbox). On by default with Resend's suppressions API and a\n * full-access key: `RESEND_LOOKUP_API_KEY` when set, otherwise `RESEND_API_KEY`. A sending-only key is refused, logged\n * once per 5 minutes naming the missing permission, and the enquiry is sent as before. Off by default when\n * `createResendSend` replaces the provider, and `false` turns it off.\n */\n suppressionCheck?: BrandlabContactSuppressionCheck | false\n /**\n * Opt-in only (default `false`): when every business inbox is suppressed, refuse and ask the visitor to call. By\n * default the suppression check only records and alerts, and the enquiry is sent to the client's own inbox.\n */\n refuseWhenAllSuppressed?: boolean\n /** The same-day alert for a delivery failure the route finds before sending (3.14.0). */\n onDeliveryFailure?: BrandlabContactDeliveryAlert\n}\n\n/**\n * A Resend send function that loads the optional `resend` peer only when an\n * enquiry is actually delivered, so validation, bot and local requests never\n * load the provider SDK.\n */\nexport function createLazyResendContactSend(apiKey: string): ResendContactSend {\n let send: Promise<ResendContactSend> | undefined\n return async (payload, options) => {\n send ??= import('resend').then(({ Resend }) =>\n createResendSdkContactSend(new Resend(apiKey)),\n )\n return (await send)(payload, options)\n }\n}\n\n/**\n * The whole of `src/app/api/contact/route.ts`:\n * `export const POST = createBrandlabContactRouteHandler({ contract, runtime })`.\n * The contract and runtime are validated when the route module loads; each\n * request then resolves the deployment from its environment and delegates to\n * createBrandlabContactRuntime exactly as a per-request runtime would.\n */\nexport function createBrandlabContactRouteHandler(\n options: BrandlabContactRouteHandlerOptions,\n): (request: Request) => Promise<Response> {\n if (!options || typeof options !== 'object') {\n throw new TypeError('createBrandlabContactRouteHandler requires the contract and runtime.')\n }\n if (options.createResendSend !== undefined && typeof options.createResendSend !== 'function') {\n throw new TypeError('createResendSend must be a function.')\n }\n const createResendSend = options.createResendSend ?? createLazyResendContactSend\n // One suppression cache for the module. A synthetic test that replaces the provider never asks the real one.\n const suppressionCheck =\n options.suppressionCheck === false\n ? undefined\n : options.suppressionCheck ?? (options.createResendSend ? undefined : createResendSuppressionCheck())\n // One limiter for the module, shared by every per-request runtime, so its windows outlive each request.\n const rateLimit = options.rateLimit === false ? false : createBrandlabContactRateLimiter(options.rateLimit)\n const runtimeFor = (environment: BrandlabEnvironment) =>\n createBrandlabContactRuntime({\n contract: options.contract,\n runtime: options.runtime,\n environment,\n deploymentMode: detectBrandlabContactDeploymentMode(environment),\n createResendSend,\n ...(options.botGuard ? { botGuard: options.botGuard } : {}),\n ...(options.now ? { now: options.now } : {}),\n rateLimit,\n ...(suppressionCheck ? { suppressionCheck } : {}),\n ...(options.onDeliveryFailure ? { onDeliveryFailure: options.onDeliveryFailure } : {}),\n ...(options.refuseWhenAllSuppressed === true ? { refuseWhenAllSuppressed: true } : {}),\n })\n\n // Fail at module load, not on a customer's first enquiry.\n runtimeFor({})\n\n return (request: Request) =>\n runtimeFor(options.environment ?? process.env).contactRouteHandler(request)\n}\n"]}
1
+ {"version":3,"file":"route-handler.js","sourceRoot":"","sources":["../../src/contact/route-handler.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAIpB,OAAO,EACL,gCAAgC,GAEjC,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,4BAA4B,GAG7B,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,0BAA0B,EAA0B,MAAM,aAAa,CAAA;AAChF,OAAO,EACL,4BAA4B,EAC5B,mCAAmC,GAEpC,MAAM,aAAa,CAAA;AAwCpB;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAc;IACxD,IAAI,IAA4C,CAAA;IAChD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;QAChC,IAAI,KAAK,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAC5C,0BAA0B,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAC/C,CAAA;QACD,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACvC,CAAC,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iCAAiC,CAC/C,OAA2C;IAE3C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,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AE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,SAAS;QACT,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtF,GAAG,CAAC,OAAO,CAAC,uBAAuB,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvF,CAAC,CAAA;IAEJ,0DAA0D;IAC1D,UAAU,CAAC,EAAE,CAAC,CAAA;IAEd,OAAO,CAAC,OAAgB,EAAE,EAAE,CAC1B,UAAU,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;AAC/E,CAAC","sourcesContent":["import 'server-only'\n\nimport type { BrandlabContactContract } from '@brandlab-digital/site-core/contact'\nimport type { BrandlabEnvironment } from '@brandlab-digital/site-core/site'\nimport {\n createBrandlabContactRateLimiter,\n type BrandlabContactRateLimitOptions,\n} from './rate-limit.js'\nimport {\n createResendSuppressionCheck,\n type BrandlabContactDeliveryAlert,\n type BrandlabContactSuppressionCheck,\n} from './delivery.js'\nimport { createResendSdkContactSend, type ResendContactSend } from './resend.js'\nimport {\n createBrandlabContactRuntime,\n detectBrandlabContactDeploymentMode,\n type BrandlabContactRuntimeDefinitionOptions,\n} from './server.js'\nimport type { ContactBotGuard } from './shared.js'\nimport type { BrandlabContactSpamFilterOptions } from './spam-filter.js'\n\nexport interface BrandlabContactRouteHandlerOptions {\n contract: BrandlabContactContract\n /** Labels, brand name, canonical site URL, email style and attachment settings. */\n runtime: BrandlabContactRuntimeDefinitionOptions\n botGuard?: ContactBotGuard\n /**\n * The shared spam filter (4.1.0), on by default. Sites add phrases or relax a rule here; `false` turns it off.\n */\n spamFilter?: BrandlabContactSpamFilterOptions | false\n /** Defaults to process.env, read on every request. */\n environment?: BrandlabEnvironment\n now?: () => Date\n /** Replaces the Resend SDK in synthetic tests; production code omits it. */\n createResendSend?: (apiKey: string) => ResendContactSend\n /**\n * Abuse limits per client IP and per email address, held for the life of the route module (BRANDLAB_CONTACT_RATE_LIMITS\n * by default; `false` turns them off). They apply only where enquiries are delivered (production and Preview).\n */\n rateLimit?: BrandlabContactRateLimitOptions | false\n /**\n * The pre-send check of each business inbox against Resend's suppression list (3.14.0), held for the life of the\n * route module so its answers are cached (5 minutes per inbox). On by default with Resend's suppressions API and a\n * full-access key: `RESEND_LOOKUP_API_KEY` when set, otherwise `RESEND_API_KEY`. A sending-only key is refused, logged\n * once per 5 minutes naming the missing permission, and the enquiry is sent as before. Off by default when\n * `createResendSend` replaces the provider, and `false` turns it off.\n */\n suppressionCheck?: BrandlabContactSuppressionCheck | false\n /**\n * Opt-in only (default `false`): when every business inbox is suppressed, refuse and ask the visitor to call. By\n * default the suppression check only records and alerts, and the enquiry is sent to the client's own inbox.\n */\n refuseWhenAllSuppressed?: boolean\n /** The same-day alert for a delivery failure the route finds before sending (3.14.0). */\n onDeliveryFailure?: BrandlabContactDeliveryAlert\n}\n\n/**\n * A Resend send function that loads the optional `resend` peer only when an\n * enquiry is actually delivered, so validation, bot and local requests never\n * load the provider SDK.\n */\nexport function createLazyResendContactSend(apiKey: string): ResendContactSend {\n let send: Promise<ResendContactSend> | undefined\n return async (payload, options) => {\n send ??= import('resend').then(({ Resend }) =>\n createResendSdkContactSend(new Resend(apiKey)),\n )\n return (await send)(payload, options)\n }\n}\n\n/**\n * The whole of `src/app/api/contact/route.ts`:\n * `export const POST = createBrandlabContactRouteHandler({ contract, runtime })`.\n * The contract and runtime are validated when the route module loads; each\n * request then resolves the deployment from its environment and delegates to\n * createBrandlabContactRuntime exactly as a per-request runtime would.\n */\nexport function createBrandlabContactRouteHandler(\n options: BrandlabContactRouteHandlerOptions,\n): (request: Request) => Promise<Response> {\n if (!options || typeof options !== 'object') {\n throw new TypeError('createBrandlabContactRouteHandler requires the contract and runtime.')\n }\n if (options.createResendSend !== undefined && typeof options.createResendSend !== 'function') {\n throw new TypeError('createResendSend must be a function.')\n }\n const createResendSend = options.createResendSend ?? createLazyResendContactSend\n // One suppression cache for the module. A synthetic test that replaces the provider never asks the real one.\n const suppressionCheck =\n options.suppressionCheck === false\n ? undefined\n : options.suppressionCheck ?? (options.createResendSend ? undefined : createResendSuppressionCheck())\n // One limiter for the module, shared by every per-request runtime, so its windows outlive each request.\n const rateLimit = options.rateLimit === false ? false : createBrandlabContactRateLimiter(options.rateLimit)\n const runtimeFor = (environment: BrandlabEnvironment) =>\n createBrandlabContactRuntime({\n contract: options.contract,\n runtime: options.runtime,\n environment,\n deploymentMode: detectBrandlabContactDeploymentMode(environment),\n createResendSend,\n ...(options.botGuard ? { botGuard: options.botGuard } : {}),\n ...(options.spamFilter !== undefined ? { spamFilter: options.spamFilter } : {}),\n ...(options.now ? { now: options.now } : {}),\n rateLimit,\n ...(suppressionCheck ? { suppressionCheck } : {}),\n ...(options.onDeliveryFailure ? { onDeliveryFailure: options.onDeliveryFailure } : {}),\n ...(options.refuseWhenAllSuppressed === true ? { refuseWhenAllSuppressed: true } : {}),\n })\n\n // Fail at module load, not on a customer's first enquiry.\n runtimeFor({})\n\n return (request: Request) =>\n runtimeFor(options.environment ?? process.env).contactRouteHandler(request)\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import 'server-only';
2
- export { BRANDLAB_CONTACT_API_KEY_ENV, BRANDLAB_CONTACT_MAX_REQUEST_BYTES, BRANDLAB_CONTACT_RATE_LIMITS, BRANDLAB_CONTACT_RUNTIME, createBrandlabContactRateLimiter, createBrandlabContactRuntime, createResendSdkContactSend, detectBrandlabContactDeploymentMode, type BrandlabContactRateLimitOptions, type BrandlabContactRateLimitRule, type BrandlabContactRateLimiter, type BrandlabContactRuntime, type BrandlabContactRuntimeDefinitionOptions, type BrandlabContactRuntimeOptions, type ResendContactSend, type ResendSdkContactClient, } from './server.js';
2
+ export { BRANDLAB_CONTACT_API_KEY_ENV, BRANDLAB_CONTACT_MAX_REQUEST_BYTES, BRANDLAB_CONTACT_RATE_LIMITS, BRANDLAB_CONTACT_RUNTIME, BRANDLAB_PREVIEW_CONTACT_HEADER, BRANDLAB_PREVIEW_TEST_RECIPIENT, createBrandlabContactRateLimiter, createBrandlabContactRuntime, createResendSdkContactSend, detectBrandlabContactDeploymentMode, type BrandlabContactRateLimitOptions, type BrandlabContactRateLimitRule, type BrandlabContactRateLimiter, type BrandlabContactRuntime, type BrandlabContactRuntimeDefinitionOptions, type BrandlabContactRuntimeOptions, type ResendContactSend, type ResendSdkContactClient, } from './server.js';
3
3
  export { createBrandlabContactRouteHandler, createLazyResendContactSend, type BrandlabContactRouteHandlerOptions, } from './route-handler.js';
4
4
  export { BRANDLAB_CONTACT_DELIVERY_ALERT_FAILED_EVENT, BRANDLAB_CONTACT_DELIVERY_FAILED_EVENT, BRANDLAB_CONTACT_DELIVERY_STATUS_EVENT, BRANDLAB_CONTACT_LOOKUP_API_KEY_ENV, BRANDLAB_CONTACT_SUPPRESSION_CACHE_MS, BRANDLAB_CONTACT_SUPPRESSION_UNAVAILABLE_EVENT, createResendSuppressionCheck, type BrandlabContactDeliveryAlert, type BrandlabContactDeliveryFailure, type BrandlabContactDeliveryFailureCode, type BrandlabContactSuppressionCheck, type BrandlabContactSuppressionStatus, type ResendSuppressionCheckOptions, } from './delivery.js';
5
5
  export { BRANDLAB_RESEND_WEBHOOK_RATE_LIMIT, BRANDLAB_RESEND_WEBHOOK_SECRET_ENV, createBrandlabResendWebhookRoute, verifyResendWebhookSignature, type BrandlabResendWebhookRoute, type BrandlabResendWebhookRouteOptions, } from './resend-webhook.js';
6
+ export { BRANDLAB_CONTACT_KNOWN_SPAM_SENDER_HASHES, BRANDLAB_CONTACT_MIN_FILL_MS, BRANDLAB_CONTACT_STRONG_SPAM_SIGNALS, BRANDLAB_CONTACT_WEAK_SPAM_SIGNALS, assessBrandlabContactSpam, contactSpamFieldsOf, isClearlyForeignOrRandomSuburb, type BrandlabContactSpamAssessment, type BrandlabContactSpamFilterOptions, type BrandlabContactSpamSignal, } from './spam-filter.js';
6
7
  //# sourceMappingURL=server-entry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-entry.d.ts","sourceRoot":"","sources":["../../src/contact/server-entry.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EACL,4BAA4B,EAC5B,kCAAkC,EAClC,4BAA4B,EAC5B,wBAAwB,EACxB,gCAAgC,EAChC,4BAA4B,EAC5B,0BAA0B,EAC1B,mCAAmC,EACnC,KAAK,+BAA+B,EACpC,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,uCAAuC,EAC5C,KAAK,6BAA6B,EAClC,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,GAC5B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,iCAAiC,EACjC,2BAA2B,EAC3B,KAAK,kCAAkC,GACxC,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,4CAA4C,EAC5C,sCAAsC,EACtC,sCAAsC,EACtC,mCAAmC,EACnC,qCAAqC,EACrC,8CAA8C,EAC9C,4BAA4B,EAC5B,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,EACnC,KAAK,kCAAkC,EACvC,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,EACrC,KAAK,6BAA6B,GACnC,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,kCAAkC,EAClC,kCAAkC,EAClC,gCAAgC,EAChC,4BAA4B,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,iCAAiC,GACvC,MAAM,qBAAqB,CAAA"}
1
+ {"version":3,"file":"server-entry.d.ts","sourceRoot":"","sources":["../../src/contact/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S, BRANDLAB_CONTACT_RUNTIME, createBrandlabContactRateLimiter, createBrandlabContactRuntime, createResendSdkContactSend, detectBrandlabContactDeploymentMode, } from './server.js';
2
+ export { BRANDLAB_CONTACT_API_KEY_ENV, BRANDLAB_CONTACT_MAX_REQUEST_BYTES, BRANDLAB_CONTACT_RATE_LIMITS, BRANDLAB_CONTACT_RUNTIME, BRANDLAB_PREVIEW_CONTACT_HEADER, BRANDLAB_PREVIEW_TEST_RECIPIENT, createBrandlabContactRateLimiter, createBrandlabContactRuntime, createResendSdkContactSend, detectBrandlabContactDeploymentMode, } from './server.js';
3
3
  export { createBrandlabContactRouteHandler, createLazyResendContactSend, } from './route-handler.js';
4
4
  export { BRANDLAB_CONTACT_DELIVERY_ALERT_FAILED_EVENT, BRANDLAB_CONTACT_DELIVERY_FAILED_EVENT, BRANDLAB_CONTACT_DELIVERY_STATUS_EVENT, BRANDLAB_CONTACT_LOOKUP_API_KEY_ENV, BRANDLAB_CONTACT_SUPPRESSION_CACHE_MS, BRANDLAB_CONTACT_SUPPRESSION_UNAVAILABLE_EVENT, createResendSuppressionCheck, } from './delivery.js';
5
5
  export { BRANDLAB_RESEND_WEBHOOK_RATE_LIMIT, BRANDLAB_RESEND_WEBHOOK_SECRET_ENV, createBrandlabResendWebhookRoute, verifyResendWebhookSignature, } from './resend-webhook.js';
6
+ export { BRANDLAB_CONTACT_KNOWN_SPAM_SENDER_HASHES, BRANDLAB_CONTACT_MIN_FILL_MS, BRANDLAB_CONTACT_STRONG_SPAM_SIGNALS, BRANDLAB_CONTACT_WEAK_SPAM_SIGNALS, assessBrandlabContactSpam, contactSpamFieldsOf, isClearlyForeignOrRandomSuburb, } from './spam-filter.js';
6
7
  //# sourceMappingURL=server-entry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-entry.js","sourceRoot":"","sources":["../../src/contact/server-entry.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EACL,4BAA4B,EAC5B,kCAAkC,EAClC,4BAA4B,EAC5B,wBAAwB,EACxB,gCAAgC,EAChC,4BAA4B,EAC5B,0BAA0B,EAC1B,mCAAmC,GASpC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,iCAAiC,EACjC,2BAA2B,GAE5B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,4CAA4C,EAC5C,sCAAsC,EACtC,sCAAsC,EACtC,mCAAmC,EACnC,qCAAqC,EACrC,8CAA8C,EAC9C,4BAA4B,GAO7B,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,kCAAkC,EAClC,kCAAkC,EAClC,gCAAgC,EAChC,4BAA4B,GAG7B,MAAM,qBAAqB,CAAA","sourcesContent":["import 'server-only'\n\nexport {\n BRANDLAB_CONTACT_API_KEY_ENV,\n BRANDLAB_CONTACT_MAX_REQUEST_BYTES,\n BRANDLAB_CONTACT_RATE_LIMITS,\n BRANDLAB_CONTACT_RUNTIME,\n createBrandlabContactRateLimiter,\n createBrandlabContactRuntime,\n createResendSdkContactSend,\n detectBrandlabContactDeploymentMode,\n type BrandlabContactRateLimitOptions,\n type BrandlabContactRateLimitRule,\n type BrandlabContactRateLimiter,\n type BrandlabContactRuntime,\n type BrandlabContactRuntimeDefinitionOptions,\n type BrandlabContactRuntimeOptions,\n type ResendContactSend,\n type ResendSdkContactClient,\n} from './server.js'\nexport {\n createBrandlabContactRouteHandler,\n createLazyResendContactSend,\n type BrandlabContactRouteHandlerOptions,\n} from './route-handler.js'\nexport {\n BRANDLAB_CONTACT_DELIVERY_ALERT_FAILED_EVENT,\n BRANDLAB_CONTACT_DELIVERY_FAILED_EVENT,\n BRANDLAB_CONTACT_DELIVERY_STATUS_EVENT,\n BRANDLAB_CONTACT_LOOKUP_API_KEY_ENV,\n BRANDLAB_CONTACT_SUPPRESSION_CACHE_MS,\n BRANDLAB_CONTACT_SUPPRESSION_UNAVAILABLE_EVENT,\n createResendSuppressionCheck,\n type BrandlabContactDeliveryAlert,\n type BrandlabContactDeliveryFailure,\n type BrandlabContactDeliveryFailureCode,\n type BrandlabContactSuppressionCheck,\n type BrandlabContactSuppressionStatus,\n type ResendSuppressionCheckOptions,\n} from './delivery.js'\nexport {\n BRANDLAB_RESEND_WEBHOOK_RATE_LIMIT,\n BRANDLAB_RESEND_WEBHOOK_SECRET_ENV,\n createBrandlabResendWebhookRoute,\n verifyResendWebhookSignature,\n type BrandlabResendWebhookRoute,\n type BrandlabResendWebhookRouteOptions,\n} from './resend-webhook.js'\n"]}
1
+ {"version":3,"file":"server-entry.js","sourceRoot":"","sources":["../../src/contact/server-entry.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EACL,4BAA4B,EAC5B,kCAAkC,EAClC,4BAA4B,EAC5B,wBAAwB,EACxB,+BAA+B,EAC/B,+BAA+B,EAC/B,gCAAgC,EAChC,4BAA4B,EAC5B,0BAA0B,EAC1B,mCAAmC,GASpC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,iCAAiC,EACjC,2BAA2B,GAE5B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,4CAA4C,EAC5C,sCAAsC,EACtC,sCAAsC,EACtC,mCAAmC,EACnC,qCAAqC,EACrC,8CAA8C,EAC9C,4BAA4B,GAO7B,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,kCAAkC,EAClC,kCAAkC,EAClC,gCAAgC,EAChC,4BAA4B,GAG7B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,yCAAyC,EACzC,4BAA4B,EAC5B,oCAAoC,EACpC,kCAAkC,EAClC,yBAAyB,EACzB,mBAAmB,EACnB,8BAA8B,GAI/B,MAAM,kBAAkB,CAAA","sourcesContent":["import 'server-only'\n\nexport {\n BRANDLAB_CONTACT_API_KEY_ENV,\n BRANDLAB_CONTACT_MAX_REQUEST_BYTES,\n BRANDLAB_CONTACT_RATE_LIMITS,\n BRANDLAB_CONTACT_RUNTIME,\n BRANDLAB_PREVIEW_CONTACT_HEADER,\n BRANDLAB_PREVIEW_TEST_RECIPIENT,\n createBrandlabContactRateLimiter,\n createBrandlabContactRuntime,\n createResendSdkContactSend,\n detectBrandlabContactDeploymentMode,\n type BrandlabContactRateLimitOptions,\n type BrandlabContactRateLimitRule,\n type BrandlabContactRateLimiter,\n type BrandlabContactRuntime,\n type BrandlabContactRuntimeDefinitionOptions,\n type BrandlabContactRuntimeOptions,\n type ResendContactSend,\n type ResendSdkContactClient,\n} from './server.js'\nexport {\n createBrandlabContactRouteHandler,\n createLazyResendContactSend,\n type BrandlabContactRouteHandlerOptions,\n} from './route-handler.js'\nexport {\n BRANDLAB_CONTACT_DELIVERY_ALERT_FAILED_EVENT,\n BRANDLAB_CONTACT_DELIVERY_FAILED_EVENT,\n BRANDLAB_CONTACT_DELIVERY_STATUS_EVENT,\n BRANDLAB_CONTACT_LOOKUP_API_KEY_ENV,\n BRANDLAB_CONTACT_SUPPRESSION_CACHE_MS,\n BRANDLAB_CONTACT_SUPPRESSION_UNAVAILABLE_EVENT,\n createResendSuppressionCheck,\n type BrandlabContactDeliveryAlert,\n type BrandlabContactDeliveryFailure,\n type BrandlabContactDeliveryFailureCode,\n type BrandlabContactSuppressionCheck,\n type BrandlabContactSuppressionStatus,\n type ResendSuppressionCheckOptions,\n} from './delivery.js'\nexport {\n BRANDLAB_RESEND_WEBHOOK_RATE_LIMIT,\n BRANDLAB_RESEND_WEBHOOK_SECRET_ENV,\n createBrandlabResendWebhookRoute,\n verifyResendWebhookSignature,\n type BrandlabResendWebhookRoute,\n type BrandlabResendWebhookRouteOptions,\n} from './resend-webhook.js'\nexport {\n BRANDLAB_CONTACT_KNOWN_SPAM_SENDER_HASHES,\n BRANDLAB_CONTACT_MIN_FILL_MS,\n BRANDLAB_CONTACT_STRONG_SPAM_SIGNALS,\n BRANDLAB_CONTACT_WEAK_SPAM_SIGNALS,\n assessBrandlabContactSpam,\n contactSpamFieldsOf,\n isClearlyForeignOrRandomSuburb,\n type BrandlabContactSpamAssessment,\n type BrandlabContactSpamFilterOptions,\n type BrandlabContactSpamSignal,\n} from './spam-filter.js'\n"]}