Skip to content

Signature

Several people sign one PDF of the tenant, in person on a display or through a link. The last signature moves the request to all-signed; a job renders a signature page, appends it to the unchanged original and completes the request.

  • Feature - createSignatureFeature({ retention, hostEntities, linkSecret, deliverLink, signaturePageUrl }). Needs files, user-data-rights (exports and erases signer data) and renderer-puppeteer-client (prints the signature page); the test mounts user-data-rights with its own dependencies.
  • Host - every request belongs to a host row (hostType, hostId, one of hostEntities, here a lease); a user sees and works on the request only while they can read that row.
  • deliverLink - issue-link hands the signing link to the app (mail) and returns only { signerId, linkSentAt }: whoever may issue a link must not be able to sign with it.
  • Test - setupTestStack and HTTP: request, issue-link, anonymous sign-by-link, sweep job, completed.
src/feature.ts the feature with a link outbox
src/__tests__/feature.integration.test.ts request to completed request over HTTP

The feature entry point — embedded straight from the source file, so the code here is exactly what runs. Multi-file samples keep their remaining files next to it on GitHub (link below):

import { createSignatureFeature } from "@cosmicdrift/kumiko-bundled-features/signature";
import { createEntity, createTextField, defineFeature } from "@cosmicdrift/kumiko-framework/engine";
export const leaseEntity = createEntity({
name: "lease",
table: "recipe_signature_leases",
fields: {
name: createTextField({
required: true,
maxLength: 100,
personal: false,
reason: "technical_reference",
}),
},
});
// In an app the host is the record the document belongs to; a user sees its requests while they can read it.
export const leaseFeature = defineFeature("signature-recipe-lease", (r) => {
r.entity(leaseEntity);
});
// In an app `deliverLink` sends a mail to the signer. The recipe keeps the links in a map so the
// test can open them: the link is never part of a handler result.
export const deliveredLinks = new Map<string, string>();
export const SIGNATURE_LINK_SECRET = "signature-recipe-link-secret-0123456789";
export const signatureFeature = createSignatureFeature({
retention: { keepFor: "10y", unfinishedKeepFor: "90d" },
linkSecret: SIGNATURE_LINK_SECRET,
hostEntities: ["lease"],
signaturePageUrl: "https://app.example/sign",
deliverLink: async (_ctx, { signerId, url }) => {
deliveredLinks.set(signerId, url);
},
});

📄 On GitHub: samples/recipes/signature/src/feature.ts