@wealthreach/site-kit 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a11y/index.js +7 -2
- package/dist/a11y/shell-client.d.ts +1 -1
- package/dist/a11y/shell-client.js +4 -4
- package/dist/analytics/index.d.ts +2 -2
- package/dist/analytics/index.js +9 -3
- package/dist/{attribution-DQaAWtA5.d.ts → attribution-BajAl0tG.d.ts} +17 -7
- package/dist/blog/index.d.ts +16 -4
- package/dist/blog/index.js +57 -4
- package/dist/{chunk-Y77ARZE4.js → chunk-DHVKLLL7.js} +5 -3
- package/dist/{chunk-QQP7VG2C.js → chunk-JPUCXNHR.js} +109 -16
- package/dist/{chunk-4YRCSRZZ.js → chunk-SNTMH6M3.js} +2 -2
- package/dist/{chunk-7GDXQ6UB.js → chunk-T4Q4VJ6K.js} +34 -7
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +4 -3
- package/dist/consent/index.d.ts +5 -3
- package/dist/consent/index.js +4 -2
- package/dist/forms/index.d.ts +19 -7
- package/dist/forms/index.js +141 -42
- package/dist/next/leads-route.d.ts +8 -5
- package/dist/next/leads-route.js +136 -123
- package/dist/{schema-C1ixytx2.d.ts → schema-AcsTlgUv.d.ts} +4 -0
- package/dist/{schema-DD0nDOD0.d.ts → schema-CYsBDpoU.d.ts} +3 -0
- package/package.json +1 -1
package/dist/config/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SiteConfig } from '../schema-
|
|
2
|
-
export { B as BlogConfig, a as BookingConfig, C as ComplianceConfig, b as ConsentConfig, c as CtaLink, D as DEFAULT_ANALYTICS_ENDPOINT, d as DEFAULT_LEADS_API_URL, F as FooterGroup, I as IntegrationsConfig, N as NavItem, e as SocialLink, V as VisitorsConfig, f as blogConfigSchema, g as bookingConfigSchema, h as complianceConfigSchema, i as consentConfigSchema, j as ctaLinkSchema, k as displayNameFromLegal, l as footerGroupSchema, m as integrationsConfigSchema, n as navItemSchema, s as siteConfigSchema, o as socialLinkSchema, v as visitorsConfigSchema } from '../schema-
|
|
1
|
+
import { S as SiteConfig } from '../schema-AcsTlgUv.js';
|
|
2
|
+
export { B as BlogConfig, a as BookingConfig, C as ComplianceConfig, b as ConsentConfig, c as CtaLink, D as DEFAULT_ANALYTICS_ENDPOINT, d as DEFAULT_LEADS_API_URL, F as FooterGroup, I as IntegrationsConfig, N as NavItem, e as SocialLink, V as VisitorsConfig, f as blogConfigSchema, g as bookingConfigSchema, h as complianceConfigSchema, i as consentConfigSchema, j as ctaLinkSchema, k as displayNameFromLegal, l as footerGroupSchema, m as integrationsConfigSchema, n as navItemSchema, s as siteConfigSchema, o as socialLinkSchema, v as visitorsConfigSchema } from '../schema-AcsTlgUv.js';
|
|
3
3
|
import { Metadata } from 'next';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '../regulatory-schema-uDKNJ7q8.js';
|
package/dist/config/index.js
CHANGED
|
@@ -219,7 +219,7 @@ var bookingConfigSchema = z2.object({
|
|
|
219
219
|
var consentConfigSchema = z2.object({
|
|
220
220
|
enabled: z2.boolean().default(true),
|
|
221
221
|
message: z2.string().trim().optional().default(""),
|
|
222
|
-
policyUrl: z2.string().trim().optional().default("
|
|
222
|
+
policyUrl: z2.string().trim().optional().default(""),
|
|
223
223
|
/** Legacy cookie names to migrate silently for returning visitors (e.g. Brandywine Oak). */
|
|
224
224
|
legacyConsentCookies: z2.array(z2.string().trim().min(1)).optional().default([]),
|
|
225
225
|
/** Additional US states requiring opt-in beyond California (CA is always opt-in). */
|
|
@@ -229,7 +229,8 @@ var consentConfigSchema = z2.object({
|
|
|
229
229
|
});
|
|
230
230
|
var visitorsConfigSchema = z2.object({
|
|
231
231
|
enabled: z2.boolean().default(false),
|
|
232
|
-
siteScriptUrl: z2.string().trim().optional().default("")
|
|
232
|
+
siteScriptUrl: z2.string().trim().optional().default(""),
|
|
233
|
+
recordings: z2.boolean().optional()
|
|
233
234
|
});
|
|
234
235
|
var blogConfigSchema = z2.object({
|
|
235
236
|
enabled: z2.boolean().optional().default(true),
|
|
@@ -278,7 +279,7 @@ var siteConfigSchema = z2.object({
|
|
|
278
279
|
consent: consentConfigSchema.optional().default({
|
|
279
280
|
enabled: true,
|
|
280
281
|
message: "",
|
|
281
|
-
policyUrl: "
|
|
282
|
+
policyUrl: "",
|
|
282
283
|
legacyConsentCookies: [],
|
|
283
284
|
extraOptInUsRegions: [],
|
|
284
285
|
hideFloatingPrivacyButton: false
|
package/dist/consent/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { S as SiteConfig } from '../schema-
|
|
2
|
+
import { S as SiteConfig } from '../schema-CYsBDpoU.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -24,7 +24,8 @@ declare function analyticsAllowed(consent: ConsentValue | null, mode: PrivacyMod
|
|
|
24
24
|
declare function parseConsentValue(raw: string | null): ConsentValue | null;
|
|
25
25
|
declare function readCookieFromString(cookieHeader: string, name: string): string | null;
|
|
26
26
|
declare function readBrowserCookie(name: string): string | null;
|
|
27
|
-
declare function
|
|
27
|
+
declare function legacyConsentStorageKey(siteId?: string): string;
|
|
28
|
+
declare function readStoredConsent(legacyCookieNames?: readonly string[], siteId?: string): ConsentValue | null;
|
|
28
29
|
declare function writeConsentCookie(value: ConsentValue): void;
|
|
29
30
|
declare function readGpcSignal(): boolean;
|
|
30
31
|
declare function resolveGeoFromHeaders(headers: Headers): {
|
|
@@ -33,6 +34,7 @@ declare function resolveGeoFromHeaders(headers: Headers): {
|
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
interface ConsentBootstrapOptions {
|
|
37
|
+
siteId?: string;
|
|
36
38
|
visitorScriptUrl?: string;
|
|
37
39
|
gtmId?: string;
|
|
38
40
|
ga4MeasurementId?: string;
|
|
@@ -99,5 +101,5 @@ interface ConsentBannerProps {
|
|
|
99
101
|
*/
|
|
100
102
|
declare function ConsentBanner({ floatingButtonClassName, bannerClassName, }?: ConsentBannerProps): React__default.JSX.Element | null;
|
|
101
103
|
|
|
102
|
-
export { CONSENT_COOKIE, CONSENT_MAX_AGE, ConsentBanner, ConsentGate, ConsentProvider, DEFAULT_OPT_IN_US_REGIONS, GA4_SCRIPT_ID, GTM_SCRIPT_ID, MODE_COOKIE, MODE_MAX_AGE, OPT_IN_COUNTRIES, PrivacyChoicesButton, VISITOR_SCRIPT_ID, analyticsAllowed, buildConsentBootstrapScript, parseConsentValue, privacyModeForLocation, readBrowserCookie, readCookieFromString, readGpcSignal, readStoredConsent, resolveGeoFromHeaders, sanitizeGa4Id, sanitizeGtmId, sanitizeVisitorScriptUrl, useConsent, writeConsentCookie };
|
|
104
|
+
export { CONSENT_COOKIE, CONSENT_MAX_AGE, ConsentBanner, ConsentGate, ConsentProvider, DEFAULT_OPT_IN_US_REGIONS, GA4_SCRIPT_ID, GTM_SCRIPT_ID, MODE_COOKIE, MODE_MAX_AGE, OPT_IN_COUNTRIES, PrivacyChoicesButton, VISITOR_SCRIPT_ID, analyticsAllowed, buildConsentBootstrapScript, legacyConsentStorageKey, parseConsentValue, privacyModeForLocation, readBrowserCookie, readCookieFromString, readGpcSignal, readStoredConsent, resolveGeoFromHeaders, sanitizeGa4Id, sanitizeGtmId, sanitizeVisitorScriptUrl, useConsent, writeConsentCookie };
|
|
103
105
|
export type { ConsentBannerProps, ConsentBootstrapOptions, ConsentContextValue, ConsentProviderProps, ConsentValue, PrivacyChoicesButtonProps, PrivacyMode };
|
package/dist/consent/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ConsentBanner,
|
|
4
4
|
PrivacyChoicesButton
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-DHVKLLL7.js";
|
|
6
6
|
import {
|
|
7
7
|
CONSENT_COOKIE,
|
|
8
8
|
CONSENT_MAX_AGE,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
VISITOR_SCRIPT_ID,
|
|
18
18
|
analyticsAllowed,
|
|
19
19
|
buildConsentBootstrapScript,
|
|
20
|
+
legacyConsentStorageKey,
|
|
20
21
|
parseConsentValue,
|
|
21
22
|
privacyModeForLocation,
|
|
22
23
|
readBrowserCookie,
|
|
@@ -29,7 +30,7 @@ import {
|
|
|
29
30
|
sanitizeVisitorScriptUrl,
|
|
30
31
|
useConsent,
|
|
31
32
|
writeConsentCookie
|
|
32
|
-
} from "../chunk-
|
|
33
|
+
} from "../chunk-T4Q4VJ6K.js";
|
|
33
34
|
export {
|
|
34
35
|
CONSENT_COOKIE,
|
|
35
36
|
CONSENT_MAX_AGE,
|
|
@@ -46,6 +47,7 @@ export {
|
|
|
46
47
|
VISITOR_SCRIPT_ID,
|
|
47
48
|
analyticsAllowed,
|
|
48
49
|
buildConsentBootstrapScript,
|
|
50
|
+
legacyConsentStorageKey,
|
|
49
51
|
parseConsentValue,
|
|
50
52
|
privacyModeForLocation,
|
|
51
53
|
readBrowserCookie,
|
package/dist/forms/index.d.ts
CHANGED
|
@@ -27,7 +27,19 @@ interface FormSuccessResult<TData = unknown> {
|
|
|
27
27
|
data?: TData;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
declare const MAX_CUSTOM_FIELDS = 40;
|
|
30
31
|
declare function isSensitiveFieldKey(key: string): boolean;
|
|
32
|
+
interface SanitizedCustomFieldsResult {
|
|
33
|
+
customFields: Record<string, string | boolean | string[]>;
|
|
34
|
+
blockedSensitiveKeys: string[];
|
|
35
|
+
tooManyCustomFields: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Sanitizes explicitly separated `customFields` without applying honeypot
|
|
39
|
+
* detection, canonical field aliasing (`email_address` -> `email`), or
|
|
40
|
+
* string-to-boolean `"on"` coercion.
|
|
41
|
+
*/
|
|
42
|
+
declare function sanitizeCustomFields(input: Record<string, CustomFieldValue | undefined> | null | undefined): SanitizedCustomFieldsResult;
|
|
31
43
|
interface PackedFormValues {
|
|
32
44
|
name?: string;
|
|
33
45
|
email: string;
|
|
@@ -37,6 +49,7 @@ interface PackedFormValues {
|
|
|
37
49
|
turnstileToken?: string;
|
|
38
50
|
customFields: Record<string, string | boolean | string[]>;
|
|
39
51
|
blockedSensitiveKeys: string[];
|
|
52
|
+
tooManyCustomFields: boolean;
|
|
40
53
|
}
|
|
41
54
|
/**
|
|
42
55
|
* Extracts canonical lead fields (handling real-world aliases like `Full-Name`,
|
|
@@ -85,17 +98,16 @@ declare function useWealthReachForm<TData = unknown>(options: UseWealthReachForm
|
|
|
85
98
|
phone?: string;
|
|
86
99
|
message?: string;
|
|
87
100
|
customFields?: Record<string, CustomFieldValue>;
|
|
101
|
+
honeypot?: string;
|
|
88
102
|
turnstileToken?: string;
|
|
89
103
|
}) => Promise<{
|
|
90
|
-
ok: false;
|
|
91
|
-
error: string;
|
|
92
|
-
leadId?: undefined;
|
|
93
|
-
data?: undefined;
|
|
94
|
-
} | {
|
|
95
104
|
ok: true;
|
|
96
105
|
leadId: string;
|
|
97
106
|
data: TData | undefined;
|
|
98
107
|
error?: undefined;
|
|
108
|
+
} | {
|
|
109
|
+
ok: false;
|
|
110
|
+
error: string;
|
|
99
111
|
}>;
|
|
100
112
|
status: "idle" | "submitting" | "success" | "error";
|
|
101
113
|
errors: Record<string, string>;
|
|
@@ -124,5 +136,5 @@ declare function WealthReachHiddenContext({ formId, formKind, }: {
|
|
|
124
136
|
formKind?: FormKind;
|
|
125
137
|
}): React__default.JSX.Element;
|
|
126
138
|
|
|
127
|
-
export { FORM_KINDS, WealthReachForm, WealthReachHiddenContext, isSensitiveFieldKey, packFormEntries, useWealthReachForm };
|
|
128
|
-
export type { CustomFieldValue, FormKind, FormSuccessResult, NormalizedLeadSubmission, PackedFormValues, UseWealthReachFormOptions, WealthReachFormProps };
|
|
139
|
+
export { FORM_KINDS, MAX_CUSTOM_FIELDS, WealthReachForm, WealthReachHiddenContext, isSensitiveFieldKey, packFormEntries, sanitizeCustomFields, useWealthReachForm };
|
|
140
|
+
export type { CustomFieldValue, FormKind, FormSuccessResult, NormalizedLeadSubmission, PackedFormValues, SanitizedCustomFieldsResult, UseWealthReachFormOptions, WealthReachFormProps };
|
package/dist/forms/index.js
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
readAttributionSnapshot,
|
|
4
4
|
readConsentedWebsiteVisit,
|
|
5
5
|
trackFormSubmission
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-JPUCXNHR.js";
|
|
7
7
|
import {
|
|
8
8
|
useConsent
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-T4Q4VJ6K.js";
|
|
10
10
|
|
|
11
11
|
// src/forms/types.ts
|
|
12
12
|
var FORM_KINDS = [
|
|
@@ -22,10 +22,13 @@ var FORM_KINDS = [
|
|
|
22
22
|
var SENSITIVE_FIELD_RE = /(?:^|[_.-])(?:ssn|social[_-]?security|account[_-]?number|routing[_-]?number|password|passwd|secret|credit[_-]?card|card[_-]?number|cvv|cvc|tax[_-]?id|ein|tin)(?:$|[_.-])/i;
|
|
23
23
|
var HONEYPOT_KEYS = /* @__PURE__ */ new Set([
|
|
24
24
|
"website",
|
|
25
|
-
"company_website",
|
|
26
25
|
"wr_hp",
|
|
27
26
|
"_hp"
|
|
28
27
|
]);
|
|
28
|
+
var CUSTOM_FIELD_KEY_RE = /^[a-zA-Z0-9_.-]{1,64}$/;
|
|
29
|
+
var CONTROL_CHARS_RE = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;
|
|
30
|
+
var PROTOTYPE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
31
|
+
var MAX_CUSTOM_FIELDS = 40;
|
|
29
32
|
var INTERNAL_KEYS = /* @__PURE__ */ new Set([
|
|
30
33
|
"cf-turnstile-response",
|
|
31
34
|
"turnstileToken",
|
|
@@ -37,6 +40,58 @@ function normalizeKey(raw) {
|
|
|
37
40
|
function isSensitiveFieldKey(key) {
|
|
38
41
|
return SENSITIVE_FIELD_RE.test(key);
|
|
39
42
|
}
|
|
43
|
+
function sanitizeCustomFields(input) {
|
|
44
|
+
const customFields = {};
|
|
45
|
+
const blockedSensitiveKeys = [];
|
|
46
|
+
let tooManyCustomFields = false;
|
|
47
|
+
let fieldCount = 0;
|
|
48
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
49
|
+
return { customFields, blockedSensitiveKeys, tooManyCustomFields };
|
|
50
|
+
}
|
|
51
|
+
for (const [rawKey, rawValue] of Object.entries(input)) {
|
|
52
|
+
if (rawValue === void 0 || rawValue === null) continue;
|
|
53
|
+
const key = rawKey.trim();
|
|
54
|
+
if (!key) continue;
|
|
55
|
+
if (isSensitiveFieldKey(key)) {
|
|
56
|
+
blockedSensitiveKeys.push(key);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (PROTOTYPE_KEYS.has(key) || !CUSTOM_FIELD_KEY_RE.test(key)) continue;
|
|
60
|
+
let sanitizedValue;
|
|
61
|
+
if (typeof rawValue === "boolean") {
|
|
62
|
+
sanitizedValue = rawValue;
|
|
63
|
+
} else if (Array.isArray(rawValue)) {
|
|
64
|
+
const cleaned = rawValue.map(
|
|
65
|
+
(item) => String(item).trim().replace(CONTROL_CHARS_RE, "").slice(0, 200)
|
|
66
|
+
).filter((s) => s.length > 0).slice(0, 25);
|
|
67
|
+
if (cleaned.length > 0) {
|
|
68
|
+
sanitizedValue = cleaned;
|
|
69
|
+
}
|
|
70
|
+
} else if (typeof rawValue === "number") {
|
|
71
|
+
if (Number.isFinite(rawValue)) {
|
|
72
|
+
sanitizedValue = String(rawValue);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
const cleaned = String(rawValue).trim().replace(CONTROL_CHARS_RE, "").slice(0, 2e3);
|
|
76
|
+
if (cleaned.length > 0) {
|
|
77
|
+
sanitizedValue = cleaned;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (sanitizedValue === void 0) continue;
|
|
81
|
+
if (fieldCount >= MAX_CUSTOM_FIELDS) {
|
|
82
|
+
tooManyCustomFields = true;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
Object.defineProperty(customFields, key, {
|
|
86
|
+
value: sanitizedValue,
|
|
87
|
+
enumerable: true,
|
|
88
|
+
writable: true,
|
|
89
|
+
configurable: true
|
|
90
|
+
});
|
|
91
|
+
fieldCount += 1;
|
|
92
|
+
}
|
|
93
|
+
return { customFields, blockedSensitiveKeys, tooManyCustomFields };
|
|
94
|
+
}
|
|
40
95
|
function packFormEntries(entries) {
|
|
41
96
|
const buckets = /* @__PURE__ */ new Map();
|
|
42
97
|
let honeypot = "";
|
|
@@ -75,6 +130,14 @@ function packFormEntries(entries) {
|
|
|
75
130
|
}
|
|
76
131
|
buckets.set(key, list);
|
|
77
132
|
}
|
|
133
|
+
const normalizedKeys = /* @__PURE__ */ new Set();
|
|
134
|
+
for (const [rawKey, values] of buckets.entries()) {
|
|
135
|
+
if (values.length > 0) normalizedKeys.add(normalizeKey(rawKey));
|
|
136
|
+
}
|
|
137
|
+
const hasExactName = normalizedKeys.has("name");
|
|
138
|
+
const hasExactEmail = normalizedKeys.has("email");
|
|
139
|
+
const hasExactPhone = normalizedKeys.has("phone");
|
|
140
|
+
const hasExactMessage = normalizedKeys.has("message");
|
|
78
141
|
let name;
|
|
79
142
|
let firstName;
|
|
80
143
|
let lastName;
|
|
@@ -82,47 +145,49 @@ function packFormEntries(entries) {
|
|
|
82
145
|
let phone;
|
|
83
146
|
let message;
|
|
84
147
|
const customFields = {};
|
|
148
|
+
let customFieldCount = 0;
|
|
149
|
+
let tooManyCustomFields = false;
|
|
85
150
|
for (const [rawKey, values] of buckets.entries()) {
|
|
86
151
|
if (values.length === 0) continue;
|
|
87
152
|
const normalized = normalizeKey(rawKey);
|
|
88
153
|
const firstString = String(values[0] ?? "").trim();
|
|
89
|
-
if (normalized === "name" || normalized === "full_name" || normalized === "your_name") {
|
|
154
|
+
if (normalized === "name" || !hasExactName && (normalized === "full_name" || normalized === "your_name")) {
|
|
90
155
|
name = firstString;
|
|
91
156
|
continue;
|
|
92
157
|
}
|
|
93
|
-
if (normalized === "first_name" || normalized === "firstname") {
|
|
158
|
+
if (!hasExactName && (normalized === "first_name" || normalized === "firstname")) {
|
|
94
159
|
firstName = firstString;
|
|
95
160
|
continue;
|
|
96
161
|
}
|
|
97
|
-
if (normalized === "last_name" || normalized === "lastname") {
|
|
162
|
+
if (!hasExactName && (normalized === "last_name" || normalized === "lastname")) {
|
|
98
163
|
lastName = firstString;
|
|
99
164
|
continue;
|
|
100
165
|
}
|
|
101
|
-
if (normalized === "email" || normalized === "email_address" || normalized === "e_mail" || normalized === "e_mail_address") {
|
|
166
|
+
if (normalized === "email" || !hasExactEmail && (normalized === "email_address" || normalized === "e_mail" || normalized === "e_mail_address")) {
|
|
102
167
|
email = firstString.toLowerCase();
|
|
103
168
|
continue;
|
|
104
169
|
}
|
|
105
|
-
if (normalized === "phone" || normalized === "phone_number" || normalized === "telephone" || normalized === "tel") {
|
|
170
|
+
if (normalized === "phone" || !hasExactPhone && (normalized === "phone_number" || normalized === "telephone" || normalized === "tel")) {
|
|
106
171
|
phone = firstString;
|
|
107
172
|
continue;
|
|
108
173
|
}
|
|
109
|
-
if (normalized === "message" || normalized === "comments" || normalized === "notes" || normalized === "how_can_we_help") {
|
|
174
|
+
if (normalized === "message" || !hasExactMessage && (normalized === "comments" || normalized === "notes" || normalized === "how_can_we_help")) {
|
|
110
175
|
message = firstString;
|
|
111
176
|
continue;
|
|
112
177
|
}
|
|
113
|
-
if (!normalized) continue;
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
customFields[normalized] = v;
|
|
118
|
-
} else if (v === "on") {
|
|
119
|
-
customFields[normalized] = true;
|
|
120
|
-
} else {
|
|
121
|
-
customFields[normalized] = v.slice(0, 2e3);
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
customFields[normalized] = values.map((v) => String(v).slice(0, 200)).slice(0, 25);
|
|
178
|
+
if (!normalized || PROTOTYPE_KEYS.has(normalized)) continue;
|
|
179
|
+
if (customFieldCount >= MAX_CUSTOM_FIELDS) {
|
|
180
|
+
tooManyCustomFields = true;
|
|
181
|
+
continue;
|
|
125
182
|
}
|
|
183
|
+
const packedValue = values.length === 1 ? typeof values[0] === "boolean" ? values[0] : values[0].replace(CONTROL_CHARS_RE, "").slice(0, 2e3) : values.map((v) => String(v).replace(CONTROL_CHARS_RE, "").slice(0, 200)).slice(0, 25);
|
|
184
|
+
Object.defineProperty(customFields, normalized, {
|
|
185
|
+
value: packedValue,
|
|
186
|
+
enumerable: true,
|
|
187
|
+
writable: true,
|
|
188
|
+
configurable: true
|
|
189
|
+
});
|
|
190
|
+
customFieldCount += 1;
|
|
126
191
|
}
|
|
127
192
|
if (!name && (firstName || lastName)) {
|
|
128
193
|
name = [firstName, lastName].filter(Boolean).join(" ").trim();
|
|
@@ -135,7 +200,8 @@ function packFormEntries(entries) {
|
|
|
135
200
|
honeypot,
|
|
136
201
|
...turnstileToken ? { turnstileToken } : {},
|
|
137
202
|
customFields,
|
|
138
|
-
blockedSensitiveKeys
|
|
203
|
+
blockedSensitiveKeys,
|
|
204
|
+
tooManyCustomFields
|
|
139
205
|
};
|
|
140
206
|
}
|
|
141
207
|
|
|
@@ -198,20 +264,27 @@ function useWealthReachForm(options) {
|
|
|
198
264
|
setStatus("error");
|
|
199
265
|
return { ok: false, error: "Blocked sensitive fields" };
|
|
200
266
|
}
|
|
267
|
+
if (packed.tooManyCustomFields) {
|
|
268
|
+
setServerError(
|
|
269
|
+
"This form has too many fields to submit (maximum 40 custom fields)."
|
|
270
|
+
);
|
|
271
|
+
setStatus("error");
|
|
272
|
+
return { ok: false, error: "Too many custom fields" };
|
|
273
|
+
}
|
|
201
274
|
const allowsEmailOnly = formKind === "newsletter" || formKind === "resource";
|
|
202
275
|
if (!allowsEmailOnly && !packed.name) {
|
|
203
276
|
nextErrors.name = "Please enter your name.";
|
|
204
277
|
}
|
|
205
|
-
if (!packed.email || !EMAIL_RE.test(packed.email)) {
|
|
278
|
+
if (!packed.email || packed.email.length > 254 || !EMAIL_RE.test(packed.email)) {
|
|
206
279
|
nextErrors.email = "Please enter a valid email address.";
|
|
207
280
|
}
|
|
208
281
|
if (validate) {
|
|
209
282
|
const flat = {
|
|
283
|
+
...packed.customFields,
|
|
210
284
|
...packed.name ? { name: packed.name } : {},
|
|
211
285
|
email: packed.email,
|
|
212
286
|
...packed.phone ? { phone: packed.phone } : {},
|
|
213
|
-
...packed.message ? { message: packed.message } : {}
|
|
214
|
-
...packed.customFields
|
|
287
|
+
...packed.message ? { message: packed.message } : {}
|
|
215
288
|
};
|
|
216
289
|
Object.assign(nextErrors, validate(flat));
|
|
217
290
|
}
|
|
@@ -259,6 +332,11 @@ function useWealthReachForm(options) {
|
|
|
259
332
|
}
|
|
260
333
|
if (!config.visitors?.enabled && consentAllowed) {
|
|
261
334
|
trackFormSubmission(formId, pathname ?? "/", config);
|
|
335
|
+
} else if (config.visitors?.enabled && consentAllowed && typeof window !== "undefined") {
|
|
336
|
+
try {
|
|
337
|
+
window.__wrVisitor?.markFormSubmitted?.(formRef.current);
|
|
338
|
+
} catch {
|
|
339
|
+
}
|
|
262
340
|
}
|
|
263
341
|
const leadId = data.leadId ?? submissionId;
|
|
264
342
|
submissionIdRef.current = createSubmissionId();
|
|
@@ -294,31 +372,50 @@ function useWealthReachForm(options) {
|
|
|
294
372
|
async (event) => {
|
|
295
373
|
event.preventDefault();
|
|
296
374
|
if (status === "submitting") return;
|
|
297
|
-
const
|
|
298
|
-
const
|
|
375
|
+
const formEl = event.currentTarget;
|
|
376
|
+
const fd = new FormData(formEl);
|
|
377
|
+
const checkboxNames = /* @__PURE__ */ new Set();
|
|
378
|
+
for (const el of Array.from(formEl.elements)) {
|
|
379
|
+
if (el instanceof HTMLInputElement && el.type === "checkbox" && el.name) {
|
|
380
|
+
checkboxNames.add(el.name);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const entries = [];
|
|
384
|
+
for (const [k, v] of fd.entries()) {
|
|
385
|
+
if (checkboxNames.has(k) && v === "on") {
|
|
386
|
+
entries.push([k, true]);
|
|
387
|
+
} else {
|
|
388
|
+
entries.push([k, v]);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const packed = packFormEntries(entries);
|
|
299
392
|
await sendPayload(packed);
|
|
300
393
|
},
|
|
301
394
|
[status, sendPayload]
|
|
302
395
|
);
|
|
303
396
|
const submit = useCallback(
|
|
304
397
|
async (payload) => {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
];
|
|
308
|
-
if (payload.name !== void 0) entries.push(["name", payload.name]);
|
|
309
|
-
if (payload.phone !== void 0) entries.push(["phone", payload.phone]);
|
|
310
|
-
if (payload.message !== void 0) entries.push(["message", payload.message]);
|
|
311
|
-
if (payload.turnstileToken) {
|
|
312
|
-
entries.push(["turnstileToken", payload.turnstileToken]);
|
|
398
|
+
if (status === "submitting") {
|
|
399
|
+
return { ok: false, error: "Submission in progress" };
|
|
313
400
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
return sendPayload(
|
|
401
|
+
const { customFields, blockedSensitiveKeys, tooManyCustomFields } = sanitizeCustomFields(payload.customFields);
|
|
402
|
+
const name = payload.name?.trim();
|
|
403
|
+
const phone = payload.phone?.trim();
|
|
404
|
+
const message = payload.message?.trim();
|
|
405
|
+
const turnstileToken = payload.turnstileToken?.trim();
|
|
406
|
+
return sendPayload({
|
|
407
|
+
...name ? { name } : {},
|
|
408
|
+
email: payload.email.trim().toLowerCase(),
|
|
409
|
+
...phone ? { phone } : {},
|
|
410
|
+
...message ? { message } : {},
|
|
411
|
+
honeypot: (payload.honeypot ?? "").trim(),
|
|
412
|
+
...turnstileToken ? { turnstileToken } : {},
|
|
413
|
+
customFields,
|
|
414
|
+
blockedSensitiveKeys,
|
|
415
|
+
tooManyCustomFields
|
|
416
|
+
});
|
|
320
417
|
},
|
|
321
|
-
[sendPayload]
|
|
418
|
+
[status, sendPayload]
|
|
322
419
|
);
|
|
323
420
|
const getFieldProps = useCallback(
|
|
324
421
|
(name) => {
|
|
@@ -441,9 +538,11 @@ function WealthReachHiddenContext({
|
|
|
441
538
|
}
|
|
442
539
|
export {
|
|
443
540
|
FORM_KINDS,
|
|
541
|
+
MAX_CUSTOM_FIELDS,
|
|
444
542
|
WealthReachForm,
|
|
445
543
|
WealthReachHiddenContext,
|
|
446
544
|
isSensitiveFieldKey,
|
|
447
545
|
packFormEntries,
|
|
546
|
+
sanitizeCustomFields,
|
|
448
547
|
useWealthReachForm
|
|
449
548
|
};
|
|
@@ -17,15 +17,18 @@ interface AttributionSnapshot {
|
|
|
17
17
|
referrer_host?: string;
|
|
18
18
|
captured_at?: string;
|
|
19
19
|
}
|
|
20
|
+
interface WebsiteVisitJourneyEntry {
|
|
21
|
+
sessionId: string;
|
|
22
|
+
startedAt: string;
|
|
23
|
+
pages: string[];
|
|
24
|
+
referrer?: string | null;
|
|
25
|
+
activeMs?: number;
|
|
26
|
+
}
|
|
20
27
|
interface WebsiteVisitSnapshot {
|
|
21
28
|
visitorKey: string;
|
|
22
29
|
sessionId: string;
|
|
23
30
|
device: "desktop" | "mobile";
|
|
24
|
-
journey?:
|
|
25
|
-
landingPath?: string;
|
|
26
|
-
referrerHost?: string;
|
|
27
|
-
pagesViewed?: string[];
|
|
28
|
-
};
|
|
31
|
+
journey?: WebsiteVisitJourneyEntry[];
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
declare const FORM_KINDS: readonly ["lead", "newsletter", "resource", "calculator", "consultation", "event"];
|