Skip to content

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

TypeScript

Add a name field, filled in with the signer's name when they sign

Ben Jones23add9893ac0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8ea04e9..e339a92 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,17 @@ release says when it does.
## [Unreleased]
+### 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.
+
+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-16
Sign-in security and audit features for organizations that need them, and
diff --git a/README.md b/README.md
index 03bbcae..fd3433f 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,7 @@
### Prepare a document in minutes
-Upload a PDF, add up to 10 signers in the order they sign, and add people who only receive the finished copy. Then place fields where they belong: signature, initials, date, text, number, checkbox, dropdown and radio buttons, each required or optional and each tied to one signer.
+Upload a PDF, add up to 10 signers in the order they sign, and add people who only receive the finished copy. Then place fields where they belong: signature, initials, date, name, text, number, checkbox, dropdown and radio buttons, each required or optional and each tied to one signer.
![Placing signature, date and dropdown fields for two signers on a master services agreement](docs/images/prepare.png)
@@ -124,7 +124,7 @@ DocuSign does more, and charges for it per user. SignuDoc does the everyday sign
| **Signing without an account** | ✅ | ✅ |
| **Signing order** | ✅ in order, up to 10 signers | ✅ in order, at the same time, or mixed |
| **People who only get a copy** | ✅ | ✅ and more roles: approvers, editors, in-person signers |
-| **Field types** | ✅ signature, initials, date, text, number, checkbox, dropdown, radio, each required or optional | ✅ more types; dropdown, radio and signer attachments need Business Pro |
+| **Field types** | ✅ signature, initials, date, name, text, number, checkbox, dropdown, radio, each required or optional | ✅ more types; dropdown, radio and signer attachments need Business Pro |
| **Templates** | ✅ | ✅ from Personal, shared from Standard |
| **Deadlines and automatic reminders** | ✅ | ✅ |
| **Access code and emailed one-time code** | ✅ | ✅ plus SMS, phone, knowledge-based questions and ID checks, as paid add-ons |
diff --git a/db/migrations/20261118090000_name_field.sql b/db/migrations/20261118090000_name_field.sql
new file mode 100644
index 0000000..47cddc1
--- /dev/null
+++ b/db/migrations/20261118090000_name_field.sql
@@ -0,0 +1,20 @@
+-- A name field: filled in with the signer's name when they sign, the way a
+-- date field is filled in with the day. The signer does not type it.
+
+alter table public.fields
+ drop constraint if exists fields_type_check;
+
+alter table public.fields
+ add constraint fields_type_check check (
+ type in (
+ 'signature',
+ 'initials',
+ 'date',
+ 'name',
+ 'text',
+ 'checkbox',
+ 'number',
+ 'dropdown',
+ 'radio'
+ )
+ );
diff --git a/src/components/envelopes/prepare-live-shell.tsx b/src/components/envelopes/prepare-live-shell.tsx
index cc77640..bb06df4 100644
--- a/src/components/envelopes/prepare-live-shell.tsx
+++ b/src/components/envelopes/prepare-live-shell.tsx
@@ -9,6 +9,7 @@ import {
SquareCheckIcon,
SquareChevronDownIcon,
TypeIcon,
+ UserRoundIcon,
type LucideIcon,
} from "lucide-react";
import {
@@ -171,6 +172,15 @@ const fieldTools: readonly FieldTool[] = [
placeholderLabel: "Date",
type: "date",
},
+ {
+ defaultHeight: 0.045,
+ defaultWidth: 0.2,
+ label: "Name",
+ minHeight: 0.0045,
+ minWidth: 0.006,
+ placeholderLabel: "Name",
+ type: "name",
+ },
{
defaultHeight: 0.055,
defaultWidth: 0.18,
@@ -218,8 +228,8 @@ const fieldTools: readonly FieldTool[] = [
},
] as const;
-// Fields the sender may leave optional. A signature, initials and the date
-// are always needed.
+// Fields the sender may leave optional. A signature, initials, the date and
+// the name are always needed.
function canBeOptional(type: PrepareFieldType) {
return (
type === "text" ||
@@ -1179,6 +1189,7 @@ const fieldToolIcons: Record<PrepareFieldType, LucideIcon> = {
date: CalendarIcon,
dropdown: SquareChevronDownIcon,
initials: CaseSensitiveIcon,
+ name: UserRoundIcon,
number: HashIcon,
radio: CircleDotIcon,
signature: SignatureIcon,
diff --git a/src/components/envelopes/review-shell.tsx b/src/components/envelopes/review-shell.tsx
index 90bc0cf..ace0de3 100644
--- a/src/components/envelopes/review-shell.tsx
+++ b/src/components/envelopes/review-shell.tsx
@@ -52,6 +52,7 @@ type ReviewFieldSummaryLabel =
| "Checkbox"
| "Date"
| "Initials"
+ | "Name"
| "Signature"
| "Text";
diff --git a/src/components/signing/signing-live-shell.tsx b/src/components/signing/signing-live-shell.tsx
index fd488a4..80f36c9 100644
--- a/src/components/signing/signing-live-shell.tsx
+++ b/src/components/signing/signing-live-shell.tsx
@@ -135,6 +135,8 @@ function getCanvasFieldLabel(
return "Initial";
case "date":
return "Date";
+ case "name":
+ return "Name";
case "text":
return "Text";
case "checkbox":
@@ -174,6 +176,8 @@ function getFieldLabel(
return "Initial here";
case "date":
return "Date";
+ case "name":
+ return "Name";
case "text":
return "Enter text";
case "checkbox":
@@ -229,6 +233,8 @@ function getSummaryLabel(field: SigningCurrentField) {
return "Initials";
case "date":
return "Date";
+ case "name":
+ return "Name";
case "text":
return "Text input";
case "checkbox":
@@ -271,13 +277,18 @@ function getCompletionValue(
checkboxValues,
localDateLabel,
signatureValues,
+ signerName,
textValues,
- }: EnteredValues & { localDateLabel: string },
+ }: EnteredValues & { localDateLabel: string; signerName: string },
) {
if (field.type === "signature" || field.type === "initials") {
return signatureValues[field.id]?.value ?? "Tap to sign";
}
+ if (field.type === "name") {
+ return signerName;
+ }
+
if (field.type === "text") {
return textValues[field.id]?.trim() || "Enter text";
}
@@ -951,6 +962,7 @@ export function SigningLiveShell({
key={field.id}
localDateLabel={localDateLabel}
isInvalid={hasInvalidNumber(field, textValues)}
+ signerName={record.signer.name}
onCheckboxChange={(checked) => {
setSubmitError(null);
setCheckboxValues((current) => {
@@ -1098,7 +1110,11 @@ export function SigningLiveShell({
value={getCompletionValue(
field,
record.currentSignerFields,
- { ...enteredValues, localDateLabel },
+ {
+ ...enteredValues,
+ localDateLabel,
+ signerName: record.signer.name,
+ },
)}
/>
))}
@@ -1439,6 +1455,7 @@ function CurrentSignerField({
onSignatureClick,
onTextChange,
signatureEntry,
+ signerName,
textValue,
}: {
checkboxValue: boolean;
@@ -1450,6 +1467,8 @@ function CurrentSignerField({
onSignatureClick: () => void;
onTextChange: (value: string) => void;
signatureEntry?: SignatureEntry;
+ /** What a name field shows: the name the sender gave this signer. */
+ signerName: string;
textValue: string;
}) {
const frame = getFieldFrame(field);
@@ -1508,7 +1527,8 @@ function CurrentSignerField({
);
}
- if (field.type === "date") {
+ // Filled in for the signer: the day they sign, or their name.
+ if (field.type === "date" || field.type === "name") {
return (
<div
className="absolute z-2 overflow-hidden rounded-[0.375rem] border border-(--border-strong) bg-white/92 text-sm text-(--fg)"
@@ -1517,7 +1537,7 @@ function CurrentSignerField({
>
{showInlineValue ? (
<p className="flex h-full items-center truncate px-2 text-[12px] font-semibold">
- {localDateLabel}
+ {field.type === "date" ? localDateLabel : signerName}
</p>
) : null}
</div>
diff --git a/src/lib/envelopes.ts b/src/lib/envelopes.ts
index 0281fc0..f673044 100644
--- a/src/lib/envelopes.ts
+++ b/src/lib/envelopes.ts
@@ -313,6 +313,7 @@ type ReviewFieldSummary =
| "Date"
| "Dropdown"
| "Initials"
+ | "Name"
| "Number"
| "Radio group"
| "Signature"
@@ -482,6 +483,7 @@ const FIELD_TYPE_SUMMARY_LABELS: Record<
date: "Date",
dropdown: "Dropdown",
initials: "Initials",
+ name: "Name",
number: "Number",
radio: "Radio group",
signature: "Signature",
@@ -489,14 +491,15 @@ const FIELD_TYPE_SUMMARY_LABELS: Record<
};
const FIELD_TYPE_SORT_ORDER: Record<FieldRecord["type"], number> = {
- checkbox: 6,
+ checkbox: 7,
date: 2,
- dropdown: 5,
+ dropdown: 6,
initials: 1,
- number: 4,
- radio: 7,
+ name: 3,
+ number: 5,
+ radio: 8,
signature: 0,
- text: 3,
+ text: 4,
};
const TIMELINE_TONE_MAP: Record<
diff --git a/src/lib/name-field.dbtest.ts b/src/lib/name-field.dbtest.ts
new file mode 100644
index 0000000..9f11197
--- /dev/null
+++ b/src/lib/name-field.dbtest.ts
@@ -0,0 +1,161 @@
+import assert from "node:assert/strict";
+import { randomUUID } from "node:crypto";
+import { after, before, test } from "node:test";
+
+import type pg from "pg";
+
+import { openTestDatabase } from "./db/test-database.ts";
+import { ELECTRONIC_RECORDS_DISCLOSURE_VERSION } from "./electronic-records-disclosure.ts";
+import type { EmailService } from "./services/email.ts";
+import { issueSigningLink } from "./services/signing-links.ts";
+import type { StorageService } from "./services/storage.ts";
+import { recordSignerConsent, submitSigningForToken } from "./signing.ts";
+
+// A name field against a real Postgres: it is filled in with the signer's
+// name when they sign, without the signer sending anything for it.
+// Run with `npm run test:db`.
+
+process.env.APP_URL ??= "https://sign.example.test";
+
+let database: pg.Pool;
+const createdUsers: string[] = [];
+
+before(async () => {
+ database = await openTestDatabase();
+ // The next signer's invitation reads the install's name through the shared pool.
+ globalThis.__signudocPgPool = database;
+});
+
+after(async () => {
+ await database.query(`delete from public."user" where id = any($1)`, [
+ createdUsers,
+ ]);
+ await database.end();
+});
+
+function unixNow() {
+ return Math.floor(Date.now() / 1000);
+}
+
+const refuse = async (): Promise<never> => {
+ throw new Error("not used");
+};
+
+// A typed signature from the first of two signers stores no file and does
+// not finish the envelope, so nothing here touches storage.
+const storageService: StorageService = {
+ deleteObject: refuse,
+ getObject: refuse,
+ getObjectStream: refuse,
+ headObject: refuse,
+ putObject: refuse,
+};
+
+const emailService: EmailService = {
+ async send(message) {
+ return { accepted: [message.to], messageId: "m-1", rejected: [] };
+ },
+ async sendBatch() {
+ throw new Error("not used");
+ },
+};
+
+test("a name field is filled in with the signer's name when they sign", async () => {
+ const userId = randomUUID();
+ const envelopeId = randomUUID();
+ const rileyId = randomUUID();
+ const caseyId = randomUUID();
+ const signatureId = randomUUID();
+ const nameId = randomUUID();
+ const now = unixNow();
+ const link = await issueSigningLink({ expiresInSeconds: 60, issuedAt: now });
+
+ createdUsers.push(userId);
+ await database.query(
+ `insert into public."user" (id, name, email, role) values ($1, 'Sam Sender', $2, 'user')`,
+ [userId, `${userId}@example.test`],
+ );
+ await database.query(
+ `
+ insert into envelopes (
+ id, user_id, title, status, source_pdf_key, source_pdf_filename,
+ source_pdf_size_bytes, page_count, source_pdf_hash, sent_at
+ ) values ($1, $2, 'Lease', 'sent', $3, 'lease.pdf', 10, 1, $4, $5)
+ `,
+ [envelopeId, userId, `test/${envelopeId}.pdf`, "a".repeat(64), now],
+ );
+ await database.query(
+ `
+ insert into signers (
+ id, envelope_id, name, email, sign_order, status,
+ signing_token_hash, signing_token_expires_at, last_notified_at
+ ) values ($1, $2, 'Riley Recipient', $3, 1, 'notified', $4, $5, $6)
+ `,
+ [
+ rileyId,
+ envelopeId,
+ `${rileyId}@example.test`,
+ link.tokenHash,
+ link.exp,
+ now,
+ ],
+ );
+ await database.query(
+ `
+ insert into signers (id, envelope_id, name, email, sign_order, status)
+ values ($1, $2, 'Casey Second', $3, 2, 'pending')
+ `,
+ [caseyId, envelopeId, `${caseyId}@example.test`],
+ );
+ await database.query(
+ `
+ insert into fields (
+ id, envelope_id, signer_id, type, page, x, y, width, height
+ ) values
+ ($1, $3, $4, 'signature', 1, 0.1, 0.1, 0.2, 0.1),
+ ($2, $3, $4, 'name', 1, 0.1, 0.3, 0.2, 0.05)
+ `,
+ [signatureId, nameId, envelopeId, rileyId],
+ );
+ await recordSignerConsent(
+ link.token,
+ { disclosureVersion: ELECTRONIC_RECORDS_DISCLOSURE_VERSION },
+ { database },
+ );
+
+ // Only the signature is sent: the name is not the signer's to give.
+ await submitSigningForToken(
+ link.token,
+ {
+ clientTimezoneOffsetMinutes: 0,
+ fields: [
+ {
+ fieldId: signatureId,
+ inputMethod: "typed",
+ type: "signature",
+ value: "Riley Recipient",
+ },
+ ],
+ },
+ { database, emailService, storageService },
+ );
+
+ const stored = await database.query<{
+ input_method: string | null;
+ submitted_at: number | null;
+ value: string | null;
+ }>(`select input_method, submitted_at, value from fields where id = $1`, [
+ nameId,
+ ]);
+
+ assert.equal(stored.rows[0]?.value, "Riley Recipient");
+ assert.equal(stored.rows[0]?.input_method, "auto");
+ assert.ok(stored.rows[0]?.submitted_at);
+
+ const riley = await database.query<{ status: string }>(
+ `select status from signers where id = $1`,
+ [rileyId],
+ );
+
+ assert.equal(riley.rows[0]?.status, "signed");
+});
diff --git a/src/lib/schemas/field.test.ts b/src/lib/schemas/field.test.ts
new file mode 100644
index 0000000..eee980c
--- /dev/null
+++ b/src/lib/schemas/field.test.ts
@@ -0,0 +1,40 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { fieldPlacementSchema } from "./field.ts";
+
+const placement = {
+ height: 0.05,
+ page: 1,
+ signerId: "signer-1",
+ width: 0.2,
+ x: 0.1,
+ y: 0.1,
+};
+
+test("fields that fill themselves in or are the signature are always required", () => {
+ for (const type of ["signature", "initials", "date", "name"] as const) {
+ assert.equal(
+ fieldPlacementSchema.safeParse({ ...placement, required: false, type })
+ .success,
+ false,
+ `an optional ${type} field was accepted`,
+ );
+ assert.equal(
+ fieldPlacementSchema.safeParse({ ...placement, type }).success,
+ true,
+ `a ${type} field was refused`,
+ );
+ }
+});
+
+test("a text field may be optional", () => {
+ assert.equal(
+ fieldPlacementSchema.safeParse({
+ ...placement,
+ required: false,
+ type: "text",
+ }).success,
+ true,
+ );
+});
diff --git a/src/lib/schemas/field.ts b/src/lib/schemas/field.ts
index fe2abed..6a43cab 100644
--- a/src/lib/schemas/field.ts
+++ b/src/lib/schemas/field.ts
@@ -95,7 +95,8 @@ export const fieldPlacementSchema = z
if (
(field.type === "signature" ||
field.type === "initials" ||
- field.type === "date") &&
+ field.type === "date" ||
+ field.type === "name") &&
!field.required
) {
ctx.addIssue({
diff --git a/src/lib/services/pdf-finalize.test.ts b/src/lib/services/pdf-finalize.test.ts
index 74fcf2d..1aefd98 100644
--- a/src/lib/services/pdf-finalize.test.ts
+++ b/src/lib/services/pdf-finalize.test.ts
@@ -525,3 +525,41 @@ test("numbers and dropdown choices are stamped as text, radio buttons as rings",
assert.ok(pdfBytes.byteLength > chosenOnly.byteLength);
assert.ok(chosenOnly.byteLength > withoutRadios.byteLength);
});
+
+test("a name field is stamped with the name it was filled in with", async () => {
+ const fixture = await makeFixture();
+ // Not the name on the fixture's signatures, so only the name field can
+ // put it on the page.
+ const printedName = "Zofia Nowak-Wiśniewska";
+ const nameField: FieldRecord = {
+ createdAt: 1_800_000_000,
+ envelopeId: fixture.envelope.id,
+ height: 0.03,
+ id: "name-1",
+ inputMethod: "auto",
+ page: 1,
+ required: true,
+ signerId: "signer-1",
+ submittedAt: 1_800_000_000,
+ type: "name",
+ updatedAt: 1_800_000_000,
+ value: printedName,
+ width: 0.3,
+ x: 0.1,
+ y: 0.5,
+ };
+ const pdfBytes = await renderFinalizedEnvelopePdf(
+ {
+ auditEvents: fixture.auditEvents,
+ completedAt: fixture.envelope.completedAt!,
+ envelope: fixture.envelope,
+ fields: [...fixture.fields, nameField],
+ signers: fixture.signers,
+ sourcePdfKey: fixture.envelope.sourcePdfKey,
+ },
+ { seal: saveUnsealed, storageService: fixture.storageService },
+ );
+ const text = (await extractText(pdfBytes)).replace(/\s+/g, " ");
+
+ assert.ok(text.includes(printedName));
+});
diff --git a/src/lib/services/pdf-finalize.ts b/src/lib/services/pdf-finalize.ts
index 3617d40..2601ed3 100644
--- a/src/lib/services/pdf-finalize.ts
+++ b/src/lib/services/pdf-finalize.ts
@@ -459,6 +459,7 @@ export async function stampFieldValue(
return;
}
case "date":
+ case "name":
case "text":
case "number":
case "dropdown": {
diff --git a/src/lib/signing.ts b/src/lib/signing.ts
index 5a28d43..3295f08 100644
--- a/src/lib/signing.ts
+++ b/src/lib/signing.ts
@@ -934,6 +934,7 @@ function isFieldSubmissionComplete(
case "signature":
case "initials":
case "date":
+ case "name":
return typeof update.submittedAt === "number";
case "text":
case "number":
@@ -2234,6 +2235,19 @@ function buildSignerSubmission(
continue;
}
+ // The name the sender gave this signer, as it stands when they sign.
+ if (field.type === "name") {
+ fieldUpdates.set(field.id, {
+ checked: null,
+ fieldId: field.id,
+ imageKey: null,
+ inputMethod: "auto",
+ submittedAt,
+ value: context.signer.name,
+ });
+ continue;
+ }
+
if (
field.type === "text" ||
field.type === "number" ||
diff --git a/src/lib/types/domain.ts b/src/lib/types/domain.ts
index 81dcb52..35a0730 100644
--- a/src/lib/types/domain.ts
+++ b/src/lib/types/domain.ts
@@ -38,6 +38,7 @@ export const fieldTypes = [
"signature",
"initials",
"date",
+ "name",
"text",
"checkbox",
"number",