@mccaskie-labs/workbench-agreements 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +4 -0
- package/dist/certificate.d.ts +1 -1
- package/dist/certificate.js +12 -4
- package/dist/cli.js +0 -0
- package/dist/styles.js +10 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @mccaskie-labs/workbench-agreements
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Every tool follows the project's look (docs/theming.md step 2, Robert, 24 November 2026). Each tool's colour, font and corner variables now default to the shared theme tokens with a Clean, light fallback (`--wb-booking-accent: var(--wb-accent, #2563eb)`), and tool colours with no token of their own (a recessed panel, a status mark, a tinted pill) are worked out from the tokens with `color-mix()`. So a page drawn with these tools takes the look in the project's workbench.css: light (Clean) by default, or whatever brand.json and project.css say. Breaking for a project page that relied on the old dark defaults: give brand.json the look you want, or set the tokens in project.css. Variable and class names are unchanged, so existing project.css overrides still win. workbench-ui: `styleProblems` refuses a tool's text, muted, surface, line, background, accent, focus, danger, success, warning, font or radius variable whose default doesn't read its token (email, PDF and image follow in step 3); the `wb-ui` class no longer forces dark, and Workbench's own pages (`STYLE`, `UI_CSS`) keep their dark values; `shell` with `stylesheets` (a project page) no longer says dark in its meta tag.
|
|
8
|
+
|
|
9
|
+
## 0.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- `pdf-lib` is loaded only when a PDF is read or made, so importing the package keeps Workers test runs under the runtime's message size limit ("Message is too large").
|
|
14
|
+
|
|
3
15
|
## 0.1.0
|
|
4
16
|
|
|
5
17
|
- First version: `createAgreements` (create, invite, share for Messenger and WhatsApp, get, list, void, file, verify, the signing route, tick, cleanup), `agreementsMigration`, the signed copy with its signing certificate (`buildSignedCopy`), the signing pages with `wb-agreement-*` classes and `AGREEMENT_STYLES`, words in English, Tagalog and Taglish, and `npx workbench-agreements init|generate [--check]|migration`.
|
package/README.md
CHANGED
|
@@ -37,3 +37,7 @@ ctx.waitUntil(agreements.cleanup());
|
|
|
37
37
|
| `AGREEMENT_WORDS` | The words in English, Tagalog and Taglish (`ui.wbagreement.*`) |
|
|
38
38
|
|
|
39
39
|
Commands: `npx workbench-agreements init`, `generate [--check]`, `migration`.
|
|
40
|
+
|
|
41
|
+
## Size and Workers tests
|
|
42
|
+
|
|
43
|
+
PDF work uses `pdf-lib` (about 1 MB), which the package loads only when a PDF is read or made: on `create`, on signing, and in `pdfPages` or `buildSignedCopy`. Importing the package doesn't load it, so a Workers test run (`@cloudflare/vitest-plugin`), which sends each test file's modules to the runtime, doesn't fail with "Message is too large". If a test file of yours imports `pdf-lib` itself, for example to make a sample PDF, load it with `await import("pdf-lib")` inside the test, not at the top of the file.
|
package/dist/certificate.d.ts
CHANGED
package/dist/certificate.js
CHANGED
|
@@ -9,12 +9,17 @@
|
|
|
9
9
|
// The standard PDF fonts only draw Western European letters (WinAnsi), which
|
|
10
10
|
// covers English and Filipino names (ñ, é); anything else is shown by its
|
|
11
11
|
// plain letter, or "?", and the exact text stays in the database.
|
|
12
|
-
|
|
12
|
+
// pdf-lib is loaded only when a PDF is read or made, never at import: a Worker
|
|
13
|
+
// that imports the package (or a Workers test run that loads it in every test
|
|
14
|
+
// file) then doesn't carry it until an agreement is created or signed.
|
|
15
|
+
let pdfLib;
|
|
16
|
+
const loadPdfLib = () => (pdfLib ??= import("pdf-lib"));
|
|
13
17
|
import { AgreementsError } from "./errors.js";
|
|
14
18
|
/** The page count, refusing a file pdf-lib can't open or one that is encrypted (a signed copy couldn't be made from it). */
|
|
15
19
|
export async function pdfPages(bytes) {
|
|
16
20
|
if (bytes.length < 8 || String.fromCharCode(...bytes.slice(0, 5)) !== "%PDF-")
|
|
17
21
|
throw new AgreementsError("invalid_request", "document must be a PDF");
|
|
22
|
+
const { PDFDocument } = await loadPdfLib();
|
|
18
23
|
try {
|
|
19
24
|
const doc = await PDFDocument.load(bytes, { updateMetadata: false });
|
|
20
25
|
const n = doc.getPageCount();
|
|
@@ -28,9 +33,11 @@ export async function pdfPages(bytes) {
|
|
|
28
33
|
}
|
|
29
34
|
const A4 = { width: 595.28, height: 841.89 };
|
|
30
35
|
const MARGIN = 50;
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const
|
|
36
|
+
// pdf-lib's rgb() makes exactly this shape; written out so no import is needed here.
|
|
37
|
+
const colour = (red, green, blue) => ({ type: "RGB", red, green, blue });
|
|
38
|
+
const INK = colour(0.11, 0.11, 0.13);
|
|
39
|
+
const MUTED = colour(0.37, 0.37, 0.42);
|
|
40
|
+
const RULE = colour(0.84, 0.84, 0.87);
|
|
34
41
|
/** Text a standard font can draw: each character it can't becomes its plain letter, or "?". */
|
|
35
42
|
export function winAnsi(font, s) {
|
|
36
43
|
const set = new Set(font.getCharacterSet());
|
|
@@ -84,6 +91,7 @@ const METHOD = { typed: "Typed their name", drawn: "Drew their signature" };
|
|
|
84
91
|
const IDENTITY = { link: "Opened the private signing link sent to them", email_code: "Opened the private signing link and entered a one-time code emailed to them" };
|
|
85
92
|
/** The signed copy's bytes. */
|
|
86
93
|
export async function buildSignedCopy(c) {
|
|
94
|
+
const { PDFDocument, StandardFonts } = await loadPdfLib();
|
|
87
95
|
let doc;
|
|
88
96
|
try {
|
|
89
97
|
doc = await PDFDocument.load(c.document, { updateMetadata: false });
|
package/dist/cli.js
CHANGED
|
File without changes
|
package/dist/styles.js
CHANGED
|
@@ -18,16 +18,16 @@ export const AGREEMENT_STYLES = {
|
|
|
18
18
|
title: "Agreement signing page",
|
|
19
19
|
prefix: "wb-agreement-",
|
|
20
20
|
variables: [
|
|
21
|
-
{ name: "--wb-agreement-text", value: "#
|
|
22
|
-
{ name: "--wb-agreement-muted", value: "#
|
|
23
|
-
{ name: "--wb-agreement-surface", value: "#
|
|
24
|
-
{ name: "--wb-agreement-line", value: "#
|
|
25
|
-
{ name: "--wb-agreement-accent", value: "#
|
|
26
|
-
{ name: "--wb-agreement-on-accent", value: "#ffffff", about: "Text on the Sign button" },
|
|
27
|
-
{ name: "--wb-agreement-danger", value: "#b42318", about: "Problems and the Decline button" },
|
|
28
|
-
{ name: "--wb-agreement-danger-soft", value: "#
|
|
29
|
-
{ name: "--wb-agreement-focus", value: "rgba(
|
|
30
|
-
{ name: "--wb-agreement-radius", value: "
|
|
21
|
+
{ name: "--wb-agreement-text", value: "var(--wb-text, #1f2937)", about: "Text" },
|
|
22
|
+
{ name: "--wb-agreement-muted", value: "var(--wb-muted, #5b6472)", about: "Quieter text: who it's from, hints, the deadline" },
|
|
23
|
+
{ name: "--wb-agreement-surface", value: "var(--wb-surface, #f7f8f8)", about: "Background of the page and the fields" },
|
|
24
|
+
{ name: "--wb-agreement-line", value: "var(--wb-line, #d7d8db)", about: "Borders of the fields and the signature box" },
|
|
25
|
+
{ name: "--wb-agreement-accent", value: "var(--wb-accent, #2563eb)", about: "The Sign button and links" },
|
|
26
|
+
{ name: "--wb-agreement-on-accent", value: "var(--wb-on-accent, #ffffff)", about: "Text on the Sign button" },
|
|
27
|
+
{ name: "--wb-agreement-danger", value: "var(--wb-danger, #b42318)", about: "Problems and the Decline button" },
|
|
28
|
+
{ name: "--wb-agreement-danger-soft", value: "var(--wb-danger-bg, #f9eded)", about: "Background of the problem box" },
|
|
29
|
+
{ name: "--wb-agreement-focus", value: "var(--wb-focus, rgba(37,99,235,0.4))", about: "The ring round whatever has focus" },
|
|
30
|
+
{ name: "--wb-agreement-radius", value: "var(--wb-radius, 8px)", about: "Corner rounding of fields, buttons and the signature box" },
|
|
31
31
|
{ name: "--wb-agreement-width", value: "36rem", about: "Widest the page grows" },
|
|
32
32
|
{ name: "--wb-agreement-signature-font", value: '"Segoe Script","Brush Script MT","Snell Roundhand",cursive', about: "The typed signature's handwriting font" },
|
|
33
33
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-agreements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Agreements and e-signing for Workbench apps: send a branded PDF agreement, let each person sign it online with a typed or drawn signature, keep a timestamped audit trail, and email the signed copy, with a signing certificate, to everyone. Runs in the app's own Worker, database and R2 bucket.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|