From 74b4eb182df82a23266461dc8f63457dff13e984 Mon Sep 17 00:00:00 2001 From: Ruben Hensen Date: Sun, 24 May 2026 15:46:48 +0200 Subject: [PATCH] fix(pg-node): clean up stale Node 20 references and README style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to dobby's review on the (already-merged) #46: - Root README and pg-node/src/config.mjs still referenced "Node 20.6+" after the engines bump to >=22 in #46's chore commit. - pg-node/src/config.mjs comment referenced `--env-file=` but the npm scripts use `--env-file-if-exists`. - pg-node/README "Two modes" list used the inline-header + em-dash pattern flagged by writing-rules; converted to a small table. - Trimmed a few stylistic em-dashes (lead paragraph, prerequisites, staging note, SDK-mapping paragraph). Kept the bold "does not actually deliver notification emails" callout — that one is load-bearing. No behaviour change; verified with `node --check` on all .mjs files and a live `npm run upload` to staging (UUID 6e22edaf-…). --- README.md | 2 +- pg-node/README.md | 18 ++++++++++-------- pg-node/src/config.mjs | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c2fe0a5..829db66 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ See [pg-sveltekit/README.md](pg-sveltekit/README.md) for environment variables a ### Node.js example -Requires Node.js 20.6+ and a PostGuard API key. +Requires Node.js 22+ and a PostGuard API key. ```bash cd pg-node diff --git a/pg-node/README.md b/pg-node/README.md index c348d85..695f37c 100644 --- a/pg-node/README.md +++ b/pg-node/README.md @@ -1,19 +1,21 @@ # pg-node: PostGuard Node.js example -Node.js example demonstrating how to use the [@e4a/pg-js](https://www.npmjs.com/package/@e4a/pg-js) SDK from a server runtime. Mirrors the [pg-sveltekit](../pg-sveltekit) example's "Informatierijk notificeren" flow (citizen + organisation recipients) but as a CLI script — drop-in starting point for backend integrations. +Node.js example demonstrating how to use the [@e4a/pg-js](https://www.npmjs.com/package/@e4a/pg-js) SDK from a server runtime. Mirrors the [pg-sveltekit](../pg-sveltekit) example's "Informatierijk notificeren" flow (citizen + organisation recipients) as a CLI script. Drop-in starting point for backend integrations. ## What it does -Two modes, selected by the script flag: +Two modes, selected by an npm script: -1. **Send** (`npm run send`) — encrypts the input files for a citizen (exact email) and an organisation (email domain), uploads to Cryptify, and asks Cryptify to email each recipient a download link. -2. **Upload-only** (`npm run upload`) — same encryption + upload, but silent. Cryptify returns a UUID you can distribute through some other channel. +| Mode | Command | What it does | +| ----------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Send | `npm run send` | Encrypts the input files for a citizen (exact email) and an organisation (email domain), uploads to Cryptify, and asks Cryptify to email each recipient. | +| Upload-only | `npm run upload` | Same encryption and upload, but silent. Cryptify returns a UUID you can distribute through some other channel. | -Files come from `PG_INPUT_FILES` (comma-separated paths) or two in-memory demo files if that is unset. +Files come from `PG_INPUT_FILES` (comma-separated paths), or two in-memory demo files if that is unset. ## Prerequisites -- **Node.js 22+** — matches `@e4a/pg-js`'s `engines.node`. The SDK also supports Bun and Deno; the same encryption code in `src/encryption.mjs` works there too. +- **Node.js 22+**, matching `@e4a/pg-js`'s `engines.node`. The SDK also supports Bun and Deno; the same encryption code in `src/encryption.mjs` works there too. - A PostGuard for Business API key. ## Setup @@ -38,7 +40,7 @@ The script prints the resulting `uuid` and the corresponding `…/download?uuid= ## Staging Cryptify does not send email -The default `PG_CRYPTIFY_URL` is `storage.staging.postguard.eu` — the staging deployment. It **does not actually deliver notification emails**, so you can exercise the full upload + notify flow without spamming real inboxes while you integrate. +The default `PG_CRYPTIFY_URL` is `storage.staging.postguard.eu`, the staging deployment. It **does not actually deliver notification emails**, so you can exercise the full upload + notify flow without spamming real inboxes while you integrate. - The upload itself works. You get back a real UUID and the download URL is usable. - `npm run send` succeeds, but no recipient mail is sent. Open the printed URL yourself to verify the decrypt flow end-to-end. @@ -72,4 +74,4 @@ const sealed = pg.encrypt({ const { uuid } = await sealed.upload({ notify: { recipients: true, message, language: 'EN' } }); ``` -`notify` must be nested under an object — the SDK validates the shape and throws a clear `TypeError` if you pass `{ notify: true }` or forget to nest. See the [SDK README](https://github.com/encryption4all/postguard-js#server-side-usage-node-bun-deno) for the full server-side surface. +`notify` must be nested under an object. The SDK validates the shape and throws a clear `TypeError` if you pass `{ notify: true }` or forget to nest. See the [SDK README](https://github.com/encryption4all/postguard-js#server-side-usage-node-bun-deno) for the full server-side surface. diff --git a/pg-node/src/config.mjs b/pg-node/src/config.mjs index cbd2b7e..3bffbf6 100644 --- a/pg-node/src/config.mjs +++ b/pg-node/src/config.mjs @@ -1,5 +1,5 @@ -// Env-driven config. Run with `node --env-file=.env index.mjs` to load -// from .env (Node 20.6+). Mirrors pg-sveltekit's config.ts. +// Env-driven config. `.env` is loaded automatically by the npm scripts +// via Node's `--env-file-if-exists`. Mirrors pg-sveltekit's config.ts. export const PKG_URL = process.env.PG_PKG_URL || 'https://pkg.staging.postguard.eu'; export const CRYPTIFY_URL = process.env.PG_CRYPTIFY_URL || 'https://storage.staging.postguard.eu';