diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9e89c76 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,68 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + web: + runs-on: ubuntu-latest + defaults: + run: + working-directory: web + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + cache-dependency-path: web/package-lock.json + - run: npm ci + - run: npm run lint + - run: npm run typecheck + - run: npm test + - run: npm run build + - run: npx playwright install --with-deps chromium + - run: npm run test:e2e + env: + CI: 'true' + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: playwright-report + path: web/test-results + retention-days: 7 + + site: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + cache-dependency-path: | + web/package-lock.json + site/package-lock.json + - name: Build web app + working-directory: web + run: npm ci && npm run build + - name: Build and check documentation site + working-directory: site + run: | + npm ci + node build.mjs --out ../_site --app ../web/dist + node check.mjs --dir ../_site + + gmail-addon: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - run: node --test gmail-addon/detect.test.mjs diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..50fd8a2 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,63 @@ +name: Deploy to GitHub Pages + +on: + push: + tags: ['v*'] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + cache-dependency-path: | + web/package-lock.json + site/package-lock.json + - name: Build web app + working-directory: web + run: | + npm ci + npm test + npm run build + env: + VITE_GOOGLE_CLIENT_ID: ${{ vars.GOOGLE_CLIENT_ID }} + VITE_GOOGLE_API_KEY: ${{ vars.GOOGLE_API_KEY }} + VITE_GOOGLE_APP_ID: ${{ vars.GOOGLE_APP_ID }} + - name: Build documentation site (app under /app/) + working-directory: site + run: | + npm ci + node build.mjs --out ../_site --app ../web/dist + node check.mjs --dir ../_site + - name: Checksums of every published file + run: node web/scripts/checksums.mjs _site + - uses: actions/upload-artifact@v4 + with: + name: SHA256SUMS + path: _site/SHA256SUMS.txt + - uses: actions/upload-pages-artifact@v3 + with: + path: _site + + deploy: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..90dbb69 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +_site +node_modules diff --git a/README.md b/README.md index 8ae3c03..17bb9f1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,105 @@ # unpassword -A Google Workspace app that removes passwords of Office, PDF files and compressed archives for archiving purposes. + +A Google Workspace app that removes the password protection of **Office (DOCX/XLSX/PPTX), PDF files and compressed archives (ZIP)** whose password you already know, for archiving purposes: you can archive them under your own protection (account security, encrypted storage, access policies) instead of a sender's file password. + +**Website and documentation:** . The web app runs at [`/app/`](https://nullthrone.github.io/unpassword/app/). + +**Zero-knowledge:** decryption and re-saving happen entirely in your browser. There is no backend. The provider of unpassword never receives your files, your passwords or the decrypted content. + +**Not a cracking tool:** unpassword requires the current password. It never guesses, enumerates or bypasses passwords, and it keeps protections that need a password you did not supply. See [Guardrails](#guardrails). + +## How it works + +``` +Browser (static web app) Google +┌──────────────────────────────────────┐ ┌───────────────────────────┐ +│ UI ── Web Worker: qpdf (WASM), │ HTTPS │ Drive API (scope: │ +│ ECMA-376 Office crypto, zip.js │◄──────►│ drive.file), Picker, OAuth │ +│ – only place with password and │ └───────────────────────────┘ +│ plaintext │ ▲ +└──────────────────────────────────────┘ │ encrypted file only +Gmail add-on (Apps Script) ── copies the still-encrypted ───────┘ + attachment to Drive, opens the web app +``` + +- **Local mode:** pick or drop a file, enter the password, download the result. No Google sign-in, no Google scripts loaded. +- **Drive mode:** "Open with → unpassword" in Drive, or "Choose from Google Drive". The result is saved next to the original as ` (unlocked).` (German UI: `(entsperrt)`). Optionally, the encrypted original goes to the trash. +- **Gmail:** the add-on lists password-protected attachments. "Open in unpassword" stores the *encrypted* attachment in the Drive folder `unpassword – Eingang` and opens the web app on it. + +| Format | Supported protection | Result | +|---|---|---| +| PDF | Standard security handler: RC4 40/128, AES-128, AES-256 (R2–R6) | open password removed; see PDF permissions below | +| DOCX/XLSX/PPTX (and macro variants) | ECMA-376 Agile and Standard encryption | unencrypted OOXML document | +| ZIP | ZipCrypto, WinZip AES-128/192/256 | unencrypted ZIP with the same entries | + +Not supported: legacy binary Office (.doc/.xls/.ppt), 7z/RAR, certificate-based or DRM protection (Adobe LiveCycle, FileOpen, …), sheet/workbook protection, "read-only recommended". + +### PDF permissions + +PDFs have two passwords: the open (user) password and the permissions (owner) password. + +| You enter | File | Result | +|---|---|---| +| open password | no permission restrictions | fully decrypted | +| open password | with restrictions (print, copy, …) | open password removed. The **restrictions are kept** (AES-256, empty open password, random owner password that is discarded) | +| owner password | any | fully decrypted | +| – | owner password only, no open password | refused: lifting restrictions requires the owner password | + +## Guardrails + +unpassword is built so that it is useless for attacking files you have no password for: + +- Exactly one typed password per attempt. There are no password lists, imports, generators or "common password" features. The static test `web/tests/guardrails.test.ts` fails if such code appears, including zip.js' password-candidate API. +- Per-file rate limiting: two free failures, then 5 s, 10 s, 20 s … and a lock after ten failures for the session. +- No export of hashes, verifiers or salts in any form. +- Key-derivation parameters (e.g. Office spin counts) are used as stored in the file. +- Only real encryption is removed with the password that controls it. Permission restrictions, DRM and structure protection are never bypassed. + +These limits run on your machine and are not a cryptographic boundary against a modified copy of the code. They make sure unpassword itself adds no attack capability: a determined attacker gains nothing from it they would not have without it. Details are in [docs/SECURITY.md](docs/SECURITY.md). + +## Repository layout + +``` +web/ static web app (Vite + TypeScript, no UI framework) + src/core/ format handlers, rate limiter – pure, DOM-free, unit tested + src/google/ OAuth (GIS), Picker, Drive REST client + tests/ Vitest unit tests + fixtures + e2e/ Playwright tests (local mode, Drive mode with mocked APIs, network assertions) +gmail-addon/ Apps Script Gmail launcher (never decrypts) +site/ documentation site for GitHub Pages: renders docs/ and the landing page, no JavaScript +design/ Nullthrone Design System tokens and fonts (self-hosted), the unpassword mark and its PNG renderings +scripts/ fixture generator, cross-check, brand asset renderer +docs/ security model, privacy policy, terms, support, imprint, deployment setup +``` + +## Development + +```bash +cd web +npm ci +npm run dev # local mode works without any Google configuration +npm test # unit tests +npm run test:e2e # Playwright (Chromium) +npm run lint && npm run typecheck +npm run build # dist/ + dist/SHA256SUMS.txt +``` + +Documentation site: + +```bash +cd site && npm ci +node build.mjs --app ../web/dist # writes ../_site (app under /app/) +node check.mjs # CSP, no external resources, no broken links +``` + +Brand assets (icons, banner, Marketplace screenshots) are rendered by `node scripts/render-brand-assets.mjs` after `npm run build` in `web/`. + +Drive integration needs `VITE_GOOGLE_CLIENT_ID`, `VITE_GOOGLE_API_KEY` and `VITE_GOOGLE_APP_ID` (see [docs/SETUP.md](docs/SETUP.md)). Without them the app runs in local mode only. + +## Verifying a deployment + +The Pages workflow builds from a tagged commit and publishes `SHA256SUMS.txt` at the site root. Build the same tag locally with the same public Google identifiers and compare the checksums. + +## License + +MIT, see [LICENSE](LICENSE). Third-party components: [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000..0ce3bd8 --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,30 @@ +# Third-party notices + +unpassword bundles the following components into the web app. + +| Component | License | Use | +|---|---|---| +| [qpdf](https://github.com/qpdf/qpdf) via [@neslinesli93/qpdf-wasm](https://github.com/neslinesli93/qpdf-wasm) | Apache-2.0 (qpdf), ISC (WASM packaging) | PDF decryption and re-encryption | +| [@zip.js/zip.js](https://github.com/gildas-lormeau/zip.js) | BSD-3-Clause | ZIP reading and writing | +| [cfb](https://github.com/SheetJS/js-cfb) | Apache-2.0 | Compound File Binary parsing (encrypted Office containers) | +| [@noble/ciphers](https://github.com/paulmillr/noble-ciphers), [@noble/hashes](https://github.com/paulmillr/noble-hashes) | MIT | AES, SHA-1/SHA-2, HMAC for Office decryption | + +The web app and the documentation site additionally include: + +| Component | License | Use | +|---|---|---| +| [Jost](https://github.com/indestructible-type/Jost), [Public Sans](https://github.com/uswds/public-sans), [JetBrains Mono](https://github.com/JetBrains/JetBrainsMono) | SIL Open Font License 1.1 (texts in `design/nullthrone/fonts/`) | Typefaces, self-hosted (files taken from Fontsource) | +| Nullthrone Design System | Nullthrone, used by its owner | Design tokens and brand marks in `design/` | +| [marked](https://github.com/markedjs/marked) | MIT | Build-time Markdown rendering of the documentation site (not shipped) | + +The test suite additionally contains three sample documents from [msoffcrypto-tool](https://github.com/nolze/msoffcrypto-tool) (MIT): `web/tests/fixtures/office/standard.docx`, `office-agile.docx` and `office-agile.xlsx`. + +The full license texts are in each package's `LICENSE` file in `web/node_modules` after `npm ci`, and at the linked repositories. + +## Apache-2.0 notice (qpdf) + +qpdf is Copyright (c) 2005–2024 Jay Berkenbilt and contributors, licensed under the Apache License, Version 2.0. You may obtain a copy of the License at . Distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND. + +## Apache-2.0 notice (cfb) + +cfb is Copyright (C) 2013-present SheetJS LLC, licensed under the Apache License, Version 2.0. diff --git a/design/nullthrone/README.md b/design/nullthrone/README.md new file mode 100644 index 0000000..8af917b --- /dev/null +++ b/design/nullthrone/README.md @@ -0,0 +1,21 @@ +# Nullthrone Design System (vendored) + +Tokens and brand assets from the Nullthrone Design System handoff (Claude Design export, 2026-10-04), used by the web app (`web/`) and the documentation site (`site/`). + +- `tokens/colors.css`, `typography.css`, `spacing.css`, `effects.css`, `motion.css` and `base.css` are copied unchanged. +- `tokens/fonts.css` replaces the original Google Fonts import with self-hosted files in `fonts/` (Jost, Public Sans, JetBrains Mono, all SIL OFL 1.1). unpassword makes no third-party requests for fonts. +- `assets/nullthrone-mark.svg` and `assets/nullthrone-lockup.svg` are the umbrella brand marks. They fill with `currentColor`. +- `nullthrone.css` imports everything in the original order. + +## Rules that matter most + +These are summarised from the design system README. + +- Ink (`--ink-950`) on warm paper (`--paper`). Brass (`--brass-500`) is the single accent, used at most once per view for the primary call to action. +- Corners are square. Structure comes from 1px hairlines. The double rule (two hairlines 3px apart) marks major section breaks. +- Display type and uppercase labels use Jost with `--track-caps`. Body text uses Public Sans, code uses JetBrains Mono. +- Shadows are near-flat. No gradients, no transparency, no blur, no emoji. +- Dark mode inverts the primitives. It follows the OS preference, and `data-theme` overrides it. +- Voice: declarative and precise. No hype, no hedging. + +Do not edit the copied token files. Override in the consuming stylesheet instead. diff --git a/design/nullthrone/assets/nullthrone-lockup.svg b/design/nullthrone/assets/nullthrone-lockup.svg new file mode 100644 index 0000000..a797932 --- /dev/null +++ b/design/nullthrone/assets/nullthrone-lockup.svg @@ -0,0 +1,24 @@ + +Nullthrone + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/design/nullthrone/assets/nullthrone-mark.svg b/design/nullthrone/assets/nullthrone-mark.svg new file mode 100644 index 0000000..010089e --- /dev/null +++ b/design/nullthrone/assets/nullthrone-mark.svg @@ -0,0 +1,12 @@ + +Nullthrone + + + + + + + + + + \ No newline at end of file diff --git a/design/nullthrone/fonts/LICENSE-jetbrains-mono.txt b/design/nullthrone/fonts/LICENSE-jetbrains-mono.txt new file mode 100644 index 0000000..8f7ed67 --- /dev/null +++ b/design/nullthrone/fonts/LICENSE-jetbrains-mono.txt @@ -0,0 +1,93 @@ +Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono) JetBrainsMono-Italic[wght].ttf: Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/design/nullthrone/fonts/LICENSE-jost.txt b/design/nullthrone/fonts/LICENSE-jost.txt new file mode 100644 index 0000000..2b531af --- /dev/null +++ b/design/nullthrone/fonts/LICENSE-jost.txt @@ -0,0 +1,93 @@ +Copyright 2020 The Jost Project Authors (https://github.com/indestructible-type/Jost) Jost-Italic[wght].ttf: Copyright 2020 The Jost Project Authors (https://github.com/indestructible-type/Jost) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/design/nullthrone/fonts/LICENSE-public-sans.txt b/design/nullthrone/fonts/LICENSE-public-sans.txt new file mode 100644 index 0000000..a6cb63a --- /dev/null +++ b/design/nullthrone/fonts/LICENSE-public-sans.txt @@ -0,0 +1,93 @@ +Copyright 2015 The Public Sans Project Authors (https://github.com/uswds/public-sans) PublicSans-Italic[wght].ttf: Copyright 2015 The Public Sans Project Authors (https://github.com/uswds/public-sans) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/design/nullthrone/fonts/jetbrains-mono-latin-400-normal.woff2 b/design/nullthrone/fonts/jetbrains-mono-latin-400-normal.woff2 new file mode 100644 index 0000000..5858873 Binary files /dev/null and b/design/nullthrone/fonts/jetbrains-mono-latin-400-normal.woff2 differ diff --git a/design/nullthrone/fonts/jetbrains-mono-latin-500-normal.woff2 b/design/nullthrone/fonts/jetbrains-mono-latin-500-normal.woff2 new file mode 100644 index 0000000..be878e6 Binary files /dev/null and b/design/nullthrone/fonts/jetbrains-mono-latin-500-normal.woff2 differ diff --git a/design/nullthrone/fonts/jost-latin-ext-wght-normal.woff2 b/design/nullthrone/fonts/jost-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..3c90baf Binary files /dev/null and b/design/nullthrone/fonts/jost-latin-ext-wght-normal.woff2 differ diff --git a/design/nullthrone/fonts/jost-latin-wght-normal.woff2 b/design/nullthrone/fonts/jost-latin-wght-normal.woff2 new file mode 100644 index 0000000..08a7b80 Binary files /dev/null and b/design/nullthrone/fonts/jost-latin-wght-normal.woff2 differ diff --git a/design/nullthrone/fonts/public-sans-latin-ext-wght-italic.woff2 b/design/nullthrone/fonts/public-sans-latin-ext-wght-italic.woff2 new file mode 100644 index 0000000..9dcaba7 Binary files /dev/null and b/design/nullthrone/fonts/public-sans-latin-ext-wght-italic.woff2 differ diff --git a/design/nullthrone/fonts/public-sans-latin-ext-wght-normal.woff2 b/design/nullthrone/fonts/public-sans-latin-ext-wght-normal.woff2 new file mode 100644 index 0000000..49ce111 Binary files /dev/null and b/design/nullthrone/fonts/public-sans-latin-ext-wght-normal.woff2 differ diff --git a/design/nullthrone/fonts/public-sans-latin-wght-italic.woff2 b/design/nullthrone/fonts/public-sans-latin-wght-italic.woff2 new file mode 100644 index 0000000..068db26 Binary files /dev/null and b/design/nullthrone/fonts/public-sans-latin-wght-italic.woff2 differ diff --git a/design/nullthrone/fonts/public-sans-latin-wght-normal.woff2 b/design/nullthrone/fonts/public-sans-latin-wght-normal.woff2 new file mode 100644 index 0000000..15b5f3d Binary files /dev/null and b/design/nullthrone/fonts/public-sans-latin-wght-normal.woff2 differ diff --git a/design/nullthrone/nullthrone.css b/design/nullthrone/nullthrone.css new file mode 100644 index 0000000..4db26e2 --- /dev/null +++ b/design/nullthrone/nullthrone.css @@ -0,0 +1,8 @@ +/* Nullthrone Design System – entry point (order as in the original styles.css). */ +@import url('tokens/fonts.css'); +@import url('tokens/colors.css'); +@import url('tokens/typography.css'); +@import url('tokens/spacing.css'); +@import url('tokens/effects.css'); +@import url('tokens/motion.css'); +@import url('tokens/base.css'); diff --git a/design/nullthrone/tokens/base.css b/design/nullthrone/tokens/base.css new file mode 100644 index 0000000..30f6f32 --- /dev/null +++ b/design/nullthrone/tokens/base.css @@ -0,0 +1,6 @@ +body{font-family:var(--font-body);font-size:var(--text-md);line-height:var(--leading-body);color:var(--text-body);background:var(--surface-page);margin:0;-webkit-font-smoothing:antialiased} +h1,h2,h3,h4{font-family:var(--font-display);font-weight:var(--weight-display);line-height:var(--leading-tight);letter-spacing:var(--track-display);margin:0} +code,pre{font-family:var(--font-mono)} +a{color:var(--text-body);text-decoration:underline;text-decoration-color:var(--brass-500);text-underline-offset:3px;transition:color var(--dur-fast) var(--ease)} +a:hover{color:var(--brass-600)} +::selection{background:var(--brass-200)} diff --git a/design/nullthrone/tokens/colors.css b/design/nullthrone/tokens/colors.css new file mode 100644 index 0000000..7bcb2bf --- /dev/null +++ b/design/nullthrone/tokens/colors.css @@ -0,0 +1,72 @@ +:root{ +color-scheme:light; +/* Base — ink & paper */ +--ink-950:#141317;--ink-900:#1E1C21;--ink-700:#3A3740;--ink-500:#6E6B72;--ink-400:#928F96;--ink-300:#B6B3B8;--ink-200:#D9D6D3;--ink-100:#E9E6DF; +--paper:#F4F2EC;--paper-raised:#FBFAF6;--paper-white:#FFFFFF; +/* Brass — the single accent */ +--brass-700:#7A5A1F;--brass-600:#8F6B26;--brass-500:#A87E2F;--brass-400:#C09A4B;--brass-200:#E4D5AC;--brass-100:#EFE6CD; +/* Signals — muted, architectural */ +--green-600:#2F6B4F;--green-100:#DFEAE3; +--amber-600:#A05E14;--amber-100:#F3E5D2; +--red-600:#8C2F2E;--red-100:#F0DDDC; +/* Semantic aliases */ +--text-body:var(--ink-950);--text-muted:var(--ink-500);--text-faint:var(--ink-400);--text-inverse:var(--paper);--text-accent:var(--brass-600); +--surface-page:var(--paper);--surface-card:var(--paper-raised);--surface-inset:var(--ink-100);--surface-inverse:var(--ink-950); +--border-line:var(--ink-200);--border-strong:var(--ink-950);--border-mid:var(--ink-300); +--accent:var(--brass-500);--accent-hover:var(--brass-600);--accent-active:var(--brass-700); +--focus-ring:0 0 0 2px var(--paper),0 0 0 4px var(--brass-500); +--ok:var(--green-600);--ok-bg:var(--green-100);--warn:var(--amber-600);--warn-bg:var(--amber-100);--danger:var(--red-600);--danger-bg:var(--red-100); +--press-ink:#000000;--danger-hover:#7A2827;--danger-active:#682221; +--overlay-scrim:rgba(20,19,23,.5); +} + +/* Dark — the brand inverted at primitive level. ink and paper swap roles. + Ratios follow the kenny Fleet Console (t11z/kenny). Elevation is shadow, never a lighter plane. */ +[data-theme="dark"]{ +color-scheme:dark; +--ink-950:#EFEDE7;--ink-900:#DEDBD4;--ink-700:#B4B0A9;--ink-500:#8A8781;--ink-400:#6E6B67;--ink-300:#4C4952;--ink-200:#33313A;--ink-100:#100F13; +--paper:#17161A;--paper-raised:#1F1D22;--paper-white:#2B2930; +--brass-700:#B98B36;--brass-600:#DCB768;--brass-500:#C89E4A;--brass-400:#8F6B26;--brass-200:#4A3A1B;--brass-100:#2A2110; +--green-600:#6FA98C;--green-100:#1A2A23; +--amber-600:#D9853C;--amber-100:#2C2117; +--red-600:#CB6A62;--red-100:#2C1B1B; +--press-ink:#8A8781;--danger-hover:#A9524E;--danger-active:#8E4341; +--overlay-scrim:rgba(6,6,8,.66); +} +@media (prefers-color-scheme:dark){ +:root{ +color-scheme:dark; +--ink-950:#EFEDE7;--ink-900:#DEDBD4;--ink-700:#B4B0A9;--ink-500:#8A8781;--ink-400:#6E6B67;--ink-300:#4C4952;--ink-200:#33313A;--ink-100:#100F13; +--paper:#17161A;--paper-raised:#1F1D22;--paper-white:#2B2930; +--brass-700:#B98B36;--brass-600:#DCB768;--brass-500:#C89E4A;--brass-400:#8F6B26;--brass-200:#4A3A1B;--brass-100:#2A2110; +--green-600:#6FA98C;--green-100:#1A2A23; +--amber-600:#D9853C;--amber-100:#2C2117; +--red-600:#CB6A62;--red-100:#2C1B1B; +--press-ink:#8A8781;--danger-hover:#A9524E;--danger-active:#8E4341; +--overlay-scrim:rgba(6,6,8,.66); +} +} + +/* Light re-assertion — last in cascade so [data-theme="light"] wins over the OS-dark default, + letting a region turn back into the light inside a dark ground. */ +[data-theme="light"]{ +color-scheme:light; +/* Base — ink & paper */ +--ink-950:#141317;--ink-900:#1E1C21;--ink-700:#3A3740;--ink-500:#6E6B72;--ink-400:#928F96;--ink-300:#B6B3B8;--ink-200:#D9D6D3;--ink-100:#E9E6DF; +--paper:#F4F2EC;--paper-raised:#FBFAF6;--paper-white:#FFFFFF; +/* Brass — the single accent */ +--brass-700:#7A5A1F;--brass-600:#8F6B26;--brass-500:#A87E2F;--brass-400:#C09A4B;--brass-200:#E4D5AC;--brass-100:#EFE6CD; +/* Signals — muted, architectural */ +--green-600:#2F6B4F;--green-100:#DFEAE3; +--amber-600:#A05E14;--amber-100:#F3E5D2; +--red-600:#8C2F2E;--red-100:#F0DDDC; +/* Semantic aliases */ +--text-body:var(--ink-950);--text-muted:var(--ink-500);--text-faint:var(--ink-400);--text-inverse:var(--paper);--text-accent:var(--brass-600); +--surface-page:var(--paper);--surface-card:var(--paper-raised);--surface-inset:var(--ink-100);--surface-inverse:var(--ink-950); +--border-line:var(--ink-200);--border-strong:var(--ink-950);--border-mid:var(--ink-300); +--accent:var(--brass-500);--accent-hover:var(--brass-600);--accent-active:var(--brass-700); +--focus-ring:0 0 0 2px var(--paper),0 0 0 4px var(--brass-500); +--ok:var(--green-600);--ok-bg:var(--green-100);--warn:var(--amber-600);--warn-bg:var(--amber-100);--danger:var(--red-600);--danger-bg:var(--red-100); +--press-ink:#000000;--danger-hover:#7A2827;--danger-active:#682221; +--overlay-scrim:rgba(20,19,23,.5); +} diff --git a/design/nullthrone/tokens/effects.css b/design/nullthrone/tokens/effects.css new file mode 100644 index 0000000..a81535f --- /dev/null +++ b/design/nullthrone/tokens/effects.css @@ -0,0 +1,34 @@ +:root{ +/* Corners are square. --radius-1 exists only for tiny inner elements. */ +--radius-0:0px;--radius-1:2px; +--line:1px solid var(--border-line);--line-strong:1px solid var(--border-strong); +--shadow-1:0 1px 2px rgba(20,19,23,.07);--shadow-2:0 2px 8px rgba(20,19,23,.10);--shadow-3:0 12px 32px rgba(20,19,23,.16); +--ease:cubic-bezier(.2,0,0,1);/* @kind other */ +--dur-fast:120ms;/* @kind other */ +--dur-med:200ms;/* @kind other */ +--dur-slow:320ms;/* @kind other */ +} + +[data-theme="dark"]{ +--shadow-1:0 1px 2px rgba(0,0,0,.45); +--shadow-2:0 2px 10px rgba(0,0,0,.55); +--shadow-3:0 14px 38px rgba(0,0,0,.66); +} +@media (prefers-color-scheme:dark){ +:root{ +--shadow-1:0 1px 2px rgba(0,0,0,.45); +--shadow-2:0 2px 10px rgba(0,0,0,.55); +--shadow-3:0 14px 38px rgba(0,0,0,.66); +} +} + +[data-theme="light"]{ +/* Corners are square. --radius-1 exists only for tiny inner elements. */ +--radius-0:0px;--radius-1:2px; +--line:1px solid var(--border-line);--line-strong:1px solid var(--border-strong); +--shadow-1:0 1px 2px rgba(20,19,23,.07);--shadow-2:0 2px 8px rgba(20,19,23,.10);--shadow-3:0 12px 32px rgba(20,19,23,.16); +--ease:cubic-bezier(.2,0,0,1);/* @kind other */ +--dur-fast:120ms;/* @kind other */ +--dur-med:200ms;/* @kind other */ +--dur-slow:320ms;/* @kind other */ +} diff --git a/design/nullthrone/tokens/fonts.css b/design/nullthrone/tokens/fonts.css new file mode 100644 index 0000000..e98e16e --- /dev/null +++ b/design/nullthrone/tokens/fonts.css @@ -0,0 +1,11 @@ +/* Self-hosted webfonts (SIL OFL 1.1, see ../fonts/LICENSE-*.txt). + Replaces the design system's Google Fonts import: no third-party request, + no IP address leaves for a font CDN. Family names match tokens/typography.css. */ +@font-face{font-family:'Jost';font-style:normal;font-weight:100 900;font-display:swap;src:url('../fonts/jost-latin-wght-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD} +@font-face{font-family:'Public Sans';font-style:normal;font-weight:100 900;font-display:swap;src:url('../fonts/public-sans-latin-wght-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD} +@font-face{font-family:'Public Sans';font-style:italic;font-weight:100 900;font-display:swap;src:url('../fonts/public-sans-latin-wght-italic.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD} +@font-face{font-family:'Jost';font-style:normal;font-weight:100 900;font-display:swap;src:url('../fonts/jost-latin-ext-wght-normal.woff2') format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF} +@font-face{font-family:'Public Sans';font-style:normal;font-weight:100 900;font-display:swap;src:url('../fonts/public-sans-latin-ext-wght-normal.woff2') format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF} +@font-face{font-family:'Public Sans';font-style:italic;font-weight:100 900;font-display:swap;src:url('../fonts/public-sans-latin-ext-wght-italic.woff2') format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF} +@font-face{font-family:'JetBrains Mono';font-style:normal;font-weight:400;font-display:swap;src:url('../fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD} +@font-face{font-family:'JetBrains Mono';font-style:normal;font-weight:500;font-display:swap;src:url('../fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD} diff --git a/design/nullthrone/tokens/motion.css b/design/nullthrone/tokens/motion.css new file mode 100644 index 0000000..e8c33a7 --- /dev/null +++ b/design/nullthrone/tokens/motion.css @@ -0,0 +1,5 @@ +/* Motion primitives — fades and small translates only; no bounces. */ +@keyframes nt-fade-up{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}} +@keyframes nt-fade-in{from{opacity:0}to{opacity:1}} +@keyframes nt-bar-pulse{0%,100%{transform:scaleY(.35);opacity:.5}50%{transform:scaleY(1);opacity:1}} +@keyframes nt-indeterminate{0%{left:-35%}100%{left:100%}} diff --git a/design/nullthrone/tokens/spacing.css b/design/nullthrone/tokens/spacing.css new file mode 100644 index 0000000..5cbe695 --- /dev/null +++ b/design/nullthrone/tokens/spacing.css @@ -0,0 +1,5 @@ +:root{ +--space-1:4px;--space-2:8px;--space-3:12px;--space-4:16px;--space-5:24px;--space-6:32px;--space-7:48px;--space-8:64px;--space-9:96px; +--control-h-sm:28px;--control-h-md:36px;--control-h-lg:44px; +--container-max:1120px;--container-pad:var(--space-6); +} diff --git a/design/nullthrone/tokens/typography.css b/design/nullthrone/tokens/typography.css new file mode 100644 index 0000000..f36deef --- /dev/null +++ b/design/nullthrone/tokens/typography.css @@ -0,0 +1,12 @@ +:root{ +--font-display:'Jost',system-ui,sans-serif; +--font-body:'Public Sans',system-ui,sans-serif; +--font-mono:'JetBrains Mono',ui-monospace,monospace; +/* Scale */ +--display-xl:56px;--display-lg:40px;--display-md:28px;--display-sm:20px; +--text-lg:18px;--text-md:15px;--text-sm:13px;--text-xs:11px; +/* Tracking — letterspaced caps are a core brand motif */ +--track-caps:0.14em;--track-caps-wide:0.22em;--track-display:0.01em; +--leading-tight:1.15;--leading-body:1.55; +--weight-display:500;--weight-body:400;--weight-strong:600; +} diff --git a/design/unpassword/README.md b/design/unpassword/README.md new file mode 100644 index 0000000..534c20e --- /dev/null +++ b/design/unpassword/README.md @@ -0,0 +1,15 @@ +# unpassword mark + +The mark is an open padlock drawn in the Nullthrone formal language: + +- The **shackle** has stepped Art Deco shoulders, like the stepped head of the Nullthrone monogram. Its right leg is lifted out of the body: the lock is open. +- The **keyhole** is the monogram's arched "0" opening. +- The **cap bar** above the body and the slanted **side columns** repeat the throne silhouette. + +| File | Use | +|---|---| +| `mark.svg` | Full mark, ≥ 48 px. Fills with `currentColor`. | +| `mark-small.svg` | Reduced mark without cap bar and columns, for ≤ 32 px (favicons, toolbar). `currentColor`. | +| `favicon.svg` | Small mark with built-in light/dark colours. | + +Colours: ink, paper or brass only (see `design/nullthrone`). Keep a clear space of a quarter of the mark's width. PNG renderings (Marketplace icons, banner, social card, add-on logo) are generated by `scripts/render-brand-assets.mjs`. diff --git a/design/unpassword/favicon.svg b/design/unpassword/favicon.svg new file mode 100644 index 0000000..1f5c269 --- /dev/null +++ b/design/unpassword/favicon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/design/unpassword/mark-small.svg b/design/unpassword/mark-small.svg new file mode 100644 index 0000000..cc21741 --- /dev/null +++ b/design/unpassword/mark-small.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/design/unpassword/mark.svg b/design/unpassword/mark.svg new file mode 100644 index 0000000..1e02eb5 --- /dev/null +++ b/design/unpassword/mark.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/design/unpassword/png/banner-220x140.png b/design/unpassword/png/banner-220x140.png new file mode 100644 index 0000000..8a273de Binary files /dev/null and b/design/unpassword/png/banner-220x140.png differ diff --git a/design/unpassword/png/icon-128.png b/design/unpassword/png/icon-128.png new file mode 100644 index 0000000..047be52 Binary files /dev/null and b/design/unpassword/png/icon-128.png differ diff --git a/design/unpassword/png/icon-16.png b/design/unpassword/png/icon-16.png new file mode 100644 index 0000000..295fafc Binary files /dev/null and b/design/unpassword/png/icon-16.png differ diff --git a/design/unpassword/png/icon-32.png b/design/unpassword/png/icon-32.png new file mode 100644 index 0000000..17d1466 Binary files /dev/null and b/design/unpassword/png/icon-32.png differ diff --git a/design/unpassword/png/icon-48.png b/design/unpassword/png/icon-48.png new file mode 100644 index 0000000..db24ab6 Binary files /dev/null and b/design/unpassword/png/icon-48.png differ diff --git a/design/unpassword/png/icon-96.png b/design/unpassword/png/icon-96.png new file mode 100644 index 0000000..480ccf7 Binary files /dev/null and b/design/unpassword/png/icon-96.png differ diff --git a/design/unpassword/png/screenshot-1-pick.png b/design/unpassword/png/screenshot-1-pick.png new file mode 100644 index 0000000..9098387 Binary files /dev/null and b/design/unpassword/png/screenshot-1-pick.png differ diff --git a/design/unpassword/png/screenshot-2-password.png b/design/unpassword/png/screenshot-2-password.png new file mode 100644 index 0000000..e4c0b0c Binary files /dev/null and b/design/unpassword/png/screenshot-2-password.png differ diff --git a/design/unpassword/png/screenshot-3-result.png b/design/unpassword/png/screenshot-3-result.png new file mode 100644 index 0000000..8e0af97 Binary files /dev/null and b/design/unpassword/png/screenshot-3-result.png differ diff --git a/design/unpassword/png/social-card.png b/design/unpassword/png/social-card.png new file mode 100644 index 0000000..b848604 Binary files /dev/null and b/design/unpassword/png/social-card.png differ diff --git a/docs/IMPRINT.md b/docs/IMPRINT.md new file mode 100644 index 0000000..2acab48 --- /dev/null +++ b/docs/IMPRINT.md @@ -0,0 +1,20 @@ +# Imprint + +_Impressum – Angaben gemäß § 5 DDG_ + +Thomas Sprock +Am Kleikamp 26 +31319 Sehnde +Germany + +**Contact / Kontakt** +Email: [github@nullthrone.xyz](mailto:github@nullthrone.xyz) + +**Responsible for the content / Verantwortlich für den Inhalt nach § 18 Abs. 2 MStV** +Thomas Sprock, address as above. + +unpassword is an open-source project published under the Nullthrone name. It is free of charge and not a commercial offering. + +## Liability for links + +This site links to external websites, such as GitHub and Google. We have no influence on their content, and their operators are responsible for it. At the time of linking, no infringements were apparent. If we become aware of an infringement, we remove the link. diff --git a/docs/PRIVACY.md b/docs/PRIVACY.md new file mode 100644 index 0000000..fe07387 --- /dev/null +++ b/docs/PRIVACY.md @@ -0,0 +1,52 @@ +# Privacy policy + +_Last updated: 2026-10-06_ + +unpassword is designed so that its provider cannot access your data. + +## Controller + +Thomas Sprock, Am Kleikamp 26, 31319 Sehnde, Germany. Email: [github@nullthrone.xyz](mailto:github@nullthrone.xyz). See also the [imprint](IMPRINT.md). + +## What unpassword processes + +- **Files and passwords** you select or enter are processed **only in your browser**, in a web worker. They are never sent to the provider of unpassword. There is no unpassword server. +- **Google Drive (optional):** if you choose Drive, your browser obtains an OAuth access token from Google with the scope `https://www.googleapis.com/auth/drive.file`. That scope only covers files you select in the Google Picker or open with unpassword, and files unpassword creates. Your browser downloads the selected (encrypted) file directly from Google and, on your request, uploads the decrypted copy directly to your Drive. The token is kept in memory and discarded when you close the page. +- **Gmail add-on (optional):** when you open a message, the add-on reads the attachments of **that message only** (`gmail.addons.current.message.readonly`) to detect password protection. If you click "Open in unpassword", it copies the **still-encrypted** attachment into a Drive folder named "unpassword – Eingang" (`drive.file`) and opens the web app. The add-on never receives passwords or decrypted content. + +## What unpassword does not do + +- No analytics, telemetry, error reporting, cookies or tracking. +- No third-party fonts or content delivery networks. Fonts are served from this site. +- No storage of files, passwords or results in the browser (no localStorage/IndexedDB) or anywhere else. +- No sharing or sale of data. The provider has none. + +## Google API Services User Data Policy + +unpassword's use of information received from Google APIs adheres to the [Google API Services User Data Policy](https://developers.google.com/terms/api-services-user-data-policy), including the Limited Use requirements. Data from Google APIs is used only to provide the user-facing features described above and is never transferred to the provider or any third party. + +## Hosting + +This website and the web app are static files served by GitHub Pages, operated by GitHub, Inc., USA. To deliver the pages, GitHub processes technical access data: IP address, time, requested file and browser identification. GitHub may store this data in server logs. The logs contain no file content and no passwords. The legal basis is Art. 6(1)(f) GDPR, our legitimate interest in delivering the site securely. Details are in the [GitHub General Privacy Statement](https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement). + +The documentation pages contain no scripts. The web app loads scripts only from this site, and from Google only when you choose to use Google Drive. + +## Legal basis + +- Processing in your browser is not processing by the provider, who receives no data. +- Google Drive and Gmail access happens at your request, to provide the function you asked for: Art. 6(1)(b) GDPR. The access is between your browser or Google account and Google. +- Hosting: Art. 6(1)(f) GDPR, see above. + +## Your rights + +Under the GDPR you have the right of access (Art. 15), rectification (Art. 16), erasure (Art. 17), restriction of processing (Art. 18), data portability (Art. 20) and objection (Art. 21). Because the provider stores no personal data about you, these rights will usually concern GitHub or Google directly. Contact us at the address above for any request. + +You also have the right to lodge a complaint with a supervisory authority. For the provider, this is the [Landesbeauftragte für den Datenschutz Niedersachsen](https://www.lfd.niedersachsen.de). + +## Revoking access + +Remove unpassword's access at . Files unpassword created remain in your Drive until you delete them. + +## Contact + +Email [github@nullthrone.xyz](mailto:github@nullthrone.xyz), or open an issue at . diff --git a/docs/SECURITY.md b/docs/SECURITY.md new file mode 100644 index 0000000..c32ef79 --- /dev/null +++ b/docs/SECURITY.md @@ -0,0 +1,54 @@ +# Security model + +## Goals + +1. **Confidentiality towards the provider (zero-knowledge).** Whoever builds and hosts unpassword never gets access to files, passwords or plaintext. +2. **Legitimate use only.** unpassword removes protection only with the password that controls it, and it is useless as a password-guessing tool. +3. **Integrity of results.** Output is verified before it is offered: re-encrypted PDFs are re-inspected, Office packages carry an HMAC check, ZIP entries are CRC/MAC-checked. + +## Trust boundaries + +| Component | Sees plaintext or password? | Notes | +|---|---|---| +| unpassword provider / hosting (GitHub Pages) | no | serves static files only; no backend, no logging endpoint, no analytics | +| Browser, web worker | yes | the only place where decryption happens | +| Google (Drive, GIS, Picker scripts) | Drive mode only: plaintext when **you** save to Drive | Google already stores your files; the password never goes to Google | +| Gmail add-on (Apps Script, runs on Google servers) | no | handles only the encrypted attachment | + +### Enforcement + +- **Content Security Policy** (`web/vite.config.ts`, injected into the built `index.html`): `connect-src` allows only this origin and Google's API hosts. Even a compromised dependency cannot send data anywhere else from the page or the worker. `object-src 'none'`, `base-uri 'none'` and `form-action 'none'` close other channels. The CSP is delivered via `` because GitHub Pages cannot set headers, so `frame-ancestors` is not available. Host it behind a server that sets headers if you need it. +- **Worker isolation.** Passwords and plaintext are processed in a dedicated worker (`web/src/worker.ts`). The main thread holds the password only between the input field and `postMessage`, and the field is cleared immediately. +- **No persistence.** ESLint forbids `localStorage`, `sessionStorage` and `indexedDB` in `src/`. Nothing is cached. Buffers are overwritten after use as far as JavaScript allows. Garbage-collected copies cannot be wiped reliably. +- **Local mode loads no third-party code.** Google scripts are loaded only when the user chooses Drive. +- **Minimal OAuth scope.** `drive.file` grants access only to files the user picks or that unpassword creates. Tokens stay in memory. +- **Static guardrail tests** (`web/tests/guardrails.test.ts`) fail the build if source code references non-Google endpoints, uses `fetch` outside the Drive client, or contains password-guessing features. +- **E2E network assertions** (`web/e2e/`) check that in local mode every request stays on the app origin, and in Drive mode only Google API hosts are contacted. They also check that the password never appears in any URL or request body. + +### Residual risks + +- Google's GIS and Picker scripts run with page privileges in Drive mode. This is inherent to any Drive web app. Use local mode if you do not want any third-party script on the page. +- A malicious browser extension or a compromised device can read anything the page can. +- Supply chain: dependencies are few, pinned via `package-lock.json`, and bundled at build time. No code is loaded from CDNs at runtime except Google's scripts in Drive mode. + +## Anti-misuse design + +| Measure | Where | +|---|---| +| One password per call, no candidate lists | `Unlocker` type in `src/core/types.ts`; zip.js is used through its core API with a single `password` | +| Rate limit: 2 free failures, then exponential delay from 5 s, lock after 10 | `src/core/guard.ts`, applied in `src/core/session.ts` inside the worker | +| Wrong ZipCrypto passwords that pass the 1-byte check are still rejected | CRC verification, test with 600 wrong passwords in `tests/zip.test.ts` | +| PDF restrictions preserved without the owner password | `src/core/pdf/policy.ts` (pure, table-tested), with verification after re-encryption | +| No owner-password recovery, no "remove restrictions only" mode | policy refuses `owner-password-required` | +| No hash or verifier export | guardrail test | +| Unsupported protection is refused rather than worked around | DRM / certificate handlers → `unsupported` | + +The guard is client-side code. Someone can delete it from their own copy. That is accepted: the goal is that unpassword provides no attack capability, and the cryptographic work an attacker faces is identical with or without it. + +### Password encodings + +For PDF R2–R4 the password must be PDFDocEncoding bytes, for R5/R6 UTF-8. Producers are inconsistent, so the PDF handler passes the *same typed password* to qpdf in up to four byte encodings (UTF-8 NFC, PDFDocEncoding, UTF-8 NFKC, UTF-8 as typed). This is representation, not guessing. The set is fixed, derived only from the user's input, and counts as one attempt. + +## Reporting vulnerabilities + +Please open a private security advisory on GitHub rather than a public issue. diff --git a/docs/SETUP.md b/docs/SETUP.md new file mode 100644 index 0000000..cd37da5 --- /dev/null +++ b/docs/SETUP.md @@ -0,0 +1,87 @@ +# Deployment setup + +unpassword consists of a static web app and an optional Gmail add-on. Both must belong to the **same Google Cloud project**: `drive.file` grants are per project, and that is what lets the web app open the encrypted attachment the add-on stored. + +These steps need a Google account with access to the Cloud console and, for Marketplace publication, a Google Workspace Marketplace developer registration. + +## 1. Google Cloud project + +1. Create a project in the [Cloud console](https://console.cloud.google.com/) and note its **project number**. That number is `VITE_GOOGLE_APP_ID`. +2. Enable the **Google Drive API**, **Google Picker API**, **Gmail API** (for the add-on) and **Google Workspace Marketplace SDK**. +3. **OAuth consent screen:** set the app name to *unpassword*, add the privacy policy URL (`docs/PRIVACY.md` on GitHub or a published copy) and the scopes: + - `https://www.googleapis.com/auth/drive.file` + - `https://www.googleapis.com/auth/gmail.addons.execute` + - `https://www.googleapis.com/auth/gmail.addons.current.message.readonly` +4. **OAuth client ID** of type *Web application*: + - Authorized JavaScript origin: `https://.github.io` (or your domain). + - This is `VITE_GOOGLE_CLIENT_ID`. +5. **API key:** restrict it to *HTTP referrers* `https://.github.io/*` (the app sends only its origin as referrer, `strict-origin`) and to the *Google Picker API*. This is `VITE_GOOGLE_API_KEY`. + +None of these three values is secret. They end up in the public JavaScript bundle by design, and the restrictions above are what protect them. + +## 2. Web app (GitHub Pages) + +1. In the repository settings, go to *Pages* and set *Source* to **GitHub Actions**. +2. In *Settings → Secrets and variables → Actions → Variables*, add `GOOGLE_CLIENT_ID`, `GOOGLE_API_KEY` and `GOOGLE_APP_ID`. +3. Push a tag `v*` (e.g. `v0.1.0`), or run the workflow manually. `.github/workflows/pages.yml` builds the web app and the documentation site, then deploys both: + - `https://.github.io/unpassword/` – documentation site (`site/`, rendered from `docs/`) + - `https://.github.io/unpassword/app/` – the web app (`web/`) + - `https://.github.io/unpassword/SHA256SUMS.txt` – checksums of every published file, also attached to the workflow run + +To host elsewhere, build the same way (`site/build.mjs --app web/dist`) and serve `_site/` statically. If your server can set headers, also send the CSP from `web/vite.config.ts` as an HTTP header, plus `frame-ancestors 'none'`. + +## 3. Drive "Open with" integration + +In the Cloud console, open *Google Workspace Marketplace SDK* and then *App Configuration*: + +1. Enable **Drive app** integration. +2. **Open URL:** `https://.github.io/unpassword/app/`. Drive appends `?state={"ids":[…],"action":"open",…}`, which the app reads (`web/src/google/drive.ts` → `launchFileId`). +3. **Default MIME types:** `application/pdf`, `application/zip` + **Secondary MIME types:** `application/x-zip-compressed`, `application/octet-stream`, `application/x-ole-storage`, `application/vnd.ms-office`, `application/encrypted`, `application/vnd.openxmlformats-officedocument.wordprocessingml.document`, `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`, `application/vnd.openxmlformats-officedocument.presentationml.presentation` + **File extensions:** `pdf`, `zip`, `docx`, `xlsx`, `pptx`, `docm`, `xlsm`, `pptm` +4. Leave "Creating files" disabled. unpassword only opens existing files. + +## 4. Gmail add-on + +```bash +npm install -g @google/clasp +cd gmail-addon +clasp login +clasp create --type standalone --title unpassword # or copy .clasp.json.example and set scriptId +clasp push +``` + +1. In the Apps Script editor, open *Project Settings* and set the **Google Cloud Platform project** to the project number from step 1 (same project as the web app). +2. Optionally, in *Project Settings → Script properties*, set `UNPASSWORD_WEB_URL` if the web app is not at `https://nullthrone.github.io/unpassword/app/`. Update `openLinkUrlPrefixes` and `logoUrl` in `appsscript.json` to match. +3. Choose *Deploy → Test deployments → Install* and open a message with a protected attachment in Gmail. +4. For Marketplace publication, add the deployment ID under *Marketplace SDK → App Configuration → Gmail add-on*. + +## 5. Marketplace listing + +The documentation site is the listing's reference. Use these values in *Marketplace SDK → Store Listing* and on the OAuth consent screen: + +| Field | Value | +|---|---| +| Application name | unpassword | +| Short description | Remove passwords you already know from PDF, Office and ZIP files – decrypted in your browser, zero-knowledge. | +| Category | Productivity / Utilities | +| Application homepage / Developer website | `https://nullthrone.github.io/unpassword/` | +| Privacy policy URL | `https://nullthrone.github.io/unpassword/privacy/` | +| Terms of service URL | `https://nullthrone.github.io/unpassword/terms/` | +| Support URL | `https://nullthrone.github.io/unpassword/support/` | +| Developer name / email | Nullthrone · Thomas Sprock, `github@nullthrone.xyz` (see `/imprint/`) | +| Application icons 32/48/96/128 | `brand/icon-32.png`, `icon-48.png`, `icon-96.png`, `icon-128.png` | +| Card banner 220 × 140 | `brand/banner-220x140.png` | +| Screenshots 1280 × 800 | `brand/screenshot-1-pick.png`, `-2-password.png`, `-3-result.png` | +| Authorized domain (OAuth consent) | `nullthrone.github.io` | + +All graphics are listed with previews on `/marketplace/`. They are generated from `design/unpassword/` by `scripts/render-brand-assets.mjs`; rerun it after changing the mark or the app's look. + +- In the description, state the legitimate purpose plainly: removing **known** passwords for personal archiving. The guardrails on the homepage are written to be quoted in the review. +- Expect an OAuth verification for the Gmail scopes. `drive.file` is a non-sensitive scope. + +## 6. Check after deployment + +- Local mode: drop a protected file and unlock it. In the browser's network panel, verify that no request leaves the page's origin. +- Drive: use "Open with → unpassword" on a protected PDF in Drive, then save. The new file should appear next to the original. +- Gmail: open a message with a protected ZIP, choose *Open in unpassword*, and confirm that the encrypted copy lands in "unpassword – Eingang" and the web app opens it. diff --git a/docs/SUPPORT.md b/docs/SUPPORT.md new file mode 100644 index 0000000..d30c840 --- /dev/null +++ b/docs/SUPPORT.md @@ -0,0 +1,36 @@ +# Support + +unpassword is maintained as an open-source project. Support is provided on a best-effort basis; there is no guaranteed response time. + +## Where to ask + +| Topic | Channel | +|---|---| +| Bugs, questions, feature requests | [GitHub issues](https://github.com/nullthrone/unpassword/issues) | +| Security vulnerabilities | [Private security advisory](https://github.com/nullthrone/unpassword/security/advisories/new). Please do not open a public issue. | +| Privacy requests, everything else | [github@nullthrone.xyz](mailto:github@nullthrone.xyz) | + +Never send us an encrypted file together with its password, and never send us a decrypted file. We do not need either to help you, and we will not ask for them. Describe the file instead: its format, the program that created it, and the exact error message. + +## Common situations + +**"The password is incorrect."** +unpassword checks the password exactly as typed. Check the keyboard layout and Caps Lock. For PDFs, both the open password and the owner password are accepted. + +**"Too many failed attempts."** +After two failed attempts, unpassword waits before each further attempt. After ten failures the file is locked for the current session. Reload the page to start a new session. The limit exists so that unpassword cannot be used to guess passwords. + +**"Owner password required."** +The PDF opens without a password and is only restricted, for example against printing or copying. Lifting these restrictions requires the owner password. unpassword does not bypass them. + +**"Format or protection scheme not supported."** +The following are supported: PDF (standard security handler), encrypted DOCX/XLSX/PPTX, and ZIP (ZipCrypto, WinZip AES). The following are not: legacy .doc/.xls/.ppt, 7z/RAR, DRM and certificate-based protection. + +**The integrity-check warning (Office).** +The password was correct and the content was decrypted. However, the file's integrity code does not match. Either the file was modified after encryption, or the program that wrote it is faulty. Compare the content with the original before deleting anything. + +**"Saved to My Drive" instead of next to the original.** +unpassword only has access to files you open with it (`drive.file`). If it may not write into the original's folder, it saves to the root of My Drive. + +**Revoking access.** +Open [Google Account → Third-party apps](https://myaccount.google.com/connections) and remove unpassword. Files unpassword created stay in your Drive. diff --git a/docs/TERMS.md b/docs/TERMS.md new file mode 100644 index 0000000..01dbdd3 --- /dev/null +++ b/docs/TERMS.md @@ -0,0 +1,47 @@ +# Terms of Service + +_Last updated: 2026-10-06_ + +These terms apply to the use of unpassword, which consists of the web application at `https://nullthrone.github.io/unpassword/app/` and the unpassword Gmail add-on. unpassword is provided by Thomas Sprock (Nullthrone), see the [imprint](IMPRINT.md). + +## 1. The service + +unpassword removes the password protection of PDF, Office and ZIP files in your browser, using a password you supply. It is free of charge. + +The source code is published under the [MIT License](https://github.com/nullthrone/unpassword/blob/main/LICENSE). The license governs the code. These terms govern the hosted service. + +## 2. Permitted use + +You may use unpassword only for files that you are entitled to unlock, with a password you obtained lawfully. Typical examples are statements, payslips or reports addressed to you. + +You must not use unpassword to: + +- access files you are not authorised to open; +- circumvent technical protection measures of third parties, for example under § 95a of the German Copyright Act (UrhG) or comparable laws; +- determine, guess or test passwords you do not know. + +unpassword is designed to support only legitimate use. It accepts one typed password per attempt, limits failed attempts, and preserves PDF permission restrictions unless you supply the owner password. + +## 3. Your responsibility + +Removing a password removes a layer of protection. You are responsible for storing the unlocked file securely, for example in an account protected by two-factor authentication or in encrypted storage. You are also responsible for keeping a copy of the original until you have checked the result. + +## 4. No access to your data + +Decryption runs entirely in your browser. The provider does not receive your files, your passwords or the decrypted content. See the [privacy policy](PRIVACY.md) and the [security model](SECURITY.md). + +## 5. Google services + +If you use Google Drive or Gmail with unpassword, Google's terms of service and privacy policy also apply to those services. + +## 6. Availability and changes + +unpassword is provided as is, without any commitment to availability, features or support. We may change or discontinue the service at any time. + +## 7. Liability + +unpassword is provided free of charge. The provider is liable only for intent and gross negligence. This does not limit liability for injury to life, body or health, or liability under mandatory statutory provisions such as the German Product Liability Act. + +## 8. Final provisions + +German law applies, excluding the UN Convention on Contracts for the International Sale of Goods. If you are a consumer, this choice of law does not deprive you of the protection of mandatory provisions of the law of your country of habitual residence. If any provision is invalid, the remaining provisions stay in effect. diff --git a/gmail-addon/.clasp.json.example b/gmail-addon/.clasp.json.example new file mode 100644 index 0000000..8accdcd --- /dev/null +++ b/gmail-addon/.clasp.json.example @@ -0,0 +1,4 @@ +{ + "scriptId": "YOUR_SCRIPT_ID", + "rootDir": "." +} diff --git a/gmail-addon/.claspignore b/gmail-addon/.claspignore new file mode 100644 index 0000000..71e5788 --- /dev/null +++ b/gmail-addon/.claspignore @@ -0,0 +1,3 @@ +**/** +!appsscript.json +!Code.js diff --git a/gmail-addon/Code.js b/gmail-addon/Code.js new file mode 100644 index 0000000..269a386 --- /dev/null +++ b/gmail-addon/Code.js @@ -0,0 +1,171 @@ +/** + * unpassword – Gmail launcher. + * + * This add-on never decrypts anything and never sees a password. It lists the + * attachments of the open message that look password-protected and, on + * request, copies the still-encrypted attachment into the user's Drive + * (folder "unpassword – Eingang") and opens the unpassword web app for it. + * Decryption happens in the user's browser only. + * + * Scopes: gmail.addons.current.message.readonly (only the open message), + * drive.file (only files this app creates), gmail.addons.execute. + */ + +/** Base URL of the web app. Override with the script property UNPASSWORD_WEB_URL. */ +function webAppUrl_() { + var url = PropertiesService.getScriptProperties().getProperty('UNPASSWORD_WEB_URL'); + return (url || 'https://nullthrone.github.io/unpassword/app/').replace(/\/?$/, '/'); +} + +var INBOX_FOLDER = 'unpassword – Eingang'; +var MAX_BYTES = 25 * 1024 * 1024; // Gmail attachment limit + +function isGerman_(e) { + var locale = (e && e.commonEventObject && e.commonEventObject.userLocale) || Session.getActiveUserLocale() || 'en'; + return String(locale).toLowerCase().indexOf('de') === 0; +} + +function strings_(e) { + return isGerman_(e) + ? { + header: 'Passwortgeschützte Anhänge', + intro: + 'unpassword entfernt den Passwortschutz in deinem Browser – mit dem Passwort, das du kennst. ' + + 'Dieses Add-on legt nur die verschlüsselte Datei in Drive ab und öffnet unpassword.', + none: 'In dieser Nachricht wurden keine passwortgeschützten PDF-, Office- oder ZIP-Anhänge gefunden.', + open: 'In unpassword öffnen', + protectedLabel: 'passwortgeschützt', + failed: 'Der Anhang konnte nicht nach Google Drive kopiert werden.', + } + : { + header: 'Password-protected attachments', + intro: + 'unpassword removes the password protection in your browser – with the password you know. ' + + 'This add-on only stores the encrypted file in Drive and opens unpassword.', + none: 'No password-protected PDF, Office or ZIP attachments found in this message.', + open: 'Open in unpassword', + protectedLabel: 'password protected', + failed: 'The attachment could not be copied to Google Drive.', + }; +} + +/** + * Cheap, local detection on the encrypted bytes – no decryption involved. + * Returns 'pdf' | 'ooxml' | 'zip' or null. + */ +function detectProtected_(bytes) { + var n = bytes.length; + function at(i) { + return bytes[i] & 0xff; + } + function ascii(from, to) { + var s = ''; + for (var i = from; i < Math.min(to, n); i++) s += String.fromCharCode(at(i)); + return s; + } + if (ascii(0, 1024).indexOf('%PDF-') !== -1) { + // the /Encrypt entry lives in the trailer or the cross-reference stream + return ascii(Math.max(0, n - 65536), n).indexOf('/Encrypt') !== -1 || ascii(0, 65536).indexOf('/Encrypt') !== -1 + ? 'pdf' + : null; + } + var cfb = [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1]; + if ( + n > 8 && + cfb.every(function (b, i) { + return at(i) === b; + }) + ) { + // encrypted OOXML stores its streams under these UTF-16 names + return ascii(0, Math.min(n, 1 << 20)).indexOf('E\u0000n\u0000c\u0000r\u0000y\u0000p\u0000t\u0000i\u0000o\u0000n\u0000I\u0000n\u0000f\u0000o') !== -1 + ? 'ooxml' + : null; + } + if (n > 8 && at(0) === 0x50 && at(1) === 0x4b && at(2) === 0x03 && at(3) === 0x04) { + // any local file header with general purpose flag bit 0 (= encrypted) + for (var i = 0; i + 8 < n; i++) { + if (at(i) === 0x50 && at(i + 1) === 0x4b && at(i + 2) === 0x03 && at(i + 3) === 0x04 && (at(i + 6) & 1) === 1) { + return 'zip'; + } + } + return null; + } + return null; +} + +function onGmailMessageOpen(e) { + var s = strings_(e); + GmailApp.setCurrentMessageAccessToken(e.gmail.accessToken); + var message = GmailApp.getMessageById(e.gmail.messageId); + var attachments = message.getAttachments({ includeInlineImages: false }); + + var section = CardService.newCardSection().addWidget(CardService.newTextParagraph().setText(s.intro)); + var found = 0; + attachments.forEach(function (att, index) { + if (att.getSize() > MAX_BYTES) return; + var kind = detectProtected_(att.getBytes()); + if (!kind) return; + found++; + section.addWidget( + CardService.newDecoratedText() + .setText(att.getName()) + .setBottomLabel(s.protectedLabel) + .setWrapText(true) + .setButton( + CardService.newTextButton() + .setText(s.open) + .setOnClickAction( + CardService.newAction() + .setFunctionName('openInUnpassword') + .setParameters({ messageId: e.gmail.messageId, index: String(index) }), + ), + ), + ); + }); + if (!found) section.addWidget(CardService.newTextParagraph().setText(s.none)); + + return CardService.newCardBuilder().setHeader(CardService.newCardHeader().setTitle(s.header)).addSection(section).build(); +} + +function inboxFolderId_() { + var q = + "mimeType = 'application/vnd.google-apps.folder' and name = '" + + INBOX_FOLDER.replace(/'/g, "\\'") + + "' and trashed = false"; + // With drive.file this only sees folders unpassword created itself. + var res = Drive.Files.list({ q: q, fields: 'files(id)', pageSize: 1 }); + if (res.files && res.files.length) return res.files[0].id; + return Drive.Files.create({ name: INBOX_FOLDER, mimeType: 'application/vnd.google-apps.folder' }, null, { + fields: 'id', + }).id; +} + +function openInUnpassword(e) { + var s = strings_(e); + try { + GmailApp.setCurrentMessageAccessToken(e.gmail.accessToken); + var params = e.commonEventObject.parameters; + var message = GmailApp.getMessageById(params.messageId); + var att = message.getAttachments({ includeInlineImages: false })[Number(params.index)]; + // The blob is the encrypted attachment exactly as received. + var file = Drive.Files.create( + { name: att.getName(), parents: [inboxFolderId_()], appProperties: { unpassword: 'inbox' } }, + att.copyBlob(), + { fields: 'id' }, + ); + var url = webAppUrl_() + '#/drive?fileId=' + encodeURIComponent(file.id); + return CardService.newActionResponseBuilder() + .setOpenLink( + CardService.newOpenLink() + .setUrl(url) + .setOpenAs(CardService.OpenAs.FULL_SIZE) + .setOnClose(CardService.OnClose.NOTHING), + ) + .build(); + } catch (err) { + console.error('openInUnpassword failed: ' + (err && err.message)); + return CardService.newActionResponseBuilder() + .setNotification(CardService.newNotification().setText(s.failed)) + .build(); + } +} diff --git a/gmail-addon/appsscript.json b/gmail-addon/appsscript.json new file mode 100644 index 0000000..ddb8d1e --- /dev/null +++ b/gmail-addon/appsscript.json @@ -0,0 +1,26 @@ +{ + "timeZone": "Europe/Berlin", + "runtimeVersion": "V8", + "exceptionLogging": "NONE", + "oauthScopes": [ + "https://www.googleapis.com/auth/gmail.addons.execute", + "https://www.googleapis.com/auth/gmail.addons.current.message.readonly", + "https://www.googleapis.com/auth/drive.file" + ], + "dependencies": { + "enabledAdvancedServices": [{ "userSymbol": "Drive", "serviceId": "drive", "version": "v3" }] + }, + "urlFetchWhitelist": [], + "addOns": { + "common": { + "name": "unpassword", + "logoUrl": "https://nullthrone.github.io/unpassword/brand/icon-128.png", + "layoutProperties": { "primaryColor": "#141317", "secondaryColor": "#A87E2F" }, + "openLinkUrlPrefixes": ["https://nullthrone.github.io/unpassword/app/"], + "useLocaleFromApp": true + }, + "gmail": { + "contextualTriggers": [{ "unconditional": {}, "onTriggerFunction": "onGmailMessageOpen" }] + } + } +} diff --git a/gmail-addon/detect.test.mjs b/gmail-addon/detect.test.mjs new file mode 100644 index 0000000..891bf51 --- /dev/null +++ b/gmail-addon/detect.test.mjs @@ -0,0 +1,28 @@ +// Runs the add-on's attachment detection against the shared fixtures (node --test). +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; +import test from 'node:test'; +import assert from 'node:assert/strict'; +import vm from 'node:vm'; + +const ctx = {}; +vm.runInNewContext(readFileSync(join(import.meta.dirname, 'Code.js'), 'utf8'), ctx); +const fixtures = join(import.meta.dirname, '..', 'web', 'tests', 'fixtures'); +// Apps Script hands out bytes as signed Java bytes +const bytes = (p) => Array.from(readFileSync(join(fixtures, p)), (b) => (b > 127 ? b - 256 : b)); + +test('detects protected attachments', () => { + assert.equal(ctx.detectProtected_(bytes('pdf/restricted-aes256.pdf')), 'pdf'); + assert.equal(ctx.detectProtected_(bytes('pdf/owner-only.pdf')), 'pdf'); + assert.equal(ctx.detectProtected_(bytes('office/agile.docx')), 'ooxml'); + assert.equal(ctx.detectProtected_(bytes('office/standard.docx')), 'ooxml'); + assert.equal(ctx.detectProtected_(bytes('zip/zipcrypto.zip')), 'zip'); + assert.equal(ctx.detectProtected_(bytes('zip/aes.zip')), 'zip'); + assert.equal(ctx.detectProtected_(bytes('zip/partial.zip')), 'zip'); +}); + +test('ignores unprotected attachments', () => { + assert.equal(ctx.detectProtected_(bytes('pdf/plain.pdf')), null); + assert.equal(ctx.detectProtected_(bytes('office/plain.docx')), null); + assert.equal(ctx.detectProtected_(bytes('zip/plain.zip')), null); +}); diff --git a/scripts/crosscheck.py b/scripts/crosscheck.py new file mode 100644 index 0000000..2b2b84e --- /dev/null +++ b/scripts/crosscheck.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 +"""Cross-check unpassword's outputs with independent implementations. + + cd web && UNPASSWORD_DUMP=/tmp/up npx vitest run tests/dump.test.ts + python3 scripts/crosscheck.py /tmp/up + +Requires: pip install pikepdf msoffcrypto-tool +""" +import io +import sys +import zipfile +from pathlib import Path + +import msoffcrypto +import pikepdf + +ROOT = Path(__file__).resolve().parent.parent +PLAIN_ZIP = ROOT / "web" / "tests" / "fixtures" / "zip" / "plain.zip" + + +def check_pdf(path: Path, mode: str): + pdf = pikepdf.open(path) # no password + if mode == "decrypted": + assert not pdf.is_encrypted, "still encrypted" + else: + assert pdf.is_encrypted, "restrictions were dropped" + allow = pdf.allow + assert not allow.extract and not allow.print_highres, f"restrictions lost: {allow}" + assert len(pdf.pages) == 1 + + +def check_ooxml(path: Path): + data = path.read_bytes() + assert not msoffcrypto.OfficeFile(io.BytesIO(data)).is_encrypted(), "still encrypted" + with zipfile.ZipFile(io.BytesIO(data)) as z: + assert z.testzip() is None + assert "[Content_Types].xml" in z.namelist() + + +def check_zip(path: Path, source: str): + with zipfile.ZipFile(path) as z: + assert z.testzip() is None + for info in z.infolist(): + assert not info.flag_bits & 0x1, f"{info.filename} still encrypted" + if source in ("zipcrypto.zip", "aes.zip"): + with zipfile.ZipFile(PLAIN_ZIP) as ref: + for name in ref.namelist(): + if not name.endswith("/"): + assert z.read(name) == ref.read(name), f"{name} differs" + + +def main(directory: str): + files = sorted(Path(directory).iterdir()) + if not files: + raise SystemExit("no outputs found") + failed = 0 + for f in files: + # __.. + kind, rest = f.name.split("__", 1) + source, _which, mode = rest.rsplit(".", 2) + try: + if kind == "pdf": + check_pdf(f, mode) + elif kind == "office": + check_ooxml(f) + else: + check_zip(f, source) + print(f"ok {f.name}") + except Exception as e: # noqa: BLE001 + failed += 1 + print(f"FAIL {f.name}: {e}") + sys.exit(1 if failed else 0) + + +if __name__ == "__main__": + main(sys.argv[1]) diff --git a/scripts/gen-fixtures.py b/scripts/gen-fixtures.py new file mode 100644 index 0000000..fac2543 --- /dev/null +++ b/scripts/gen-fixtures.py @@ -0,0 +1,200 @@ +#!/usr/bin/env python3 +"""Generate the encrypted test fixtures used by web/tests. + +Requirements: pip install pikepdf msoffcrypto-tool pyzipper, and the `zip` CLI +(ZipCrypto archives). Run from the repository root: + + python3 scripts/gen-fixtures.py + +Every password used here is listed in web/tests/fixtures/README.md. The files +are small and committed so the JS test suite runs without Python; this script +documents and reproduces how they were made. Encryption uses random salts, so +regenerated files differ byte-wise while remaining equivalent. +""" +import io +import shutil +import subprocess +import tempfile +import zipfile +from pathlib import Path + +import msoffcrypto +from msoffcrypto.format.ooxml import OOXMLFile +import pikepdf +import pyzipper + +ROOT = Path(__file__).resolve().parent.parent +OUT = ROOT / "web" / "tests" / "fixtures" + +USER_PW = "user-Pässwort1" +OWNER_PW = "owner-Pässwort2" +OFFICE_PW = "Büro-Geheim 42" +ZIP_PW = "zip-Geheim3" +ZIP_PW_OTHER = "something-else" + +FIXED_DATE = (2024, 1, 2, 3, 4, 6) + + +def pdf_doc() -> pikepdf.Pdf: + pdf = pikepdf.new() + pdf.add_blank_page(page_size=(200, 200)) + content = b"BT /F1 24 Tf 20 100 Td (unpassword test) Tj ET" + page = pdf.pages[0] + page.obj.Resources = pikepdf.Dictionary( + Font=pikepdf.Dictionary( + F1=pikepdf.Dictionary(Type=pikepdf.Name.Font, Subtype=pikepdf.Name.Type1, BaseFont=pikepdf.Name.Helvetica) + ) + ) + page.obj.Contents = pdf.make_stream(content) + pdf.docinfo["/Title"] = "unpassword fixture" + return pdf + + +def save_pdf(name: str, **enc): + pdf = pdf_doc() + kwargs = {"static_id": True, "deterministic_id": False} + if enc: + kwargs["encryption"] = pikepdf.Encryption(**enc) + pdf.save(OUT / "pdf" / name, **kwargs) + + +ALLOW_ALL = pikepdf.Permissions( + accessibility=True, + extract=True, + modify_annotation=True, + modify_assembly=True, + modify_form=True, + modify_other=True, + print_lowres=True, + print_highres=True, +) +RESTRICTED = pikepdf.Permissions(extract=False, print_highres=False, modify_other=False, modify_assembly=False) + + +def gen_pdf(): + (OUT / "pdf").mkdir(parents=True, exist_ok=True) + save_pdf("plain.pdf") + # open password, no restrictions + save_pdf("user-aes256.pdf", user=USER_PW, owner=OWNER_PW, R=6, allow=ALLOW_ALL) + # open password plus restrictions, three cipher generations + save_pdf("restricted-aes256.pdf", user=USER_PW, owner=OWNER_PW, R=6, allow=RESTRICTED) + save_pdf("restricted-aes128.pdf", user=USER_PW, owner=OWNER_PW, R=4, aes=True, allow=RESTRICTED) + save_pdf("restricted-rc4.pdf", user=USER_PW, owner=OWNER_PW, R=3, aes=False, metadata=False, allow=RESTRICTED) + # no open password, only owner restrictions + save_pdf("owner-only.pdf", user="", owner=OWNER_PW, R=6, allow=RESTRICTED) + + +def minimal_docx() -> bytes: + files = { + "[Content_Types].xml": ( + '' + '' + '' + '' + '' + "" + ), + "_rels/.rels": ( + '' + '' + '' + ), + "word/document.xml": ( + '' + '' + "unpassword test" + + "Lorem ipsum dolor sit amet." * 120 + + "" + ), + } + buf = io.BytesIO() + # Stored, not deflated: msoffcrypto-tool's OLE writer corrupts streams that + # land in the mini stream (< 4096 bytes), so the package must be larger. + with zipfile.ZipFile(buf, "w", zipfile.ZIP_STORED) as z: + for name, text in files.items(): + z.writestr(zipfile.ZipInfo(name, FIXED_DATE), text) + data = buf.getvalue() + assert len(data) > 4096 + return data + + +def gen_office(): + (OUT / "office").mkdir(parents=True, exist_ok=True) + plain = minimal_docx() + (OUT / "office" / "plain.docx").write_bytes(plain) + out = io.BytesIO() + OOXMLFile(io.BytesIO(plain)).encrypt(OFFICE_PW, out) + (OUT / "office" / "agile.docx").write_bytes(out.getvalue()) + check = msoffcrypto.OfficeFile(io.BytesIO(out.getvalue())) + check.load_key(password=OFFICE_PW) + decrypted = io.BytesIO() + check.decrypt(decrypted, verify_integrity=True) + assert decrypted.getvalue() == plain + # Files produced by Microsoft Office itself, and ECMA-376 Standard + # encryption (which msoffcrypto-tool cannot produce), come from the + # msoffcrypto-tool test suite (MIT licence, password "Password1234_"): + # office/standard.docx <- tests/inputs/ecma376standard_password.docx + # office/office-agile.docx <- tests/inputs/example_password.docx + # office/office-agile.xlsx <- tests/inputs/example_password.xlsx + + +def aes_info(z, name): + info = z.zipinfo_cls(name, FIXED_DATE) + info.compress_type = pyzipper.ZIP_DEFLATED + return info + + +def gen_zip(): + d = OUT / "zip" + d.mkdir(parents=True, exist_ok=True) + payload = { + "readme.txt": b"unpassword test archive\n" * 20, + "docs/statement.txt": "Kontoauszug – Umlaute äöü\n".encode() * 50, + } + with tempfile.TemporaryDirectory() as tmp: + t = Path(tmp) + for name, data in payload.items(): + p = t / name + p.parent.mkdir(parents=True, exist_ok=True) + p.write_bytes(data) + for f in ["zipcrypto.zip", "plain.zip"]: + (d / f).unlink(missing_ok=True) + subprocess.run(["zip", "-q", "-X", "-r", "-P", ZIP_PW, str(d / "zipcrypto.zip"), "readme.txt", "docs"], cwd=t, check=True) + subprocess.run(["zip", "-q", "-X", "-r", str(d / "plain.zip"), "readme.txt", "docs"], cwd=t, check=True) + + with pyzipper.AESZipFile(d / "aes.zip", "w", compression=pyzipper.ZIP_DEFLATED, encryption=pyzipper.WZ_AES) as z: + z.setpassword(ZIP_PW.encode()) + for name, data in payload.items(): + z.writestr(aes_info(z, name), data) + + # two entries encrypted with different passwords: must be rejected + with pyzipper.AESZipFile(d / "mixed.zip", "w", compression=pyzipper.ZIP_DEFLATED, encryption=pyzipper.WZ_AES) as z: + z.setpassword(ZIP_PW.encode()) + z.writestr(aes_info(z, "a.txt"), b"first") + z.setpassword(ZIP_PW_OTHER.encode()) + z.writestr(aes_info(z, "b.txt"), b"second") + + # one encrypted entry next to an unencrypted one: allowed + buf = io.BytesIO() + with pyzipper.AESZipFile(buf, "w", compression=pyzipper.ZIP_DEFLATED) as z: + z.writestr(aes_info(z, "public.txt"), b"not secret") + with pyzipper.AESZipFile(buf, "a", compression=pyzipper.ZIP_DEFLATED, encryption=pyzipper.WZ_AES) as z: + z.setpassword(ZIP_PW.encode()) + z.writestr(aes_info(z, "secret.txt"), b"secret") + (d / "partial.zip").write_bytes(buf.getvalue()) + + +def main(): + if not shutil.which("zip"): + raise SystemExit("the `zip` CLI is required for ZipCrypto fixtures") + gen_pdf() + gen_office() + gen_zip() + print(f"fixtures written to {OUT}") + + +if __name__ == "__main__": + main() diff --git a/scripts/render-brand-assets.mjs b/scripts/render-brand-assets.mjs new file mode 100644 index 0000000..1fcc4b9 --- /dev/null +++ b/scripts/render-brand-assets.mjs @@ -0,0 +1,130 @@ +// Renders unpassword's PNG brand assets and Marketplace screenshots into +// design/unpassword/png/. Uses the Playwright Chromium from web/node_modules. +// +// cd web && npm run build && cd .. && node scripts/render-brand-assets.mjs +// +// Set PLAYWRIGHT_CHROMIUM_PATH to use a preinstalled Chromium binary. +import { createServer } from 'node:http'; +import { mkdirSync, readFileSync, existsSync, statSync } from 'node:fs'; +import { createRequire } from 'node:module'; +import { extname, join, normalize } from 'node:path'; + +const ROOT = join(import.meta.dirname, '..'); +const OUT = join(ROOT, 'design/unpassword/png'); +const require = createRequire(join(ROOT, 'web/package.json')); +const { chromium } = require('@playwright/test'); + +const INK = '#141317'; +const PAPER = '#F4F2EC'; +const BRASS = '#C09A4B'; + +const svg = (file) => readFileSync(join(ROOT, 'design/unpassword', file), 'utf8'); +// Fonts inlined as data URIs: pages rendered via setContent may not load file:// URLs. +const fontsCss = readFileSync(join(ROOT, 'design/nullthrone/tokens/fonts.css'), 'utf8').replace( + /url\('\.\.\/fonts\/([^']+)'\)/g, + (_, f) => `url('data:font/woff2;base64,${readFileSync(join(ROOT, 'design/nullthrone/fonts', f)).toString('base64')}')`, +); + +function page(width, height, inner, bg = 'transparent') { + return `${inner}`; +} + +const browser = await chromium.launch( + process.env.PLAYWRIGHT_CHROMIUM_PATH ? { executablePath: process.env.PLAYWRIGHT_CHROMIUM_PATH } : {}, +); +mkdirSync(OUT, { recursive: true }); + +async function shot(name, width, height, html) { + const p = await browser.newPage({ viewport: { width, height } }); + await p.setContent(html, { waitUntil: 'load' }); + await p.evaluate(() => document.fonts.ready); + await p.screenshot({ path: join(OUT, name), omitBackground: true }); + await p.close(); + console.log(` ${name}`); +} + +// Icons: ink square with the paper mark – legible on light and dark Marketplace backgrounds. +for (const size of [16, 32, 48, 96, 128]) { + const file = size <= 32 ? 'mark-small.svg' : 'mark.svg'; + const pad = Math.round(size * (size <= 32 ? 0.14 : 0.18)); + const inner = `
+ ${svg(file).replace('`; + await shot(`icon-${size}.png`, size, size, page(size, size, inner)); +} + +// Marketplace card banner 220 × 140 +await shot( + 'banner-220x140.png', + 220, + 140, + page( + 220, + 140, + `
+ ${svg('mark.svg').replace('unpassword
+
by Nullthrone
+
`, + INK, + ), +); + +// Social card 1200 × 630 +await shot( + 'social-card.png', + 1200, + 630, + page( + 1200, + 630, + `
+
+
Open source · Zero knowledge · by Nullthrone
+
Remove passwords
you already know.
+
PDF · Office · ZIP, decrypted in your browser.
+
+
+ ${svg('mark.svg').replace(' +
`, + INK, + ), +); + +// Marketplace screenshots 1280 × 800 from the built web app (web/dist), English UI. +const dist = join(ROOT, 'web/dist'); +if (!existsSync(join(dist, 'index.html'))) { + console.log(' (skipping screenshots: build web/ first)'); +} else { + const types = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.wasm': 'application/wasm', '.svg': 'image/svg+xml', '.woff2': 'font/woff2' }; + const server = createServer((req, res) => { + let p = normalize(join(dist, decodeURIComponent(new URL(req.url, 'http://x').pathname))); + if (!p.startsWith(dist)) return res.writeHead(403).end(); + if (existsSync(p) && statSync(p).isDirectory()) p = join(p, 'index.html'); + if (!existsSync(p)) return res.writeHead(404).end(); + res.writeHead(200, { 'Content-Type': types[extname(p)] ?? 'application/octet-stream' }).end(readFileSync(p)); + }).listen(0); + const url = `http://localhost:${server.address().port}/`; + const fixtures = join(ROOT, 'web/tests/fixtures'); + const ctx = await browser.newContext({ viewport: { width: 1280, height: 800 }, locale: 'en-US', colorScheme: 'light' }); + const p = await ctx.newPage(); + await p.goto(url); + await p.evaluate(() => document.fonts.ready); + await p.screenshot({ path: join(OUT, 'screenshot-1-pick.png') }); + await p.locator('#file').setInputFiles(join(fixtures, 'pdf/restricted-aes256.pdf')); + await p.getByLabel('Current password').fill('user-Pässwort1'); + await p.getByLabel(/I am entitled/).check(); + await p.screenshot({ path: join(OUT, 'screenshot-2-password.png') }); + await p.getByRole('button', { name: 'Remove password protection' }).click(); + await p.getByText(/open password is removed/).waitFor(); + await p.screenshot({ path: join(OUT, 'screenshot-3-result.png') }); + console.log(' screenshot-1-pick.png, screenshot-2-password.png, screenshot-3-result.png'); + await ctx.close(); + server.close(); +} + +await browser.close(); +console.log(`brand assets written to ${OUT}`); diff --git a/site/build.mjs b/site/build.mjs new file mode 100644 index 0000000..8a9a1b0 --- /dev/null +++ b/site/build.mjs @@ -0,0 +1,332 @@ +// Builds the unpassword documentation site into ../_site (or --out DIR). +// Sources: site/index.html (landing page), docs/*.md (rendered into the page +// template), design/ (tokens, fonts, brand assets). Optionally copies a built +// web app into /app (--app DIR). The output contains no JavaScript. +import { + cpSync, + existsSync, + mkdirSync, + readFileSync, + rmSync, + writeFileSync, +} from "node:fs"; +import { dirname, join, normalize, posix } from "node:path"; +import { parseArgs } from "node:util"; +import { Marked } from "marked"; + +const ROOT = join(import.meta.dirname, ".."); +const REPO = "https://github.com/nullthrone/unpassword"; +export const SITE_URL = "https://nullthrone.github.io/unpassword/"; + +const { values: args } = parseArgs({ + options: { out: { type: "string" }, app: { type: "string" } }, +}); +const OUT = args.out ? normalize(args.out) : join(ROOT, "_site"); + +/** Markdown documents published as pages: repo path → route and page eyebrow. */ +export const DOCS = [ + { + src: "docs/SECURITY.md", + route: "security", + eyebrow: "Security model", + nav: "Security", + }, + { + src: "docs/PRIVACY.md", + route: "privacy", + eyebrow: "Policy", + nav: "Privacy", + }, + { src: "docs/TERMS.md", route: "terms", eyebrow: "Policy" }, + { + src: "docs/SETUP.md", + route: "setup", + eyebrow: "Documentation", + nav: "Setup", + }, + { src: "docs/SUPPORT.md", route: "support", eyebrow: "Help", nav: "Support" }, + { src: "docs/IMPRINT.md", route: "imprint", eyebrow: "Legal" }, +]; + +const CSP = [ + "default-src 'self'", + "script-src 'none'", + "style-src 'self'", + "img-src 'self' data:", + "font-src 'self'", + "object-src 'none'", + "base-uri 'none'", + "form-action 'none'", + "frame-src 'none'", +].join("; "); + +const esc = (s) => + s + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """); +const read = (p) => readFileSync(join(ROOT, p), "utf8"); + +function slug(text) { + return text + .toLowerCase() + .replace(/<[^>]+>/g, "") + .replace(/&[a-z]+;/g, "") + .replace(/[^\w\s-]/g, "") + .trim() + .replace(/\s+/g, "-"); +} + +/** Rewrites a link found in a repo file to its published location. */ +function rewriteHref(href, fromRepoPath, depth) { + if (/^([a-z]+:|#|\/\/)/i.test(href)) return href; + const [path, hash = ""] = href.split("#"); + const anchor = hash ? `#${hash}` : ""; + const target = posix.normalize(posix.join(posix.dirname(fromRepoPath), path)); + const prefix = "../".repeat(depth); + const doc = DOCS.find((d) => d.src === target); + if (doc) return `${prefix}${doc.route}/${anchor}`; + if (target === "README.md") return `${prefix}${anchor}`; + return `${REPO}/blob/main/${target}${anchor}`; +} + +function renderMarkdown(src, depth) { + const marked = new Marked({ gfm: true }); + marked.use({ + renderer: { + heading({ tokens, depth: level }) { + const html = this.parser.parseInline(tokens); + const id = slug(html); + return `${html}\n`; + }, + link({ href, title, tokens }) { + const text = this.parser.parseInline(tokens); + const out = rewriteHref(href, src, depth); + const external = /^https?:/.test(out); + return `${text}`; + }, + }, + }); + // wide tables scroll inside a wrapper instead of widening the page + return marked + .parse(read(src)) + .replaceAll("", '
') + .replaceAll("
", "
"); +} + +/** unpassword mark (small variant) as inline SVG, fills with currentColor. */ +function inlineMark(file, size) { + return read(`design/unpassword/${file}`) + .replace(/\s*role="img"/, "") + .replace(/\s*aria-label="[^"]*"/, "") + .replace( + " + + + + +${esc(pageTitle)} + + + + + + + + + + + +
+ +
+
+${body} +
+ + + +`; +} + +function docPage(doc) { + const html = renderMarkdown(doc.src, 1); + const m = html.match(/

([\s\S]*?)<\/h1>\n?/); + const title = m ? m[1].replace(/<[^>]+>/g, "") : doc.route; + const content = m ? html.replace(m[0], "") : html; + const body = `
+

${esc(doc.eyebrow)}

+

${m ? m[1] : esc(title)}

+ +
+${content} +
+
`; + return layout({ + title, + description: `${title} of unpassword, the zero-knowledge tool to remove passwords you already know from PDF, Office and ZIP files.`, + depth: 1, + body, + active: `${doc.route}/`, + }); +} + +function marketplacePage() { + const assets = [ + ["icon-32.png", "Icon 32 × 32"], + ["icon-48.png", "Icon 48 × 48"], + ["icon-96.png", "Icon 96 × 96"], + ["icon-128.png", "Icon 128 × 128 (also the Gmail add-on logo)"], + ["banner-220x140.png", "Card banner 220 × 140"], + ["social-card.png", "Social card 1200 × 630"], + ["screenshot-1-pick.png", "Screenshot 1280 × 800 – choose a file"], + ["screenshot-2-password.png", "Screenshot 1280 × 800 – enter the password"], + ["screenshot-3-result.png", "Screenshot 1280 × 800 – result"], + ["mark.svg", "Mark (SVG, currentColor)"], + ["favicon.svg", "Favicon (SVG, light/dark)"], + ]; + const rows = assets + .map( + ([file, label]) => + `
  • ${label}brand/${file}
  • `, + ) + .join("\n"); + const body = `
    +

    Google Workspace Marketplace

    +

    Brand assets

    + +

    Graphics for the Marketplace listing, generated from design/unpassword by scripts/render-brand-assets.mjs. The URLs the listing references are in the setup guide.

    +
      +${rows} +
    +
    `; + return layout({ + title: "Brand assets", + description: + "Icons, banner and screenshots of unpassword for the Google Workspace Marketplace listing.", + depth: 1, + body, + active: "marketplace/", + }); +} + +/** Concatenates design tokens and site styles into one stylesheet (no @import chains). */ +function stylesheet() { + const files = [ + "fonts", + "colors", + "typography", + "spacing", + "effects", + "motion", + "base", + ]; + const tokens = files + .map((f) => + read(`design/nullthrone/tokens/${f}.css`).replaceAll( + "url('../fonts/", + "url('fonts/", + ), + ) + .join("\n"); + return `/* Generated by site/build.mjs – edit site/styles/site.css or design/nullthrone/tokens */\n${tokens}\n${read("site/styles/site.css")}`; +} + +function write(rel, content) { + const file = join(OUT, rel); + mkdirSync(dirname(file), { recursive: true }); + writeFileSync(file, content); +} + +export function build() { + rmSync(OUT, { recursive: true, force: true }); + mkdirSync(OUT, { recursive: true }); + + write("index.html", layout({ ...landing(), depth: 0, active: "" })); + for (const doc of DOCS) write(`${doc.route}/index.html`, docPage(doc)); + write("marketplace/index.html", marketplacePage()); + write( + "404.html", + layout({ + title: "Not found", + description: "This page does not exist.", + depth: 0, + body: `

    404

    This page does not exist.

    Go to the overview.

    `, + }).replace(/(href|src)="(?!https?:|\/|#|mailto:)/g, '$1="/unpassword/'), + ); + + write("assets/site.css", stylesheet()); + cpSync(join(ROOT, "design/nullthrone/fonts"), join(OUT, "assets/fonts"), { + recursive: true, + }); + cpSync(join(ROOT, "design/unpassword/png"), join(OUT, "brand"), { + recursive: true, + }); + for (const f of ["mark.svg", "mark-small.svg", "favicon.svg"]) { + cpSync(join(ROOT, "design/unpassword", f), join(OUT, "brand", f)); + } + write(".nojekyll", ""); + + if (args.app) { + if (!existsSync(join(args.app, "index.html"))) + throw new Error(`no web app build in ${args.app}`); + cpSync(args.app, join(OUT, "app"), { recursive: true }); + } + console.log(`site written to ${OUT}`); +} + +function landing() { + const body = read("site/index.html") + .replaceAll("{{MARK}}", inlineMark("mark.svg", 132)) + .replaceAll("{{REPO}}", REPO); + return { + title: "", + description: + "unpassword removes the password protection of PDF, Office and ZIP files whose password you know – entirely in your browser. Zero-knowledge, open source, for Google Workspace.", + body, + bodyClass: "home", + }; +} + +if (import.meta.url === `file://${process.argv[1]}`) build(); diff --git a/site/check.mjs b/site/check.mjs new file mode 100644 index 0000000..ff4fc00 --- /dev/null +++ b/site/check.mjs @@ -0,0 +1,86 @@ +// Static checks for the built site (../_site or --dir DIR): +// - every page has a CSP meta tag and a +// - no page loads a resource from another origin (src, stylesheet, icon) +// - every internal link and anchor resolves +import { existsSync, readFileSync, readdirSync, statSync } from "node:fs"; +import { dirname, join, normalize, relative } from "node:path"; +import { parseArgs } from "node:util"; + +const { values: args } = parseArgs({ options: { dir: { type: "string" } } }); +const DIR = normalize(args.dir ?? join(import.meta.dirname, "..", "_site")); +/** Generated at deploy time, not present in local builds. */ +const DEPLOY_ONLY = new Set(["SHA256SUMS.txt"]); + +function htmlFiles(dir) { + return readdirSync(dir).flatMap((n) => { + const p = join(dir, n); + if (statSync(p).isDirectory()) + return relative(DIR, p) === "app" ? [] : htmlFiles(p); + return p.endsWith(".html") ? [p] : []; + }); +} + +const errors = []; +const ids = new Map(); +const files = htmlFiles(DIR); +for (const f of files) + ids.set( + f, + new Set( + [...readFileSync(f, "utf8").matchAll(/\sid="([^"]+)"/g)].map((m) => m[1]), + ), + ); + +function resolveTarget(from, url) { + const [path, hash] = url.split("#"); + let target = path ? normalize(join(dirname(from), path)) : from; + if ( + path.endsWith("/") || + (existsSync(target) && statSync(target).isDirectory()) + ) + target = join(target, "index.html"); + return { target, hash }; +} + +for (const f of files) { + const rel = relative(DIR, f); + const html = readFileSync(f, "utf8"); + if (!/<meta http-equiv="Content-Security-Policy"/.test(html)) + errors.push(`${rel}: missing CSP`); + if (!/<title>[^<]+<\/title>/.test(html)) + errors.push(`${rel}: missing <title>`); + if (/<script\b/i.test(html)) errors.push(`${rel}: contains a <script>`); + + for (const m of html.matchAll( + /<(img|script|source|iframe)\b[^>]*\ssrc="([^"]+)"/g, + )) { + if (/^(https?:)?\/\//.test(m[2])) + errors.push(`${rel}: external resource ${m[2]}`); + } + for (const m of html.matchAll(/<link\b[^>]*\shref="([^"]+)"/g)) { + if (/^(https?:)?\/\//.test(m[1])) + errors.push(`${rel}: external resource ${m[1]}`); + } + if (rel === "404.html") continue; // absolute /unpassword/ links, checked via the other pages + for (const m of html.matchAll(/<a\b[^>]*\shref="([^"]+)"/g)) { + const href = m[1]; + if (/^(https?:|mailto:)/.test(href)) continue; + const { target, hash } = resolveTarget(f, href); + if (DEPLOY_ONLY.has(relative(DIR, target))) continue; + if (relative(DIR, target).startsWith("app/")) { + if (!existsSync(join(DIR, "app"))) continue; // app copied only with --app + } + if (!existsSync(target)) { + errors.push(`${rel}: broken link ${href}`); + continue; + } + if (hash && target.endsWith(".html") && !ids.get(target)?.has(hash)) + errors.push(`${rel}: missing anchor ${href}`); + } +} + +if (errors.length) { + console.error(errors.join("\n")); + process.exit(1); +} +console.log(`site ok: ${files.length} pages checked in ${DIR}`); diff --git a/site/index.html b/site/index.html new file mode 100644 index 0000000..c5e3a38 --- /dev/null +++ b/site/index.html @@ -0,0 +1,325 @@ +<section class="hero band"> + <div class="wrap hero-inner"> + <div class="hero-copy"> + <p class="eyebrow">Open source · MIT license · by Nullthrone</p> + <h1>Remove passwords you already know.</h1> + <p class="lede"> + unpassword removes the password protection of PDF, Office and ZIP files + in your browser, so you can archive them under protection you control. + The password never leaves your device. Neither does the file. + </p> + <div class="cta"> + <a class="button accent" href="app/">Open unpassword</a> + <a class="button outline-inverse" href="{{REPO}}" rel="noopener" + >Read the source</a + > + </div> + </div> + <div class="hero-mark" aria-hidden="true">{{MARK}}</div> + </div> +</section> + +<section class="facts"> + <div class="wrap facts-inner"> + <div> + <span class="fact">No server</span + ><span + >Decryption runs in a web worker on your device. There is no backend to + trust.</span + > + </div> + <div> + <span class="fact">No guessing</span + ><span + >One typed password per attempt. Failed attempts slow down and + lock.</span + > + </div> + <div> + <span class="fact">No tracking</span + ><span + >No analytics, no cookies, no third-party fonts. This page loads no + scripts.</span + > + </div> + </div> +</section> + +<section class="section wrap" id="how-it-works"> + <p class="eyebrow">How it works</p> + <h2>Three steps. One password. Your archive.</h2> + <div class="double-rule" aria-hidden="true"></div> + <ol class="steps"> + <li> + <span class="step-no">01</span> + <h3>Select the file</h3> + <p> + Drop it into the web app, pick it from Google Drive, use + <em>Open with</em> in Drive, or open a Gmail attachment through the + add-on. + </p> + </li> + <li> + <span class="step-no">02</span> + <h3>Enter the password</h3> + <p> + Use the password you were given. unpassword checks it against the file’s + own encryption. It does not try alternatives. + </p> + </li> + <li> + <span class="step-no">03</span> + <h3>Archive your way</h3> + <p> + Download the unlocked file, or save it next to the original in Drive. + Protect it with your account security instead of a sender’s file + password. + </p> + </li> + </ol> +</section> + +<section class="section wrap split" id="zero-knowledge"> + <div> + <p class="eyebrow">Architecture</p> + <h2>Zero knowledge, by construction.</h2> + <p> + unpassword is a static web app. Its provider hosts files and nothing else. + No server receives your document, your password or the decrypted result. + </p> + <ul class="ticks"> + <li> + Decryption runs in an isolated web worker: qpdf compiled to WebAssembly + for PDF, the ECMA-376 algorithms for Office, zip.js for archives. + </li> + <li> + A Content Security Policy lets the app talk only to its own origin and + to Google’s APIs. The browser blocks everything else. + </li> + <li> + Drive access uses the <code>drive.file</code> scope: only files you + select or that unpassword creates. + </li> + <li> + The Gmail add-on handles the encrypted attachment only. It never sees a + password. + </li> + </ul> + <p><a href="security/">Read the security model</a></p> + </div> + <figure class="diagram"> + <svg viewBox="0 0 480 400" role="img" aria-labelledby="dg-title dg-desc"> + <title id="dg-title">Data flow + + The browser decrypts locally and exchanges files only with Google Drive. + The Gmail add-on stores the encrypted attachment in Drive. The + unpassword provider only serves static files and receives no data. + + + + + + + + Your browser + + Web worker + password · decryption + plaintext in memory only + UI · download + CSP: own origin + Google APIs + + + Google + Drive API + OAuth · Picker + your files + + + Gmail add-on + encrypted only + + + + + + unpassword provider + + serves static files (GitHub Pages) + + + receives no files, passwords or results + + + code only + + + + +
    +
    +
    +

    Guardrails

    +

    Not a cracking tool.

    +

    + unpassword exists for files you are entitled to open. It is built to be + useless against files you are not. +

    +
    +
      +
    • + One password per attempt. Typed by you. No lists, no + imports, no generators. +
    • +
    • + Rate limited. Two free failures, then 5 s, 10 s, 20 s … + and a lock after ten. +
    • +
    • + Restrictions are kept. A PDF’s open password removes + the open protection only. Print and copy restrictions stay unless you + enter the owner password. +
    • +
    • + Nothing to crack offline. Hashes, verifiers and salts + are never exported. +
    • +
    • + No bypassing. DRM, certificate protection and sheet + protection are refused. +
    • +
    • + Stated plainly. These limits run on your device and are + not a cryptographic boundary. unpassword adds no attack capability: the + work an attacker faces is the same with or without it. +
    • +
    +
    +
    + +
    +

    Formats

    +

    What unpassword unlocks.

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    FormatProtectionResult
    PDFStandard security handler: RC4, AES-128, AES-256 + Open password removed. Restrictions kept unless the owner password + is supplied. +
    DOCX · XLSX · PPTXECMA-376 Agile and Standard encryptionUnencrypted Office document, integrity-checked
    ZIPZipCrypto, WinZip AES-128/192/256Unencrypted ZIP with the same entries, every entry verified
    +
    +

    + Not supported: legacy .doc/.xls/.ppt, 7z and RAR, DRM, certificate-based + protection, worksheet protection. +

    +
    + +
    +

    Get it

    +

    Where unpassword runs.

    + +
    +
    +

    Web app

    +

    In any browser

    +

    + Open the app and drop a file. No account needed. Nothing is uploaded. +

    +

    Open the web app

    +
    +
    +

    Google Drive

    +

    Open with unpassword

    +

    + After installing from the Google Workspace Marketplace, right-click a + protected file in Drive and choose Open with → unpassword. +

    +

    Requires the drive.file scope

    +
    +
    +

    Gmail

    +

    From an attachment

    +

    + The add-on lists protected attachments of the open message and hands the + still-encrypted file to the web app via Drive. +

    +

    Reads the open message only

    +
    +
    +

    + Administrators and self-hosters: see the setup guide. +

    +
    + +
    +
    +

    Verify

    +

    Check what you run.

    +
    +
    +

    + Every deployment is built by GitHub Actions from a tagged commit. The + checksums of all published files are listed in + SHA256SUMS.txt. Build the same tag yourself, with the same public Google identifiers, + and compare the app/ entries. +

    +
    git clone {{REPO}}
    +cd unpassword/web && npm ci && npm run build
    +sha256sum dist/assets/*
    +
    +
    diff --git a/site/package-lock.json b/site/package-lock.json new file mode 100644 index 0000000..3238d0f --- /dev/null +++ b/site/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "unpassword-site", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "unpassword-site", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "marked": "^18.1.0" + } + }, + "node_modules/marked": { + "version": "18.1.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-18.1.0.tgz", + "integrity": "sha512-PamYXWWWg2nboG3oX5Ffzpy3EFZROqZJK9hSlMmUnekp7TxPs5DcT95vwd46m73/exfKCRVMtgXoPMI4FEJL6w==", + "license": "MIT", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 20" + } + } + } +} diff --git a/site/package.json b/site/package.json new file mode 100644 index 0000000..f03f211 --- /dev/null +++ b/site/package.json @@ -0,0 +1,16 @@ +{ + "name": "unpassword-site", + "version": "0.1.0", + "private": true, + "description": "Documentation site for unpassword (GitHub Pages, Workspace Marketplace reference).", + "license": "MIT", + "type": "module", + "scripts": { + "build": "node build.mjs", + "check": "node check.mjs", + "test": "node --test" + }, + "dependencies": { + "marked": "^18.1.0" + } +} diff --git a/site/styles/site.css b/site/styles/site.css new file mode 100644 index 0000000..20c8aa3 --- /dev/null +++ b/site/styles/site.css @@ -0,0 +1,804 @@ +/* unpassword documentation site – Nullthrone Design System. + Tokens come first in the generated stylesheet (see build.mjs). */ + +* { + box-sizing: border-box; +} + +html { + scroll-padding-top: var(--space-5); +} + +body { + display: flex; + flex-direction: column; + min-height: 100vh; +} + +main { + flex: 1; +} + +.wrap, +.wrap-narrow { + width: 100%; + margin: 0 auto; + padding: 0 var(--space-4); +} + +.wrap { + max-width: var(--container-max); +} + +.wrap-narrow { + max-width: 800px; +} + +@media (min-width: 720px) { + .wrap, + .wrap-narrow { + padding: 0 var(--container-pad); + } +} + +.skip { + position: absolute; + left: -9999px; +} + +.skip:focus { + left: var(--space-4); + top: var(--space-4); + z-index: 10; + padding: var(--space-2) var(--space-3); + background: var(--surface-card); + box-shadow: var(--focus-ring); +} + +/* -------------------------------------------------------------- caps type */ + +.eyebrow, +.wordmark, +.byline, +.nav a, +.footer-nav a, +.button, +.fact, +.step-no, +th { + font-family: var(--font-display); + font-weight: var(--weight-display); + text-transform: uppercase; + letter-spacing: var(--track-caps); +} + +.eyebrow { + margin: 0 0 var(--space-2); + font-size: var(--text-xs); + letter-spacing: var(--track-caps-wide); + color: var(--text-accent); +} + +h1 { + font-size: var(--display-lg); +} + +h2 { + font-size: var(--display-md); + margin-bottom: var(--space-4); +} + +h3 { + font-size: var(--display-sm); + margin-bottom: var(--space-2); +} + +code { + font-size: 0.9em; +} + +a:focus-visible, +.button:focus-visible { + outline: none; + box-shadow: var(--focus-ring); +} + +.double-rule { + border-top: var(--line-strong); + padding-top: 3px; + margin: var(--space-4) 0 var(--space-6); +} + +.double-rule::after { + content: ""; + display: block; + border-top: var(--line-strong); +} + +.muted { + color: var(--text-muted); + font-size: var(--text-sm); +} + +/* -------------------------------------------------------------- bands */ + +.band { + background: var(--surface-inverse); + color: var(--text-inverse); +} + +.band a { + color: var(--text-inverse); +} + +.band-inner { + min-height: 64px; + display: flex; + align-items: center; + justify-content: space-between; + flex-wrap: wrap; + gap: var(--space-3) var(--space-6); + padding-top: var(--space-3); + padding-bottom: var(--space-3); +} + +.brand { + display: inline-flex; + align-items: center; + gap: var(--space-3); + text-decoration: none; +} + +.brand:hover { + color: var(--brass-400); +} + +.wordmark { + font-size: 14px; + letter-spacing: var(--track-caps-wide); +} + +.byline { + font-size: var(--text-xs); + color: var(--ink-300); +} + +.nav { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-2) var(--space-5); +} + +.nav a { + font-size: var(--text-xs); + color: var(--ink-300); + text-decoration: none; + border-bottom: 1px solid transparent; + padding-bottom: 2px; + transition: color var(--dur-fast) var(--ease); +} + +.nav a:hover, +.nav a[aria-current="page"] { + color: var(--brass-400); + border-bottom-color: var(--brass-400); +} + +.band .nav-app { + color: var(--text-inverse); + border: 1px solid var(--ink-500); + padding: 6px var(--space-3); +} + +.band .nav-app:hover { + border-color: var(--brass-400); +} + +/* -------------------------------------------------------------- buttons */ + +.button { + display: inline-flex; + align-items: center; + height: var(--control-h-lg); + padding: 0 var(--space-5); + font-size: 13px; + text-decoration: none; + border: 1px solid transparent; + transition: + background var(--dur-fast) var(--ease), + border-color var(--dur-fast) var(--ease); +} + +.band .button.accent, +.button.accent { + background: var(--brass-500); + color: var(--paper); +} + +.button.accent:hover { + background: var(--brass-600); +} + +.button.accent:active { + background: var(--brass-700); +} + +.band .button.outline-inverse { + color: var(--text-inverse); + border-color: var(--ink-500); +} + +.button.outline-inverse:hover { + border-color: var(--text-inverse); +} + +/* -------------------------------------------------------------- hero */ + +.hero { + border-top: 1px solid var(--ink-700); +} + +.hero-inner { + display: grid; + grid-template-columns: 1fr; + gap: var(--space-6); + padding-top: var(--space-8); + padding-bottom: var(--space-8); + align-items: center; +} + +.hero .eyebrow { + color: var(--brass-400); +} + +.hero h1 { + font-size: clamp(36px, 6vw, var(--display-xl)); + max-width: 14ch; + margin-bottom: var(--space-5); +} + +.lede { + font-size: var(--text-lg); + max-width: 60ch; + margin: 0 0 var(--space-6); +} + +.hero .lede { + color: var(--ink-300); +} + +.cta { + display: flex; + flex-wrap: wrap; + gap: var(--space-3); +} + +.hero-mark { + display: none; + justify-self: center; + color: var(--text-inverse); +} + +.hero-mark svg { + width: 220px; + height: 220px; +} + +@media (min-width: 880px) { + .hero-inner { + grid-template-columns: 1fr auto; + } + + .hero-mark { + display: block; + padding: 0 var(--space-7); + border-left: 1px solid var(--ink-700); + } +} + +/* -------------------------------------------------------------- facts */ + +.facts { + border-bottom: var(--line); + background: var(--surface-card); +} + +.facts-inner { + display: grid; + grid-template-columns: 1fr; +} + +.facts-inner > div { + display: flex; + flex-direction: column; + gap: var(--space-1); + padding: var(--space-5) 0; + font-size: var(--text-sm); + color: var(--text-muted); +} + +.facts-inner > div + div { + border-top: var(--line); +} + +.fact { + font-size: 12px; + color: var(--text-body); +} + +@media (min-width: 720px) { + .facts-inner { + grid-template-columns: repeat(3, 1fr); + } + + .facts-inner > div { + padding: var(--space-5) var(--space-5); + } + + .facts-inner > div:first-child { + padding-left: 0; + } + + .facts-inner > div + div { + border-top: none; + border-left: var(--line); + } +} + +/* -------------------------------------------------------------- sections */ + +.section { + padding-top: var(--space-8); + padding-bottom: var(--space-4); +} + +.section:last-child { + padding-bottom: var(--space-8); +} + +.split { + display: grid; + grid-template-columns: 1fr; + gap: var(--space-6); +} + +@media (min-width: 880px) { + .split { + grid-template-columns: 1fr 1fr; + gap: var(--space-8); + align-items: start; + } +} + +.steps { + list-style: none; + margin: 0; + padding: 0; + display: grid; + grid-template-columns: 1fr; +} + +.steps li { + padding: var(--space-5) 0; +} + +.steps li + li { + border-top: var(--line); +} + +.steps p { + margin: 0; + color: var(--text-muted); +} + +.step-no { + display: block; + font-size: var(--text-xs); + color: var(--text-accent); + margin-bottom: var(--space-3); +} + +@media (min-width: 720px) { + .steps { + grid-template-columns: repeat(3, 1fr); + } + + .steps li { + padding: 0 var(--space-5); + } + + .steps li:first-child { + padding-left: 0; + } + + .steps li + li { + border-top: none; + border-left: var(--line); + } +} + +.ticks { + list-style: none; + padding: 0; + margin: var(--space-4) 0; + display: grid; + gap: var(--space-3); +} + +.ticks li { + position: relative; + padding-left: var(--space-5); +} + +.ticks li::before { + content: ""; + position: absolute; + left: 0; + top: 0.75em; + width: 10px; + border-top: 1px solid var(--brass-500); +} + +/* diagram */ + +.diagram { + margin: 0; + padding: var(--space-5); + background: var(--surface-card); + border: var(--line); + box-shadow: var(--shadow-1); +} + +.diagram svg { + width: 100%; + height: auto; + display: block; +} + +.dg-box, +.dg-box-strong, +.dg-box-accent, +.dg-box-dashed { + fill: var(--paper-white); + stroke: var(--border-mid); + stroke-width: 1; +} + +.dg-box-strong { + stroke: var(--border-strong); +} + +.dg-box-accent { + fill: var(--brass-100); + stroke: var(--brass-500); +} + +.dg-box-dashed { + fill: none; + stroke-dasharray: 4 4; +} + +.dg-line { + stroke: var(--ink-950); + stroke-width: 1.25; +} + +.dg-line-faint { + stroke: var(--ink-400); + stroke-width: 1; + stroke-dasharray: 3 3; +} + +.dg-fill { + fill: var(--ink-950); +} + +.dg-label { + font-family: var(--font-display); + font-size: 13px; + font-weight: 500; + letter-spacing: 0.12em; + text-transform: uppercase; + fill: var(--ink-950); +} + +.dg-text { + font-family: var(--font-body); + font-size: 13px; + fill: var(--ink-700); +} + +.dg-small { + font-family: var(--font-body); + font-size: 11px; + fill: var(--ink-500); +} + +/* guardrails (inverse) */ + +.section-inverse { + margin-top: var(--space-8); + padding: var(--space-8) 0; +} + +.section-inverse .eyebrow { + color: var(--brass-400); +} + +.section-inverse p { + color: var(--ink-300); +} + +.guardrails { + list-style: none; + margin: 0; + padding: 0; + border-top: 1px solid var(--ink-700); +} + +.guardrails li { + padding: var(--space-3) 0; + border-bottom: 1px solid var(--ink-700); + color: var(--ink-300); +} + +.guardrails strong { + color: var(--text-inverse); + font-weight: var(--weight-strong); +} + +/* tables */ + +.table-wrap { + overflow-x: auto; + margin: var(--space-4) 0; +} + +table { + width: 100%; + border-collapse: collapse; + font-size: 14px; +} + +th { + font-size: var(--text-xs); + text-align: left; + color: var(--ink-700); + border-bottom: var(--line-strong); + padding: var(--space-2) var(--space-3) var(--space-2) 0; +} + +td { + vertical-align: top; + padding: var(--space-3) var(--space-3) var(--space-3) 0; + border-bottom: var(--line); +} + +/* cards */ + +.cards { + display: grid; + grid-template-columns: 1fr; + gap: var(--space-5); + margin-bottom: var(--space-4); +} + +@media (min-width: 880px) { + .cards { + grid-template-columns: repeat(3, 1fr); + } +} + +.card { + display: flex; + flex-direction: column; + background: var(--surface-card); + border: var(--line); + box-shadow: var(--shadow-1); + padding: var(--space-5); +} + +.card p { + margin: 0; + font-size: 14px; + color: var(--text-muted); +} + +.card .eyebrow { + margin-bottom: var(--space-2); + color: var(--text-accent); +} + +.card-foot { + margin-top: auto !important; + padding-top: var(--space-4); + border-top: var(--line); + margin-block-start: var(--space-4) !important; + font-size: var(--text-sm) !important; +} + +/* verify */ + +.verify { + display: grid; + grid-template-columns: 1fr; + gap: var(--space-4); + margin-top: var(--space-4); +} + +@media (min-width: 880px) { + .verify { + grid-template-columns: 1fr 2fr; + } +} + +pre { + background: var(--surface-inverse); + color: var(--text-inverse); + padding: var(--space-4) var(--space-5); + overflow-x: auto; + font-size: 13px; + line-height: 1.7; +} + +/* -------------------------------------------------------------- documents */ + +.doc { + padding-top: var(--space-8); + padding-bottom: var(--space-8); +} + +.doc-wide { + padding-top: var(--space-8); + padding-bottom: var(--space-8); +} + +.doc h1 { + font-size: var(--display-lg); +} + +.prose { + max-width: 72ch; +} + +.prose h2 { + font-size: var(--display-sm); + margin: var(--space-7) 0 var(--space-3); + padding-top: var(--space-4); + border-top: var(--line); +} + +.prose h3 { + font-size: var(--text-lg); + font-family: var(--font-display); + margin: var(--space-5) 0 var(--space-2); +} + +.prose p, +.prose li { + max-width: 72ch; +} + +.prose ul, +.prose ol { + padding-left: var(--space-5); +} + +.prose li + li { + margin-top: var(--space-1); +} + +.prose blockquote { + margin: var(--space-4) 0; + padding: var(--space-2) var(--space-4); + border-left: 2px solid var(--brass-500); + color: var(--text-muted); +} + +.prose :not(pre) > code { + background: var(--surface-inset); + padding: 1px 4px; +} + +.prose em:only-child { + color: var(--text-muted); +} + +/* brand assets page */ + +.assets { + list-style: none; + padding: 0; + margin: var(--space-6) 0 0; + display: grid; + grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); + gap: var(--space-5); +} + +.asset { + display: flex; + flex-direction: column; + gap: var(--space-2); + padding: var(--space-4); + background: var(--surface-card); + border: var(--line); + font-size: var(--text-sm); +} + +.asset a { + display: flex; + align-items: center; + justify-content: center; + min-height: 140px; + background: var(--paper-white); + border: var(--line); + padding: var(--space-3); +} + +.asset img { + max-width: 100%; + max-height: 160px; +} + +.asset code { + color: var(--text-muted); + font-size: 12px; +} + +/* -------------------------------------------------------------- footer */ + +.footer { + border-top: 3px double var(--ink-500); +} + +.footer-inner { + display: grid; + gap: var(--space-5); + padding-top: var(--space-7); + padding-bottom: var(--space-7); +} + +.footer-brand { + display: flex; + align-items: center; + gap: var(--space-4); +} + +.footer-nav { + display: flex; + flex-wrap: wrap; + gap: var(--space-2) var(--space-5); + padding-top: var(--space-4); + border-top: 1px solid var(--ink-700); +} + +.footer-nav a { + font-size: var(--text-xs); + color: var(--ink-300); + text-decoration: none; +} + +.footer-nav a:hover { + color: var(--brass-400); +} + +.footer-note { + margin: 0; + font-size: var(--text-sm); + color: var(--ink-400); +} + +@media (max-width: 560px) { + .byline { + display: none; + } + + .footer-brand .byline { + display: block; + } + + h1 { + font-size: var(--display-md); + } +} diff --git a/web/.gitignore b/web/.gitignore new file mode 100644 index 0000000..31a56fb --- /dev/null +++ b/web/.gitignore @@ -0,0 +1,6 @@ +node_modules +dist +test-results +playwright-report +.env.local +dist-e2e diff --git a/web/.prettierignore b/web/.prettierignore new file mode 100644 index 0000000..ec05fb1 --- /dev/null +++ b/web/.prettierignore @@ -0,0 +1,6 @@ +dist +node_modules +tests/fixtures +test-results +playwright-report +dist-e2e diff --git a/web/.prettierrc.json b/web/.prettierrc.json new file mode 100644 index 0000000..f49b59f --- /dev/null +++ b/web/.prettierrc.json @@ -0,0 +1 @@ +{ "singleQuote": true, "printWidth": 120 } diff --git a/web/e2e/unpassword.spec.ts b/web/e2e/unpassword.spec.ts new file mode 100644 index 0000000..31783fc --- /dev/null +++ b/web/e2e/unpassword.spec.ts @@ -0,0 +1,254 @@ +import { expect, test, type Page, type Request, type Route } from '@playwright/test'; +import { readFileSync } from 'node:fs'; +import { createRequire } from 'node:module'; +import { join } from 'node:path'; +import { inspectEncryption, setQpdfWasmLocation } from '../src/core/pdf/qpdf'; + +setQpdfWasmLocation(createRequire(import.meta.url).resolve('@neslinesli93/qpdf-wasm/dist/qpdf.wasm')); + +const fixtures = join(import.meta.dirname, '..', 'tests', 'fixtures'); +const fixture = (p: string) => readFileSync(join(fixtures, p)); + +const PDF_USER = 'user-Pässwort1'; +const ZIP_PW = 'zip-Geheim3'; + +/** Records every request the page (and its workers) make. */ +function recordRequests(page: Page): Request[] { + const seen: Request[] = []; + page.context().on('request', (r) => seen.push(r)); + return seen; +} + +function assertNoLeak(requests: Request[], password: string, allowedHosts: string[]) { + for (const r of requests) { + const url = new URL(r.url()); + if (url.protocol === 'data:' || url.protocol === 'blob:') continue; + expect(allowedHosts, `unexpected host for ${r.url()}`).toContain(url.host); + expect(decodeURIComponent(r.url())).not.toContain(password); + const body = r.postDataBuffer(); + if (body) expect(body.toString('latin1')).not.toContain(password); + if (body) expect(body.toString('utf8')).not.toContain(password); + } +} + +async function unlock(page: Page, password: string) { + await page.getByLabel('Bisheriges Passwort').fill(password); + const attest = page.getByLabel(/Ich bin berechtigt/); + if (!(await attest.isChecked())) await attest.check(); + await page.getByRole('button', { name: 'Passwortschutz entfernen' }).click(); +} + +test('local mode: PDF with open password and restrictions', async ({ page }) => { + const requests = recordRequests(page); + await page.goto('./'); + await page.locator('#file').setInputFiles(join(fixtures, 'pdf/restricted-aes256.pdf')); + await expect(page.getByText('restricted-aes256.pdf')).toBeVisible(); + + await unlock(page, 'falsch'); + await expect(page.getByText(/Das Passwort ist falsch\. Noch 9 Versuche\./)).toBeVisible(); + + await unlock(page, PDF_USER); + await expect(page.getByText(/Der Öffnen-Schutz ist entfernt/)).toBeVisible(); + + const [download] = await Promise.all([ + page.waitForEvent('download'), + page.getByRole('button', { name: 'Herunterladen' }).click(), + ]); + expect(download.suggestedFilename()).toBe('restricted-aes256 (entsperrt).pdf'); + const out = new Uint8Array(readFileSync((await download.path())!)); + // opens without a password, restrictions intact + const info = await inspectEncryption(out, ''); + expect(info).toMatchObject({ encrypted: true, userPasswordMatched: true }); + expect(info?.capabilities).toMatchObject({ extract: false, printhigh: false, modifyassembly: false }); + + // local mode: nothing but this origin, and no Google script was loaded + assertNoLeak(requests, PDF_USER, ['localhost:4173']); +}); + +test('local mode: ZIP and Office files', async ({ page }) => { + const requests = recordRequests(page); + await page.goto('./'); + await page.locator('#file').setInputFiles(join(fixtures, 'zip/aes.zip')); + await unlock(page, ZIP_PW); + await expect(page.getByText(/nicht mehr passwortgeschützt/)).toBeVisible(); + + await page.getByRole('button', { name: 'Andere Datei' }).click(); + await page.locator('#file').setInputFiles(join(fixtures, 'office/office-agile.xlsx')); + await unlock(page, 'Password1234_'); + await expect(page.getByText(/nicht mehr passwortgeschützt/)).toBeVisible(); + const [download] = await Promise.all([ + page.waitForEvent('download'), + page.getByRole('button', { name: 'Herunterladen' }).click(), + ]); + expect(download.suggestedFilename()).toBe('office-agile (entsperrt).xlsx'); + expect( + readFileSync((await download.path())!) + .subarray(0, 2) + .toString(), + ).toBe('PK'); + + assertNoLeak(requests, ZIP_PW, ['localhost:4173']); +}); + +test('rate limiting: cooldown after the third failure', async ({ page }) => { + await page.goto('./'); + await page.locator('#file').setInputFiles(join(fixtures, 'zip/zipcrypto.zip')); + await unlock(page, 'a'); + await unlock(page, 'b'); + await unlock(page, 'c'); + await expect(page.getByText(/Nächster Versuch in \d+ s\./)).toBeVisible(); + await expect(page.getByRole('button', { name: 'Passwortschutz entfernen' })).toBeDisabled(); +}); + +test('refuses files without password protection', async ({ page }) => { + await page.goto('./'); + await page.locator('#file').setInputFiles(join(fixtures, 'pdf/plain.pdf')); + await unlock(page, 'irgendwas'); + await expect(page.getByText(/nicht passwortgeschützt/)).toBeVisible(); +}); + +test('the built page carries a restrictive CSP', async ({ page }) => { + await page.goto('./'); + const csp = await page.locator('meta[http-equiv="Content-Security-Policy"]').getAttribute('content'); + expect(csp).toContain("default-src 'self'"); + expect(csp).toContain("connect-src 'self' https://www.googleapis.com"); +}); + +// ----------------------------------------------------------------- Drive flow + +const CORS = { + 'access-control-allow-origin': '*', + 'access-control-allow-headers': '*', + 'access-control-allow-methods': 'GET, POST, PUT, PATCH, OPTIONS', + 'access-control-expose-headers': 'Location', +}; + +const GIS_STUB = ` +window.google = window.google || {}; +google.accounts = { oauth2: { initTokenClient(cfg) { + if (cfg.scope !== 'https://www.googleapis.com/auth/drive.file') throw new Error('unexpected scope ' + cfg.scope); + return { requestAccessToken() { setTimeout(() => cfg.callback({ access_token: 'e2e-token', expires_in: 3600 }), 0); } }; +} } };`; + +test('Drive mode: open from Gmail add-on link, unlock, save back to Drive', async ({ page }) => { + const requests = recordRequests(page); + const uploads: { meta?: unknown; body?: Buffer } = {}; + let trashed = false; + + await page.route('https://accounts.google.com/gsi/client', (route) => + route.fulfill({ contentType: 'text/javascript', body: GIS_STUB }), + ); + await page.route('https://www.googleapis.com/**', async (route: Route) => { + const req = route.request(); + if (req.method() === 'OPTIONS') return route.fulfill({ status: 204, headers: CORS }); + expect(req.headers()['authorization']).toBe('Bearer e2e-token'); + const url = new URL(req.url()); + if (url.pathname === '/drive/v3/files/FILE1' && url.searchParams.get('alt') === 'media') { + return route.fulfill({ headers: CORS, body: fixture('zip/aes.zip') }); + } + if (url.pathname === '/drive/v3/files/FILE1' && req.method() === 'GET') { + return route.fulfill({ + headers: CORS, + json: { id: 'FILE1', name: 'Lohnabrechnung.zip', mimeType: 'application/zip', parents: ['FOLDER'] }, + }); + } + if (url.pathname === '/drive/v3/files/FILE1' && req.method() === 'PATCH') { + trashed = JSON.parse(req.postData()!).trashed === true; + return route.fulfill({ headers: CORS, json: { id: 'FILE1' } }); + } + if (url.pathname === '/upload/drive/v3/files' && req.method() === 'POST') { + uploads.meta = JSON.parse(req.postData()!); + return route.fulfill({ + headers: { + ...CORS, + Location: 'https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&upload_id=U1', + }, + body: '', + }); + } + if (url.pathname === '/upload/drive/v3/files' && req.method() === 'PUT') { + uploads.body = req.postDataBuffer()!; + return route.fulfill({ headers: CORS, json: { id: 'NEW1', name: 'Lohnabrechnung (entsperrt).zip' } }); + } + return route.fulfill({ status: 404, headers: CORS, body: 'unexpected' }); + }); + + await page.goto('./#/drive?fileId=FILE1'); + await expect(page.getByText('Lohnabrechnung.zip')).toBeVisible(); + await unlock(page, ZIP_PW); + await expect(page.getByText(/nicht mehr passwortgeschützt/)).toBeVisible(); + + await page.getByLabel(/Originaldatei in den Papierkorb/).check(); + await page.getByRole('button', { name: 'In Google Drive speichern' }).click(); + await expect(page.getByText(/Gespeichert: Lohnabrechnung \(entsperrt\)\.zip/)).toBeVisible(); + + expect(uploads.meta).toEqual({ + name: 'Lohnabrechnung (entsperrt).zip', + mimeType: 'application/zip', + parents: ['FOLDER'], + appProperties: { unpassword: 'unlocked' }, + }); + // the uploaded archive is the decrypted one: a ZIP whose general purpose flag has no encryption bit + expect(uploads.body!.subarray(0, 4).toString('latin1')).toBe('PK\x03\x04'); + expect(uploads.body!.readUInt16LE(6) & 1).toBe(0); + expect(trashed).toBe(true); + + assertNoLeak(requests, ZIP_PW, ['localhost:4173', 'accounts.google.com', 'www.googleapis.com']); +}); + +test('Drive mode: falls back to My Drive when the original folder is not writable', async ({ page }) => { + const created: unknown[] = []; + await page.route('https://accounts.google.com/gsi/client', (route) => + route.fulfill({ contentType: 'text/javascript', body: GIS_STUB }), + ); + await page.route('https://www.googleapis.com/**', (route) => { + const req = route.request(); + if (req.method() === 'OPTIONS') return route.fulfill({ status: 204, headers: CORS }); + const url = new URL(req.url()); + if (url.searchParams.get('alt') === 'media') return route.fulfill({ headers: CORS, body: fixture('zip/aes.zip') }); + if (url.pathname.startsWith('/drive/v3/files/')) { + return route.fulfill({ + headers: CORS, + json: { id: 'F', name: 'a.zip', mimeType: 'application/zip', parents: ['NOACCESS'] }, + }); + } + if (req.method() === 'POST') { + const meta = JSON.parse(req.postData()!); + created.push(meta); + if (meta.parents) return route.fulfill({ status: 404, headers: CORS, json: { error: 'not found' } }); + return route.fulfill({ + headers: { ...CORS, Location: 'https://www.googleapis.com/upload/drive/v3/files?upload_id=U2' }, + body: '', + }); + } + return route.fulfill({ headers: CORS, json: { id: 'N', name: 'a (entsperrt).zip' } }); + }); + await page.goto('./#/drive?fileId=F'); + await unlock(page, ZIP_PW); + await page.getByRole('button', { name: 'In Google Drive speichern' }).click(); + await expect(page.getByText(/Gespeichert in „Meine Ablage“/)).toBeVisible(); + expect(created).toHaveLength(2); + expect(created[1]).not.toHaveProperty('parents'); +}); + +test('Drive "Open with" state parameter is honoured', async ({ page }) => { + await page.route('https://accounts.google.com/gsi/client', (route) => + route.fulfill({ contentType: 'text/javascript', body: GIS_STUB }), + ); + await page.route('https://www.googleapis.com/**', (route) => { + const req = route.request(); + if (req.method() === 'OPTIONS') return route.fulfill({ status: 204, headers: CORS }); + if (new URL(req.url()).searchParams.get('alt') === 'media') { + return route.fulfill({ headers: CORS, body: fixture('pdf/user-aes256.pdf') }); + } + return route.fulfill({ + headers: CORS, + json: { id: 'X', name: 'Befund.pdf', mimeType: 'application/pdf', parents: [] }, + }); + }); + const state = encodeURIComponent(JSON.stringify({ ids: ['X'], action: 'open', userId: '1' })); + await page.goto(`./?state=${state}`); + await expect(page.getByText('Befund.pdf')).toBeVisible(); + await unlock(page, PDF_USER); + await expect(page.getByText(/nicht mehr passwortgeschützt/)).toBeVisible(); +}); diff --git a/web/eslint.config.js b/web/eslint.config.js new file mode 100644 index 0000000..34e2e95 --- /dev/null +++ b/web/eslint.config.js @@ -0,0 +1,29 @@ +import js from '@eslint/js'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; + +export default tseslint.config( + { ignores: ['dist', 'dist-e2e', 'node_modules', 'test-results', 'playwright-report'] }, + js.configs.recommended, + ...tseslint.configs.recommended, + { + files: ['scripts/**', 'tests/**', 'e2e/**', '*.config.*'], + languageOptions: { globals: { ...globals.node } }, + }, + { + files: ['src/**/*.ts'], + languageOptions: { globals: { ...globals.browser } }, + rules: { + // Guardrails: no persistence of secrets, no dynamic code. + 'no-restricted-globals': [ + 'error', + { name: 'localStorage', message: 'unpassword never persists file data or passwords.' }, + { name: 'sessionStorage', message: 'unpassword never persists file data or passwords.' }, + { name: 'indexedDB', message: 'unpassword never persists file data or passwords.' }, + ], + 'no-eval': 'error', + 'no-implied-eval': 'error', + 'no-new-func': 'error', + }, + }, +); diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..94e64de --- /dev/null +++ b/web/index.html @@ -0,0 +1,19 @@ + + + + + + + + unpassword + + + +
    + + + + diff --git a/web/package-lock.json b/web/package-lock.json new file mode 100644 index 0000000..9ccd5c8 --- /dev/null +++ b/web/package-lock.json @@ -0,0 +1,2530 @@ +{ + "name": "unpassword-web", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "unpassword-web", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@neslinesli93/qpdf-wasm": "^0.3.0", + "@noble/ciphers": "^2.4.0", + "@noble/hashes": "^2.4.0", + "@zip.js/zip.js": "^2.23.0", + "cfb": "^1.2.2" + }, + "devDependencies": { + "@eslint/js": "^10.0.1", + "@playwright/test": "^1.63.0", + "@types/node": "^26.6.4", + "eslint": "^10.12.0", + "globals": "^17.13.0", + "prettier": "^3.9.9", + "typescript": "^6.0.3", + "typescript-eslint": "^8.71.1", + "vite": "^8.3.3", + "vitest": "^5.0.3" + } + }, + "node_modules/@cacheable/memory": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", + "integrity": "sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cacheable/utils": "^2.5.0", + "@keyv/bigmap": "^1.3.1", + "hookified": "^1.15.1", + "keyv": "^5.6.0" + } + }, + "node_modules/@cacheable/utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@cacheable/utils/-/utils-2.5.0.tgz", + "integrity": "sha512-buipgOVDkkPXNR5+xBpDw7Zk2n1EvU7qBJCNUcL7rhQ//kfpOXPAvQ511Os0vpLYJ1pZnvudNytkQt2hst3wqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hashery": "^1.5.1", + "keyv": "^5.6.0" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz", + "integrity": "sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", + "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.23.5", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.5.tgz", + "integrity": "sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^3.0.5", + "debug": "^4.3.1", + "minimatch": "^10.2.4" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.7.0.tgz", + "integrity": "sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/core": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.2.1.tgz", + "integrity": "sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/js": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-10.0.1.tgz", + "integrity": "sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "eslint": "^10.0.0" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/@eslint/object-schema": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-3.0.5.tgz", + "integrity": "sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.7.3.tgz", + "integrity": "sha512-IkO+/KEUvwbVpiURZg+P7zF74z5Jxe0UgJxVni+RtoHQ6IZieXaO02kmadomap/q+l6bc/jdPGGqTjhuZnuz1Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1", + "levn": "^0.4.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", + "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/types": "^0.15.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.8.tgz", + "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.2", + "@humanfs/types": "^0.15.0", + "@humanwhocodes/retry": "^0.4.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/types": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@humanfs/types/-/types-0.15.0.tgz", + "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@keyv/bigmap": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@keyv/bigmap/-/bigmap-1.3.1.tgz", + "integrity": "sha512-WbzE9sdmQtKy8vrNPa9BRnwZh5UF4s1KTmSK0KUVLo3eff5BlQNNWDnFOouNpKfPKDnms9xynJjsMYjMaT/aFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hashery": "^1.4.0", + "hookified": "^1.15.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "keyv": "^5.6.0" + } + }, + "node_modules/@keyv/serialize": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@keyv/serialize/-/serialize-1.1.1.tgz", + "integrity": "sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@neslinesli93/qpdf-wasm": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@neslinesli93/qpdf-wasm/-/qpdf-wasm-0.3.0.tgz", + "integrity": "sha512-ObyTmabopTMwN6AGwrEkmDbdmM5wnwlRdn9jnJYQ2KbBUPdPDcfNf1QkcWFOVD+qIgSqILz9nK51e22T+x+gkQ==", + "license": "ISC" + }, + "node_modules/@noble/ciphers": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-2.4.0.tgz", + "integrity": "sha512-AnjFn0Jv92laAkvMrghlFZq4qQCIN/4DxFV/eooqtC2YTjB7kBeLMS2T9KJX4Dn+ZVXLOwK0lSgqDtx9gvxtiw==", + "license": "MIT", + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.4.0.tgz", + "integrity": "sha512-X5XaVWZIBCT7HHZGm5I7ZQXDwLG+bGXuSrMQAW+7Zvl87h1kmc1ZB1VSRJcpUfoUrGQp4Fkoxm5kZ+Ms+aW+eA==", + "license": "MIT", + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.152.0.tgz", + "integrity": "sha512-oM/5rLBm2tPkg0iBgkH/FOeR3PCDpY19GTgAZjMFM8h9WI9VW7cLgzp6nwtarYKmovavIQZ+Fe/RKX/8C8O/Rw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/@playwright/test": { + "version": "1.63.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.63.0.tgz", + "integrity": "sha512-oxMK4vllB9RK5NQ2l1pq1IfOf2AvnEuj/vYGDj0H2nMtmtZpKtCwt/l00GEO6xjGfpBNAvjovvYdCm50dRQkpQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.63.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.12.tgz", + "integrity": "sha512-dB/a1214qKfHMXCpgqR4OZT+jS4kTyEXbQGJPqzobt5EwH5rX080pxE37alt3RzvR1bf1Yz/yGqRfrYAxuPw0A==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.12.tgz", + "integrity": "sha512-7KHFgQ5VJxIHcLlrwrc3Xbds7oTNQT7Pgi9gQCJKrd2VGab/UksIOYp6VD8MzCstGxOKMgNamPwUCfxPdP1OHg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.12.tgz", + "integrity": "sha512-3YIhqHD96nA5SaYNRBR16HnGv4oavZvXfD/ayHM+oYZ0WD/8lBAtf6zQua4kEyAvpqrluKXl0lnOBoiNby7x9w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.12.tgz", + "integrity": "sha512-UuuJ35MFw4gmFOrE9pEqIV+K3syIKveph+Qc1/ljHZVdoDW4pz/JHR/eMVom+TZGl/5OOvGJOWaOCVt3ZfqhxA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.12.tgz", + "integrity": "sha512-uMvssit0a4W+/7D8CbHUvG719mH3R2jwXAlh/XcPvuHTE0g++LymF88DCGNX0HM2rBOn0xrzgXktIB6fLSJBTQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.12.tgz", + "integrity": "sha512-XcFu0R0xWnwzSf4IQgFH1rJIckPN1pLy2R+4r9IDB7Yfu/ys9cVqfa4pBrMHj7a3gl8mIR4nRNPg0e5IvEVs6g==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.12.tgz", + "integrity": "sha512-260UrKgn8tz39ak+SMDOirKzr7V04M9dWPw5llW00SwBivCZoWcRBKV1d8cXnRkUmSZA3BdiUmBHWk7734Ulpw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.12.tgz", + "integrity": "sha512-5YK1I9SqDkbPgc1IA8BgDl34suqUS2q0KWnBrirm0E51YjOs6eo6dV6jbQfNE/argHRSvd0QUGgtpIoYx+WWpw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.12.tgz", + "integrity": "sha512-Rkcrmp7eFRg74yL5fXEU91JEWbdEPLevWwGtXpmhbjlD1StScbWTmO94Bhly+Mo+ketKYkdmM1vNUKeWSlx8cQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.12.tgz", + "integrity": "sha512-qvK4DuAsQc2BSjlx+Xr+IzOIvvxbGZqxFwdWfG6F518Erj0GGISyQbJ6pIappnOxlNPzNHvo/L0BwB30GZ+zVw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.12.tgz", + "integrity": "sha512-Q9uLBO53Xd4QIq1WOycVQyPP1O4HhraEV2qqb3uTrnVw6QZih9duY4vNXOivL1xoUS1/z+W8eF4NMfl2a8Sdjw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.12.tgz", + "integrity": "sha512-3IBxWFMjbOZskDPKv8Lf9BCnahlKuHthWkYnyIxOH/QcJrFcS4EmcenthApkwr/5+nEqZlLzeYbxeMaX7A5u4g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.12.tgz", + "integrity": "sha512-xtX61xg4LKPkPWilZU1ynKClz5Gj4bf74LML4r3eVLWumKnGjoEr1OSHQhMdbBDoYTi+yjrujvpZe2pUnqCrrA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.12.tgz", + "integrity": "sha512-At7fPB6PCaIjzgIhEZFxuT+BBFqiQibJDT4d3PhiR3f4E7bbMZF4aKblbFfEM3sETRDd1YiQx/+U/g/B/ou5Ew==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.12.tgz", + "integrity": "sha512-WIw2haVKwjuYdXkHaoC0mF8Le71TuCBxjrdKqLbJGctbBABj+ClfmNvtbOnzpq3RokNo5+V1qhtSzJyXorsklQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", + "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/esrecurse": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz", + "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "26.6.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.4.tgz", + "integrity": "sha512-ldVPDCzj7fsaGZrLB0NuHuTvJcsNasysBAqMolr/cgxrLd1xbqxIr3XJiPnHHJUCxj5sNF1vnRj9aWnrVh5Jcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~8.9.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.71.1.tgz", + "integrity": "sha512-nNlBf6HuotqMgZvSkWD5hNdemiBIxQ2NmrlgfcUIeZRs+BbakjscCQRq/Hb74EFVnFiSWWdL12JruqwBy3ERDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.71.1", + "@typescript-eslint/type-utils": "8.71.1", + "@typescript-eslint/utils": "8.71.1", + "@typescript-eslint/visitor-keys": "8.71.1", + "ignore": "^7.0.5", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.71.1", + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.12.tgz", + "integrity": "sha512-/8UvqAPU9DGTI9k4mxtf49U37Isfwr8Uts96+SBHIkFxPJnHS0Ew4f00sM4Scd8V8EjM0jUNtVDdv1kPdt35lg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.71.1.tgz", + "integrity": "sha512-oM/5sAqz/l1v/zYK1qTOPrn2+JIrBGC1V6uNYucRO5gh6eT9vWJ/RhPbGE59byvZEUQ4VP6XkLBaS5Jti5jpvw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.71.1", + "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/typescript-estree": "8.71.1", + "@typescript-eslint/visitor-keys": "8.71.1", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.71.1.tgz", + "integrity": "sha512-Oijc9RUsohHjncg6iGi7gCtjnEjYt9FWv9u6ygK8uKcHK5eLjLAkqERQ9BaytbpceOFdk6kifPCS/zAZE+A99g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.71.1", + "@typescript-eslint/types": "^8.71.1", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.71.1.tgz", + "integrity": "sha512-1YUDZXdTnXLlob03SFHBipdyMBsDVm7zoSz0ytTJ39dk5J1TgsTK03VlR/dLXG/RLLUrPcYbD4rp23BmHxHP0w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/visitor-keys": "8.71.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.71.1.tgz", + "integrity": "sha512-oTvkml5SxXhgg+WWKhod5qWQICDXtOB+/Hi9VdPKFAANJ2b7YOgMffgvzXuqog7R6A/JtrzRf128dsxummyWhg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.71.1.tgz", + "integrity": "sha512-kH3t3jZCYv2PZSBEWPKTariLrCaoF1CLoPitYFBJOhAGEwWnSRAtGEifrfrpBa4K9JlwWNZotgA5w3/wLSk/FQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/typescript-estree": "8.71.1", + "@typescript-eslint/utils": "8.71.1", + "debug": "^4.4.3", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.71.1.tgz", + "integrity": "sha512-ybYnPTUwg3VQQOFEiBPLs8Jxl1ry2vXdn1kVKguomBbvxpetdu3MKTNDqFNUrlG8ylP9MpZosmXMFYlGQHk1oQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.71.1.tgz", + "integrity": "sha512-pSKSEK1JJpHs6KiKVtABCE4iJK5d7FLFzDXQNBQ2oRY7LEd3UwOt3TZemTgu9syTIf56dJWlTn/pdmrO9oKUXQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.71.1", + "@typescript-eslint/tsconfig-utils": "8.71.1", + "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/visitor-keys": "8.71.1", + "debug": "^4.4.3", + "minimatch": "^10.2.2", + "semver": "^7.7.3", + "tinyglobby": "^0.2.15", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.71.1.tgz", + "integrity": "sha512-CBjT6gfAz3DW2j9Q4moFnqt208Aq+506sVGXfpRcyAeqn0EpayL0mjdWoCO2t3RC7GewNrFxdeehuEaPg6DMzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.71.1", + "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/typescript-estree": "8.71.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.71.1.tgz", + "integrity": "sha512-0GxiUGqMU0qXJt58cBsiG3DP8lUmBaFo2vChtUX+CT7PnR3v/VGLLrzVP4K9r1lNiZXjHYefMBbPunplr09v6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.71.1", + "eslint-visitor-keys": "^5.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@vitest/mocker": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.3.tgz", + "integrity": "sha512-T8sWAIbkSyAjkwTcaEc3Iu0o9A27X1/kdXrizhZkGuSKScRQtRzclfAMpOTcGdXCsqxeWlpGy3XjqaW8CpLORg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.31", + "@vitest/spy": "5.0.3", + "estree-walker": "^3.0.3", + "magic-string": "^1.2.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/spy": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.3.tgz", + "integrity": "sha512-XhFysQTB8AZ+P4gMi+Lpo99vg2AZi0qKpaB9yXQl37+CaMEAPO3iH/wGVnSyL5MPERiLezpqTVtrR6UZH5GCXg==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@zip.js/zip.js": { + "version": "2.23.0", + "resolved": "https://registry.npmjs.org/@zip.js/zip.js/-/zip.js-2.23.0.tgz", + "integrity": "sha512-K5obAqfrO7zhycnCupM9aaoZ9kx0SA0kv7+Z2oOUsdpWquv4s/Z4zyD7AdTqxrK3pgPM+ozaUi8kdRQbCWaIrQ==", + "license": "BSD-3-Clause", + "engines": { + "bun": ">=0.7.0", + "deno": ">=1.0.0", + "node": ">=18.0.0" + } + }, + "node_modules/acorn": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", + "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/adler-32": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz", + "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==", + "license": "Apache-2.0", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/cacheable": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/cacheable/-/cacheable-2.5.0.tgz", + "integrity": "sha512-60cyAOytib/OzBw1JNSoSV/boK1AtHryDIjvVBk7XbN4ugfkM3+Sry7fEjNgPMGgOjuaZPAp8ruZ0Cxafwyq9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cacheable/memory": "^2.2.0", + "@cacheable/utils": "^2.5.0", + "hookified": "^1.15.0", + "keyv": "^5.6.0", + "qified": "^0.10.1" + } + }, + "node_modules/cfb": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz", + "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", + "license": "Apache-2.0", + "dependencies": { + "adler-32": "~1.3.0", + "crc-32": "~1.2.0" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/chai": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz", + "integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "license": "Apache-2.0", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/es-module-lexer": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", + "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==", + "dev": true, + "license": "MIT" + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "10.12.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.12.0.tgz", + "integrity": "sha512-npHjrHb2o4ehH3mE+YuxABR+0gyb0aVWCIolgJDArwCiHEIsonBm3ZKjel5b0U5+a+MbEvIyRCGCzD3eKKK2NA==", + "dev": true, + "license": "MIT", + "workspaces": [ + "packages/*" + ], + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.2", + "@eslint/config-array": "^0.23.5", + "@eslint/config-helpers": "^0.7.0", + "@eslint/core": "^1.2.1", + "@eslint/plugin-kit": "^0.7.3", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.14.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^9.1.2", + "eslint-visitor-keys": "^5.0.1", + "espree": "^11.2.0", + "esquery": "^1.7.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "11.1.5 || >11.1.6 <12", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "minimatch": "^10.2.5", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-9.1.2.tgz", + "integrity": "sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@types/esrecurse": "^4.3.1", + "@types/estree": "^1.0.8", + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-11.2.0.tgz", + "integrity": "sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.16.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^5.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/expect-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/file-entry-cache": { + "version": "11.1.5", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-11.1.5.tgz", + "integrity": "sha512-+PFTHITI08JIGhnNpGNI8T8inUpgZfk3GNEqfT9R2zZV2iFXg3CvqzSl/uEhs7TSGujYRELEANyDvS8Fj7+S7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^6.1.23" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "6.1.23", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-6.1.23.tgz", + "integrity": "sha512-f++BY9pTk+983xK1FLzlLpmM0i0z+jHmx3QESGkURMXujQZz1k5wzwX6hjnQ8goaD0B+sYnDK1yZ6MTyZfUaqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cacheable": "^2.5.0", + "flatted": "^3.4.2", + "hookified": "^1.15.0" + } + }, + "node_modules/flatted": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.4.tgz", + "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==", + "dev": true, + "license": "ISC" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "17.13.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-17.13.0.tgz", + "integrity": "sha512-RwMTC61u7hrG3ZJMkZQOK4JLJrKS8QtoTii63EmWvFXHqycY9FObBJQCbsLxSO8kjKhWE5kV1GC+Vb1g3RI0Zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/hashery": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/hashery/-/hashery-1.5.1.tgz", + "integrity": "sha512-iZyKG96/JwPz1N55vj2Ie2vXbhu440zfUfJvSwEqEbeLluk7NnapfGqa7LH0mOsnDxTF85Mx8/dyR6HfqcbmbQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hookified": "^1.15.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/hookified": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-1.15.1.tgz", + "integrity": "sha512-MvG/clsADq1GPM2KGo2nyfaWVyn9naPiXrqIe4jYjXNZQt238kWyOGrsyc/DmRAQ+Re6yeo6yX/yoNCG5KAEVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/keyv": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.6.0.tgz", + "integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@keyv/serialize": "^1.1.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/magic-string": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.3.tgz", + "integrity": "sha512-z12OxmaPGE0F4xlpGdjuAUckipLpQlTAuAmyGhNoD7ODpYUzvDfvtxUbjM/jwznyP178oju/KDdyi220wNJ0RQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, + "node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/obug": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.2.1.tgz", + "integrity": "sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/playwright": { + "version": "1.63.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.63.0.tgz", + "integrity": "sha512-+7ziBLidS4NaNCdt57SUDT+wYmmd5fmiQejUic/kb+YsYSCPyOOE9sebzMjNmQrsnNpDJqd4WHvV/8lfKfUDUg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.63.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/playwright-core": { + "version": "1.63.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.63.0.tgz", + "integrity": "sha512-rYCsBF/M5HjUch52bbtVONEFjv6Xu8sm8h72dNlR5bzIE1fvC/bxgspzkjSfU+MweEMmPM8KJebG6nnyxo5mCg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/postcss": { + "version": "8.5.29", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.29.tgz", + "integrity": "sha512-49cGhUbXj8Qenv0iTMxA1cFBzxXoctpC9Ujd77t1WcbJIr6nF/eI7g/8MgxrYldFRuAXvja7xQRwavoW7kgrxQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.19", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.9.9", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.9.tgz", + "integrity": "sha512-Z/CJHIkdujO/OtN7nXUii0Rf3VT5SRuhjBA82Xvu2XhBUgX3nhP67T0LHceBdQLex7OOFGTox+Q5Yg8Jk2Qivg==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/qified": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/qified/-/qified-0.10.1.tgz", + "integrity": "sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hookified": "^2.1.1" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/qified/node_modules/hookified": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-2.2.0.tgz", + "integrity": "sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA==", + "dev": true, + "license": "MIT" + }, + "node_modules/rolldown": { + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.12.tgz", + "integrity": "sha512-8wafseiaG80xmXSfqidUNqZcylTlhmPZZt+za2m+js2sFZ8dTNlhIOV2WcbIPx2hgwPBJpEUGFAMZ9bgBBLTSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.152.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.12", + "@rolldown/binding-android-arm64": "1.2.12", + "@rolldown/binding-darwin-arm64": "1.2.12", + "@rolldown/binding-darwin-x64": "1.2.12", + "@rolldown/binding-freebsd-x64": "1.2.12", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.12", + "@rolldown/binding-linux-arm64-gnu": "1.2.12", + "@rolldown/binding-linux-arm64-musl": "1.2.12", + "@rolldown/binding-linux-ppc64-gnu": "1.2.12", + "@rolldown/binding-linux-s390x-gnu": "1.2.12", + "@rolldown/binding-linux-x64-gnu": "1.2.12", + "@rolldown/binding-linux-x64-musl": "1.2.12", + "@rolldown/binding-openharmony-arm64": "1.2.12", + "@rolldown/binding-win32-arm64-msvc": "1.2.12", + "@rolldown/binding-win32-x64-msvc": "1.2.12" + } + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/std-env": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.3.0.tgz", + "integrity": "sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.0.tgz", + "integrity": "sha512-78U2TlB2CnVenajOFzf3BKSm0J6oz5L0NV7g32LCPccvYc0lbWvys4d3uUUCS2B1N8PAf2+aekR8i1KbC3HO7Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/tinyexec": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", + "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/ts-api-utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", + "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/typescript": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", + "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/typescript-eslint": { + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.71.1.tgz", + "integrity": "sha512-oiNVPC3/NbV1FpaHU07l8O6ynqG9v4PAiW2WvTrAmZdR0f2HI/gE668ElMLCK7Xbsu5k2fK5C4fXNiq05j7/nQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.71.1", + "@typescript-eslint/parser": "8.71.1", + "@typescript-eslint/typescript-estree": "8.71.1", + "@typescript-eslint/utils": "8.71.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/undici-types": { + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz", + "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/vite": { + "version": "8.3.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.3.tgz", + "integrity": "sha512-cTAldKPImjg6c+gk48U19POPn3GCBzZwpdsN8ZMEEcbpes+6/wvfqUd0C2y3qYY4wsj8PwgFwrZ/1jBPVttMSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.7", + "postcss": "^8.5.28", + "rolldown": "~1.2.11", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.7.1", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vitest": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.3.tgz", + "integrity": "sha512-xMw97S3rjdtj5dkVat7jCsqWBpvchs3RlpQctUqwJD0KkERk40vz2fJ77lDwW/Vzh/pk18eItYAzkodhSes3jQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/mocker": "5.0.3", + "chai": "^6.2.2", + "es-module-lexer": "^2.3.2", + "expect-type": "^1.4.0", + "magic-string": "^1.2.3", + "obug": "^2.1.4", + "picomatch": "^4.0.7", + "std-env": "^4.2.0", + "tinybench": "^6.1.4", + "tinyexec": "^1.3.0", + "tinyglobby": "^0.2.17", + "why-is-node-running": "3.2.1" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^22.12.0 || ^24.0.0 || >=26.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "5.0.3", + "@vitest/browser-preview": "5.0.3", + "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", + "@vitest/coverage-istanbul": "5.0.3", + "@vitest/coverage-v8": "5.0.3", + "@vitest/ui": "5.0.3", + "happy-dom": "*", + "jsdom": "*", + "vite": "^6.4.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@opentelemetry/api": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/coverage-istanbul": { + "optional": true + }, + "@vitest/coverage-v8": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "vite": { + "optional": false + } + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/why-is-node-running": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz", + "integrity": "sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==", + "dev": true, + "license": "MIT", + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=20.11" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/web/package.json b/web/package.json new file mode 100644 index 0000000..bf4d80b --- /dev/null +++ b/web/package.json @@ -0,0 +1,37 @@ +{ + "name": "unpassword-web", + "version": "0.1.0", + "private": true, + "description": "Zero-knowledge removal of known passwords from PDF, Office and ZIP files – runs entirely in the browser.", + "license": "MIT", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc --noEmit && vite build && node scripts/checksums.mjs", + "preview": "vite preview", + "typecheck": "tsc --noEmit", + "lint": "eslint . && prettier --check .", + "format": "prettier --write .", + "test": "vitest run", + "test:e2e": "playwright test" + }, + "dependencies": { + "@neslinesli93/qpdf-wasm": "^0.3.0", + "@noble/ciphers": "^2.4.0", + "@noble/hashes": "^2.4.0", + "@zip.js/zip.js": "^2.23.0", + "cfb": "^1.2.2" + }, + "devDependencies": { + "@eslint/js": "^10.0.1", + "@playwright/test": "^1.63.0", + "@types/node": "^26.6.4", + "eslint": "^10.12.0", + "globals": "^17.13.0", + "prettier": "^3.9.9", + "typescript": "^6.0.3", + "typescript-eslint": "^8.71.1", + "vite": "^8.3.3", + "vitest": "^5.0.3" + } +} diff --git a/web/playwright.config.ts b/web/playwright.config.ts new file mode 100644 index 0000000..1d9542a --- /dev/null +++ b/web/playwright.config.ts @@ -0,0 +1,26 @@ +import { defineConfig } from '@playwright/test'; + +const PORT = 4173; +// Build with dummy Google identifiers so the Drive flow can be exercised +// against mocked Google endpoints. +const env = 'VITE_GOOGLE_CLIENT_ID=e2e-client VITE_GOOGLE_API_KEY=e2e-key VITE_GOOGLE_APP_ID=123456'; + +export default defineConfig({ + testDir: 'e2e', + timeout: 60_000, + use: { + baseURL: `http://localhost:${PORT}/`, + locale: 'de-DE', + acceptDownloads: true, + launchOptions: process.env.PLAYWRIGHT_CHROMIUM_PATH + ? { executablePath: process.env.PLAYWRIGHT_CHROMIUM_PATH } + : undefined, + }, + webServer: { + command: `${env} npx vite build --outDir dist-e2e && npx vite preview --outDir dist-e2e --port ${PORT} --strictPort`, + url: `http://localhost:${PORT}/`, + reuseExistingServer: !process.env.CI, + timeout: 120_000, + }, + projects: [{ name: 'chromium', use: { browserName: 'chromium' } }], +}); diff --git a/web/scripts/checksums.mjs b/web/scripts/checksums.mjs new file mode 100644 index 0000000..b483b97 --- /dev/null +++ b/web/scripts/checksums.mjs @@ -0,0 +1,19 @@ +// Writes /SHA256SUMS.txt so anyone can compare the deployed site with a local build. +import { createHash } from 'node:crypto'; +import { readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs'; +import { join, relative, resolve } from 'node:path'; + +// Directory to hash: first argument, default web/dist. +const dist = process.argv[2] ? resolve(process.argv[2]) : join(import.meta.dirname, '..', 'dist'); +const files = (dir) => + readdirSync(dir).flatMap((n) => { + const p = join(dir, n); + return statSync(p).isDirectory() ? files(p) : [p]; + }); + +const lines = files(dist) + .filter((p) => !p.endsWith('SHA256SUMS.txt')) + .map((p) => `${createHash('sha256').update(readFileSync(p)).digest('hex')} ${relative(dist, p)}`) + .sort((a, b) => a.slice(66).localeCompare(b.slice(66))); +writeFileSync(join(dist, 'SHA256SUMS.txt'), lines.join('\n') + '\n'); +console.log(lines.join('\n')); diff --git a/web/src/core/detect.ts b/web/src/core/detect.ts new file mode 100644 index 0000000..1bc5d46 --- /dev/null +++ b/web/src/core/detect.ts @@ -0,0 +1,27 @@ +import type { Format } from './types'; + +const CFB_MAGIC = [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1]; + +export type Detected = Format | 'cfb-other' | null; + +function startsWith(data: Uint8Array, bytes: number[], offset = 0): boolean { + if (data.length < offset + bytes.length) return false; + return bytes.every((b, i) => data[offset + i] === b); +} + +/** + * Identifies the container by its magic bytes. Encrypted OOXML files are not + * ZIPs but Compound File Binary containers; whether such a container really is + * encrypted OOXML (and not, say, a legacy .doc) is decided by the office module. + */ +export function detectFormat(data: Uint8Array): Format | null { + // PDF: "%PDF-" may be preceded by up to 1 KiB of junk. + const head = data.subarray(0, 1024 + 5); + for (let i = 0; i + 5 <= head.length; i++) { + if (head[i] === 0x25 && startsWith(head, [0x25, 0x50, 0x44, 0x46, 0x2d], i)) return 'pdf'; + } + if (startsWith(data, CFB_MAGIC)) return 'ooxml'; + // local file header, or end of central directory of an empty archive + if (startsWith(data, [0x50, 0x4b, 0x03, 0x04]) || startsWith(data, [0x50, 0x4b, 0x05, 0x06])) return 'zip'; + return null; +} diff --git a/web/src/core/guard.ts b/web/src/core/guard.ts new file mode 100644 index 0000000..5a1c011 --- /dev/null +++ b/web/src/core/guard.ts @@ -0,0 +1,71 @@ +import { UnpasswordError } from './types'; + +export interface GuardPolicy { + /** Failed attempts allowed without delay. */ + freeAttempts: number; + /** Delay after the first failure beyond `freeAttempts`, doubling afterwards. */ + baseDelayMs: number; + /** After this many failures the file is locked for the session. */ + maxFailures: number; +} + +export const DEFAULT_POLICY: GuardPolicy = { freeAttempts: 2, baseDelayMs: 5_000, maxFailures: 10 }; + +interface State { + failures: number; + nextAllowedAt: number; +} + +export interface GuardStatus { + failures: number; + remaining: number; + retryAfterMs: number; + locked: boolean; +} + +/** + * Rate limits password attempts per file. This is not a cryptographic + * boundary – the code is open source and runs on the user's machine – but it + * ensures that unpassword itself is useless as a guessing tool: it accepts one + * typed password at a time and slows down quickly. + */ +export class AttemptGuard { + private readonly states = new Map(); + + constructor( + private readonly policy: GuardPolicy = DEFAULT_POLICY, + private readonly now: () => number = () => Date.now(), + ) {} + + status(key: string): GuardStatus { + const s = this.states.get(key) ?? { failures: 0, nextAllowedAt: 0 }; + return { + failures: s.failures, + remaining: Math.max(0, this.policy.maxFailures - s.failures), + retryAfterMs: Math.max(0, s.nextAllowedAt - this.now()), + locked: s.failures >= this.policy.maxFailures, + }; + } + + /** Throws `locked` or `cooldown` if an attempt is not allowed right now. */ + assertAllowed(key: string): void { + const st = this.status(key); + if (st.locked) throw new UnpasswordError('locked', 'too many failed attempts for this file'); + if (st.retryAfterMs > 0) { + throw new UnpasswordError('cooldown', 'please wait before the next attempt', { retryAfterMs: st.retryAfterMs }); + } + } + + recordFailure(key: string): GuardStatus { + const s = this.states.get(key) ?? { failures: 0, nextAllowedAt: 0 }; + s.failures += 1; + const over = s.failures - this.policy.freeAttempts; + s.nextAllowedAt = over > 0 ? this.now() + this.policy.baseDelayMs * 2 ** (over - 1) : 0; + this.states.set(key, s); + return this.status(key); + } + + recordSuccess(key: string): void { + this.states.delete(key); + } +} diff --git a/web/src/core/index.ts b/web/src/core/index.ts new file mode 100644 index 0000000..9d7f50a --- /dev/null +++ b/web/src/core/index.ts @@ -0,0 +1,25 @@ +import { detectFormat } from './detect'; +import { UnpasswordError, MAX_INPUT_BYTES, type Format, type UnlockResult, type Unlocker } from './types'; + +export { detectFormat } from './detect'; +export { AttemptGuard, DEFAULT_POLICY } from './guard'; +export * from './types'; + +const loaders: Record Promise> = { + pdf: async () => (await import('./pdf/index')).unlockPdf, + ooxml: async () => (await import('./office/index')).unlockOoxml, + zip: async () => (await import('./zip/index')).unlockZip, +}; + +/** + * Removes the password protection from `input` using exactly one password the + * user knows. Never retries, never guesses. + */ +export async function unlock(input: Uint8Array, password: string): Promise { + if (password.length === 0) throw new UnpasswordError('empty-password'); + if (input.length > MAX_INPUT_BYTES) throw new UnpasswordError('too-large', 'file is too large'); + const format = detectFormat(input); + if (!format) throw new UnpasswordError('unsupported', 'unrecognised file type'); + const unlocker = await loaders[format](); + return unlocker(input, password); +} diff --git a/web/src/core/office/agile.ts b/web/src/core/office/agile.ts new file mode 100644 index 0000000..2572320 --- /dev/null +++ b/web/src/core/office/agile.ts @@ -0,0 +1,149 @@ +import { cbc } from '@noble/ciphers/aes.js'; +import { hmac } from '@noble/hashes/hmac.js'; +import { UnpasswordError } from '../types'; +import { + HASHES, + base64ToBytes, + concat, + constantTimeEqual, + fit, + iteratedHash, + le32, + packageBody, + type HashFn, +} from './util'; + +// MS-OFFCRYPTO 2.3.4.13 / 2.3.4.14 block keys +const BLOCK_VERIFIER_INPUT = Uint8Array.of(0xfe, 0xa7, 0xd2, 0x76, 0x3b, 0x4b, 0x9e, 0x79); +const BLOCK_VERIFIER_VALUE = Uint8Array.of(0xd7, 0xaa, 0x0f, 0x6d, 0x30, 0x61, 0x34, 0x4e); +const BLOCK_KEY_VALUE = Uint8Array.of(0x14, 0x6e, 0x0b, 0xe7, 0xab, 0xac, 0xd0, 0xd6); +const BLOCK_HMAC_KEY = Uint8Array.of(0x5f, 0xb2, 0xad, 0x01, 0x0c, 0xb9, 0xe1, 0xf6); +const BLOCK_HMAC_VALUE = Uint8Array.of(0xa0, 0x67, 0x7f, 0x02, 0xb2, 0x2c, 0x84, 0x33); + +const PASSWORD_KEY_ENCRYPTOR = 'http://schemas.microsoft.com/office/2006/keyEncryptor/password'; +const SEGMENT = 4096; +const MAX_SPIN_COUNT = 10_000_000; + +type Attrs = Record; + +/** Attributes of the first element with the given local name (namespace prefix ignored). */ +function element(xml: string, localName: string, from = 0): { attrs: Attrs; index: number } | null { + const re = new RegExp(`<(?:[A-Za-z_][\\w.-]*:)?${localName}\\b([^>]*)>`, 'g'); + re.lastIndex = from; + const m = re.exec(xml); + if (!m) return null; + const attrs: Attrs = {}; + for (const a of m[1].matchAll(/([\w:.-]+)\s*=\s*"([^"]*)"/g)) attrs[a[1]] = a[2]; + return { attrs, index: m.index }; +} + +interface CipherParams { + salt: Uint8Array; + blockSize: number; + keyBits: number; + hashSize: number; + hash: HashFn; +} + +function cipherParams(a: Attrs, what: string): CipherParams { + if (a.cipherAlgorithm !== 'AES' || a.cipherChaining !== 'ChainingModeCBC') { + throw new UnpasswordError('unsupported', `unsupported ${what} cipher ${a.cipherAlgorithm}/${a.cipherChaining}`); + } + const hash = HASHES[a.hashAlgorithm]; + if (!hash) throw new UnpasswordError('unsupported', `unsupported hash ${a.hashAlgorithm}`); + const keyBits = Number(a.keyBits); + const blockSize = Number(a.blockSize); + const hashSize = Number(a.hashSize); + if (![128, 192, 256].includes(keyBits) || blockSize !== 16 || !(hashSize > 0 && hashSize <= 64)) { + throw new UnpasswordError('unsupported', `unsupported ${what} parameters`); + } + return { salt: base64ToBytes(a.saltValue), blockSize, keyBits, hashSize, hash }; +} + +function aesCbcDecrypt(key: Uint8Array, iv: Uint8Array, data: Uint8Array): Uint8Array { + if (data.length % 16 !== 0) throw new UnpasswordError('corrupt', 'ciphertext is not block aligned'); + return cbc(key, iv, { disablePadding: true }).decrypt(data); +} + +export interface AgileResult { + data: Uint8Array; + integrityOk: boolean | null; +} + +export function decryptAgile(xmlBytes: Uint8Array, encryptedPackage: Uint8Array, password: string): AgileResult { + const xml = new TextDecoder('utf-8').decode(xmlBytes); + + const keyData = element(xml, 'keyData'); + const integrity = element(xml, 'dataIntegrity'); + const encryptor = element(xml, 'keyEncryptor'); + if (!keyData || !encryptor) throw new UnpasswordError('corrupt', 'incomplete encryption descriptor'); + if (encryptor.attrs.uri !== PASSWORD_KEY_ENCRYPTOR) { + // certificate-based key encryptors are not password protection + throw new UnpasswordError('unsupported', 'document is not password-encrypted'); + } + const encKey = element(xml, 'encryptedKey', encryptor.index); + if (!encKey) throw new UnpasswordError('corrupt', 'missing password key encryptor'); + + const kd = cipherParams(keyData.attrs, 'data'); + const pk = cipherParams(encKey.attrs, 'key'); + const spinCount = Number(encKey.attrs.spinCount); + if (!Number.isInteger(spinCount) || spinCount < 0 || spinCount > MAX_SPIN_COUNT) { + throw new UnpasswordError('unsupported', 'unsupported spin count'); + } + + // 2.3.4.11 password key derivation + const h = iteratedHash(pk.hash, pk.salt, password, spinCount); + const keyLen = pk.keyBits / 8; + const derive = (block: Uint8Array) => fit(pk.hash(concat(h, block)), keyLen); + + // 2.3.4.13 password verification + const verifierInput = fit( + aesCbcDecrypt(derive(BLOCK_VERIFIER_INPUT), pk.salt, base64ToBytes(encKey.attrs.encryptedVerifierHashInput)), + pk.salt.length, + ); + const verifierHash = aesCbcDecrypt( + derive(BLOCK_VERIFIER_VALUE), + pk.salt, + base64ToBytes(encKey.attrs.encryptedVerifierHashValue), + ).slice(0, pk.hashSize); + if (!constantTimeEqual(pk.hash(verifierInput).slice(0, pk.hashSize), verifierHash)) { + h.fill(0); + throw new UnpasswordError('wrong-password'); + } + + const secretKey = aesCbcDecrypt( + derive(BLOCK_KEY_VALUE), + pk.salt, + base64ToBytes(encKey.attrs.encryptedKeyValue), + ).slice(0, kd.keyBits / 8); + h.fill(0); + + // 2.3.4.14 data integrity: HMAC over the whole EncryptedPackage stream + let integrityOk: boolean | null = null; + if (integrity) { + const iv1 = fit(kd.hash(concat(kd.salt, BLOCK_HMAC_KEY)), kd.blockSize); + const iv2 = fit(kd.hash(concat(kd.salt, BLOCK_HMAC_VALUE)), kd.blockSize); + const hmacKey = aesCbcDecrypt(secretKey, iv1, base64ToBytes(integrity.attrs.encryptedHmacKey)).slice( + 0, + kd.hashSize, + ); + const expected = aesCbcDecrypt(secretKey, iv2, base64ToBytes(integrity.attrs.encryptedHmacValue)).slice( + 0, + kd.hashSize, + ); + const actual = hmac(kd.hash as never, hmacKey, encryptedPackage).slice(0, kd.hashSize); + integrityOk = constantTimeEqual(actual, expected); + } + + // 2.3.4.15 data encryption: 4096-byte segments, per-segment IV + const { size, body } = packageBody(encryptedPackage); + const out = new Uint8Array(body.length); + for (let seg = 0, off = 0; off < body.length; seg++, off += SEGMENT) { + const iv = fit(kd.hash(concat(kd.salt, le32(seg))), kd.blockSize); + out.set(aesCbcDecrypt(secretKey, iv, body.subarray(off, Math.min(off + SEGMENT, body.length))), off); + } + secretKey.fill(0); + const result = out.slice(0, size); + out.fill(0); + return { data: result, integrityOk }; +} diff --git a/web/src/core/office/container.ts b/web/src/core/office/container.ts new file mode 100644 index 0000000..a2f2b94 --- /dev/null +++ b/web/src/core/office/container.ts @@ -0,0 +1,33 @@ +import * as CFB from 'cfb'; +import { UnpasswordError } from '../types'; + +export interface EncryptedOoxml { + encryptionInfo: Uint8Array; + encryptedPackage: Uint8Array; +} + +function toBytes(blob: number[] | Uint8Array): Uint8Array { + return blob instanceof Uint8Array ? blob : Uint8Array.from(blob); +} + +/** + * Reads the two streams of an encrypted OOXML file (MS-OFFCRYPTO 2.3.4.4). + * CFB containers without them (legacy .doc/.xls/.ppt) are not supported. + */ +export function readEncryptedOoxml(data: Uint8Array): EncryptedOoxml { + let container: CFB.CFB$Container; + try { + container = CFB.parse(data, { type: 'array' } as CFB.CFB$ParsingOptions); + } catch (cause) { + throw new UnpasswordError('corrupt', 'not a valid compound file', { cause }); + } + const info = CFB.find(container, 'EncryptionInfo'); + const pkg = CFB.find(container, 'EncryptedPackage'); + if (!info?.content || !pkg?.content) { + throw new UnpasswordError( + 'unsupported', + 'legacy binary Office files (.doc/.xls/.ppt) are not supported; only encrypted .docx/.xlsx/.pptx', + ); + } + return { encryptionInfo: toBytes(info.content), encryptedPackage: toBytes(pkg.content) }; +} diff --git a/web/src/core/office/index.ts b/web/src/core/office/index.ts new file mode 100644 index 0000000..7253e95 --- /dev/null +++ b/web/src/core/office/index.ts @@ -0,0 +1,31 @@ +import { UnpasswordError, type UnlockResult, type UnlockWarning } from '../types'; +import { decryptAgile } from './agile'; +import { readEncryptedOoxml } from './container'; +import { decryptStandard } from './standard'; + +export async function unlockOoxml(input: Uint8Array, password: string): Promise { + const { encryptionInfo, encryptedPackage } = readEncryptedOoxml(input); + if (encryptionInfo.length < 8) throw new UnpasswordError('corrupt', 'EncryptionInfo too short'); + const v = new DataView(encryptionInfo.buffer, encryptionInfo.byteOffset, encryptionInfo.byteLength); + const major = v.getUint16(0, true); + const minor = v.getUint16(2, true); + const rest = encryptionInfo.subarray(8); + + let data: Uint8Array; + const warnings: UnlockWarning[] = []; + if (major === 4 && minor === 4) { + const r = decryptAgile(rest, encryptedPackage, password); + data = r.data; + if (r.integrityOk === false) warnings.push('integrity-check-failed'); + } else if ((major === 2 || major === 3 || major === 4) && minor === 2) { + data = decryptStandard(rest, encryptedPackage, password); + } else { + throw new UnpasswordError('unsupported', `unsupported Office encryption version ${major}.${minor}`); + } + + // The plaintext of an OOXML package is a ZIP file. + if (!(data[0] === 0x50 && data[1] === 0x4b && data[2] === 0x03 && data[3] === 0x04)) { + throw new UnpasswordError('corrupt', 'decrypted package is not an OOXML document'); + } + return { format: 'ooxml', mode: 'decrypted', warnings, data }; +} diff --git a/web/src/core/office/standard.ts b/web/src/core/office/standard.ts new file mode 100644 index 0000000..dad5e06 --- /dev/null +++ b/web/src/core/office/standard.ts @@ -0,0 +1,77 @@ +import { ecb } from '@noble/ciphers/aes.js'; +import { sha1 } from '@noble/hashes/legacy.js'; +import { UnpasswordError } from '../types'; +import { concat, constantTimeEqual, iteratedHash, le32, packageBody } from './util'; + +const ALG_AES128 = 0x660e; +const ALG_AES192 = 0x660f; +const ALG_AES256 = 0x6610; +const ALG_HASH_SHA1 = 0x8004; +const FLAG_CRYPTOAPI = 0x04; +const FLAG_AES = 0x20; +const SPIN_COUNT = 50_000; + +/** + * ECMA-376 Standard Encryption (MS-OFFCRYPTO 2.3.4.5 – 2.3.4.9). + * `data` is the EncryptionInfo stream starting after the 8-byte version/flags header. + */ +export function decryptStandard(info: Uint8Array, encryptedPackage: Uint8Array, password: string): Uint8Array { + const v = new DataView(info.buffer, info.byteOffset, info.byteLength); + const headerSize = v.getUint32(0, true); + const h = 4; // EncryptionHeader starts after headerSize field + const flags = v.getUint32(h, true); + const algId = v.getUint32(h + 8, true); + const algIdHash = v.getUint32(h + 12, true); + const keyBits = v.getUint32(h + 16, true); + + if (!(flags & FLAG_CRYPTOAPI) || !(flags & FLAG_AES)) { + throw new UnpasswordError('unsupported', 'only AES-based standard encryption is supported'); + } + if (![ALG_AES128, ALG_AES192, ALG_AES256].includes(algId) || (algIdHash !== 0 && algIdHash !== ALG_HASH_SHA1)) { + throw new UnpasswordError('unsupported', 'unsupported standard encryption algorithm'); + } + if (![128, 192, 256].includes(keyBits)) throw new UnpasswordError('unsupported', 'unsupported key size'); + + // EncryptionVerifier + let o = 4 + headerSize; + const saltSize = v.getUint32(o, true); + o += 4; + if (saltSize !== 16) throw new UnpasswordError('corrupt', 'unexpected salt size'); + const salt = info.slice(o, o + 16); + o += 16; + const encryptedVerifier = info.slice(o, o + 16); + o += 16; + const verifierHashSize = v.getUint32(o, true); + o += 4; + const encryptedVerifierHash = info.slice(o, o + 32); + if (encryptedVerifierHash.length !== 32) throw new UnpasswordError('corrupt', 'truncated encryption verifier'); + + // 2.3.4.7 key derivation + const hn = iteratedHash(sha1, salt, password, SPIN_COUNT); + const hfinal = sha1(concat(hn, le32(0))); + hn.fill(0); + const buf1 = new Uint8Array(64).fill(0x36); + const buf2 = new Uint8Array(64).fill(0x5c); + for (let i = 0; i < hfinal.length; i++) { + buf1[i] ^= hfinal[i]; + buf2[i] ^= hfinal[i]; + } + const key = concat(sha1(buf1), sha1(buf2)).slice(0, keyBits / 8); + hfinal.fill(0); + + // 2.3.4.9 password verification + const cipher = ecb(key, { disablePadding: true }); + const verifier = cipher.decrypt(encryptedVerifier); + const verifierHash = cipher.decrypt(encryptedVerifierHash).slice(0, verifierHashSize); + if (!constantTimeEqual(sha1(verifier), verifierHash)) { + key.fill(0); + throw new UnpasswordError('wrong-password'); + } + + const { size, body } = packageBody(encryptedPackage); + const out = ecb(key, { disablePadding: true }).decrypt(body); + key.fill(0); + const result = out.slice(0, size); + out.fill(0); + return result; +} diff --git a/web/src/core/office/util.ts b/web/src/core/office/util.ts new file mode 100644 index 0000000..400211f --- /dev/null +++ b/web/src/core/office/util.ts @@ -0,0 +1,111 @@ +import { sha1 } from '@noble/hashes/legacy.js'; +import { sha256, sha384, sha512 } from '@noble/hashes/sha2.js'; +import { UnpasswordError } from '../types'; + +export type HashFn = ((data: Uint8Array) => Uint8Array) & { outputLen: number; blockLen: number; create(): unknown }; + +export const HASHES: Record = { + SHA1: sha1 as unknown as HashFn, + 'SHA-1': sha1 as unknown as HashFn, + SHA256: sha256 as unknown as HashFn, + 'SHA-256': sha256 as unknown as HashFn, + SHA384: sha384 as unknown as HashFn, + 'SHA-384': sha384 as unknown as HashFn, + SHA512: sha512 as unknown as HashFn, + 'SHA-512': sha512 as unknown as HashFn, +}; + +/** Office passwords are hashed as UTF-16LE without terminator. */ +export function utf16le(s: string): Uint8Array { + const out = new Uint8Array(s.length * 2); + for (let i = 0; i < s.length; i++) { + const c = s.charCodeAt(i); + out[i * 2] = c & 0xff; + out[i * 2 + 1] = c >> 8; + } + return out; +} + +export function concat(...parts: Uint8Array[]): Uint8Array { + const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0)); + let o = 0; + for (const p of parts) { + out.set(p, o); + o += p.length; + } + return out; +} + +export function le32(n: number): Uint8Array { + const b = new Uint8Array(4); + new DataView(b.buffer).setUint32(0, n >>> 0, true); + return b; +} + +/** Truncate, or pad with 0x36, to `len` bytes (MS-OFFCRYPTO 2.3.4.11). */ +export function fit(data: Uint8Array, len: number): Uint8Array { + if (data.length >= len) return data.slice(0, len); + const out = new Uint8Array(len).fill(0x36); + out.set(data); + return out; +} + +export function constantTimeEqual(a: Uint8Array, b: Uint8Array): boolean { + if (a.length !== b.length) return false; + let d = 0; + for (let i = 0; i < a.length; i++) d |= a[i] ^ b[i]; + return d === 0; +} + +/** + * StreamSize of an EncryptedPackage. The field is 8 bytes, but common + * implementations only read (and some writers only fill) the low 4 bytes; with + * inputs far below 4 GiB the high half carries no information. + */ +export function readStreamSize(data: Uint8Array): number { + return new DataView(data.buffer, data.byteOffset, 8).getUint32(0, true); +} + +/** The ciphertext needed for `size` plaintext bytes, rounded up to the AES block size. */ +export function blockAlignedBody(encryptedPackage: Uint8Array, size: number): Uint8Array { + const needed = Math.ceil(size / 16) * 16; + const body = encryptedPackage.subarray(8); + if (needed > body.length) throw new RangeError('encrypted package truncated'); + return body.subarray(0, needed); +} + +/** + * H0 = H(salt + password); Hn = H(iterator + Hn-1) for n in 0..spinCount-1. + * The spin count is taken from the file unchanged. + */ +export function iteratedHash(hash: HashFn, salt: Uint8Array, password: string, spinCount: number): Uint8Array { + const pw = utf16le(password); + let h = hash(concat(salt, pw)); + pw.fill(0); + const buf = new Uint8Array(4 + h.length); + const view = new DataView(buf.buffer); + for (let i = 0; i < spinCount; i++) { + view.setUint32(0, i, true); + buf.set(h, 4); + h = hash(buf); + } + buf.fill(0); + return h; +} + +export function base64ToBytes(b64: string): Uint8Array { + const bin = atob(b64.replace(/\s+/g, '')); + const out = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i); + return out; +} + +export function packageBody(encryptedPackage: Uint8Array): { size: number; body: Uint8Array } { + if (encryptedPackage.length < 8) throw new UnpasswordError('corrupt', 'encrypted package too short'); + const size = readStreamSize(encryptedPackage); + try { + return { size, body: blockAlignedBody(encryptedPackage, size) }; + } catch (cause) { + throw new UnpasswordError('corrupt', 'encrypted package truncated', { cause }); + } +} diff --git a/web/src/core/pdf/index.ts b/web/src/core/pdf/index.ts new file mode 100644 index 0000000..a5a95a9 --- /dev/null +++ b/web/src/core/pdf/index.ts @@ -0,0 +1,32 @@ +import { UnpasswordError, type UnlockResult } from '../types'; +import { decidePdfAction, restrictionsPreserved } from './policy'; +import { decryptPdf, inspectEncryption, removeOpenPasswordKeepRestrictions } from './qpdf'; + +export async function unlockPdf(input: Uint8Array, password: string): Promise { + const withoutPassword = await inspectEncryption(input, ''); + if (withoutPassword && !withoutPassword.encrypted) { + throw new UnpasswordError('not-encrypted', 'this PDF is not encrypted'); + } + const withPassword = await inspectEncryption(input, password); + const action = decidePdfAction(withPassword, withoutPassword !== null); + + switch (action.kind) { + case 'refuse': + throw new UnpasswordError(action.reason); + case 'decrypt': + return { format: 'pdf', mode: 'decrypted', warnings: [], data: await decryptPdf(input, withPassword!.password) }; + case 'preserve-restrictions': { + const data = await removeOpenPasswordKeepRestrictions(input, withPassword!.password, action.capabilities); + // Verify: opens without a password and carries the same restrictions. + const check = await inspectEncryption(data, ''); + if ( + !check?.encrypted || + !check.userPasswordMatched || + !restrictionsPreserved(action.capabilities, check.capabilities) + ) { + throw new UnpasswordError('corrupt', 're-encryption could not be verified'); + } + return { format: 'pdf', mode: 'open-password-removed', warnings: [], data }; + } + } +} diff --git a/web/src/core/pdf/password.ts b/web/src/core/pdf/password.ts new file mode 100644 index 0000000..53bf505 --- /dev/null +++ b/web/src/core/pdf/password.ts @@ -0,0 +1,73 @@ +/** + * Byte encodings of the one password the user typed. + * + * PDF R2–R4 hash passwords as PDFDocEncoding bytes, R5/R6 as UTF-8 (after + * SASLprep). Producers are not always consistent, and the qpdf WASM build does + * not transcode non-ASCII input for R≤4. We therefore hand qpdf the same typed + * password in each plausible encoding. This is not guessing: every variant is + * a byte representation of the identical user input. + */ + +// PDFDocEncoding bytes 0x80–0xA0 that differ from Latin-1 (ISO 32000-1, Annex D.2) +const PDFDOC_SPECIAL: Record = { + 0x2022: 0x80, + 0x2020: 0x81, + 0x2021: 0x82, + 0x2026: 0x83, + 0x2014: 0x84, + 0x2013: 0x85, + 0x0192: 0x86, + 0x2044: 0x87, + 0x2039: 0x88, + 0x203a: 0x89, + 0x2212: 0x8a, + 0x2030: 0x8b, + 0x201e: 0x8c, + 0x201c: 0x8d, + 0x201d: 0x8e, + 0x2018: 0x8f, + 0x2019: 0x90, + 0x201a: 0x91, + 0x2122: 0x92, + 0xfb01: 0x93, + 0xfb02: 0x94, + 0x0141: 0x95, + 0x0152: 0x96, + 0x0160: 0x97, + 0x0178: 0x98, + 0x017d: 0x99, + 0x0131: 0x9a, + 0x0142: 0x9b, + 0x0153: 0x9c, + 0x0161: 0x9d, + 0x017e: 0x9e, + 0x20ac: 0xa0, +}; + +/** PDFDocEncoding of `s`, or `null` if a character is not representable. */ +export function toPdfDocEncoding(s: string): Uint8Array | null { + const out: number[] = []; + for (const ch of s.normalize('NFC')) { + const cp = ch.codePointAt(0)!; + if ((cp >= 0x20 && cp <= 0x7e) || (cp >= 0xa1 && cp <= 0xff && cp !== 0xad)) out.push(cp); + else if (cp in PDFDOC_SPECIAL) out.push(PDFDOC_SPECIAL[cp]); + else return null; + } + return Uint8Array.from(out); +} + +function hex(bytes: Uint8Array): string { + return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join(''); +} + +/** Distinct hex-encoded byte representations of `password`, most likely first. */ +export function passwordEncodings(password: string): string[] { + const utf8 = new TextEncoder(); + const candidates = [ + utf8.encode(password.normalize('NFC')), + toPdfDocEncoding(password), + utf8.encode(password.normalize('NFKC')), + utf8.encode(password), + ]; + return [...new Set(candidates.filter((c): c is Uint8Array => c !== null).map(hex))]; +} diff --git a/web/src/core/pdf/policy.ts b/web/src/core/pdf/policy.ts new file mode 100644 index 0000000..33bd562 --- /dev/null +++ b/web/src/core/pdf/policy.ts @@ -0,0 +1,76 @@ +/** + * Decides what unpassword may do with an encrypted PDF, given which password + * the user supplied. Pure function; see tests/pdf-policy.test.ts for the table. + * + * Principle: unpassword removes protection only with the password that + * controls it. The open (user) password removes the open protection; the + * permission restrictions the author set belong to the owner password and are + * preserved unless that password is supplied. + */ + +export interface PdfCapabilities { + accessibility: boolean; + extract: boolean; + modify: boolean; + modifyannotations: boolean; + modifyassembly: boolean; + modifyforms: boolean; + modifyother: boolean; + printhigh: boolean; + printlow: boolean; +} + +export interface PdfEncryptionInfo { + encrypted: boolean; + userPasswordMatched: boolean; + ownerPasswordMatched: boolean; + capabilities: PdfCapabilities; +} + +export type PdfAction = + | { kind: 'decrypt' } + | { kind: 'preserve-restrictions'; capabilities: PdfCapabilities } + | { kind: 'refuse'; reason: 'not-encrypted' | 'wrong-password' | 'owner-password-required' }; + +export function hasRestrictions(c: PdfCapabilities): boolean { + return !( + c.accessibility && + c.extract && + c.modify && + c.modifyannotations && + c.modifyassembly && + c.modifyforms && + c.modifyother && + c.printhigh && + c.printlow + ); +} + +/** True if every permission denied in `original` is still denied in `result`. */ +export function restrictionsPreserved(original: PdfCapabilities, result: PdfCapabilities): boolean { + return (Object.keys(original) as (keyof PdfCapabilities)[]).every((k) => original[k] || !result[k]); +} + +/** + * @param withPassword qpdf's view of the file opened with the supplied password + * (`null` if qpdf rejected the password) + * @param opensWithoutPassword whether the file opens with an empty password, + * i.e. it has no open protection at all + */ +export function decidePdfAction(withPassword: PdfEncryptionInfo | null, opensWithoutPassword: boolean): PdfAction { + if (withPassword === null) return { kind: 'refuse', reason: 'wrong-password' }; + if (!withPassword.encrypted) return { kind: 'refuse', reason: 'not-encrypted' }; + + if (withPassword.ownerPasswordMatched) return { kind: 'decrypt' }; + + if (!withPassword.userPasswordMatched) return { kind: 'refuse', reason: 'wrong-password' }; + + // Only the user password matched. + if (opensWithoutPassword) { + // There is no open password to remove; only restrictions are left, and + // lifting them needs the owner password. + return { kind: 'refuse', reason: 'owner-password-required' }; + } + if (!hasRestrictions(withPassword.capabilities)) return { kind: 'decrypt' }; + return { kind: 'preserve-restrictions', capabilities: withPassword.capabilities }; +} diff --git a/web/src/core/pdf/qpdf.ts b/web/src/core/pdf/qpdf.ts new file mode 100644 index 0000000..95f7048 --- /dev/null +++ b/web/src/core/pdf/qpdf.ts @@ -0,0 +1,210 @@ +import createModule from '@neslinesli93/qpdf-wasm'; +import { UnpasswordError } from '../types'; +import { passwordEncodings } from './password'; +import type { PdfCapabilities, PdfEncryptionInfo } from './policy'; + +let wasmLocation: string | null = null; + +/** + * Where Emscripten loads qpdf.wasm from: the bundled same-origin asset URL in + * the browser, a file path under Node (tests). + */ +export function setQpdfWasmLocation(location: string): void { + wasmLocation = location; +} + +interface QpdfRun { + code: number; + stdout: string; + stderr: string; + output: Uint8Array | null; +} + +interface EmscriptenModule { + callMain(args: string[]): number; + FS: { + init(input: () => number | null, output: (c: number | null) => void, error: (c: number | null) => void): void; + writeFile(path: string, data: Uint8Array): void; + readFile(path: string): Uint8Array; + unlink(path: string): void; + }; +} + +const IN = '/in.pdf'; +const OUT = '/out.pdf'; + +/** + * Runs one qpdf command in a fresh module instance, so no state (and no + * plaintext in the WASM heap) survives between operations. + */ +async function runQpdf(input: Uint8Array, args: (inPath: string, outPath: string) => string[]): Promise { + const location = wasmLocation; + if (!location) throw new Error('qpdf wasm location not configured'); + + const out: number[] = []; + const err: number[] = []; + const factory = createModule as unknown as (opts: object) => Promise; + const mod = await factory({ + locateFile: () => location, + noInitialRun: true, + preRun: [ + (m: EmscriptenModule) => + m.FS.init( + () => null, + (c) => { + if (c !== null) out.push(c); + }, + (c) => { + if (c !== null) err.push(c); + }, + ), + ], + }); + + // Under Node (tests) Emscripten reports qpdf's exit status via process.exitCode. + const proc = (globalThis as { process?: { exitCode?: number | string } }).process; + const savedExitCode = proc?.exitCode; + mod.FS.writeFile(IN, input); + let code: number; + try { + code = mod.callMain(args(IN, OUT)); + } finally { + if (proc) proc.exitCode = savedExitCode; + } + let output: Uint8Array | null; + try { + output = mod.FS.readFile(OUT).slice(); + } catch { + output = null; + } + // Best effort: wipe the in-memory file system copies. + for (const p of [IN, OUT]) { + try { + mod.FS.writeFile(p, new Uint8Array(0)); + mod.FS.unlink(p); + } catch { + /* not present */ + } + } + const decoder = new TextDecoder(); + return { code, stdout: decoder.decode(new Uint8Array(out)), stderr: decoder.decode(new Uint8Array(err)), output }; +} + +/** A password as raw bytes (hex), as qpdf's `--password-mode=hex-bytes` expects it. */ +export type PasswordBytes = { hex: string }; + +function passwordArgs(pw: PasswordBytes): string[] { + return ['--password-mode=hex-bytes', `--password=${pw.hex}`]; +} + +export const EMPTY_PASSWORD: PasswordBytes = { hex: '' }; + +/** + * Inspects the encryption dictionary with the typed password. Returns `null` + * when qpdf rejects it, otherwise the encryption info together with the byte + * encoding of the password that qpdf accepted. + */ +export async function inspectEncryption( + input: Uint8Array, + password: string, +): Promise<(PdfEncryptionInfo & { password: PasswordBytes }) | null> { + const encodings = password === '' ? [''] : passwordEncodings(password); + for (const hex of encodings) { + const pw = { hex }; + const info = await inspectWith(input, pw); + if (info) return { ...info, password: pw }; + } + return null; +} + +async function inspectWith(input: Uint8Array, pw: PasswordBytes): Promise { + const run = await runQpdf(input, (inPath) => ['--json=2', '--json-key=encrypt', ...passwordArgs(pw), inPath]); + if (run.code !== 0 && run.code !== 3) { + if (/invalid password/i.test(run.stderr)) return null; + throw classifyFailure(run.stderr); + } + let parsed: { + encrypt?: { + encrypted: boolean; + userpasswordmatched: boolean; + ownerpasswordmatched: boolean; + capabilities: PdfCapabilities; + }; + }; + try { + parsed = JSON.parse(run.stdout); + } catch (cause) { + throw new UnpasswordError('corrupt', 'could not read PDF encryption information', { cause }); + } + const e = parsed.encrypt; + if (!e) throw new UnpasswordError('corrupt', 'could not read PDF encryption information'); + return { + encrypted: e.encrypted, + userPasswordMatched: e.userpasswordmatched, + ownerPasswordMatched: e.ownerpasswordmatched, + capabilities: { ...e.capabilities }, + }; +} + +function classifyFailure(stderr: string): UnpasswordError { + const msg = stderr.trim().split('\n').pop() ?? ''; + if (/unsupported|unknown security handler|filter|PubSec|certificate/i.test(stderr)) { + return new UnpasswordError('unsupported', msg || 'unsupported PDF security handler'); + } + return new UnpasswordError('corrupt', msg || 'qpdf failed'); +} + +function finish(run: QpdfRun): Uint8Array { + // exit code 3 = success with warnings + if ((run.code !== 0 && run.code !== 3) || !run.output) throw classifyFailure(run.stderr); + return run.output; +} + +export async function decryptPdf(input: Uint8Array, password: PasswordBytes): Promise { + return finish(await runQpdf(input, (i, o) => [...passwordArgs(password), '--decrypt', i, o])); +} + +function yn(v: boolean): string { + return v ? 'y' : 'n'; +} + +/** qpdf arguments that reproduce the given permissions with 256-bit AES. */ +export function permissionArgs(c: PdfCapabilities): string[] { + return [ + `--print=${c.printhigh ? 'full' : c.printlow ? 'low' : 'none'}`, + `--extract=${yn(c.extract)}`, + `--accessibility=${yn(c.accessibility)}`, + `--assemble=${yn(c.modifyassembly)}`, + `--annotate=${yn(c.modifyannotations)}`, + `--form=${yn(c.modifyforms)}`, + `--modify-other=${yn(c.modifyother)}`, + ]; +} + +/** + * Removes the open password but keeps the author's restrictions: re-encrypts + * with AES-256, an empty user password and a random owner password that is + * discarded immediately. + */ +export async function removeOpenPasswordKeepRestrictions( + input: Uint8Array, + password: PasswordBytes, + capabilities: PdfCapabilities, +): Promise { + const ownerBytes = crypto.getRandomValues(new Uint8Array(32)); + const owner = Array.from(ownerBytes, (b) => b.toString(16).padStart(2, '0')).join(''); + ownerBytes.fill(0); + return finish( + await runQpdf(input, (i, o) => [ + ...passwordArgs(password), + i, + '--encrypt', + '--user-password=', + `--owner-password=${owner}`, + '--bits=256', + ...permissionArgs(capabilities), + '--', + o, + ]), + ); +} diff --git a/web/src/core/session.ts b/web/src/core/session.ts new file mode 100644 index 0000000..467d26c --- /dev/null +++ b/web/src/core/session.ts @@ -0,0 +1,37 @@ +import { AttemptGuard } from './guard'; +import { unlock } from './index'; +import { UnpasswordError, type UnlockResult } from './types'; + +async function fingerprint(data: Uint8Array): Promise { + const digest = new Uint8Array(await crypto.subtle.digest('SHA-256', data as Uint8Array)); + return Array.from(digest, (b) => b.toString(16).padStart(2, '0')).join(''); +} + +/** + * The only entry point the UI uses: one password per call, rate limited per + * file (identified by the SHA-256 of its encrypted bytes). + */ +export class UnlockSession { + constructor(private readonly guard: AttemptGuard = new AttemptGuard()) {} + + async attempt(input: Uint8Array, password: string): Promise { + const key = await fingerprint(input); + this.guard.assertAllowed(key); + try { + const result = await unlock(input, password); + this.guard.recordSuccess(key); + return result; + } catch (e) { + if (e instanceof UnpasswordError && e.code === 'wrong-password') { + const st = this.guard.recordFailure(key); + if (st.locked) throw new UnpasswordError('locked', 'too many failed attempts for this file', { cause: e }); + throw new UnpasswordError('wrong-password', e.message, { + cause: e, + retryAfterMs: st.retryAfterMs, + remainingAttempts: st.remaining, + }); + } + throw e; + } + } +} diff --git a/web/src/core/types.ts b/web/src/core/types.ts new file mode 100644 index 0000000..cf07f71 --- /dev/null +++ b/web/src/core/types.ts @@ -0,0 +1,74 @@ +export type Format = 'pdf' | 'ooxml' | 'zip'; + +/** + * What happened to the file: + * - `decrypted`: all encryption removed. + * - `open-password-removed`: PDF only. The open password is gone, but the + * author's permission restrictions are kept (re-encrypted with an empty user + * password and a random, discarded owner password). + */ +export type UnlockMode = 'decrypted' | 'open-password-removed'; + +/** + * Non-fatal findings the user should see. + * - `integrity-check-failed`: Office data-integrity HMAC mismatch. The + * password was verified and the content decrypted, but the file was either + * modified after encryption or written by a non-conforming tool. + */ +export type UnlockWarning = 'integrity-check-failed'; + +export interface UnlockResult { + format: Format; + mode: UnlockMode; + warnings: UnlockWarning[]; + data: Uint8Array; +} + +export type ErrorCode = + /** The supplied password does not open the file. Counts as a failed attempt. */ + | 'wrong-password' + /** No password was supplied. */ + | 'empty-password' + /** The file carries no password protection that unpassword would remove. */ + | 'not-encrypted' + /** The file is protected, but only by restrictions that need the owner password. */ + | 'owner-password-required' + /** Format or protection scheme is not supported (e.g. DRM, certificates, legacy Office). */ + | 'unsupported' + /** ZIP entries use different passwords. */ + | 'mixed-passwords' + /** Output would exceed the size limits. */ + | 'too-large' + /** The file is damaged or failed an integrity check. */ + | 'corrupt' + /** Too many failed attempts; wait `retryAfterMs`. */ + | 'cooldown' + /** Too many failed attempts; the file is locked for this session. */ + | 'locked'; + +export class UnpasswordError extends Error { + readonly code: ErrorCode; + readonly retryAfterMs?: number; + readonly remainingAttempts?: number; + + constructor( + code: ErrorCode, + message?: string, + options?: { cause?: unknown; retryAfterMs?: number; remainingAttempts?: number }, + ) { + super(message ?? code, options?.cause === undefined ? undefined : { cause: options.cause }); + this.name = 'UnpasswordError'; + this.code = code; + this.retryAfterMs = options?.retryAfterMs; + this.remainingAttempts = options?.remainingAttempts; + } +} + +/** + * A format handler takes exactly one password. There is intentionally no + * variant accepting several candidates: unpassword never guesses. + */ +export type Unlocker = (input: Uint8Array, password: string) => Promise; + +export const MAX_INPUT_BYTES = 512 * 1024 * 1024; +export const MAX_OUTPUT_BYTES = 1024 * 1024 * 1024; diff --git a/web/src/core/zip/index.ts b/web/src/core/zip/index.ts new file mode 100644 index 0000000..c29d19c --- /dev/null +++ b/web/src/core/zip/index.ts @@ -0,0 +1,134 @@ +import { + ERR_INVALID_COMPRESSED_DATA, + ERR_INVALID_CRC32, + ERR_INVALID_PASSWORD, + ERR_INVALID_UNCOMPRESSED_SIZE, + ERR_UNSUPPORTED_ENCRYPTION, + Uint8ArrayReader, + Uint8ArrayWriter, + ZipReader, + ZipWriter, + configure, + type Entry, +} from '@zip.js/zip.js'; +import { MAX_OUTPUT_BYTES, UnpasswordError, type UnlockResult } from '../types'; + +// unpassword already runs in a dedicated worker; zip.js must not spawn its own +// (blob) workers, which the CSP would block anyway. +configure({ useWebWorkers: false }); + +/** Upper bound for compressed→uncompressed expansion of a single entry. */ +const MAX_RATIO = 1000; +/** Entries smaller than this are exempt from the ratio check. */ +const RATIO_EXEMPT_BYTES = 1024 * 1024; + +const WRONG_PASSWORD_ERRORS = new Set([ + ERR_INVALID_PASSWORD, + // ZipCrypto verifies the password on a single byte; a wrong password that + // passes that check shows up as one of these while reading. + ERR_INVALID_CRC32, + ERR_INVALID_COMPRESSED_DATA, + ERR_INVALID_UNCOMPRESSED_SIZE, +]); + +function errorMessage(e: unknown): string { + return e instanceof Error ? e.message : String(e); +} + +/** A sink that collects chunks and aborts once `limit` bytes are exceeded. */ +function limitedSink(limit: number): { stream: WritableStream; result(): Uint8Array } { + const chunks: Uint8Array[] = []; + let total = 0; + const stream = new WritableStream({ + write(chunk) { + total += chunk.length; + if (total > limit) throw new UnpasswordError('too-large', 'archive expands beyond the size limit'); + chunks.push(chunk); + }, + }); + return { + stream, + result() { + const out = new Uint8Array(total); + let o = 0; + for (const c of chunks) { + out.set(c, o); + o += c.length; + c.fill(0); + } + return out; + }, + }; +} + +/** + * Decrypts every entry of a password-protected ZIP with the single supplied + * password and writes an unencrypted ZIP with the same entries. + */ +export async function unlockZip(input: Uint8Array, password: string): Promise { + const reader = new ZipReader(new Uint8ArrayReader(input)); + let entries: Entry[]; + try { + entries = await reader.getEntries(); + } catch (cause) { + throw new UnpasswordError('corrupt', 'not a readable ZIP archive', { cause }); + } + + if (!entries.some((e) => e.encrypted)) { + await reader.close(); + throw new UnpasswordError('not-encrypted', 'this archive is not encrypted'); + } + + const writer = new ZipWriter(new Uint8ArrayWriter(), { level: 6 }); + let total = 0; + let decryptedAny = false; + try { + for (const entry of entries) { + const options = { + lastModDate: entry.lastModDate, + comment: entry.comment, + externalFileAttributes: entry.externalFileAttributes, + versionMadeBy: entry.versionMadeBy, + msDosCompatible: entry.msDosCompatible, + }; + if (entry.directory) { + await writer.add(entry.filename, undefined, { ...options, directory: true }); + continue; + } + + const remaining = MAX_OUTPUT_BYTES - total; + const declaredTooBig = + entry.uncompressedSize > remaining || + (entry.uncompressedSize > RATIO_EXEMPT_BYTES && entry.uncompressedSize > entry.compressedSize * MAX_RATIO); + if (declaredTooBig) throw new UnpasswordError('too-large', `entry "${entry.filename}" is too large`); + + const sink = limitedSink(remaining); + try { + // Exactly one password, checked against CRC-32 / AES authentication code. + await entry.getData(sink.stream, { password: entry.encrypted ? password : undefined, checkCrc32: true }); + } catch (e) { + if (e instanceof UnpasswordError) throw e; + const msg = errorMessage(e); + if (entry.encrypted && WRONG_PASSWORD_ERRORS.has(msg)) { + throw new UnpasswordError(decryptedAny ? 'mixed-passwords' : 'wrong-password', undefined, { cause: e }); + } + if (msg === ERR_UNSUPPORTED_ENCRYPTION) throw new UnpasswordError('unsupported', msg, { cause: e }); + throw new UnpasswordError('corrupt', `cannot read "${entry.filename}": ${msg}`, { cause: e }); + } + if (entry.encrypted) decryptedAny = true; + + const data = sink.result(); + total += data.length; + await writer.add(entry.filename, new Uint8ArrayReader(data), options); + data.fill(0); + } + const out = await writer.close(); + return { format: 'zip', mode: 'decrypted', warnings: [], data: out }; + } catch (e) { + // Discard the partially written archive. + await writer.close().catch(() => undefined); + throw e; + } finally { + await reader.close(); + } +} diff --git a/web/src/files.ts b/web/src/files.ts new file mode 100644 index 0000000..b1e4216 --- /dev/null +++ b/web/src/files.ts @@ -0,0 +1,36 @@ +import type { Format } from './core/types'; + +const OOXML_TYPES: Record = { + docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + docm: 'application/vnd.ms-word.document.macroEnabled.12', + xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + xlsm: 'application/vnd.ms-excel.sheet.macroEnabled.12', + xlsb: 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + pptm: 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', +}; + +export function extension(name: string): string { + const m = name.match(/\.([A-Za-z0-9]{1,8})$/); + return m ? m[1].toLowerCase() : ''; +} + +/** "Kontoauszug.pdf" → "Kontoauszug (entsperrt).pdf" */ +export function outputName(name: string, suffix: string, format: Format): string { + const ext = extension(name); + const base = ext ? name.slice(0, -(ext.length + 1)) : name; + const fallbackExt = format === 'pdf' ? 'pdf' : format === 'zip' ? 'zip' : 'docx'; + return `${base || 'file'} (${suffix}).${ext || fallbackExt}`; +} + +export function outputMimeType(name: string, format: Format): string { + if (format === 'pdf') return 'application/pdf'; + if (format === 'zip') return 'application/zip'; + return OOXML_TYPES[extension(name)] ?? 'application/octet-stream'; +} + +export function formatSize(bytes: number): string { + if (bytes < 1024) return `${bytes} B`; + if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; + return `${(bytes / 1024 / 1024).toFixed(1)} MB`; +} diff --git a/web/src/google/auth.ts b/web/src/google/auth.ts new file mode 100644 index 0000000..381b86b --- /dev/null +++ b/web/src/google/auth.ts @@ -0,0 +1,37 @@ +import { DRIVE_SCOPE, googleConfig, loadScript } from './config'; + +let tokenClient: google.accounts.oauth2.TokenClient | null = null; +let token: { value: string; expiresAt: number } | null = null; +let pending: { resolve: (t: string) => void; reject: (e: Error) => void } | null = null; + +/** + * Returns an OAuth access token for drive.file, prompting the user if needed. + * The token lives in memory only. + */ +export async function getAccessToken(): Promise { + if (token && token.expiresAt - 60_000 > Date.now()) return token.value; + await loadScript('https://accounts.google.com/gsi/client'); + tokenClient ??= google.accounts.oauth2.initTokenClient({ + client_id: googleConfig.clientId!, + scope: DRIVE_SCOPE, + callback: (r) => { + const p = pending; + pending = null; + if (r.error || !r.access_token) { + p?.reject(new Error(r.error_description || r.error || 'authorization failed')); + return; + } + token = { value: r.access_token, expiresAt: Date.now() + r.expires_in * 1000 }; + p?.resolve(r.access_token); + }, + error_callback: (e) => { + const p = pending; + pending = null; + p?.reject(new Error(e.message || e.type)); + }, + }); + return new Promise((resolve, reject) => { + pending = { resolve, reject }; + tokenClient!.requestAccessToken({ prompt: '' }); + }); +} diff --git a/web/src/google/config.ts b/web/src/google/config.ts new file mode 100644 index 0000000..20c2a09 --- /dev/null +++ b/web/src/google/config.ts @@ -0,0 +1,38 @@ +/** + * Public identifiers of the Google Cloud project. None of these is a secret: + * the OAuth client ID and the API key are embedded in every Google web app + * and must be restricted to this site's origin in the Cloud console. + */ +export const googleConfig = { + clientId: import.meta.env.VITE_GOOGLE_CLIENT_ID as string | undefined, + apiKey: import.meta.env.VITE_GOOGLE_API_KEY as string | undefined, + /** Cloud project number, required by the Picker for drive.file grants. */ + appId: import.meta.env.VITE_GOOGLE_APP_ID as string | undefined, +}; + +export const driveEnabled = Boolean(googleConfig.clientId && googleConfig.apiKey && googleConfig.appId); + +/** The only OAuth scope unpassword requests: files the user opens or creates with the app. */ +export const DRIVE_SCOPE = 'https://www.googleapis.com/auth/drive.file'; + +const loaded = new Map>(); + +/** Loads a Google script on demand – never in local-only mode. */ +export function loadScript(src: string): Promise { + let p = loaded.get(src); + if (!p) { + p = new Promise((resolve, reject) => { + const s = document.createElement('script'); + s.src = src; + s.async = true; + s.onload = () => resolve(); + s.onerror = () => { + loaded.delete(src); + reject(new Error(`failed to load ${src}`)); + }; + document.head.append(s); + }); + loaded.set(src, p); + } + return p; +} diff --git a/web/src/google/drive.ts b/web/src/google/drive.ts new file mode 100644 index 0000000..3dff9ca --- /dev/null +++ b/web/src/google/drive.ts @@ -0,0 +1,127 @@ +/** + * Minimal Drive v3 client. The browser talks to Google directly; unpassword + * has no server in between. Only ciphertext is downloaded, and the plaintext + * is uploaded solely to the user's own Drive on explicit request. + */ +const API = 'https://www.googleapis.com/drive/v3/files'; +const UPLOAD = 'https://www.googleapis.com/upload/drive/v3/files'; + +export interface DriveFile { + id: string; + name: string; + mimeType: string; + size?: string; + parents?: string[]; + webViewLink?: string; +} + +export class DriveError extends Error { + constructor( + readonly status: number, + message: string, + ) { + super(message); + } +} + +async function call(token: string, url: string, init: RequestInit = {}): Promise { + const res = await fetch(url, { + ...init, + headers: { ...(init.headers as Record), Authorization: `Bearer ${token}` }, + // never send cookies or referrers to Google along with file data + credentials: 'omit', + referrerPolicy: 'no-referrer', + }); + if (!res.ok) throw new DriveError(res.status, `Drive API ${res.status}`); + return res; +} + +export async function getMetadata(token: string, id: string): Promise { + const res = await call( + token, + `${API}/${encodeURIComponent(id)}?fields=id,name,mimeType,size,parents&supportsAllDrives=true`, + ); + return res.json(); +} + +export async function download(token: string, id: string): Promise { + const res = await call(token, `${API}/${encodeURIComponent(id)}?alt=media&supportsAllDrives=true`); + return new Uint8Array(await res.arrayBuffer()); +} + +/** + * Saves next to the original if possible. With the drive.file scope the app + * may not be allowed to write into a folder it has not been granted; then the + * file goes to the root of My Drive instead. + */ +export async function uploadNextTo( + token: string, + meta: { name: string; mimeType: string; parents?: string[] }, + data: Uint8Array, +): Promise<{ file: DriveFile; inParent: boolean }> { + if (meta.parents?.length) { + try { + return { file: await upload(token, meta, data), inParent: true }; + } catch (e) { + if (!(e instanceof DriveError && (e.status === 403 || e.status === 404))) throw e; + } + } + return { file: await upload(token, { name: meta.name, mimeType: meta.mimeType }, data), inParent: false }; +} + +/** Resumable upload (works for any size) into the given parent folders. */ +export async function upload( + token: string, + meta: { name: string; mimeType: string; parents?: string[] }, + data: Uint8Array, +): Promise { + const init = await call(token, `${UPLOAD}?uploadType=resumable&supportsAllDrives=true&fields=id,name,webViewLink`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Upload-Content-Type': meta.mimeType, + 'X-Upload-Content-Length': String(data.length), + }, + body: JSON.stringify({ ...meta, appProperties: { unpassword: 'unlocked' } }), + }); + const session = init.headers.get('Location'); + if (!session?.startsWith(UPLOAD)) throw new DriveError(0, 'no upload session'); + const res = await call(token, session, { + method: 'PUT', + headers: { 'Content-Type': meta.mimeType }, + body: new Blob([data as Uint8Array], { type: meta.mimeType }), + }); + return res.json(); +} + +export async function trash(token: string, id: string): Promise { + await call(token, `${API}/${encodeURIComponent(id)}?supportsAllDrives=true`, { + method: 'PATCH', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ trashed: true }), + }); +} + +/** + * The file ID unpassword was opened with, if any: + * - Drive "Open with": `?state={"ids":["…"],"action":"open",…}` + * - Gmail add-on: `#/drive?fileId=…` + */ +export function launchFileId(loc: Location = location): string | null { + const state = new URLSearchParams(loc.search).get('state'); + if (state) { + try { + const parsed = JSON.parse(state) as { action?: string; ids?: unknown }; + const id = Array.isArray(parsed.ids) ? parsed.ids[0] : undefined; + if (parsed.action === 'open' && typeof id === 'string' && /^[\w-]+$/.test(id)) return id; + } catch { + /* ignore malformed state */ + } + } + const hash = loc.hash.match(/^#\/drive\?(.*)$/); + if (hash) { + const id = new URLSearchParams(hash[1]).get('fileId'); + if (id && /^[\w-]+$/.test(id)) return id; + } + return null; +} diff --git a/web/src/google/gapi.d.ts b/web/src/google/gapi.d.ts new file mode 100644 index 0000000..3f61851 --- /dev/null +++ b/web/src/google/gapi.d.ts @@ -0,0 +1,57 @@ +// Minimal typings for the parts of Google Identity Services and the Picker we use. +declare namespace google.accounts.oauth2 { + interface TokenResponse { + access_token: string; + expires_in: number; + error?: string; + error_description?: string; + } + interface TokenClient { + requestAccessToken(overrides?: { prompt?: string }): void; + } + function initTokenClient(config: { + client_id: string; + scope: string; + callback: (r: TokenResponse) => void; + error_callback?: (e: { type: string; message?: string }) => void; + }): TokenClient; + function revoke(token: string, done?: () => void): void; +} + +declare namespace google.picker { + enum Action { + PICKED = 'picked', + CANCEL = 'cancel', + } + enum ViewId { + DOCS = 'all', + } + interface PickerDocument { + id: string; + name: string; + mimeType: string; + } + interface ResponseObject { + action: string; + docs?: PickerDocument[]; + } + class DocsView { + constructor(viewId?: ViewId); + setMimeTypes(mimeTypes: string): DocsView; + setIncludeFolders(include: boolean): DocsView; + setParent(folderId: string): DocsView; + setMode(mode: unknown): DocsView; + } + class PickerBuilder { + addView(view: DocsView): PickerBuilder; + setAppId(appId: string): PickerBuilder; + setOAuthToken(token: string): PickerBuilder; + setDeveloperKey(key: string): PickerBuilder; + setLocale(locale: string): PickerBuilder; + setTitle(title: string): PickerBuilder; + setCallback(cb: (r: ResponseObject) => void): PickerBuilder; + build(): { setVisible(v: boolean): void }; + } +} + +declare const gapi: { load(api: string, cb: () => void): void }; diff --git a/web/src/google/picker.ts b/web/src/google/picker.ts new file mode 100644 index 0000000..59d9405 --- /dev/null +++ b/web/src/google/picker.ts @@ -0,0 +1,40 @@ +import { getAccessToken } from './auth'; +import { googleConfig, loadScript } from './config'; +import { lang } from '../i18n'; + +export const PICKABLE_MIME_TYPES = [ + 'application/pdf', + 'application/zip', + 'application/x-zip-compressed', + 'application/octet-stream', + 'application/x-ole-storage', + 'application/encrypted', + 'application/vnd.ms-office', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', +]; + +/** Opens the Google Picker; resolves with the chosen file ID or `null` on cancel. */ +export async function pickDriveFile(): Promise { + const token = await getAccessToken(); + await loadScript('https://apis.google.com/js/api.js'); + await new Promise((resolve) => gapi.load('picker', resolve)); + return new Promise((resolve) => { + const view = new google.picker.DocsView(google.picker.ViewId.DOCS) + .setMimeTypes(PICKABLE_MIME_TYPES.join(',')) + .setIncludeFolders(true); + new google.picker.PickerBuilder() + .addView(view) + .setAppId(googleConfig.appId!) + .setOAuthToken(token) + .setDeveloperKey(googleConfig.apiKey!) + .setLocale(lang) + .setCallback((r) => { + if (r.action === google.picker.Action.PICKED && r.docs?.[0]) resolve(r.docs[0].id); + else if (r.action === google.picker.Action.CANCEL) resolve(null); + }) + .build() + .setVisible(true); + }); +} diff --git a/web/src/i18n.ts b/web/src/i18n.ts new file mode 100644 index 0000000..2bd4c2b --- /dev/null +++ b/web/src/i18n.ts @@ -0,0 +1,147 @@ +const de = { + title: 'unpassword', + byline: 'by Nullthrone', + eyebrow: 'Open Source · Zero Knowledge', + headline: 'Passwörter entfernen, die du schon kennst.', + links: { privacy: 'Datenschutz', security: 'Sicherheit', terms: 'Nutzungsbedingungen', imprint: 'Impressum' }, + tagline: + 'PDF-, Office- und ZIP-Dateien entsperren und so archivieren, wie du es willst – vollständig in deinem Browser.', + principleLocal: 'Entschlüsselung ausschließlich in deinem Browser. Kein Server, kein Tracking.', + principleKnown: 'Du brauchst das bisherige Passwort. unpassword rät keine Passwörter und umgeht keinen Schutz.', + principleArchive: 'Gedacht für die eigene Archivierung, geschützt auf deine Art statt mit fremden Passwörtern.', + chooseLocal: 'Datei vom Gerät wählen', + dropHint: 'oder hierher ziehen', + chooseDrive: 'Aus Google Drive wählen', + driveSignIn: 'Mit Google anmelden …', + loadingDrive: 'Datei wird aus Google Drive geladen …', + driveFileUnavailable: + 'unpassword hat keinen Zugriff auf diese Datei. Bitte wähle sie über „Aus Google Drive wählen“ aus, damit Google den Zugriff freigibt.', + formats: 'PDF · DOCX/XLSX/PPTX · ZIP', + file: 'Datei', + type: { pdf: 'PDF', ooxml: 'Office-Dokument', zip: 'ZIP-Archiv' }, + unknownType: 'Unbekannter Dateityp. Unterstützt werden PDF, verschlüsselte DOCX/XLSX/PPTX und ZIP.', + password: 'Bisheriges Passwort', + passwordHint: + 'Für PDFs: Das Öffnen-Passwort entfernt den Öffnen-Schutz; Rechtebeschränkungen bleiben dann erhalten. Mit dem Rechte-Passwort (Owner-Passwort) wird alles entfernt.', + attest: 'Ich bin berechtigt, diese Datei zu entsperren, und habe das Passwort rechtmäßig erhalten.', + submit: 'Passwortschutz entfernen', + working: 'Wird entschlüsselt …', + another: 'Andere Datei', + done: { + decrypted: 'Fertig. Die Datei ist nicht mehr passwortgeschützt.', + 'open-password-removed': + 'Fertig. Der Öffnen-Schutz ist entfernt. Die Rechtebeschränkungen des Absenders (z. B. Drucken oder Kopieren) bleiben erhalten, weil dafür das Owner-Passwort nötig wäre.', + }, + warning: { + 'integrity-check-failed': + 'Hinweis: Die Integritätsprüfung des Dokuments ist fehlgeschlagen. Das Passwort war korrekt, aber die Datei wurde nach der Verschlüsselung verändert oder von einem fehlerhaften Programm erzeugt. Prüfe den Inhalt.', + }, + download: 'Herunterladen', + saveDrive: 'In Google Drive speichern', + trashOriginal: 'Verschlüsselte Originaldatei in den Papierkorb verschieben', + saving: 'Wird gespeichert …', + saved: 'Gespeichert:', + savedRoot: 'Gespeichert in „Meine Ablage“ (kein Schreibzugriff auf den Ordner des Originals):', + openInDrive: 'In Google Drive öffnen', + unlockedSuffix: 'entsperrt', + errors: { + 'wrong-password': 'Das Passwort ist falsch.', + 'empty-password': 'Bitte gib das Passwort ein.', + 'not-encrypted': 'Diese Datei ist nicht passwortgeschützt – es gibt nichts zu entfernen.', + 'owner-password-required': + 'Dieses PDF hat keinen Öffnen-Schutz, nur Rechtebeschränkungen. Diese lassen sich nur mit dem Rechte-Passwort (Owner-Passwort) entfernen.', + unsupported: 'Dieses Format bzw. dieses Schutzverfahren wird nicht unterstützt.', + 'mixed-passwords': 'Die Einträge dieses Archivs nutzen unterschiedliche Passwörter. Das wird nicht unterstützt.', + 'too-large': 'Die Datei ist zu groß.', + corrupt: 'Die Datei ist beschädigt oder konnte nicht gelesen werden.', + cooldown: 'Zu viele Fehlversuche. Bitte warte kurz.', + locked: 'Zu viele Fehlversuche. Diese Datei ist für die aktuelle Sitzung gesperrt.', + network: 'Google Drive ist nicht erreichbar. Bitte versuche es erneut.', + }, + remaining: (n: number) => `Noch ${n} ${n === 1 ? 'Versuch' : 'Versuche'}.`, + retryIn: (s: number) => `Nächster Versuch in ${s} s.`, + privacyTitle: 'Was passiert mit meinen Daten?', + privacy: [ + 'Datei und Passwort verlassen deinen Browser nicht. Die Entschlüsselung läuft in einem isolierten Web Worker.', + 'Mit Google Drive spricht dein Browser direkt mit Google – nur mit der Berechtigung für Dateien, die du selbst auswählst (drive.file).', + 'unpassword betreibt keinen Server, speichert nichts und erhebt keine Statistiken.', + 'Bei wiederholten Fehlversuchen verlangsamt unpassword weitere Versuche und sperrt die Datei nach zehn Fehlern.', + ], + source: 'Quellcode', +}; + +type Strings = typeof de; + +const en: Strings = { + title: 'unpassword', + byline: 'by Nullthrone', + eyebrow: 'Open Source · Zero Knowledge', + headline: 'Remove passwords you already know.', + links: { privacy: 'Privacy', security: 'Security', terms: 'Terms', imprint: 'Imprint' }, + tagline: 'Unlock PDF, Office and ZIP files and archive them your way – entirely in your browser.', + principleLocal: 'Decryption happens only in your browser. No server, no tracking.', + principleKnown: 'You need the current password. unpassword never guesses passwords or bypasses protection.', + principleArchive: 'Made for personal archiving, secured your way instead of with someone else’s passwords.', + chooseLocal: 'Choose a file from this device', + dropHint: 'or drop it here', + chooseDrive: 'Choose from Google Drive', + driveSignIn: 'Signing in with Google …', + loadingDrive: 'Loading file from Google Drive …', + driveFileUnavailable: + 'unpassword cannot access this file. Please select it via “Choose from Google Drive” so Google grants access.', + formats: 'PDF · DOCX/XLSX/PPTX · ZIP', + file: 'File', + type: { pdf: 'PDF', ooxml: 'Office document', zip: 'ZIP archive' }, + unknownType: 'Unknown file type. Supported: PDF, encrypted DOCX/XLSX/PPTX and ZIP.', + password: 'Current password', + passwordHint: + 'For PDFs: the open password removes the open protection and keeps permission restrictions. The owner password removes everything.', + attest: 'I am entitled to unlock this file and obtained the password legitimately.', + submit: 'Remove password protection', + working: 'Decrypting …', + another: 'Another file', + done: { + decrypted: 'Done. The file is no longer password protected.', + 'open-password-removed': + 'Done. The open password is removed. The sender’s permission restrictions (e.g. printing or copying) are kept, because lifting them requires the owner password.', + }, + warning: { + 'integrity-check-failed': + 'Note: the document’s integrity check failed. The password was correct, but the file was modified after encryption or written by a faulty program. Please check its content.', + }, + download: 'Download', + saveDrive: 'Save to Google Drive', + trashOriginal: 'Move the encrypted original to the trash', + saving: 'Saving …', + saved: 'Saved:', + savedRoot: 'Saved to “My Drive” (no write access to the original’s folder):', + openInDrive: 'Open in Google Drive', + unlockedSuffix: 'unlocked', + errors: { + 'wrong-password': 'The password is incorrect.', + 'empty-password': 'Please enter the password.', + 'not-encrypted': 'This file is not password protected – there is nothing to remove.', + 'owner-password-required': + 'This PDF has no open password, only permission restrictions. These can only be removed with the owner password.', + unsupported: 'This format or protection scheme is not supported.', + 'mixed-passwords': 'The entries of this archive use different passwords, which is not supported.', + 'too-large': 'The file is too large.', + corrupt: 'The file is damaged or could not be read.', + cooldown: 'Too many failed attempts. Please wait a moment.', + locked: 'Too many failed attempts. This file is locked for the current session.', + network: 'Google Drive is not reachable. Please try again.', + }, + remaining: (n: number) => `${n} ${n === 1 ? 'attempt' : 'attempts'} left.`, + retryIn: (s: number) => `Next attempt in ${s} s.`, + privacyTitle: 'What happens to my data?', + privacy: [ + 'File and password never leave your browser. Decryption runs in an isolated web worker.', + 'With Google Drive, your browser talks directly to Google – only with access to files you select yourself (drive.file).', + 'unpassword runs no server, stores nothing and collects no statistics.', + 'After repeated failed attempts unpassword slows down further attempts and locks the file after ten failures.', + ], + source: 'Source code', +}; + +export const t: Strings = (navigator.language || 'en').toLowerCase().startsWith('de') ? de : en; +export const lang = t === de ? 'de' : 'en'; diff --git a/web/src/main.ts b/web/src/main.ts new file mode 100644 index 0000000..1d8a5f9 --- /dev/null +++ b/web/src/main.ts @@ -0,0 +1,7 @@ +import './styles.css'; +import { lang } from './i18n'; +import { App } from './ui/app'; + +document.documentElement.lang = lang; +const root = document.getElementById('app')!; +void new App(root).start(); diff --git a/web/src/protocol.ts b/web/src/protocol.ts new file mode 100644 index 0000000..15df3ac --- /dev/null +++ b/web/src/protocol.ts @@ -0,0 +1,23 @@ +import type { ErrorCode, Format, UnlockMode, UnlockWarning } from './core/types'; + +export interface WorkerRequest { + id: number; + /** A copy of the encrypted file. */ + data: ArrayBuffer; + password: string; +} + +export type WorkerResponse = + | { + id: number; + ok: true; + result: { format: Format; mode: UnlockMode; warnings: UnlockWarning[]; data: ArrayBuffer }; + } + | { + id: number; + ok: false; + error: { code: ErrorCode; message: string; retryAfterMs?: number; remainingAttempts?: number }; + }; + +export type UnlockOutcome = Extract['result']; +export type UnlockFailure = Extract['error']; diff --git a/web/src/styles.css b/web/src/styles.css new file mode 100644 index 0000000..44dd42c --- /dev/null +++ b/web/src/styles.css @@ -0,0 +1,466 @@ +/* + * unpassword app styles on the Nullthrone Design System tokens + * (design/nullthrone). Square corners, hairlines, ink on paper, brass as the + * single accent. Dark mode comes from the tokens (OS preference). + */ +@import '../../design/nullthrone/nullthrone.css'; + +* { + box-sizing: border-box; +} + +body { + min-height: 100vh; +} + +.container { + max-width: 720px; + margin: 0 auto; + padding: 0 var(--space-4); +} + +/* ------------------------------------------------------------ brand band */ + +.band { + background: var(--surface-inverse); + color: var(--text-inverse); +} + +.band-inner { + max-width: 720px; + margin: 0 auto; + padding: 0 var(--space-4); + height: 64px; + display: flex; + align-items: center; + justify-content: space-between; + gap: var(--space-4); +} + +.brand { + display: inline-flex; + align-items: center; + gap: var(--space-3); + color: var(--text-inverse); + text-decoration: none; +} + +.brand:hover { + color: var(--brass-400); +} + +.wordmark, +.byline, +.eyebrow, +.badge, +button, +label.field, +summary { + font-family: var(--font-display); + font-weight: var(--weight-display); + text-transform: uppercase; + letter-spacing: var(--track-caps); +} + +.wordmark { + font-size: 14px; + letter-spacing: var(--track-caps-wide); +} + +.byline { + font-size: var(--text-xs); + color: var(--ink-300); +} + +/* ------------------------------------------------------------ intro */ + +.intro { + padding: var(--space-7) 0 var(--space-5); +} + +.eyebrow { + margin: 0 0 var(--space-2); + font-size: var(--text-xs); + letter-spacing: var(--track-caps-wide); + color: var(--text-accent); +} + +h1 { + font-size: var(--display-lg); + margin-bottom: var(--space-3); +} + +.tagline { + margin: 0 0 var(--space-4); + font-size: var(--text-lg); + color: var(--text-muted); +} + +.principles { + margin: 0; + padding: var(--space-4) 0 0; + border-top: var(--line); + list-style: none; + display: grid; + gap: var(--space-2); + font-size: var(--text-sm); + color: var(--text-muted); +} + +.principles li { + padding-left: var(--space-4); + position: relative; +} + +.principles li::before { + content: ''; + position: absolute; + left: 0; + top: 0.6em; + width: 8px; + border-top: 1px solid var(--brass-500); +} + +/* ------------------------------------------------------------ card */ + +.card { + background: var(--surface-card); + border: var(--line); + box-shadow: var(--shadow-1); + padding: var(--space-6); + display: flex; + flex-direction: column; + gap: var(--space-4); + animation: nt-fade-up var(--dur-med) var(--ease); +} + +.dropzone { + display: flex; + flex-direction: column; + align-items: center; + gap: var(--space-1); + padding: var(--space-7) var(--space-4); + border: 1px dashed var(--border-mid); + background: var(--paper-white); + cursor: pointer; + text-align: center; + transition: border-color var(--dur-fast) var(--ease); +} + +.dropzone strong { + font-family: var(--font-display); + font-weight: var(--weight-display); + font-size: var(--display-sm); +} + +.dropzone:hover, +.dropzone.over, +#file:focus-visible + .dropzone { + border: var(--line-strong); +} + +#file:focus-visible + .dropzone { + box-shadow: var(--focus-ring); +} + +.visually-hidden { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip: rect(0 0 0 0); + white-space: nowrap; +} + +.file { + display: flex; + align-items: center; + gap: var(--space-3); + min-width: 0; + padding-bottom: var(--space-4); + border-bottom: var(--line); +} + +.file .name { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-weight: var(--weight-strong); +} + +.badge { + flex: none; + display: inline-flex; + align-items: center; + height: 20px; + padding: 0 var(--space-2); + font-size: 10px; + background: var(--brass-100); + color: var(--brass-700); + border: 1px solid var(--brass-400); +} + +/* ------------------------------------------------------------ form */ + +form.unlock { + display: flex; + flex-direction: column; + gap: var(--space-3); +} + +label.field { + font-size: var(--text-xs); + color: var(--ink-700); +} + +input[type='password'] { + font: inherit; + font-size: 14px; + height: var(--control-h-lg); + padding: 0 var(--space-3); + border: var(--line); + border-radius: var(--radius-0); + background: var(--paper-white); + color: var(--text-body); + width: 100%; + outline: none; + transition: border-color var(--dur-fast) var(--ease); +} + +input[type='password']:focus { + border: var(--line-strong); + box-shadow: var(--focus-ring); +} + +input:disabled { + background: var(--surface-inset); +} + +.check { + display: flex; + gap: var(--space-3); + align-items: flex-start; + font-size: 14px; + cursor: pointer; +} + +.check input { + appearance: none; + flex: none; + width: 16px; + height: 16px; + margin: 3px 0 0; + border: 1px solid var(--ink-400); + border-radius: var(--radius-1); + background: var(--paper-white); + display: grid; + place-content: center; + cursor: pointer; + transition: background var(--dur-fast) var(--ease); +} + +.check input:checked { + background: var(--ink-950); + border-color: var(--ink-950); +} + +.check input:checked::after { + content: ''; + width: 8px; + height: 4px; + border-left: 1.6px solid var(--paper); + border-bottom: 1.6px solid var(--paper); + transform: translateY(-1px) rotate(-45deg); +} + +.check input:focus-visible { + outline: none; + box-shadow: var(--focus-ring); +} + +/* ------------------------------------------------------------ buttons */ + +button { + height: var(--control-h-md); + padding: 0 var(--space-4); + font-size: 12px; + border-radius: var(--radius-0); + border: 1px solid var(--ink-950); + background: var(--ink-950); + color: var(--paper); + cursor: pointer; + white-space: nowrap; + transition: background var(--dur-fast) var(--ease); +} + +button:hover { + background: var(--ink-700); +} + +button:active { + background: var(--press-ink); +} + +button:focus-visible { + outline: none; + box-shadow: var(--focus-ring); +} + +/* the single brass call to action of each view */ +button.accent { + height: var(--control-h-lg); + padding: 0 var(--space-5); + font-size: 13px; + background: var(--brass-500); + border-color: transparent; +} + +button.accent:hover { + background: var(--brass-600); +} + +button.accent:active { + background: var(--brass-700); +} + +button.secondary { + background: transparent; + color: var(--ink-950); + border-color: var(--ink-950); +} + +button.secondary:hover { + background: var(--surface-inset); +} + +button.secondary:active { + background: var(--ink-200); +} + +button.link { + align-self: flex-start; + height: auto; + padding: 0; + border: none; + background: none; + color: var(--text-muted); + font-size: var(--text-xs); + text-decoration: underline; + text-decoration-color: var(--brass-500); + text-underline-offset: 3px; +} + +button.link:hover { + color: var(--brass-600); + background: none; +} + +button:disabled { + opacity: 0.45; + cursor: not-allowed; +} + +.actions { + display: flex; + flex-wrap: wrap; + gap: var(--space-3); +} + +/* ------------------------------------------------------------ text & notices */ + +.hint, +.muted { + color: var(--text-muted); + font-size: var(--text-sm); + margin: 0; +} + +.status { + margin: 0; + min-height: 1.5em; + font-size: 14px; +} + +.status:empty { + display: none; +} + +.status.error { + color: var(--danger); +} + +.notice { + margin: 0; + padding: var(--space-3) var(--space-4); + border: 1px solid; + font-size: 14px; +} + +.notice.success { + background: var(--ok-bg); + color: var(--ok); +} + +.notice.warning { + background: var(--warn-bg); + color: var(--warn); +} + +.notice.error { + background: var(--danger-bg); + color: var(--danger); +} + +/* ------------------------------------------------------------ footer */ + +footer { + padding-top: var(--space-7); + padding-bottom: var(--space-7); + font-size: var(--text-sm); +} + +.double-rule { + border-top: var(--line-strong); + padding-top: 3px; + margin-bottom: var(--space-5); +} + +.double-rule::after { + content: ''; + display: block; + border-top: var(--line-strong); +} + +footer summary { + cursor: pointer; + font-size: var(--text-xs); + color: var(--ink-700); +} + +footer ul { + color: var(--text-muted); + padding-left: var(--space-5); +} + +.footer-links { + display: flex; + flex-wrap: wrap; + gap: var(--space-2) var(--space-5); + margin-top: var(--space-5); +} + +@media (max-width: 480px) { + h1 { + font-size: var(--display-md); + } + + .card { + padding: var(--space-5) var(--space-4); + } + + .byline { + display: none; + } +} diff --git a/web/src/ui/app.ts b/web/src/ui/app.ts new file mode 100644 index 0000000..6f37695 --- /dev/null +++ b/web/src/ui/app.ts @@ -0,0 +1,362 @@ +import { detectFormat } from '../core/detect'; +import type { Format } from '../core/types'; +import { formatSize, outputMimeType, outputName } from '../files'; +import { getAccessToken } from '../google/auth'; +import { driveEnabled } from '../google/config'; +import { DriveError, download, getMetadata, launchFileId, trash, uploadNextTo } from '../google/drive'; +import { pickDriveFile } from '../google/picker'; +import { t } from '../i18n'; +import type { UnlockOutcome } from '../protocol'; +import { UnlockFailed, Unlocker } from '../unlocker'; +import { clear, h } from './dom'; +import { mark } from './mark'; + +interface Source { + name: string; + data: Uint8Array; + format: Format | null; + drive?: { id: string; parents?: string[] }; +} + +export class App { + private readonly unlocker = new Unlocker(); + private source: Source | null = null; + private result: UnlockOutcome | null = null; + private readonly main: HTMLElement; + private cooldownTimer: number | undefined; + + constructor(root: HTMLElement) { + this.main = h('main', { class: 'card' }); + root.append(this.banner(), h('div', { class: 'container' }, this.header(), this.main), this.footer()); + } + + async start(): Promise { + const id = driveEnabled ? launchFileId() : null; + if (id) { + history.replaceState(null, '', location.pathname); + await this.loadFromDrive(id); + } else { + this.renderPick(); + } + } + + // ---------------------------------------------------------------- layout + + /** Inverse brand band: mark, wordmark, byline. */ + private banner(): HTMLElement { + return h( + 'header', + { class: 'band' }, + h( + 'div', + { class: 'band-inner' }, + h( + 'a', + { class: 'brand', href: '../', 'aria-label': t.title }, + mark(26), + h('span', { class: 'wordmark' }, t.title), + ), + h('span', { class: 'byline' }, t.byline), + ), + ); + } + + private header(): HTMLElement { + return h( + 'section', + { class: 'intro' }, + h('p', { class: 'eyebrow' }, t.eyebrow), + h('h1', {}, t.headline), + h('p', { class: 'tagline' }, t.tagline), + h( + 'ul', + { class: 'principles' }, + h('li', {}, t.principleLocal), + h('li', {}, t.principleKnown), + h('li', {}, t.principleArchive), + ), + ); + } + + private footer(): HTMLElement { + const links: [string, string][] = [ + ['../privacy/', t.links.privacy], + ['../security/', t.links.security], + ['../terms/', t.links.terms], + ['../imprint/', t.links.imprint], + ['https://github.com/nullthrone/unpassword', t.source], + ]; + return h( + 'footer', + { class: 'container' }, + h('div', { class: 'double-rule', 'aria-hidden': 'true' }), + h('details', {}, h('summary', {}, t.privacyTitle), h('ul', {}, ...t.privacy.map((p) => h('li', {}, p)))), + h('nav', { class: 'footer-links' }, ...links.map(([href, label]) => h('a', { href, rel: 'noopener' }, label))), + ); + } + + // ---------------------------------------------------------------- step 1: pick + + private renderPick(message?: string): void { + this.reset(); + const input = h('input', { type: 'file', id: 'file', class: 'visually-hidden' }); + input.addEventListener('change', () => { + const f = input.files?.[0]; + if (f) void this.loadLocal(f); + }); + const drop = h( + 'label', + { class: 'dropzone', for: 'file' }, + h('strong', {}, t.chooseLocal), + h('span', {}, t.dropHint), + h('span', { class: 'muted' }, t.formats), + ); + drop.addEventListener('dragover', (e) => { + e.preventDefault(); + drop.classList.add('over'); + }); + drop.addEventListener('dragleave', () => drop.classList.remove('over')); + drop.addEventListener('drop', (e) => { + e.preventDefault(); + drop.classList.remove('over'); + const f = e.dataTransfer?.files[0]; + if (f) void this.loadLocal(f); + }); + + clear(this.main); + if (message) this.main.append(h('p', { class: 'notice error', role: 'alert' }, message)); + this.main.append(input, drop); + if (driveEnabled) { + this.main.append( + h('button', { type: 'button', class: 'secondary', onclick: () => void this.pickFromDrive() }, t.chooseDrive), + ); + } + } + + private async loadLocal(file: File): Promise { + const data = new Uint8Array(await file.arrayBuffer()); + this.setSource({ name: file.name, data, format: detectFormat(data) }); + } + + private async pickFromDrive(): Promise { + try { + this.busy(t.driveSignIn); + const id = await pickDriveFile(); + if (id) await this.loadFromDrive(id); + else this.renderPick(); + } catch (e) { + console.warn(e); + this.renderPick(t.errors.network); + } + } + + private async loadFromDrive(id: string): Promise { + try { + this.busy(t.loadingDrive); + const token = await getAccessToken(); + const meta = await getMetadata(token, id); + const data = await download(token, id); + this.setSource({ name: meta.name, data, format: detectFormat(data), drive: { id, parents: meta.parents } }); + } catch (e) { + console.warn(e); + const noAccess = e instanceof DriveError && (e.status === 403 || e.status === 404); + this.renderPick(noAccess ? t.driveFileUnavailable : t.errors.network); + } + } + + private setSource(source: Source): void { + this.reset(); + this.source = source; + if (!source.format) { + this.renderPick(t.unknownType); + return; + } + this.renderPassword(); + } + + // ---------------------------------------------------------------- step 2: password + + private fileSummary(): HTMLElement { + const s = this.source!; + return h( + 'div', + { class: 'file' }, + h('span', { class: 'badge' }, s.format ? t.type[s.format] : '?'), + h('span', { class: 'name', title: s.name }, s.name), + h('span', { class: 'muted' }, formatSize(s.data.length)), + ); + } + + private renderPassword(): void { + const s = this.source!; + const status = h('p', { class: 'status', role: 'status', 'aria-live': 'polite' }); + const pw = h('input', { + type: 'password', + id: 'password', + name: 'unpassword-current-password', + autocomplete: 'off', + autocapitalize: 'off', + spellcheck: 'false', + required: true, + }); + const attest = h('input', { type: 'checkbox', id: 'attest', required: true }); + const submit = h('button', { type: 'submit', class: 'accent' }, t.submit); + const form = h( + 'form', + { class: 'unlock', novalidate: false }, + h('label', { for: 'password', class: 'field' }, t.password), + pw, + s.format === 'pdf' ? h('p', { class: 'hint muted' }, t.passwordHint) : null, + h('label', { class: 'check' }, attest, h('span', {}, t.attest)), + submit, + status, + ); + + form.addEventListener('submit', async (e) => { + e.preventDefault(); + if (!pw.value) { + status.textContent = t.errors['empty-password']; + return; + } + const password = pw.value; + pw.value = ''; + submit.disabled = true; + status.className = 'status'; + status.textContent = t.working; + try { + this.result = await this.unlocker.unlock(s.data, password); + this.renderResult(); + } catch (err) { + status.className = 'status error'; + if (!(err instanceof UnlockFailed)) { + console.warn(err); + status.textContent = t.errors.corrupt; + submit.disabled = false; + return; + } + const f = err.failure; + const parts = [t.errors[f.code]]; + if (f.code === 'wrong-password' && f.remainingAttempts !== undefined) + parts.push(t.remaining(f.remainingAttempts)); + status.textContent = parts.join(' '); + if (f.code === 'locked' || f.code === 'not-encrypted' || f.code === 'unsupported') { + pw.disabled = true; + return; + } + this.cooldown(f.retryAfterMs ?? 0, submit, status, parts.join(' ')); + pw.focus(); + } + }); + + clear(this.main); + this.main.append(this.fileSummary(), form, this.anotherButton()); + pw.focus(); + } + + private cooldown(ms: number, button: HTMLButtonElement, status: HTMLElement, prefix: string): void { + window.clearInterval(this.cooldownTimer); + if (ms <= 0) { + button.disabled = false; + return; + } + const until = Date.now() + ms; + const tick = () => { + const left = Math.ceil((until - Date.now()) / 1000); + if (left <= 0) { + window.clearInterval(this.cooldownTimer); + status.textContent = prefix; + button.disabled = false; + } else { + status.textContent = `${prefix} ${t.retryIn(left)}`; + } + }; + tick(); + this.cooldownTimer = window.setInterval(tick, 1000); + } + + // ---------------------------------------------------------------- step 3: result + + private renderResult(): void { + const s = this.source!; + const r = this.result!; + const name = outputName(s.name, t.unlockedSuffix, r.format); + const mime = outputMimeType(s.name, r.format); + const status = h('p', { class: 'status', role: 'status', 'aria-live': 'polite' }); + const actions = h( + 'div', + { class: 'actions' }, + h('button', { type: 'button', class: 'accent', onclick: () => this.download(name, mime) }, t.download), + ); + let trashRow: HTMLElement | null = null; + + if (s.drive && driveEnabled) { + const drive = s.drive; + const trashBox = h('input', { type: 'checkbox', id: 'trash' }); + trashRow = h('label', { class: 'check' }, trashBox, h('span', {}, t.trashOriginal)); + const save = h('button', { type: 'button', class: 'secondary' }, t.saveDrive); + save.addEventListener('click', async () => { + save.disabled = true; + status.className = 'status'; + status.textContent = t.saving; + try { + const token = await getAccessToken(); + const { file, inParent } = await uploadNextTo( + token, + { name, mimeType: mime, parents: drive.parents }, + new Uint8Array(r.data), + ); + if (trashBox.checked) await trash(token, drive.id); + const link = `https://drive.google.com/file/d/${encodeURIComponent(file.id)}/view`; + status.replaceChildren( + `${inParent ? t.saved : t.savedRoot} ${file.name} – `, + h('a', { href: link, target: '_blank', rel: 'noopener' }, t.openInDrive), + ); + } catch (e) { + console.warn(e); + status.className = 'status error'; + status.textContent = t.errors.network; + save.disabled = false; + } + }); + actions.append(save); + } + + clear(this.main); + this.main.append( + this.fileSummary(), + h('p', { class: 'notice success' }, t.done[r.mode]), + ...r.warnings.map((w) => h('p', { class: 'notice warning' }, t.warning[w])), + actions, + ); + if (trashRow) this.main.append(trashRow); + this.main.append(status, this.anotherButton()); + } + + private download(name: string, mime: string): void { + const url = URL.createObjectURL(new Blob([this.result!.data], { type: mime })); + const a = h('a', { href: url, download: name }); + document.body.append(a); + a.click(); + a.remove(); + setTimeout(() => URL.revokeObjectURL(url), 30_000); + } + + // ---------------------------------------------------------------- helpers + + private anotherButton(): HTMLElement { + return h('button', { type: 'button', class: 'link', onclick: () => this.renderPick() }, t.another); + } + + private busy(text: string): void { + clear(this.main); + this.main.append(h('p', { class: 'status', role: 'status', 'aria-live': 'polite' }, text)); + } + + /** Drop references to file contents and wipe the decrypted copy. */ + private reset(): void { + window.clearInterval(this.cooldownTimer); + if (this.result) new Uint8Array(this.result.data).fill(0); + this.result = null; + this.source = null; + } +} diff --git a/web/src/ui/dom.ts b/web/src/ui/dom.ts new file mode 100644 index 0000000..e00b140 --- /dev/null +++ b/web/src/ui/dom.ts @@ -0,0 +1,23 @@ +type Child = Node | string | null | undefined | false; +type Attrs = Record; + +/** Tiny DOM builder. Text is always inserted as text nodes – never as HTML. */ +export function h( + tag: K, + attrs: Attrs = {}, + ...children: Child[] +): HTMLElementTagNameMap[K] { + const el = document.createElement(tag); + for (const [k, v] of Object.entries(attrs)) { + if (v === undefined || v === false) continue; + if (k.startsWith('on') && typeof v === 'function') el.addEventListener(k.slice(2), v); + else if (v === true) el.setAttribute(k, ''); + else el.setAttribute(k, String(v)); + } + for (const c of children) if (c !== null && c !== undefined && c !== false) el.append(c); + return el; +} + +export function clear(el: Element): void { + el.replaceChildren(); +} diff --git a/web/src/ui/mark.ts b/web/src/ui/mark.ts new file mode 100644 index 0000000..138ec33 --- /dev/null +++ b/web/src/ui/mark.ts @@ -0,0 +1,13 @@ +import markSmall from '../../../design/unpassword/mark-small.svg?raw'; + +/** The unpassword mark as inline SVG (fills with currentColor). Parsed from our own bundled asset. */ +export function mark(size: number): SVGSVGElement { + const doc = new DOMParser().parseFromString(markSmall, 'image/svg+xml'); + const svg = document.importNode(doc.documentElement, true) as unknown as SVGSVGElement; + svg.setAttribute('width', String(size)); + svg.setAttribute('height', String(size)); + svg.setAttribute('aria-hidden', 'true'); + svg.removeAttribute('role'); + svg.removeAttribute('aria-label'); + return svg; +} diff --git a/web/src/unlocker.ts b/web/src/unlocker.ts new file mode 100644 index 0000000..038f32f --- /dev/null +++ b/web/src/unlocker.ts @@ -0,0 +1,38 @@ +import type { UnlockFailure, UnlockOutcome, WorkerRequest, WorkerResponse } from './protocol'; + +export class UnlockFailed extends Error { + constructor(readonly failure: UnlockFailure) { + super(failure.message); + } +} + +/** Main-thread handle to the decryption worker. */ +export class Unlocker { + private readonly worker = new Worker(new URL('./worker.ts', import.meta.url), { type: 'module' }); + private nextId = 1; + private readonly pending = new Map void; reject: (e: Error) => void }>(); + + constructor() { + this.worker.onmessage = (ev: MessageEvent) => { + const p = this.pending.get(ev.data.id); + if (!p) return; + this.pending.delete(ev.data.id); + if (ev.data.ok) p.resolve(ev.data.result); + else p.reject(new UnlockFailed(ev.data.error)); + }; + this.worker.onerror = (ev) => { + for (const p of this.pending.values()) p.reject(new Error(ev.message || 'worker error')); + this.pending.clear(); + }; + } + + unlock(encrypted: Uint8Array, password: string): Promise { + const id = this.nextId++; + const copy = encrypted.slice().buffer as ArrayBuffer; + const req: WorkerRequest = { id, data: copy, password }; + return new Promise((resolve, reject) => { + this.pending.set(id, { resolve, reject }); + this.worker.postMessage(req, [copy]); + }); + } +} diff --git a/web/src/worker.ts b/web/src/worker.ts new file mode 100644 index 0000000..afcbe1c --- /dev/null +++ b/web/src/worker.ts @@ -0,0 +1,44 @@ +/// +/** + * The only place where passwords and decrypted content are processed. The + * worker makes no network requests beyond loading its own WASM asset. + */ +import wasmUrl from '@neslinesli93/qpdf-wasm/dist/qpdf.wasm?url'; +import { setQpdfWasmLocation } from './core/pdf/qpdf'; +import { UnlockSession } from './core/session'; +import { UnpasswordError } from './core/types'; +import type { WorkerRequest, WorkerResponse } from './protocol'; + +// Resolve against the worker's own URL; Emscripten fetches it from this origin. +setQpdfWasmLocation(new URL(wasmUrl, self.location.href).href); + +const session = new UnlockSession(); +const scope = self as unknown as DedicatedWorkerGlobalScope; + +scope.onmessage = async (ev: MessageEvent) => { + const { id, data, password } = ev.data; + const input = new Uint8Array(data); + try { + const result = await session.attempt(input, password); + // Transfer a buffer that holds exactly the result, never a larger backing store. + const exact = + result.data.byteOffset === 0 && result.data.byteLength === result.data.buffer.byteLength + ? result.data + : result.data.slice(); + const buffer = exact.buffer as ArrayBuffer; + const msg: WorkerResponse = { + id, + ok: true, + result: { format: result.format, mode: result.mode, warnings: result.warnings, data: buffer }, + }; + scope.postMessage(msg, [buffer]); + } catch (e) { + const err = + e instanceof UnpasswordError + ? { code: e.code, message: e.message, retryAfterMs: e.retryAfterMs, remainingAttempts: e.remainingAttempts } + : { code: 'corrupt' as const, message: e instanceof Error ? e.message : String(e) }; + scope.postMessage({ id, ok: false, error: err } satisfies WorkerResponse); + } finally { + input.fill(0); + } +}; diff --git a/web/tests/detect.test.ts b/web/tests/detect.test.ts new file mode 100644 index 0000000..6598ab6 --- /dev/null +++ b/web/tests/detect.test.ts @@ -0,0 +1,26 @@ +import { describe, expect, it } from 'vitest'; +import { detectFormat } from '../src/core/detect'; +import { fixture } from './helpers'; + +describe('detectFormat', () => { + it.each([ + ['pdf/plain.pdf', 'pdf'], + ['pdf/restricted-aes256.pdf', 'pdf'], + ['office/agile.docx', 'ooxml'], + ['office/standard.docx', 'ooxml'], + ['office/plain.docx', 'zip'], + ['zip/aes.zip', 'zip'], + ['zip/zipcrypto.zip', 'zip'], + ])('%s → %s', (file, format) => { + expect(detectFormat(fixture(file))).toBe(format); + }); + + it('rejects unknown data', () => { + expect(detectFormat(new TextEncoder().encode('hello world'))).toBeNull(); + }); + + it('finds %PDF- after leading junk', () => { + const data = new Uint8Array([...new TextEncoder().encode('junk\n'), ...fixture('pdf/plain.pdf')]); + expect(detectFormat(data)).toBe('pdf'); + }); +}); diff --git a/web/tests/dump.test.ts b/web/tests/dump.test.ts new file mode 100644 index 0000000..ae18027 --- /dev/null +++ b/web/tests/dump.test.ts @@ -0,0 +1,40 @@ +/** + * Writes unlocked outputs to $UNPASSWORD_DUMP for an independent cross-check + * with other tools (scripts/crosscheck.py). Skipped unless the variable is set. + */ +import { mkdirSync, writeFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { beforeAll, describe, it } from 'vitest'; +import { unlock } from '../src/core/index'; +import { PW, fixture, useNodeQpdf } from './helpers'; + +const dir = process.env.UNPASSWORD_DUMP; + +const cases: [string, string][] = [ + ['pdf/user-aes256.pdf', PW.pdfUser], + ['pdf/restricted-aes256.pdf', PW.pdfUser], + ['pdf/restricted-aes128.pdf', PW.pdfUser], + ['pdf/restricted-rc4.pdf', PW.pdfUser], + ['pdf/restricted-rc4.pdf', PW.pdfOwner], + ['pdf/owner-only.pdf', PW.pdfOwner], + ['office/agile.docx', PW.office], + ['office/standard.docx', PW.officeStandard], + ['office/office-agile.docx', PW.officeStandard], + ['office/office-agile.xlsx', PW.officeStandard], + ['zip/zipcrypto.zip', PW.zip], + ['zip/aes.zip', PW.zip], + ['zip/partial.zip', PW.zip], +]; + +describe.skipIf(!dir)('dump unlocked outputs', () => { + beforeAll(() => { + useNodeQpdf(); + mkdirSync(dir!, { recursive: true }); + }); + it.each(cases)('%s', async (file, password) => { + const r = await unlock(fixture(file), password); + const which = password === PW.pdfOwner ? 'owner' : 'user'; + const name = `${file.replace('/', '__')}.${which}.${r.mode}`; + writeFileSync(join(dir!, name), r.data); + }); +}); diff --git a/web/tests/fixtures/README.md b/web/tests/fixtures/README.md new file mode 100644 index 0000000..6360f08 --- /dev/null +++ b/web/tests/fixtures/README.md @@ -0,0 +1,24 @@ +# Test fixtures + +Generated by `scripts/gen-fixtures.py` (except `office/standard.docx`, see below). +All passwords are test values and intentionally public. + +| File | Password(s) | Notes | +|---|---|---| +| `pdf/plain.pdf` | – | not encrypted | +| `pdf/user-aes256.pdf` | user `user-Pässwort1`, owner `owner-Pässwort2` | AES-256 (R6), no restrictions | +| `pdf/restricted-aes256.pdf` | user `user-Pässwort1`, owner `owner-Pässwort2` | AES-256 (R6); no extract, low-res print only, no assembly, no other modification | +| `pdf/restricted-aes128.pdf` | same | AES-128 (R4), same restrictions | +| `pdf/restricted-rc4.pdf` | same | RC4-128 (R3), same restrictions | +| `pdf/owner-only.pdf` | owner `owner-Pässwort2` (empty user password) | opens without password, restrictions only | +| `office/plain.docx` | – | minimal unencrypted DOCX | +| `office/agile.docx` | `Büro-Geheim 42` | ECMA-376 Agile (msoffcrypto-tool) | +| `office/standard.docx` | `Password1234_` | ECMA-376 Standard; taken from the msoffcrypto-tool test suite (MIT) | +| `zip/plain.zip` | – | not encrypted | +| `zip/zipcrypto.zip` | `zip-Geheim3` | traditional PKWARE encryption (`zip -P`) | +| `zip/aes.zip` | `zip-Geheim3` | WinZip AES-256 | +| `zip/partial.zip` | `zip-Geheim3` | one plain entry, one AES entry | +| `zip/mixed.zip` | `zip-Geheim3` / `something-else` | entries with different passwords – must be rejected | +| `office/office-agile.docx` | `Password1234_` | ECMA-376 Agile written by Microsoft Office; from the msoffcrypto-tool test suite (MIT) | +| `office/office-agile.xlsx` | `Password1234_` | same, spreadsheet | + diff --git a/web/tests/fixtures/office/agile.docx b/web/tests/fixtures/office/agile.docx new file mode 100644 index 0000000..f8ee26a Binary files /dev/null and b/web/tests/fixtures/office/agile.docx differ diff --git a/web/tests/fixtures/office/office-agile.docx b/web/tests/fixtures/office/office-agile.docx new file mode 100644 index 0000000..e36bff9 Binary files /dev/null and b/web/tests/fixtures/office/office-agile.docx differ diff --git a/web/tests/fixtures/office/office-agile.xlsx b/web/tests/fixtures/office/office-agile.xlsx new file mode 100644 index 0000000..08946a6 Binary files /dev/null and b/web/tests/fixtures/office/office-agile.xlsx differ diff --git a/web/tests/fixtures/office/plain.docx b/web/tests/fixtures/office/plain.docx new file mode 100644 index 0000000..1b02db8 Binary files /dev/null and b/web/tests/fixtures/office/plain.docx differ diff --git a/web/tests/fixtures/office/standard.docx b/web/tests/fixtures/office/standard.docx new file mode 100644 index 0000000..81030b5 Binary files /dev/null and b/web/tests/fixtures/office/standard.docx differ diff --git a/web/tests/fixtures/pdf/owner-only.pdf b/web/tests/fixtures/pdf/owner-only.pdf new file mode 100644 index 0000000..9798c72 Binary files /dev/null and b/web/tests/fixtures/pdf/owner-only.pdf differ diff --git a/web/tests/fixtures/pdf/plain.pdf b/web/tests/fixtures/pdf/plain.pdf new file mode 100644 index 0000000..d2ae8ba Binary files /dev/null and b/web/tests/fixtures/pdf/plain.pdf differ diff --git a/web/tests/fixtures/pdf/restricted-aes128.pdf b/web/tests/fixtures/pdf/restricted-aes128.pdf new file mode 100644 index 0000000..dcaf1a6 Binary files /dev/null and b/web/tests/fixtures/pdf/restricted-aes128.pdf differ diff --git a/web/tests/fixtures/pdf/restricted-aes256.pdf b/web/tests/fixtures/pdf/restricted-aes256.pdf new file mode 100644 index 0000000..d5ad137 Binary files /dev/null and b/web/tests/fixtures/pdf/restricted-aes256.pdf differ diff --git a/web/tests/fixtures/pdf/restricted-rc4.pdf b/web/tests/fixtures/pdf/restricted-rc4.pdf new file mode 100644 index 0000000..b23e1ca Binary files /dev/null and b/web/tests/fixtures/pdf/restricted-rc4.pdf differ diff --git a/web/tests/fixtures/pdf/user-aes256.pdf b/web/tests/fixtures/pdf/user-aes256.pdf new file mode 100644 index 0000000..2d8239a Binary files /dev/null and b/web/tests/fixtures/pdf/user-aes256.pdf differ diff --git a/web/tests/fixtures/zip/aes.zip b/web/tests/fixtures/zip/aes.zip new file mode 100644 index 0000000..9fe8bcc Binary files /dev/null and b/web/tests/fixtures/zip/aes.zip differ diff --git a/web/tests/fixtures/zip/mixed.zip b/web/tests/fixtures/zip/mixed.zip new file mode 100644 index 0000000..43e481e Binary files /dev/null and b/web/tests/fixtures/zip/mixed.zip differ diff --git a/web/tests/fixtures/zip/partial.zip b/web/tests/fixtures/zip/partial.zip new file mode 100644 index 0000000..dc8b376 Binary files /dev/null and b/web/tests/fixtures/zip/partial.zip differ diff --git a/web/tests/fixtures/zip/plain.zip b/web/tests/fixtures/zip/plain.zip new file mode 100644 index 0000000..93002e0 Binary files /dev/null and b/web/tests/fixtures/zip/plain.zip differ diff --git a/web/tests/fixtures/zip/zipcrypto.zip b/web/tests/fixtures/zip/zipcrypto.zip new file mode 100644 index 0000000..29f928a Binary files /dev/null and b/web/tests/fixtures/zip/zipcrypto.zip differ diff --git a/web/tests/guard.test.ts b/web/tests/guard.test.ts new file mode 100644 index 0000000..e084993 --- /dev/null +++ b/web/tests/guard.test.ts @@ -0,0 +1,57 @@ +import { describe, expect, it } from 'vitest'; +import { AttemptGuard } from '../src/core/guard'; +import { UnpasswordError } from '../src/core/types'; + +function setup() { + let now = 0; + const guard = new AttemptGuard(undefined, () => now); + return { guard, advance: (ms: number) => (now += ms) }; +} + +function code(fn: () => void): string | null { + try { + fn(); + return null; + } catch (e) { + return (e as UnpasswordError).code; + } +} + +describe('AttemptGuard', () => { + it('allows two failures without delay, then backs off exponentially', () => { + const { guard, advance } = setup(); + guard.recordFailure('f'); + expect(code(() => guard.assertAllowed('f'))).toBeNull(); + guard.recordFailure('f'); + expect(code(() => guard.assertAllowed('f'))).toBeNull(); + + expect(guard.recordFailure('f').retryAfterMs).toBe(5_000); + expect(code(() => guard.assertAllowed('f'))).toBe('cooldown'); + advance(5_000); + expect(code(() => guard.assertAllowed('f'))).toBeNull(); + + expect(guard.recordFailure('f').retryAfterMs).toBe(10_000); + advance(9_999); + expect(code(() => guard.assertAllowed('f'))).toBe('cooldown'); + advance(1); + expect(guard.recordFailure('f').retryAfterMs).toBe(20_000); + }); + + it('locks after ten failures for the rest of the session', () => { + const { guard, advance } = setup(); + for (let i = 0; i < 10; i++) { + guard.recordFailure('f'); + advance(10 ** 9); + } + expect(guard.status('f')).toMatchObject({ locked: true, remaining: 0 }); + expect(code(() => guard.assertAllowed('f'))).toBe('locked'); + }); + + it('tracks files independently and resets on success', () => { + const { guard } = setup(); + for (let i = 0; i < 3; i++) guard.recordFailure('a'); + expect(code(() => guard.assertAllowed('b'))).toBeNull(); + guard.recordSuccess('a'); + expect(guard.status('a').failures).toBe(0); + }); +}); diff --git a/web/tests/guardrails.test.ts b/web/tests/guardrails.test.ts new file mode 100644 index 0000000..1d1b08b --- /dev/null +++ b/web/tests/guardrails.test.ts @@ -0,0 +1,62 @@ +/** + * Static guardrails: unpassword must never grow features that guess or + * enumerate passwords, persist secrets or talk to third parties. + */ +import { readFileSync, readdirSync, statSync } from 'node:fs'; +import { join, relative } from 'node:path'; +import { describe, expect, it } from 'vitest'; + +const SRC = join(import.meta.dirname, '..', 'src'); + +function files(dir: string): string[] { + return readdirSync(dir).flatMap((n) => { + const p = join(dir, n); + return statSync(p).isDirectory() ? files(p) : p.endsWith('.ts') ? [p] : []; + }); +} + +const sources = files(SRC).map((p) => ({ path: relative(SRC, p), text: readFileSync(p, 'utf8') })); + +describe('guardrails', () => { + it.each([ + // zip.js password-candidate / prompt-loop features (filesystem API) + [/\bpasswords\s*:/, 'zip.js password candidate lists'], + [/\brequestPassword\b/, 'zip.js password request loops'], + [/@zip\.js\/zip\.js\/.*fs|\bzip\.fs\b|\bfs\.ZipFS\b/, 'zip.js filesystem API'], + [/recovereduserpassword/i, 'recovering user passwords from owner passwords'], + [/wordlist|dictionary attack|brute.?force/i, 'password guessing'], + [/hashcat|john ?the ?ripper/i, 'exporting crackable hashes'], + ])('source contains no %s (%s)', (pattern) => { + const hits = sources.filter((s) => pattern.test(s.text)).map((s) => s.path); + expect(hits).toEqual([]); + }); + + it('core never touches the network', () => { + const hits = sources + .filter((s) => s.path.startsWith('core')) + .filter((s) => /\bfetch\(|XMLHttpRequest|WebSocket|sendBeacon|EventSource/.test(s.text)) + .map((s) => s.path); + expect(hits).toEqual([]); + }); + + it('network access is confined to the Google API module', () => { + const hits = sources + .filter((s) => /\bfetch\(/.test(s.text)) + .map((s) => s.path) + .filter((p) => p !== 'google/drive.ts'); + expect(hits).toEqual([]); + }); + + it('only Google endpoints are referenced', () => { + const urls = sources.flatMap((s) => [...s.text.matchAll(/https:\/\/[^\s'"`)]+/g)].map((m) => m[0])); + const foreign = urls.filter( + (u) => + !/^https:\/\/(www\.googleapis\.com|accounts\.google\.com|apis\.google\.com|docs\.google\.com|drive\.google\.com)\//.test( + u, + ) && + !/^https:\/\/schemas\.(microsoft|openxmlformats)\.(com|org)\//.test(u) && + u !== 'https://github.com/nullthrone/unpassword', + ); + expect(foreign).toEqual([]); + }); +}); diff --git a/web/tests/helpers.ts b/web/tests/helpers.ts new file mode 100644 index 0000000..66f3fb7 --- /dev/null +++ b/web/tests/helpers.ts @@ -0,0 +1,22 @@ +import { readFileSync } from 'node:fs'; +import { createRequire } from 'node:module'; +import { join } from 'node:path'; +import { setQpdfWasmLocation } from '../src/core/pdf/qpdf'; + +const require = createRequire(import.meta.url); + +export function fixture(path: string): Uint8Array { + return new Uint8Array(readFileSync(join(import.meta.dirname, 'fixtures', path))); +} + +export function useNodeQpdf(): void { + setQpdfWasmLocation(require.resolve('@neslinesli93/qpdf-wasm/dist/qpdf.wasm')); +} + +export const PW = { + pdfUser: 'user-Pässwort1', + pdfOwner: 'owner-Pässwort2', + office: 'Büro-Geheim 42', + officeStandard: 'Password1234_', + zip: 'zip-Geheim3', +} as const; diff --git a/web/tests/office.test.ts b/web/tests/office.test.ts new file mode 100644 index 0000000..ecfa9ff --- /dev/null +++ b/web/tests/office.test.ts @@ -0,0 +1,87 @@ +import { describe, expect, it } from 'vitest'; +import { unlockOoxml } from '../src/core/office/index'; +import { UnpasswordError } from '../src/core/types'; +import { PW, fixture } from './helpers'; + +async function errorCode(p: Promise): Promise { + try { + await p; + } catch (e) { + if (e instanceof UnpasswordError) return e.code; + throw e; + } + throw new Error('expected an error'); +} + +function indexOf(hay: Uint8Array, needle: Uint8Array): number { + outer: for (let i = 0; i + needle.length <= hay.length; i++) { + for (let j = 0; j < needle.length; j++) if (hay[i + j] !== needle[j]) continue outer; + return i; + } + return -1; +} + +/** Offset of the EncryptedPackage stream: it starts with its plaintext size as uint64 LE. */ +function locate(data: Uint8Array, size: number): number { + const header = new Uint8Array(8); + new DataView(header.buffer).setUint32(0, size, true); + const at = indexOf(data, header); + if (at < 0) throw new Error('EncryptedPackage not found'); + return at; +} + +function containsAscii(data: Uint8Array, text: string): boolean { + return new TextDecoder('latin1').decode(data).includes(text); +} + +describe('unlockOoxml', () => { + it.each(['office/office-agile.docx', 'office/office-agile.xlsx'])( + 'decrypts Agile encryption written by Microsoft Office (%s) with a valid integrity HMAC', + async (file) => { + const r = await unlockOoxml(fixture(file), PW.officeStandard); + expect(r).toMatchObject({ format: 'ooxml', mode: 'decrypted', warnings: [] }); + expect(containsAscii(r.data, '[Content_Types].xml')).toBe(true); + }, + ); + + it('decrypts Agile encryption with a non-ASCII password byte-exactly', async () => { + const r = await unlockOoxml(fixture('office/agile.docx'), PW.office); + expect(r.data).toEqual(fixture('office/plain.docx')); + expect(r.warnings).toEqual([]); + }); + + it('decrypts ECMA-376 Standard encryption', async () => { + const r = await unlockOoxml(fixture('office/standard.docx'), PW.officeStandard); + expect(Array.from(r.data.subarray(0, 4))).toEqual([0x50, 0x4b, 0x03, 0x04]); + expect(containsAscii(r.data, '[Content_Types].xml')).toBe(true); + }); + + it.each(['office/agile.docx', 'office/office-agile.docx', 'office/standard.docx'])( + '%s rejects a wrong password', + async (file) => { + expect(await errorCode(unlockOoxml(fixture(file), 'wrong'))).toBe('wrong-password'); + }, + ); + + it('detects tampering via the Agile data integrity HMAC', async () => { + const data = fixture('office/office-agile.docx'); + const r = await unlockOoxml(data, PW.officeStandard); + expect(r.warnings).toEqual([]); + // flip one byte of the EncryptedPackage ciphertext + const marker = locate(data, r.data.length); + data[marker + 2000] ^= 0xff; + const tampered = await unlockOoxml(data, PW.officeStandard).catch((e: UnpasswordError) => e); + if (tampered instanceof UnpasswordError) expect(tampered.code).toBe('corrupt'); + else expect(tampered.warnings).toEqual(['integrity-check-failed']); + }); + + it('rejects non-OOXML compound files', async () => { + const data = fixture('office/standard.docx'); + // break the stream name "EncryptionInfo" in the directory + const name = new Uint8Array([...'EncryptionInfo'].flatMap((c) => [c.charCodeAt(0), 0])); + const at = indexOf(data, name); + expect(at).toBeGreaterThan(0); + data[at] = 'X'.charCodeAt(0); + expect(await errorCode(unlockOoxml(data, PW.officeStandard))).toBe('unsupported'); + }); +}); diff --git a/web/tests/pdf-password.test.ts b/web/tests/pdf-password.test.ts new file mode 100644 index 0000000..bb05c11 --- /dev/null +++ b/web/tests/pdf-password.test.ts @@ -0,0 +1,17 @@ +import { describe, expect, it } from 'vitest'; +import { passwordEncodings, toPdfDocEncoding } from '../src/core/pdf/password'; + +describe('PDF password encodings', () => { + it('encodes Latin-1 and PDFDoc specials', () => { + expect(Array.from(toPdfDocEncoding('a䀕')!)).toEqual([0x61, 0xe4, 0xa0, 0x80]); + }); + + it('returns null for unrepresentable characters', () => { + expect(toPdfDocEncoding('密码')).toBeNull(); + }); + + it('produces distinct encodings of the same input only', () => { + expect(passwordEncodings('abc')).toEqual(['616263']); + expect(passwordEncodings('ä')).toEqual(['c3a4', 'e4']); + }); +}); diff --git a/web/tests/pdf-policy.test.ts b/web/tests/pdf-policy.test.ts new file mode 100644 index 0000000..30395f6 --- /dev/null +++ b/web/tests/pdf-policy.test.ts @@ -0,0 +1,78 @@ +import { describe, expect, it } from 'vitest'; +import { + decidePdfAction, + restrictionsPreserved, + type PdfCapabilities, + type PdfEncryptionInfo, +} from '../src/core/pdf/policy'; + +const ALL: PdfCapabilities = { + accessibility: true, + extract: true, + modify: true, + modifyannotations: true, + modifyassembly: true, + modifyforms: true, + modifyother: true, + printhigh: true, + printlow: true, +}; +const RESTRICTED: PdfCapabilities = { ...ALL, extract: false, printhigh: false, modify: false }; + +const info = (p: Partial): PdfEncryptionInfo => ({ + encrypted: true, + userPasswordMatched: false, + ownerPasswordMatched: false, + capabilities: ALL, + ...p, +}); + +describe('decidePdfAction', () => { + it('user password, no restrictions → decrypt', () => { + expect(decidePdfAction(info({ userPasswordMatched: true }), false)).toEqual({ kind: 'decrypt' }); + }); + + it('user password, restrictions → remove open password only, keep restrictions', () => { + expect(decidePdfAction(info({ userPasswordMatched: true, capabilities: RESTRICTED }), false)).toEqual({ + kind: 'preserve-restrictions', + capabilities: RESTRICTED, + }); + }); + + it('owner password → decrypt, whatever the restrictions', () => { + expect(decidePdfAction(info({ ownerPasswordMatched: true, capabilities: RESTRICTED }), false)).toEqual({ + kind: 'decrypt', + }); + expect(decidePdfAction(info({ ownerPasswordMatched: true, capabilities: RESTRICTED }), true)).toEqual({ + kind: 'decrypt', + }); + }); + + it('owner-only file without owner password → refused', () => { + expect(decidePdfAction(info({ userPasswordMatched: true, capabilities: RESTRICTED }), true)).toEqual({ + kind: 'refuse', + reason: 'owner-password-required', + }); + expect(decidePdfAction(info({ userPasswordMatched: true }), true)).toEqual({ + kind: 'refuse', + reason: 'owner-password-required', + }); + }); + + it('wrong password → refused', () => { + expect(decidePdfAction(null, false)).toEqual({ kind: 'refuse', reason: 'wrong-password' }); + expect(decidePdfAction(info({}), false)).toEqual({ kind: 'refuse', reason: 'wrong-password' }); + }); + + it('unencrypted → refused', () => { + expect(decidePdfAction(info({ encrypted: false }), true)).toEqual({ kind: 'refuse', reason: 'not-encrypted' }); + }); +}); + +describe('restrictionsPreserved', () => { + it('detects a lost restriction', () => { + expect(restrictionsPreserved(RESTRICTED, RESTRICTED)).toBe(true); + expect(restrictionsPreserved(RESTRICTED, { ...RESTRICTED, extract: true })).toBe(false); + expect(restrictionsPreserved(RESTRICTED, { ...RESTRICTED, printlow: false })).toBe(true); + }); +}); diff --git a/web/tests/pdf.test.ts b/web/tests/pdf.test.ts new file mode 100644 index 0000000..d969749 --- /dev/null +++ b/web/tests/pdf.test.ts @@ -0,0 +1,75 @@ +import { beforeAll, describe, expect, it } from 'vitest'; +import { unlockPdf } from '../src/core/pdf/index'; +import { inspectEncryption } from '../src/core/pdf/qpdf'; +import { UnpasswordError } from '../src/core/types'; +import { PW, fixture, useNodeQpdf } from './helpers'; + +beforeAll(useNodeQpdf); + +async function errorCode(p: Promise): Promise { + try { + await p; + } catch (e) { + if (e instanceof UnpasswordError) return e.code; + throw e; + } + throw new Error('expected an error'); +} + +describe('unlockPdf', () => { + it('fully decrypts with the user password when there are no restrictions', async () => { + const r = await unlockPdf(fixture('pdf/user-aes256.pdf'), PW.pdfUser); + expect(r.mode).toBe('decrypted'); + expect((await inspectEncryption(r.data, ''))?.encrypted).toBe(false); + }); + + it.each(['restricted-aes256.pdf', 'restricted-aes128.pdf', 'restricted-rc4.pdf'])( + '%s: user password removes only the open password and keeps restrictions', + async (file) => { + const original = await inspectEncryption(fixture(`pdf/${file}`), PW.pdfUser); + const r = await unlockPdf(fixture(`pdf/${file}`), PW.pdfUser); + expect(r.mode).toBe('open-password-removed'); + const after = await inspectEncryption(r.data, ''); + expect(after).toMatchObject({ encrypted: true, userPasswordMatched: true, ownerPasswordMatched: false }); + expect(after?.capabilities.extract).toBe(false); + expect(after?.capabilities.printhigh).toBe(false); + expect(after?.capabilities.modifyassembly).toBe(false); + expect(after?.capabilities.modifyother).toBe(false); + expect(after?.capabilities.printlow).toBe(original?.capabilities.printlow); + // the original owner password does not control the new file + expect((await inspectEncryption(r.data, PW.pdfOwner))?.ownerPasswordMatched ?? false).toBe(false); + }, + ); + + it.each(['restricted-aes256.pdf', 'restricted-aes128.pdf', 'restricted-rc4.pdf', 'owner-only.pdf'])( + '%s: owner password fully decrypts', + async (file) => { + const r = await unlockPdf(fixture(`pdf/${file}`), PW.pdfOwner); + expect(r.mode).toBe('decrypted'); + expect((await inspectEncryption(r.data, ''))?.encrypted).toBe(false); + }, + ); + + it('accepts the password regardless of how the producer encoded it', async () => { + // R3/R4 fixtures store PDFDocEncoding bytes, R6 stores UTF-8 + for (const f of ['restricted-rc4.pdf', 'restricted-aes128.pdf', 'restricted-aes256.pdf']) { + expect((await inspectEncryption(fixture(`pdf/${f}`), PW.pdfUser))?.userPasswordMatched).toBe(true); + // decomposed umlaut (NFD) is the same typed password + expect((await inspectEncryption(fixture(`pdf/${f}`), PW.pdfUser.normalize('NFD')))?.userPasswordMatched).toBe( + true, + ); + } + }); + + it('rejects a wrong password', async () => { + expect(await errorCode(unlockPdf(fixture('pdf/restricted-aes256.pdf'), 'wrong'))).toBe('wrong-password'); + }); + + it('refuses to lift owner-only restrictions without the owner password', async () => { + expect(await errorCode(unlockPdf(fixture('pdf/owner-only.pdf'), 'anything'))).toBe('wrong-password'); + }); + + it('reports unencrypted files', async () => { + expect(await errorCode(unlockPdf(fixture('pdf/plain.pdf'), 'x'))).toBe('not-encrypted'); + }); +}); diff --git a/web/tests/session.test.ts b/web/tests/session.test.ts new file mode 100644 index 0000000..5ac50c7 --- /dev/null +++ b/web/tests/session.test.ts @@ -0,0 +1,53 @@ +import { beforeAll, describe, expect, it } from 'vitest'; +import { AttemptGuard } from '../src/core/guard'; +import { UnlockSession } from '../src/core/session'; +import { UnpasswordError } from '../src/core/types'; +import { PW, fixture, useNodeQpdf } from './helpers'; + +beforeAll(useNodeQpdf); + +async function error(p: Promise): Promise { + try { + await p; + } catch (e) { + if (e instanceof UnpasswordError) return e; + throw e; + } + throw new Error('expected an error'); +} + +describe('UnlockSession', () => { + it('unlocks with the right password', async () => { + const s = new UnlockSession(); + expect((await s.attempt(fixture('zip/aes.zip'), PW.zip)).format).toBe('zip'); + }); + + it('rejects an empty password without counting it', async () => { + const s = new UnlockSession(); + expect((await error(s.attempt(fixture('zip/aes.zip'), ''))).code).toBe('empty-password'); + }); + + it('rate limits wrong passwords per file and eventually locks', async () => { + let now = 0; + const s = new UnlockSession(new AttemptGuard(undefined, () => now)); + const data = fixture('zip/aes.zip'); + + const e1 = await error(s.attempt(data, 'a')); + expect(e1).toMatchObject({ code: 'wrong-password', remainingAttempts: 9, retryAfterMs: 0 }); + await error(s.attempt(data, 'b')); + const e3 = await error(s.attempt(data, 'c')); + expect(e3).toMatchObject({ code: 'wrong-password', retryAfterMs: 5_000 }); + + // even the right password is refused during the cooldown + expect((await error(s.attempt(data, PW.zip))).code).toBe('cooldown'); + + for (let i = 0; i < 6; i++) { + now += 10 ** 9; + await error(s.attempt(data, `x${i}`)); + } + now += 10 ** 9; + expect((await error(s.attempt(data, 'last'))).code).toBe('locked'); + now += 10 ** 9; + expect((await error(s.attempt(data, PW.zip))).code).toBe('locked'); + }); +}); diff --git a/web/tests/zip.test.ts b/web/tests/zip.test.ts new file mode 100644 index 0000000..7f54cd6 --- /dev/null +++ b/web/tests/zip.test.ts @@ -0,0 +1,70 @@ +import { Uint8ArrayReader, Uint8ArrayWriter, ZipReader } from '@zip.js/zip.js'; +import { describe, expect, it } from 'vitest'; +import { UnpasswordError } from '../src/core/types'; +import { unlockZip } from '../src/core/zip/index'; +import { PW, fixture } from './helpers'; + +async function errorCode(p: Promise): Promise { + try { + await p; + } catch (e) { + if (e instanceof UnpasswordError) return e.code; + throw e; + } + throw new Error('expected an error'); +} + +async function contents(zip: Uint8Array): Promise> { + const reader = new ZipReader(new Uint8ArrayReader(zip)); + const out: Record = {}; + for (const e of await reader.getEntries()) { + if (e.directory) continue; + const data = await e.getData(new Uint8ArrayWriter()); + out[e.filename] = { encrypted: e.encrypted, text: new TextDecoder().decode(data) }; + } + await reader.close(); + return out; +} + +describe('unlockZip', () => { + it.each(['zip/zipcrypto.zip', 'zip/aes.zip'])('%s → unencrypted archive with identical content', async (file) => { + const r = await unlockZip(fixture(file), PW.zip); + expect(r).toMatchObject({ format: 'zip', mode: 'decrypted' }); + const got = await contents(r.data); + const expected = await contents(fixture('zip/plain.zip')); + expect(Object.keys(got).sort()).toEqual(Object.keys(expected).sort()); + for (const [name, entry] of Object.entries(got)) { + expect(entry.encrypted).toBe(false); + expect(entry.text).toBe(expected[name].text); + } + }); + + it('keeps unencrypted entries of partially encrypted archives', async () => { + const got = await contents((await unlockZip(fixture('zip/partial.zip'), PW.zip)).data); + expect(got).toEqual({ + 'public.txt': { encrypted: false, text: 'not secret' }, + 'secret.txt': { encrypted: false, text: 'secret' }, + }); + }); + + it.each(['zip/zipcrypto.zip', 'zip/aes.zip'])('%s rejects a wrong password', async (file) => { + expect(await errorCode(unlockZip(fixture(file), 'wrong'))).toBe('wrong-password'); + }); + + it('rejects ZipCrypto wrong passwords that pass the 1-byte check', async () => { + // Over many wrong passwords, ~1/256 pass ZipCrypto's check byte; all must still fail. + const data = fixture('zip/zipcrypto.zip'); + for (let i = 0; i < 600; i++) { + expect(await errorCode(unlockZip(data, `wrong-${i}`))).toBe('wrong-password'); + } + }); + + it('rejects archives whose entries use different passwords', async () => { + expect(await errorCode(unlockZip(fixture('zip/mixed.zip'), PW.zip))).toBe('mixed-passwords'); + }); + + it('reports unencrypted archives', async () => { + expect(await errorCode(unlockZip(fixture('zip/plain.zip'), 'x'))).toBe('not-encrypted'); + expect(await errorCode(unlockZip(fixture('office/plain.docx'), 'x'))).toBe('not-encrypted'); + }); +}); diff --git a/web/tsconfig.json b/web/tsconfig.json new file mode 100644 index 0000000..68a3a86 --- /dev/null +++ b/web/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "Bundler", + "lib": ["ES2023", "DOM", "DOM.Iterable", "WebWorker"], + "types": ["vite/client", "node"], + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noImplicitOverride": true, + "isolatedModules": true, + "skipLibCheck": true, + "noEmit": true, + "resolveJsonModule": true + }, + "include": ["src", "tests", "e2e", "vite.config.ts", "playwright.config.ts"] +} diff --git a/web/vite.config.ts b/web/vite.config.ts new file mode 100644 index 0000000..d9979ad --- /dev/null +++ b/web/vite.config.ts @@ -0,0 +1,49 @@ +import { defineConfig, type Plugin } from 'vitest/config'; + +/** + * Content Security Policy for the built site. The browser may only talk to + * this origin and to Google's APIs; everything else – including any attempt + * to send file contents or passwords elsewhere – is blocked by the browser. + * (Not applied to the dev server, whose HMR needs inline scripts.) + */ +export const CSP = [ + "default-src 'self'", + "script-src 'self' 'wasm-unsafe-eval' https://accounts.google.com https://apis.google.com", + "style-src 'self' 'unsafe-inline' https://accounts.google.com", + "img-src 'self' data: https://*.googleusercontent.com https://ssl.gstatic.com https://www.gstatic.com", + "connect-src 'self' https://www.googleapis.com https://content.googleapis.com https://accounts.google.com", + 'frame-src https://accounts.google.com https://docs.google.com https://drive.google.com https://content.googleapis.com', + "worker-src 'self'", + "object-src 'none'", + "base-uri 'none'", + "form-action 'none'", +].join('; '); + +function csp(): Plugin { + return { + name: 'unpassword-csp', + apply: 'build', + transformIndexHtml: (html) => + html.replace( + '', + `\n `, + ), + }; +} + +export default defineConfig({ + base: './', + plugins: [csp()], + // design tokens, fonts and the mark live in ../design (shared with the docs site) + server: { fs: { allow: ['..'] } }, + build: { + target: 'es2022', + sourcemap: false, + assetsInlineLimit: 0, + }, + worker: { format: 'es' }, + test: { + include: ['tests/**/*.test.ts'], + testTimeout: 60_000, + }, +});