Skip to content

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

TypeScript

Name a custom disclosure by the words as the signer reads them

Claudea0c861fe739f
diff --git a/src/app/api/admin/settings/route.ts b/src/app/api/admin/settings/route.ts
index e85b047..191fbb4 100644
--- a/src/app/api/admin/settings/route.ts
+++ b/src/app/api/admin/settings/route.ts
@@ -9,7 +9,6 @@ import {
toOrganizationSettingsView,
updateOrganizationSettings,
} from "@/lib/organization-settings";
-import { getDisclosureVersion } from "@/lib/electronic-records-disclosure";
import { logRouteError } from "@/lib/security/logging";
import {
applyRateLimit,
@@ -79,9 +78,6 @@ export async function PUT(request: Request) {
? {
consentDisclosureNotice: {
agreed: true,
- disclosureVersion: getDisclosureVersion(
- after.consentDisclosure,
- ),
noticeVersion: CUSTOM_DISCLOSURE_NOTICE_VERSION,
},
}
diff --git a/src/lib/consent-disclosure.dbtest.ts b/src/lib/consent-disclosure.dbtest.ts
index 595c018..8de3838 100644
--- a/src/lib/consent-disclosure.dbtest.ts
+++ b/src/lib/consent-disclosure.dbtest.ts
@@ -128,7 +128,9 @@ test("an administrator's own disclosure is shown, agreed to and kept, filled in"
const { envelopeId, token } = await sentEnvelope();
const payload = await getSigningPayloadForToken(token, { database });
- assert.equal(payload.disclosure.version, getDisclosureVersion(custom));
+ const shown = "Signing with Dollar $$ Consulting\nWe send this online.";
+
+ assert.equal(payload.disclosure.version, getDisclosureVersion(shown));
assert.deepEqual(payload.disclosure.sections, [
{
heading: "Signing with Dollar $$ Consulting",
@@ -152,7 +154,7 @@ test("an administrator's own disclosure is shown, agreed to and kept, filled in"
assert.equal(consented.rows.length, 1);
assert.equal(
consented.rows[0]?.metadata.disclosureVersion,
- getDisclosureVersion(custom),
+ getDisclosureVersion(shown),
);
assert.equal(
consented.rows[0]?.metadata.disclosureText,
@@ -205,6 +207,41 @@ test("a change to the disclosure shows at once, and the older version is refused
assert.equal(consented.rows.length, 1);
});
+test("a change to the support address after the page loaded is refused too", async () => {
+ await setDisclosure("Write to {contact}.");
+
+ const { token } = await sentEnvelope();
+ const before = await getSigningPayloadForToken(token, { database });
+ const supportBefore = await database.query<{
+ support_address: string | null;
+ }>("select support_address from public.app_settings where id");
+
+ try {
+ await database.query(
+ "update public.app_settings set support_address = '[email protected]' where id",
+ );
+ invalidateSettingsCache();
+
+ const afterChange = await getSigningPayloadForToken(token, { database });
+
+ assert.notEqual(afterChange.disclosure.version, before.disclosure.version);
+ await assert.rejects(
+ recordSignerConsent(
+ token,
+ { disclosureVersion: before.disclosure.version },
+ { database },
+ ),
+ SigningMutationError,
+ );
+ } finally {
+ await database.query(
+ "update public.app_settings set support_address = $1 where id",
+ [supportBefore.rows[0]?.support_address ?? null],
+ );
+ invalidateSettingsCache();
+ }
+});
+
test("with no disclosure of its own the built-in one is used and no text is kept", async () => {
await setDisclosure(null);
diff --git a/src/lib/signing.ts b/src/lib/signing.ts
index cd0e225..0a73db7 100644
--- a/src/lib/signing.ts
+++ b/src/lib/signing.ts
@@ -1759,16 +1759,25 @@ async function readSignerDisclosure(
resolveSettings(await readStoredSettings(database)).consentDisclosure,
);
+ const sections = buildDisclosureSections(
+ {
+ contactAddress: branding.supportAddress ?? context.sender.email,
+ senderName: normalizeSenderName(context.sender),
+ },
+ customDisclosure,
+ );
+
return {
customDisclosure,
- sections: buildDisclosureSections(
- {
- contactAddress: branding.supportAddress ?? context.sender.email,
- senderName: normalizeSenderName(context.sender),
- },
- customDisclosure,
- ),
- version: getDisclosureVersion(customDisclosure),
+ sections,
+ // A custom disclosure is named by the words as this signer reads them,
+ // filled in, so a change to the support address or the sender's name
+ // after the page loaded is refused too, and the record holds the words
+ // that were shown.
+ version:
+ customDisclosure === null
+ ? getDisclosureVersion(null)
+ : getDisclosureVersion(disclosureSectionsAsText(sections)),
};
}