Open-source document signature platform. Not affiliated with DocuSign.
TypeScript
Cover the new features in the end-to-end test and the README
Claude46f4ce30e7f8
diff --git a/README.md b/README.mdindex cd3a13b..1ea65ce 100644--- a/README.md+++ b/README.md@@ -122,13 +122,17 @@ Some data still leaves the EU: Vercel's and Resend's account metadata and logs,## What it does- Upload PDF documents-- Add up to 10 signers in routing order-- Place signature, initials, date, text, and checkbox fields+- Add up to 10 signers in routing order, and people who only receive a copy of the finished document+- Place signature, initials, date, text, number, checkbox, dropdown, and radio button fields+- Save a document as a template, and send it again by naming who signs this time- Send secure signing links by email- Let recipients sign without creating an account-- Track draft, sent, completed, declined, and voided envelopes-- Generate a final signed PDF and audit certificate-- Send manual reminders to the current signer+- Give each envelope its own signing deadline, and change it while the envelope is out+- Track draft, sent, completed, declined, voided, and expired envelopes+- Generate a final signed PDF and audit certificate, with names and text in Latin, Greek, Cyrillic, Chinese, Japanese, and Korean scripts+- Send a reminder to the current signer yourself, or have one sent every few days+- Put your organization's logo and color on the site, the signing pages, and the emails+- Have more than one administrator- Run on any Postgres database, locally or hosted## Built with@@ -277,6 +281,10 @@ npm run test:e2e6. Each signer completes their turn in order.7. SignuDoc finalizes the signed PDF and audit certificate when the last signer finishes.+People added to receive a copy do not sign. They are sent the finished document and its certificate at step 7 and nothing before it.++A document you send often can be kept as a template: open any envelope, sent or not, and choose Save as template. The template keeps the document, the fields and the signing order, and no one's name or email address. Using it asks who signs this time and opens a draft at step 4.+## Self-hosting somewhere elseSignuDoc is a regular Next.js app and runs anywhere Node.js 24 and Postgres do:@@ -305,7 +313,7 @@ Self-hosted operators are responsible for:## Daily cleanup-Once a day the app deletes drafts nobody has touched for 30 days, finishes account deletions that were requested, and clears expired download links and finished rate limit counters. The work is done by a request to:+Once a day the app deletes drafts nobody has touched for 30 days, finishes account deletions that were requested, and clears expired download links and finished rate limit counters. The same run sends the automatic reminders that are due and tells a sender when an envelope has passed its signing deadline. The work is done by a request to:```text/api/internal/retentiondiff --git a/e2e/signing-flow.spec.ts b/e2e/signing-flow.spec.tsindex 02a8178..4eb6070 100644--- a/e2e/signing-flow.spec.ts+++ b/e2e/signing-flow.spec.ts@@ -11,6 +11,21 @@ const ORGANIZATION_NAME = "Harbour & Finch Legal";// The accent and the em dash are on purpose: download file names are built// from the title, and a header value cannot carry the em dash as it is.const ENVELOPE_TITLE = "Façade works agreement — phase 1";+// Dark enough to carry white text, so it is used exactly as entered.+const BRAND_COLOR = "#0b7a53";+// A one-pixel PNG: the smallest thing that is honestly an image.+const LOGO_PNG = Buffer.from(+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",+ "base64",+);++function readAccentColor(page: Page): Promise<string> {+ return page.evaluate(() =>+ getComputedStyle(document.documentElement)+ .getPropertyValue("--accent")+ .trim(),+ );+}function watchForContentSecurityPolicyViolations(page: Page, sink: string[]) {page.on("console", (message) => {@@ -43,6 +58,8 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", aconst senderEmail = `sender+${runId}@example.com`;const outsiderEmail = `outsider+${runId}@elsewhere.example`;const signerEmail = `signer+${runId}@example.com`;+ const copyEmail = `copy+${runId}@example.com`;+ const secondSignerEmail = `second+${runId}@example.com`;const cspViolations: string[] = [];let envelopeId = "";@@ -123,6 +140,25 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", aexpect(testEmail.subject).toBe(`Test email from ${ORGANIZATION_NAME}`);+ // The organization puts its own logo and color on the site. The logo+ // is saved the moment it is chosen, the color with the form.+ await adminPage.getByLabel("Logo image").setInputFiles({+ buffer: LOGO_PNG,+ mimeType: "image/png",+ name: "logo.png",+ });+ await expect(+ adminPage.getByRole("button", { name: "Replace logo" }),+ ).toBeVisible();+ await adminPage.getByLabel("Brand color").fill(BRAND_COLOR);+ await adminPage+ .getByRole("button", { name: "Save organization settings" })+ .click();+ await expect(+ adminPage.getByText("Organization settings saved."),+ ).toBeVisible();+ await expect.poll(() => readAccentColor(adminPage)).toBe(BRAND_COLOR);+// Setup can only happen once.await adminPage.goto("/setup");await expect(adminPage).not.toHaveURL(/\/setup/);@@ -152,9 +188,19 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", a"/download/not-a-real-link",]) {await page.goto(publicPath);- await expect(- page.getByRole("link", { exact: true, name: ORGANIZATION_NAME }),- ).toBeVisible();++ // The link still carries the name, and now shows the logo.+ const brandLink = page.getByRole("link", {+ exact: true,+ name: ORGANIZATION_NAME,+ });++ await expect(brandLink).toBeVisible();+ await expect(brandLink.locator("img")).toHaveAttribute(+ "src",+ /^\/api\/brand\/logo\?v=[0-9a-f]{16}$/,+ );+ expect(await readAccentColor(page)).toBe(BRAND_COLOR);const footer = page.getByRole("contentinfo");@@ -284,6 +330,10 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", aawait test.step("add a signer", async () => {await page.getByLabel("Signer 1 name").fill("Riley Recipient");await page.getByLabel("Signer 1 email").fill(signerEmail);+ // Someone who gets the finished document without signing it.+ await page.getByRole("button", { name: "+ Add a copy recipient" }).click();+ await page.getByLabel("Copy recipient 1 name").fill("Casey Copy");+ await page.getByLabel("Copy recipient 1 email").fill(copyEmail);await page.getByRole("button", { name: "Next →" }).click();await expect(page).toHaveURL(/\/prepare$/);});@@ -306,6 +356,34 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", a).toBeVisible();await expect(page.getByText("Signature ready")).toBeVisible();await expect(page.getByRole("status")).toHaveText("Saved");++ // One of each field the signer answers by typing a number or choosing.+ const placeField = async (tool: string, x: number, y: number) => {+ await page.getByRole("button", { exact: true, name: tool }).click();+ await page.getByLabel(`Place ${tool} on page 1`).click({+ position: { x: box!.width * x, y: box!.height * y },+ });+ };++ await placeField("Number", 0.25, 0.3);+ await placeField("Dropdown", 0.5, 0.3);++ // Until a dropdown has choices the draft is saved but cannot go on.+ await expect(page.getByRole("button", { name: "Next →" })).toBeDisabled();+ await page+ .getByRole("textbox", { name: "Choices" })+ .fill("Monthly\nYearly");+ await placeField("Radio button", 0.25, 0.4);+ await page+ .getByRole("textbox", { name: "What this button means" })+ .fill("Yes");+ await page+ .getByRole("button", { name: "+ Add a button to this group" })+ .click();+ await page+ .getByRole("textbox", { name: "What this button means" })+ .fill("No");+ await expect(page.getByRole("button", { name: "Next →" })).toBeEnabled();await page.getByRole("button", { name: "Next →" }).click();await expect(page).toHaveURL(/\/review$/);});@@ -314,6 +392,9 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", aawait expect(page.getByRole("heading", { name: ENVELOPE_TITLE }),).toBeVisible();+ // The sender decides how long signers get and how often to nudge them.+ await page.getByLabel("Signing deadline").selectOption("7");+ await page.getByLabel("Automatic reminders").selectOption("2");await page.getByRole("button", { name: "Send envelope" }).click();const confirmation = page.getByRole("dialog", {@@ -322,6 +403,13 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", aawait confirmation.getByRole("checkbox").check();await confirmation.getByRole("button", { name: "Send now" }).click();++ await expect(page).toHaveURL(new RegExp(`/envelopes/${envelopeId}$`));+ await expect(page.getByText(/^Expires .+\.$/)).toBeVisible();+ await expect(+ page.getByText("Automatic reminders: every 2 days."),+ ).toBeVisible();+ await expect(page.getByText("Casey Copy")).toBeVisible();});const invitation = await waitForEmail({@@ -331,6 +419,12 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", aconst signingLink = extractLink(invitation.text, "/sign/");expect(invitation.text).toContain(`through ${ORGANIZATION_NAME}.`);+ // The logo opens the message, fetched from this site.+ expect(invitation.html).toMatch(+ new RegExp(+ `<img src="${baseURL ?? ""}/api/brand/logo\\?v=[0-9a-f]{16}" alt="Harbour & Finch Legal"`,+ ),+ );await test.step("the recipient signs without an account", async () => {const recipientContext = await browser.newContext({@@ -360,7 +454,10 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", aawait expect(recipientPage.getByRole("img", { name: "Rendered PDF page 1" }),).toBeVisible();- await expect(recipientPage.getByText("1 required remaining")).toBeVisible();+ expect(await readAccentColor(recipientPage)).toBe(BRAND_COLOR);+ // The signature, the dropdown and the radio group. The number is+ // optional, and the two radio buttons are one question.+ await expect(recipientPage.getByText("3 required remaining")).toBeVisible();await recipientPage.getByRole("button", { exact: true, name: "Signature" }).click();@@ -368,6 +465,19 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", a.getByRole("dialog", { name: "Add your signature" }).getByRole("button", { name: "Apply signature" }).click();+ await recipientPage.getByLabel("Choose one").selectOption("Yearly");+ await recipientPage.getByRole("radio", { name: "No" }).click();+ await recipientPage.getByRole("radio", { name: "Yes" }).click();+ await expect(+ recipientPage.getByRole("radio", { name: "No" }),+ ).toHaveAttribute("aria-checked", "false");++ // A comma as a decimal mark could be read two ways, so it is not taken.+ await recipientPage.getByLabel("Enter a number").fill("12,5");+ await expect(+ recipientPage.getByRole("button", { name: "Finish" }),+ ).toBeDisabled();+ await recipientPage.getByLabel("Enter a number").fill("1,250.5");await recipientPage.getByRole("button", { name: "Finish" }).click();await recipientPage.getByRole("dialog", { name: "Finish signing?" })@@ -407,6 +517,20 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", aawait recipientContext.close();});+ await test.step("the copy recipient gets the finished document and nothing before it", async () => {+ const copyEmailMessage = await waitForEmail({+ template: "completion_notification",+ to: copyEmail,+ });++ expect(copyEmailMessage.attachments?.length).toBe(2);+ expect(+ extractLinks(copyEmailMessage.text).some((link) =>+ new URL(link).pathname.startsWith("/sign/"),+ ),+ ).toBe(false);+ });+await test.step("the sender sees it completed and can download", async () => {await waitForEmail({template: "completion_notification",@@ -463,6 +587,49 @@ test("a new install is set up, a sender sends a PDF and a recipient signs it", aawait anonymousContext.close();});+ await test.step("the document is saved as a template and used for the next one", async () => {+ await page.goto(`/envelopes/${envelopeId}`);+ await page.getByRole("button", { name: "Save as template" }).click();++ const saveDialog = page.getByRole("dialog", { name: "Save as a template" });++ await saveDialog.getByLabel("Template name").fill("Works agreement");+ await saveDialog+ .getByRole("textbox", { name: /^Signer 1/ })+ .fill("Contractor");+ await saveDialog.getByRole("button", { name: "Save template" }).click();+ await expect(page.getByText("Saved as the template")).toBeVisible();++ await page.getByRole("link", { name: "View templates" }).click();+ await expect(page).toHaveURL(/\/templates$/);+ await expect(+ page.getByRole("heading", { name: "Works agreement" }),+ ).toBeVisible();+ // The template names a role, not the person who signed the original.+ await expect(page.getByText("1. Contractor")).toBeVisible();+ await expect(page.getByText("Riley Recipient")).toHaveCount(0);++ await page.getByRole("link", { name: "Use template" }).click();+ await expect(page).toHaveURL(/\/templates\/[^/]+\/use$/);+ await page.getByLabel("Envelope title").fill("Works agreement, phase 2");+ await page.getByLabel("Contractor name").fill("Sasha Second");+ await page.getByLabel("Contractor email").fill(secondSignerEmail);+ await page.getByRole("button", { name: "Create draft" }).click();++ // A new draft with the same fields, on the person named this time,+ // one click from being sent.+ await expect(page).toHaveURL(/\/envelopes\/[^/]+\/review$/);+ expect(page.url()).not.toContain(envelopeId);+ await expect(+ page.getByRole("heading", { name: "Works agreement, phase 2" }),+ ).toBeVisible();+ await expect(page.getByText("Sasha Second")).toBeVisible();+ await expect(page.getByText("(4 fields)")).toBeVisible();+ await expect(+ page.getByRole("button", { name: "Send envelope" }),+ ).toBeEnabled();+ });+// An install from before there were administrators has accounts but// nobody in charge. One of its users takes charge with the setup token.await test.step("an install with no administrator is claimed with the setup token", async () => {diff --git a/e2e/support/outbox.ts b/e2e/support/outbox.tsindex 07f3ae8..5f4901c 100644--- a/e2e/support/outbox.ts+++ b/e2e/support/outbox.ts@@ -5,6 +5,7 @@ import { e2eOutboxDir } from "../../playwright.config";export type CapturedEmail = {attachments?: { filename: string; sha256: string }[];+ html?: string;subject: string;template: string;text: string;