@hogsend/engine 0.30.0 → 0.31.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/package.json +7 -7
- package/src/cold-connect/page.ts +136 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hogsend/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"svix": "^1.95.1",
|
|
41
41
|
"winston": "^3.19.0",
|
|
42
42
|
"zod": "^4.4.3",
|
|
43
|
-
"@hogsend/core": "^0.
|
|
44
|
-
"@hogsend/db": "^0.
|
|
45
|
-
"@hogsend/
|
|
46
|
-
"@hogsend/plugin-
|
|
47
|
-
"@hogsend/
|
|
43
|
+
"@hogsend/core": "^0.31.0",
|
|
44
|
+
"@hogsend/db": "^0.31.0",
|
|
45
|
+
"@hogsend/plugin-posthog": "^0.31.0",
|
|
46
|
+
"@hogsend/plugin-resend": "^0.31.0",
|
|
47
|
+
"@hogsend/email": "^0.31.0"
|
|
48
48
|
},
|
|
49
49
|
"optionalDependencies": {
|
|
50
|
-
"@hogsend/plugin-postmark": "^0.
|
|
50
|
+
"@hogsend/plugin-postmark": "^0.31.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "^22.15.3",
|
package/src/cold-connect/page.ts
CHANGED
|
@@ -13,17 +13,64 @@ export interface ColdConnectBranding {
|
|
|
13
13
|
successCopy: { heading: string; body: string };
|
|
14
14
|
/** Heading + body shown after a failed/expired bind. */
|
|
15
15
|
errorCopy: { heading: string; body: string };
|
|
16
|
-
/** A short emoji/glyph rendered in the badge. */
|
|
16
|
+
/** A short emoji/glyph rendered in the badge (fallback when `iconSvg` is unset). */
|
|
17
17
|
badge: string;
|
|
18
|
+
/**
|
|
19
|
+
* Inline platform-logo SVG rendered in the badge instead of `badge`.
|
|
20
|
+
*
|
|
21
|
+
* SECURITY: unlike every other field here (plain text, written via
|
|
22
|
+
* `textContent`), this is inlined into the page markup verbatim. It MUST be a
|
|
23
|
+
* static, developer-authored `<svg>…</svg>` from connector source — NEVER
|
|
24
|
+
* runtime/user input. Author it with `fill="currentColor"`; the badge tints it
|
|
25
|
+
* white.
|
|
26
|
+
*/
|
|
27
|
+
iconSvg?: string;
|
|
18
28
|
/** Accent color (`#rrggbb`); validated, falls back to a safe blue. */
|
|
19
29
|
accentColor?: string;
|
|
30
|
+
/** Uppercase micro-label above the badge (Studio `.eyebrow`). Defaults to "Hogsend". */
|
|
31
|
+
eyebrow?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Reassurance footnote under the button ("didn't request this? ignore it").
|
|
34
|
+
* Hidden once the bind resolves. Has a safe default if omitted.
|
|
35
|
+
*/
|
|
36
|
+
reassurance?: string;
|
|
20
37
|
}
|
|
21
38
|
|
|
22
39
|
const ACCENT_RE = /^#[0-9a-fA-F]{6}$/;
|
|
23
|
-
|
|
40
|
+
// AA-safe default (white-on-accent ≥ 4.5:1) for the Confirm button label.
|
|
41
|
+
const DEFAULT_ACCENT = "#1f6feb";
|
|
42
|
+
const DEFAULT_EYEBROW = "Hogsend";
|
|
43
|
+
const DEFAULT_REASSURANCE =
|
|
44
|
+
"Didn't request this? You can safely close this tab — nothing is linked until you tap Confirm.";
|
|
45
|
+
|
|
46
|
+
// Faint film-grain matching the Studio surface; pure CSS, no external request.
|
|
47
|
+
const GRAIN =
|
|
48
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E";
|
|
49
|
+
|
|
50
|
+
// Escapes a value for embedding inside an inline <script> as a JS literal.
|
|
51
|
+
// JSON.stringify does NOT escape `<`, so an embedded `</script>` would close the
|
|
52
|
+
// tag early; neutralizing `<`/`>`/`&` closes that breakout on this CSP-less page.
|
|
53
|
+
function jsonForScript(value: unknown): string {
|
|
54
|
+
return JSON.stringify(value)
|
|
55
|
+
.replace(/</g, "\\u003c")
|
|
56
|
+
.replace(/>/g, "\\u003e")
|
|
57
|
+
.replace(/&/g, "\\u0026");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Fail-closed shape check for the one raw-inlined field (`iconSvg`). It is
|
|
61
|
+
// documented as trusted, developer-authored markup; a malformed value falls back
|
|
62
|
+
// to the emoji badge rather than inlining anything unexpected.
|
|
63
|
+
function isSafeIconSvg(svg: string | undefined): svg is string {
|
|
64
|
+
if (!svg) return false;
|
|
65
|
+
const t = svg.trim();
|
|
66
|
+
return t.startsWith("<svg") && !/<script|\son\w+\s*=|javascript:/i.test(t);
|
|
67
|
+
}
|
|
24
68
|
|
|
25
69
|
/**
|
|
26
|
-
* Self-contained
|
|
70
|
+
* Self-contained connect page, styled to the Hogsend Studio "Crimzon" design
|
|
71
|
+
* language (ink background, hairline-bordered surface card, Inter, eyebrow
|
|
72
|
+
* micro-label, faint grain) while keeping each connector's platform accent on
|
|
73
|
+
* the badge tint + Confirm button.
|
|
27
74
|
*
|
|
28
75
|
* Security (from the adversarial review):
|
|
29
76
|
* - `?tok=` is read CLIENT-side and never reflected into the markup.
|
|
@@ -52,16 +99,31 @@ export function coldConnectPageHtml(
|
|
|
52
99
|
? branding.accentColor
|
|
53
100
|
: DEFAULT_ACCENT;
|
|
54
101
|
|
|
55
|
-
|
|
102
|
+
// Trusted, developer-authored static markup (see `iconSvg` security note);
|
|
103
|
+
// fail-closed to the emoji badge if it doesn't look like a bare <svg>.
|
|
104
|
+
const safeIconSvg = isSafeIconSvg(branding.iconSvg)
|
|
105
|
+
? branding.iconSvg
|
|
106
|
+
: undefined;
|
|
107
|
+
if (branding.iconSvg && !safeIconSvg) {
|
|
108
|
+
console.warn(
|
|
109
|
+
"[cold-connect] iconSvg failed the safe-shape check; falling back to the emoji badge",
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
const badgeInner = safeIconSvg ?? "";
|
|
113
|
+
|
|
114
|
+
const config = jsonForScript({
|
|
56
115
|
posthogKey: opts.posthogKey,
|
|
57
116
|
// posthog-js falls back to US when host is null; an EU deploy must set
|
|
58
117
|
// POSTHOG_HOST.
|
|
59
118
|
posthogHost: opts.posthogHost,
|
|
60
119
|
exchangeUrl: opts.exchangeUrl,
|
|
61
120
|
identifyPropKey: opts.identifyPropKey,
|
|
62
|
-
|
|
121
|
+
// SVG takes precedence; emoji only fills in when there's no inline logo.
|
|
122
|
+
badge: safeIconSvg ? null : branding.badge,
|
|
123
|
+
eyebrow: branding.eyebrow || DEFAULT_EYEBROW,
|
|
63
124
|
title: branding.title,
|
|
64
125
|
blurb: branding.blurb,
|
|
126
|
+
reassurance: branding.reassurance || DEFAULT_REASSURANCE,
|
|
65
127
|
successCopy: branding.successCopy,
|
|
66
128
|
errorCopy: branding.errorCopy,
|
|
67
129
|
});
|
|
@@ -74,40 +136,89 @@ export function coldConnectPageHtml(
|
|
|
74
136
|
<meta name="robots" content="noindex" />
|
|
75
137
|
<title>Connect</title>
|
|
76
138
|
<style>
|
|
77
|
-
:root {
|
|
139
|
+
:root {
|
|
140
|
+
color-scheme: dark;
|
|
141
|
+
--ink: #050101;
|
|
142
|
+
--surface: rgba(255, 255, 255, 0.02);
|
|
143
|
+
--hairline: rgba(255, 255, 255, 0.08);
|
|
144
|
+
--text: #ffffff;
|
|
145
|
+
--muted: rgba(255, 255, 255, 0.6);
|
|
146
|
+
/* 0.5 (not Studio's 0.4) so the 12px eyebrow clears WCAG AA. */
|
|
147
|
+
--faint: rgba(255, 255, 255, 0.5);
|
|
148
|
+
--accent: ${accent};
|
|
149
|
+
}
|
|
78
150
|
* { box-sizing: border-box; }
|
|
151
|
+
html, body { height: 100%; }
|
|
79
152
|
body {
|
|
80
153
|
margin: 0; min-height: 100vh; display: flex; align-items: center;
|
|
81
|
-
justify-content: center;
|
|
82
|
-
|
|
83
|
-
|
|
154
|
+
justify-content: center; padding: 24px; position: relative;
|
|
155
|
+
background: var(--ink); color: var(--text);
|
|
156
|
+
font-family: "Inter", ui-sans-serif, system-ui, -apple-system,
|
|
157
|
+
"Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
158
|
+
font-feature-settings: "cv11", "ss01"; letter-spacing: -0.02em;
|
|
159
|
+
-webkit-font-smoothing: antialiased;
|
|
160
|
+
}
|
|
161
|
+
/* Studio film-grain overlay. */
|
|
162
|
+
body::before {
|
|
163
|
+
content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
|
|
164
|
+
opacity: 0.025; background-image: url("${GRAIN}");
|
|
84
165
|
}
|
|
85
166
|
.card {
|
|
86
|
-
max-width:
|
|
87
|
-
|
|
88
|
-
border
|
|
167
|
+
position: relative; z-index: 1; max-width: 400px; width: 100%;
|
|
168
|
+
text-align: center; background: var(--surface);
|
|
169
|
+
border: 1px solid var(--hairline); border-radius: 6px;
|
|
170
|
+
padding: 40px 32px 32px;
|
|
171
|
+
box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
|
|
172
|
+
}
|
|
173
|
+
.eyebrow {
|
|
174
|
+
margin: 0 0 24px; font-size: 12px; line-height: 1; font-weight: 500;
|
|
175
|
+
letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint);
|
|
89
176
|
}
|
|
90
177
|
.badge {
|
|
91
178
|
width: 56px; height: 56px; margin: 0 auto 20px; border-radius: 9999px;
|
|
92
179
|
display: flex; align-items: center; justify-content: center;
|
|
93
|
-
background: ${accent}
|
|
180
|
+
font-size: 26px; color: #fff; background: ${accent}24;
|
|
181
|
+
border: 1px solid ${accent}40;
|
|
182
|
+
}
|
|
183
|
+
.badge svg { width: 28px; height: 28px; display: block; }
|
|
184
|
+
h1 {
|
|
185
|
+
font-family: "Inter Display", "InterDisplay", "Inter", ui-sans-serif,
|
|
186
|
+
system-ui, sans-serif;
|
|
187
|
+
font-size: 22px; line-height: 1.2; margin: 0 0 10px; font-weight: 600;
|
|
188
|
+
letter-spacing: -0.02em;
|
|
189
|
+
}
|
|
190
|
+
.blurb {
|
|
191
|
+
margin: 0 0 24px; font-size: 14px; line-height: 1.6; color: var(--muted);
|
|
94
192
|
}
|
|
95
|
-
h1 { font-size: 20px; margin: 0 0 8px; font-weight: 600; }
|
|
96
|
-
p { margin: 0 0 24px; color: rgba(250,250,250,0.7); line-height: 1.6; }
|
|
97
193
|
button {
|
|
98
194
|
appearance: none; border: 0; border-radius: 10px; cursor: pointer;
|
|
99
|
-
background:
|
|
195
|
+
background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
|
|
100
196
|
padding: 12px 20px; width: 100%;
|
|
197
|
+
transition: filter 0.2s ease, opacity 0.2s ease;
|
|
101
198
|
}
|
|
199
|
+
button:hover { filter: brightness(1.08); }
|
|
102
200
|
button:disabled { opacity: 0.6; cursor: default; }
|
|
201
|
+
button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
|
|
202
|
+
.note {
|
|
203
|
+
margin: 20px 0 0; padding-top: 20px; border-top: 1px solid var(--hairline);
|
|
204
|
+
font-size: 12px; line-height: 1.6; color: var(--muted);
|
|
205
|
+
}
|
|
206
|
+
@media (prefers-reduced-motion: reduce) {
|
|
207
|
+
*, *::before, *::after {
|
|
208
|
+
transition-duration: 0.001ms !important;
|
|
209
|
+
animation-duration: 0.001ms !important;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
103
212
|
</style>
|
|
104
213
|
</head>
|
|
105
214
|
<body>
|
|
106
215
|
<main class="card">
|
|
107
|
-
<
|
|
216
|
+
<p class="eyebrow" id="eyebrow"></p>
|
|
217
|
+
<div class="badge" id="badge" aria-hidden="true">${badgeInner}</div>
|
|
108
218
|
<h1 id="h"></h1>
|
|
109
|
-
<p id="p"></p>
|
|
219
|
+
<p class="blurb" id="p"></p>
|
|
110
220
|
<button id="btn" type="button">Confirm connection</button>
|
|
221
|
+
<p class="note" id="note"></p>
|
|
111
222
|
</main>
|
|
112
223
|
<script>
|
|
113
224
|
var CFG = ${config};
|
|
@@ -116,10 +227,15 @@ export function coldConnectPageHtml(
|
|
|
116
227
|
var h = document.getElementById("h");
|
|
117
228
|
var p = document.getElementById("p");
|
|
118
229
|
var badge = document.getElementById("badge");
|
|
230
|
+
var eyebrow = document.getElementById("eyebrow");
|
|
231
|
+
var note = document.getElementById("note");
|
|
119
232
|
|
|
120
|
-
badge.textContent = CFG.badge;
|
|
233
|
+
if (CFG.badge) { badge.textContent = CFG.badge; }
|
|
234
|
+
eyebrow.textContent = CFG.eyebrow;
|
|
121
235
|
h.textContent = CFG.title;
|
|
122
236
|
p.textContent = CFG.blurb;
|
|
237
|
+
note.textContent = CFG.reassurance;
|
|
238
|
+
document.title = CFG.title;
|
|
123
239
|
|
|
124
240
|
function loadPosthog(host) {
|
|
125
241
|
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="init capture register register_once register_for_session unregister unregister_for_session getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty createPersonProfile opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing clear_opt_in_out_capturing debug".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
|
|
@@ -132,6 +248,7 @@ export function coldConnectPageHtml(
|
|
|
132
248
|
|
|
133
249
|
function done(ok, key, platformUserId) {
|
|
134
250
|
btn.style.display = "none";
|
|
251
|
+
note.style.display = "none";
|
|
135
252
|
if (ok && CFG.posthogKey) {
|
|
136
253
|
try {
|
|
137
254
|
loadPosthog(CFG.posthogHost || "https://us.i.posthog.com");
|