diff --git a/CHANGELOG.md b/CHANGELOG.md index f9089f0..73aa7f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and No unreleased changes at this time. Future work tracked in `docs/ROADMAP.md` under "Beyond". +## [2.0.1] — 2026-10-22 + +### Fixed + +- **The editor and the output panel scroll again.** The wrapper `@uiw/react-codemirror` renders around the editor had no height, so both editors grew to fit their content inside a clipped panel: long input or output could not be scrolled with the mouse, touch or keyboard. The wrapper now fills its panel. The read-only output's scroll container also takes keyboard focus, so the arrow and page keys scroll it, without making the output editable (which would open the on-screen keyboard on phones). +- **Fewer console errors.** The content security policy now allows WebAssembly (`'wasm-unsafe-eval'`, which still forbids JavaScript `eval`) on the website and in the apps, so the bson library's small 64-bit math helper no longer logs a violation (it fell back to JavaScript before). `browsing-topics` was removed from the `Permissions-Policy` header, which Brave and Firefox reported as an unknown feature. The remaining messages come from inside Cloudflare's Turnstile frame, which has its own policy. +- **Production smoke check.** After a deploy it now waits until the new version answers several times in a row and retries before failing, because a deploy takes a moment to reach every Cloudflare edge location. + ## [2.0.0] — 2026-10-22 A new home, a hardened toolchain and a full audit. The web app moves to **** on Cloudflare Workers; the old GitHub Pages address redirects there, keeping the path. Because the website now uses Cloudflare services, the Privacy Policy and Terms are at version 2.0 and **everyone is asked to accept them again** (`CONSENT_VERSION` 2). diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md index 5f7f037..ddbf226 100644 --- a/docs/DEPLOYMENT.md +++ b/docs/DEPLOYMENT.md @@ -196,11 +196,11 @@ Vite copies `public/` into `dist/`; Workers Static Assets applies `_headers` and | Header | Value | | --- | --- | -| `Content-Security-Policy` | `default-src 'self'`; scripts from self, `static.cloudflareinsights.com` and `challenges.cloudflare.com`; `connect-src` self + `cloudflareinsights.com`; `frame-src` Turnstile; `worker-src 'self'`; `object-src 'none'`, `base-uri 'self'`, `form-action 'self'`, `frame-ancestors 'none'`, `upgrade-insecure-requests`. `style-src` keeps `'unsafe-inline'` (CodeMirror, Radix and Sonner inject styles at runtime). | +| `Content-Security-Policy` | `default-src 'self'`; scripts from self, `static.cloudflareinsights.com` and `challenges.cloudflare.com`, plus `'wasm-unsafe-eval'` (WebAssembly only, for bson's 64-bit math helper); `connect-src` self + `cloudflareinsights.com`; `frame-src` Turnstile; `worker-src 'self'`; `object-src 'none'`, `base-uri 'self'`, `form-action 'self'`, `frame-ancestors 'none'`, `upgrade-insecure-requests`. `style-src` keeps `'unsafe-inline'` (CodeMirror, Radix and Sonner inject styles at runtime). | | `Strict-Transport-Security` | `max-age=31536000`, deliberately without `includeSubDomains` | | `X-Content-Type-Options`, `X-Frame-Options` | `nosniff`, `DENY` | | `Referrer-Policy` | `strict-origin-when-cross-origin` | -| `Permissions-Policy` | camera, microphone, geolocation, motion sensors, payment, USB and Topics all disabled | +| `Permissions-Policy` | camera, microphone, geolocation, motion sensors, payment and USB disabled (`browsing-topics` was dropped in 2.0.1: Brave and Firefox log it as an unknown feature, and the site runs no ad code) | | `Cross-Origin-Opener-Policy` | `same-origin` | | `Cache-Control` | HTML `no-cache, no-transform`; `/assets/*` `public, max-age=31536000, immutable` (hashed file names) | diff --git a/docs/TAURI-NOTES.md b/docs/TAURI-NOTES.md index 8ef7eb2..e3d187b 100644 --- a/docs/TAURI-NOTES.md +++ b/docs/TAURI-NOTES.md @@ -87,10 +87,11 @@ Widening the scope requires both a capability edit and a CSP review in `app.security.csp` in `tauri.conf.json`: ``` -default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; script-src 'self'; connect-src 'self' ipc: http://ipc.localhost; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none' +default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; script-src 'self' 'wasm-unsafe-eval'; connect-src 'self' ipc: http://ipc.localhost; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none' ``` - 2.0.0 added `object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'`. +- 2.0.1 added `'wasm-unsafe-eval'` to `script-src`: bson compiles a tiny WebAssembly helper for 64-bit math (it falls back to JavaScript when blocked, but every WebView logged a CSP violation). - No third-party origins. Cloudflare Turnstile and Web Analytics are web-only and compiled out of Tauri builds (`__IS_TAURI_BUILD__`), so this CSP never needs their hosts. The web CSP lives in `public/_headers` — see diff --git a/package-lock.json b/package-lock.json index c4cff4c..68a8df1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "jsonprism", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "jsonprism", - "version": "2.0.0", + "version": "2.0.1", "license": "Apache-2.0", "dependencies": { "@codemirror/lang-json": "^6.0.2", diff --git a/package.json b/package.json index fc628d7..dc3125d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jsonprism", "private": true, - "version": "2.0.0", + "version": "2.0.1", "type": "module", "description": "Disperse JSON into 12 formats (six convert back) — JSONL, CSV, TSV, YAML, XML, TOML, RESX, Markdown, SQL, BSON, CBOR, MessagePack. Conversion runs locally in your browser or desktop app.", "author": "poli0981 (https://github.com/poli0981)", diff --git a/public/_headers b/public/_headers index 4bb529f..3218217 100644 --- a/public/_headers +++ b/public/_headers @@ -2,18 +2,20 @@ # API responses from worker/ set their own headers. # # CSP notes: -# - script-src: the Cloudflare Web Analytics beacon and the Turnstile widget. +# - script-src: the Cloudflare Web Analytics beacon and the Turnstile widget; +# 'wasm-unsafe-eval' lets bson compile its small WebAssembly helper for +# 64-bit math (it allows WebAssembly only, not JavaScript eval). # - style-src 'unsafe-inline': CodeMirror, Radix and Sonner inject styles at runtime. # - connect-src: the analytics beacon reports to cloudflareinsights.com (or /cdn-cgi/rum). # - frame-src: the Turnstile challenge iframe. # - worker-src 'self': the conversion Web Worker. /* - Content-Security-Policy: default-src 'self'; script-src 'self' https://static.cloudflareinsights.com https://challenges.cloudflare.com; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self' https://cloudflareinsights.com; frame-src https://challenges.cloudflare.com; worker-src 'self'; manifest-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests + Content-Security-Policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval' https://static.cloudflareinsights.com https://challenges.cloudflare.com; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self' https://cloudflareinsights.com; frame-src https://challenges.cloudflare.com; worker-src 'self'; manifest-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests Strict-Transport-Security: max-age=31536000 X-Content-Type-Options: nosniff X-Frame-Options: DENY Referrer-Policy: strict-origin-when-cross-origin - Permissions-Policy: accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=(), browsing-topics=() + Permissions-Policy: accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=() Cross-Origin-Opener-Policy: same-origin # HTML must revalidate so a deploy is picked up; no-transform keeps zone # features (Rocket Loader, Email Obfuscation) from rewriting pages and diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 522d3e8..b441814 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler2" @@ -1876,7 +1876,7 @@ dependencies = [ [[package]] name = "jsonprism" -version = "2.0.0" +version = "2.0.1" dependencies = [ "serde", "serde_json", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index b537758..06ce393 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jsonprism" -version = "2.0.0" +version = "2.0.1" description = "Disperse JSON into many formats." authors = ["poli0981 "] license = "Apache-2.0" diff --git a/src-tauri/license.rtf b/src-tauri/license.rtf index 5a861cb..8781b2b 100644 --- a/src-tauri/license.rtf +++ b/src-tauri/license.rtf @@ -6,12 +6,12 @@ By installing and using JSONPrism, you agree to the terms below.\par \par JSONPrism is free, open-source software licensed under the Apache License 2.0:\par -https://github.com/poli0981/jsonPrism/blob/v2.0.0/LICENSE\par +https://github.com/poli0981/jsonPrism/blob/v2.0.1/LICENSE\par \par Your use is also governed by the following documents (version 2.0, effective 2026-10-22):\par -\bullet\tab Terms of Service (EULA): https://github.com/poli0981/jsonPrism/blob/v2.0.0/TERMS.md\par -\bullet\tab Privacy Policy: https://github.com/poli0981/jsonPrism/blob/v2.0.0/PRIVACY.md\par -\bullet\tab Disclaimer: https://github.com/poli0981/jsonPrism/blob/v2.0.0/DISCLAIMER.md\par +\bullet\tab Terms of Service (EULA): https://github.com/poli0981/jsonPrism/blob/v2.0.1/TERMS.md\par +\bullet\tab Privacy Policy: https://github.com/poli0981/jsonPrism/blob/v2.0.1/PRIVACY.md\par +\bullet\tab Disclaimer: https://github.com/poli0981/jsonPrism/blob/v2.0.1/DISCLAIMER.md\par \par JSONPrism is provided \ldblquote as is\rdblquote , without warranty of any kind. The desktop app converts everything on your device and makes no network requests of its own.\par \par diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index ef0c831..478dfb3 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -26,7 +26,7 @@ } ], "security": { - "csp": "default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; script-src 'self'; connect-src 'self' ipc: http://ipc.localhost; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" + "csp": "default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; script-src 'self' 'wasm-unsafe-eval'; connect-src 'self' ipc: http://ipc.localhost; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" } }, "bundle": { @@ -78,7 +78,7 @@ }, "android": { "minSdkVersion": 31, - "versionCode": 20000 + "versionCode": 20001 } }, "plugins": { diff --git a/src/components/converter/CodeEditor.tsx b/src/components/converter/CodeEditor.tsx index 9e21883..4e00b65 100644 --- a/src/components/converter/CodeEditor.tsx +++ b/src/components/converter/CodeEditor.tsx @@ -1,6 +1,11 @@ import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; -import CodeMirror, { EditorState, EditorView, type BasicSetupOptions } from '@uiw/react-codemirror'; +import CodeMirror, { + EditorState, + EditorView, + ViewPlugin, + type BasicSetupOptions, +} from '@uiw/react-codemirror'; import { json } from '@codemirror/lang-json'; import { yaml } from '@codemirror/lang-yaml'; import { xml } from '@codemirror/lang-xml'; @@ -108,6 +113,21 @@ const jsonlLint = linter((view) => { return diagnostics; }); +/** + * Read-only output isn't contenteditable (that would raise the on-screen + * keyboard on phones), so CodeMirror never moves a cursor through it and + * swallows the arrow keys. Make the scroll container itself focusable instead: + * the browser then scrolls it with the arrow and page keys. + */ +function focusableScroller(label: string | undefined) { + return ViewPlugin.define((view) => { + view.scrollDOM.tabIndex = 0; + view.scrollDOM.setAttribute('role', 'region'); + if (label) view.scrollDOM.setAttribute('aria-label', label); + return {}; + }); +} + function languageExtensions(language: EditorLanguage, readOnly: boolean) { switch (language) { case 'json': @@ -237,6 +257,7 @@ export function CodeEditor({ ...(ariaLabel ? { 'aria-label': ariaLabel } : {}), ...(readOnly ? { 'aria-readonly': 'true' } : {}), }), + ...(readOnly ? [focusableScroller(ariaLabel)] : []), theme, ]; }, [ariaLabel, language, phrases, readOnly, resolvedTheme, wrap]); @@ -244,6 +265,10 @@ export function CodeEditor({ return (
{ }); }); +describe('CodeEditor — sizing', () => { + // Regression: the wrapper @uiw/react-codemirror renders had no height, so the + // editor grew to its content inside an overflow-hidden panel and could not scroll. + it.each([false, true])('fills its panel so long documents scroll (readOnly=%s)', (readOnly) => { + const { root } = renderEditor({ value: 'x\n'.repeat(500), readOnly }); + const wrapper = root.parentElement!; + expect(wrapper).toHaveClass('cm-theme-none', 'h-full'); + expect(wrapper.parentElement).toHaveClass('h-full', 'overflow-hidden'); + }); +}); + describe('CodeEditor — read-only', () => { it('marks the content read-only and drops the editing chrome', () => { const { content, container } = renderEditor({ @@ -123,6 +134,12 @@ describe('CodeEditor — read-only', () => { }); expect(content).toHaveAttribute('contenteditable', 'false'); expect(content).toHaveAttribute('aria-readonly', 'true'); + // Regression: not contenteditable, so the scroll container takes focus and + // the browser scrolls it with the arrow and page keys. + const scroller = container.querySelector('.cm-scroller')!; + expect(scroller).toHaveAttribute('tabindex', '0'); + expect(scroller).toHaveAttribute('role', 'region'); + expect(scroller).toHaveAttribute('aria-label', 'YAML output (read-only)'); expect(content).toHaveAttribute('aria-label', 'YAML output (read-only)'); expect(container.querySelector('.cm-lineNumbers')).not.toBeNull(); expect(container.querySelector('.cm-activeLine')).toBeNull();