Compare commits

...

2 Commits

Author SHA1 Message Date
8d1e1846e6 Update OVERVIEW.md for the Masked print view (Refs #31)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 14:00:58 -05:00
90e8a3a850 Add Masked print view: secrets shown with every digit hidden
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 13:39:48 -05:00
5 changed files with 29 additions and 7 deletions

View File

@@ -15,7 +15,7 @@ The owner keeps accounts, documents, contacts, wind-down steps and similar life-
| Crypto | WebCrypto: PBKDF2-SHA256 (600,000 iterations) into AES-256-GCM |
| Build | `build.js`: concatenates `src/*.js`, no bundler, no dependencies |
| Tests | `node --test` (built-in runner). Browser behavior was checked by hand with headless Chromium over CDP, which is not part of the repo. |
| Hosting / issues | Gitea (`gitea.ericthered.tech`), `gt` CLI. Issues #1–#19 track the work. |
| Hosting / issues | Gitea (`gitea.ericthered.tech`), `gt` CLI. Issues track the work (latest: #31). |
There are no npm dependencies and no CDN or network calls at runtime.
@@ -80,7 +80,7 @@ A **visual sequence** (`kind: 'sequence'`, numbered `frames` of image + text wit
**Upgrading app code, keeping data.** A file runs the code it was saved with. On the start screen, "Open your existing Final Wishes file" extracts the `#payload` from an older `.html`, unlocks it with the passphrase, and Save then writes it out with the newer code.
**Print.** Built only when Print is chosen and cleared on `afterprint`, so secrets don't linger in the DOM. It is a `<table>` whose `<thead>` holds the running header, which the browser repeats at the top of every page. Each section starts a new page (a section with sub-tabs gets a sub-heading per non-empty tab), records and sequence steps avoid page breaks inside them, and checklist items have tick boxes. The print dialog offers three views (issue #29): "withhold secrets" (default, mode `masked`), "lawyer's view" (`lawyer`: shows secrets flagged `lawyer: true`, still withholds plain secrets) "lawyer's summary" (`summary`, issue #30: `summaryGroups()` in `print.js` lists only records with lawyer-level text fields, each with just those fields, built by `printSummary()` in `app.js`) and "include secrets" (`complete`). `isHidden()`, `displayValue()`, `frameView()` and `usesView()` in `print.js` take the mode (a boolean still works: true is complete); `levelOf()`/`setLevel()` in `ops.js` keep the flags canonical and the edit UI uses a Normal/Lawyer/Secret select. Older builds read a lawyer-level item as a plain secret, which fails closed. `countByLevel()` feeds the dialog counts; `?reset=1` still erases lawyer-level values. Images are decoded before `window.print()`.
**Print.** Built only when Print is chosen and cleared on `afterprint`, so secrets don't linger in the DOM. It is a `<table>` whose `<thead>` holds the running header, which the browser repeats at the top of every page. Each section starts a new page (a section with sub-tabs gets a sub-heading per non-empty tab), records and sequence steps avoid page breaks inside them, and checklist items have tick boxes. The print dialog offers five views (issues #29, #30, #31): "withhold secrets" (default, mode `masked`), "lawyer's view" (`lawyer`: shows secrets flagged `lawyer: true`, still withholds plain secrets), "lawyer's summary" (`summary`, issue #30: `summaryGroups()` in `print.js` lists only records with lawyer-level text fields, each with just those fields, built by `printSummary()` in `app.js`) "Masked" (`obscured`, issue #31: like complete, but `maskDigits()` in `print.js` turns every digit in a secret value, and in a secret frame's text and if-stuck note, into a bullet; secret images and secret frames with a picture are withheld, because a picture can't be masked) and "include secrets" (`complete`). Note the naming trap: the UI label "Masked" is mode `obscured`, because `masked` already meant withhold. `isHidden()`, `displayValue()`, `frameView()` and `usesView()` in `print.js` take the mode (a boolean still works: true is complete); `levelOf()`/`setLevel()` in `ops.js` keep the flags canonical and the edit UI uses a Normal/Lawyer/Secret select. Older builds read a lawyer-level item as a plain secret, which fails closed. `countByLevel()` feeds the dialog counts; `?reset=1` still erases lawyer-level values. Images are decoded before `window.print()`.
## Integrations

View File

@@ -859,6 +859,7 @@
if (mode === 'summary') return printSummary(state.doc);
const doc = state.doc;
const kept = mode === 'complete' ? 'This copy INCLUDES passwords, PINs and other secrets. Keep it locked away (fire safe or sealed envelope).'
: mode === 'obscured' ? 'This is the MASKED copy. Secrets are shown, but every digit in them is replaced by \u2022. Pictures marked secret are withheld. Keep it locked away.'
: mode === 'lawyer' ? "This is the LAWYER'S VIEW. It includes account numbers and other details a lawyer needs, but the most private secrets (passwords, PINs, balances) are WITHHELD. Keep it locked away."
: 'Secrets (passwords, PINs, security answers) are WITHHELD from this copy. They are stored in the encrypted file.';
const content = [
@@ -896,6 +897,7 @@
radio('masked', true, 'Withhold secrets (safe overview; ' + plural(n.lawyer + n.secret) + ' hidden)'),
radio('lawyer', false, "Lawyer's view (shows " + n.lawyer + ' lawyer-level value' + (n.lawyer === 1 ? '' : 's') + '; ' + plural(n.secret) + ' hidden)'),
radio('summary', false, "Lawyer's summary (a short list of " + sum.records + ' record' + (sum.records === 1 ? '' : 's') + ' with lawyer-level values, ' + sum.values + ' value' + (sum.values === 1 ? '' : 's') + ')'),
radio('obscured', false, 'Masked (shows ' + plural(n.lawyer + n.secret) + ' with every number hidden)'),
radio('complete', false, 'Include secrets (full copy: store it securely)'),
h('div', { class: 'row' },
btn('Cancel', () => { dlg.close(); dlg.remove(); }),

View File

@@ -8,7 +8,11 @@ import { printGroups } from './ops.js';
// rest withheld) and 'complete' (everything). A boolean is accepted for older
// callers: true is 'complete', false is 'masked'. 'summary' is the lawyer's summary:
// it shows lawyer-level values like 'lawyer' does, but lists only those records (see summaryGroups).
export const PRINT_MODES = ['masked', 'lawyer', 'complete', 'summary'];
// 'obscured' is the "Masked" view: like 'complete', but every digit in a secret value is replaced
// by a bullet, so the shape of an answer shows without the number. Pictures can't be masked, so a
// secret image (or a secret frame with a picture) is withheld.
export const PRINT_MODES = ['masked', 'lawyer', 'complete', 'summary', 'obscured'];
export const maskDigits = (text) => String(text == null ? '' : text).replace(/\p{Nd}/gu, '\u2022');
export function normalizeMode(mode) {
if (mode === true) return 'complete';
return PRINT_MODES.includes(mode) ? mode : 'masked';
@@ -20,6 +24,7 @@ export function normalizeMode(mode) {
export function isHidden(item, mode) {
if (!item.secret) return false;
const m = normalizeMode(mode);
if (m === 'obscured') return item.kind === 'image' || !!item.image;
return m === 'complete' ? false : m === 'masked' ? true : !item.lawyer;
}
@@ -32,7 +37,8 @@ export function displayValue(field, mode) {
}
if (field.secret) {
if (!field.value) return '(not set)';
return isHidden(field, mode) ? '[withheld]' : field.value;
if (isHidden(field, mode)) return '[withheld]';
return normalizeMode(mode) === 'obscured' ? maskDigits(field.value) : field.value;
}
return field.value || '(blank)';
}
@@ -68,11 +74,12 @@ export function frameLayout(frame) {
export function frameView(frame, mode) {
const hasContent = !!(frame.image || String(frame.text || '').trim() || String(frame.ifStuck || '').trim());
const withheld = isHidden(frame, mode) && hasContent;
const m = frame.secret && normalizeMode(mode) === 'obscured' ? maskDigits : (x) => x;
return {
withheld,
image: withheld ? '' : frame.image,
text: withheld ? '' : frame.text,
ifStuck: withheld ? '' : String(frame.ifStuck || '').trim(),
text: withheld ? '' : m(frame.text),
ifStuck: withheld ? '' : m(String(frame.ifStuck || '').trim()),
stop: withheld ? false : !!frame.stop,
layout: withheld ? 'none' : frameLayout(frame),
};

View File

@@ -2,7 +2,7 @@
// YYMMDD is the date, X the iteration that day (A first, B second, ...).
// Bump with `npm run bump` (see bump-version.js). build.js strips `export`.
export const APP_VERSION = '261127A';
export const APP_VERSION = '261201A';
const VERSION_RE = /^(\d{6})([A-Z])$/;
export const isVersion = (v) => typeof v === 'string' && VERSION_RE.test(v);

View File

@@ -158,3 +158,16 @@ test("the summary mode shows lawyer values like the lawyer's view and keeps plai
assert.equal(isHidden(acct.num, 'summary'), false);
assert.equal(isHidden(acct.amt, 'summary'), true);
});
test('obscured ("Masked") view shows secrets with every digit replaced; images are withheld', () => {
const pin = { label: 'PIN', value: 'ab 1234-x9', secret: true };
assert.equal(displayValue(pin, 'obscured'), 'ab ••••-x•');
assert.equal(displayValue({ label: 'n', value: 'Ann 5', secret: false }, 'obscured'), 'Ann 5');
assert.equal(displayValue({ label: 'p', value: '', secret: true }, 'obscured'), '(not set)');
assert.equal(displayValue({ label: 'c', kind: 'image', value: 'data:x', secret: true }, 'obscured'), '[withheld]');
const fr = frameView({ image: '', text: 'PIN 4321', ifStuck: 'call 555', layout: 'under', secret: true }, 'obscured');
assert.equal(fr.withheld, false);
assert.equal(fr.text, 'PIN ••••');
assert.equal(fr.ifStuck, 'call •••');
assert.equal(frameView({ image: 'data:x', text: 't', layout: 'under', secret: true }, 'obscured').withheld, true);
});