Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

---

## [1.10.6] — 2026-11-02

### Security
- **A Content Security Policy limits where FinLens can send your data.** `index.html` now starts with a CSP `<meta>` tag. Its key rule is `connect-src`: scripts can only reach the Anthropic API (and the page's own origin), so code that got into the page, from a tampered library or an injection, can't post your transactions to another server with `fetch()` or XHR. Remote images are blocked too, which closes image beacons. Scripts can load only from FinLens's own files and five exact CDN file URLs.
- **Limit:** `'unsafe-inline'` stays in `script-src`, because many views use inline `onclick` handlers. The CSP restricts where injected inline script can send data, not whether it runs. Removing it is a larger refactor.
- **Every CDN script is pinned with an SRI hash.** Chart.js, PapaParse and Day.js had none, so a tampered or changed CDN copy would have run with full access to your data. All three now have `integrity` attributes, like marked and DOMPurify already did. A file that doesn't match is blocked instead of run.
- **All five libraries now load from jsDelivr's npm mirror.** Chart.js, PapaParse and Day.js moved from cdnjs to the same versions on jsDelivr, which serves the published npm files byte for byte. Each hash was computed from the npm package and can be re-checked the same way; the existing marked and DOMPurify hashes match their npm packages too.

### Docs
- **CLAUDE.md §2** — SRI on every CDN script, how to recompute a hash, the CSP and its limits; **§15** — new CDN scripts need a hash and a CSP entry.

---

## [1.10.5] — 2026-11-02

### Fixed
Expand Down
30 changes: 23 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Until then, this section is the rule.

FinLens is a **single-origin, zero-build, vanilla JavaScript personal finance dashboard** that runs entirely in the browser. There is no server, no npm, no bundler, no framework, and no TypeScript. The entry point is `index.html`; everything else is a plain `.js` file in the `js/` folder.

**Current version:** v1.10.5 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release).
**Current version:** v1.10.6 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release).

**What it does:** Imports CSV exports from Ally Bank (Checking + Savings) and Chase credit cards, parses and normalizes them into a unified transaction model, and renders a multi-tab financial dashboard with budgeting, debt tracking, savings forecasting, investment planning, and Claude-powered AI analysis.

Expand All @@ -71,16 +71,32 @@ FinLens is a **single-origin, zero-build, vanilla JavaScript personal finance da
|---|---|---|
| Markup + CSS | Vanilla HTML5 / CSS custom properties | `index.html` |
| JavaScript | Vanilla ES2020+ (global scope) | `js/*.js` |
| CSV parsing | PapaParse | CDN 5.4.1 |
| Charts | Chart.js | CDN 4.4.1 |
| Date formatting | Day.js | CDN 1.11.10 |
| CSV parsing | PapaParse | jsDelivr 5.4.1 (pinned + SRI) |
| Charts | Chart.js | jsDelivr 4.4.1 (pinned + SRI) |
| Date formatting | Day.js | jsDelivr 1.11.10 (pinned + SRI) |
| Markdown render | marked.js | jsDelivr 15.0.12 (pinned + SRI) |
| HTML sanitizer | DOMPurify | jsDelivr 3.4.17 (pinned + SRI) |
| AI | Anthropic Messages API (`claude-sonnet-5-5`, `AI_MODEL` in `views-ai.js`) | Direct browser fetch |
| Persistence | `finlens-state.json` via File System Access API → IndexedDB → `localStorage` (see §4.5) | Browser native |
| IndexedDB | Native — `finlens_db` (all app data, §19) and `finlens_fs` (CSV folder handle, §14) | Browser native |

Scripts that render model output (marked, DOMPurify) are version-pinned with `integrity`/`crossorigin` attributes. When bumping either, recompute the SRI hash from the exact file and update both `index.html` and this table.
**Every CDN script is version-pinned with `integrity`/`crossorigin` attributes (v1.10.6),** and all five come from jsDelivr's npm mirror (`cdn.jsdelivr.net/npm/<pkg>@<version>/<file>`), which serves the published npm files byte for byte. That makes each hash checkable without the CDN: `npm pack <pkg>@<version>`, then `openssl dgst -sha384 -binary <file> | openssl base64 -A`. A file that doesn't match its hash is blocked and the app breaks visibly, which is the point: it fails closed.

**Content Security Policy (v1.10.6).** A `<meta http-equiv="Content-Security-Policy">` at the top of `index.html` limits what the page can load and where it can send data:

| Directive | Allows | Why |
|---|---|---|
| `default-src` | nothing | Anything not listed below is blocked |
| `script-src` | `'self'`, `'unsafe-inline'`, the five exact CDN file URLs | Own scripts, inline handlers (§12), pinned libraries only |
| `style-src` | `'self'`, `'unsafe-inline'`, Google Fonts CSS | All CSS is inline (§6) |
| `font-src` | Google Fonts files | |
| `img-src` | `'self'`, `data:`, `blob:` | Favicon is a `data:` URL; no remote images, so no image beacons |
| `connect-src` | `'self'`, `https://api.anthropic.com` | **The key line:** `fetch`/XHR can only reach the Anthropic API (and the page's own origin, for AI Eval samples over HTTP) |
| `object-src`, `base-uri`, `form-action` | nothing | |

- **When adding or bumping a library,** update the script tag, its hash, the exact URL in `script-src` and this table together. A URL missing from `script-src` is blocked even with a correct hash.
- **When calling a new remote API,** add its origin to `connect-src`, or the call is blocked with a console error.
- **Limits:** `'unsafe-inline'` means injected inline script would still run; the CSP limits where it can send data, not whether it runs. Dropping it needs every inline `onclick` replaced with `addEventListener`. A `<meta>` CSP can't set `frame-ancestors` or report violations; those need HTTP headers, which a `file://` page doesn't have. Navigations (links, `location`) aren't covered by CSP.

**No build step.** Open `index.html` in Chrome/Edge/Arc/Brave and it just works. Safari and Firefox are supported but degrade gracefully on File System Access API features.

Expand Down Expand Up @@ -704,7 +720,7 @@ The handle lives in a separate `finlens_fs` database (distinct from `finlens_db`
- **Do not add npm, a bundler, or a build step.** The project is intentionally zero-dependency local.
- **Do not use ES module `import/export`** — all files share global scope by design.
- **Do not use `async`/`await` in view render functions** — renders are synchronous. Async work (API calls, file I/O) belongs in handler functions, not in the `registerView` callback.
- **Do not add new CDN scripts without adding them to `index.html`** and documenting the version in this file.
- **Do not add new CDN scripts without adding them to `index.html`** with an SRI hash, adding the exact URL to the CSP `script-src`, and documenting the version in §2.
- **Do not call `localStorage` directly** — always use `lsSet`/`lsGet`.
- **Do not create CSS files** — all CSS belongs in the `<style>` block in `index.html`.
- **Do not hard-code colors** — use CSS custom properties.
Expand Down Expand Up @@ -798,7 +814,7 @@ Multiple Chase card files can be loaded simultaneously. Each gets a unique `acco

---

*Last updated: v1.10.5 — 2026-11-02 (no section changes: Import Logs race fix; v1.10.4: §8, §13 single `~` is literal; §21 excerpts escape `~`; v1.10.3: §13 refusals; §21 declined runs; v1.10.2: §13 summary states its dates; §21 per-month derivations; v1.10.1: §13 `AI_MAX_TOKENS`, thinking and cut-off answers; v1.10.0: §21 AI Eval added; §13 `callClaude()` raw mode; v1.9.6: §14 folder access lasts until the last tab closes, not one page load; v1.9.5: §7 chart guard; v1.9.4: views-db.js changelog reads CRLF checkouts; v1.9.3: §14 folder permission: re-request on click, Reconnect banner, browser copy wins; v1.9.2: §0 branch, PR and approval workflow added; v1.9.1: §4.5 rehydrate transactions loaded from JSON; v1.9.0: §20 Data & Reset added; v1.8.1: §10 re-upload dedup rewritten for the occurrence-suffix fix; v1.8.0: AI Analysis restored with API-key and output hardening; `renderMarkdown()` added; `samples/` added; §1–3, §13, §14, §17 corrected to match the code)*
*Last updated: v1.10.6 — 2026-11-02 (§2 SRI on every CDN script, Content Security Policy; §15 new CDN scripts need a hash and a CSP entry; v1.10.5: no section changes: Import Logs race fix; v1.10.4: §8, §13 single `~` is literal; §21 excerpts escape `~`; v1.10.3: §13 refusals; §21 declined runs; v1.10.2: §13 summary states its dates; §21 per-month derivations; v1.10.1: §13 `AI_MAX_TOKENS`, thinking and cut-off answers; v1.10.0: §21 AI Eval added; §13 `callClaude()` raw mode; v1.9.6: §14 folder access lasts until the last tab closes, not one page load; v1.9.5: §7 chart guard; v1.9.4: views-db.js changelog reads CRLF checkouts; v1.9.3: §14 folder permission: re-request on click, Reconnect banner, browser copy wins; v1.9.2: §0 branch, PR and approval workflow added; v1.9.1: §4.5 rehydrate transactions loaded from JSON; v1.9.0: §20 Data & Reset added; v1.8.1: §10 re-upload dedup rewritten for the occurrence-suffix fix; v1.8.0: AI Analysis restored with API-key and output hardening; `renderMarkdown()` added; `samples/` added; §1–3, §13, §14, §17 corrected to match the code)*

---

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> A zero-install, browser-native finance dashboard. Drop in your bank CSVs, get instant clarity on your money.

**Version:** v1.10.5 &nbsp;·&nbsp; **Stack:** Vanilla JS, HTML, CSS &nbsp;·&nbsp; **Install:** None
**Version:** v1.10.6 &nbsp;·&nbsp; **Stack:** Vanilla JS, HTML, CSS &nbsp;·&nbsp; **Install:** None

---

Expand Down Expand Up @@ -169,6 +169,7 @@ FinLens uses `claude-sonnet-5-5`.
- **Key storage** — the key is stored only in your browser (localStorage + IndexedDB). It is never written to `finlens-state.json`. Versions up to 1.7.0 did save it there; v1.8.0 moves it into browser storage on load and rewrites the file without it on the next save (click **Save Now** in **Settings → Import** to force it). For a personal, local-only app this is a deliberate trade-off; a multi-user deployment would proxy calls through a server holding the key in a secrets vault.
- **Prompt injection** — your financial summary is sent inside `<financial_data>` tags, and the system prompt tells Claude to treat that content as data, never as instructions (merchant descriptions come straight from bank CSVs).
- **Output rendering** — Claude's Markdown is converted with marked and sanitized with DOMPurify before it touches the page (`renderMarkdown()` in `core.js`). Scripts, event handlers and images are stripped, so injected text can't run code or exfiltrate data through image URLs. Both libraries are version-pinned with SRI hashes.
- **Content Security Policy** — every CDN library is pinned with an SRI hash, so a tampered copy is blocked instead of run, and a CSP lets the page send data only to the Anthropic API. Code that got into the page couldn't post your data anywhere else with `fetch()` or a remote image.

---

Expand Down Expand Up @@ -260,4 +261,4 @@ See [CHANGELOG.md](CHANGELOG.md) for the full release history.

---

*FinLens v1.10.5 — Built for one person's finances, designed to be useful for anyone's.*
*FinLens v1.10.6 — Built for one person's finances, designed to be useful for anyone's.*
26 changes: 19 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,30 @@
<title>FinLens — Personal Finances</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='8' fill='%2300C49A'/><text x='16' y='23' text-anchor='middle' font-size='15' font-weight='700' font-family='Sora,system-ui,sans-serif' fill='%230b1220'>FL</text></svg>">

<!-- Content Security Policy: limits what this page can load and where it can send data.
connect-src is the important line: scripts can only talk to the Anthropic API (and this
page's own origin, for the AI Eval sample files when served over HTTP), so injected or
tampered code can't post your data somewhere else with fetch() or XHR. Scripts are
limited to FinLens's own files plus five exact CDN files. 'unsafe-inline' is still
needed for scripts because many views use inline onclick handlers (CLAUDE.md §12).
Keep this list in step with CLAUDE.md §2 when adding or bumping a library. -->
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.js https://cdn.jsdelivr.net/npm/papaparse@5.4.1/papaparse.min.js https://cdn.jsdelivr.net/npm/marked@15.0.12/marked.min.js https://cdn.jsdelivr.net/npm/dompurify@3.4.17/dist/purify.min.js https://cdn.jsdelivr.net/npm/dayjs@1.11.10/dayjs.min.js; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src https://fonts.gstatic.com; img-src 'self' data: blob:; connect-src 'self' https://api.anthropic.com; object-src 'none'; base-uri 'none'; form-action 'none'">

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap" rel="stylesheet">

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.4.1/papaparse.min.js"></script>
<!-- marked + DOMPurify are pinned with SRI hashes: they render Claude's output, so a
tampered or silently upgraded CDN file must fail closed. All Markdown goes through
renderMarkdown() in core.js. -->
<!-- Every third-party script is pinned to an exact version and an SRI hash, so a tampered
or silently changed CDN file fails closed instead of running with access to your data.
All five come from jsDelivr's npm mirror, which serves the published npm files byte for
byte, so each hash can be checked against the npm package (CLAUDE.md §2).
marked + DOMPurify render Claude's output: all Markdown goes through renderMarkdown()
in core.js. -->
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.js" integrity="sha384-dug+JxfBvklEQdJ4AYuBBAIScUz0bVN73xpy273gcAwHjb3qI0fXmuYNaNfdyYJG" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/papaparse@5.4.1/papaparse.min.js" integrity="sha384-D/t0ZMqQW31H3az8ktEiNb39wyKnS82iFY52QPACM+IjKW3jDUhyIgh2PApRqJZs" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/marked@15.0.12/marked.min.js" integrity="sha384-948ahk4ZmxYVYOc+rxN1H2gM1EJ2Duhp7uHtZ4WSLkV4Vtx5MUqnV+l7u9B+jFv+" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.4.17/dist/purify.min.js" integrity="sha384-P0JNneQf81HOl9VwNXK76cQ9VMD6Nfsnepxb0cCOg8+UzEdzgPHAPV4wVQrvYQSx" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.10/dayjs.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs@1.11.10/dayjs.min.js" integrity="sha384-DpVxUeeBWjUvUV1czyIHJAjh+jYUZFu2lLakbdua5vbwOrBGi1UgaKCHjTC+x3Ky" crossorigin="anonymous"></script>

<style>
/* =============== THEME =============== */
Expand Down Expand Up @@ -326,7 +338,7 @@
<div style="margin-top:auto">
<a class="nav" data-view="settings">⚙️ Settings</a>
<div class="footer">
<div style="color:var(--text-3);font-size:11px">v1.10.5 · FinLens</div>
<div style="color:var(--text-3);font-size:11px">v1.10.6 · FinLens</div>
</div>
</div>
</aside>
Expand Down
2 changes: 1 addition & 1 deletion js/views-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function _renderGeneralSettings(root) {
</select>
</div>
</div>
<div class="muted" style="font-size:11.5px;margin-top:14px">FinLens v1.10.5 ·${State.transactions.length} transactions loaded${State.lastRefresh?' · Refreshed '+dayjs(State.lastRefresh).format('MMM D, YYYY h:mm A'):''}</div>`;
<div class="muted" style="font-size:11.5px;margin-top:14px">FinLens v1.10.6 ·${State.transactions.length} transactions loaded${State.lastRefresh?' · Refreshed '+dayjs(State.lastRefresh).format('MMM D, YYYY h:mm A'):''}</div>`;
root.appendChild(displayCard);

/* ---- Anthropic API Key ---- */
Expand Down