Open-source document signature platform. Not affiliated with DocuSign.
TypeScript
Merge the updated webhooks branch (main 0.5.2) into the embedded signing branch
Claudec212497fc14a
diff --cc CHANGELOG.mdindex 14c19c7,0b2a77f..49a54a5--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -30,19 -30,236 +30,244 @@@ release says when it doesdelivery log with "Send again", a test button and secret rotation;`GET /api/v1/webhook-deliveries` lets an app catch up. A new daily cronjob, `/api/internal/webhooks`, sends retries that are due.+- Embedded signing: an app can send an envelope with+ `"delivery": "embedded"` and show the signing page in a frame on its own+ site, from a link it asks for at+ `POST /api/v1/envelopes/{id}/signers/{signerId}/embed-link`. No invitations+ are emailed. Only sites an administrator lists under Settings,+ Organization, Embedded signing can frame the page, and the frame tells+ the app with `postMessage` when the signer signs or declines. The+ certificate of completion says the signer was identified by the app.This changes the database: the new `api_keys`, `api_idempotency`,-`webhook_endpoints` and `webhook_deliveries` tables and three new columns-are added by the migrations that run on deploy.+`webhook_endpoints`, `webhook_deliveries` and `embed_allowed_origins`+tables and six new columns are added by the migrations that run on deploy.+ ## [0.5.2] - 2026-11-19++ Twenty-four bug fixes. Seventeen fix reported issues (sixteen from @coygeek,+ one from @seanGSISG), and ten came as pull requests from five outside+ contributors. This release adds one database column: see the end of this+ entry.++ ### Signing++ - Opening an old invitation after the envelope was signed, completed,+ declined or voided says what happened to it, instead of asking the signer+ to request a new link the sender cannot send (#110, PR #178).+ - Reloading the signing page before Finish asks first, instead of throwing+ away the signature and answers without warning (#99, PR #169).+ - A long Text answer no longer widens the signing page past the window+ (#103, PR #177).+ - Closing the signature dialog, including with Escape, returns focus to the+ field instead of the top of the page (#105, PR #181).+ - "Resend code" says when the code was not sent, instead of confirming an+ email during the wait between codes (#113, PR #172).+ - A signer name that is a lone emoji, or uses scripts with combining marks,+ gives whole-character avatar initials instead of a broken one that could+ stop the page from loading (#115, PR #173).++ ### Sending++ - Going Back from Add signers returns to the same draft, instead of a blank+ upload where a second upload made a second draft (#94, PR #166).+ - A field placed just before pressing Back on Place fields is saved+ (#102, PR #165).+ - On a phone, the Field tools sheet stays on screen with Done visible, and+ Escape closes it (#111, PR #180).+ - A long unbroken title in the review and send dialogs wraps, so "Send now"+ stays on screen (#104, PR #168).+ - On wide screens the envelope page's action buttons wrap instead of covering+ a long title (#131, PR #132 by @seanGSISG, carried in PR #170).+ - A new sender on an install without email is told so at sign-up, instead of+ being told to check their inbox (#95, PR #167).+ - Uploading a cut-off or damaged logo is refused, instead of replacing the+ working logo with a broken one (#91, PR #124 by @HimanshuMahto, carried in+ PR #171).++ ### Audit trail and certificates++ - Password resets, role changes and account closure requests record the IP+ address and user agent in the site audit trail (#98, PR #164).+ - The daily job's scheduled account deletion is logged as the system's, not as+ a user action (#109, PR #176).+ - The certificate says a locally captured email was captured, not accepted by+ a mail provider (#106, PR #175).++ ### Administrators and settings++ - The last administrator cannot close their own account (PR #153 by+ @MattJackson).+ - Saving settings can no longer be undone by an older cached copy+ (PR #152 by @MattJackson).+ - A cancelled deletion's email always arrives before the notice of a deletion+ scheduled again (PR #160 by @RayFernando1337).+ - A scheduled deletion whose files could not be removed is reported as a+ failure (PR #162 by @RayFernando1337).+ - Switching between Mine and Everyone's on the dashboard clears the old search+ (PR #161 by @RayFernando1337).++ ### Hosting++ - The functions that draw PDFs ship only the files they need instead of a+ copy of the whole project, and CI checks this after each build (#108,+ PR #119 by @UsamaKhan, carried in PR #174).+ - An empty `STORAGE_LOCAL_DIR` uses the default `.data/storage` folder instead+ of the working directory (PR #151 by @MattJackson).+ - A backup or restore whose copy fails lets go of its download+ (PR #150 by @MattJackson).++ The seven outside PRs #150-#153 and #160-#162 were merged through PR #179.++ Thank you to everyone who helped with this release. @coygeek filed sixteen of+ these reports, each with the cause and a clear way to reproduce it, which is a+ huge gift to the project. @MattJackson sent four careful fixes for the edges of+ backups, storage, settings and account closure. @RayFernando1337 sent three+ fixes for scheduled deletion and the dashboard. @UsamaKhan made the PDF+ functions much smaller, @HimanshuMahto made logo uploads safe against damaged+ files, and @seanGSISG both reported the covered title and sent the fix.++ This release changes the database (`20261119090000_spent_signing_links.sql`,+ one new column on signers that lets an old link say what happened). On Vercel+ the production build applies it. On other hosts, run `npm run db:migrate` as on+ every deploy.++ ## [0.5.1] - 2026-11-19++ Six bug fixes, all reported by @coygeek. There are no database changes and no+ new settings.++ ### Fixes++ - A completed envelope whose title has an emoji near the 120th character can+ be downloaded again. Its signed PDF and certificate returned a server error,+ because the file name was cut in the middle of the emoji (#89, PR #142).+ The email sender's name and the seal certificate's names are now cut at+ whole characters too, so an emoji in an organization name cannot break the+ seal or the From line (PR #148).+ - A long answer in a Text, Number or Dropdown field wraps onto as many lines+ as it needs inside its box on the signed PDF, at the largest size that fits,+ instead of running past the box and off the page. While typing, the signer+ sees a "box is full" warning with how many characters fit, and Finish stays+ off until the answer is shortened. Answers accepted before this release are+ still drawn whole (#90, PR #146).+ - With local disk storage, PDFs between 10 and 20 MB upload instead of failing+ with a misleading title error. An upload over the limit gets the usual size+ message (#92, PR #147).+ - The certificate lists audit events in the order they were recorded, so+ events from the same second no longer swap places, for example "completed"+ above the last "signed". Existing certificates still verify (#97, PR #143).+ - The last signer can finish, and a signer can decline, when the install's+ email setup has been removed. The envelope used to stay incomplete with a+ server error (#96, PR #145).+ - Voiding an envelope emails the signers who already signed, telling them the+ document will not be completed. Signers still waiting for their turn were+ never invited and still get nothing. The void dialog says who will be told+ (#93, PR #144).++ Thanks to @coygeek for six clear, careful reports, each with the cause and a+ way to reproduce it, which made every one of these fixes straightforward.++ ## [0.5.0] - 2026-11-18++ Administrators can now see every member's envelopes and delete finished ones+ after a 14-day notice, plus six outside bug fixes and a security update. This+ release changes the database: see the end of this entry.++ ### Administrators++ - An "Everyone's" view on the dashboard lists every member's sent and+ finished envelopes, with the sender on each card. Administrators can open+ them and download their files, and a download of another member's file is+ recorded in the site audit trail. Drafts stay private to their sender.+ - The dashboard is split into pages of 48, and its search box searches the+ whole list on the server, including the sender's name and email in+ "Everyone's".+ - "Delete envelope" on a completed, declined or voided envelope schedules it+ for deletion 14 days later. The sender gets an email naming who asked, and+ any administrator can cancel within the 14 days, in which case the sender+ is told it will not be deleted. Nothing is deleted before the sender has+ been emailed. In Part 11 mode a reason is required. The request, a+ cancellation and the deletion itself are all in the site audit trail, with+ the record's hashes kept after the files are gone.+ - A deleted envelope's files are queued and retried by the daily job until+ they are gone, so a storage hiccup cannot leave orphaned files behind.+ - The retention sweep does not delete an envelope with a deletion scheduled,+ so the retention period cannot cut the 14-day notice short.++ ### Fixes++ - Fields placed on rotated pages (typical of landscape scans), and on pages+ whose crop box differs from the page size, are stamped where they were+ placed in the signed PDF instead of shifted or sideways. This includes+ envelopes uploaded before this release (#69, PR #116).+ - A void or decline that races another void, decline or the last signature+ no longer deletes the winner's certificate (#68).+ - After switching signature tabs, the Draw tab shows the drawing that will+ be applied, instead of an empty canvas (#70).+ - A client that sends an empty User-Agent header can sign, verify, consent+ and decline, instead of getting an error (#71).+ - Exporting the audit trail of an envelope whose title has a dash, curly+ quote or non-Latin characters works, instead of failing with a server+ error (#72).+ - An envelope's timeline lists events in the order they were recorded, so+ "completed" no longer shows before "signed" (#73).++ ### Security++ - node-forge updated to 1.4.3, which fixes four moderate advisories (#80).++ Thanks to @njarrar for the six fixes, and to @jasonhaggart for the node-forge+ update.++ This release changes the database (`20261118100000_pending_file_deletions.sql`,+ `20261118110000_scheduled_envelope_deletions.sql`). On Vercel the production+ build applies them. On other hosts, run `npm run db:migrate` as on every+ deploy.++ ## [0.4.0] - 2026-11-17++ A name field, and fixes for nine reported bugs. This release changes the+ database: see the end of this entry.++ ### Envelopes++ - A name field. Place it where the signer's printed name belongs, and it is+ filled in with the name the sender gave that signer when they sign, the+ way a date field is filled in with the day. It is always required, and the+ signer does not type it. Contributed by @sumnerboy12 (#49, PR #50).++ ### Fixes++ - The certificate's "sent" and reminder rows name the sender, not the first+ signer next to the sender's email address (#52).+ - Sending or reminding when email is not set up says so, instead of failing+ with a generic server error. A manual reminder no longer retires the+ signer's link before finding there is no email to send it with (#53).+ - A password-locked PDF is named as locked on upload, instead of being+ reported as a file that could not be rendered (#54).+ - After a signer declines, the page says the decline was recorded, instead+ of "This link has expired" (#55).+ - Setup refuses a password over 128 characters instead of silently cutting+ it short, which made the next sign-in fail (#56).+ - Sign-in and sign-up say a password is too long, instead of "too short" or+ "something went wrong" (#57).+ - Typed signatures in the script font keep every letter when the text is+ copied or searched, and no longer show gaps inside names where the font+ joins letters (#58, #59).++ ### Documentation++ - The agent deploy guide checks Vercel's rule that the free Hobby plan is+ for non-commercial use before choosing free plans for a company (#47).++ Thanks to @coygeek for the detailed bug reports, and to @sumnerboy12 for the+ name field.++ This release changes the database (`20261118090000_name_field.sql`). On+ Vercel the production build applies it. On other hosts, run+ `npm run db:migrate` as on every deploy.+## [0.3.0] - 2026-11-16Sign-in security and audit features for organizations that need them, anddiff --cc e2e/signing-flow.spec.tsindex 18e8f01,54289af..b6ef6da--- a/e2e/signing-flow.spec.ts+++ b/e2e/signing-flow.spec.ts@@@ -1,15 -1,11 +1,16 @@@import { expect, test, type Page } from "@playwright/test";import pg from "pg";-import { e2eDatabaseUrl, e2eSetupToken } from "../playwright.config";+import {+ e2eDatabaseUrl,+ e2eOutboxDir,+ e2eSetupToken,+} from "../playwright.config";import { extractLink, extractLinks, waitForEmail } from "./support/outbox";import { totpCode } from "./support/totp";+import { startEmbedParent } from "./support/embed-parent";- import { writeSamplePdf } from "./support/sample-pdf";+ import { writeLargePdf, writeSamplePdf } from "./support/sample-pdf";+ import { startSignInWindowAfresh } from "./support/sign-in-limit";import {hasValidSignature,startWebhookReceiver,@@@ -1557,264 -2024,6 +2029,267 @@@ test("an administrator makes an API keawait receiver.close();});+test("an app shows the signing page in its own site, only on a site an administrator allowed, and hears that it was signed", async ({+ baseURL,+ browser,+ page,+ playwright,+}) => {+ const database = new pg.Client({ connectionString: e2eDatabaseUrl });+ let adminEmail = "";++ await database.connect();++ try {+ adminEmail =+ (+ await database.query<{ email: string }>(+ `select email from public."user" where role = 'admin' order by "createdAt" limit 1`,+ )+ ).rows[0]?.email ?? "";++ // Like the API key test, this one signs in just before the two-step++ // test: start the sign-in window afresh.++ await startSignInWindowAfresh(database);+ } finally {+ await database.end();+ }++ expect(adminEmail).not.toBe("");++ const api = await playwright.request.newContext({ baseURL });+ const portal = await startEmbedParent();+ const stranger = await startEmbedParent();+ let key = "";++ await test.step("an administrator makes a key and allows the app's site", async () => {+ await page.goto("/login");+ await page.getByLabel("Email").fill(adminEmail);+ await page.getByLabel("Password").fill(PASSWORD);+ await page.getByRole("button", { name: "Log in" }).click();+ await expect(page).toHaveURL(/\/dashboard$/);+ await page.goto("/settings");+ await page.getByPlaceholder("For example: Billing app").fill("Portal");+ await page.getByRole("button", { name: "Create key" }).click();+ key =+ (await page.getByTestId("new-api-key").locator("code").textContent()) ??+ "";+ expect(key).toMatch(/^sdk_/);+ await page.getByRole("button", { name: "Done" }).click();++ await page+ .getByPlaceholder("https://app.example.com", { exact: true })+ .fill(portal.origin);+ await page.getByRole("button", { name: "Allow site" }).click();+ await expect(+ page+ .getByRole("list", { name: "Sites allowed to embed signing" })+ .getByText(portal.origin),+ ).toBeVisible();+ });++ const auth = () => ({ authorization: `Bearer ${key}` });+ const signerEmail = `embedded-signer+${String(Date.now())}@example.com`;+ let envelopeId = "";+ let signerId = "";++ await test.step("the app sends an envelope for embedded signing, and no email goes out", async () => {+ const pdfPath = await writeSamplePdf(+ test.info().outputPath("embedded-agreement.pdf"),+ );+ const { readFile } = await import("node:fs/promises");+ const created = await api.post("/api/v1/envelopes", {+ headers: auth(),+ multipart: {+ data: JSON.stringify({+ fields: [+ {+ height: 0.05,+ page: 1,+ signer: "client",+ type: "signature",+ width: 0.3,+ x: 0.1,+ y: 0.7,+ },+ ],+ send: { delivery: "embedded", permittedUseConfirmed: true },+ signers: [+ { email: signerEmail, name: "Robin Portal", ref: "client" },+ ],+ title: "Portal service agreement",+ }),+ file: {+ buffer: await readFile(pdfPath),+ mimeType: "application/pdf",+ name: "agreement.pdf",+ },+ },+ });++ expect(created.status()).toBe(201);++ const envelope = (await created.json()) as {+ delivery: string;+ id: string;+ signers: Array<{ id: string; status: string }>;+ status: string;+ };++ expect(envelope).toMatchObject({+ delivery: "embedded",+ signers: [{ status: "notified" }],+ status: "sent",+ });+ envelopeId = envelope.id;+ signerId = envelope.signers[0]!.id;+ });++ let link = "";++ await test.step("a signing link is made only for an allowed site", async () => {+ const path = `/api/v1/envelopes/${envelopeId}/signers/${signerId}/embed-link`;+ const refused = await api.post(path, {+ data: { origin: stranger.origin },+ headers: auth(),+ });++ expect(refused.status()).toBe(403);++ const made = await api.post(path, {+ data: { origin: portal.origin },+ headers: auth(),+ });++ expect(made.status()).toBe(201);++ const body = (await made.json()) as { object: string; url: string };++ expect(body.object).toBe("embed_link");+ link = body.url;+ expect(new URL(link).searchParams.get("origin")).toBe(portal.origin);+ });++ await test.step("another site cannot frame that link", async () => {+ const strangerPage = await page.context().newPage();+ const refusals: string[] = [];++ strangerPage.on("console", (message) => {+ if (/frame-ancestors/.test(message.text())) {+ refusals.push(message.text());+ }+ });+ await strangerPage.goto(stranger.pageFor(link));+ await expect.poll(() => refusals.length).toBeGreaterThan(0);+ await expect(+ strangerPage+ .frameLocator("#signing")+ .getByRole("dialog", { name: "Before you sign" }),+ ).toHaveCount(0);+ await strangerPage.close();+ });++ await test.step("the signer signs inside the app's page, and the app is told", async () => {+ const context = await browser.newContext();+ const portalPage = await context.newPage();++ await portalPage.goto(portal.pageFor(link));++ const frame = portalPage.frameLocator("#signing");+ const consent = frame.getByRole("dialog", { name: "Before you sign" });++ await consent+ .getByRole("checkbox", {+ name: "I agree to use electronic records and signatures",+ })+ .check();+ await consent.getByRole("button", { name: "Agree and continue" }).click();+ await frame.getByRole("button", { exact: true, name: "Signature" }).click();+ await frame+ .getByRole("dialog", { name: "Add your signature" })+ .getByRole("button", { name: "Apply signature" })+ .click();+ await frame.getByRole("button", { name: "Finish" }).click();+ await frame+ .getByRole("dialog", { name: "Finish signing?" })+ .getByRole("button", { name: "Finish signing" })+ .click();++ await expect+ .poll(() =>+ portalPage.evaluate(() =>+ (+ window as unknown as {+ signudocMessages: Array<{ data: { type?: string } }>;+ }+ ).signudocMessages.map((message) => message.data.type),+ ),+ )+ .toContain("signudoc:signed");++ const messages = await portalPage.evaluate(+ () =>+ (+ window as unknown as {+ signudocMessages: Array<{ data: unknown; origin: string }>;+ }+ ).signudocMessages,+ );++ expect(+ messages.find(+ (message) =>+ (message.data as { type?: string }).type === "signudoc:signed",+ ),+ ).toMatchObject({+ data: { envelopeId, signerId, type: "signudoc:signed" },+ origin: new URL(baseURL!).origin,+ });+ // The frame moves on to the embedded done page, still inside the app.+ await expect+ .poll(() =>+ portalPage+ .frames()+ .some((child) => /\/embed\/sign\/[^/]+\/done/.test(child.url())),+ )+ .toBe(true);+ await context.close();+ });++ await test.step("the envelope is completed, and the signer was never emailed an invitation", async () => {+ await expect+ .poll(async () => {+ const response = await api.get(`/api/v1/envelopes/${envelopeId}`, {+ headers: auth(),+ });++ return ((await response.json()) as { status: string }).status;+ })+ .toBe("completed");++ const { readdir, readFile } = await import("node:fs/promises");+ const invitations: string[] = [];++ for (const file of await readdir(e2eOutboxDir)) {+ const message = JSON.parse(+ await readFile(`${e2eOutboxDir}/${file}`, "utf8"),+ ) as { template?: string; to?: string | string[] };++ if (+ message.template === "signing_invitation" &&+ [message.to].flat().includes(signerEmail)+ ) {+ invitations.push(file);+ }+ }++ expect(invitations).toEqual([]);+ });++ await api.dispose();+ await portal.close();+ await stranger.close();+});+test("two-step sign-in: an administrator sets it up and requires it of everyone", async ({browser,page,diff --cc src/components/settings/security-panel.tsxindex ee54f92,98ccd32..aa58b75--- a/src/components/settings/security-panel.tsx+++ b/src/components/settings/security-panel.tsx@@@ -26,8 -26,10 +26,12 @@@ const EVENT_LABELS: Record<SystemAuditEapi_key_created: "API key created",api_key_revoked: "API key revoked",email_domain_changed: "Email domain changed",+ embed_origin_added: "Site allowed to embed signing",+ embed_origin_removed: "Site no longer allowed to embed signing",+ envelope_deleted: "Finished envelope deleted",+ envelope_deletion_cancelled: "Envelope deletion cancelled",+ envelope_deletion_scheduled: "Envelope deletion scheduled",+ envelope_file_downloaded: "Another member's file downloaded",identity_verification_revoked: "Identity confirmation taken back",identity_verified: "Identity confirmed",logo_changed: "Logo changed",diff --cc src/components/signing/signing-live-shell.tsxindex 9c82792,197de9f..e358a50--- a/src/components/signing/signing-live-shell.tsx+++ b/src/components/signing/signing-live-shell.tsx@@@ -52,7 -53,8 +53,9 @@@ importisNumberEntry,NUMBER_ENTRY_MESSAGE,} from "@/lib/field-choices";+ import { getInitials } from "@/lib/initials";+ import { truncateToWholeCharacters } from "@/lib/text-truncate";+import { postToEmbedParent } from "./embed-parent-message";const typedSignatureFont ='"Snell Roundhand", "Brush Script MT", "Segoe Script", cursive';@@@ -678,14 -853,7 +857,15 @@@ export function SigningLiveShell(const fallbackRedirectPath = `${window.location.pathname.replace(/\/$/, "")}/done?title=${encodeURIComponent(record.envelopeTitle)}`;+ if (embedOrigin) {+ postToEmbedParent(embedOrigin, {+ envelopeId: record.envelopeId,+ signerId: record.signer.id,+ type: "signudoc:signed",+ });+ }++ leavingOnPurposeRef.current = true;window.location.assign(payload?.redirectPath ?? fallbackRedirectPath);} catch {setSubmitError(defaultSubmitErrorMessage);@@@ -757,15 -926,10 +938,18 @@@return;}+ if (embedOrigin) {+ postToEmbedParent(embedOrigin, {+ envelopeId: record.envelopeId,+ signerId: record.signer.id,+ type: "signudoc:declined",+ });+ }+- window.location.reload();+ // Not a reload: a decline retires this link, so reloading would land+ // on "This link has expired" instead of saying the decline was+ // recorded (issue #55).+ setHasDeclined(true);} catch {setDeclineError(defaultDeclineErrorMessage);setIsDeclining(false);diff --cc src/components/signing/signing-shell.tsxindex 0a2a8b6,e615f18..c038d24--- a/src/components/signing/signing-shell.tsx+++ b/src/components/signing/signing-shell.tsx@@@ -8,22 -4,17 +4,23 @@@ import typeSigningPayload,SigningVerificationState,} from "@/lib/schemas/signing";+import { EmbedParentMessage } from "./embed-parent-message";import { SignerVerificationScreen } from "./signer-verification-screen";+ import { SigningStateScreen } from "./signing-state-screen";import {SigningLiveShell,type ProviderSignatureProblem,} from "./signing-live-shell";type SigningUnavailableState =- "already-signed" | "declined" | "error" | "expired" | "voided";+ "already-signed" | "completed" | "declined" | "error" | "expired" | "voided";type SigningShellProps = {+ /**+ * Set on an embedded signing page: the site framing it, which is told+ * when the signer signs or declines, or why the page cannot be used.+ */+ embedOrigin?: string | null;initialState?: SigningUnavailableState;record?: SigningPayload;/** Set when the signer came back from a signing provider without signing. */@@@ -83,63 -74,12 +85,25 @@@ export function SigningShell(return <SignerVerificationScreen state={verification} token={token} />;}- const tokenState = tokenStateCopy[initialState ?? "error"];+ const state = initialState ?? "error";+ const tokenState = tokenStateCopy[state];return (- <SigningStateScreen- description={tokenState.description}- title={tokenState.title}- />+ <>+ {embedOrigin ? (+ <EmbedParentMessage+ message={{ state, type: "signudoc:error" }}+ origin={embedOrigin}+ />+ ) : null}- <StandaloneStateScreen++ <SigningStateScreen+ description={+ embedOrigin && state === "expired"+ ? "Ask the app you are using for a new signing link."+ : tokenState.description+ }+ title={tokenState.title}+ />+ </>);}-- function StandaloneStateScreen({- description,- title,- }: {- description: string;- title: string;- }) {- return (- <div className="flex min-h-screen flex-col">- <header>- <div className="page-width flex items-center py-4">- <Brand href="/" />- </div>- </header>- <main className="page-width flex flex-1 items-center justify-center py-10">- <section- className="panel w-full max-w-[640px] px-6 py-12 text-center sm:px-12 sm:py-14"- data-animate="enter"- >- <span- aria-hidden="true"- className="mx-auto inline-flex size-14 items-center justify-center rounded-2xl bg-(--accent-soft) text-(--accent)"- >- <FileTextIcon className="size-6" strokeWidth={2.2} />- </span>- <h1 className="mt-6 text-[clamp(1.625rem,4vw,2.125rem)] font-extrabold leading-tight tracking-[-0.03em] text-(--fg)">- {title}- </h1>- <p className="mx-auto mt-3 max-w-[460px] text-base leading-7 text-(--secondary)">- {description}- </p>- </section>- </main>- <PublicLegalFooter />- </div>- );- }diff --cc src/lib/reminders.tsindex 39eb2b7,ae0e660..cfce243--- a/src/lib/reminders.ts+++ b/src/lib/reminders.ts@@@ -22,9 -22,13 +22,14 @@@ importrecordAuditEvent,recordEmailSent,} from "./services/audit.ts";- import { createEmailService, type EmailService } from "./services/email.ts";+ import {+ createEmailService,+ EMAIL_NOT_CONNECTED_MESSAGE,+ isEmailNotConnectedError,+ type EmailService,+ } from "./services/email.ts";import { buildDeadlineLine } from "./services/signing-invitation-email.ts";+import { isEmbeddedEnvelope } from "./embedding.ts";import { withUserEmailLegalFooter } from "./services/email-legal-footer.ts";import {formatReminderAvailableAt,@@@ -631,15 -623,20 +636,29 @@@ export async function sendManualEnvelopnowUnixTimestamp = Math.floor(Date.now() / 1000),}: SendReminderOptions = {},) {+ // Its signers sign in another app, which reminds them itself. A reminder+ // would also retire the link that app holds.+ if (await isEmbeddedEnvelope(envelopeId, database, userId)) {+ throw new ReminderMutationError(+ "This envelope is signed in another app, so SignuDoc does not email its signers.",+ 409,+ );+ }++ // Before the reminder is saved: saving retires the signer's current link,+ // so with no email to carry the new one the signer would be left with none.+ let service: EmailService;++ try {+ service = emailService ?? createEmailService();+ } catch (error) {+ if (isEmailNotConnectedError(error)) {+ throw new ReminderMutationError(EMAIL_NOT_CONNECTED_MESSAGE, 503);+ }++ throw error;+ }+const persisted = await persistReminder(envelopeId,{ ...input, kind: "manual", userId },diff --cc src/lib/services/system-audit.tsindex 31ed0f4,00a8190..43c2366--- a/src/lib/services/system-audit.ts+++ b/src/lib/services/system-audit.ts@@@ -47,8 -47,10 +47,12 @@@ export const systemAuditEventTypes ="webhook_endpoint_created","webhook_endpoint_changed","webhook_endpoint_deleted",+ "embed_origin_added",+ "embed_origin_removed",+ "envelope_deleted",+ "envelope_file_downloaded",+ "envelope_deletion_scheduled",+ "envelope_deletion_cancelled",] as const;export type SystemAuditEventType = (typeof systemAuditEventTypes)[number];