Add Masked print view: secrets shown with every digit hidden
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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(); }),
|
||||
|
||||
15
src/print.js
15
src/print.js
@@ -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),
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user