@wealthreach/site-kit 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -2
- package/dist/a11y/client.d.ts +23 -0
- package/dist/a11y/client.js +72 -0
- package/dist/a11y/index.d.ts +43 -0
- package/dist/a11y/index.js +194 -0
- package/dist/a11y/shell-client.d.ts +19 -0
- package/dist/a11y/shell-client.js +45 -0
- package/dist/analytics/index.d.ts +47 -0
- package/dist/analytics/index.js +122 -0
- package/dist/attribution-DQaAWtA5.d.ts +41 -0
- package/dist/blog/index.d.ts +131 -0
- package/dist/blog/index.js +259 -0
- package/dist/chunk-4YRCSRZZ.js +32 -0
- package/dist/chunk-7GDXQ6UB.js +772 -0
- package/dist/chunk-QQP7VG2C.js +231 -0
- package/dist/chunk-Y77ARZE4.js +214 -0
- package/dist/config/index.d.ts +20 -0
- package/dist/config/index.js +445 -0
- package/dist/consent/index.d.ts +103 -0
- package/dist/consent/index.js +61 -0
- package/dist/disclosures/index.d.ts +57 -0
- package/dist/disclosures/index.js +361 -0
- package/dist/forms/index.d.ts +128 -0
- package/dist/forms/index.js +449 -0
- package/dist/mdx/index.d.ts +15 -0
- package/dist/mdx/index.js +45 -0
- package/dist/next/config.cjs +140 -0
- package/dist/next/config.d.cts +36 -0
- package/dist/next/config.d.ts +36 -0
- package/dist/next/config.js +111 -0
- package/dist/next/draft-route.d.ts +10 -0
- package/dist/next/draft-route.js +49 -0
- package/dist/next/leads-route.d.ts +138 -0
- package/dist/next/leads-route.js +771 -0
- package/dist/next/privacy-mode.d.ts +14 -0
- package/dist/next/privacy-mode.js +86 -0
- package/dist/next/proxy.d.ts +19 -0
- package/dist/next/proxy.js +93 -0
- package/dist/regulatory-schema-uDKNJ7q8.d.ts +1301 -0
- package/dist/schema-C1ixytx2.d.ts +2911 -0
- package/dist/schema-DD0nDOD0.d.ts +1744 -0
- package/package.json +85 -3
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
readAttributionSnapshot,
|
|
4
|
+
readConsentedWebsiteVisit,
|
|
5
|
+
trackFormSubmission
|
|
6
|
+
} from "../chunk-QQP7VG2C.js";
|
|
7
|
+
import {
|
|
8
|
+
useConsent
|
|
9
|
+
} from "../chunk-7GDXQ6UB.js";
|
|
10
|
+
|
|
11
|
+
// src/forms/types.ts
|
|
12
|
+
var FORM_KINDS = [
|
|
13
|
+
"lead",
|
|
14
|
+
"newsletter",
|
|
15
|
+
"resource",
|
|
16
|
+
"calculator",
|
|
17
|
+
"consultation",
|
|
18
|
+
"event"
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
// src/forms/packing.ts
|
|
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
|
+
var HONEYPOT_KEYS = /* @__PURE__ */ new Set([
|
|
24
|
+
"website",
|
|
25
|
+
"company_website",
|
|
26
|
+
"wr_hp",
|
|
27
|
+
"_hp"
|
|
28
|
+
]);
|
|
29
|
+
var INTERNAL_KEYS = /* @__PURE__ */ new Set([
|
|
30
|
+
"cf-turnstile-response",
|
|
31
|
+
"turnstileToken",
|
|
32
|
+
"__wr_context"
|
|
33
|
+
]);
|
|
34
|
+
function normalizeKey(raw) {
|
|
35
|
+
return raw.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 64);
|
|
36
|
+
}
|
|
37
|
+
function isSensitiveFieldKey(key) {
|
|
38
|
+
return SENSITIVE_FIELD_RE.test(key);
|
|
39
|
+
}
|
|
40
|
+
function packFormEntries(entries) {
|
|
41
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
42
|
+
let honeypot = "";
|
|
43
|
+
let turnstileToken;
|
|
44
|
+
const blockedSensitiveKeys = [];
|
|
45
|
+
for (const [rawKey, rawValue] of entries) {
|
|
46
|
+
if (typeof File !== "undefined" && rawValue instanceof File) continue;
|
|
47
|
+
const key = rawKey.trim();
|
|
48
|
+
if (!key) continue;
|
|
49
|
+
if (HONEYPOT_KEYS.has(key.toLowerCase())) {
|
|
50
|
+
const val = String(rawValue ?? "").trim();
|
|
51
|
+
if (val) honeypot = val;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (key === "cf-turnstile-response" || key === "turnstileToken") {
|
|
55
|
+
const val = String(rawValue ?? "").trim();
|
|
56
|
+
if (val) turnstileToken = val;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (INTERNAL_KEYS.has(key)) continue;
|
|
60
|
+
if (isSensitiveFieldKey(key)) {
|
|
61
|
+
blockedSensitiveKeys.push(key);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const list = buckets.get(key) ?? [];
|
|
65
|
+
if (Array.isArray(rawValue)) {
|
|
66
|
+
for (const item of rawValue) {
|
|
67
|
+
const s = String(item).trim();
|
|
68
|
+
if (s) list.push(s);
|
|
69
|
+
}
|
|
70
|
+
} else if (typeof rawValue === "boolean") {
|
|
71
|
+
list.push(rawValue);
|
|
72
|
+
} else {
|
|
73
|
+
const s = String(rawValue ?? "").trim();
|
|
74
|
+
if (s.length > 0) list.push(s);
|
|
75
|
+
}
|
|
76
|
+
buckets.set(key, list);
|
|
77
|
+
}
|
|
78
|
+
let name;
|
|
79
|
+
let firstName;
|
|
80
|
+
let lastName;
|
|
81
|
+
let email = "";
|
|
82
|
+
let phone;
|
|
83
|
+
let message;
|
|
84
|
+
const customFields = {};
|
|
85
|
+
for (const [rawKey, values] of buckets.entries()) {
|
|
86
|
+
if (values.length === 0) continue;
|
|
87
|
+
const normalized = normalizeKey(rawKey);
|
|
88
|
+
const firstString = String(values[0] ?? "").trim();
|
|
89
|
+
if (normalized === "name" || normalized === "full_name" || normalized === "your_name") {
|
|
90
|
+
name = firstString;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (normalized === "first_name" || normalized === "firstname") {
|
|
94
|
+
firstName = firstString;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (normalized === "last_name" || normalized === "lastname") {
|
|
98
|
+
lastName = firstString;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (normalized === "email" || normalized === "email_address" || normalized === "e_mail" || normalized === "e_mail_address") {
|
|
102
|
+
email = firstString.toLowerCase();
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (normalized === "phone" || normalized === "phone_number" || normalized === "telephone" || normalized === "tel") {
|
|
106
|
+
phone = firstString;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (normalized === "message" || normalized === "comments" || normalized === "notes" || normalized === "how_can_we_help") {
|
|
110
|
+
message = firstString;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (!normalized) continue;
|
|
114
|
+
if (values.length === 1) {
|
|
115
|
+
const v = values[0];
|
|
116
|
+
if (typeof v === "boolean") {
|
|
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);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (!name && (firstName || lastName)) {
|
|
128
|
+
name = [firstName, lastName].filter(Boolean).join(" ").trim();
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
...name ? { name } : {},
|
|
132
|
+
email,
|
|
133
|
+
...phone ? { phone } : {},
|
|
134
|
+
...message ? { message } : {},
|
|
135
|
+
honeypot,
|
|
136
|
+
...turnstileToken ? { turnstileToken } : {},
|
|
137
|
+
customFields,
|
|
138
|
+
blockedSensitiveKeys
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/forms/use-form.tsx
|
|
143
|
+
import { useCallback, useId, useMemo, useRef, useState } from "react";
|
|
144
|
+
import { usePathname } from "next/navigation";
|
|
145
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
146
|
+
var FORM_ID_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
147
|
+
var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
148
|
+
function createSubmissionId() {
|
|
149
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
150
|
+
return crypto.randomUUID();
|
|
151
|
+
}
|
|
152
|
+
return `sub-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
153
|
+
}
|
|
154
|
+
function useWealthReachForm(options) {
|
|
155
|
+
const {
|
|
156
|
+
formId,
|
|
157
|
+
formKind = "lead",
|
|
158
|
+
endpoint = "/api/leads",
|
|
159
|
+
advisorId,
|
|
160
|
+
validate,
|
|
161
|
+
onSuccess
|
|
162
|
+
} = options;
|
|
163
|
+
if (!FORM_ID_RE.test(formId)) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`Invalid WealthReach formId "${formId}": must be lowercase kebab-case (^[a-z0-9][a-z0-9-]{0,63}$).`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
const pathname = usePathname();
|
|
169
|
+
const { config, allowed: consentAllowed } = useConsent();
|
|
170
|
+
const baseId = useId();
|
|
171
|
+
const formRef = useRef(null);
|
|
172
|
+
const submissionIdRef = useRef(createSubmissionId());
|
|
173
|
+
const [status, setStatus] = useState("idle");
|
|
174
|
+
const [errors, setErrors] = useState({});
|
|
175
|
+
const [serverError, setServerError] = useState(null);
|
|
176
|
+
const reset = useCallback(() => {
|
|
177
|
+
submissionIdRef.current = createSubmissionId();
|
|
178
|
+
setStatus("idle");
|
|
179
|
+
setErrors({});
|
|
180
|
+
setServerError(null);
|
|
181
|
+
formRef.current?.reset();
|
|
182
|
+
}, []);
|
|
183
|
+
const focusFirstInvalid = useCallback((fieldErrors) => {
|
|
184
|
+
const firstKey = Object.keys(fieldErrors)[0];
|
|
185
|
+
if (!firstKey || !formRef.current) return;
|
|
186
|
+
const target = formRef.current.querySelector(
|
|
187
|
+
`[name="${CSS.escape(firstKey)}"], [id$="-${CSS.escape(firstKey)}"]`
|
|
188
|
+
);
|
|
189
|
+
target?.focus();
|
|
190
|
+
}, []);
|
|
191
|
+
const sendPayload = useCallback(
|
|
192
|
+
async (packed) => {
|
|
193
|
+
const nextErrors = {};
|
|
194
|
+
if (packed.blockedSensitiveKeys.length > 0) {
|
|
195
|
+
setServerError(
|
|
196
|
+
"Please do not enter sensitive account numbers, SSNs, or passwords in this form."
|
|
197
|
+
);
|
|
198
|
+
setStatus("error");
|
|
199
|
+
return { ok: false, error: "Blocked sensitive fields" };
|
|
200
|
+
}
|
|
201
|
+
const allowsEmailOnly = formKind === "newsletter" || formKind === "resource";
|
|
202
|
+
if (!allowsEmailOnly && !packed.name) {
|
|
203
|
+
nextErrors.name = "Please enter your name.";
|
|
204
|
+
}
|
|
205
|
+
if (!packed.email || !EMAIL_RE.test(packed.email)) {
|
|
206
|
+
nextErrors.email = "Please enter a valid email address.";
|
|
207
|
+
}
|
|
208
|
+
if (validate) {
|
|
209
|
+
const flat = {
|
|
210
|
+
...packed.name ? { name: packed.name } : {},
|
|
211
|
+
email: packed.email,
|
|
212
|
+
...packed.phone ? { phone: packed.phone } : {},
|
|
213
|
+
...packed.message ? { message: packed.message } : {},
|
|
214
|
+
...packed.customFields
|
|
215
|
+
};
|
|
216
|
+
Object.assign(nextErrors, validate(flat));
|
|
217
|
+
}
|
|
218
|
+
if (Object.keys(nextErrors).length > 0) {
|
|
219
|
+
setErrors(nextErrors);
|
|
220
|
+
setServerError(null);
|
|
221
|
+
setStatus("error");
|
|
222
|
+
focusFirstInvalid(nextErrors);
|
|
223
|
+
return { ok: false, error: "Validation failed" };
|
|
224
|
+
}
|
|
225
|
+
setErrors({});
|
|
226
|
+
setServerError(null);
|
|
227
|
+
setStatus("submitting");
|
|
228
|
+
const submissionId = submissionIdRef.current;
|
|
229
|
+
const attribution = readAttributionSnapshot();
|
|
230
|
+
const websiteVisit = readConsentedWebsiteVisit(config.siteId, consentAllowed);
|
|
231
|
+
const sourceUrl = typeof window !== "undefined" ? `${window.location.origin}${window.location.pathname}` : `${config.seo.siteUrl || "https://example.invalid"}${pathname ?? "/"}`;
|
|
232
|
+
try {
|
|
233
|
+
const res = await fetch(endpoint, {
|
|
234
|
+
method: "POST",
|
|
235
|
+
headers: { "Content-Type": "application/json" },
|
|
236
|
+
body: JSON.stringify({
|
|
237
|
+
formId,
|
|
238
|
+
formKind,
|
|
239
|
+
submissionId,
|
|
240
|
+
...advisorId ? { advisorId } : {},
|
|
241
|
+
...packed.name ? { name: packed.name } : {},
|
|
242
|
+
email: packed.email,
|
|
243
|
+
...packed.phone ? { phone: packed.phone } : {},
|
|
244
|
+
...packed.message ? { message: packed.message } : {},
|
|
245
|
+
...Object.keys(packed.customFields).length > 0 ? { customFields: packed.customFields } : {},
|
|
246
|
+
sourceUrl,
|
|
247
|
+
attribution,
|
|
248
|
+
...websiteVisit ? { websiteVisit } : {},
|
|
249
|
+
...packed.honeypot ? { honeypot: packed.honeypot } : {},
|
|
250
|
+
...packed.turnstileToken ? { turnstileToken: packed.turnstileToken } : {}
|
|
251
|
+
})
|
|
252
|
+
});
|
|
253
|
+
const data = await res.json().catch(() => ({}));
|
|
254
|
+
if (!res.ok || data.ok === false) {
|
|
255
|
+
const msg = data.error || "We couldn't submit your request right now. Please try again.";
|
|
256
|
+
setServerError(msg);
|
|
257
|
+
setStatus("error");
|
|
258
|
+
return { ok: false, error: msg };
|
|
259
|
+
}
|
|
260
|
+
if (!config.visitors?.enabled && consentAllowed) {
|
|
261
|
+
trackFormSubmission(formId, pathname ?? "/", config);
|
|
262
|
+
}
|
|
263
|
+
const leadId = data.leadId ?? submissionId;
|
|
264
|
+
submissionIdRef.current = createSubmissionId();
|
|
265
|
+
setStatus("success");
|
|
266
|
+
onSuccess?.({
|
|
267
|
+
leadId,
|
|
268
|
+
submissionId,
|
|
269
|
+
consentAllowed,
|
|
270
|
+
data: data.data
|
|
271
|
+
});
|
|
272
|
+
return { ok: true, leadId, data: data.data };
|
|
273
|
+
} catch {
|
|
274
|
+
const msg = "Network error while submitting. Please check your connection and try again.";
|
|
275
|
+
setServerError(msg);
|
|
276
|
+
setStatus("error");
|
|
277
|
+
return { ok: false, error: msg };
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
[
|
|
281
|
+
formId,
|
|
282
|
+
formKind,
|
|
283
|
+
endpoint,
|
|
284
|
+
advisorId,
|
|
285
|
+
validate,
|
|
286
|
+
focusFirstInvalid,
|
|
287
|
+
config,
|
|
288
|
+
consentAllowed,
|
|
289
|
+
pathname,
|
|
290
|
+
onSuccess
|
|
291
|
+
]
|
|
292
|
+
);
|
|
293
|
+
const onSubmit = useCallback(
|
|
294
|
+
async (event) => {
|
|
295
|
+
event.preventDefault();
|
|
296
|
+
if (status === "submitting") return;
|
|
297
|
+
const fd = new FormData(event.currentTarget);
|
|
298
|
+
const packed = packFormEntries(fd.entries());
|
|
299
|
+
await sendPayload(packed);
|
|
300
|
+
},
|
|
301
|
+
[status, sendPayload]
|
|
302
|
+
);
|
|
303
|
+
const submit = useCallback(
|
|
304
|
+
async (payload) => {
|
|
305
|
+
const entries = [
|
|
306
|
+
["email", payload.email]
|
|
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]);
|
|
313
|
+
}
|
|
314
|
+
if (payload.customFields) {
|
|
315
|
+
for (const [k, v] of Object.entries(payload.customFields)) {
|
|
316
|
+
entries.push([k, v]);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return sendPayload(packFormEntries(entries));
|
|
320
|
+
},
|
|
321
|
+
[sendPayload]
|
|
322
|
+
);
|
|
323
|
+
const getFieldProps = useCallback(
|
|
324
|
+
(name) => {
|
|
325
|
+
const id = `${baseId}-${name}`;
|
|
326
|
+
const hasError = Boolean(errors[name]);
|
|
327
|
+
return {
|
|
328
|
+
id,
|
|
329
|
+
name,
|
|
330
|
+
"aria-invalid": hasError,
|
|
331
|
+
...hasError ? { "aria-describedby": `${id}-error` } : {}
|
|
332
|
+
};
|
|
333
|
+
},
|
|
334
|
+
[baseId, errors]
|
|
335
|
+
);
|
|
336
|
+
const getErrorProps = useCallback(
|
|
337
|
+
(name) => {
|
|
338
|
+
if (!errors[name]) return null;
|
|
339
|
+
return {
|
|
340
|
+
id: `${baseId}-${name}-error`,
|
|
341
|
+
role: "alert"
|
|
342
|
+
};
|
|
343
|
+
},
|
|
344
|
+
[baseId, errors]
|
|
345
|
+
);
|
|
346
|
+
const Honeypot = useMemo(
|
|
347
|
+
() => function WealthReachHoneypot() {
|
|
348
|
+
return /* @__PURE__ */ jsxs(
|
|
349
|
+
"div",
|
|
350
|
+
{
|
|
351
|
+
"aria-hidden": "true",
|
|
352
|
+
style: {
|
|
353
|
+
position: "absolute",
|
|
354
|
+
left: "-10000px",
|
|
355
|
+
width: "1px",
|
|
356
|
+
height: "1px",
|
|
357
|
+
overflow: "hidden"
|
|
358
|
+
},
|
|
359
|
+
children: [
|
|
360
|
+
/* @__PURE__ */ jsx("label", { htmlFor: `${baseId}-website`, children: "Leave this field blank" }),
|
|
361
|
+
/* @__PURE__ */ jsx(
|
|
362
|
+
"input",
|
|
363
|
+
{
|
|
364
|
+
id: `${baseId}-website`,
|
|
365
|
+
name: "website",
|
|
366
|
+
type: "text",
|
|
367
|
+
tabIndex: -1,
|
|
368
|
+
autoComplete: "off",
|
|
369
|
+
defaultValue: ""
|
|
370
|
+
}
|
|
371
|
+
)
|
|
372
|
+
]
|
|
373
|
+
}
|
|
374
|
+
);
|
|
375
|
+
},
|
|
376
|
+
[baseId]
|
|
377
|
+
);
|
|
378
|
+
return {
|
|
379
|
+
formRef,
|
|
380
|
+
formProps: {
|
|
381
|
+
ref: formRef,
|
|
382
|
+
noValidate: true,
|
|
383
|
+
onSubmit,
|
|
384
|
+
"data-wr-form": formId,
|
|
385
|
+
"data-wr-form-kind": formKind
|
|
386
|
+
},
|
|
387
|
+
Honeypot,
|
|
388
|
+
getFieldProps,
|
|
389
|
+
getErrorProps,
|
|
390
|
+
submit,
|
|
391
|
+
status,
|
|
392
|
+
errors,
|
|
393
|
+
serverError,
|
|
394
|
+
reset,
|
|
395
|
+
consentAllowed
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// src/forms/form.tsx
|
|
400
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
401
|
+
function WealthReachForm({
|
|
402
|
+
form,
|
|
403
|
+
children,
|
|
404
|
+
...rest
|
|
405
|
+
}) {
|
|
406
|
+
const { Honeypot, formProps } = form;
|
|
407
|
+
return /* @__PURE__ */ jsxs2("form", { ...formProps, ...rest, children: [
|
|
408
|
+
/* @__PURE__ */ jsx2(Honeypot, {}),
|
|
409
|
+
children
|
|
410
|
+
] });
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// src/forms/hidden-context.tsx
|
|
414
|
+
import { useEffect, useState as useState2 } from "react";
|
|
415
|
+
import { usePathname as usePathname2 } from "next/navigation";
|
|
416
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
417
|
+
function WealthReachHiddenContext({
|
|
418
|
+
formId,
|
|
419
|
+
formKind = "lead"
|
|
420
|
+
}) {
|
|
421
|
+
const pathname = usePathname2();
|
|
422
|
+
const { config, allowed } = useConsent();
|
|
423
|
+
const [payload, setPayload] = useState2("");
|
|
424
|
+
useEffect(() => {
|
|
425
|
+
const submissionId = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `sub-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
426
|
+
const attribution = readAttributionSnapshot();
|
|
427
|
+
const websiteVisit = readConsentedWebsiteVisit(config.siteId, allowed);
|
|
428
|
+
const sourceUrl = typeof window !== "undefined" ? `${window.location.origin}${window.location.pathname}` : `${config.seo.siteUrl || "https://example.invalid"}${pathname ?? "/"}`;
|
|
429
|
+
setPayload(
|
|
430
|
+
JSON.stringify({
|
|
431
|
+
formId,
|
|
432
|
+
formKind,
|
|
433
|
+
submissionId,
|
|
434
|
+
sourceUrl,
|
|
435
|
+
attribution,
|
|
436
|
+
...websiteVisit ? { websiteVisit } : {}
|
|
437
|
+
})
|
|
438
|
+
);
|
|
439
|
+
}, [formId, formKind, config, allowed, pathname]);
|
|
440
|
+
return /* @__PURE__ */ jsx3("input", { type: "hidden", name: "__wr_context", value: payload, readOnly: true });
|
|
441
|
+
}
|
|
442
|
+
export {
|
|
443
|
+
FORM_KINDS,
|
|
444
|
+
WealthReachForm,
|
|
445
|
+
WealthReachHiddenContext,
|
|
446
|
+
isSensitiveFieldKey,
|
|
447
|
+
packFormEntries,
|
|
448
|
+
useWealthReachForm
|
|
449
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rejects `javascript:`, `vbscript:`, `data:`, and protocol-relative `//` URLs
|
|
3
|
+
* in MDX-authored links and media.
|
|
4
|
+
*/
|
|
5
|
+
declare function safeUrl(raw: string | null | undefined): string | null;
|
|
6
|
+
interface HastNode {
|
|
7
|
+
type?: string;
|
|
8
|
+
tagName?: string;
|
|
9
|
+
properties?: Record<string, unknown>;
|
|
10
|
+
children?: HastNode[];
|
|
11
|
+
}
|
|
12
|
+
/** Minimal zero-dependency rehype plugin stripping unsafe URLs from rendered MDX ASTs. */
|
|
13
|
+
declare function rehypeSafeUrls(): (tree: HastNode) => void;
|
|
14
|
+
|
|
15
|
+
export { rehypeSafeUrls, safeUrl };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/mdx/safe-url.ts
|
|
2
|
+
var ALLOWED_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]);
|
|
3
|
+
function safeUrl(raw) {
|
|
4
|
+
if (!raw) return null;
|
|
5
|
+
const trimmed = raw.trim();
|
|
6
|
+
if (!trimmed) return null;
|
|
7
|
+
if (trimmed.startsWith("#")) return trimmed;
|
|
8
|
+
if (trimmed.startsWith("/") && !trimmed.startsWith("//") && !trimmed.includes("\\")) {
|
|
9
|
+
return trimmed;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const parsed = new URL(trimmed);
|
|
13
|
+
return ALLOWED_PROTOCOLS.has(parsed.protocol) ? trimmed : null;
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
var URL_PROPS = ["href", "src", "poster"];
|
|
19
|
+
function rehypeSafeUrls() {
|
|
20
|
+
return (tree) => {
|
|
21
|
+
const visit = (node) => {
|
|
22
|
+
if (node.properties) {
|
|
23
|
+
for (const prop of URL_PROPS) {
|
|
24
|
+
const val = node.properties[prop];
|
|
25
|
+
if (typeof val === "string") {
|
|
26
|
+
const cleaned = safeUrl(val);
|
|
27
|
+
if (cleaned === null) {
|
|
28
|
+
delete node.properties[prop];
|
|
29
|
+
} else {
|
|
30
|
+
node.properties[prop] = cleaned;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(node.children)) {
|
|
36
|
+
for (const child of node.children) visit(child);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
visit(tree);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
rehypeSafeUrls,
|
|
44
|
+
safeUrl
|
|
45
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/next/config.ts
|
|
21
|
+
var config_exports = {};
|
|
22
|
+
__export(config_exports, {
|
|
23
|
+
SANDBOX_DEV_ORIGINS: () => SANDBOX_DEV_ORIGINS,
|
|
24
|
+
SECURITY_HEADERS: () => SECURITY_HEADERS,
|
|
25
|
+
VERCEL_BLOB_REMOTE_PATTERN: () => VERCEL_BLOB_REMOTE_PATTERN,
|
|
26
|
+
buildSecurityHeaders: () => buildSecurityHeaders,
|
|
27
|
+
withWealthReach: () => withWealthReach
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(config_exports);
|
|
30
|
+
var SANDBOX_DEV_ORIGINS = [
|
|
31
|
+
"*.vercel.run",
|
|
32
|
+
"*.vercel.app",
|
|
33
|
+
"*.modal.run",
|
|
34
|
+
"*.modal.host",
|
|
35
|
+
"*.w.modal.run",
|
|
36
|
+
"*.w.modal.host"
|
|
37
|
+
];
|
|
38
|
+
var VERCEL_BLOB_REMOTE_PATTERN = {
|
|
39
|
+
protocol: "https",
|
|
40
|
+
hostname: "*.public.blob.vercel-storage.com"
|
|
41
|
+
};
|
|
42
|
+
function buildSecurityHeaders(options) {
|
|
43
|
+
const includeFrameOptions = options?.includeFrameOptions ?? true;
|
|
44
|
+
const ancestors = [
|
|
45
|
+
"'self'",
|
|
46
|
+
"https://*.wealthreach.ai",
|
|
47
|
+
...options?.extraFrameAncestors ?? []
|
|
48
|
+
].join(" ");
|
|
49
|
+
const headers = [
|
|
50
|
+
{
|
|
51
|
+
key: "Strict-Transport-Security",
|
|
52
|
+
value: "max-age=63072000; includeSubDomains; preload"
|
|
53
|
+
},
|
|
54
|
+
{ key: "X-Content-Type-Options", value: "nosniff" },
|
|
55
|
+
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
|
56
|
+
{
|
|
57
|
+
key: "Permissions-Policy",
|
|
58
|
+
value: "camera=(), microphone=(), geolocation=(), payment=(), usb=()"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "Content-Security-Policy",
|
|
62
|
+
value: `frame-ancestors ${ancestors}; base-uri 'self'; object-src 'none'`
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
if (includeFrameOptions) {
|
|
66
|
+
headers.splice(2, 0, { key: "X-Frame-Options", value: "SAMEORIGIN" });
|
|
67
|
+
}
|
|
68
|
+
return headers;
|
|
69
|
+
}
|
|
70
|
+
var SECURITY_HEADERS = buildSecurityHeaders({
|
|
71
|
+
includeFrameOptions: true
|
|
72
|
+
});
|
|
73
|
+
function isSandboxOrDev() {
|
|
74
|
+
return process.env.NODE_ENV === "development" || process.env.WR_SANDBOX === "1" || process.env.WR_SANDBOX_PREVIEW === "1";
|
|
75
|
+
}
|
|
76
|
+
function withWealthReach(options = {}) {
|
|
77
|
+
const {
|
|
78
|
+
rootDir,
|
|
79
|
+
blogPostsDir = "data/blog",
|
|
80
|
+
extraFrameAncestors,
|
|
81
|
+
headers: userHeaders,
|
|
82
|
+
images: userImages,
|
|
83
|
+
allowedDevOrigins: userDevOrigins,
|
|
84
|
+
outputFileTracingIncludes: userTracing,
|
|
85
|
+
turbopack: userTurbopack,
|
|
86
|
+
...rest
|
|
87
|
+
} = options;
|
|
88
|
+
const normalizedPostsDir = blogPostsDir.replace(/^\.?\//, "").replace(/\/$/, "");
|
|
89
|
+
const defaultTracingGlob = `./${normalizedPostsDir}/**/*`;
|
|
90
|
+
const mergedDevOrigins = Array.from(
|
|
91
|
+
/* @__PURE__ */ new Set([...SANDBOX_DEV_ORIGINS, ...userDevOrigins ?? []])
|
|
92
|
+
);
|
|
93
|
+
const existingPatterns = userImages?.remotePatterns ?? [];
|
|
94
|
+
const hasBlobPattern = existingPatterns.some(
|
|
95
|
+
(p) => p.hostname === "*.public.blob.vercel-storage.com" || p.hostname.endsWith(".public.blob.vercel-storage.com")
|
|
96
|
+
);
|
|
97
|
+
const mergedImages = {
|
|
98
|
+
formats: ["image/avif", "image/webp"],
|
|
99
|
+
minimumCacheTTL: 60 * 60 * 24,
|
|
100
|
+
...userImages,
|
|
101
|
+
remotePatterns: hasBlobPattern ? existingPatterns : [VERCEL_BLOB_REMOTE_PATTERN, ...existingPatterns]
|
|
102
|
+
};
|
|
103
|
+
const mergedTracing = {
|
|
104
|
+
...userTracing ?? {},
|
|
105
|
+
"/**": Array.from(
|
|
106
|
+
/* @__PURE__ */ new Set([defaultTracingGlob, ...userTracing?.["/**"] ?? []])
|
|
107
|
+
)
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
devIndicators: false,
|
|
111
|
+
poweredByHeader: false,
|
|
112
|
+
productionBrowserSourceMaps: false,
|
|
113
|
+
...rest,
|
|
114
|
+
allowedDevOrigins: mergedDevOrigins,
|
|
115
|
+
images: mergedImages,
|
|
116
|
+
outputFileTracingIncludes: mergedTracing,
|
|
117
|
+
...rootDir || userTurbopack ? {
|
|
118
|
+
turbopack: {
|
|
119
|
+
...rootDir ? { root: rootDir } : {},
|
|
120
|
+
...userTurbopack
|
|
121
|
+
}
|
|
122
|
+
} : {},
|
|
123
|
+
async headers() {
|
|
124
|
+
const baseHeaders = buildSecurityHeaders({
|
|
125
|
+
includeFrameOptions: !isSandboxOrDev(),
|
|
126
|
+
extraFrameAncestors: isSandboxOrDev() ? ["http://localhost:*", "http://127.0.0.1:*", ...extraFrameAncestors ?? []] : extraFrameAncestors
|
|
127
|
+
});
|
|
128
|
+
const extra = userHeaders ? await userHeaders() : [];
|
|
129
|
+
return [{ source: "/(.*)", headers: baseHeaders }, ...extra];
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
+
0 && (module.exports = {
|
|
135
|
+
SANDBOX_DEV_ORIGINS,
|
|
136
|
+
SECURITY_HEADERS,
|
|
137
|
+
VERCEL_BLOB_REMOTE_PATTERN,
|
|
138
|
+
buildSecurityHeaders,
|
|
139
|
+
withWealthReach
|
|
140
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { NextConfig } from 'next';
|
|
2
|
+
|
|
3
|
+
declare const SANDBOX_DEV_ORIGINS: readonly ["*.vercel.run", "*.vercel.app", "*.modal.run", "*.modal.host", "*.w.modal.run", "*.w.modal.host"];
|
|
4
|
+
declare const VERCEL_BLOB_REMOTE_PATTERN: {
|
|
5
|
+
protocol: "https";
|
|
6
|
+
hostname: string;
|
|
7
|
+
};
|
|
8
|
+
declare function buildSecurityHeaders(options?: {
|
|
9
|
+
includeFrameOptions?: boolean;
|
|
10
|
+
extraFrameAncestors?: string[];
|
|
11
|
+
}): Array<{
|
|
12
|
+
key: string;
|
|
13
|
+
value: string;
|
|
14
|
+
}>;
|
|
15
|
+
declare const SECURITY_HEADERS: {
|
|
16
|
+
key: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}[];
|
|
19
|
+
interface WithWealthReachOptions extends NextConfig {
|
|
20
|
+
/** Pass `__dirname` so Turbopack pins the site root even inside nested workspaces. */
|
|
21
|
+
rootDir?: string;
|
|
22
|
+
/** Blog directory to include in Vercel serverless output file tracing (default `"data/blog"`). */
|
|
23
|
+
blogPostsDir?: string;
|
|
24
|
+
/** Additional CSP frame-ancestors origins beyond `'self'` and `https://*.wealthreach.ai`. */
|
|
25
|
+
extraFrameAncestors?: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Wraps any client Next.js 16 config with WealthReach security headers, Eve
|
|
29
|
+
* Modal/Vercel sandbox preview compatibility, Vercel Blob image optimization,
|
|
30
|
+
* and waiting-post file tracing — while deeply preserving every site-specific
|
|
31
|
+
* redirect, image host, header, or custom Next option.
|
|
32
|
+
*/
|
|
33
|
+
declare function withWealthReach(options?: WithWealthReachOptions): NextConfig;
|
|
34
|
+
|
|
35
|
+
export { SANDBOX_DEV_ORIGINS, SECURITY_HEADERS, VERCEL_BLOB_REMOTE_PATTERN, buildSecurityHeaders, withWealthReach };
|
|
36
|
+
export type { WithWealthReachOptions };
|