@c1m-public/dash-site-kit 0.15.0 → 0.16.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 CHANGED
@@ -267,7 +267,7 @@ before relying on it.
267
267
 
268
268
  ## Peer dependencies
269
269
 
270
- `@c1m-public/channel-client` (>=0.35.0), `next` 16, `react` 19.
270
+ `@c1m-public/channel-client` (>=0.36.0), `next` 16, `react` 19.
271
271
 
272
272
  The moving quote form, validation, server data layer and customer lead portal
273
273
  are shared across Dash sites. A site supplies its own channel client and
@@ -13,6 +13,8 @@ export interface DashBootstrap {
13
13
  branding: {
14
14
  primaryColor?: string;
15
15
  logoUrl?: string;
16
+ /** Wide logo for dark surfaces, when the dash uploaded one. */
17
+ logoDarkUrl?: string;
16
18
  logoSquareUrl?: string;
17
19
  faviconUrl?: string;
18
20
  coverUrl?: string;
@@ -1,4 +1,5 @@
1
1
  import { normalizeSignals } from "@c1m-public/channel-client/site";
2
+ import { absoluteHttpsUrl } from "../url-policy.js";
2
3
  function text(value) {
3
4
  const trimmed = value?.trim();
4
5
  return trimmed || undefined;
@@ -7,7 +8,8 @@ function text(value) {
7
8
  /** One flat shell object from ONE wire read: `dash.init`. */
8
9
  export function normalizeDashBootstrap(init) {
9
10
  const signals = normalizeSignals(init);
10
- const name = text(init.tenant.display_name) ?? init.tenant.id;
11
+ // The backend's resolved brand name wins; older backends omit it.
12
+ const name = text(init.branding?.name) ?? text(init.tenant.display_name) ?? init.tenant.id;
11
13
  const siteUrl = text(signals.site?.url)?.replace(/\/+$/, "") ?? null;
12
14
  return {
13
15
  id: init.tenant.id,
@@ -15,10 +17,11 @@ export function normalizeDashBootstrap(init) {
15
17
  description: text(init.seo?.description) ?? text(init.public_profile.short_description),
16
18
  branding: {
17
19
  primaryColor: text(init.branding?.primary_color),
18
- logoUrl: text(init.branding?.logo_url) ?? text(init.public_profile.logo_url),
19
- logoSquareUrl: text(init.branding?.logo_square_url),
20
- faviconUrl: text(init.branding?.favicon_url),
21
- coverUrl: text(init.branding?.cover_url) ?? text(init.public_profile.header_media_url),
20
+ logoUrl: absoluteHttpsUrl(init.branding?.logo_url) ?? absoluteHttpsUrl(init.public_profile.logo_url),
21
+ logoDarkUrl: absoluteHttpsUrl(init.branding?.logo_dark_url),
22
+ logoSquareUrl: absoluteHttpsUrl(init.branding?.logo_square_url),
23
+ faviconUrl: absoluteHttpsUrl(init.branding?.favicon_url),
24
+ coverUrl: absoluteHttpsUrl(init.branding?.cover_url) ?? absoluteHttpsUrl(init.public_profile.header_media_url),
22
25
  },
23
26
  locale: {
24
27
  region: text(init.locale?.region),
@@ -1,4 +1,5 @@
1
1
  import { formatMoney } from "./format.js";
2
+ import { absoluteHttpsUrl } from "./url-policy.js";
2
3
  export function canonicalUrl(baseUrl, pathname) {
3
4
  if (!baseUrl)
4
5
  return undefined;
@@ -56,17 +57,18 @@ export function createSiteConfig(defaults, options = {}) {
56
57
  return fallback;
57
58
  try {
58
59
  const bootstrap = await options.loadBootstrap();
60
+ // Absolute https only: a relative or legacy value would 404 on the
61
+ // site's own origin, so it falls through to the site's own fallback.
62
+ const brand = bootstrap.branding;
63
+ const iconUrl = absoluteHttpsUrl(brand.faviconUrl) ?? absoluteHttpsUrl(brand.logoSquareUrl);
64
+ const imageUrl = absoluteHttpsUrl(brand.coverUrl) ?? absoluteHttpsUrl(brand.logoUrl);
59
65
  return {
60
66
  name: bootstrap.seo.title || siteName,
61
67
  description: bootstrap.seo.description || siteDescription,
62
68
  baseUrl: bootstrap.site.url ?? resolveSiteBaseUrl(),
63
69
  locale: safeLocale(bootstrap.locale.locale),
64
- ...(bootstrap.branding.faviconUrl ?? bootstrap.branding.logoSquareUrl
65
- ? { iconUrl: (bootstrap.branding.faviconUrl ?? bootstrap.branding.logoSquareUrl) }
66
- : {}),
67
- ...(bootstrap.branding.coverUrl ?? bootstrap.branding.logoUrl
68
- ? { imageUrl: (bootstrap.branding.coverUrl ?? bootstrap.branding.logoUrl) }
69
- : {}),
70
+ ...(iconUrl ? { iconUrl } : {}),
71
+ ...(imageUrl ? { imageUrl } : {}),
70
72
  ...(bootstrap.branding.primaryColor ? { primaryColor: bootstrap.branding.primaryColor } : {}),
71
73
  };
72
74
  }
@@ -1,3 +1,10 @@
1
1
  export declare function safePublicHref(value: unknown): string | undefined;
2
2
  export declare function safeImageSource(value: unknown): string | undefined;
3
3
  export declare function isInternalHref(href: string): boolean;
4
+ /**
5
+ * Brand media (logo, icon, share image) must be an absolute https URL: the
6
+ * backend resolves them to that, and a relative or other value (a legacy
7
+ * `/tenant-media/...` path) would 404 on the site's own origin. Anything else
8
+ * is undefined so the caller uses its own fallback.
9
+ */
10
+ export declare function absoluteHttpsUrl(value: unknown): string | undefined;
@@ -44,3 +44,21 @@ export function safeImageSource(value) {
44
44
  export function isInternalHref(href) {
45
45
  return internal(href);
46
46
  }
47
+ /**
48
+ * Brand media (logo, icon, share image) must be an absolute https URL: the
49
+ * backend resolves them to that, and a relative or other value (a legacy
50
+ * `/tenant-media/...` path) would 404 on the site's own origin. Anything else
51
+ * is undefined so the caller uses its own fallback.
52
+ */
53
+ export function absoluteHttpsUrl(value) {
54
+ const source = candidate(value);
55
+ if (!source)
56
+ return undefined;
57
+ try {
58
+ const url = new URL(source);
59
+ return url.protocol === "https:" && url.hostname ? url.toString() : undefined;
60
+ }
61
+ catch {
62
+ return undefined;
63
+ }
64
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c1m-public/dash-site-kit",
3
- "version": "0.15.0",
3
+ "version": "0.16.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.35.0 <1",
46
+ "@c1m-public/channel-client": ">=0.36.0 <1",
47
47
  "@c1m-public/platform-auth": ">=0.22.0 <1",
48
48
  "next": "^16",
49
49
  "react": "^19"
@@ -57,7 +57,7 @@
57
57
  "react-dom": "19.2.8",
58
58
  "typescript": "5.9.3",
59
59
  "vitest": "^4.1.4",
60
- "@c1m-public/channel-client": "0.35.0",
60
+ "@c1m-public/channel-client": "0.36.0",
61
61
  "@c1m-public/platform-auth": "0.23.0"
62
62
  },
63
63
  "peerDependenciesMeta": {