Signing in returned 200, but the browser never sent the session cookie
back, so every following request was a 401. The dashboard called the API
on another origin (http://localhost:8000): opened as 127.0.0.1:3000 or a
LAN address that is a different site, so the SameSite cookie was never
stored, and browsers also drop a Secure cookie over plain http.
- the web server proxies /api/* to API_PROXY_TARGET (http://api:8000 in
compose) and the client calls /api by default, so the cookie is
first-party on any host; NEXT_PUBLIC_API_BASE is now only for an API
on its own host
- /api is excluded from the locale middleware, and the proxy timeout is
raised to 10 minutes for large uploads and downloads
- AUTH_COOKIE_SECURE defaults to auto: Secure whenever the request came
over HTTPS, directly or via X-Forwarded-Proto; true/false force it
- .env.example, compose, both READMEs and the CHANGELOG updated
The dashboard stops storing the API token in localStorage (CodeQL
js/clear-text-storage-of-sensitive-data).
- every request goes out with credentials; writes carry the session's
CSRF token
- session state lives in memory and comes from GET /auth/session, kept
in sync across tabs with a BroadcastChannel
- pages guard with useRequireSignIn instead of reading the token
- the token earlier versions left in localStorage is wiped on load
- SECURITY.md: the code-scanning example for disposition 3 now says
the tracked issue has shipped
Closes#33
- CONTRIBUTING.fa.md follows the original section by section, in the
same order, with the terminology README.fa.md already uses (رونویسی،
ورکر، سلفهاست، داشبورد، فاینتیون)
- commands, code blocks, paths and commit prefixes stay in English so
they remain copy-pasteable; no command or number was changed
- both files get a language switcher line, like the READMEs
Closes#31
Groundwork for moving the dashboard token out of localStorage (#33),
where any XSS in the dashboard could read it.
- register, login and token-login also set the token as an HttpOnly,
Secure, SameSite cookie; the JSON body keeps api_token for API clients
- the API accepts the cookie when no bearer header is sent; bearer auth
(bot, scripts, OpenAI-compatible clients) is unchanged and needs no
CSRF token, since browsers never attach it on their own
- cookie-authenticated unsafe methods must send X-CSRF-Token: an HMAC of
the session token, so the server recomputes it without storing
anything and a cross-site page cannot derive it (403 otherwise)
- GET /auth/session returns the signed-in account and its CSRF token;
logout also clears the cookie
- CORS allows credentials for the explicit SOKHAN_CORS_ORIGINS list
- AUTH_COOKIE_SECURE / _SAMESITE / _MAX_AGE_DAYS, documented in
.env.example and passed through compose
The Latin-to-Persian mapping turned every comma into ، and the spacing
rule then added a space after it, so "1,000" came out as "1، 000": one
number split into two.
- a comma between a digit and exactly three more digits is a thousands
separator and is kept as is (Latin and Persian digits)
- a comma in a list of numbers (4090,4080) still becomes ، as before
Documents what the rule-based pass does today, case by case, before any
rule changes (#30):
- slash dates and fractions (1404/09/02, 2026/11/23, 1/2) stay intact
- Latin digits and words inside Persian sentences, decimals, version
numbers and clock times are left alone
- abbreviation dots (Dr.) count as terminal punctuation; a dot mid
sentence is untouched
- ellipses (… and ...) are terminal and tightened, so a trailing-off
question keeps its ellipsis instead of gaining a question mark
- repeated and mixed marks (!!!, ؟؟, ?!) are preserved, since they carry
the speaker's emphasis
An unwritable DATA_DIR (a root-owned volume, a full disk, a read-only
mount) made POST /jobs and POST /v1/audio/transcriptions fail with a
bare 500 and a PermissionError traceback, with nothing in the response
telling the client it was a server-side storage problem.
- save_upload raises StorageUnavailableError on any OSError while
creating DATA_DIR/audio or writing the file, and removes a partially
written file first
- one app-level handler turns it into 503 with a short detail; the real
error, including the path, goes only to the server log
- the API logs an error at startup when DATA_DIR is not writable, so a
bad volume shows up before the first upload
The email sat in the header row next to Sign out, truncated on medium
screens and hidden on small ones.
- an avatar with the email's initial opens a menu with the full email
and Sign out
- the menu closes on outside click and Escape, returns focus to the
avatar, and opens towards the inline end so it fits in RTL and LTR
- accounts without a known email get a generic avatar and "Signed in"
Signing in now lives in the header, so the landing page's second
button only repeated it.
- the hero keeps a single "Get started" call to action, which sends
signed-out visitors to the login page
- removes the LoginCta component and the unused loginCta strings
- an eye button inside the password field switches it between hidden
and plain text; it is labelled for screen readers, exposes its state
with aria-pressed and resets when the sign-in mode changes
- the field stays LTR, so the button sits at its right edge in both
languages
- the archive re-fetches every 3 s while any job is queued or
processing; it loaded once, so its progress bars never moved
- ProgressBar shows a moving bar while no progress has been reported
yet, with "Getting ready" in place of 0%, and falls back to a pulse
under prefers-reduced-motion
- the job page uses the translated percent string, so English no
longer shows the Persian percent sign
Progress was only saved after each 30-second chunk, so a clip shorter
than 30 s (one chunk) sat at 0% for the whole job, model load included,
and then jumped to 100%.
- the Whisper engine calls an optional on_progress callback with how far
into the chunk it is, as faster-whisper yields each segment
- the pipeline maps that onto overall progress (by chunk count, or by
the duration estimate when streaming) and saves it monotonically,
below 100 and at most once a second
- engines opt in with reports_progress; ones with the plain
three-argument transcribe keep working unchanged
After signing in nothing showed that you were signed in, and there was
no way to sign out.
- the header shows Sign in when signed out, and the account email plus
Sign out when signed in (Telegram placeholder emails are not shown)
- sign out calls POST /auth/logout, then clears the local session even
if the API is unreachable, and goes to the login page
- the landing page's sign-in button is hidden for a signed-in user, and
the login page redirects them to the upload page
- a useSession hook (useSyncExternalStore) keeps every component in
sync across sign-in and sign-out, including other tabs
Signing out of the dashboard only forgot the token in the browser; the
token itself stayed valid for anyone who had copied it.
- POST /auth/logout replaces the stored hash with one of a fresh random
token that is never returned, then answers 204
- an account has a single active token, so this signs out every client
holding it, the same way a new sign-in already does
- a revoked token is rejected by every endpoint, including token-login
The bot caches one API token per chat and reuses it forever. A newer
sign-in for the same account (or a logout) revokes that token, after
which every request from the chat failed and /start kept showing a dead
connect code.
- the client raises AuthError on 401 from upload, job and quota calls
- handlers run API calls through _authed: on AuthError the cached token
is dropped, the chat re-registers once and the call is retried
- /start checks the cached token before showing it as the connect code
- the completion poller, which has no Telegram user to re-register
with, untracks the job and asks the chat to send /start
- TokenStore.forget drops a chat's token
- HF_HOME=/data/huggingface on api and worker: the model cache sat in
the container filesystem, so every recreate (down/up, --build, a new
image) re-downloaded the model weights — and transcription failed
outright wherever the Hugging Face Hub is unreachable
- the postgres healthcheck probes $POSTGRES_USER / $POSTGRES_DB instead
of a hardcoded sokhan
- compose interpolates from the .env next to deploy/docker-compose.yml,
not the one at the repo root: the quickstart in both READMEs and the
.env.example header now say cp .env.example deploy/.env, and the
missing-password error names that path
- ThemeToggle (sun/moon) in the site header; an explicit choice is
saved in localStorage, otherwise prefers-color-scheme decides and OS
changes are followed live
- an inline <head> script sets html.dark before first paint, so there
is no flash of the wrong theme; suppressHydrationWarning on <html>
covers the class it adds
- globals.css remaps the Tailwind palette under html.dark (stone
inverted, accent tints darkened, text-only accent shades lifted)
instead of adding dark: to ~230 utilities across 8 files; solid
teal/red keep their value for white-on-accent buttons, with targeted
overrides where they double as a text colour
- per-scheme themeColor; fa/en labels for the toggle
POST /auth/login accepted unlimited password guesses.
- FailureThrottle: thread-safe sliding window kept in process (the
compose stack runs a single uvicorn process)
- keyed by (client address, email): an attacker cannot lock a victim
out from everywhere, and users behind one NAT are not punished for
each other's typos
- after LOGIN_MAX_FAILURES (10) failures within
LOGIN_FAILURE_WINDOW_SECONDS (900) the endpoint answers 429 with
Retry-After; a successful login clears the count; 0 disables it
callback_url only had to start with http(s)://, so any user could make
the worker POST to loopback, the compose network (postgres, redis),
link-local cloud metadata or the LAN.
- upload time: literal private, loopback and link-local hosts and
localhost are rejected with 422 (no DNS lookup on the request path)
- delivery time: a guarded create_connection resolves once, refuses
the host if any address is non-public and connects to the vetted
address itself, so DNS rebinding cannot swap in a private IP after
the check
- redirects are not followed and *_PROXY env vars are ignored for
callbacks
- WEBHOOK_ALLOW_PRIVATE_TARGETS=true restores the old behaviour for
trusted single-tenant installs (e.g. n8n on the LAN)
BREAKING CHANGE: callbacks to private addresses now need
WEBHOOK_ALLOW_PRIVATE_TARGETS=true.
The MAX_UPLOAD_MB check in POST /jobs and /v1/audio/transcriptions ran
after file.file.read(): Starlette had already spooled the whole
multipart body to a temp file and the handler then loaded it into RAM,
so one multi-gigabyte upload from any registered user could exhaust the
API container.
- BodySizeLimitMiddleware answers 413 up front from Content-Length, or
mid-stream by counting bytes for chunked bodies (FastAPI re-raises
the HTTPException from body parsing)
- the cap is MAX_UPLOAD_MB plus 1 MiB of multipart framing; registered
before CORS so browsers can read the 413
- measured on the compose stack: a 250 MB chunked upload is cut off
with 413 while the API stays at ~89 MB RSS and /tmp stays empty
The endpoint minted a fresh API token for whatever telegram_id the
caller sent. Telegram ids are not secret (anyone sharing a group sees
them), so any client that could reach the API could log in as any
Telegram user: read and delete their transcripts, spend their quota and
rotate their token out from under the bot.
- new BOT_API_SECRET; require_bot checks X-Bot-Secret with
compare_digest, mirroring require_admin: 403 on a wrong or missing
secret, 503 while unset
- the bot sends the header and refuses to start without the secret
- tests: rejected without / with a wrong secret, disabled while unset,
bot client sends the header
BREAKING CHANGE: deployments running the bot must set the same
BOT_API_SECRET on the API and the bot.
Uploaded audio lives under DATA_DIR (/data, the sokhan-data named
volume). The image never created that directory, so Docker made the
mount point root-owned on first start and every upload failed with
PermissionError once the process runs as appuser.
Docker seeds a new named volume with the mount point's ownership, so
creating /data/audio in the image, owned by appuser, fixes fresh
installs without an entrypoint chown.
Every decision below is measured on the 12-clip Common Voice fa fixture
with a reproducible harness; no number is hand-written.
- fa_polish module: orthographic-only repair (ZWNJ fusion, split
imperatives like 'بی پوش' -> 'بپوش', Arabic code points, digits).
Wired into the pipeline (FA_POLISH=true) and ported 1:1 to the browser
demo (16-case parity test vs Python). -3.6 WER points.
- Persian orthography initial_prompt as the default: whisper copies the
prompt's script style. -1.3 points (small), -4.8 (fine-tuned).
- Default engine small -> medium: 56.2% WER vs 75.0% (v2 harness) at
~1.1x realtime on 2 CPU cores. small stays the speed-first profile.
- Browser demo: default model base -> small (90.2% -> 75.0% under v2),
polished output identical to the server's shape.
- benchmarks/tune_decode.py: the sweep harness behind every decision
(prompt x beam x VAD x condition_on_previous_text).
- training/export_web_onnx.py: LoRA merge -> ONNX -> int8 -> HF Hub so
the next fine-tune can run inside the browser demo.
- baseline.json regenerated for the v2 harness; weekly benchmark now
guards small AND medium; gate test updated.
Fixture: small 80.5% -> 75.0%, fine-tuned 79.3% -> 75.0%, medium 56.2%.
Root causes of the eternal 'processing' state:
- worker dropped every command: Chromium 158+ posts dedicated-worker
messages with an EMPTY event.origin, so the strict origin guard
rejected them all; now only foreign origins are rejected
- decodeAudioData inside a forced 16 kHz AudioContext can wedge on
opus/webm in Chromium; decode now runs at the natural rate and is
resampled offline to 16 kHz with a 45 s watchdog
Speed:
- WebGPU fast path (fp32 encoder + q4 decoder) with automatic WASM/q8
fallback and a one-time mid-run GPU->CPU retry on driver errors
- windowing moved into the worker (30 s window / 5 s overlap,
timestamp-midpoint trim) enabling true per-window progress
UX:
- per-window progress + ETA + elapsed timer + stage pills + device badge
- cancel button that terminates the worker (model stays in cache)
- timestamped line-by-line transcript toggle + copy button
- hard caps: 30 min WebGPU / 10 min WASM / 60 MB per file, with clear
Persian messages — no input can wedge the demo anymore
Reading and reviewing the code stays free, noncommercial use stays free;
any commercial use now requires a paid license from the author.
Releases through v1.4.1 remain MIT.
Release prep so the tag-driven pipeline can do its job:
- __version__ 1.4.0 -> 1.4.1 in backend, bot and web package.json
(dynamic packaging reads these)
- Unreleased becomes [1.4.1] - 2026-11-26: the security fixes, the new
workflows (Release, Scorecard, PR title check, compose smoke), the
hardening (timeouts/concurrency/pinning/SBOM/permissions), branch
protection, docs truthfulness and the privacy sections — one
consolidated section per Keep-a-Changelog
- CITATION.cff tracks 1.4.1 / 2026-11-26
- landing eyebrow and the 1200x630 og-image regenerate as v1.4.1
- extract_release_notes.py verified against the new section (91 lines
of notes for the workflow to publish)
The first Scorecard run scored Token-Permissions 0 because ci.yml and
sync-space.yml had no explicit permissions block (they inherit the
default write-everything token). Both now declare contents: read —
matching what every other workflow already did — which should take
that check to 10 on the next weekly run.
Scorecard's next run surfaced two more specifics:
- upload-sarif rejected results_file (old input name); the modern
input is sarif_file — the default fell back to ../results and the
step failed with 'Path does not exist'. Scorecard analysis itself
ran fine; only the SARIF upload was misconfigured
- GitHub deprecates CodeQL Action v3 in December 2026 — weeks away —
and the runner logs flagged Node 20 on checkout/upload-artifact
Everything moves to the newest major with Node 24: codeql-action v4,
checkout v5, setup-python v6, upload-artifact v5, upload-pages-artifact
v4, login-action v4, metadata-action v6, build-push-action v7 (deploy-
pages v5 / configure-pages v6 / setup-buildx-action v4 stay: no newer
major exists). All SHAs resolved from the Git refs API with annotated
tags peeled to commits, verified via the commits endpoint.
Two CI failures taught two lessons:
1. Scorecard's webapp verifies every pinned action belongs to its repo
and rejected 'imposter commit 945b7d9...' — the ref API had returned
the annotated tag OBJECT id for codeql-action@v3, not the commit.
The other twelve tags were lightweight, so only codeql-action was
affected; init/analyze/upload-sarif now pin 74c1aea (a verified
commit from 2026-11-24).
2. Pages still raced even with the artifact-visibility wait: the Pages
metadata service converges a few seconds after the Actions artifacts
API, and delete+upload in one run poisons the first deploy attempt.
Deploy now runs as two attempts with a 20 s settle gap; the
environment URL falls back to the retry step's output.
Both fixes verified against the GitHub API, not guessed.
Phase E of professionalization round 3:
- New weekly Scorecard workflow (ossf/scorecard-action, publish_results
on): grades the supply-chain posture and posts SARIF to the Security
tab — complements CodeQL, which grades code, with a grade of process
- README badges (both languages): CodeQL, benchmark gate, Release tag,
and the public OpenSSF Scorecard badge join CI/Docker/Space/landing
- 'Data and privacy' sections in README.md and README.fa.md: explicit
story for a product that handles recordings — self-hosted audio
stays on the operator's machine (verified: delete_job unlinks the
stored file, outbound calls exist only in the operator-configured
webhook and optional LLM summary), the browser demo uploads nothing,
zero telemetry
Phase D: the compose job used to only parse the file. Now it actually
builds the API image, starts postgres + redis + api with the same
compose file self-hosters use, polls /healthz for up to 3 minutes,
asserts /plans exposes both free and pro tiers and /docs renders, then
tears everything down with a trap. This catches deployment-wiring
breaks (bad env passthrough, broken entrypoint, migration failure)
that unit tests structurally cannot see.
Phase C of professionalization round 3:
- New Release workflow: pushing a v* tag extracts the matching
CHANGELOG.md section (scripts/extract_release_notes.py) and creates
or updates the GitHub Release — the changelog stays the single
source of truth and releases stop being manual API calls
- The extractor fails loudly on a tag without a section, so an
unnoticed version mismatch cannot ship empty notes
- Tested both paths locally: v1.4.0 yields the full section, a bogus
version exits 1 with the hint to add one
Professionalization round 3, phase A+B:
- Every job gets an explicit timeout-minutes (pr: 5, compose: 10,
sync/pages/web: 10-15, ci/codeql: 30, docker: 40, benchmark: 60) —
hung jobs no longer burn the runner hour silently
- CI gets a concurrency group with cancel-in-progress (stale pushes
stop superseding runs early)
- GHCR builds now attach SBOM + max-mode provenance attestations
(verifiable via docker buildx imagetools inspect) — supply-chain
metadata ships with every image
- New PR title check: Conventional Commits enforced on pull_request
titles, matching the discipline CONTRIBUTING.md already declares
- All third-party actions pinned to full commit SHAs (with trailing
'# vX' comments so Dependabot keeps updating them): removes the
tag-retargeting attack surface and satisfies the OpenSSF Scorecard
pinned-dependencies check
Validated: all seven workflow YAMLs parse.
The artifact metadata service is eventually consistent: with the
delete-stale + upload sequence, deploy-pages fetched an empty artifact
list ('No artifacts named github-pages were found') in the same second
the upload registered. The workflow now polls for the artifact to
become visible (up to 45 s) before deploying, making the pipeline
deterministic instead of racing.
The cleanup step deletes artifacts via the REST API, which requires
the actions:write permission the workflow did not request — the step
failed with 'Resource not accessible by integration'.
deploy-pages fails with 'multiple artifacts with the name
github-pages found' whenever a previous artifact survives retention —
which bit us twice this week and needed manual API surgery. The
workflow now clears stale github-pages artifacts before uploading, so
deploys are self-healing; retention also lowered to 3 days since the
artifact is consumed immediately by deploy-pages.