Skip to content

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

TypeScript

Merge main (0.4.0) into the API keys branch

Claude260a530cad28
diff --cc CHANGELOG.md
index b29149c,4725b09..f6d4cec
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -8,18 -8,49 +8,61 @@@ release says when it does
## [Unreleased]
+### API
+
+- API keys: an administrator can make keys under Settings, Organization, API
+ keys, for another app to use the SignuDoc API. A key is shown once, only
+ its hash is stored, and it acts as the administrator who made it. Keys can
+ be read-only, can expire, and stop working when revoked or when their
+ administrator stops being one. `GET /api/v1/me` checks a key works. See
+ [docs/api.md](docs/api.md).
+
+This changes the database: the new `api_keys` table is added by the
+migration that runs on 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-16
Sign-in security and audit features for organizations that need them, and
diff --cc e2e/signing-flow.spec.ts
index 885fbea,39e8656..da9c090
--- a/e2e/signing-flow.spec.ts
+++ b/e2e/signing-flow.spec.ts
@@@ -1216,91 -1216,132 +1216,217 @@@ test("a signer signs with a qualified s
});
});
+ test("a signer who declines is told the decline was recorded, not that the link expired", async ({
+ browser,
+ page,
+ }, testInfo) => {
+ const runId = String(Date.now());
+ const signerEmail = `decliner+${runId}@example.com`;
+ const database = new pg.Client({ connectionString: e2eDatabaseUrl });
+ let adminEmail = "";
+
+ await database.connect();
+
+ try {
+ const admin = await database.query<{ email: string }>(
+ `select email from public."user" where role = 'admin' limit 1`,
+ );
+
+ adminEmail = admin.rows[0]?.email ?? "";
+ } finally {
+ await database.end();
+ }
+
+ expect(adminEmail).not.toBe("");
+
+ let envelopeId = "";
+
+ await test.step("the sender sends a document to one signer", async () => {
+ const pdfPath = await writeSamplePdf(testInfo.outputPath("terms.pdf"));
+
+ 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("/envelopes/new");
+ await page.getByLabel("Envelope title").fill("Terms to decline");
+ await page.getByLabel("Upload PDF").setInputFiles(pdfPath);
+ await page.getByRole("button", { name: "Next ->" }).click();
+ await expect(page).toHaveURL(/\/envelopes\/[^/]+\/signers$/);
+ envelopeId = /\/envelopes\/([^/]+)\/signers$/.exec(page.url())?.[1] ?? "";
+
+ await page.getByLabel("Signer 1 name").fill("Dana Decliner");
+ await page.getByLabel("Signer 1 email").fill(signerEmail);
+ await page.getByRole("button", { name: "Next →" }).click();
+ await expect(page).toHaveURL(/\/prepare$/);
+
+ await page.getByRole("button", { exact: true, name: "Signature" }).click();
+
+ const placementTarget = page.getByLabel("Place Signature on page 1");
+ const box = await placementTarget.boundingBox();
+
+ await placementTarget.click({
+ position: { x: box!.width * 0.3, y: box!.height * 0.6 },
+ });
+ await expect(page.getByRole("status")).toHaveText("Saved");
+ await page.getByRole("button", { name: "Next →" }).click();
+ await expect(page).toHaveURL(/\/review$/);
+ await page.getByRole("button", { name: "Send envelope" }).click();
+
+ const confirmation = page.getByRole("dialog", {
+ name: "Send this envelope?",
+ });
+
+ await confirmation.getByRole("checkbox").check();
+ await confirmation.getByRole("button", { name: "Send now" }).click();
+ await expect(page).toHaveURL(new RegExp(`/envelopes/${envelopeId}$`));
+ });
+
+ await test.step("the signer declines and sees that it was recorded", async () => {
+ const invitation = await waitForEmail({
+ template: "signing_invitation",
+ to: signerEmail,
+ });
+ const signerContext = await browser.newContext({
+ viewport: { height: 900, width: 1440 },
+ });
+ const signerPage = await signerContext.newPage();
+
+ await signerPage.goto(extractLink(invitation.text, "/sign/"));
+
+ const consent = signerPage.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 signerPage
+ .getByRole("button", { exact: true, name: "Decline" })
+ .click();
+
+ const decline = signerPage.getByRole("dialog", {
+ name: "Decline to sign?",
+ });
+
+ await decline
+ .getByLabel("Reason (optional)")
+ .fill("Terms in section 2 are not what we agreed.");
+ await decline.getByRole("button", { name: "Decline to sign" }).click();
+
+ const declined = signerPage.getByRole("heading", {
+ name: "You declined to sign",
+ });
+
+ await expect(declined).toBeVisible();
+ // Focus moves to the outcome, so a screen reader reads it out.
+ await expect(declined).toBeFocused();
+ await expect(signerPage.getByText("This link has expired")).toHaveCount(0);
+ await expect(
+ signerPage.getByText(/Request a new signing link/),
+ ).toHaveCount(0);
+ await signerContext.close();
+ });
+
+ await test.step("the sender sees the decline and its reason", async () => {
+ await waitForEmail({ template: "decline_notification", to: adminEmail });
+ await page.goto(`/envelopes/${envelopeId}`);
+ await expect(
+ page.getByText(
+ "Decline reason: Terms in section 2 are not what we agreed.",
+ ),
+ ).toBeVisible();
+ });
+ });
+
+test("an administrator makes an API key, the API accepts it, and revoking it stops it", async ({
+ baseURL,
+ 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 ?? "";
+ } finally {
+ await database.end();
+ }
+
+ expect(adminEmail).not.toBe("");
+
+ // A separate client, with no session cookie: only the key gets it in.
+ const api = await playwright.request.newContext({ baseURL });
+ let key = "";
+
+ await test.step("the key is made in Settings and shown once", 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("Billing app");
+ await page.getByRole("button", { name: "Create key" }).click();
+
+ key =
+ (await page.getByTestId("new-api-key").locator("code").textContent()) ??
+ "";
+ expect(key).toMatch(/^sdk_[A-Za-z0-9_-]{43}$/);
+ await page.getByRole("button", { name: "Done" }).click();
+ await expect(page.getByTestId("new-api-key")).toHaveCount(0);
+ await expect(
+ page.getByRole("list", { name: "API keys" }).getByText(key.slice(0, 12)),
+ ).toBeVisible();
+ });
+
+ await test.step("the API answers to the key and to nothing else", async () => {
+ const me = await api.get("/api/v1/me", {
+ headers: { authorization: `Bearer ${key}` },
+ });
+
+ expect(me.status()).toBe(200);
+ expect(me.headers()["ratelimit-limit"]).toBe("600");
+ expect(await me.json()).toMatchObject({
+ key: { name: "Billing app", scope: "write" },
+ user: { email: adminEmail },
+ });
+
+ const anonymous = await api.get("/api/v1/me");
+
+ expect(anonymous.status()).toBe(401);
+ expect(await anonymous.json()).toMatchObject({
+ error: { code: "unauthorized" },
+ });
+ });
+
+ await test.step("a revoked key is refused at once", async () => {
+ await page.getByRole("button", { name: "Revoke Billing app" }).click();
+ await page.getByRole("button", { name: "Revoke", exact: true }).click();
+ await expect(
+ page.getByRole("list", { name: "API keys" }).getByText("Revoked"),
+ ).toBeVisible();
+
+ const refused = await api.get("/api/v1/me", {
+ headers: { authorization: `Bearer ${key}` },
+ });
+
+ expect(refused.status()).toBe(401);
+ });
+
+ await api.dispose();
+});
+
test("two-step sign-in: an administrator sets it up and requires it of everyone", async ({
browser,
page,