Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46d1e53656 | ||
|
|
db94730fa5 |
No files matched your search
@@ -28,37 +28,60 @@ jobs:
|
||||
timeout-minutes: 20
|
||||
permissions: {}
|
||||
steps:
|
||||
# A new deploy reaches Cloudflare's edge locations over a minute or so;
|
||||
# until then some requests still hit the previous version. Wait until the
|
||||
# commit has been served several times in a row.
|
||||
- name: Wait for this commit to go live
|
||||
if: github.event_name == 'push'
|
||||
env:
|
||||
SHA: ${{ github.sha }}
|
||||
run: |
|
||||
want="${SHA:0:7}"
|
||||
for attempt in $(seq 1 60); do
|
||||
streak=0
|
||||
for attempt in $(seq 1 90); do
|
||||
live=$(curl -fsS -A "$UA" --max-time 10 "$SITE/" | sed -n 's/.*<meta name="jsonprism-commit" content="\([0-9a-f]*\)".*/\1/p' | head -n 1 || true)
|
||||
if [ "$live" = "$want" ]; then
|
||||
echo "Production serves $live"
|
||||
exit 0
|
||||
streak=$((streak + 1))
|
||||
if [ "$streak" -ge 3 ]; then
|
||||
echo "Production serves $live"
|
||||
exit 0
|
||||
fi
|
||||
sleep 10
|
||||
continue
|
||||
fi
|
||||
streak=0
|
||||
echo "Attempt $attempt: live=${live:-unknown}, waiting for $want"
|
||||
sleep 15
|
||||
sleep 10
|
||||
done
|
||||
echo "::error::Production did not serve $want within 15 minutes. Check Workers Builds in the Cloudflare dashboard."
|
||||
exit 1
|
||||
|
||||
- name: Check headers, routes and API
|
||||
run: |
|
||||
set -euo pipefail
|
||||
fail() { echo "::error::$1"; exit 1; }
|
||||
headers=$(curl -fsSI -A "$UA" "$SITE/")
|
||||
for expected in "content-security-policy: default-src 'self'" "strict-transport-security: max-age=" "x-content-type-options: nosniff" "x-frame-options: deny"; do
|
||||
grep -qi "^$expected" <<<"$headers" || fail "Missing header: $expected"
|
||||
set -uo pipefail
|
||||
checks() {
|
||||
local headers expected old code
|
||||
headers=$(curl -fsSI -A "$UA" "$SITE/") || { echo "home page unreachable"; return 1; }
|
||||
for expected in "content-security-policy: default-src 'self'" "strict-transport-security: max-age=" "x-content-type-options: nosniff" "x-frame-options: deny"; do
|
||||
grep -qi "^$expected" <<<"$headers" || { echo "missing header: $expected"; return 1; }
|
||||
done
|
||||
[ "$(curl -sS -A "$UA" -o /dev/null -w '%{http_code}' "$SITE/about")" = 200 ] || { echo "/about is not served by the SPA fallback"; return 1; }
|
||||
old=$(curl -sS -A "$UA" -o /dev/null -w '%{http_code} %{redirect_url}' "$SITE/jsonPrism/about")
|
||||
[ "$old" = "301 $SITE/about" ] || { echo "/jsonPrism/about gave '$old', expected a 301 to /about"; return 1; }
|
||||
[ "$(curl -fsS -A "$UA" "$SITE/api/health")" = '{"ok":true,"service":"jsonprism"}' ] || { echo "/api/health is not healthy"; return 1; }
|
||||
curl -fsS -A "$UA" "$SITE/.well-known/security.txt" | grep -q '^Contact: mailto:security@poli0981.dev' || { echo "security.txt is missing or stale"; return 1; }
|
||||
code=$(curl -sS -A "$UA" -o /dev/null -w '%{http_code}' -X POST -H 'Origin: https://example.com' -H 'Content-Type: application/json' --data '{"token":"x"}' "$SITE/api/turnstile/verify")
|
||||
[ "$code" = 403 ] || { echo "/api/turnstile/verify answered $code to a foreign origin, expected 403"; return 1; }
|
||||
}
|
||||
# Retry briefly in case a request still lands on an edge location
|
||||
# that hasn't picked up the deploy yet.
|
||||
for attempt in 1 2 3 4; do
|
||||
if problem=$(checks); then
|
||||
echo "Production checks passed."
|
||||
exit 0
|
||||
fi
|
||||
echo "Attempt $attempt: $problem"
|
||||
sleep 20
|
||||
done
|
||||
[ "$(curl -sS -A "$UA" -o /dev/null -w '%{http_code}' "$SITE/about")" = 200 ] || fail "/about is not served by the SPA fallback"
|
||||
old=$(curl -sS -A "$UA" -o /dev/null -w '%{http_code} %{redirect_url}' "$SITE/jsonPrism/about")
|
||||
[ "$old" = "301 $SITE/about" ] || fail "/jsonPrism/about gave '$old', expected a 301 to /about"
|
||||
[ "$(curl -fsS -A "$UA" "$SITE/api/health")" = '{"ok":true,"service":"jsonprism"}' ] || fail "/api/health is not healthy"
|
||||
curl -fsS -A "$UA" "$SITE/.well-known/security.txt" | grep -q '^Contact: mailto:security@poli0981.dev' || fail "security.txt is missing or stale"
|
||||
code=$(curl -sS -A "$UA" -o /dev/null -w '%{http_code}' -X POST -H 'Origin: https://example.com' -H 'Content-Type: application/json' --data '{"token":"x"}' "$SITE/api/turnstile/verify")
|
||||
[ "$code" = 403 ] || fail "/api/turnstile/verify answered $code to a foreign origin, expected 403"
|
||||
echo "Production checks passed."
|
||||
echo "::error::$problem"
|
||||
exit 1
|
||||
@@ -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 **<https://jsonprism.poli0981.dev>** 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).
|
||||
|
||||
+2
-2
@@ -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) |
|
||||
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
Generated
+2
-2
@@ -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",
|
||||
|
||||
+1
-1
@@ -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 <code@poli0981.dev> (https://github.com/poli0981)",
|
||||
|
||||
+5
-3
@@ -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
|
||||
|
||||
Generated
+2
-2
@@ -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",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "jsonprism"
|
||||
version = "2.0.0"
|
||||
version = "2.0.1"
|
||||
description = "Disperse JSON into many formats."
|
||||
authors = ["poli0981 <code@poli0981.dev>"]
|
||||
license = "Apache-2.0"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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 (
|
||||
<div className={cn('h-full overflow-hidden', className)}>
|
||||
<CodeMirror
|
||||
// The wrapper div this component renders must fill the panel too, or
|
||||
// `height="100%"` has nothing to resolve against: the editor grows to
|
||||
// its content, gets clipped, and never scrolls.
|
||||
className="h-full"
|
||||
value={value}
|
||||
readOnly={readOnly}
|
||||
editable={!readOnly}
|
||||
|
||||
@@ -113,6 +113,17 @@ describe('CodeEditor — editable', () => {
|
||||
});
|
||||
});
|
||||
|
||||
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();
|
||||
|
||||
Reference in new issue
Block a user