Skip to content

Open-source document signature platform. Not affiliated with DocuSign.

TypeScript

Give the public pages the install's own name and links

Claude4163162a39ec
diff --git a/e2e/signing-flow.spec.ts b/e2e/signing-flow.spec.ts
index f5d6ed1..1e4785e 100644
--- a/e2e/signing-flow.spec.ts
+++ b/e2e/signing-flow.spec.ts
@@ -142,6 +142,34 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", a
await adminContext.close();
});
+ await test.step("pages a signer can reach carry the organization's name and its own links", async () => {
+ // These sit outside the signed-in app. None of them may fall back to the
+ // hosted service's name, or link to pages only the hosted service has.
+ for (const publicPath of [
+ "/signer-privacy",
+ "/electronic-signatures",
+ "/verify",
+ "/download/not-a-real-link",
+ ]) {
+ await page.goto(publicPath);
+ await expect(
+ page.getByRole("link", { exact: true, name: ORGANIZATION_NAME }),
+ ).toBeVisible();
+
+ const footer = page.getByRole("contentinfo");
+
+ await expect(
+ footer.getByRole("link", { exact: true, name: "Privacy" }),
+ ).toHaveAttribute("href", "/signer-privacy");
+
+ for (const hostedOnly of ["Terms", "Accessibility", "Contact"]) {
+ await expect(
+ footer.getByRole("link", { exact: true, name: hostedOnly }),
+ ).toHaveCount(0);
+ }
+ }
+ });
+
await test.step("an address outside the organization cannot sign up", async () => {
await page.goto("/signup");
await expect(page).toHaveTitle(ORGANIZATION_NAME);
diff --git a/src/components/layout/branding-provider.tsx b/src/components/layout/branding-provider.tsx
index 52b915f..cee8cab 100644
--- a/src/components/layout/branding-provider.tsx
+++ b/src/components/layout/branding-provider.tsx
@@ -5,8 +5,9 @@ import { createContext, useContext, type ReactNode } from "react";
import { HOSTED_BRANDING, type Branding } from "@/lib/branding";
// What this install calls itself, handed down from the server layouts that
-// looked it up. A page outside those layouts (the landing page, the legal
-// pages) only exists in hosted mode, which is also the default here.
+// looked it up, and from PublicDocumentShell for the pages outside them. The
+// one page with neither (the landing page) only exists in hosted mode, which
+// is also the default here.
const BrandingContext = createContext<Branding>(HOSTED_BRANDING);
type BrandingProviderProps = {
diff --git a/src/components/layout/public-document-shell.tsx b/src/components/layout/public-document-shell.tsx
index c07eb4c..7c6b002 100644
--- a/src/components/layout/public-document-shell.tsx
+++ b/src/components/layout/public-document-shell.tsx
@@ -1,8 +1,12 @@
import type { ReactNode } from "react";
+import { connection } from "next/server";
import { Brand } from "@/components/layout/brand";
+import { BrandingProvider } from "@/components/layout/branding-provider";
import { PublicLegalFooter } from "@/components/layout/public-legal-links";
import { PublicSessionMenu } from "@/components/layout/public-session-menu";
+import { buildBranding, type Branding } from "@/lib/branding";
+import { getBranding, resolveSettings } from "@/lib/settings";
type PublicDocumentShellProps = {
children: ReactNode;
@@ -11,7 +15,47 @@ type PublicDocumentShellProps = {
title: string;
};
-export function PublicDocumentShell({
+async function loadBranding(): Promise<Branding> {
+ try {
+ return await getBranding();
+ } catch {
+ // A page of text is not worth failing over a database that cannot be
+ // reached. This is the install before anything was saved: still its own
+ // footer links, and never the hosted service's.
+ return buildBranding(resolveSettings(null));
+ }
+}
+
+// These pages sit outside the layouts that hand branding down, and some of
+// them are on every install: the signer privacy notice, what signatures are
+// for, document verification and the expired download link. So the shell
+// looks up what this install calls itself. Without that, such a page would
+// carry the hosted service's name and link to pages only it has.
+export async function PublicDocumentShell({
+ children,
+ description,
+ lastUpdated,
+ title,
+}: PublicDocumentShellProps) {
+ // Read when the page is requested, so one build serves any install.
+ await connection();
+
+ const branding = await loadBranding();
+
+ return (
+ <BrandingProvider branding={branding}>
+ <PublicDocumentPage
+ description={description}
+ lastUpdated={lastUpdated}
+ title={title}
+ >
+ {children}
+ </PublicDocumentPage>
+ </BrandingProvider>
+ );
+}
+
+function PublicDocumentPage({
children,
description,
lastUpdated,