@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.
Files changed (42) hide show
  1. package/README.md +20 -2
  2. package/dist/a11y/client.d.ts +23 -0
  3. package/dist/a11y/client.js +72 -0
  4. package/dist/a11y/index.d.ts +43 -0
  5. package/dist/a11y/index.js +194 -0
  6. package/dist/a11y/shell-client.d.ts +19 -0
  7. package/dist/a11y/shell-client.js +45 -0
  8. package/dist/analytics/index.d.ts +47 -0
  9. package/dist/analytics/index.js +122 -0
  10. package/dist/attribution-DQaAWtA5.d.ts +41 -0
  11. package/dist/blog/index.d.ts +131 -0
  12. package/dist/blog/index.js +259 -0
  13. package/dist/chunk-4YRCSRZZ.js +32 -0
  14. package/dist/chunk-7GDXQ6UB.js +772 -0
  15. package/dist/chunk-QQP7VG2C.js +231 -0
  16. package/dist/chunk-Y77ARZE4.js +214 -0
  17. package/dist/config/index.d.ts +20 -0
  18. package/dist/config/index.js +445 -0
  19. package/dist/consent/index.d.ts +103 -0
  20. package/dist/consent/index.js +61 -0
  21. package/dist/disclosures/index.d.ts +57 -0
  22. package/dist/disclosures/index.js +361 -0
  23. package/dist/forms/index.d.ts +128 -0
  24. package/dist/forms/index.js +449 -0
  25. package/dist/mdx/index.d.ts +15 -0
  26. package/dist/mdx/index.js +45 -0
  27. package/dist/next/config.cjs +140 -0
  28. package/dist/next/config.d.cts +36 -0
  29. package/dist/next/config.d.ts +36 -0
  30. package/dist/next/config.js +111 -0
  31. package/dist/next/draft-route.d.ts +10 -0
  32. package/dist/next/draft-route.js +49 -0
  33. package/dist/next/leads-route.d.ts +138 -0
  34. package/dist/next/leads-route.js +771 -0
  35. package/dist/next/privacy-mode.d.ts +14 -0
  36. package/dist/next/privacy-mode.js +86 -0
  37. package/dist/next/proxy.d.ts +19 -0
  38. package/dist/next/proxy.js +93 -0
  39. package/dist/regulatory-schema-uDKNJ7q8.d.ts +1301 -0
  40. package/dist/schema-C1ixytx2.d.ts +2911 -0
  41. package/dist/schema-DD0nDOD0.d.ts +1744 -0
  42. package/package.json +85 -3
@@ -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 };
@@ -0,0 +1,111 @@
1
+ // src/next/config.ts
2
+ var SANDBOX_DEV_ORIGINS = [
3
+ "*.vercel.run",
4
+ "*.vercel.app",
5
+ "*.modal.run",
6
+ "*.modal.host",
7
+ "*.w.modal.run",
8
+ "*.w.modal.host"
9
+ ];
10
+ var VERCEL_BLOB_REMOTE_PATTERN = {
11
+ protocol: "https",
12
+ hostname: "*.public.blob.vercel-storage.com"
13
+ };
14
+ function buildSecurityHeaders(options) {
15
+ const includeFrameOptions = options?.includeFrameOptions ?? true;
16
+ const ancestors = [
17
+ "'self'",
18
+ "https://*.wealthreach.ai",
19
+ ...options?.extraFrameAncestors ?? []
20
+ ].join(" ");
21
+ const headers = [
22
+ {
23
+ key: "Strict-Transport-Security",
24
+ value: "max-age=63072000; includeSubDomains; preload"
25
+ },
26
+ { key: "X-Content-Type-Options", value: "nosniff" },
27
+ { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
28
+ {
29
+ key: "Permissions-Policy",
30
+ value: "camera=(), microphone=(), geolocation=(), payment=(), usb=()"
31
+ },
32
+ {
33
+ key: "Content-Security-Policy",
34
+ value: `frame-ancestors ${ancestors}; base-uri 'self'; object-src 'none'`
35
+ }
36
+ ];
37
+ if (includeFrameOptions) {
38
+ headers.splice(2, 0, { key: "X-Frame-Options", value: "SAMEORIGIN" });
39
+ }
40
+ return headers;
41
+ }
42
+ var SECURITY_HEADERS = buildSecurityHeaders({
43
+ includeFrameOptions: true
44
+ });
45
+ function isSandboxOrDev() {
46
+ return process.env.NODE_ENV === "development" || process.env.WR_SANDBOX === "1" || process.env.WR_SANDBOX_PREVIEW === "1";
47
+ }
48
+ function withWealthReach(options = {}) {
49
+ const {
50
+ rootDir,
51
+ blogPostsDir = "data/blog",
52
+ extraFrameAncestors,
53
+ headers: userHeaders,
54
+ images: userImages,
55
+ allowedDevOrigins: userDevOrigins,
56
+ outputFileTracingIncludes: userTracing,
57
+ turbopack: userTurbopack,
58
+ ...rest
59
+ } = options;
60
+ const normalizedPostsDir = blogPostsDir.replace(/^\.?\//, "").replace(/\/$/, "");
61
+ const defaultTracingGlob = `./${normalizedPostsDir}/**/*`;
62
+ const mergedDevOrigins = Array.from(
63
+ /* @__PURE__ */ new Set([...SANDBOX_DEV_ORIGINS, ...userDevOrigins ?? []])
64
+ );
65
+ const existingPatterns = userImages?.remotePatterns ?? [];
66
+ const hasBlobPattern = existingPatterns.some(
67
+ (p) => p.hostname === "*.public.blob.vercel-storage.com" || p.hostname.endsWith(".public.blob.vercel-storage.com")
68
+ );
69
+ const mergedImages = {
70
+ formats: ["image/avif", "image/webp"],
71
+ minimumCacheTTL: 60 * 60 * 24,
72
+ ...userImages,
73
+ remotePatterns: hasBlobPattern ? existingPatterns : [VERCEL_BLOB_REMOTE_PATTERN, ...existingPatterns]
74
+ };
75
+ const mergedTracing = {
76
+ ...userTracing ?? {},
77
+ "/**": Array.from(
78
+ /* @__PURE__ */ new Set([defaultTracingGlob, ...userTracing?.["/**"] ?? []])
79
+ )
80
+ };
81
+ return {
82
+ devIndicators: false,
83
+ poweredByHeader: false,
84
+ productionBrowserSourceMaps: false,
85
+ ...rest,
86
+ allowedDevOrigins: mergedDevOrigins,
87
+ images: mergedImages,
88
+ outputFileTracingIncludes: mergedTracing,
89
+ ...rootDir || userTurbopack ? {
90
+ turbopack: {
91
+ ...rootDir ? { root: rootDir } : {},
92
+ ...userTurbopack
93
+ }
94
+ } : {},
95
+ async headers() {
96
+ const baseHeaders = buildSecurityHeaders({
97
+ includeFrameOptions: !isSandboxOrDev(),
98
+ extraFrameAncestors: isSandboxOrDev() ? ["http://localhost:*", "http://127.0.0.1:*", ...extraFrameAncestors ?? []] : extraFrameAncestors
99
+ });
100
+ const extra = userHeaders ? await userHeaders() : [];
101
+ return [{ source: "/(.*)", headers: baseHeaders }, ...extra];
102
+ }
103
+ };
104
+ }
105
+ export {
106
+ SANDBOX_DEV_ORIGINS,
107
+ SECURITY_HEADERS,
108
+ VERCEL_BLOB_REMOTE_PATTERN,
109
+ buildSecurityHeaders,
110
+ withWealthReach
111
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Contract 3.5 Draft Mode door (`GET /api/draft`).
3
+ * Verifies `WR_DRAFT_SECRET` in constant time, supports `?disable=1` exit,
4
+ * marks `?as=owner` audience cookie (clearing on any other visit so compliance
5
+ * reviews stay pixel-identical to public views), and redirects to a validated
6
+ * site-relative `?path=`.
7
+ */
8
+ declare function createDraftGetHandler(request: Request): Promise<Response>;
9
+
10
+ export { createDraftGetHandler };
@@ -0,0 +1,49 @@
1
+ // src/next/draft-route.ts
2
+ import { timingSafeEqual } from "crypto";
3
+ import { cookies, draftMode } from "next/headers";
4
+ import { redirect } from "next/navigation";
5
+
6
+ // src/blog/draft-view.ts
7
+ var DRAFT_AUDIENCE_COOKIE = "wr_draft_audience";
8
+
9
+ // src/next/draft-route.ts
10
+ function safeRelativePath(raw) {
11
+ if (!raw) return "/";
12
+ if (!raw.startsWith("/") || raw.startsWith("//") || /[\u0000-\u001F\u007F]/.test(raw) || raw.includes("\\") || raw.includes("://")) {
13
+ return "/";
14
+ }
15
+ return raw;
16
+ }
17
+ async function createDraftGetHandler(request) {
18
+ const url = new URL(request.url);
19
+ const path = safeRelativePath(url.searchParams.get("path"));
20
+ const draft = await draftMode();
21
+ if (url.searchParams.get("disable") === "1") {
22
+ draft.disable();
23
+ (await cookies()).delete(DRAFT_AUDIENCE_COOKIE);
24
+ redirect(path);
25
+ }
26
+ const secret = process.env.WR_DRAFT_SECRET;
27
+ const providedSecret = url.searchParams.get("secret");
28
+ const expectedBytes = Buffer.from(secret ?? "", "utf8");
29
+ const providedBytes = Buffer.from(providedSecret ?? "", "utf8");
30
+ if (!secret || !providedSecret || expectedBytes.length !== providedBytes.length || !timingSafeEqual(expectedBytes, providedBytes)) {
31
+ return new Response("Not found", { status: 404 });
32
+ }
33
+ draft.enable();
34
+ const jar = await cookies();
35
+ if (url.searchParams.get("as") === "owner") {
36
+ jar.set(DRAFT_AUDIENCE_COOKIE, "owner", {
37
+ httpOnly: true,
38
+ sameSite: "lax",
39
+ secure: process.env.NODE_ENV === "production",
40
+ path: "/"
41
+ });
42
+ } else {
43
+ jar.delete(DRAFT_AUDIENCE_COOKIE);
44
+ }
45
+ redirect(path);
46
+ }
47
+ export {
48
+ createDraftGetHandler
49
+ };
@@ -0,0 +1,138 @@
1
+ import { SiteConfig } from '../config/index.js';
2
+ import 'zod';
3
+ import '../regulatory-schema-uDKNJ7q8.js';
4
+
5
+ interface AttributionSnapshot {
6
+ gclid?: string;
7
+ gbraid?: string;
8
+ wbraid?: string;
9
+ utm_source?: string;
10
+ utm_medium?: string;
11
+ utm_campaign?: string;
12
+ utm_term?: string;
13
+ utm_content?: string;
14
+ utm_id?: string;
15
+ adgroup?: string;
16
+ landing_path?: string;
17
+ referrer_host?: string;
18
+ captured_at?: string;
19
+ }
20
+ interface WebsiteVisitSnapshot {
21
+ visitorKey: string;
22
+ sessionId: string;
23
+ device: "desktop" | "mobile";
24
+ journey?: {
25
+ landingPath?: string;
26
+ referrerHost?: string;
27
+ pagesViewed?: string[];
28
+ };
29
+ }
30
+
31
+ declare const FORM_KINDS: readonly ["lead", "newsletter", "resource", "calculator", "consultation", "event"];
32
+ type FormKind = (typeof FORM_KINDS)[number];
33
+ interface NormalizedLeadSubmission {
34
+ formId: string;
35
+ formKind: FormKind;
36
+ submissionId: string;
37
+ advisorId?: string;
38
+ name?: string;
39
+ email: string;
40
+ phone?: string;
41
+ message?: string;
42
+ customFields?: Record<string, string | boolean | string[]>;
43
+ sourceUrl: string;
44
+ attribution: AttributionSnapshot;
45
+ websiteVisit?: WebsiteVisitSnapshot;
46
+ honeypot?: string;
47
+ turnstileToken?: string;
48
+ }
49
+
50
+ interface SubmitLeadToWealthReachArgs {
51
+ config: SiteConfig;
52
+ formId: string;
53
+ formKind?: FormKind;
54
+ submissionId?: string;
55
+ advisorId?: string;
56
+ name?: string;
57
+ email: string;
58
+ phone?: string;
59
+ message?: string;
60
+ customFields?: Record<string, string | boolean | string[]>;
61
+ sourceUrl: string;
62
+ attribution?: AttributionSnapshot;
63
+ websiteVisit?: WebsiteVisitSnapshot;
64
+ /** Default true when a server secret (`WR_DRAFT_SECRET` / `WR_SITE_LEADS_SECRET`) is available so WealthReach notifies advisors securely. */
65
+ notifyAdvisor?: boolean;
66
+ /** Optional server-only secret override for signing `x-wr-site-signature` (defaults to `WR_SITE_LEADS_SECRET` or `WR_DRAFT_SECRET`). */
67
+ notifySecret?: string;
68
+ /** Override synthetic check mode (auto-enabled when WR_SANDBOX=1 or WR_SYNTHETIC_LEADS=1). */
69
+ syntheticCheck?: boolean;
70
+ fetchImpl?: typeof fetch;
71
+ }
72
+ declare function computeSiteLeadNotifySignature(input: {
73
+ siteId: string;
74
+ advisorId: string;
75
+ submissionId: string;
76
+ }, secret: string): string;
77
+ type SubmitLeadResult = {
78
+ ok: true;
79
+ leadId: string;
80
+ synthetic?: boolean;
81
+ } | {
82
+ ok: false;
83
+ status: number;
84
+ error: string;
85
+ };
86
+ /**
87
+ * Direct server-side WealthReach lead handoff (`POST /api/attract/site-leads`).
88
+ * Use directly inside React 19 Server Actions (`"use server"`) or custom API
89
+ * routes (e.g. Brandywine Oak's `/api/get-started` fit router) so EVERY form on
90
+ * the site is captured in WealthReach with attribution and consent-gated visits.
91
+ */
92
+ declare function submitLeadToWealthReach(args: SubmitLeadToWealthReachArgs): Promise<SubmitLeadResult>;
93
+ /**
94
+ * Resolves and pins the WealthReach lead endpoint (mapping legacy
95
+ * `/api/attract/leads` URLs to `/api/attract/site-leads`). Rejects non-HTTPS
96
+ * or non-WealthReach hosts in production to prevent SSRF / API-key exfiltration.
97
+ */
98
+ declare function resolveSiteLeadsEndpoint(configuredUrl?: string): string;
99
+ interface ExtractedWealthReachContext {
100
+ formId: string;
101
+ formKind: FormKind;
102
+ submissionId: string;
103
+ sourceUrl: string;
104
+ attribution: AttributionSnapshot;
105
+ websiteVisit?: WebsiteVisitSnapshot;
106
+ }
107
+ /**
108
+ * Extracts client attribution, submissionId, sourceUrl, and consented visit
109
+ * attached by `<WealthReachHiddenContext />` inside a React 19 Server Action.
110
+ */
111
+ declare function extractWealthReachContext(formData: FormData, fallback: {
112
+ formId: string;
113
+ formKind?: FormKind;
114
+ sourceUrl: string;
115
+ }): ExtractedWealthReachContext;
116
+ interface LeadRouteHandlerOptions {
117
+ /** Verify Cloudflare Turnstile when TURNSTILE_SECRET_KEY is configured (default true). */
118
+ verifyTurnstile?: boolean;
119
+ /** Have WealthReach email the advisor when a server secret (`WR_DRAFT_SECRET`) is configured (set false if onAfterCapture sends a custom CC email). */
120
+ notifyAdvisor?: boolean;
121
+ /** Optional server-only secret override for `x-wr-site-signature`. */
122
+ notifySecret?: string;
123
+ /** Optional downstream hook (e.g. Zapier/Slack, custom fit routing, team CC) run AFTER WealthReach confirms capture. */
124
+ onAfterCapture?: (ctx: {
125
+ leadId: string;
126
+ submission: NormalizedLeadSubmission;
127
+ }) => Promise<Record<string, unknown> | void>;
128
+ fetchImpl?: typeof fetch;
129
+ }
130
+ /**
131
+ * Creates a same-origin Next.js App Router `POST /api/leads` handler that
132
+ * validates inputs, checks honeypot/Turnstile/rate-limit, hands off to
133
+ * WealthReach `/api/attract/site-leads`, and runs any custom `onAfterCapture`.
134
+ */
135
+ declare function createLeadRouteHandler(getConfig: () => SiteConfig, options?: LeadRouteHandlerOptions): (request: Request) => Promise<Response>;
136
+
137
+ export { computeSiteLeadNotifySignature, createLeadRouteHandler, extractWealthReachContext, resolveSiteLeadsEndpoint, submitLeadToWealthReach };
138
+ export type { ExtractedWealthReachContext, LeadRouteHandlerOptions, SubmitLeadResult, SubmitLeadToWealthReachArgs };