@c1m-public/dash-site-kit 0.17.1 → 0.19.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 +17 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/models/bootstrap.d.ts +3 -19
- package/dist/models/bootstrap.js +1 -16
- package/dist/next/site-proxy.d.ts +11 -9
- package/dist/next/site-proxy.js +15 -12
- package/dist/sentry.d.ts +28 -0
- package/dist/sentry.js +21 -0
- package/dist/ui/private-page.d.ts +7 -0
- package/dist/ui/private-page.js +9 -0
- package/dist/ui/unavailable-page.d.ts +15 -0
- package/dist/ui/unavailable-page.js +15 -0
- package/dist/ui.d.ts +2 -0
- package/dist/ui.js +2 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -229,9 +229,23 @@ Dash has no launch copy yet.
|
|
|
229
229
|
|
|
230
230
|
## Site modes
|
|
231
231
|
|
|
232
|
-
The Dash's mode
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
The Dash's state and mode arrive in `dash.init`'s `signals`, and
|
|
233
|
+
`createDashSiteProxy` enforces them before anything renders, through the same
|
|
234
|
+
`siteDecision` and `siteResponse` workspace sites use. The site's state comes
|
|
235
|
+
first:
|
|
236
|
+
|
|
237
|
+
- **No site on the plan**: every non-exempt path is served `/unavailable` in
|
|
238
|
+
place with 404 and `noindex`.
|
|
239
|
+
- **Inactive owner** (suspended, archived, pending, disabled): the same page
|
|
240
|
+
with 503.
|
|
241
|
+
- **Private**: every non-exempt path is served `/private` in place with 403.
|
|
242
|
+
|
|
243
|
+
Add an `app/unavailable/page.tsx` that renders `DashUnavailablePage` (with
|
|
244
|
+
`reason` from `siteDecision(signals, "/")`) and an `app/private/page.tsx` that
|
|
245
|
+
renders `DashPrivatePage`. A gate never takes over either path, so each route
|
|
246
|
+
should call `notFound()` when the site is available.
|
|
247
|
+
|
|
248
|
+
Then the gate:
|
|
235
249
|
|
|
236
250
|
- **Waitlist** (page placement): every non-exempt path gets a 307 to
|
|
237
251
|
`/waitlist`. Signups are stored as CRM leads.
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
export type * from "./models/bootstrap.js";
|
|
12
12
|
export type * from "./models/waitlist.js";
|
|
13
13
|
export type * from "./models/landing.js";
|
|
14
|
-
export { GATE_EXEMPT_PATHS,
|
|
14
|
+
export { GATE_EXEMPT_PATHS, PRIVATE_PATH, UNAVAILABLE_PATH } from "./models/bootstrap.js";
|
|
15
15
|
export type * from "./models/attribution.js";
|
|
16
16
|
export type { LegalDocument, LegalSection, LegalSiteFacts } from "./models/legal.js";
|
|
17
17
|
export { cookieNotice, privacyNotice, termsOfUse } from "./models/legal.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { GATE_EXEMPT_PATHS,
|
|
1
|
+
export { GATE_EXEMPT_PATHS, PRIVATE_PATH, UNAVAILABLE_PATH } from "./models/bootstrap.js";
|
|
2
2
|
export { cookieNotice, privacyNotice, termsOfUse } from "./models/legal.js";
|
|
3
3
|
export { FIRST_TOUCH_COOKIE, FIRST_TOUCH_MAX_AGE_SECONDS, decodeFirstTouch, encodeFirstTouch, firstTouchFrom } from "./models/attribution.js";
|
|
4
4
|
export { validateMovingQuoteForm } from "./validation/moving-quotes.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { GATE_EXEMPT_PATHS };
|
|
1
|
+
import type { SiteGate, SiteSignals } from "@c1m-public/channel-client/site";
|
|
2
|
+
export { GATE_EXEMPT_PATHS, PRIVATE_PATH, UNAVAILABLE_PATH } from "@c1m-public/channel-client/site";
|
|
3
3
|
/**
|
|
4
4
|
* Everything the shell needs on every request, from ONE channel read
|
|
5
5
|
* (`dash.init`): who the dash is, how it looks, where it lives, what it
|
|
@@ -34,7 +34,7 @@ export interface DashBootstrap {
|
|
|
34
34
|
title: string;
|
|
35
35
|
description?: string;
|
|
36
36
|
};
|
|
37
|
-
/** The standard site-decision block;
|
|
37
|
+
/** The standard site-decision block; `createDashSiteProxy` enforces it. */
|
|
38
38
|
signals: SiteSignals;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -43,19 +43,3 @@ export interface DashBootstrap {
|
|
|
43
43
|
* `status` (maintenance answers 503 with Retry-After).
|
|
44
44
|
*/
|
|
45
45
|
export type DashGate = SiteGate;
|
|
46
|
-
/** What the proxy does with a request instead of serving it. */
|
|
47
|
-
export type GateAction = {
|
|
48
|
-
type: "redirect";
|
|
49
|
-
path: string;
|
|
50
|
-
} | {
|
|
51
|
-
type: "rewrite";
|
|
52
|
-
path: string;
|
|
53
|
-
status: number;
|
|
54
|
-
retryAfter?: number;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* What a request gets instead of the normal site, or null to serve it: the
|
|
58
|
-
* shared `siteDecision` reduced to what a proxy enforces. Exempt paths
|
|
59
|
-
* (`GATE_EXEMPT_PATHS` plus `exempt`) are always served.
|
|
60
|
-
*/
|
|
61
|
-
export declare function gateAction(bootstrap: Pick<DashBootstrap, "signals">, pathname: string, exempt?: readonly string[]): GateAction | null;
|
package/dist/models/bootstrap.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { GATE_EXEMPT_PATHS };
|
|
3
|
-
/**
|
|
4
|
-
* What a request gets instead of the normal site, or null to serve it: the
|
|
5
|
-
* shared `siteDecision` reduced to what a proxy enforces. Exempt paths
|
|
6
|
-
* (`GATE_EXEMPT_PATHS` plus `exempt`) are always served.
|
|
7
|
-
*/
|
|
8
|
-
export function gateAction(bootstrap, pathname, exempt = []) {
|
|
9
|
-
const decision = siteDecision(bootstrap.signals, pathname, { exempt });
|
|
10
|
-
if (decision.type === "redirect")
|
|
11
|
-
return { type: "redirect", path: decision.path };
|
|
12
|
-
if (decision.type === "rewrite") {
|
|
13
|
-
return { type: "rewrite", path: decision.path, status: decision.status, ...(decision.retryAfter ? { retryAfter: decision.retryAfter } : {}) };
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
1
|
+
export { GATE_EXEMPT_PATHS, PRIVATE_PATH, UNAVAILABLE_PATH } from "@c1m-public/channel-client/site";
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { NextResponse, type NextRequest } from "next/server";
|
|
2
|
-
import {
|
|
2
|
+
import type { DashBootstrap } from "../models/bootstrap.js";
|
|
3
3
|
export interface DashSiteProxyOptions {
|
|
4
4
|
/** The site's cached bootstrap read (`data.loadDashBootstrap`). */
|
|
5
5
|
loadBootstrap: () => Promise<Pick<DashBootstrap, "signals">>;
|
|
6
|
-
/** Extra paths
|
|
6
|
+
/** Extra paths no gate or site state ever takes over. */
|
|
7
7
|
exempt?: readonly string[];
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* The site's proxy in one line.
|
|
11
|
-
* renders
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* The site's proxy in one line. The site's state acts before anything
|
|
11
|
+
* renders: no site on the plan serves `/unavailable` with 404, an inactive
|
|
12
|
+
* owner the same page with 503, a private site `/private` with 403; then a
|
|
13
|
+
* live page gate answers a real 307 to the waitlist, or serves the
|
|
14
|
+
* maintenance page in place with 503 and Retry-After. Every rewrite carries
|
|
15
|
+
* `noindex`. Every other request passes through with first-touch attribution
|
|
16
|
+
* recorded. The bootstrap read is the same cached `dash.init` the layout
|
|
17
|
+
* uses, so the gate costs no extra API call. If the bootstrap cannot be read
|
|
18
|
+
* the request passes through: the site's own error handling decides.
|
|
17
19
|
*/
|
|
18
20
|
export declare function createDashSiteProxy({ loadBootstrap, exempt }: DashSiteProxyOptions): (request: NextRequest) => Promise<NextResponse>;
|
package/dist/next/site-proxy.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NextResponse } from "next/server";
|
|
2
|
-
import {
|
|
2
|
+
import { siteDecision, siteResponse } from "@c1m-public/channel-client/site";
|
|
3
3
|
import { recordFirstTouch } from "./first-touch.js";
|
|
4
4
|
function respond(request, action) {
|
|
5
|
-
if (
|
|
5
|
+
if (action.type === "serve")
|
|
6
6
|
return NextResponse.next();
|
|
7
7
|
const target = new URL(action.path, request.nextUrl);
|
|
8
8
|
if (action.type === "redirect")
|
|
@@ -13,22 +13,25 @@ function respond(request, action) {
|
|
|
13
13
|
return NextResponse.rewrite(target, { status: action.status, headers });
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* The site's proxy in one line.
|
|
17
|
-
* renders
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
16
|
+
* The site's proxy in one line. The site's state acts before anything
|
|
17
|
+
* renders: no site on the plan serves `/unavailable` with 404, an inactive
|
|
18
|
+
* owner the same page with 503, a private site `/private` with 403; then a
|
|
19
|
+
* live page gate answers a real 307 to the waitlist, or serves the
|
|
20
|
+
* maintenance page in place with 503 and Retry-After. Every rewrite carries
|
|
21
|
+
* `noindex`. Every other request passes through with first-touch attribution
|
|
22
|
+
* recorded. The bootstrap read is the same cached `dash.init` the layout
|
|
23
|
+
* uses, so the gate costs no extra API call. If the bootstrap cannot be read
|
|
24
|
+
* the request passes through: the site's own error handling decides.
|
|
23
25
|
*/
|
|
24
26
|
export function createDashSiteProxy({ loadBootstrap, exempt = [] }) {
|
|
25
27
|
return async function proxy(request) {
|
|
26
|
-
let action =
|
|
28
|
+
let action = { type: "serve" };
|
|
27
29
|
try {
|
|
28
|
-
|
|
30
|
+
const { signals } = await loadBootstrap();
|
|
31
|
+
action = siteResponse(siteDecision(signals, request.nextUrl.pathname, { exempt }));
|
|
29
32
|
}
|
|
30
33
|
catch {
|
|
31
|
-
|
|
34
|
+
// Fail open; see above.
|
|
32
35
|
}
|
|
33
36
|
return recordFirstTouch(request, respond(request, action));
|
|
34
37
|
};
|
package/dist/sentry.d.ts
CHANGED
|
@@ -5,7 +5,35 @@ export interface ChannelSiteSentryConfiguration {
|
|
|
5
5
|
release?: string;
|
|
6
6
|
site: string;
|
|
7
7
|
}
|
|
8
|
+
export interface ChannelSiteSentryDataCollection {
|
|
9
|
+
cookies: false;
|
|
10
|
+
databaseQueryData: false;
|
|
11
|
+
genAI: {
|
|
12
|
+
inputs: false;
|
|
13
|
+
outputs: false;
|
|
14
|
+
};
|
|
15
|
+
graphQL: {
|
|
16
|
+
document: false;
|
|
17
|
+
variables: false;
|
|
18
|
+
};
|
|
19
|
+
httpBodies: [];
|
|
20
|
+
httpHeaders: {
|
|
21
|
+
request: {
|
|
22
|
+
allow: string[];
|
|
23
|
+
};
|
|
24
|
+
response: false;
|
|
25
|
+
};
|
|
26
|
+
mcp: {
|
|
27
|
+
inputs: false;
|
|
28
|
+
outputs: false;
|
|
29
|
+
};
|
|
30
|
+
queues: false;
|
|
31
|
+
stackFrameVariables: false;
|
|
32
|
+
urlQueryParams: false;
|
|
33
|
+
userInfo: false;
|
|
34
|
+
}
|
|
8
35
|
export interface ChannelSiteSentryOptions {
|
|
36
|
+
dataCollection: ChannelSiteSentryDataCollection;
|
|
9
37
|
dsn: string;
|
|
10
38
|
enableLogs: false;
|
|
11
39
|
environment?: string;
|
package/dist/sentry.js
CHANGED
|
@@ -6,6 +6,26 @@ export class ChannelSiteSentryConfigurationError extends Error {
|
|
|
6
6
|
this.code = code;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Sentry 11 ignores `sendDefaultPii`, and any category left out here defaults
|
|
11
|
+
* to collected, so list them all. Sites take visitors' contact details and put
|
|
12
|
+
* access tokens in URLs; none of that belongs in an error report.
|
|
13
|
+
*/
|
|
14
|
+
function channelSiteDataCollection() {
|
|
15
|
+
return {
|
|
16
|
+
cookies: false,
|
|
17
|
+
databaseQueryData: false,
|
|
18
|
+
genAI: { inputs: false, outputs: false },
|
|
19
|
+
graphQL: { document: false, variables: false },
|
|
20
|
+
httpBodies: [],
|
|
21
|
+
httpHeaders: { request: { allow: ["user-agent"] }, response: false },
|
|
22
|
+
mcp: { inputs: false, outputs: false },
|
|
23
|
+
queues: false,
|
|
24
|
+
stackFrameVariables: false,
|
|
25
|
+
urlQueryParams: false,
|
|
26
|
+
userInfo: false,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
9
29
|
function validateDsn(value) {
|
|
10
30
|
let dsn;
|
|
11
31
|
try {
|
|
@@ -35,6 +55,7 @@ export function resolveChannelSiteSentryOptions(configuration) {
|
|
|
35
55
|
const environment = configuration.environment?.trim();
|
|
36
56
|
const release = configuration.release?.trim();
|
|
37
57
|
return {
|
|
58
|
+
dataCollection: channelSiteDataCollection(),
|
|
38
59
|
dsn: validateDsn(dsn),
|
|
39
60
|
enableLogs: false,
|
|
40
61
|
...(environment ? { environment } : {}),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Container, Eyebrow } from "./primitives.js";
|
|
3
|
+
/**
|
|
4
|
+
* The page for a private site. The proxy serves it in place with 403; its
|
|
5
|
+
* route should 404 when the site is public. Server component.
|
|
6
|
+
*/
|
|
7
|
+
export function DashPrivatePage({ siteName }) {
|
|
8
|
+
return (_jsx("main", { className: "flex min-h-screen items-center py-16", children: _jsxs(Container, { className: "max-w-md space-y-6", children: [_jsx(Eyebrow, { children: siteName }), _jsx("h1", { className: "text-3xl font-semibold tracking-tight text-ink", children: "This site is private" })] }) }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const HEADLINES: {
|
|
2
|
+
readonly "no-site": "This site isn't available";
|
|
3
|
+
readonly inactive: "This site is temporarily unavailable";
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* The page for a site that cannot serve. The proxy serves it in place with
|
|
7
|
+
* 404 when the plan has no site (`reason: "no-site"`) and 503 when the owner
|
|
8
|
+
* is inactive (`reason: "inactive"`). Its route should 404 otherwise.
|
|
9
|
+
* Server component.
|
|
10
|
+
*/
|
|
11
|
+
export declare function DashUnavailablePage({ siteName, reason }: {
|
|
12
|
+
siteName: string;
|
|
13
|
+
reason: keyof typeof HEADLINES;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Container, Eyebrow } from "./primitives.js";
|
|
3
|
+
const HEADLINES = {
|
|
4
|
+
"no-site": "This site isn't available",
|
|
5
|
+
inactive: "This site is temporarily unavailable",
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The page for a site that cannot serve. The proxy serves it in place with
|
|
9
|
+
* 404 when the plan has no site (`reason: "no-site"`) and 503 when the owner
|
|
10
|
+
* is inactive (`reason: "inactive"`). Its route should 404 otherwise.
|
|
11
|
+
* Server component.
|
|
12
|
+
*/
|
|
13
|
+
export function DashUnavailablePage({ siteName, reason }) {
|
|
14
|
+
return (_jsx("main", { className: "flex min-h-screen items-center py-16", children: _jsxs(Container, { className: "max-w-md space-y-6", children: [_jsx(Eyebrow, { children: siteName }), _jsx("h1", { className: "text-3xl font-semibold tracking-tight text-ink", children: HEADLINES[reason] }), reason === "inactive" ? _jsx("p", { className: "text-base leading-7 text-muted", children: "Please check back later." }) : null] }) }));
|
|
15
|
+
}
|
package/dist/ui.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export { DashHoneypotField, HONEYPOT_FIELD_NAME, readHoneypot } from "./ui/honey
|
|
|
13
13
|
export { DashWaitlistForm } from "./ui/waitlist-form.js";
|
|
14
14
|
export { DashWaitlistEmailLink, DashWaitlistPage } from "./ui/waitlist-page.js";
|
|
15
15
|
export { DashMaintenancePage } from "./ui/maintenance-page.js";
|
|
16
|
+
export { DashUnavailablePage } from "./ui/unavailable-page.js";
|
|
17
|
+
export { DashPrivatePage } from "./ui/private-page.js";
|
|
16
18
|
export { DashLandingPage, DashWaitlistLanding } from "./ui/landing-page.js";
|
|
17
19
|
export { SiteErrorFallback } from "./ui/error-fallback.js";
|
|
18
20
|
export { DashLegalPage } from "./ui/legal-page.js";
|
package/dist/ui.js
CHANGED
|
@@ -13,6 +13,8 @@ export { DashHoneypotField, HONEYPOT_FIELD_NAME, readHoneypot } from "./ui/honey
|
|
|
13
13
|
export { DashWaitlistForm } from "./ui/waitlist-form.js";
|
|
14
14
|
export { DashWaitlistEmailLink, DashWaitlistPage } from "./ui/waitlist-page.js";
|
|
15
15
|
export { DashMaintenancePage } from "./ui/maintenance-page.js";
|
|
16
|
+
export { DashUnavailablePage } from "./ui/unavailable-page.js";
|
|
17
|
+
export { DashPrivatePage } from "./ui/private-page.js";
|
|
16
18
|
export { DashLandingPage, DashWaitlistLanding } from "./ui/landing-page.js";
|
|
17
19
|
export { SiteErrorFallback } from "./ui/error-fallback.js";
|
|
18
20
|
export { DashLegalPage } from "./ui/legal-page.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c1m-public/dash-site-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Shared transport, domain and UI layer for MML dash-scoped public sites",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"server-only": "0.0.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@c1m-public/channel-client": ">=0.
|
|
46
|
+
"@c1m-public/channel-client": ">=0.39.0 <1",
|
|
47
47
|
"@c1m-public/platform-auth": ">=0.22.0 <1",
|
|
48
48
|
"next": "^16",
|
|
49
49
|
"react": "^19"
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"react-dom": "19.2.8",
|
|
58
58
|
"typescript": "5.9.3",
|
|
59
59
|
"vitest": "^4.1.4",
|
|
60
|
-
"@c1m-public/
|
|
61
|
-
"@c1m-public/
|
|
60
|
+
"@c1m-public/platform-auth": "0.26.0",
|
|
61
|
+
"@c1m-public/channel-client": "0.39.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
64
64
|
"next": {
|