Skip to content

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

TypeScript

Add a Part 11 validation pack, and test that the retention period skips Part 11 records

Claudecc7ead0a8c35
diff --git a/README.md b/README.md
index e790429..90e27d3 100644
--- a/README.md
+++ b/README.md
@@ -209,7 +209,7 @@ Every install has a page at `/electronic-signatures` that says what it is for, a
- protected health information under HIPAA;
- documents that many laws keep out of electronic signature, such as wills, family-law matters, court orders, notices of foreclosure, eviction, utility shut-off or insurance cancellation, and in most EU countries real estate transfers and documents that need a notary.
-For FDA 21 CFR Part 11 records, an administrator can turn on **Part 11 mode** under Settings. Signers then sign with their own accounts, whose identity an administrator has confirmed, give their password again at each signature, and see the meaning of their signature (approval, review, responsibility or authorship) printed beside it with their name and the time. Audit trails export as CSV, and finished records are never deleted on a timer. That covers the software's part only: validating your install, writing and following your own procedures, training your people and certifying your electronic signatures to the FDA stay with your organization.
+For FDA 21 CFR Part 11 records, an administrator can turn on **Part 11 mode** under Settings. Signers then sign with their own accounts, whose identity an administrator has confirmed, give their password again at each signature, and see the meaning of their signature (approval, review, responsibility or authorship) printed beside it with their name and the time. Audit trails export as CSV, and finished records are never deleted on a timer. That covers the software's part only: validating your install, writing and following your own procedures, training your people and certifying your electronic signatures to the FDA stay with your organization. The [Part 11 validation pack](docs/part11/README.md) gives you starting documents for that: requirements, a traceability matrix, a risk assessment, qualification scripts, SOP templates and the FDA letter.
Your install carries your organization's name, and your organization is responsible for how it is used: linking your own terms and privacy policy, keeping the support address pointed at a mailbox someone reads, choosing how long documents are kept, and answering signers' data requests. [Your responsibilities](docs/self-hosting.md#your-responsibilities) has the details.
diff --git a/docs/part11/README.md b/docs/part11/README.md
new file mode 100644
index 0000000..26eb6b5
--- /dev/null
+++ b/docs/part11/README.md
@@ -0,0 +1,44 @@
+# FDA 21 CFR Part 11 validation pack
+
+These are starting documents for an organization that wants to use SignuDoc for records that fall under FDA 21 CFR Part 11. Copy them into your own quality system, fill in the blanks marked `[like this]`, and change anything that doesn't match how you work.
+
+> **This is not legal or regulatory advice.** SignuDoc's maintainers do not validate your install, and nothing here says that an install meets Part 11. Whether yours does depends on how you validate it, run it, and control it. Ask your quality and regulatory people, and a lawyer when it matters.
+
+## What SignuDoc does and what you do
+
+SignuDoc provides the software controls in **Part 11 mode**, which an administrator turns on under Settings. The rest is yours.
+
+| SignuDoc (software) | Your organization |
+| ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
+| Signers sign with their own account. An administrator records how they checked who the person is. | Decide who may sign, check identities, and keep the evidence (11.100(b)). |
+| Email and password to open the document, and again at each signature. | Make sure people keep their passwords to themselves, and train them (11.10(i), 11.300). |
+| Five wrong passwords lock signing and email the administrators. | Look into every lock before unlocking (11.300(d)). |
+| The meaning (approval, review, responsibility, authorship) is printed with the name and UTC time. | Choose which meaning each kind of record needs. |
+| Hash-chained audit trails for each envelope and for the install, exportable as CSV. | Review them, keep the exports, and say who may see them (11.10(d), (e)). |
+| Finished Part 11 records are never deleted on a timer or by a data request. | Decide how long to keep them, and delete them by hand when your rules allow. |
+| Sealed PDF and certificate, so any later change to the file shows. | Validate the install (11.10(a)), control changes, and send the certification letter to the FDA (11.100(c)). |
+
+## The documents
+
+| Document | What it is for |
+| ----------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
+| [Requirements](requirements.md) | What the system has to do, one numbered requirement per line, each tied to a Part 11 section. |
+| [Traceability matrix](traceability-matrix.md) | Each requirement, where SignuDoc meets it, and the test that shows it. |
+| [Risk assessment](risk-assessment.md) | What can go wrong, how bad it would be, and what controls it. |
+| [Installation qualification](installation-qualification.md) | A checklist for each new deployment. |
+| [Operational qualification](operational-qualification.md) | Test scripts a person runs on your install, with places to record results. |
+| [Release and change control](change-control.md) | How to take a new SignuDoc version, and the evidence each release gives you. |
+| [Suppliers](suppliers.md) | Vercel, Neon and Resend: what each one holds, and what to get from each. |
+| [Procedures (SOP templates)](procedures.md) | Accounts and identity checks, signing, audit review, locks, records, incidents. |
+| [FDA certification letter](fda-certification-letter.md) | A template for the letter 11.100(c) asks for. |
+| [Known gaps](known-gaps.md) | What Part 11 mode does not do yet, and what to do instead. |
+
+## Suggested order
+
+1. Read [Known gaps](known-gaps.md) and [Risk assessment](risk-assessment.md), and decide whether SignuDoc fits your records.
+2. Adopt the [procedures](procedures.md) and the [requirements](requirements.md), changed to suit you.
+3. Deploy, then run the [installation qualification](installation-qualification.md).
+4. Turn on Part 11 mode and run the [operational qualification](operational-qualification.md).
+5. Approve the install for use and file the evidence.
+6. Send the [certification letter](fda-certification-letter.md) if you haven't already.
+7. For every new version, follow [release and change control](change-control.md).
diff --git a/docs/part11/change-control.md b/docs/part11/change-control.md
new file mode 100644
index 0000000..a2c27c3
--- /dev/null
+++ b/docs/part11/change-control.md
@@ -0,0 +1,45 @@
+# Release and change control
+
+SignuDoc has no numbered releases. Each commit on `main` is a version. Your install runs whichever commit you last pulled into your copy (see [Keep your install up to date](../self-hosting.md#keep-your-install-up-to-date)). Change control is about deciding which commit you run and showing that it still works.
+
+## Evidence each version gives you
+
+Every pull request and every push to `main` runs the project's CI (`.github/workflows/ci.yml`):
+
+- **Typecheck, lint, unit tests, build**, which includes `npm test`.
+- **End-to-end test**, which runs the database tests (`npm run test:db`) against a real Postgres and then the browser test (`npm run test:e2e`). The browser test includes a full Part 11 run: an admin turns the mode on, a send is refused until the signer's identity is confirmed, the signer signs with their password after one wrong try, and the audit exports are checked.
+
+For a commit, the run on the GitHub Actions page is your test evidence. Save its link, or a PDF of the page, with the change record.
+
+## Procedure for taking a new version
+
+1. **Identify** the commit you want, and list the commits between it and the one you run now (`git log <current>..<new> --oneline`).
+2. **Assess** which ones touch the files in the [traceability matrix](traceability-matrix.md). Any database migration (`db/migrations/`) is a change to the record structure and needs a closer look.
+3. **Check** that CI passed for the new commit, and file the run link.
+4. **Test** on a separate test install, not on production:
+ - Deploy the new commit to a Vercel preview or a second project with its own database.
+ - Re-run the [OQ](operational-qualification.md) scripts for every requirement a changed file touches.
+ - Re-run OQ-04 and OQ-07 for any change at all.
+5. **Approve** the change: who reviewed it, what was tested, any deviations, and the decision.
+6. **Deploy** to production by merging the commit into your copy and pushing. Record the deployment's commit SHA and time from Vercel.
+7. **Verify** after deployment: log in, check the install audit trail chain is intact, and open one finished Part 11 record.
+
+## Emergency changes
+
+For a security fix you can't wait to test, deploy it, record why, and complete steps 4 and 5 within `[N]` working days.
+
+## Rolling back
+
+Vercel can put an earlier deployment back with Instant Rollback. A rollback does not undo database migrations. Migrations here only add, so an older version normally runs on a newer database, but check before rolling back past a migration. Record every rollback as a change.
+
+## Changes outside the code
+
+The following are changes too, and go through the same record:
+
+- environment variables;
+- the Vercel, Neon or Resend plan or region;
+- the seal certificate;
+- a new administrator;
+- turning Part 11 mode off or on.
+
+Changes made inside SignuDoc are also in the install audit trail. Changes made in the hosting consoles are not, so record them yourself.
diff --git a/docs/part11/fda-certification-letter.md b/docs/part11/fda-certification-letter.md
new file mode 100644
index 0000000..67ccf97
--- /dev/null
+++ b/docs/part11/fda-certification-letter.md
@@ -0,0 +1,31 @@
+# FDA certification letter (11.100(c))
+
+Before or at the time it starts using electronic signatures, an organization certifies to the FDA that its electronic signatures are meant to be the legally binding equivalent of handwritten ones. 21 CFR 11.100(c) says the letter is submitted on paper and signed by hand. It names the office to send it to, and that office has been reorganized since the rule was written, so check the FDA's current instructions for where and how to send it before you do. The letter is sent once for the organization, not once per system.
+
+---
+
+`[Organization letterhead]`
+
+`[Date]`
+
+`[FDA office and address, per current FDA instructions]`
+
+**Subject: Certification of electronic signatures under 21 CFR 11.100(c)**
+
+Pursuant to Section 11.100 of Title 21 of the Code of Federal Regulations, this is to certify that `[organization's legal name]` intends that all electronic signatures executed by our employees, agents, or representatives, located anywhere in the world, are the legally binding equivalent of traditional handwritten signatures.
+
+`[Optional: FDA establishment identifiers, such as FEI numbers, or a list of sites covered.]`
+
+Signed,
+
+`[Handwritten signature]`
+
+`[Name]`
+`[Title, for example Head of Quality]`
+`[Organization]`
+`[Address]`
+`[Telephone and email]`
+
+---
+
+Keep a copy with your validation records. Under 11.100(c)(2), the FDA can also ask for further certification or testimony that a specific electronic signature is the legally binding equivalent of the signer's handwritten signature.
diff --git a/docs/part11/installation-qualification.md b/docs/part11/installation-qualification.md
new file mode 100644
index 0000000..b5edf29
--- /dev/null
+++ b/docs/part11/installation-qualification.md
@@ -0,0 +1,37 @@
+# Installation qualification (IQ)
+
+Run this for each new deployment, and again when you move an install to a new Vercel project, database or storage. Record who did each step and when, with a screenshot or link as evidence.
+
+Install name: `[ ]` Web address: `[ ]` Performed by: `[ ]` Date: `[ ]`
+
+## Version
+
+| # | Check | Expected | Result | Evidence |
+| ----- | ------------------- | -------------------------------------------------------------------------------------------- | ------ | ----------------------- |
+| IQ-01 | The deployed commit | A commit on `main` of `NYLLON-SOFTWARE/SignuDoc` (or your fork), recorded by its full SHA | | Vercel deployment page |
+| IQ-02 | CI for that commit | "Typecheck, lint, unit tests, build" and "End-to-end test" passed | | GitHub Actions run link |
+| IQ-03 | Database migrations | The build log shows every migration applied, up to `20261115090000_part11_mode.sql` or later | | Vercel build log |
+
+## Services
+
+| # | Check | Expected | Result | Evidence |
+| ----- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ----------------------------------------- |
+| IQ-04 | Database | A Neon Postgres database, with the region and plan recorded, and its backup or point-in-time restore window noted | | Neon console |
+| IQ-05 | File storage | A Vercel Blob store is connected to the project, and `STORAGE_DRIVER` is unset or `blob` (never `local` on Vercel) | | Vercel project, Storage |
+| IQ-06 | Email | Settings, Email shows email working. A test email arrives | | Screenshot |
+| IQ-07 | Seal | The seal certificate is configured as your organization decided (the default install seal, or a CA-issued certificate in `SEAL_P12_BASE64` and `SEAL_P12_PASSWORD`) | | Vercel environment variables (names only) |
+| IQ-08 | Secrets | `BETTER_AUTH_SECRET` is set, unique to this install, and not shared | | Environment variable list |
+| IQ-09 | Password breach check | `PASSWORD_BREACH_CHECK` is not set to `off` | | Environment variable list |
+| IQ-10 | Time | Server times are UTC. Note the time source (Vercel's servers) | | This line |
+| IQ-11 | Access to the hosting | Only named people have access to the Vercel team, the Neon project and the Resend account, with the list attached | | Member lists |
+
+## Application
+
+| # | Check | Expected | Result | Evidence |
+| ----- | ------------ | ----------------------------------------------------------------------------------------------------------------- | ------ | ---------- |
+| IQ-12 | Setup done | The first administrator is a named person. The support address goes to a mailbox someone reads | | Settings |
+| IQ-13 | Sign-up rule | Sign-up is limited to your email domain, or closed | | Settings |
+| IQ-14 | Retention | The retention period is empty | | Settings |
+| IQ-15 | Part 11 mode | Turned on under Settings. The install audit trail shows "Part 11 mode changed: Turned on" and the chain is intact | | Screenshot |
+
+Approved for operational qualification by `[name, role, date]`.
diff --git a/docs/part11/known-gaps.md b/docs/part11/known-gaps.md
new file mode 100644
index 0000000..9135b96
--- /dev/null
+++ b/docs/part11/known-gaps.md
@@ -0,0 +1,17 @@
+# Known gaps
+
+What Part 11 mode does not do yet, and what to do instead. These are also listed in the [risk assessment](risk-assessment.md).
+
+| Gap | Part 11 | What to do for now |
+| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------- |
+| **No idle timeout.** A signed-in session lasts up to 7 days. Each signature needs the password again, but someone at an unlocked computer could see records. | 11.200(a)(1)(ii), 11.10(d) | Screen lock by policy and device management (SOP-2). |
+| **No password aging or reuse rules.** Passwords need 15 or more characters and are checked against breach lists, but they never expire. | 11.300(b) | Set a change interval in SOP-2 if your organization requires one. |
+| **Sign-in lockout is a rate limit only.** Wrong passwords at _signing_ lock the account. Wrong passwords at the normal _sign-in_ are rate limited but don't lock it. | 11.300(d) | Review sign-in rate-limit events and failed signings in the audit trail. |
+| **No biometrics or passkeys.** Signing uses email and password. | 11.200(b) | Not needed: email and password meet 11.200(a). |
+| **Some admin changes are not in the install audit trail.** These are the logo, and the sender-address check on the Email panel. Settings, roles, identity, locks and Part 11 mode are recorded. | 11.10(e) | Record logo and email changes in change control. |
+| **No signature meaning on templates.** A draft made from a template needs a meaning chosen for each signer before it can be sent. | none | The send is refused until each meaning is chosen, so nothing goes out without one. |
+| **Full database access can rewrite the audit chain** consistently. | 11.10(e) | Limit database access, and file audit exports outside the database (SOP-5). |
+| **No built-in backup of the PDFs** in Vercel Blob. | 11.10(c) | Copy the Blob store on a schedule, and test a restore (SOP-5). |
+| **Signers outside your organization** need an account on your install, and an administrator must confirm who they are. | 11.100 | Fine for staff. For outside parties, decide whether this is workable or keep those records out of Part 11 mode. |
+
+Suggestions and fixes are welcome on the project's GitHub.
diff --git a/docs/part11/operational-qualification.md b/docs/part11/operational-qualification.md
new file mode 100644
index 0000000..8ba9ad9
--- /dev/null
+++ b/docs/part11/operational-qualification.md
@@ -0,0 +1,117 @@
+# Operational qualification (OQ)
+
+Test scripts for a person to run on your install after the [installation qualification](installation-qualification.md), and again for the areas a new version changes. Each script names the requirements it tests. For each step, record the actual result, Pass or Fail, your initials and the date, and keep screenshots or exports as evidence. A failed step gets a deviation record before you go on.
+
+You need:
+
+- an **administrator** account (Admin);
+- a **sender** account (Sender), which can be the administrator;
+- two **signer** accounts, Signer A and Signer B, on email addresses you can read;
+- a test PDF.
+
+Use test documents only, and mark them as such.
+
+## OQ-01 Accounts and passwords (SYS-03, SIG-08)
+
+| Step | Action | Expected |
+| ---- | ----------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
+| 1 | Sign up as Signer A with a 14-character password. | Refused: too short. |
+| 2 | Sign up with a password of 15 or more characters that appears in public breach lists (check one on haveibeenpwned.com first). | Refused. |
+| 3 | Sign up with a strong password of 15 or more characters, and confirm the email. | Account created, and you can log in. |
+| 4 | As Signer A, open `/settings`. | No Organization, People or Part 11 sections. |
+| 5 | Create Signer B the same way. | Account created. |
+
+## OQ-02 Identity confirmation (SIG-02, SYS-05)
+
+| Step | Action | Expected |
+| ---- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
+| 1 | As Admin, in Settings, People, find Signer A. | "Identity not confirmed" shown, with a Confirm identity button. |
+| 2 | Click Confirm identity and try to save without a note. | Save is not possible. |
+| 3 | Enter how you checked (for example "badge checked in person") and save. | "Identity confirmed". The site audit trail shows "Identity confirmed", with the note and your email. |
+
+## OQ-03 Sending is refused for an unconfirmed signer (SIG-01, SIG-02)
+
+| Step | Action | Expected |
+| ---- | ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
+| 1 | As Sender, create an envelope with Signer A and Signer B in that order. | The signers step asks for a meaning for each signer. Next stays disabled until both have one. |
+| 2 | Choose Approval for A and Review for B, place a signature field for each, and send. | Refused: an administrator has to confirm Signer B's identity. |
+| 3 | Add someone with no account as a signer and send. | Refused: they need an account. Then remove them. |
+| 4 | As Admin, confirm Signer B's identity. As Sender, send again. | Sent. The envelope's audit trail shows "sent". |
+
+## OQ-04 Signing with email, password and meaning (SIG-04, SIG-06)
+
+| Step | Action | Expected |
+| ---- | ------------------------------------------------------------------------- | ------------------------------------------------------------ |
+| 1 | As Signer A, open the invitation link. | "Confirm it's you" asks for email address and password. |
+| 2 | Enter the wrong password. | Refused, with the number of tries left. |
+| 3 | Enter the right email and password. | The document opens (after the electronic records agreement). |
+| 4 | Sign the field and click Finish. | The dialog shows "Approval: …". Finish signing is disabled. |
+| 5 | Tick the meaning box and enter Signer B's email with Signer A's password. | Refused. |
+| 6 | Enter Signer A's own email and password. | Signed. |
+
+## OQ-05 Lock, alert, unlock and taking back identity (SIG-03, SIG-09)
+
+| Step | Action | Expected |
+| ---- | ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
+| 1 | As Signer B, open the link and enter a wrong password five times. | The fifth try says the account is locked for signing. |
+| 2 | Check every administrator's inbox. | An email "Signing locked for [Signer B]". |
+| 3 | Enter the right password. | Still refused: locked. |
+| 4 | As Admin, in People, check Signer B. | "Signing locked" and an Unlock signing button. The site audit trail shows four "Wrong password while signing" and one "Signing locked". |
+| 5 | Click Unlock signing. | Lock removed, and "Signing unlocked" recorded. |
+| 6 | Take back Signer B's identity confirmation. As Signer B, try to open the link with the right password. | Refused: an administrator has to confirm your identity. |
+| 7 | Confirm Signer B's identity again. | Signer B can open and sign. |
+
+## OQ-06 Signing order (SYS-08)
+
+| Step | Action | Expected |
+| ---- | ------------------------------------------------------------ | -------------------- |
+| 1 | Before Signer A has signed in OQ-04, check Signer B's inbox. | No invitation yet. |
+| 2 | After Signer A signs. | Signer B is invited. |
+
+## OQ-07 Signed record and manifestation (SIG-05, SIG-07, SYS-09)
+
+| Step | Action | Expected |
+| ---- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| 1 | After both have signed, download the signed PDF. | Below each signature: "Signed by [name] \| [YYYY-MM-DD HH:MM:SS] UTC \| Meaning: [meaning]". |
+| 2 | Download the certificate. | For each signer: identified by their own account, with email and password given again to sign; the manifestation line; the confirmed meaning statement. |
+| 3 | Upload the signed PDF on `/verify`. | It matches. |
+| 4 | Change one byte of the PDF (for example, edit it and save), then upload it. | No match. |
+
+## OQ-08 Envelope audit trail and export (SYS-01, SYS-04)
+
+| Step | Action | Expected |
+| ---- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| 1 | As Sender, open the envelope and click Export audit trail. | A CSV downloads, opening with "Part 11 envelope, yes" and "Hash chain check, intact". |
+| 2 | Read the rows. | `sent`, `viewed`, `verified`, `verification_failed`, `consented`, `reauthentication_failed`, `signed` and `completed` events, each with time (UTC), actor, IP address and browser. The `signed` row's details include the meaning. |
+
+## OQ-09 Install audit trail (SYS-05, SYS-06)
+
+| Step | Action | Expected |
+| ---- | -------------------------------------------------------------- | --------------------------------------------------------------------------------- |
+| 1 | As Admin, change the organization name and save. | The site audit trail shows "Settings changed: organizationName". |
+| 2 | Make Signer A an administrator, then make them a member again. | Two "Role changed" entries. |
+| 3 | Click Download as CSV. | The CSV opens with "Hash chain check (whole trail), intact" and lists the events. |
+
+## OQ-10 Records are kept (SYS-02)
+
+| Step | Action | Expected |
+| ---- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
+| 1 | As Admin, try to set a retention period. | The field is disabled while Part 11 mode is on. |
+| 2 | In Settings, Signer data, erase Signer A's data (confirm by typing the address). | The Part 11 record is reported as kept, and it still opens for the Sender. |
+
+## OQ-11 Void needs a reason (SYS-07)
+
+| Step | Action | Expected |
+| ---- | --------------------------------------------- | -------------------------------------------------------------------- |
+| 1 | Send a new Part 11 envelope, then click Void. | The confirm button stays disabled until a reason is typed. |
+| 2 | Type a reason and void. | The envelope's history shows the reason, and so does the CSV export. |
+
+## OQ-12 Turning the mode off (SYS-10)
+
+| Step | Action | Expected |
+| ---- | ---------------------------------------------------------------- | ---------------------------------------------------------------------- |
+| 1 | Send a Part 11 envelope to Signer A, then turn Part 11 mode off. | "Part 11 mode changed: Turned off" recorded. |
+| 2 | As Signer A, open the envelope. | Email and password are still required, and the meaning is still shown. |
+| 3 | Turn Part 11 mode on again for production use. | Recorded. |
+
+Executed by `[name]`, reviewed by `[name]`, approved by `[name, role, date]`.
diff --git a/docs/part11/procedures.md b/docs/part11/procedures.md
new file mode 100644
index 0000000..71b1962
--- /dev/null
+++ b/docs/part11/procedures.md
@@ -0,0 +1,67 @@
+# Procedures (SOP templates)
+
+Short templates for the procedures Part 11 expects you to have. Put each into your own SOP format and add owners, training needs and review dates. Replace each `[ ]` with your own text.
+
+## SOP-1 Accounts and identity confirmation (11.100, 11.300)
+
+1. Only people who sign or send regulated records get an account. Each account is for one person and is never reassigned or reused, even after the person leaves.
+2. Before confirming an identity, the administrator checks it with `[a government photo ID in person / your HR record / …]`.
+3. The administrator confirms the identity in Settings, People, Confirm identity. The note says how the check was done and gives a reference, such as "Passport seen in person, HR record 4417". The note must not contain the ID number itself.
+4. `[A second administrator reviews new confirmations within N days.]`
+5. When a person leaves or changes role, the administrator takes back their identity confirmation the same day, then closes or limits the account.
+6. Every `[quarter]`, an administrator reviews every confirmed account against the current staff list, and records the review.
+
+## SOP-2 Passwords (11.300)
+
+1. Passwords are personal. Nobody may share one, write one where others can see it, or sign in for someone else.
+2. If a password may be known to someone else, the person changes it at once and tells `[the system owner]`.
+3. Lock screens when away from the computer.
+4. Change passwords `[every N months / when there is reason]`. SignuDoc does not force password aging (see [Known gaps](known-gaps.md)).
+
+## SOP-3 Sending and signing regulated records
+
+1. The sender chooses the meaning for each signer according to `[the table below]`.
+
+ | Record type | Signer role | Meaning |
+ | ----------- | ----------- | ---------- |
+ | `[SOP]` | `[Author]` | Authorship |
+ | `[SOP]` | `[QA]` | Approval |
+ | `[ ]` | `[ ]` | `[ ]` |
+
+2. Signers read the whole document, check the meaning shown in the Finish dialog, and sign only if it is right. If it isn't, they decline and tell the sender.
+3. A sent record that must not go ahead is voided with a reason, never left to expire.
+4. Signers are trained on this SOP before their first signature, and the training is recorded.
+
+## SOP-4 Signing locks (11.300(d))
+
+1. When the "Signing locked" email arrives, an administrator contacts the person by `[phone / in person]`, not by replying to email.
+2. If the person did not make the attempts, treat it as a security incident (SOP-6) and do not unlock until it is resolved.
+3. If they did, the administrator unlocks signing in Settings, People and records the reason in `[the lock log]`.
+
+## SOP-5 Audit trail review and records (11.10(c), (e))
+
+1. Every `[month]`, an administrator:
+ - opens Settings, Part 11 and confirms the site audit trail chain is intact;
+ - downloads the site audit trail CSV for the period and files it in `[location]`;
+ - looks for unexpected settings changes, role changes, Part 11 mode changes, identity changes and locks.
+2. For each finished regulated record, the sender files the signed PDF, the certificate and the envelope's audit trail CSV in `[the record system]` within `[N]` days.
+3. If a chain check ever shows broken, stop using the install for new records and handle it as an incident.
+4. Records are kept for `[the period your predicate rules require]`. They are deleted only by hand, under `[procedure]`, after that period, with the deletion recorded.
+5. Backups of the database and of the Blob store are taken `[how and how often]` and a restore is tested `[how often]`.
+
+## SOP-6 Incidents
+
+1. Incidents include:
+ - suspected misuse of an account;
+ - a broken audit chain;
+ - a failed restore;
+ - an outage that affects regulated records;
+ - a security fix from the SignuDoc project.
+2. Record the incident, assess its effect on records, act, and close it with a CAPA where needed.
+3. A security problem in SignuDoc itself is reported to the project privately through GitHub's private vulnerability reporting, not in a public issue.
+
+## SOP-7 Validation and change control (11.10(a), (k))
+
+1. The install is validated with the [installation](installation-qualification.md) and [operational](operational-qualification.md) qualification before use.
+2. Every change follows [Release and change control](change-control.md).
+3. This validation pack is kept as a controlled document, with its version and approval.
diff --git a/docs/part11/requirements.md b/docs/part11/requirements.md
new file mode 100644
index 0000000..f04f289
--- /dev/null
+++ b/docs/part11/requirements.md
@@ -0,0 +1,46 @@
+# Requirements
+
+Your user and functional requirements for SignuDoc in Part 11 mode. Each requirement has an ID that the [traceability matrix](traceability-matrix.md) and the [operational qualification](operational-qualification.md) use. Remove any you don't need, and add your own with new IDs.
+
+Document `[ID]`, version `[1.0]`, approved by `[name, role, date]`.
+
+## System and records
+
+| ID | Requirement | Part 11 |
+| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
+| SYS-01 | The system makes accurate and complete copies of records, both readable (PDF) and machine-readable (CSV audit trail). | 11.10(b) |
+| SYS-02 | Records stay retrievable for the whole retention period. They are not deleted by a timer or by a signer's data request. | 11.10(c) |
+| SYS-03 | Only people with an account can reach the system's records. Only administrators can change settings or roles. | 11.10(d), (g) |
+| SYS-04 | A computer-generated, time-stamped audit trail records the creation, sending, viewing, signing, declining, voiding and completion of each record. It also records who did each step, from where, and when (UTC). | 11.10(e) |
+| SYS-05 | Changes to settings, roles, identity confirmations and signing locks are recorded with the old and new value, who made the change, and when. | 11.10(e) |
+| SYS-06 | Audit trail entries cannot be changed without detection: each entry is chained by hash to the one before it, and the system can check the chain. | 11.10(e) |
+| SYS-07 | Voiding a sent record needs a reason, and the reason is recorded. | 11.10(e) |
+| SYS-08 | Signers sign in the order the sender set. | 11.10(f) |
+| SYS-09 | A finished record is sealed so that any change to the file after signing is detectable. | 11.10(c), 11.70 |
+| SYS-10 | Turning Part 11 mode off does not change the rules a record was sent under. | 11.10(f) |
+
+## Signers and signatures
+
+| ID | Requirement | Part 11 |
+| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
+| SIG-01 | Each signer signs with their own account, which belongs to one person and is not reused. | 11.100(a) |
+| SIG-02 | A record is not sent unless an administrator has confirmed each signer's identity and recorded how. | 11.100(b) |
+| SIG-03 | A signer whose identity confirmation is taken back, or whose email is no longer confirmed, cannot sign. | 11.100(b) |
+| SIG-04 | The signer gives two components, email address and password, to open the record and again at each signature. | 11.200(a)(1) |
+| SIG-05 | Each signature shows the signer's printed name, the date and time (UTC), and its meaning. The same information appears in the certificate. | 11.50(a), (b) |
+| SIG-06 | The signer confirms the meaning of their signature before signing. | 11.50(a)(3) |
+| SIG-07 | The signature is linked to its record, and the seal makes it impossible to copy onto another record undetected. | 11.70 |
+| SIG-08 | Passwords are at least 15 characters long and are checked against known breached passwords. | 11.300(a), (b) |
+| SIG-09 | After five wrong passwords in a row while signing, the account can no longer sign until an administrator unlocks it, and every administrator is emailed. | 11.300(d) |
+
+## Procedural requirements (met by your procedures, not by the software)
+
+| ID | Requirement | Part 11 |
+| ------ | ---------------------------------------------------------------------------------------------------------------------------- | -------------- |
+| PRO-01 | The install is validated before use and after each change. | 11.10(a) |
+| PRO-02 | The people who build, run and use the system are trained and their training is recorded. | 11.10(i) |
+| PRO-03 | People are held accountable for actions under their signatures, by written policy. | 11.10(j) |
+| PRO-04 | System documentation is controlled. | 11.10(k) |
+| PRO-05 | The organization certifies to the FDA that its electronic signatures are the legally binding equivalent of handwritten ones. | 11.100(c) |
+| PRO-06 | Passwords are not shared. Lost or compromised accounts are handled by a written procedure. | 11.300(b), (c) |
+| PRO-07 | Audit trails and records are kept for at least as long as the underlying records must be kept. | 11.10(e) |
diff --git a/docs/part11/risk-assessment.md b/docs/part11/risk-assessment.md
new file mode 100644
index 0000000..5b29348
--- /dev/null
+++ b/docs/part11/risk-assessment.md
@@ -0,0 +1,26 @@
+# Risk assessment
+
+A starting risk assessment for SignuDoc in Part 11 mode. Score each risk for your own records and processes. The scores below assume an ordinary GxP use, such as approving SOPs or batch records, and should be changed if yours is different.
+
+**Severity** (S): 1 = no effect on product quality or patient safety, 3 = could affect a record's integrity, 5 = could hide a quality problem or let an unauthorized signature stand.
+**Likelihood** (L) after the controls: 1 = remote, 3 = possible, 5 = expected.
+**Detectability** (D): 1 = would certainly be found, 5 = would probably not be found.
+A risk priority (S × L × D) of 27 or more needs a further control or a documented acceptance.
+
+| # | Risk | Controls in SignuDoc | Controls you add | S | L | D | RPN |
+| --- | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | --- | --- | --- | --- |
+| R1 | Someone signs as another person. | Own account and password at open and at signing. An admin confirms identity. Lock after 5 wrong passwords, with admin alert. | Identity check procedure, no shared passwords, training. Investigate every lock. | 5 | 1 | 3 | 15 |
+| R2 | A signer's identity confirmation is wrong. | Admin must record how they checked. The confirmation is in the install audit trail. | Two-person check for identity confirmation. Periodic review of confirmed accounts. | 5 | 2 | 3 | 30 |
+| R3 | A record is changed after signing. | Sealed PDF. The verify page checks a copy against the stored hash. | Keep the signed PDF with the record. Check copies on the verify page when in doubt. | 5 | 1 | 1 | 5 |
+| R4 | An audit trail entry is changed or deleted in the database. | Hash chain over every entry, checked on screen and in every CSV export. | Restrict database access to named people. Export and file audit trails at each review. | 5 | 1 | 2 | 10 |
+| R5 | A database administrator rewrites the whole chain consistently. | None: someone with full database access can recompute hashes. | Keep exported CSVs outside the database (they carry the hashes at that time). Limit and log Neon console access. | 5 | 1 | 4 | 20 |
+| R6 | A record is deleted early. | Part 11 records are skipped by the retention timer and by data requests. A retention period can't be set in Part 11 mode. | Back up the database and storage. Control who can close accounts or delete by hand. | 5 | 1 | 3 | 15 |
+| R7 | Records are lost when a service fails or an account lapses. | None in the software. | Neon backups or point-in-time restore, a Blob copy, and supplier review ([Suppliers](suppliers.md)). Keep billing current. | 5 | 2 | 2 | 20 |
+| R8 | Part 11 mode is turned off by mistake. | Admin only, recorded in the install audit trail. Records already sent keep their rules. | Audit review procedure checks for `part11_mode_changed`. | 3 | 2 | 2 | 12 |
+| R9 | The signature meaning is wrong for the record. | The sender chooses it, and the signer sees and confirms it before signing. | Procedure says which meaning each record type needs. | 3 | 2 | 3 | 18 |
+| R10 | A session left open is used by someone else. | Each signature needs the password again. App sessions last up to 7 days. | Lock screens when away, by policy. See [Known gaps](known-gaps.md). | 3 | 2 | 3 | 18 |
+| R11 | A new SignuDoc version breaks a control. | Automated tests on every change, including a Part 11 browser test. | Change control: review, re-run the OQ for changed areas, approve before use. | 5 | 2 | 2 | 20 |
+| R12 | Clock error makes times wrong. | Times come from the server (Vercel) and are written in UTC. | Note the time source in the IQ. | 3 | 1 | 3 | 9 |
+| R13 | Emails (invitations, lock alerts) don't arrive. | Delivery is tracked, and the Email panel shows a failing address. | Check the Email panel in the IQ. Admins check People for locks during audit review. | 2 | 2 | 2 | 8 |
+
+Reviewed by `[name, role]`, approved by `[name, role]`, on `[date]`.
diff --git a/docs/part11/suppliers.md b/docs/part11/suppliers.md
new file mode 100644
index 0000000..246f39f
--- /dev/null
+++ b/docs/part11/suppliers.md
@@ -0,0 +1,35 @@
+# Suppliers
+
+A SignuDoc install on Vercel runs on three outside services. Your organization chooses them, signs their terms, and should assess them as suppliers of a GxP system. None of them is controlled by the SignuDoc project.
+
+Check each supplier's current security reports and terms yourself. What they offer changes, and the plan you are on matters.
+
+| Supplier | What it holds or does | What to get and check |
+| ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **Vercel** (hosting) | Runs the app and the daily cleanup job. Keeps build and runtime logs. Vercel Blob holds every PDF: originals, signed copies and certificates. | Its security report (such as SOC 2) and data processing terms. The regions your project and Blob store run in. Who in your organization is on the Vercel team. Whether your plan's log retention meets your needs. How you will back up the Blob store: plan a regular copy to storage you control. |
+| **Neon** (Postgres database, through the Vercel Marketplace) | Every record's data and both audit trails. | Its security report and data processing terms. The region. **The point-in-time restore window on your plan**: a free plan's window is short, so use a plan with a window that meets your needs, or make your own regular `pg_dump`. Who can open the Neon console, because someone with full database access could change rows (see [risk R5](risk-assessment.md)). |
+| **Resend** (email) | Sends invitations, codes, lock alerts and completion emails. Keeps delivery logs. | Its security report and terms. That the sending domain is yours and verified. Email is a notification channel, not the record: the record is in the database and the PDFs. |
+
+## Supplier assessment record
+
+For each supplier, record:
+
+- Supplier, service and plan: `[ ]`
+- Data held: `[ ]`
+- Region: `[ ]`
+- Security evidence reviewed, such as a report and its date: `[ ]`
+- Contract and data processing terms in place: `[ ]`
+- Backup and restore arrangements: `[ ]`
+- Who has access: `[ ]`
+- Risk accepted by `[name, role, date]`
+- Next review: `[date]`
+
+## The SignuDoc project itself
+
+SignuDoc is open-source software provided as is, without a supplier agreement or support commitment. Treat it as software you take responsibility for:
+
+- the code is public, and you can review it;
+- every version is tested in public CI;
+- your organization does the validation in this pack.
+
+Questions and problems go to the project's GitHub issues. Security problems go to private vulnerability reporting on the repository.
diff --git a/docs/part11/traceability-matrix.md b/docs/part11/traceability-matrix.md
new file mode 100644
index 0000000..26f4554
--- /dev/null
+++ b/docs/part11/traceability-matrix.md
@@ -0,0 +1,37 @@
+# Traceability matrix
+
+Each requirement in [Requirements](requirements.md), where SignuDoc meets it, and how it is tested. Paths are relative to the repository root.
+
+Three kinds of test evidence back the matrix:
+
+- **Automated tests**, which run on every pull request and every push to `main` (see [Release and change control](change-control.md)):
+ - `npm test`: unit tests;
+ - `npm run test:db`: database tests against a real Postgres;
+ - `npm run test:e2e`: a browser test of the whole product.
+- **OQ scripts**, which a person runs on your own install: [Operational qualification](operational-qualification.md).
+- **Procedures**, for requirements the software can't meet: [Procedures](procedures.md).
+
+| Requirement | Where it is met | Automated test | OQ script |
+| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
+| SYS-01 copies | `src/lib/audit-export.ts`, `src/app/api/envelopes/[id]/audit/route.ts`, `src/app/api/admin/audit/route.ts`, `src/lib/services/pdf-finalize.ts` | `part11.test.ts`: "a CSV cell never runs as a spreadsheet formula…"; e2e: "in Part 11 mode a verified account signs…" (step "the audit trails record it and export as CSV") | OQ-08 |
+| SYS-02 retention | `src/lib/retention.ts` (`AND NOT e.part11`), `src/lib/signer-data.ts` (`keptPart11`), `src/lib/organization-settings.ts` | `signature-evidence.dbtest.ts`: "the retention period never warns about or deletes a Part 11 record"; `part11.dbtest.ts`: "a data request does not erase a finished Part 11 envelope" | OQ-10 |
+| SYS-03 access | `src/lib/auth/`, admin routes under `src/app/api/admin/` | e2e: "a new install is set up…" (step "log in": an ordinary account gets 403 on admin routes) | OQ-01 |
+| SYS-04 envelope audit trail | `src/lib/services/audit.ts`, `src/lib/signing.ts`, `src/lib/envelopes.ts` | `signature-evidence.dbtest.ts`: "the audit chain verifies, and shows an edited row" | OQ-08 |
+| SYS-05 install audit trail | `src/lib/services/system-audit.ts`, `src/lib/part11.ts`, `src/lib/people.ts`, `src/app/api/admin/settings/route.ts` | `part11.dbtest.ts`: "five wrong passwords lock signing…"; e2e Part 11 test (site audit has `part11_mode_changed`, `identity_verified`) | OQ-09 |
+| SYS-06 hash chain | `computeAuditRowHash`, `computeSystemAuditRowHash`, `verifyAuditChain`, `verifySystemAuditChain` | `part11.dbtest.ts`: "the install audit trail is one hash chain that shows a changed row"; `part11.test.ts`: "the install audit hash changes…" | OQ-09 |
+| SYS-07 void reason | `voidSentEnvelope` in `src/lib/envelopes.ts`, void dialog in `src/components/envelopes/envelope-detail-shell.tsx` | none yet: covered by the OQ | OQ-11 |
+| SYS-08 signing order | `sign_order` in `src/lib/envelopes.ts` and `src/lib/signing.ts` | `copy-recipients.dbtest.ts`: "…stay out of the signing order" | OQ-06 |
+| SYS-09 seal | `src/lib/services/pdf-seal.ts` | `pdf-seal.test.ts`: "a sealed PDF verifies, and any change to it is detected" | OQ-07 |
+| SYS-10 rules kept per record | `envelopes.part11`, `signers.user_id` set at send in `sendDraftEnvelope` | e2e Part 11 test (mode turned off at the end) | OQ-12 |
+| SIG-01 own account | `sendDraftEnvelope` binds `signers.user_id`; `findSignerAccounts` in `src/lib/part11.ts` | `part11.test.ts`: "a send is refused for each missing Part 11 condition…" | OQ-03 |
+| SIG-02 identity confirmed | `describePart11SignerProblem`, `setIdentityVerification` | `part11.test.ts` (same test); e2e Part 11 test (step "it is not sent until an administrator confirms who the signer is") | OQ-02, OQ-03 |
+| SIG-03 re-checked | `checkSigningCredentials` in `src/lib/part11.ts` | `part11.dbtest.ts`: "an identity confirmation taken back after send stops the signature" | OQ-05 |
+| SIG-04 two components | `verifySignerCheck` (method `account`) and `reauthenticatePart11Signer` in `src/lib/signing.ts` | `part11.dbtest.ts`: "a right password signs…", "a right password with someone else's email address is a miss"; `part11.test.ts`: "a signer bound to an account must pass the account check first"; e2e Part 11 test | OQ-04 |
+| SIG-05 manifestation | `buildSignatureManifestation` in `src/lib/signature-meanings.ts`, `stampSignatureManifestation` and `describeSignerEvidence` in `src/lib/services/pdf-finalize.ts` | `part11.test.ts`: "the manifestation gives the name, the UTC time and the meaning" | OQ-07 |
+| SIG-06 meaning confirmed | Finish dialog in `src/components/signing/signing-live-shell.tsx`; `meaningConfirmed: true` in `src/lib/schemas/field.ts` | e2e Part 11 test (Finish stays disabled until the meaning is confirmed) | OQ-04 |
+| SIG-07 signature linked to record | the seal (SYS-09) and the signature's metadata in the `signed` audit event | `pdf-seal.test.ts` | OQ-07 |
+| SIG-08 password quality | `minPasswordLength: 15` and the breach check in `src/lib/auth/server.ts` | none in Part 11 tests: covered by the OQ | OQ-01 |
+| SIG-09 lock and alert | `checkSigningCredentials`, `alertAdministrators`, `unlockSigning` | `part11.dbtest.ts`: "five wrong passwords lock signing, tell the administrators and are audited" | OQ-05 |
+| PRO-01 to PRO-07 | Your procedures | | [Procedures](procedures.md), [Installation qualification](installation-qualification.md), [FDA letter](fda-certification-letter.md) |
+
+When a release changes any file named here, re-run the OQ scripts for that row (see [Release and change control](change-control.md)).
diff --git a/docs/self-hosting.md b/docs/self-hosting.md
index 7af60f6..fdb1a28 100644
--- a/docs/self-hosting.md
+++ b/docs/self-hosting.md
@@ -101,6 +101,16 @@ The first time you open a new install it takes you to `/setup`. There you name y
Your install carries your organization's name, not SignuDoc's. In Settings, link your own terms and privacy policy (without a privacy link, signers see a notice built from your settings at `/signer-privacy`; check it), keep the support address you gave at setup pointed at a mailbox someone reads, and choose how long finished documents are kept. Under GDPR your organization is the controller; Settings, Organization has the tools to answer a signer who asks for their data or for its erasure.
+## FDA 21 CFR Part 11
+
+An administrator can turn on Part 11 mode under Settings for regulated records. While it is on:
+
+- signers sign with their own confirmed accounts and give their password again at each signature;
+- the meaning of each signature is printed beside it;
+- finished records are never deleted on a timer.
+
+Validating the install is up to your organization. The [Part 11 validation pack](part11/README.md) has the documents to start from.
+
## Signed PDFs and the seal
Every finished PDF and audit certificate is sealed with a PAdES signature, so any change after signing shows in Adobe Acrobat and other PDF readers, and its SHA-256 is recorded. Anyone can check a copy at `/verify`. The audit trail in the database is a hash chain, so an edited or deleted row shows too.
diff --git a/src/lib/deploy-button.test.ts b/src/lib/deploy-button.test.ts
index b771885..45ea83d 100644
--- a/src/lib/deploy-button.test.ts
+++ b/src/lib/deploy-button.test.ts
@@ -99,6 +99,10 @@ test("every picture and page the README and the guides link to is in the reposit
"README.md",
"docs/self-hosting.md",
"docs/development.md",
+ "docs/part11/README.md",
+ "docs/part11/traceability-matrix.md",
+ "docs/part11/known-gaps.md",
+ "docs/part11/change-control.md",
]) {
const text = readFileSync(path.join(repoRoot, document), "utf8");
const targets = [...text.matchAll(localTarget)].map(
diff --git a/src/lib/signature-evidence.dbtest.ts b/src/lib/signature-evidence.dbtest.ts
index fb06cc2..4dfa70e 100644
--- a/src/lib/signature-evidence.dbtest.ts
+++ b/src/lib/signature-evidence.dbtest.ts
@@ -247,3 +247,47 @@ test("the retention period warns the sender, then deletes", async () => {
assert.equal(await envelopeOwner(old), null);
assert.equal(await envelopeOwner(recent), owner);
});
+
+test("the retention period never warns about or deletes a Part 11 record", async () => {
+ const owner = await createUser();
+ const now = 2_000_000_000;
+ const day = 24 * 60 * 60;
+ const record = await createEnvelope(
+ owner,
+ "completed",
+ now - 400 * day,
+ );
+ const sent: string[] = [];
+ const emailService = {
+ send: async (message: { subject: string; to: string }) => {
+ sent.push(message.to);
+
+ return { accepted: [message.to], rejected: [] };
+ },
+ sendBatch: async () => ({ accepted: [], rejected: [] }),
+ } as unknown as EmailService;
+
+ await database.query(`update envelopes set part11 = true where id = $1`, [
+ record,
+ ]);
+ // Part 11 mode refuses a retention period, but one set before (or by
+ // hand) must still leave Part 11 records alone.
+ await database.query(
+ `insert into app_settings (id, signup_mode, retention_days, created_at, updated_at)
+ values (true, 'closed', 30, 1, 1)
+ on conflict (id) do update set retention_days = 30`,
+ );
+
+ for (const at of [now, now + 60 * day]) {
+ await runRetentionSweep({
+ database,
+ emailService,
+ now: at,
+ storageService: storage(),
+ });
+ }
+
+ assert.equal(await envelopeOwner(record), owner);
+ assert.equal(sent.includes(`${owner}@example.test`), false);
+});