I built a file toolkit that can prove it never uploaded your file
56 image, PDF and video tools that run entirely in the browser. Bedrock plans the job, your machine does it, and a live counter proves nothing was uploaded.
Every few months I need to shrink a PDF to get under some portal's 500 KB limit. The first result
on Google does it in one click, for free. It also requires me to hand a bank statement to a server
I know nothing about, run by people I will never meet, in a jurisdiction I did not choose.
Everyone does it anyway. The file comes back smaller and nothing visibly bad happens.
I wanted to know whether the whole category could work the other way round: not "we promise we
delete your files after an hour", but no upload at all, and a way for you to check that claim
without taking my word for it.
That became Klyro — 56 image, PDF and video tools that run entirely in the browser tab, with a
live counter on every page showing how many bytes of file data have left your machine. It reads
zero, and it is reading your actual network activity, not a hard-coded string.
The shape of it
The unusual thing about the architecture is how little of it is server-side.
The browser does all the file work. PDFs go through
pdf-lib and pdf.js . Structural
operations — repair, linearise, encryption, garbage collection — go through qpdf compiled to
WebAssembly. OCR is tesseract.js with the language data vendored at build time rather than
pulled from a CDN. Video is mediabunny on top of WebCodecs, which means hardware-accelerated
encoding without shipping a 25 MB ffmpeg build. Image work runs in a Web Worker pool over
OffscreenCanvas so the UI does not freeze on a 40-megapixel photo.AWS does exactly one thing. You can type "merge these two and compress to 500 KB" instead of
hunting for tools. That sentence goes to Amazon Bedrock, and what comes back is a plan — a
list of steps you approve before anything executes. The steps then run locally.
The request that leaves your machine contains your instruction plus, for each file, its kind, MIME
type, size in KB, and whichever of page count, pixel dimensions or duration applies. About 350
bytes. Never the file. Never the filename unless you flip a switch.
- Amplify Hosting serves the static site from a monorepo,
appRoot: web.
- API Gateway (HTTP API) fronts the planner with a 2 rps / burst 5 throttle.
- Lambda,
nodejs22.xon arm64, 256 MB, 15 s timeout. It is stateless, holds no credentials of its own, and signs Bedrock calls with SigV4 from its execution role.
- Bedrock via the Mantle endpoint (
bedrock-mantle.ap-south-1.api.aws,bedrock-mantle:CreateInference), runningopenai.gpt-oss-120b.
- AWS Budgets watches the spend, because the endpoint is deliberately public and unauthenticated.
The enforcement is not in my code, it is in the browser. The site ships a Content-Security-Policy
whose
connect-src is:connect-src 'self' https://<api-id>.execute-api.ap-south-1.amazonaws.comTwo origins. That is the whole allowance. If a dependency I trusted turned malicious tomorrow and
tried to POST your document somewhere, the browser would refuse before the request left. It is the
one security control in the project that does not depend on me being careful.
What fought back
This is the part worth reading. Almost everything that went wrong was a case of something
appearing to work.
Deleting data from a PDF does not delete it
Klyro has a Privacy Check tool: find the name, the software, the old form values, the scripts and
attachments hiding inside a PDF, then strip them out. The first version looked correct and passed
its tests.
It did not remove anything.
pdf-lib gives you catalog.delete('Names') , which unlinks the entry. But pdf-lib serialises
every object it has ever registered when it saves, reachable or not. The XMP packet, the script
streams, the attachment bytes — all still sitting in the output file, findable with strings . I
had written an unlinker and called it a shredder.The fix was to stop hand-rolling it. After the
pdf-lib pass, the document goes through qpdf with:--object-streams=generate --remove-unreferenced-resources=yesqpdf rebuilds the object table by walking from the trailer, so anything unreachable is simply never
written. A correct mark-and-sweep in one line, using a WASM binary that was already in the bundle.
The test that proved it passed on a file that was still dirty
So I wrote the obvious test: strip a PDF whose author is "Registrar Office", then assert the string
is not in the output bytes.
It passed. It also passed on a file I had not stripped at all.
Two reasons, both invisible.
savePdf uses useObjectStreams: true and flate-compresses, so the
string is not sitting there in plain bytes to find. And pdf-lib writes document info as
UTF-16BE hex with a byte-order mark — Registrar Office is stored as
<feff005200650067...> , which does not match a naive Latin-1 search under any circumstances.The real test decompresses first (
--stream-data=uncompress --decode-level=all ), then searches for
each value in five encodings: Latin-1, raw UTF-16 bytes, ASCII hex, UTF-16 hex, and the
BOM-prefixed form.Then I added the thing I should have written first: a negative control that runs the same
assertion against a deliberately half-stripped file and requires it to fail. A negative assertion
nobody has watched fail is not a test, it is a decoration.
The scanner grading its own homework
Related, and worse. After stripping, the tool re-scanned the output with the same scanner and
reported "Nothing hidden found". Any blind spot in the scanner rendered as a green tick.
It now does something different. The scan records the actual identifying values it found, and
after stripping it searches the decompressed output for those specific strings. The UI shows the
count:
Re-scanned the output · 0 of 12 checks flaggedSearched 214 KB of uncompressed output for 5 recorded values · none foundUnreferenced objects · 0 (was 37)Searching for values you recorded earlier is a strictly stronger claim than re-running checks you
already know how to pass. I also changed the success message from "Nothing hidden found" to
"Nothing found by the checks this tool runs", because the first version was a claim about the file
and the second is an honest claim about the scanner.
The catalog.get() that silently returned the wrong thing
A smaller one with the same flavour. Detection used
catalog.get('Names') to find embedded
JavaScript. When that entry is an indirect reference — which it is in most real-world PDFs —
you get back a PDFRef , not the dictionary. No error, no exception, just a truthiness check
against an object that is never the shape you expected.Scripts and attachments in ordinary files were being missed entirely. The fix is
lookupMaybe ,
which resolves the reference, and it was already used correctly elsewhere in the same codebase.The compressor that made files bigger
A user-visible one: an 87 KB image came out at 93 KB when asked for 60 KB.
Two separate bugs. For video,
mediabunny 's new Quality(1_200_000) is a quality level, not a
bitrate — the constructor takes a number and means something entirely different by it. A 2 MB clip
compressed to 3 MB. The correct call is new Quality({ bitrate }) , and there is now a test
asserting the two forms produce different output, because that is the kind of mistake that reads
fine forever.For images, the search that hunts for a target size could overshoot and return a result heavier
than the input. There is now a rule at the boundary: compression never returns something bigger
than what it was given. If the best attempt is heavier, it keeps the original and says so.
Reserved concurrency you are not allowed to reserve
An AWS-specific one. I wanted a small reserved concurrency on the planner Lambda to cap the blast
radius of a runaway loop. CloudFormation rolled back:
Specified ReservedConcurrentExecutions for function decreases account'sUnreservedConcurrentExecution below its minimum value of [10].lambda:GetAccountSettings explained it: this account's total ConcurrentExecutions limit is 10,
and AWS requires 10 to stay unreserved. No reservation of any size is possible. Not a small one.
Not one.The ceiling moved to where it could actually be enforced — API Gateway throttling at 2 rps with a
burst of 5 — and the account's own limit does the rest. Worth knowing before you design around a
reservation on a new account.
The prompt that refused a feature that had already shipped
My favourite, because it was entirely self-inflicted. Late on, I tested the deployed planner with
"merge these two PDFs and compress to 500 KB" and got back zero steps and a polite explanation that
PDF compression is not supported.
It ships. It had shipped weeks earlier. The system prompt contained this line:
There is no PDF compression. If asked to shrink a PDF, set clarification explaining that only images can be compressed, and return no steps.
The tool catalogue had grown from 11 operations to 56 tools, and the planner's list had not moved.
Two schema files — one for the browser, one for the Lambda — carried a
// Keep in sync comment and
had drifted by eleven operations.Fixing the catalogue took an afternoon: 44 planner operations now, covering everything headless and
deterministic. The part I would do differently is the guard. There is now a test that reads both
schema files off disk and fails if they differ by anything except that comment line. A comment asking
two files to stay in sync is a wish. A test is a mechanism.
I deliberately left encryption and decryption out of the planner, with an explicit rule saying so.
Those need a password, and a password would have to travel inside the instruction string to Bedrock.
In an app whose entire claim is that nothing sensitive leaves the machine, that is the one operation
worth refusing on principle.
What I would tell someone starting the same thing
Put the proof in the product, not the marketing copy. The status bar counts off-origin requests
with
PerformanceObserver . When you use the command bar it ticks from 0 to 1 — and the file data
readout stays at 0 B beside it. That honest distinction between one 350-byte metadata request and an
upload does more for trust than any amount of privacy-policy prose.Write the test that fails. Every genuine bug in this project hid behind something that looked
like it worked: a passing assertion, a green tick, a plausible-looking output. If you are asserting
that something is gone, prove your assertion can still see it when it is there.
Let the browser enforce your promises. A CSP is a constraint you cannot accidentally code around
at 2am. Mine also caught me out —
Permissions-Policy: camera=() blocked my own scan-with-camera
tool, which was the header working exactly as designed.The whole thing is 216 browser tests and 24 API tests, deployed on Amplify and a single Lambda,
and it costs a few cents a month to run because the expensive part happens on your machine.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article